ATLAS Offline Software
TruthStrategyManager.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // class header
7 
8 // Framework includes
10 
12 
13 // Geant4 Includes
14 #include "G4Event.hh"
15 #include "G4EventManager.hh"
16 #include "G4PhysicalVolumeStore.hh"
17 #include "G4Step.hh"
18 #include "G4TransportationManager.hh"
19 #include "G4VPhysicalVolume.hh"
20 #include "G4VSolid.hh"
21 
22 // Truth-related includes
24 #include "MCTruth/TrackHelper.h"
25 
26 // ISF includes
29 #include "ISF_Event/ISFParticle.h"
30 
31 // DetectorDescription
35 
37  : m_truthSvc(nullptr)
38  , m_geoIDSvc(nullptr)
39 {
40 }
41 
43 {
44  static const TruthStrategyManager theMgr;
45  return theMgr;
46 }
47 
48 TruthStrategyManager& TruthStrategyManager::GetStrategyManager_nc ATLAS_NOT_THREAD_SAFE ()
49 {
50  return const_cast<TruthStrategyManager&>(GetStrategyManager());
51 }
52 
54 {
55  m_truthSvc = truthSvc;
56 }
57 
58 
60 {
61  m_geoIDSvc = geoIDSvc;
62 }
63 
64 bool TruthStrategyManager::CreateTruthIncident(const G4Step* aStep, int subDetVolLevel) const
65 {
67 
68  auto* atlasG4EvtUserInfo = static_cast<AtlasG4EventUserInfo*> (G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetUserInformation());
69 
70  // This is pretty ugly and but necessary because the Geant4TruthIncident
71  // requires an ISFParticle at this point.
72  // TODO: cleanup Geant4TruthIncident to not require an ISFParticle instance any longer
73  const Amg::Vector3D myPos(0,0,0);
74  const Amg::Vector3D myMom(0,0,0);
75  const double myMass = 0.0;
76  const double myCharge = 0.0;
77  const int myPdgCode = 0;
78  const int mystatus = 3333;
79  const double myTime =0.;
80  const int myID = HepMC::UNDEFINED_ID;
81  const ISF::DetRegionSvcIDPair origin(geoID, ISF::fUndefinedSimID);
82  ISF::ISFParticle myISFParticle(myPos, myMom, myMass, myCharge, myPdgCode, mystatus, myTime, origin, myID);
83 
84  iGeant4::Geant4TruthIncident truth(aStep, myISFParticle, geoID, atlasG4EvtUserInfo);
85 
87  return false;
88 }
89 
ATLAS_NOT_THREAD_SAFE
TruthStrategyManager &TruthStrategyManager::GetStrategyManager_nc ATLAS_NOT_THREAD_SAFE()
Install fatal handler with default options.
Definition: TruthStrategyManager.cxx:48
ISF::DetRegionSvcIDPair
std::pair< AtlasDetDescr::AtlasRegion, ISF::SimSvcID > DetRegionSvcIDPair
the datatype to be used to store each individual particle hop
Definition: ISFParticle.h:30
AtlasG4EventUserInfo
This class is attached to G4Event objects as UserInformation. It holds a pointer to the HepMC::GenEve...
Definition: AtlasG4EventUserInfo.h:21
ISF::ITruthSvc::registerTruthIncident
virtual void registerTruthIncident(ITruthIncident &truthincident, bool saveAllChildren=false) const =0
Register a truth incident.
AthMsgStreamMacros.h
TruthStrategyManager::TruthStrategyManager
TruthStrategyManager()
Definition: TruthStrategyManager.cxx:36
TruthStrategyManager::SetISFTruthSvc
void SetISFTruthSvc(ISF::ITruthSvc *truthSvc)
Define which ISF TruthService to use.
Definition: TruthStrategyManager.cxx:53
TrackHelper.h
AtlasDetDescr::AtlasRegion
AtlasRegion
Definition: AtlasRegion.h:27
ISF::ISFParticle
Definition: ISFParticle.h:42
iGeant4::ISFG4GeoHelper::nextGeoId
static AtlasDetDescr::AtlasRegion nextGeoId(const G4Step *aStep, int truthVolLevel, ISF::IGeoIDSvc *geoIDSvc)
Definition: ISFG4GeoHelper.cxx:20
iGeant4::Geant4TruthIncident
Definition: Geant4TruthIncident.h:44
TruthStrategyManager.h
TruthStrategyManager::CreateTruthIncident
bool CreateTruthIncident(const G4Step *, int subDetVolLevel) const
Returns true if any of the truth strategies return true.
Definition: TruthStrategyManager.cxx:64
TruthStrategyManager::m_geoIDSvc
ISF::IGeoIDSvc * m_geoIDSvc
Definition: TruthStrategyManager.h:49
TruthStrategyManager::GetStrategyManager
static const TruthStrategyManager & GetStrategyManager()
Retrieve the (const) singleton instance.
Definition: TruthStrategyManager.cxx:42
ISFParticle.h
TruthStrategyManager::SetISFGeoIDSvc
void SetISFGeoIDSvc(ISF::IGeoIDSvc *geoIDSvc)
Define which ISF GeoIDSvc to use.
Definition: TruthStrategyManager.cxx:59
ISF::ITruthSvc
@ class ITruthSvc
Definition: ITruthSvc.h:29
TruthStrategyManager
Singleton class for creating truth incidents.
Definition: TruthStrategyManager.h:23
ISF::IGeoIDSvc
Definition: IGeoIDSvc.h:41
AtlasRegionHelper.h
IGeoIDSvc.h
HepMC::UNDEFINED_ID
constexpr int UNDEFINED_ID
Definition: MagicNumbers.h:55
MagicNumbers.h
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
AtlasG4EventUserInfo.h
Geant4TruthIncident.h
ISFG4GeoHelper.h
ITruthSvc.h
TruthStrategyManager::m_truthSvc
ISF::ITruthSvc * m_truthSvc
ISF Services the TruthStrategyManager talks to.
Definition: TruthStrategyManager.h:48
ISF::fUndefinedSimID
@ fUndefinedSimID
Definition: SimSvcID.h:32