ATLAS Offline Software
Loading...
Searching...
No Matches
EvtInclusiveDecay.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 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"
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 "GaudiKernel/ISvcLocator.h"
35
38
39namespace CLHEP {
40 class HepRandomEngine;
41};
42
43class EvtInclusiveAtRndmGen : public EvtRandomEngine {
44public:
45 EvtInclusiveAtRndmGen(CLHEP::HepRandomEngine* engine);
46 virtual ~EvtInclusiveAtRndmGen() = default;
47 double random();
48 CLHEP::HepRandomEngine* getEngine() { return m_engine; }
49private:
50 CLHEP::HepRandomEngine* m_engine{};
51};
52
53
54
56
57public:
58 EvtInclusiveDecay(const std::string& name, ISvcLocator* pSvcLocator);
59 virtual ~EvtInclusiveDecay();
60
61 StatusCode initialize();
62 StatusCode execute();
63 StatusCode finalize();
64 std::string xmlpath(void);
65 struct ParticleIdCompare {bool operator()(const HepMC::GenParticlePtr& a,const HepMC::GenParticlePtr& b) const {return (a)&&(b)&&(a->momentum().e() < b->momentum().e());}};
66private:
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
76 bool isToBeRemoved,
77 std::set<HepMC::GenVertexPtr>& visited,
78 std::set<HepMC::GenParticlePtr,ParticleIdCompare>& toBeDecayed);
79 void removeDecayTree(HepMC::GenEvent* hepMC, HepMC::GenParticlePtr p);
80 void decayParticle(HepMC::GenEvent* hepMC, HepMC::GenParticlePtr p);
81 void addEvtGenDecayTree(HepMC::GenEvent* hepMC, HepMC::GenParticlePtr part, EvtParticle* evtPart, EvtVector4R treeStart, double momentumScaleFactor = 1.0);
82
83 bool isToBeDecayed(HepMC::ConstGenParticlePtr p, bool doCrossChecks);
84 bool isDefaultB(const int pId) const;
85
86 bool passesUserSelection(HepMC::GenEvent* hepMC);
88
89 // Utility functions to print HepMC record for debugging with optional
90 // coloring by status code and highlighting of particles in a specific list
91 void printHepMC(HepMC::GenEvent* hepMC, std::set<HepMC::GenParticlePtr,ParticleIdCompare>* particleSet = nullptr);
92 unsigned int printTree(HepMC::GenParticlePtr p, std::set<HepMC::GenVertexPtr>& visited, int level, std::set<HepMC::GenParticlePtr,ParticleIdCompare>* particleSet = nullptr);
93 std::string pdgName(HepMC::ConstGenParticlePtr p, bool statusHighlighting = false, std::set<HepMC::GenParticlePtr,ParticleIdCompare>* particleSet = nullptr);
94
95 // Random number service
96 ServiceHandle<IAthRNGSvc> m_rndmSvc{this, "RndmSvc", "AthRNGSvc"};
97
98 //Gen_tf run args.
99 IntegerProperty m_dsid{this, "Dsid", 999999};
100
102 IntegerProperty m_randomSeed{this, "RandomSeed", 1234567, "Random seed for the built-in random engine"}; // FIXME make this into an unsigned long int?
103
105
106 // EvtGen interface
108 EvtGen* m_myEvtGen{};
109
110 // jobOption params
111 std::string m_pdtFile;
112 std::string m_decayFile;
113 std::string m_userDecayFile;
115 std::string m_inputKeyName;
116 std::string m_outputKeyName;
117
123 std::vector<int> m_blackList;
124 std::set<int> m_blackListSet; // filed from m_blackList for speed optimization
125
128 std::vector<int> m_whiteList;
129 std::set<int> m_whiteListSet; // filed from m_whilteList for speed optimization
130
135
138 std::map<int,long> m_noDecayChannels;
139
141
143
154};
155
156#endif
static Double_t a
CLHEP::HepRandomEngine * getEngine()
virtual ~EvtInclusiveAtRndmGen()=default
EvtInclusiveAtRndmGen(CLHEP::HepRandomEngine *engine)
CLHEP::HepRandomEngine * m_engine
void printHepMC(HepMC::GenEvent *hepMC, std::set< HepMC::GenParticlePtr, ParticleIdCompare > *particleSet=nullptr)
CLHEP::HepRandomEngine * getRandomEngine(const std::string &streamName, unsigned long int randomSeedOffset, const EventContext &ctx) const
ServiceHandle< IAthRNGSvc > m_rndmSvc
void removeDecayTree(HepMC::GenEvent *hepMC, HepMC::GenParticlePtr p)
void reseedRandomEngine(const std::string &streamName, const EventContext &ctx)
bool isDefaultB(const int pId) const
std::set< int > m_blackListSet
CLHEP::HepRandomEngine * getRandomEngineDuringInitialize(const std::string &streamName, unsigned long int randomSeedOffset, unsigned int conditionsRun=1, unsigned int lbn=1) const
void addEvtGenDecayTree(HepMC::GenEvent *hepMC, HepMC::GenParticlePtr part, EvtParticle *evtPart, EvtVector4R treeStart, double momentumScaleFactor=1.0)
std::string m_randomStreamName
IntegerProperty m_dsid
StatusCode traverseDecayTree(HepMC::GenParticlePtr p, bool isToBeRemoved, std::set< HepMC::GenVertexPtr > &visited, std::set< HepMC::GenParticlePtr, ParticleIdCompare > &toBeDecayed)
bool passesUserSelection(HepMC::GenEvent *hepMC)
double invMass(HepMC::ConstGenParticlePtr p1, HepMC::ConstGenParticlePtr p2)
McEventCollection * m_mcEvtColl
std::string m_userDecayFile
std::string xmlpath(void)
std::set< int > m_whiteListSet
IntegerProperty m_randomSeed
Seed for random number engine.
std::vector< int > m_blackList
unsigned int printTree(HepMC::GenParticlePtr p, std::set< HepMC::GenVertexPtr > &visited, int level, std::set< HepMC::GenParticlePtr, ParticleIdCompare > *particleSet=nullptr)
std::string m_outputKeyName
bool isToBeDecayed(HepMC::ConstGenParticlePtr p, bool doCrossChecks)
std::string pdgName(HepMC::ConstGenParticlePtr p, bool statusHighlighting=false, std::set< HepMC::GenParticlePtr, ParticleIdCompare > *particleSet=nullptr)
std::map< int, long > m_noDecayChannels
void decayParticle(HepMC::GenEvent *hepMC, HepMC::GenParticlePtr p)
EvtInclusiveAtRndmGen * m_evtAtRndmGen
EvtInclusiveDecay(const std::string &name, ISvcLocator *pSvcLocator)
std::vector< int > m_whiteList
GenBase(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition GenBase.cxx:11
This defines the McEventCollection, which is really just an ObjectVector of McEvent objectsFile: Gene...
GenParticle * GenParticlePtr
Definition GenParticle.h:37
const GenParticle * ConstGenParticlePtr
Definition GenParticle.h:38
bool operator()(const HepMC::GenParticlePtr &a, const HepMC::GenParticlePtr &b) const