ATLAS Offline Software
Loading...
Searching...
No Matches
AFatrasG4Tool Class Reference

#include <AFatrasG4Tool.h>

Inheritance diagram for AFatrasG4Tool:
Collaboration diagram for AFatrasG4Tool:

Public Member Functions

 AFatrasG4Tool (const std::string &type, const std::string &name, const IInterface *parent)
 Default constructor.

Protected Member Functions

virtual StatusCode initializeFastSim () override final
 Method to make the actual fast simulation model itself, which will be owned by the tool.
virtual StatusCode BeginOfAthenaEvent (HitCollectionMap &) override final
 Begin of an athena event - do anything that needs to be done at the beginning of each athena event.
virtual StatusCode EndOfAthenaEvent (HitCollectionMap &) override final
 End of an athena event - do any tidying up required at the end of each athena event.
virtual G4VFastSimulationModel * makeFastSimModel () override final
G4Region * getRegion () const

Protected Attributes

Gaudi::Property< std::string > m_regionName {this, "RegionName", ""}
 The region to which this fast sim is assigned.
Gaudi::Property< bool > m_noRegions {this, "NoRegions", false}
 This Fast Simulation has no regions associated with it.

Private Attributes

Gaudi::Property< bool > m_doG4Transport {this, "doG4Transport", false, "Flag to enable G4 transportation"}
PublicToolHandle< IActsFatrasG4Toolm_ActsFatrasG4Tool {this, "ActsFatrasG4Tool", "ActsFatrasG4Tool", ""}
SG::WriteHandleKey< SiHitCollectionm_pixelHitsKey
SG::WriteHandleKey< SiHitCollectionm_sctHitsKey

Detailed Description

Definition at line 22 of file AFatrasG4Tool.h.

Constructor & Destructor Documentation

◆ AFatrasG4Tool()

AFatrasG4Tool::AFatrasG4Tool ( const std::string & type,
const std::string & name,
const IInterface * parent )

Default constructor.

Definition at line 8 of file AFatrasG4Tool.cxx.

9: FastSimulationBase(type, name, parent)
10{
11}
FastSimulationBase(const std::string &type, const std::string &name, const IInterface *parent)

Member Function Documentation

◆ BeginOfAthenaEvent()

StatusCode AFatrasG4Tool::BeginOfAthenaEvent ( HitCollectionMap & hcm)
finaloverrideprotectedvirtual

Begin of an athena event - do anything that needs to be done at the beginning of each athena event.

Reimplemented from FastSimulationBase.

Definition at line 22 of file AFatrasG4Tool.cxx.

23{
24 ATH_MSG_DEBUG("AFatrasG4Tool:BeginOfAthenaEvent");
26 if (msgLvl(MSG::DEBUG)){
27 const EventContext& ctx = Gaudi::Hive::currentContext();
28 ATH_MSG_DEBUG("BeginOfAthenaEvent slot=" << ctx.slot());
29 }
30
31 return StatusCode::SUCCESS;
32}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
virtual StatusCode BeginOfAthenaEvent(HitCollectionMap &) override
Begin of an athena event - do anything that needs to be done at the beginning of each athena event.

◆ EndOfAthenaEvent()

StatusCode AFatrasG4Tool::EndOfAthenaEvent ( HitCollectionMap & hcm)
finaloverrideprotectedvirtual

End of an athena event - do any tidying up required at the end of each athena event.

Reimplemented from FastSimulationBase.

Definition at line 42 of file AFatrasG4Tool.cxx.

