16 static const int layer_depth = 2;
18 ldmx::EcalGeometry::CONDITIONS_OBJECT_NAME);
21 G4double edep = aStep->GetTotalEnergyDeposit();
25 ldmx_log(trace) <<
"CalorimeterSD skipping step with zero edep.";
30 G4StepPoint* pre_point = aStep->GetPreStepPoint();
31 G4StepPoint* post_point = aStep->GetPostStepPoint();
32 G4ThreeVector position =
33 0.5 * (pre_point->GetPosition() + post_point->GetPosition());
38 auto pre_step_point = aStep->GetPreStepPoint();
40 const auto& touchable_handle = pre_step_point->GetTouchableHandle();
41 if (touchable_handle) {
42 auto history = touchable_handle->GetHistory();
44 auto volume = history->GetVolume(layer_depth);
46 cpynum = volume->GetCopyNo();
52 layer_number = cpynum / 7;
53 int module_position = cpynum % 7;
68 geometry.getID(position.x(), position.y(), layer_number, module_position);
83 auto& hit =
hits_[id];
85 hit.setPosition(position.x(), position.y(), position.z());
88 auto& hit =
hits_[id];
91 auto track = aStep->GetTrack();
92 auto time = track->GetGlobalTime();
93 auto track_id = track->GetTrackID();
94 auto pdg = track->GetParticleDefinition()->GetPDGEncoding();
97 int contrib_i = hit.findContribIndex(track_id, pdg);
99 hit.updateContrib(contrib_i, edep, time);
102 auto incident{map.findIncident(track_id)};
106 int origin{incident};
108 if (map.isDescendant(track_id, i, 100)) {
113 hit.addContrib(incident, track_id, pdg, edep, time, origin);
117 hit.setEdep(hit.getEdep() + edep);
118 if (time < hit.getTime() or hit.getTime() == 0) {