ATLAS Offline Software
InputConverter.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 #ifndef ISF_INPUTCONVERTER_H
6 #define ISF_INPUTCONVERTER_H 1
7 
8 // STL includes
9 #include <string>
10 // ISF include
12 // FrameWork includes
13 #include "GaudiKernel/ToolHandle.h"
14 #include "GaudiKernel/ServiceHandle.h"
16 
17 namespace HepPDT {
18  class ParticleDataTable;
19 }
23 
24 class IPartPropSvc;
25 class McEventCollection;
26 namespace ISFTesting {
27  class InputConverter_test;
28 }
29 namespace ISF {
30  class ISFParticle;
31  class IGenParticleFilter;
32 }
33 
34 class G4ParticleDefinition;
35 class G4PrimaryParticle;
36 class G4VSolid;
37 
38 namespace ISF {
39 
46  class InputConverter final: public extends<AthService, IInputConverter> {
47 
48  // allow test to access private data
49  friend ISFTesting::InputConverter_test;
50 
51  public:
52  InputConverter(const std::string& name, ISvcLocator* svc);
53  virtual ~InputConverter();
54 
56  virtual StatusCode initialize() override final;
57  virtual StatusCode finalize() override final;
58 
61  virtual StatusCode convert(McEventCollection& inputGenEvents,
62  ISF::ISFParticleContainer& simParticles) const override final;
63 
65  virtual StatusCode convertHepMCToG4Event(const EventContext& ctx, McEventCollection& inputGenEvents,
66  G4Event*& outputG4Event, McEventCollection& shadowGenEvents) const override final;
67 
68  virtual StatusCode convertHepMCToG4EventLegacy(const EventContext& ctx, McEventCollection& inputGenEvents,
69  G4Event*& outputG4Event) const override final;
70 
72  G4Event* ISF_to_G4Event(const EventContext& ctx, const std::vector<ISF::ISFParticle*>& isp, HepMC::GenEvent *genEvent, HepMC::GenEvent *shadowGenEvent=nullptr, bool useHepMC=false) const override final;
73 
74  private:
75 
76  const G4ParticleDefinition* getG4ParticleDefinition(int pdgcode) const;
77 
78 #ifdef HEPMC3
79  G4PrimaryParticle* getDaughterG4PrimaryParticle(const HepMC::ConstGenParticlePtr& gp) const;
80  G4PrimaryParticle* getDaughterG4PrimaryParticle(const HepMC::GenParticlePtr& gp, bool makeLinkToTruth=true) const;
81 #else
82  G4PrimaryParticle* getDaughterG4PrimaryParticle(HepMC::GenParticle& gp, bool makeLinkToTruth=true) const;
83 #endif
84 
85  G4PrimaryParticle* getG4PrimaryParticle(ISF::ISFParticle& isp, bool useHepMC, HepMC::GenEvent *shadowGenEvent) const;
86 
87  void addG4PrimaryVertex(G4Event* g4evt, ISF::ISFParticle& isp, bool useHepMC, HepMC::GenEvent *shadowGenEvent) const;
88 
89 #ifdef HEPMC3
90  void processPredefinedDecays(const HepMC::ConstGenParticlePtr& genpart, ISF::ISFParticle& isp, G4PrimaryParticle* g4particle) const;
91 #endif
92  void processPredefinedDecays(const HepMC::GenParticlePtr& genpart, ISF::ISFParticle& isp, G4PrimaryParticle* g4particle, bool makeLinkToTruth=true) const;
93 
95  const HepMC::ConstGenParticlePtr& p2) const;
96 
97  HepMC::GenParticlePtr findShadowParticle(const HepMC::ConstGenParticlePtr& genParticle, HepMC::GenEvent *shadowGenEvent) const;
98 
100  bool isInsideG4WorldVolume(const ISF::ISFParticle& isp, const G4VSolid* worldSolid) const;
101 
103 #ifdef HEPMC3
104  double getParticleMass(const HepMC::ConstGenParticlePtr& p) const;
105 #else
106  double getParticleMass(const HepMC::GenParticle& p) const;
107 #endif
108 
110  std::vector<HepMC::GenParticlePtr > getSelectedParticles(HepMC::GenEvent& evnt, bool legacyOrdering=false) const;
111 
113 #ifdef HEPMC3
114  bool passesFilters(const HepMC::ConstGenParticlePtr& p) const;
115 #else
116  bool passesFilters(const HepMC::GenParticle& p) const;
117 #endif
118 
120  ISF::ISFParticle* convertParticle(const HepMC::GenParticlePtr& genPartPtr) const;
121 
124  const HepPDT::ParticleDataTable *m_particleDataTable;
125 
127 
128  ToolHandleArray<IGenParticleFilter> m_genParticleFilters;
129 
130  bool m_quasiStableParticlesIncluded; //<! will quasi-stable particles be included in the simulation
131  BooleanProperty m_useShadowEvent{this, "UseShadowEvent", false, "New approach to selecting particles for simulation" };
132 
133  };
134 
135 }
136 
137 
138 #endif //> !ISF_INPUTCONVERTER_H
ISF::ISFParticleContainer
std::list< ISF::ISFParticle * > ISFParticleContainer
generic ISFParticle container (not necessarily a std::list!)
Definition: ISFParticleContainer.h:23
ISF::InputConverter::addG4PrimaryVertex
void addG4PrimaryVertex(G4Event *g4evt, ISF::ISFParticle &isp, bool useHepMC, HepMC::GenEvent *shadowGenEvent) const
Definition: InputConverter.cxx:1142
ISF::InputConverter::getG4ParticleDefinition
const G4ParticleDefinition * getG4ParticleDefinition(int pdgcode) const
Definition: InputConverter.cxx:504
ISF::InputConverter::m_useShadowEvent
BooleanProperty m_useShadowEvent
Definition: InputConverter.h:131
ISF::InputConverter::ISF_to_G4Event
G4Event * ISF_to_G4Event(const EventContext &ctx, const std::vector< ISF::ISFParticle * > &isp, HepMC::GenEvent *genEvent, HepMC::GenEvent *shadowGenEvent=nullptr, bool useHepMC=false) const override final
Converts vector of ISF::ISFParticles to G4Event.
Definition: InputConverter.cxx:469
HepMC::GenParticlePtr
GenParticle * GenParticlePtr
Definition: GenParticle.h:37
TRTCalib_cfilter.p1
p1
Definition: TRTCalib_cfilter.py:130
ISF::ISFParticle
Definition: ISFParticle.h:42
IInputConverter.h
GenParticle_fwd.h
ISF::InputConverter
Definition: InputConverter.h:46
ISF::InputConverter::m_particlePropSvc
ServiceHandle< IPartPropSvc > m_particlePropSvc
ParticlePropertyService and ParticleDataTable.
Definition: InputConverter.h:123
ISF::InputConverter::convertParticle
ISF::ISFParticle * convertParticle(const HepMC::GenParticlePtr &genPartPtr) const
convert GenParticle to ISFParticle
Definition: InputConverter.cxx:283
ISF::InputConverter::processPredefinedDecays
void processPredefinedDecays(const HepMC::GenParticlePtr &genpart, ISF::ISFParticle &isp, G4PrimaryParticle *g4particle, bool makeLinkToTruth=true) const
Definition: InputConverter.cxx:907
ISF::InputConverter::InputConverter
InputConverter(const std::string &name, ISvcLocator *svc)
Constructor.
Definition: InputConverter.cxx:50
ISF::InputConverter::findShadowParticle
HepMC::GenParticlePtr findShadowParticle(const HepMC::ConstGenParticlePtr &genParticle, HepMC::GenEvent *shadowGenEvent) const
Definition: InputConverter.cxx:802
TRTCalib_cfilter.p2
p2
Definition: TRTCalib_cfilter.py:131
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ISF::InputConverter::initialize
virtual StatusCode initialize() override final
Athena algtool Hooks.
Definition: InputConverter.cxx:82
ISF::InputConverter::getG4PrimaryParticle
G4PrimaryParticle * getG4PrimaryParticle(ISF::ISFParticle &isp, bool useHepMC, HepMC::GenEvent *shadowGenEvent) const
Definition: InputConverter.cxx:989
ISF::InputConverter::isInsideG4WorldVolume
bool isInsideG4WorldVolume(const ISF::ISFParticle &isp, const G4VSolid *worldSolid) const
Tests whether the given ISFParticle is within the Geant4 world volume.
Definition: InputConverter.cxx:1173
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
GenEvent_fwd.h
ISF::InputConverter::m_useGeneratedParticleMass
bool m_useGeneratedParticleMass
use GenParticle::generated_mass() in simulation
Definition: InputConverter.h:126
ISF::InputConverter::matchedGenParticles
bool matchedGenParticles(const HepMC::ConstGenParticlePtr &p1, const HepMC::ConstGenParticlePtr &p2) const
Definition: InputConverter.cxx:789
ISF::InputConverter::convert
virtual StatusCode convert(McEventCollection &inputGenEvents, ISF::ISFParticleContainer &simParticles) const override final
Convert selected particles from the given McEventCollection into ISFParticles and push them into the ...
Definition: InputConverter.cxx:117
HepPDT
Definition: BeamHaloGenerator.h:13
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
McEventCollection
This defines the McEventCollection, which is really just an ObjectVector of McEvent objects.
Definition: McEventCollection.h:33
ISF::InputConverter::m_particleDataTable
const HepPDT::ParticleDataTable * m_particleDataTable
PDT used to look up particle masses.
Definition: InputConverter.h:124
HepMC::ConstGenParticlePtr
const GenParticle * ConstGenParticlePtr
Definition: GenParticle.h:38
ISF::InputConverter::getDaughterG4PrimaryParticle
G4PrimaryParticle * getDaughterG4PrimaryParticle(HepMC::GenParticle &gp, bool makeLinkToTruth=true) const
Definition: InputConverter.cxx:701
ISF::InputConverter::m_quasiStableParticlesIncluded
bool m_quasiStableParticlesIncluded
Definition: InputConverter.h:130
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
MagicNumbers.h
ISF::InputConverter::convertHepMCToG4Event
virtual StatusCode convertHepMCToG4Event(const EventContext &ctx, McEventCollection &inputGenEvents, G4Event *&outputG4Event, McEventCollection &shadowGenEvents) const override final
Definition: InputConverter.cxx:155
skel.genpart
tuple genpart
Check that the actual generators, tune, and main PDF are consistent with the JO name.
Definition: skel.ABtoEVGEN.py:262
ISF
ISFParticleOrderedQueue.
Definition: PrimaryParticleInformation.h:13
AthService.h
ISFTesting
Core Athena algorithm for the Integrated Simulation Framework.
Definition: CollectionMerger.h:37
ISF::InputConverter::getSelectedParticles
std::vector< HepMC::GenParticlePtr > getSelectedParticles(HepMC::GenEvent &evnt, bool legacyOrdering=false) const
get all generator particles which pass filters
Definition: InputConverter.cxx:245
ISF::InputConverter::convertHepMCToG4EventLegacy
virtual StatusCode convertHepMCToG4EventLegacy(const EventContext &ctx, McEventCollection &inputGenEvents, G4Event *&outputG4Event) const override final
Definition: InputConverter.cxx:175
ISF::InputConverter::passesFilters
bool passesFilters(const HepMC::GenParticle &p) const
check if the given particle passes all filters
Definition: InputConverter.cxx:442
ISF::InputConverter::~InputConverter
virtual ~InputConverter()
Destructor.
Definition: InputConverter.cxx:75
ISF::InputConverter::getParticleMass
double getParticleMass(const HepMC::GenParticle &p) const
get right GenParticle mass
Definition: InputConverter.cxx:389
ISF::InputConverter::m_genParticleFilters
ToolHandleArray< IGenParticleFilter > m_genParticleFilters
HepMC::GenParticle filters.
Definition: InputConverter.h:128
GenParticle
@ GenParticle
Definition: TruthClasses.h:30
ServiceHandle< IPartPropSvc >
ISF::InputConverter::finalize
virtual StatusCode finalize() override final
Athena algtool Hook.
Definition: InputConverter.cxx:107