21 static const int layer_depth = 2;
23 ldmx::EcalGeometry::CONDITIONS_OBJECT_NAME);
26 G4double edep = aStep->GetTotalEnergyDeposit();
30 ldmx_log(trace) <<
"CalorimeterSD skipping step with zero edep.";
35 G4StepPoint* pre_point = aStep->GetPreStepPoint();
36 G4StepPoint* post_point = aStep->GetPostStepPoint();
37 G4ThreeVector position =
38 0.5 * (pre_point->GetPosition() + post_point->GetPosition());
43 auto pre_step_point = aStep->GetPreStepPoint();
45 const auto& touchable_handle = pre_step_point->GetTouchableHandle();
46 if (touchable_handle) {
47 auto history = touchable_handle->GetHistory();
49 auto volume = history->GetVolume(layer_depth);
51 cpynum = volume->GetCopyNo();
57 layer_number = cpynum / 7;
58 int module_position = cpynum % 7;
73 geometry.getID(position.x(), position.y(), layer_number, module_position);
88 auto& hit =
hits_[id];
90 hit.setPosition(position.x(), position.y(), position.z());
93 auto& hit =
hits_[id];
96 auto track = aStep->GetTrack();
97 auto time = track->GetGlobalTime();
98 auto track_id = track->GetTrackID();
99 auto pdg = track->GetParticleDefinition()->GetPDGEncoding();
102 int contrib_i = hit.findContribIndex(track_id, pdg);
104 hit.updateContrib(contrib_i, edep, time);
107 auto incident{map.findIncident(track_id)};
111 int origin{incident};
113 if (map.isDescendant(track_id, i, 100)) {
118 hit.addContrib(incident, track_id, pdg, edep, time, origin);
122 hit.setEdep(hit.getEdep() + edep);
123 if (time < hit.getTime() or hit.getTime() == 0) {