43{
44 ATH_MSG_DEBUG("AFatrasG4Tool:EndOfAthenaEvent");
45 const EventContext& ctx = Gaudi::Hive::currentContext();
46 ATH_MSG_DEBUG("EndOfAthenaEvent slot=" << ctx.slot()); //check if same slot as in BeginOfAthenaEvent
47
48 // create the store record once at the end of each athena event
49 SG::WriteHandle<SiHitCollection> pixelHandle(m_pixelHitsKey, ctx);
50 if (!pixelHandle.isValid()) {
51 ATH_MSG_DEBUG("Pixel container not valid — recording now");
52 ATH_CHECK(pixelHandle.record(std::make_unique<SiHitCollection>(m_pixelHitsKey.key())));
53 } else {
54 ATH_MSG_DEBUG("Pixel container already valid");
55 }
56
57 SG::WriteHandle<SiHitCollection> sctHandle(m_sctHitsKey, ctx);
58 if (!sctHandle.isValid()) {
59 ATH_MSG_DEBUG("SCT container not valid — recording now");
60 ATH_CHECK(sctHandle.record(std::make_unique<SiHitCollection>(m_sctHitsKey.key())));
61 } else {
62 ATH_MSG_DEBUG("SCT container already valid");
63 }
64
65 if (msgLvl(MSG::DEBUG)) {
66 // check if record stores created
67 ATH_MSG_DEBUG("---- HIT DEBUG ----");
68 ATH_MSG_DEBUG("Slot = " << ctx.slot());
69 ATH_MSG_DEBUG("Pixel key = " << m_pixelHitsKey.key());
70 ATH_MSG_DEBUG("Pixel isPresent = " << pixelHandle.isPresent());
71 ATH_MSG_DEBUG("Pixel isValid = " << pixelHandle.isValid());
72 ATH_MSG_DEBUG("SCT key = " << sctHandle.key());
73 ATH_MSG_DEBUG("SCT isPresent = " << sctHandle.isPresent());
74 ATH_MSG_DEBUG("SCT isValid = " << sctHandle.isValid());
75 ATH_MSG_DEBUG("-------------------");
76 }
77
78 if (!pixelHandle.isValid() || !sctHandle.isValid()) {
79 ATH_MSG_ERROR("Hit containers missing at EndOfAthenaEvent!");
80 return StatusCode::FAILURE;
81 }
82
83 // Get hits from ActsFatrasG4Tool cache
84 const auto& pixelHits = m_ActsFatrasG4Tool->getPixelHitsCache(ctx);
85 const auto& sctHits = m_ActsFatrasG4Tool->getSCTHitsCache(ctx);
86 ATH_MSG_DEBUG("Pixel cache size = " << pixelHits.size());
87 ATH_MSG_DEBUG("SCT cache size = " << sctHits.size());
88
89 // Fill the hits to store handler from the caches
90 for (const auto& hit : pixelHits) {pixelHandle->push_back(hit);}
91 for (const auto& hit : sctHits) {sctHandle->push_back(hit);}
92 ATH_MSG_DEBUG("After fill:");
93 ATH_MSG_DEBUG("Pixel container size = " << pixelHandle->size());
94 ATH_MSG_DEBUG("SCT container size = " << sctHandle->size());
95
96 // sanity printing
97 if (msgLvl(MSG::VERBOSE)) {
98 ATH_MSG_VERBOSE("==== FatrasG4Tool: Pixel Hits ====");
99 for (const SiHit& hit : *pixelHandle) {
100 const auto& start = hit.localStartPosition();
101 const auto& end = hit.localEndPosition();
102 int barcode = hit.particleLink().barcode();
103
104 ATH_MSG_VERBOSE("TrackID=" << barcode
105 << " Edep(MeV)=" << hit.energyLoss()
106 << " LocalStart=("
107 << start.x() << ", "
108 << start.y() << ", "
109 << start.z() << ")"
110 << " LocalEnd=("
111 << end.x() << ", "
112 << end.y() << ", "
113 << end.z() << ")");
114 }
115 ATH_MSG_VERBOSE("==== FatrasG4Tool: SCT Hits ====");
116 for (const SiHit& hit : *sctHandle) {
117 const auto& start = hit.localStartPosition();
118 const auto& end = hit.localEndPosition();
119 int barcode = hit.particleLink().barcode();
120
121 ATH_MSG_VERBOSE("TrackID=" << barcode
122 << " Edep(MeV)=" << hit.energyLoss()
123 << " LocalStart=("
124 << start.x() << ", "
125 << start.y() << ", "
126 << start.z() << ")"
127 << " LocalEnd=("
128 << end.x() << ", "
129 << end.y() << ", "
130 << end.z() << ")");
131 }
132 }
133
134 // Clear cache for next event
135 m_ActsFatrasG4Tool->clearCaches(ctx);
136
138}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
bool hit(const Container &ids, int pdgId)
SG::WriteHandleKey< SiHitCollection > m_sctHitsKey
SG::WriteHandleKey< SiHitCollection > m_pixelHitsKey
PublicToolHandle< IActsFatrasG4Tool > m_ActsFatrasG4Tool
virtual StatusCode EndOfAthenaEvent(HitCollectionMap &) override
End of an athena event - do any tidying up required at the end of each athena event.
int barcode(const T *p)
Definition Barcode.h:15

