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

#include <FatrasG4Tool.h>

Inheritance diagram for FatrasG4Tool:
Collaboration diagram for FatrasG4Tool:

Public Member Functions

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

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

PublicToolHandle< IActsFatrasG4Toolm_ActsFatrasG4Tool {this, "ActsFatrasG4Tool", "ActsFatrasG4Tool", ""}
SG::WriteHandleKey< SiHitCollectionm_pixelHitsKey
SG::WriteHandleKey< SiHitCollectionm_sctHitsKey

Detailed Description

Definition at line 22 of file FatrasG4Tool.h.

Member Function Documentation

◆ BeginOfAthenaEvent()

StatusCode FatrasG4Tool::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 18 of file FatrasG4Tool.cxx.

19{
20 ATH_MSG_DEBUG("FatrasG4Tool:BeginOfAthenaEvent");
22 if (msgLvl(MSG::DEBUG)){
23 const EventContext& ctx = Gaudi::Hive::currentContext();
24 ATH_MSG_DEBUG("BeginOfAthenaEvent slot=" << ctx.slot());
25 }
26
27 return StatusCode::SUCCESS;
28}
#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 FatrasG4Tool::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 38 of file FatrasG4Tool.cxx.

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

◆ FastSimulationBase()

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

Definition at line 30 of file FastSimulationBase.cxx.

14 : base_class(type,name,parent)
15{
16}

◆ 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 FatrasG4Tool::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 9 of file FatrasG4Tool.cxx.

10{
12 ATH_CHECK(m_ActsFatrasG4Tool.retrieve());
13 ATH_CHECK(m_pixelHitsKey.initialize());
14 ATH_CHECK(m_sctHitsKey.initialize());
15 return StatusCode::SUCCESS;
16}
StatusCode initializeFastSim() override
Construct and setup the fast simulation model.

◆ makeFastSimModel()

G4VFastSimulationModel * FatrasG4Tool::makeFastSimModel ( )
finaloverrideprotectedvirtual

Definition at line 31 of file FatrasG4Tool.cxx.

32{
33 ATH_MSG_INFO("Initializing Fast Simulation Model FatrasG4");
34 // Create the FatrasG4 fast simulation model
35 return new FatrasG4(name(), getRegion(), m_ActsFatrasG4Tool, this);
36}
#define ATH_MSG_INFO(x,...)
G4Region * getRegion() const

Member Data Documentation

◆ m_ActsFatrasG4Tool

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

Definition at line 44 of file FatrasG4Tool.h.

44{this, "ActsFatrasG4Tool", "ActsFatrasG4Tool", ""};

◆ 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> FatrasG4Tool::m_pixelHitsKey
private
Initial value:
{
this,
"PixelCollectionName",
"PixelHits_ActsFatrasG4",
"StoreGate key for Pixel SiHitCollection"
}

Definition at line 49 of file FatrasG4Tool.h.

49 {
50 this,
51 "PixelCollectionName",
52 "PixelHits_ActsFatrasG4",
53 "StoreGate key for Pixel SiHitCollection"
54 };

◆ 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> FatrasG4Tool::m_sctHitsKey
private
Initial value:
{
this,
"SCTCollectionName",
"SCT_Hits_ActsFatrasG4",
"StoreGate key for SCT SiHitCollection"
}

Definition at line 56 of file FatrasG4Tool.h.

56 {
57 this,
58 "SCTCollectionName",
59 "SCT_Hits_ActsFatrasG4",
60 "StoreGate key for SCT SiHitCollection"
61 };

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