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