◆ getRegion()

G4Region * FastSimulationBase::getRegion ( ) const
protectedinherited

Definition at line 18 of file FastSimulationBase.cxx.

19{
20 if (m_regionName.value().empty()) {
21 return nullptr;
22 }
23 return G4RegionStore::GetInstance()->GetRegion(m_regionName.value());
24}
Gaudi::Property< std::string > m_regionName
The region to which this fast sim is assigned.

◆ initializeFastSim()

StatusCode AFatrasG4Tool::initializeFastSim ( )
finaloverrideprotectedvirtual

Method to make the actual fast simulation model itself, which will be owned by the tool.

Must be implemented in all concrete base classes.

Definition at line 13 of file AFatrasG4Tool.cxx.

14{
16 ATH_CHECK(m_ActsFatrasG4Tool.retrieve());
17 ATH_CHECK(m_pixelHitsKey.initialize());
18 ATH_CHECK(m_sctHitsKey.initialize());
19 return StatusCode::SUCCESS;
20}
StatusCode initializeFastSim() override
Construct and setup the fast simulation model.

◆ makeFastSimModel()

G4VFastSimulationModel * AFatrasG4Tool::makeFastSimModel ( )
finaloverrideprotectedvirtual

Definition at line 35 of file AFatrasG4Tool.cxx.

36{
37 ATH_MSG_INFO("Initializing Fast Simulation Model AFatrasG4");
38 // Create the AFatrasG4 fast simulation model
39 return new AFatrasG4(name(), getRegion(), m_ActsFatrasG4Tool, m_doG4Transport, this);
40}
#define ATH_MSG_INFO(x)
Gaudi::Property< bool > m_doG4Transport
G4Region * getRegion() const

Member Data Documentation

◆ m_ActsFatrasG4Tool

PublicToolHandle<IActsFatrasG4Tool> AFatrasG4Tool::m_ActsFatrasG4Tool {this, "ActsFatrasG4Tool", "ActsFatrasG4Tool", ""}
private

Definition at line 48 of file AFatrasG4Tool.h.

48{this, "ActsFatrasG4Tool", "ActsFatrasG4Tool", ""};

◆ m_doG4Transport

Gaudi::Property<bool> AFatrasG4Tool::m_doG4Transport {this, "doG4Transport", false, "Flag to enable G4 transportation"}
private

Definition at line 45 of file AFatrasG4Tool.h.

45{this, "doG4Transport", false, "Flag to enable G4 transportation"};

◆ m_noRegions

Gaudi::Property<bool> FastSimulationBase::m_noRegions {this, "NoRegions", false}
protectedinherited

This Fast Simulation has no regions associated with it.

Definition at line 55 of file FastSimulationBase.h.

55{this, "NoRegions", false};

◆ m_pixelHitsKey

SG::WriteHandleKey<SiHitCollection> AFatrasG4Tool::m_pixelHitsKey
private
Initial value:
{
this,
"PixelCollectionName",
"PixelHits_ActsFatrasG4",
"StoreGate key for Pixel SiHitCollection"
}

Definition at line 53 of file AFatrasG4Tool.h.

53 {
54 this,
55 "PixelCollectionName",
56 "PixelHits_ActsFatrasG4",
57 "StoreGate key for Pixel SiHitCollection"
58 };

◆ m_regionName

Gaudi::Property<std::string> FastSimulationBase::m_regionName {this, "RegionName", ""}
protectedinherited

The region to which this fast sim is assigned.

Definition at line 53 of file FastSimulationBase.h.

53{this, "RegionName", ""};

◆ m_sctHitsKey

SG::WriteHandleKey<SiHitCollection> AFatrasG4Tool::m_sctHitsKey
private
Initial value:
{
this,
"SCTCollectionName",
"SCT_Hits_ActsFatrasG4",
"StoreGate key for SCT SiHitCollection"
}

Definition at line 60 of file AFatrasG4Tool.h.

60 {
61 this,
62 "SCTCollectionName",
63 "SCT_Hits_ActsFatrasG4",
64 "StoreGate key for SCT SiHitCollection"
65 };

The documentation for this class was generated from the following files: