11#include "G4StepPoint.hh"
12#include "G4TouchableHistory.hh"
23 IMessageSvc* msgSvc, MSG::Level level)
28 msg().setLevel(level);
37 " recording envelopes:");
40 ATH_MSG_DEBUG(
" " << volCollPair.first <<
", " << volCollPair.second);
50 " not found in geometry!");
53 " will NOT be recorded");
79 recEnvelope.BeginOfEvent(eventInfo->GetHitCollectionMap()->Find<
TrackRecordCollection>(recEnvelope.GetTrackRecordCollectionName()));
93 G4StepPoint* preStep = aStep->GetPreStepPoint();
94 G4StepPoint* postStep = aStep->GetPostStepPoint();
96 G4VPhysicalVolume* preVol = preStep->GetPhysicalVolume();
97 G4VPhysicalVolume* postVol = postStep->GetPhysicalVolume();
99 if (preVol == postVol)
return;
101 const G4TouchableHistory* preTHist =
static_cast<const G4TouchableHistory*
>(preStep->GetTouchable());
102 const G4TouchableHistory* postTHist =
static_cast<const G4TouchableHistory*
>(postStep->GetTouchable());
103 const int preStepVolDepth = preTHist->GetHistoryDepth();
104 const int postStepVolDepth = postTHist->GetHistoryDepth();
108 const int envelopeLevel = recEnvelope.GetLevel();
109 if (envelopeLevel <= preStepVolDepth)
112 const G4LogicalVolume* logicalVolume1 =
113 preTHist->GetVolume(preStepVolDepth-envelopeLevel)->GetLogicalVolume();
114 if (logicalVolume1 != recEnvelope.GetLogicalVolume())
continue;
116 if (envelopeLevel <= postStepVolDepth &&
117 logicalVolume1 == postTHist->GetVolume(postStepVolDepth-envelopeLevel)
118 ->GetLogicalVolume())
125 recEnvelope.AddTrackRecord(aStep);
#define ATH_MSG_WARNING(x)
AtlasHitsVector< TrackRecord > TrackRecordCollection
MsgStream & msg() const
The standard message stream.
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
This class is attached to G4Event objects as UserInformation.
std::map< std::string, std::string > VolumeCollectionMap_t
Map of volume name to output TrackRecordCollection name.
bool m_isInitialized
Used to delay initialization until the event loop, after geo is ready.
void setupRecEnvelopes()
Setup the list of RecordingEnvelope helpers.
std::vector< RecordingEnvelope > m_recordingEnvelopes
List of RecordingEnvelope helpers to invoke.
MCTruthSteppingAction(const VolumeCollectionMap_t &collMap, IMessageSvc *msgSvc, MSG::Level level)
Construct the action with specified volumes and output collections.
VolumeCollectionMap_t m_volumeCollectionMap
Map of volume name to output collection name.
virtual void BeginOfEventAction(const G4Event *) override final
Called at the start of each G4 event.
virtual void UserSteppingAction(const G4Step *) override final
Process one particle step.
Responsible for finding the G4LogicalVolume pointer for each recording envelope and for creating and ...
const std::string & GetTrackRecordCollectionName() const
Returns the name of the TrackRecordCollection to which tracks crossing this recording envelope should...
const std::string & GetVolumeName() const
Returns the name of the recording envelope volume.
bool Initialize()
Finds the pointer to the G4LogicalVolume called m_envelopeVolumeName and the number of levels beneath...