ATLAS Offline Software
EvtInclusiveDecay.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //*****************************************************************************
6 //
7 // Generators/EvtGen_i/EvtInclusiveDecay.h
8 //
9 // EvtInclusiveDecay is a TopAlg that takes HepMC events from StoreGate and
10 // generates particle decays using EvtGen. Depending on job options either all or
11 // only a subset of the particles which have decays defined in the EvtGen
12 // decay files will be handed to EvtGen. Both undecayed particles and particles
13 // with an existing decay tree can be handled (in the latter case,
14 // EvtInclusiveDecay will remove the existing decay tree).
15 //
16 // Written in February 2006 by Juerg Beringer, based in part on the existing
17 // EvtDecay module.
18 //
19 //*****************************************************************************
20 
21 #ifndef GENERATORMODULESEVTDECAYINCLUSIVE_H
22 #define GENERATORMODULESEVTDECAYINCLUSIVE_H
23 
24 #include "AtlasHepMC/GenEvent.h"
25 #include "AtlasHepMC/GenParticle.h"
26 
27 #include "HepPDT/ParticleDataTable.hh"
28 
29 #include "EvtGenBase/EvtParticle.hh"
30 #include "EvtGen/EvtGen.hh"
31 #include "EvtGenBase/EvtRandomEngine.hh"
32 
34 //#include "AthenaBaseComps/AthAlgorithm.h"
35 #include "GaudiKernel/ISvcLocator.h"
36 
39 
40 namespace CLHEP {
41  class HepRandomEngine;
42 };
43 
44 class EvtInclusiveAtRndmGen : public EvtRandomEngine {
45 public:
46  EvtInclusiveAtRndmGen(CLHEP::HepRandomEngine* engine);
47  virtual ~EvtInclusiveAtRndmGen() = default;
48  double random();
49  CLHEP::HepRandomEngine* getEngine() { return m_engine; }
50 private:
51  CLHEP::HepRandomEngine* m_engine{};
52 };
53 
54 
55 
56 class EvtInclusiveDecay:public GenBase {
57 
58 public:
59  EvtInclusiveDecay(const std::string& name, ISvcLocator* pSvcLocator);
60  virtual ~EvtInclusiveDecay();
61 
65  std::string xmlpath(void);
66 private:
67 
69 
70  void reseedRandomEngine(const std::string& streamName, const EventContext& ctx);
71  CLHEP::HepRandomEngine* getRandomEngine(const std::string& streamName, unsigned long int randomSeedOffset, const EventContext& ctx) const;
72  CLHEP::HepRandomEngine* getRandomEngineDuringInitialize(const std::string& streamName, unsigned long int randomSeedOffset, unsigned int conditionsRun=1, unsigned int lbn=1) const;
74 
75 #ifdef HEPMC3
77  bool isToBeRemoved,
78  std::set<HepMC::GenVertexPtr>& visited,
79  std::set<HepMC::GenParticlePtr>& toBeDecayed);
80 #else
82  bool isToBeRemoved,
83  std::set<HepMC::GenVertexPtr>& visited,
84  std::set<int>& toBeDecayed);
85 #endif
86  void removeDecayTree(HepMC::GenEvent* hepMC, HepMC::GenParticlePtr p);
87  void decayParticle(HepMC::GenEvent* hepMC, HepMC::GenParticlePtr p);
88  void addEvtGenDecayTree(HepMC::GenEvent* hepMC, HepMC::GenParticlePtr part,
89  EvtParticle* evtPart, EvtVector4R treeStart, double momentumScaleFactor = 1.0);
90 
91  bool isToBeDecayed(HepMC::ConstGenParticlePtr p, bool doCrossChecks);
92  bool isDefaultB(const int pId) const;
93 
94  bool passesUserSelection(HepMC::GenEvent* hepMC);
96 
97  // Utility functions to print HepMC record for debugging with optional
98  // coloring by status code and highlighting of particles in a specific list of barcodes
99 #ifdef HEPMC3
100  void printHepMC(HepMC::GenEvent* hepMC, std::set<HepMC::GenParticlePtr>* barcodeList = nullptr);
101  unsigned int printTree(HepMC::GenParticlePtr p, std::set<HepMC::GenVertexPtr>& visited, int level, std::set<HepMC::GenParticlePtr>* barcodeList = nullptr);
102  std::string pdgName(HepMC::ConstGenParticlePtr p, bool statusHighlighting = false, std::set<HepMC::GenParticlePtr>* barcodeList = nullptr);
103 #else
104  void printHepMC(HepMC::GenEvent* hepMC, std::set<int>* barcodeList = nullptr);
105  unsigned int printTree(HepMC::GenParticlePtr p, std::set<HepMC::GenVertexPtr>& visited,
106  int level, std::set<int>* barcodeList = 0);
107  std::string pdgName(HepMC::ConstGenParticlePtr p, bool statusHighlighting = false, std::set<int>* barcodeList = nullptr);
108 #endif
109 
110  // Random number service
111  ServiceHandle<IAthRNGSvc> m_rndmSvc{this, "RndmSvc", "AthRNGSvc"};
112 
113  //Gen_tf run args.
114  IntegerProperty m_dsid{this, "Dsid", 999999};
115 
117  IntegerProperty m_randomSeed{this, "RandomSeed", 1234567, "Random seed for the built-in random engine"}; // FIXME make this into an unsigned long int?
118 
120 
121  // EvtGen interface
123  EvtGen* m_myEvtGen{};
124 
125  // jobOption params
126  std::string m_pdtFile;
127  std::string m_decayFile;
128  std::string m_userDecayFile;
129  std::string m_randomStreamName;
130  std::string m_inputKeyName;
131  std::string m_outputKeyName;
132 
138  std::vector<int> m_blackList;
139  std::set<int> m_blackListSet; // filed from m_blackList for speed optimization
140 
143  std::vector<int> m_whiteList;
144  std::set<int> m_whiteListSet; // filed from m_whilteList for speed optimization
145 
150 
153  std::map<int,long> m_noDecayChannels;
154 
156 
158 
169 };
170 
171 #endif
EvtInclusiveDecay::m_checkDecayTree
bool m_checkDecayTree
Definition: EvtInclusiveDecay.h:151
LArG4FSStartPointFilter.part
part
Definition: LArG4FSStartPointFilter.py:21
EvtInclusiveDecay::isDefaultB
bool isDefaultB(const int pId) const
Definition: EvtInclusiveDecay.cxx:643
EvtInclusiveDecay::m_randomStreamName
std::string m_randomStreamName
Definition: EvtInclusiveDecay.h:129
EvtInclusiveDecay::m_allowDefaultBDecays
bool m_allowDefaultBDecays
Definition: EvtInclusiveDecay.h:142
EvtInclusiveDecay::m_maxNRepeatedDecays
int m_maxNRepeatedDecays
Definition: EvtInclusiveDecay.h:157
GenEvent.h
EvtInclusiveDecay::m_whiteList
std::vector< int > m_whiteList
Definition: EvtInclusiveDecay.h:143
EvtInclusiveDecay::m_allowAllKnownDecays
bool m_allowAllKnownDecays
Definition: EvtInclusiveDecay.h:141
EvtInclusiveDecay::m_blackList
std::vector< int > m_blackList
Definition: EvtInclusiveDecay.h:138
EvtInclusiveDecay::m_userSelMinDimuMass
double m_userSelMinDimuMass
Definition: EvtInclusiveDecay.h:165
EvtInclusiveDecay::m_noDecayChannels
std::map< int, long > m_noDecayChannels
Definition: EvtInclusiveDecay.h:153
EvtInclusiveDecay::m_blackListSet
std::set< int > m_blackListSet
Definition: EvtInclusiveDecay.h:139
EvtInclusiveDecay::reseedRandomEngine
void reseedRandomEngine(const std::string &streamName, const EventContext &ctx)
Definition: EvtInclusiveDecay.cxx:182
EvtInclusiveDecay::decayParticle
void decayParticle(HepMC::GenEvent *hepMC, HepMC::GenParticlePtr p)
Definition: EvtInclusiveDecay.cxx:490
HepMC::GenParticlePtr
GenParticle * GenParticlePtr
Definition: GenParticle.h:37
TRTCalib_cfilter.p1
p1
Definition: TRTCalib_cfilter.py:130
EvtInclusiveDecay::passesUserSelection
bool passesUserSelection(HepMC::GenEvent *hepMC)
Definition: EvtInclusiveDecay.cxx:665
EvtInclusiveDecay::m_applyUserSelection
bool m_applyUserSelection
Definition: EvtInclusiveDecay.h:159
EvtInclusiveDecay::getRandomEngineDuringInitialize
CLHEP::HepRandomEngine * getRandomEngineDuringInitialize(const std::string &streamName, unsigned long int randomSeedOffset, unsigned int conditionsRun=1, unsigned int lbn=1) const
Definition: EvtInclusiveDecay.cxx:200
EvtInclusiveDecay::m_userDecayFile
std::string m_userDecayFile
Definition: EvtInclusiveDecay.h:128
EvtInclusiveDecay::isToBeDecayed
bool isToBeDecayed(HepMC::ConstGenParticlePtr p, bool doCrossChecks)
Definition: EvtInclusiveDecay.cxx:566
EvtInclusiveDecay::m_printHepMCHighLightTopLevelDecays
bool m_printHepMCHighLightTopLevelDecays
Definition: EvtInclusiveDecay.h:149
EvtInclusiveDecay::m_userSelMu2MaxEta
double m_userSelMu2MaxEta
Definition: EvtInclusiveDecay.h:164
EvtInclusiveDecay::m_decayFile
std::string m_decayFile
Definition: EvtInclusiveDecay.h:127
EvtInclusiveDecay::m_evtAtRndmGen
EvtInclusiveAtRndmGen * m_evtAtRndmGen
Definition: EvtInclusiveDecay.h:122
EvtInclusiveDecay::m_printHepMCHighlighted
bool m_printHepMCHighlighted
Definition: EvtInclusiveDecay.h:148
GenParticle.h
EvtInclusiveDecay::m_isfHerwig
bool m_isfHerwig
Definition: EvtInclusiveDecay.h:167
EvtInclusiveAtRndmGen::getEngine
CLHEP::HepRandomEngine * getEngine()
Definition: EvtInclusiveDecay.h:49
EvtInclusiveDecay::m_printHepMCAfterEvtGen
bool m_printHepMCAfterEvtGen
Definition: EvtInclusiveDecay.h:147
EvtInclusiveDecay::addEvtGenDecayTree
void addEvtGenDecayTree(HepMC::GenEvent *hepMC, HepMC::GenParticlePtr part, EvtParticle *evtPart, EvtVector4R treeStart, double momentumScaleFactor=1.0)
Definition: EvtInclusiveDecay.cxx:528
EvtInclusiveDecay::m_readExisting
bool m_readExisting
Definition: EvtInclusiveDecay.h:133
python.iconfTool.models.loaders.level
level
Definition: loaders.py:20
TRTCalib_cfilter.p2
p2
Definition: TRTCalib_cfilter.py:131
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
GenBase
Base class for common behaviour of MC truth algorithms.
Definition: GenBase.h:47
McEventCollection.h
EvtInclusiveDecay::invMass
double invMass(HepMC::ConstGenParticlePtr p1, HepMC::ConstGenParticlePtr p2)
Definition: EvtInclusiveDecay.cxx:695
EvtInclusiveDecay::getRandomEngine
CLHEP::HepRandomEngine * getRandomEngine(const std::string &streamName, unsigned long int randomSeedOffset, const EventContext &ctx) const
Definition: EvtInclusiveDecay.cxx:191
EvtInclusiveDecay::m_pdtFile
std::string m_pdtFile
Definition: EvtInclusiveDecay.h:126
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
EvtInclusiveDecay::m_userSelMu1MinPt
double m_userSelMu1MinPt
Definition: EvtInclusiveDecay.h:161
CLHEP
STD'S.
Definition: IAtRndmGenSvc.h:19
EvtInclusiveDecay::m_checkDecayChannels
bool m_checkDecayChannels
Definition: EvtInclusiveDecay.h:152
EvtInclusiveDecay::removeDecayTree
void removeDecayTree(HepMC::GenEvent *hepMC, HepMC::GenParticlePtr p)
Definition: EvtInclusiveDecay.cxx:446
EvtInclusiveAtRndmGen::~EvtInclusiveAtRndmGen
virtual ~EvtInclusiveAtRndmGen()=default
EvtInclusiveDecay::m_dsid
IntegerProperty m_dsid
Definition: EvtInclusiveDecay.h:114
EvtInclusiveDecay::m_userSelMu1MaxEta
double m_userSelMu1MaxEta
Definition: EvtInclusiveDecay.h:163
EvtInclusiveDecay::traverseDecayTree
StatusCode traverseDecayTree(HepMC::GenParticlePtr p, bool isToBeRemoved, std::set< HepMC::GenVertexPtr > &visited, std::set< int > &toBeDecayed)
Definition: EvtInclusiveDecay.cxx:388
EvtInclusiveDecay::m_randomSeed
IntegerProperty m_randomSeed
Seed for random number engine.
Definition: EvtInclusiveDecay.h:117
EvtInclusiveDecay::printHepMC
void printHepMC(HepMC::GenEvent *hepMC, std::set< int > *barcodeList=nullptr)
Definition: EvtInclusiveDecay.cxx:737
EvtInclusiveDecay
Definition: EvtInclusiveDecay.h:56
McEventCollection
This defines the McEventCollection, which is really just an ObjectVector of McEvent objects.
Definition: McEventCollection.h:33
EvtInclusiveDecay::m_userSelRequireOppositeSignedMu
bool m_userSelRequireOppositeSignedMu
Definition: EvtInclusiveDecay.h:160
EvtInclusiveDecay::execute
StatusCode execute()
Definition: EvtInclusiveDecay.cxx:217
HepMC::ConstGenParticlePtr
const GenParticle * ConstGenParticlePtr
Definition: GenParticle.h:38
EvtInclusiveDecay::printTree
unsigned int printTree(HepMC::GenParticlePtr p, std::set< HepMC::GenVertexPtr > &visited, int level, std::set< int > *barcodeList=0)
Definition: EvtInclusiveDecay.cxx:787
GenBase.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
EvtInclusiveDecay::m_prohibitFinalStateDecay
bool m_prohibitFinalStateDecay
Definition: EvtInclusiveDecay.h:134
EvtInclusiveDecay::pdgName
std::string pdgName(HepMC::ConstGenParticlePtr p, bool statusHighlighting=false, std::set< int > *barcodeList=nullptr)
Definition: EvtInclusiveDecay.cxx:845
EvtInclusiveAtRndmGen::EvtInclusiveAtRndmGen
EvtInclusiveAtRndmGen(CLHEP::HepRandomEngine *engine)
Definition: EvtInclusiveDecay.cxx:872
EvtInclusiveDecay::m_prohibitRemoveSelfDecay
bool m_prohibitRemoveSelfDecay
Definition: EvtInclusiveDecay.h:137
EvtInclusiveDecay::m_rndmSvc
ServiceHandle< IAthRNGSvc > m_rndmSvc
Definition: EvtInclusiveDecay.h:111
EvtInclusiveDecay::EvtInclusiveDecay
EvtInclusiveDecay(const std::string &name, ISvcLocator *pSvcLocator)
Definition: EvtInclusiveDecay.cxx:56
EvtInclusiveDecay::m_mcEvtColl
McEventCollection * m_mcEvtColl
Definition: EvtInclusiveDecay.h:119
EvtInclusiveAtRndmGen::m_engine
CLHEP::HepRandomEngine * m_engine
Definition: EvtInclusiveDecay.h:51
EvtInclusiveDecay::m_prohibitUnDecay
bool m_prohibitUnDecay
Definition: EvtInclusiveDecay.h:136
AthenaPoolExample_Copy.streamName
string streamName
Definition: AthenaPoolExample_Copy.py:39
EvtInclusiveDecay::m_myEvtGen
EvtGen * m_myEvtGen
Definition: EvtInclusiveDecay.h:123
EvtInclusiveAtRndmGen::random
double random()
Definition: EvtInclusiveDecay.cxx:876
EvtInclusiveDecay::m_nRepeatedDecays
int m_nRepeatedDecays
Definition: EvtInclusiveDecay.h:155
EvtInclusiveDecay::xmlpath
std::string xmlpath(void)
Definition: EvtInclusiveDecay.cxx:882
EvtInclusiveDecay::m_setVMtransversePol
bool m_setVMtransversePol
Definition: EvtInclusiveDecay.h:168
EvtInclusiveDecay::m_printHepMCBeforeEvtGen
bool m_printHepMCBeforeEvtGen
Definition: EvtInclusiveDecay.h:146
EvtInclusiveDecay::m_outputKeyName
std::string m_outputKeyName
Definition: EvtInclusiveDecay.h:131
EvtInclusiveDecay::m_userSelMaxDimuMass
double m_userSelMaxDimuMass
Definition: EvtInclusiveDecay.h:166
EvtInclusiveDecay::m_inputKeyName
std::string m_inputKeyName
Definition: EvtInclusiveDecay.h:130
EvtInclusiveDecay::~EvtInclusiveDecay
virtual ~EvtInclusiveDecay()
Definition: EvtInclusiveDecay.cxx:111
EvtInclusiveDecay::m_userSelMu2MinPt
double m_userSelMu2MinPt
Definition: EvtInclusiveDecay.h:162
EvtInclusiveDecay::m_prohibitReDecay
bool m_prohibitReDecay
Definition: EvtInclusiveDecay.h:135
EvtInclusiveDecay::initialize
StatusCode initialize()
Definition: EvtInclusiveDecay.cxx:118
EvtInclusiveDecay::finalize
StatusCode finalize()
Definition: EvtInclusiveDecay.cxx:349
EvtInclusiveDecay::m_whiteListSet
std::set< int > m_whiteListSet
Definition: EvtInclusiveDecay.h:144
EvtInclusiveAtRndmGen
Definition: EvtInclusiveDecay.h:44
IAthRNGSvc.h
ServiceHandle< IAthRNGSvc >