ATLAS Offline Software
Loading...
Searching...
No Matches
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// Geant4 includes
13#include <G4Event.hh>
14// FrameWork includes
16#include "GaudiKernel/ServiceHandle.h"
17#include "GaudiKernel/ToolHandle.h"
18
19namespace HepPDT {
20 class ParticleDataTable;
21}
25
26class IPartPropSvc;
28namespace ISFTesting {
29 class InputConverter_test;
30}
31namespace ISF {
32 class ISFParticle;
34}
35
36class G4ParticleDefinition;
37class G4PrimaryParticle;
38class G4VSolid;
39
40namespace ISF {
41
48 class InputConverter final: public extends<AthService, IInputConverter> {
49
50 // allow test to access private data
51 friend ISFTesting::InputConverter_test;
52
53 public:
54 InputConverter(const std::string& name, ISvcLocator* svc);
55 virtual ~InputConverter();
56
58 virtual StatusCode initialize() override final;
59 virtual StatusCode finalize() override final;
60
63 virtual StatusCode convert(McEventCollection& inputGenEvents,
64 ISF::ISFParticleContainer& simParticles) const override final;
65
67 virtual StatusCode convertHepMCToG4Event(
68 McEventCollection& inputGenEvents, G4Event& outputG4Event,
69 McEventCollection& shadowGenEvents) const override final;
70
71 virtual StatusCode convertHepMCToG4EventLegacy(
72 McEventCollection& inputGenEvents,
73 G4Event& outputG4Event) const override final;
74
76 void ISF_to_G4Event(G4Event& event,
77 const std::vector<ISF::ISFParticle*>& isp,
78 HepMC::GenEvent* genEvent,
79 HepMC::GenEvent* shadowGenEvent = nullptr,
80 bool useHepMC = false) const override final;
81
82 private:
83 const G4ParticleDefinition* getG4ParticleDefinition(int pdgcode) const;
84
85#ifdef HEPMC3
86 G4PrimaryParticle* getDaughterG4PrimaryParticle(const HepMC::ConstGenParticlePtr& gp) const;
87 G4PrimaryParticle* getDaughterG4PrimaryParticle(const HepMC::GenParticlePtr& gp, bool makeLinkToTruth=true) const;
88#else
89 G4PrimaryParticle* getDaughterG4PrimaryParticle(HepMC::GenParticle& gp, bool makeLinkToTruth=true) const;
90#endif
91
92 G4PrimaryParticle* getG4PrimaryParticle(ISF::ISFParticle& isp, bool useHepMC, HepMC::GenEvent *shadowGenEvent) const;
93
94 void addG4PrimaryVertex(G4Event& g4evt, ISF::ISFParticle& isp,
95 bool useHepMC,
96 HepMC::GenEvent* shadowGenEvent) const;
97
98#ifdef HEPMC3
99 void processPredefinedDecays(const HepMC::ConstGenParticlePtr& genpart, ISF::ISFParticle& isp, G4PrimaryParticle* g4particle) const;
100#endif
101 void processPredefinedDecays(const HepMC::GenParticlePtr& genpart, ISF::ISFParticle& isp, G4PrimaryParticle* g4particle, bool makeLinkToTruth=true) const;
102
104 const HepMC::ConstGenParticlePtr& p2) const;
105
106 HepMC::GenParticlePtr findShadowParticle(const HepMC::ConstGenParticlePtr& genParticle, HepMC::GenEvent *shadowGenEvent) const;
107
109 bool isInsideG4WorldVolume(const ISF::ISFParticle& isp, const G4VSolid* worldSolid) const;
110
112#ifdef HEPMC3
113 double getParticleMass(const HepMC::ConstGenParticlePtr& p) const;
114#else
115 double getParticleMass(const HepMC::GenParticle& p) const;
116#endif
117
119 std::vector<HepMC::GenParticlePtr > getSelectedParticles(HepMC::GenEvent& evnt, bool legacyOrdering=false) const;
120
122#ifdef HEPMC3
123 bool passesFilters(const HepMC::ConstGenParticlePtr& p) const;
124#else
125 bool passesFilters(const HepMC::GenParticle& p) const;
126#endif
127
130
133 const HepPDT::ParticleDataTable *m_particleDataTable;
134
136
137 ToolHandleArray<IGenParticleFilter> m_genParticleFilters;
138
139 bool m_quasiStableParticlesIncluded; //<! will quasi-stable particles be included in the simulation
140 BooleanProperty m_useShadowEvent{this, "UseShadowEvent", false, "New approach to selecting particles for simulation" };
141
142 };
143
144}
145
146
147#endif //> !ISF_INPUTCONVERTER_H
Interface definition for HepMC::GenParticle filter, these filters should be primarily be used in the ...
The generic ISF particle definition,.
Definition ISFParticle.h:42
InputConverter(const std::string &name, ISvcLocator *svc)
Constructor.
virtual StatusCode finalize() override final
Athena algtool Hook.
void ISF_to_G4Event(G4Event &event, 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.
virtual StatusCode convertHepMCToG4EventLegacy(McEventCollection &inputGenEvents, G4Event &outputG4Event) const override final
const G4ParticleDefinition * getG4ParticleDefinition(int pdgcode) const
virtual ~InputConverter()
Destructor.
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 ...
virtual StatusCode convertHepMCToG4Event(McEventCollection &inputGenEvents, G4Event &outputG4Event, McEventCollection &shadowGenEvents) const override final
virtual StatusCode initialize() override final
Athena algtool Hooks.
G4PrimaryParticle * getG4PrimaryParticle(ISF::ISFParticle &isp, bool useHepMC, HepMC::GenEvent *shadowGenEvent) const
void processPredefinedDecays(const HepMC::GenParticlePtr &genpart, ISF::ISFParticle &isp, G4PrimaryParticle *g4particle, bool makeLinkToTruth=true) const
HepMC::GenParticlePtr findShadowParticle(const HepMC::ConstGenParticlePtr &genParticle, HepMC::GenEvent *shadowGenEvent) const
bool matchedGenParticles(const HepMC::ConstGenParticlePtr &p1, const HepMC::ConstGenParticlePtr &p2) const
BooleanProperty m_useShadowEvent
ServiceHandle< IPartPropSvc > m_particlePropSvc
ParticlePropertyService and ParticleDataTable.
void addG4PrimaryVertex(G4Event &g4evt, ISF::ISFParticle &isp, bool useHepMC, HepMC::GenEvent *shadowGenEvent) const
bool isInsideG4WorldVolume(const ISF::ISFParticle &isp, const G4VSolid *worldSolid) const
Tests whether the given ISFParticle is within the Geant4 world volume.
G4PrimaryParticle * getDaughterG4PrimaryParticle(HepMC::GenParticle &gp, bool makeLinkToTruth=true) const
std::vector< HepMC::GenParticlePtr > getSelectedParticles(HepMC::GenEvent &evnt, bool legacyOrdering=false) const
get all generator particles which pass filters
ISF::ISFParticle * convertParticle(const HepMC::GenParticlePtr &genPartPtr) const
convert GenParticle to ISFParticle
bool passesFilters(const HepMC::GenParticle &p) const
check if the given particle passes all filters
ToolHandleArray< IGenParticleFilter > m_genParticleFilters
HepMC::GenParticle filters.
const HepPDT::ParticleDataTable * m_particleDataTable
PDT used to look up particle masses.
bool m_useGeneratedParticleMass
use GenParticle::generated_mass() in simulation
double getParticleMass(const HepMC::GenParticle &p) const
get right GenParticle mass
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
Core Athena algorithm for the Integrated Simulation Framework.
ISFParticleOrderedQueue.
std::list< ISF::ISFParticle * > ISFParticleContainer
generic ISFParticle container (not necessarily a std::list!)