cepgen is hosted by Hepforge, IPPP Durham
CepGen 1.2.5
Central exclusive processes event generator
Loading...
Searching...
No Matches
TauolaFilter.cpp
Go to the documentation of this file.
1/*
2 * CepGen: a central exclusive processes event generator
3 * Copyright (C) 2019-2022 Laurent Forthomme
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include <Tauola/Log.h>
20#include <Tauola/Tauola.h>
21#include <Tauola/TauolaEvent.h>
22#include <Tauola/TauolaHepMC3Event.h>
23
26#include "CepGen/Event/Event.h"
29#include "CepGen/Physics/PDG.h"
30#include "CepGen/Utils/String.h"
32
33using namespace Tauolapp;
34
35namespace cepgen {
36 namespace hadr {
38 class TauolaFilter : public EventModifier {
39 public:
40 explicit TauolaFilter(const ParametersList&);
42
43 void initialise() override;
44 bool run(Event& ev, double& weight, bool fast) override;
45
47
48 private:
49 const ParametersList pol_states_, rad_states_;
50 };
51
53 : EventModifier(params),
54 pol_states_(steer<ParametersList>("polarisations")),
55 rad_states_(steer<ParametersList>("radiations")) {
56 if (steer<bool>("debug"))
57 Log::LogAll(true);
58 }
59
60 TauolaFilter::~TauolaFilter() { Log::SummaryAtExit(); }
61
63 Tauola::setUnits(Tauola::GEV, Tauola::MM);
64 Tauola::initialize();
65 Tauola::setSeed(seed_, 2. * seed_, 4. * seed_);
66 Tauola::momentum_conservation_threshold = 1.e-6;
67 if (!Tauola::getIsTauolaIni())
68 throw CG_FATAL("TauolaFilter:init") << "Tauola was not properly initialised!";
69
70 //--- spin correlations
71 if (pol_states_.has<bool>("full"))
72 Tauola::spin_correlation.setAll(pol_states_.get<bool>("full"));
73 pol_states_.fill<bool>("GAMMA", Tauola::spin_correlation.GAMMA);
74 pol_states_.fill<bool>("Z0", Tauola::spin_correlation.Z0);
75 pol_states_.fill<bool>("HIGGS", Tauola::spin_correlation.HIGGS);
76 pol_states_.fill<bool>("HIGGS_H", Tauola::spin_correlation.HIGGS_H);
77 pol_states_.fill<bool>("HIGGS_A", Tauola::spin_correlation.HIGGS_A);
78 pol_states_.fill<bool>("HIGGS_PLUS", Tauola::spin_correlation.HIGGS_PLUS);
79 pol_states_.fill<bool>("HIGGS_MINUS", Tauola::spin_correlation.HIGGS_MINUS);
80 pol_states_.fill<bool>("W_PLUS", Tauola::spin_correlation.W_PLUS);
81 pol_states_.fill<bool>("W_MINUS", Tauola::spin_correlation.W_MINUS);
82
83 //--- radiation states
84 if (rad_states_.has<bool>("enable"))
85 Tauola::setRadiation(rad_states_.get<bool>("enable"));
86 const auto rad_cutoff = rad_states_.get<double>("cutoff", 0.01);
87 if (rad_cutoff > 0.)
88 Tauola::setRadiationCutOff(rad_cutoff); // default energy is 0.01 (in units of half the decaying particle mass)
89
90 //--- default parameters
91 Tauola::setSameParticleDecayMode(steer<int>("sameParticleDecayMode"));
92 Tauola::setOppositeParticleDecayMode(steer<int>("oppositeParticleDecayMode"));
93
94 //--- list of tau decay branching fractions
95 for (const auto& br_per_mode : steer<std::vector<ParametersList> >("branchingRatios")) {
96 const auto mode = br_per_mode.get<int>("mode");
97 const auto br = br_per_mode.get<double>("branchingRatio");
98 Tauola::setTauBr(mode, br);
99 CG_DEBUG("TauolaFilter:init") << "Branching ratio for mode " << mode << " set to " << br << ".";
100 }
101 }
102
103 bool TauolaFilter::run(Event& ev, double& weight, bool /*fast*/) {
104 weight = 1.;
105
106 HepMC3::CepGenEvent hepmc_evt(ev);
107 TauolaHepMC3Event evt(&hepmc_evt);
108 evt.decayTaus();
109 //hepmc_evt.dump();
110 hepmc_evt.merge(ev);
111
112 return true;
113 }
114
116 auto desc = EventModifier::description();
117 desc.setDescription("Tauola interface");
118 desc.add<bool>("debug", false).setDescription("debugging mode");
119
120 auto pol_desc = ParametersDescription();
121 pol_desc.add<bool>("full", true);
122 pol_desc.add<bool>("GAMMA", Tauola::spin_correlation.GAMMA);
123 pol_desc.add<bool>("Z0", Tauola::spin_correlation.Z0);
124 pol_desc.add<bool>("HIGGS", Tauola::spin_correlation.HIGGS);
125 pol_desc.add<bool>("HIGGS_H", Tauola::spin_correlation.HIGGS_H);
126 pol_desc.add<bool>("HIGGS_A", Tauola::spin_correlation.HIGGS_A);
127 pol_desc.add<bool>("HIGGS_PLUS", Tauola::spin_correlation.HIGGS_PLUS);
128 pol_desc.add<bool>("HIGGS_MINUS", Tauola::spin_correlation.HIGGS_MINUS);
129 pol_desc.add<bool>("W_PLUS", Tauola::spin_correlation.W_PLUS);
130 pol_desc.add<bool>("W_MINUS", Tauola::spin_correlation.W_MINUS);
131 desc.add<ParametersDescription>("polarisations", pol_desc);
132
133 auto rad_desc = ParametersDescription();
134 rad_desc.add<bool>("enable", false);
135 rad_desc.add<double>("cutoff", -1.);
136 desc.add<ParametersDescription>("radiations", rad_desc);
137
138 desc.add<int>("sameParticleDecayMode", -1);
139 desc.add<int>("oppositeParticleDecayMode", -1);
140
141 auto br_desc = ParametersDescription();
142 br_desc.add<int>("mode", -1).setDescription("decay mode");
143 br_desc.add<double>("branchingRatio", 0.).setDescription("branching fraction");
144 desc.addParametersDescriptionVector("branchingRatios", br_desc, {});
145 return desc;
146 }
147 } // namespace hadr
148} // namespace cepgen
149
150// register event modifier
#define REGISTER_MODIFIER(name, obj)
Add a generic event modification module definition to the factory.
#define CG_FATAL(mod)
Definition Exception.h:61
#define CG_DEBUG(mod)
Definition Message.h:220
cepgen::hadr::TauolaFilter TauolaFilter
Interfacing between CepGen and HepMC event definitions.
void merge(cepgen::Event &) const
Merge this event with another CepGen event record.
Class template to interface (external/internal) events modification algorithms.
static ParametersDescription description()
long long seed_
Random numbers generator seed fed to the algorithm.
Container for the information on the in- and outgoing particles' kinematics.
Definition Event.h:28
A description object for parameters collection.
ParametersDescription & add(const std::string &name, const T &def)
Add the description to a new parameter.
bool has(const std::string &key) const
Check if a given parameter is handled in this list.
T get(const std::string &key, const T &def=default_arg< T >::get()) const
Get a parameter value.
const ParametersList & fill(const std::string &key, T &value) const
Fill a variable with the key content if exists.
Interface to the Tauola decay routine.
TauolaFilter(const ParametersList &)
bool run(Event &ev, double &weight, bool fast) override
Modify an event.
static ParametersDescription description()
Common namespace for this Monte Carlo generator.