ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
G4Sim
MCTruthBase
src
RecordingEnvelope.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
6
#include "
RecordingEnvelope.h
"
7
8
// Athena headers
9
#include "
MCTruth/TrackHelper.h
"
10
#include "
TrackRecord/TrackRecordCollection.h
"
11
12
//G4 headers
13
#include "G4PhysicalVolumeStore.hh"
14
#include "G4Step.hh"
15
#include "G4TransportationManager.hh"
16
#include "G4VPhysicalVolume.hh"
17
#include "G4VSolid.hh"
18
19
20
RecordingEnvelope::RecordingEnvelope
(
const
std::string& envelopeVolumeName,
const
std::string& trackRecordCollectionName):
21
m_level
(-1),
22
m_logicalVolume
(nullptr),
23
m_envelopeVolumeName
(envelopeVolumeName),
24
m_trackRecordCollectionName
(trackRecordCollectionName)
25
{
26
27
}
28
29
RecordingEnvelope::~RecordingEnvelope
()
30
{
31
32
}
33
34
bool
RecordingEnvelope::checkDaughters
(
const
G4LogicalVolume *possibleParent,
const
G4VPhysicalVolume *thePhysicalVolume,
int
& level)
const
35
{
36
if
(possibleParent->IsDaughter(thePhysicalVolume))
37
{
38
++level;
39
return
true
;
40
}
41
// Otherwise Loop over the daughters
42
const
G4int nDaughters(possibleParent->GetNoDaughters());
43
for
(G4int daughter(0); daughter<nDaughters; ++daughter)
44
{
45
const
G4VPhysicalVolume* daughterPhysVol = possibleParent->GetDaughter(daughter);
46
const
G4LogicalVolume* daughterLogVol = daughterPhysVol->GetLogicalVolume();
47
if
(this->
checkDaughters
(daughterLogVol, thePhysicalVolume,level))
48
{
49
++level;
50
return
true
;
51
}
52
}
53
return
false
;
54
}
55
bool
RecordingEnvelope::Initialize
()
56
{
57
const
G4VPhysicalVolume *thePhysicalVolume = G4PhysicalVolumeStore::GetInstance()->GetVolume(
m_envelopeVolumeName
,
false
);
58
m_logicalVolume
=thePhysicalVolume->GetLogicalVolume();
59
const
G4LogicalVolume * logicalWorld = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume()->GetLogicalVolume();
60
m_level
=0;
61
return
this->
checkDaughters
(logicalWorld, thePhysicalVolume,
m_level
);
62
}
63
64
void
RecordingEnvelope::BeginOfEvent
(
TrackRecordCollection
* trackRecordCollection)
65
{
66
m_trackRecordCollection
= trackRecordCollection;
67
}
68
void
RecordingEnvelope::AddTrackRecord
(
const
G4Step* aStep)
69
{
70
const
std::string pname = aStep->GetTrack()->GetDefinition()->GetParticleName();
71
const
int
pdgcode = (pname==
"geantino"
) ? 999 : aStep->GetTrack()->GetDefinition()->GetPDGEncoding();
72
TrackHelper
trHelp(aStep->GetTrack());
73
const
int
barcode = trHelp.
GetBarcode
();
74
const
int
status = trHelp.
GetStatus
();
75
const
int
id
= trHelp.
GetUniqueID
();
76
77
G4StepPoint *postStep=aStep->GetPostStepPoint();
78
G4ThreeVector pos=postStep->GetPosition();
79
G4ThreeVector mom=postStep->GetMomentum();
80
const
double
ener=postStep->GetTotalEnergy();
81
const
double
time=postStep->GetGlobalTime();
82
83
G4StepPoint *preStep=aStep->GetPreStepPoint();
84
G4VPhysicalVolume *preVol=preStep->GetPhysicalVolume();
85
86
m_trackRecordCollection
->Emplace(pdgcode,status,ener,mom,pos,time,barcode,
id
,preVol->GetName());
87
}
RecordingEnvelope.h
TrackHelper.h
TrackRecordCollection.h
TrackRecordCollection
AtlasHitsVector< TrackRecord > TrackRecordCollection
Definition
TrackRecordCollection.h:12
RecordingEnvelope::m_logicalVolume
G4LogicalVolume * m_logicalVolume
Pointer to the G4LogicalVolume used by this recording envelope.
Definition
RecordingEnvelope.h:73
RecordingEnvelope::m_level
int m_level
The number of levels beneath the world that the G4LogicalVolume called m_envelopeVolumeName lies.
Definition
RecordingEnvelope.h:68
RecordingEnvelope::m_envelopeVolumeName
const std::string m_envelopeVolumeName
Name of the G4LogicalVolume used by this recording envelope.
Definition
RecordingEnvelope.h:76
RecordingEnvelope::m_trackRecordCollection
TrackRecordCollection * m_trackRecordCollection
TrackRecordCollection used by this envelope.
Definition
RecordingEnvelope.h:79
RecordingEnvelope::m_trackRecordCollectionName
std::string m_trackRecordCollectionName
Definition
RecordingEnvelope.h:80
RecordingEnvelope::AddTrackRecord
void AddTrackRecord(const G4Step *aStep)
Add a TrackRecord to the TrackRecordCollection owned by this recording envelope based on the informat...
Definition
RecordingEnvelope.cxx:68
RecordingEnvelope::checkDaughters
bool checkDaughters(const G4LogicalVolume *possibleParent, const G4VPhysicalVolume *thePhysicalVolume, int &level) const
Recursively called method used to hunt for the G4LogicalVolume associated with this recording envelop...
Definition
RecordingEnvelope.cxx:34
RecordingEnvelope::RecordingEnvelope
RecordingEnvelope(const std::string &envelopeVolumeName, const std::string &trackRecordCollectionName)
Constructor.
Definition
RecordingEnvelope.cxx:20
RecordingEnvelope::Initialize
bool Initialize()
Finds the pointer to the G4LogicalVolume called m_envelopeVolumeName and the number of levels beneath...
Definition
RecordingEnvelope.cxx:55
RecordingEnvelope::~RecordingEnvelope
~RecordingEnvelope()
Destructor.
Definition
RecordingEnvelope.cxx:29
RecordingEnvelope::BeginOfEvent
void BeginOfEvent(TrackRecordCollection *)
Called at the start of each G4 event.
Definition
RecordingEnvelope.cxx:64
TrackHelper
Definition
TrackHelper.h:20
TrackHelper::GetBarcode
int GetBarcode() const
Return the truth barcode/id/status used for detector output.
Definition
TrackHelper.cxx:57
TrackHelper::GetUniqueID
int GetUniqueID() const
Definition
TrackHelper.cxx:66
TrackHelper::GetStatus
int GetStatus() const
Definition
TrackHelper.cxx:75
Generated on
for ATLAS Offline Software by
1.17.0