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#include "Tauola/TauolaHepMC3Event.h"
12namespace Tauolapp
13{
14using TauolaHepMCEvent=TauolaHepMC3Event;
15using TauolaHepMCParticle=TauolaHepMC3Particle;
16}
17
18#include "Tauola/f_Variables.h"
19
20// for proper seeding
21#include "CLHEP/Random/RandFlat.h"
23
24// Pointer to random engine
25CLHEP::HepRandomEngine* TauolaPP::p_rndmEngine = nullptr;
26
27double AthenaRandomGenerator ATLAS_NOT_THREAD_SAFE ()
28{
29 return CLHEP::RandFlat::shoot(TauolaPP::p_rndmEngine);
30}
31
32
33// Constructor
34TauolaPP::TauolaPP(const std::string& name, ISvcLocator* pSvcLocator)
35 : AthAlgorithm(name, pSvcLocator)
36{
37}
38
39
41
42 ATH_CHECK(m_rndmSvc.retrieve());
44 const long* sip = p_rndmEngine->getSeeds();
45
46 // Setup and intialise Tauola Interface
47 using Tauolapp::Tauola;
48 Tauola::setSameParticleDecayMode(m_decay_mode_same);
49 Tauola::setOppositeParticleDecayMode(m_decay_mode_opp);
50 // etc.... see Tauola.h for the full list of configurables
51 // Note: some need to be set before (or after) calling Tauola::initialize();
52
53 // Tauola::setHiggsScalarPseudoscalarMixingAngle(atof(argv[5]));
54 // Tauola::setHiggsScalarPseudoscalarPDG(25);
55
56 Tauola::initialize();
57
58 Tauola::setEtaK0sPi(1,0,1); // switches to decay eta K0_S and pi0 1/0 on/off.
59 Tauola::spin_correlation.setAll(m_spin_correlation);
60 Tauola::setRadiation(m_setRadiation);
61 Tauola::setRadiationCutOff(m_setRadiationCutOff);
62
63 //call RanLux generator for ++ part of Tauola
64 Tauola::setRandomGenerator(AthenaRandomGenerator);
65
66 //seeding tauola-fortran generator
67 // See tauola.f: the first parameter should be positive int <900000000
68 Tauola::setSeed(int(std::abs(sip[0])%(900000000)),0,0);
69
70 //setting tau mass
71 Tauolapp::parmas_.amtau=m_tau_mass;
72
73 return StatusCode::SUCCESS;
74}
75
76
77void TauolaPP::reseedRandomEngine(const std::string& streamName, const EventContext& ctx)
78{
79 long seeds[7];
80 ATHRNG::calculateSeedsMC21(seeds, streamName, ctx.eventID().event_number(), m_dsid, m_randomSeed);
81 p_rndmEngine->setSeeds(seeds, 0); // NOT THREAD-SAFE
82}
83
84
85CLHEP::HepRandomEngine* TauolaPP::getRandomEngine(const std::string& streamName, unsigned long int randomSeedOffset,
86 const EventContext& ctx) const
87{
88 ATHRNG::RNGWrapper* rngWrapper = m_rndmSvc->getEngine(this, streamName);
89 rngWrapper->setSeed( streamName, ctx.slot(), randomSeedOffset, ctx.eventID().run_number() );
90 return rngWrapper->getEngine(ctx);
91}
92
93
94CLHEP::HepRandomEngine* TauolaPP::getRandomEngineDuringInitialize(const std::string& streamName, unsigned long int randomSeedOffset, unsigned int conditionsRun, unsigned int lbn) const
95{
96 const size_t slot=0;
97 EventContext ctx;
98 ctx.setSlot( slot );
99 ctx.setEventID (EventIDBase (conditionsRun,
100 EventIDBase::UNDEFEVT, // event
101 EventIDBase::UNDEFNUM, // timestamp
102 EventIDBase::UNDEFNUM, // timestamp ns
103 lbn));
105 Atlas::ExtendedEventContext( evtStore()->hiveProxyDict(),
106 conditionsRun) );
107 return getRandomEngine(streamName, randomSeedOffset, ctx);
108}
109
110
111StatusCode TauolaPP::execute(const EventContext& ctx) {
112
113 //Re-seed the random number stream
114 reseedRandomEngine("TAUOLAPP", ctx);
115
116 // Load HepMC info
117 // FIXME should be using Read/WriteHandles here
118 const McEventCollection* mcCollptr_const;
119 ATH_CHECK( evtStore()->retrieve(mcCollptr_const, m_key) );
120 // Const_cast to make an event possible to update
121 McEventCollection* mcCollptr = const_cast<McEventCollection*>(mcCollptr_const);
122
123 // Loop over all events in McEventCollection
124 for (HepMC::GenEvent* evt : *mcCollptr) {
125 // Convert event record to format readable by tauola interface
126 auto t_event = new Tauolapp::TauolaHepMCEvent(evt);
127
128 // remove tau decays first
129 t_event->undecayTaus();
130 // decay taus
131 t_event->decayTaus();
132 // t_event->getEvent()->print();
133 }
134
135 return StatusCode::SUCCESS;
136}
#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:27
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:154
CLHEP::HepRandomEngine * getEngine(const EventContext &ctx) const
Retrieve the random engine corresponding to the provided EventContext.
Definition RNGWrapper.h:108
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
ServiceHandle< StoreGateSvc > & evtStore()
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:40
CLHEP::HepRandomEngine * getRandomEngine(const std::string &streamName, unsigned long int randomSeedOffset, const EventContext &ctx) const
Definition TauolaPP.cxx:85
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:34
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:94
IntegerProperty m_decay_mode_opp
TAUOLA decay mode of particles with opposite charge as "decay_particle".
Definition TauolaPP.h:68
void reseedRandomEngine(const std::string &streamName, const EventContext &ctx)
Definition TauolaPP.cxx:77
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
virtual StatusCode execute(const EventContext &ctx) override
Pass each event in the McEventCollection to Tauola to (re)decay the taus.
Definition TauolaPP.cxx:111
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.
HepMC3::GenEvent GenEvent
Definition GenEvent.h:39
TauolaHepMC3Event TauolaHepMCEvent
Definition TauolaPP.cxx:14
TauolaHepMC3Particle TauolaHepMCParticle
Definition TauolaPP.cxx:15