27 static const int layer_depth = 2;
28 const auto& geometry = getCondition<ldmx::EcalGeometry>(
29 ldmx::EcalGeometry::CONDITIONS_OBJECT_NAME);
32 G4double edep = aStep->GetTotalEnergyDeposit();
36 if (verboseLevel > 2) {
37 G4cout <<
"CalorimeterSD skipping step with zero edep." << G4endl
44 G4StepPoint* prePoint = aStep->GetPreStepPoint();
45 G4StepPoint* postPoint = aStep->GetPostStepPoint();
46 G4ThreeVector position =
47 0.5 * (prePoint->GetPosition() + postPoint->GetPosition());
52 auto preStepPoint = aStep->GetPreStepPoint();
54 auto touchableHandle = preStepPoint->GetTouchableHandle();
55 if (touchableHandle) {
56 auto history = touchableHandle->GetHistory();
58 auto volume = history->GetVolume(layer_depth);
60 cpynum = volume->GetCopyNo();
66 layerNumber = cpynum / 7;
67 int module_position = cpynum % 7;
82 geometry.getID(position[0], position[1], layerNumber, module_position);
97 auto& hit =
hits_[id];
108 auto [x, y, z] = geometry.getPosition(
id);
109 hit.setPosition(x, y, z);
112 auto& hit =
hits_[id];
115 auto track = aStep->GetTrack();
116 auto time = track->GetGlobalTime();
117 auto track_id = track->GetTrackID();
118 auto pdg = track->GetParticleDefinition()->GetPDGEncoding();
121 int contrib_i = hit.findContribIndex(track_id, pdg);
123 hit.updateContrib(contrib_i, edep, time);
130 hit.setEdep(hit.getEdep() + edep);
131 if (time < hit.getTime() or hit.getTime() == 0) {