ATLAS Offline Software
Loading...
Searching...
No Matches
TauolaPP.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
7
8// Tauola header files
9#include "Tauola/Log.h"
10#include "Tauola/Tauola.h"
11#ifdef HEPMC3
12#include "Tauola/TauolaHepMC3Event.h"
13namespace Tauolapp
14{
15using TauolaHepMCEvent=TauolaHepMC3Event;
16using TauolaHepMCParticle=TauolaHepMC3Particle;
17}
18#else
19#include "Tauola/TauolaHepMCEvent.h"
20#endif
21
22#include "Tauola/f_Variables.h"
23
24// for proper seeding
25#include "CLHEP/Random/RandFlat.h"
27
28// Pointer to random engine
29CLHEP::HepRandomEngine* TauolaPP::p_rndmEngine = nullptr;
30
31double AthenaRandomGenerator ATLAS_NOT_THREAD_SAFE ()
32{
33 return CLHEP::RandFlat::shoot(TauolaPP::p_rndmEngine);
34}
35
36
37// Constructor
38TauolaPP::TauolaPP(const std::string& name, ISvcLocator* pSvcLocator)
39 : AthAlgorithm(name, pSvcLocator)
40{
41}
42
43
45
46 ATH_CHECK(m_rndmSvc.retrieve());
48 const long* sip = p_rndmEngine->getSeeds();
49
50 // Setup and intialise Tauola Interface
51 using Tauolapp::Tauola;
52 Tauola::setSameParticleDecayMode(m_decay_mode_same);
53 Tauola::setOppositeParticleDecayMode(m_decay_mode_opp);
54 // etc.... see Tauola.h for the full list of configurables
55 // Note: some need to be set before (or after) calling Tauola::initialize();
56
57 // Tauola::setHiggsScalarPseudoscalarMixingAngle(atof(argv[5]));
58 // Tauola::setHiggsScalarPseudoscalarPDG(25);
59
60 Tauola::initialize();
61
62 Tauola::setEtaK0sPi(1,0,1); // switches to decay eta K0_S and pi0 1/0 on/off.
63 Tauola::spin_correlation.setAll(m_spin_correlation);
64 Tauola::setRadiation(m_setRadiation);
65 Tauola::setRadiationCutOff(m_setRadiationCutOff);
66
67 //call RanLux generator for ++ part of Tauola
68 Tauola::setRandomGenerator(AthenaRandomGenerator);
69
70 //seeding tauola-fortran generator
71 // See tauola.f: the first parameter should be positive int <900000000
72 Tauola::setSeed(int(std::abs(sip[0])%(900000000)),0,0);
73
74 //setting tau mass
75 Tauolapp::parmas_.amtau=m_tau_mass;
76
77 return StatusCode::SUCCESS;
78}
79
80
81void TauolaPP::reseedRandomEngine(const std::string& streamName, const EventContext& ctx)
82{
83 long seeds[7];
84 ATHRNG::calculateSeedsMC21(seeds, streamName, ctx.eventID().event_number(), m_dsid, m_randomSeed);
85 p_rndmEngine->setSeeds(seeds, 0); // NOT THREAD-SAFE
86}
87
88
89CLHEP::HepRandomEngine* TauolaPP::getRandomEngine(const std::string& streamName, unsigned long int randomSeedOffset,
90 const EventContext& ctx) const
91{
92 ATHRNG::RNGWrapper* rngWrapper = m_rndmSvc->getEngine(this, streamName);
93 rngWrapper->setSeed( streamName, ctx.slot(), randomSeedOffset, ctx.eventID().run_number() );
94 return rngWrapper->getEngine(ctx);
95}
96
97
98CLHEP::HepRandomEngine* TauolaPP::getRandomEngineDuringInitialize(const std::string& streamName, unsigned long int randomSeedOffset, unsigned int conditionsRun, unsigned int lbn) const
99{
100 const size_t slot=0;
101 EventContext ctx;
102 ctx.setSlot( slot );
103 ctx.setEventID (EventIDBase (conditionsRun,
104 EventIDBase::UNDEFEVT, // event
105 EventIDBase::UNDEFNUM, // timestamp
106 EventIDBase::UNDEFNUM, // timestamp ns
107 lbn));
109 Atlas::ExtendedEventContext( evtStore()->hiveProxyDict(),
110 conditionsRun) );
111 return getRandomEngine(streamName, randomSeedOffset, ctx);
112}
113
114
115StatusCode TauolaPP::execute() {
116
117 //Re-seed the random number stream
118 const EventContext& ctx = Gaudi::Hive::currentContext();
119 reseedRandomEngine("TAUOLAPP", ctx);
120
121 // Load HepMC info
122 // FIXME should be using Read/WriteHandles here
123 const McEventCollection* mcCollptr_const;
124 ATH_CHECK( evtStore()->retrieve(mcCollptr_const, m_key) );
125 // Const_cast to make an event possible to update
126 McEventCollection* mcCollptr = const_cast<McEventCollection*>(mcCollptr_const);
127
128 // Loop over all events in McEventCollection
129 for (HepMC::GenEvent* evt : *mcCollptr) {
130 // Convert event record to format readable by tauola interface
131 auto t_event = new Tauolapp::TauolaHepMCEvent(evt);
132
133 // remove tau decays first
134 t_event->undecayTaus();
135 // decay taus
136 t_event->decayTaus();
137 // t_event->getEvent()->print();
138 }
139
140 return StatusCode::SUCCESS;
141}
#define ATH_CHECK
Evaluate an expression and check for errors.
double AthenaRandomGenerator ATLAS_NOT_THREAD_SAFE()
Install fatal handler with default options.
Definition TauolaPP.cxx:31
A wrapper class for event-slot-local random engines.
Definition RNGWrapper.h:56
void setSeed(const std::string &algName, const EventContext &ctx)
Set the random seed using a string (e.g.
Definition RNGWrapper.h:169
CLHEP::HepRandomEngine * getEngine(const EventContext &ctx) const
Retrieve the random engine corresponding to the provided EventContext.
Definition RNGWrapper.h:134
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
This defines the McEventCollection, which is really just an ObjectVector of McEvent objectsFile: Gene...
virtual StatusCode initialize() override
Initialization of Tauola++ and setting of JO configurables.
Definition TauolaPP.cxx:44
CLHEP::HepRandomEngine * getRandomEngine(const std::string &streamName, unsigned long int randomSeedOffset, const EventContext &ctx) const
Definition TauolaPP.cxx:89
StringProperty m_key
Event record container key - FIXME should be using Read/WriteHandles here.
Definition TauolaPP.h:47
TauolaPP(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition TauolaPP.cxx:38
ServiceHandle< IAthRNGSvc > m_rndmSvc
Definition TauolaPP.h:50
BooleanProperty m_setRadiation
TAUOLA switch for radiative corrections for leptonic tau decays.
Definition TauolaPP.h:77
CLHEP::HepRandomEngine * getRandomEngineDuringInitialize(const std::string &streamName, unsigned long int randomSeedOffset, unsigned int conditionsRun=1, unsigned int lbn=1) const
Definition TauolaPP.cxx:98
IntegerProperty m_decay_mode_opp
TAUOLA decay mode of particles with opposite charge as "decay_particle".
Definition TauolaPP.h:68
virtual StatusCode execute() override
Pass each event in the McEventCollection to Tauola to (re)decay the taus.
Definition TauolaPP.cxx:115
void reseedRandomEngine(const std::string &streamName, const EventContext &ctx)
Definition TauolaPP.cxx:81
IntegerProperty m_decay_mode_same
TAUOLA decay mode of particles with same charge as "decay_particle".
Definition TauolaPP.h:65
DoubleProperty m_tau_mass
tau mass to be taken by TAUOLA
Definition TauolaPP.h:71
DoubleProperty m_setRadiationCutOff
TAUOLA cut-off for radiative corrections.
Definition TauolaPP.h:80
IntegerProperty m_randomSeed
Seed for random number engine.
Definition TauolaPP.h:56
IntegerProperty m_dsid
Definition TauolaPP.h:53
static CLHEP::HepRandomEngine * p_rndmEngine
Definition TauolaPP.h:35
BooleanProperty m_spin_correlation
TAUOLA switch for spin effects.
Definition TauolaPP.h:74
void calculateSeedsMC21(long *seeds, const std::string &algName, uint64_t ev, uint64_t run, uint64_t offset=0)
Set the random seed using a string (e.g.
void setExtendedEventContext(EventContext &ctx, ExtendedEventContext &&ectx)
Move an extended context into a context object.