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
23
25namespace ISFTesting {
26 class InputConverter_test;
27}
28namespace ISF {
29 class ISFParticle;
31}
32
33class G4ParticleDefinition;
34class G4PrimaryParticle;
35class G4VSolid;
36
37namespace ISF {
38
45 class InputConverter final: public extends<AthService, IInputConverter> {
46
47 // allow test to access private data
48 friend ISFTesting::InputConverter_test;
49
50 public:
51 InputConverter(const std::string& name, ISvcLocator* svc);
52 virtual ~InputConverter();
53
55 virtual StatusCode initialize() override final;
56 virtual StatusCode finalize() override final;
57
60 virtual StatusCode convert(McEventCollection& inputGenEvents,
61 ISF::ISFParticleContainer& simParticles) const override final;
62
64 virtual StatusCode convertHepMCToG4Event(
65 McEventCollection& inputGenEvents, G4Event& outputG4Event,
66 McEventCollection& shadowGenEvents) const override final;
67
68 virtual StatusCode convertHepMCToG4EventLegacy(
69 McEventCollection& inputGenEvents,
70 G4Event& outputG4Event) const override final;
71
73 void ISF_to_G4Event(G4Event& event,
74 const std::vector<ISF::ISFParticle*>& isp,
75 HepMC::GenEvent* genEvent,
76 HepMC::GenEvent* shadowGenEvent = nullptr,
77 bool useHepMC = false) const override final;
78
79 private:
80 const G4ParticleDefinition* getG4ParticleDefinition(int pdgcode) const;
81
82 G4PrimaryParticle* getDaughterG4PrimaryParticle(const HepMC::ConstGenParticlePtr& gp) const;
83 G4PrimaryParticle* getDaughterG4PrimaryParticle(const HepMC::GenParticlePtr& gp, bool makeLinkToTruth=true) const;
84
85 G4PrimaryParticle* getG4PrimaryParticle(ISF::ISFParticle& isp, bool useHepMC, HepMC::GenEvent *shadowGenEvent) const;
86
87 void addG4PrimaryVertex(G4Event& g4evt, ISF::ISFParticle& isp,
88 bool useHepMC,
89 HepMC::GenEvent* shadowGenEvent) const;
90
91 void processPredefinedDecays(const HepMC::ConstGenParticlePtr& genpart, ISF::ISFParticle& isp, G4PrimaryParticle* g4particle) const;
92 void processPredefinedDecays(const HepMC::GenParticlePtr& genpart, ISF::ISFParticle& isp, G4PrimaryParticle* g4particle, bool makeLinkToTruth=true) const;
93
95 const HepMC::ConstGenParticlePtr& p2) const;
96
98
100 bool isInsideG4WorldVolume(const ISF::ISFParticle& isp, const G4VSolid* worldSolid) const;
101
103 double getParticleMass(const HepMC::ConstGenParticlePtr& p) const;
104
106 std::vector<HepMC::GenParticlePtr > getSelectedParticles(HepMC::GenEvent& evnt, bool legacyOrdering=false) const;
107
109 bool passesFilters(const HepMC::ConstGenParticlePtr& p) const;
110
113
115 std::shared_ptr<GenData> m_gendata{nullptr};
116
118
119 ToolHandleArray<IGenParticleFilter> m_genParticleFilters;
120
121 bool m_quasiStableParticlesIncluded; //<! will quasi-stable particles be included in the simulation
122 BooleanProperty m_useShadowEvent{this, "UseShadowEvent", false, "New approach to selecting particles for simulation" };
123
124 };
125
126}
127
128
129#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 processPredefinedDecays(const HepMC::ConstGenParticlePtr &genpart, ISF::ISFParticle &isp, G4PrimaryParticle *g4particle) const
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
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
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.
bool passesFilters(const HepMC::ConstGenParticlePtr &p) const
check if the given particle passes all filters
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
std::shared_ptr< GenData > m_gendata
ParticlePropertyService and ParticleDataTable.
double getParticleMass(const HepMC::ConstGenParticlePtr &p) const
get right GenParticle mass
ToolHandleArray< IGenParticleFilter > m_genParticleFilters
HepMC::GenParticle filters.
G4PrimaryParticle * getDaughterG4PrimaryParticle(const HepMC::ConstGenParticlePtr &gp) const
bool m_useGeneratedParticleMass
use GenParticle::generated_mass() in simulation
This defines the McEventCollection, which is really just an ObjectVector of McEvent objectsFile: Gene...
HepMC3::GenParticlePtr GenParticlePtr
Definition GenParticle.h:19
HepMC3::ConstGenParticlePtr ConstGenParticlePtr
Definition GenParticle.h:20
HepMC3::GenEvent GenEvent
Definition GenEvent.h:39
Core Athena algorithm for the Integrated Simulation Framework.
ISFParticleOrderedQueue.
std::list< ISF::ISFParticle * > ISFParticleContainer
generic ISFParticle container (not necessarily a std::list!)