75{
76
77 auto edep = step->GetTotalEnergyDeposit();
78
79
80 G4double stepLength = 0.;
81 if ( step->GetTrack()->GetDefinition()->GetPDGCharge() != 0. ) {
82 stepLength = step->GetStepLength();
83 }
84
85 if ( edep==0. && stepLength == 0. ) return false;
86
87 auto touchable = (step->GetPreStepPoint()->GetTouchable());
88
89
90 auto layerNumber = touchable->GetReplicaNumber(1);
91
92
93 auto hit = (*fHitsCollection)[layerNumber];
94 if ( ! hit ) {
95 G4ExceptionDescription msg;
96 msg << "Cannot access hit " << layerNumber;
97 G4Exception("CalorimeterSD::ProcessHits()",
98 "MyCode0004", FatalException, msg);
99 }
100
101
102 auto hitTotal
104
105
106 hit->Add(edep, stepLength);
107 hitTotal->Add(edep, stepLength);
108
109 return true;
110}