Main processing method.
34 if (a_step->GetTotalEnergyDeposit() <= 0.) {
45 a_step->GetPreStepPoint()
48 a_step->GetPostStepPoint()->GetPosition();
49 std::vector<const G4Step*>
steps;
50 bool madeSubSteps(
false);
54 G4double delta = 1. / ((
double)nsub_step);
56 for (G4int
i = 0;
i < nsub_step;
i++) {
57 G4double fraction1 = ((G4double)
i) * delta;
58 G4double fraction2 = (((G4double)
i) + 1.) * delta;
59 G4ThreeVector subpoint1 =
61 G4ThreeVector subpoint2 =
63 G4StepPoint* startpoint =
new G4StepPoint(*(a_step->GetPreStepPoint()));
64 G4StepPoint* endpoint =
new G4StepPoint(*(a_step->GetPostStepPoint()));
65 startpoint->SetPosition(subpoint1);
66 endpoint->SetPosition(subpoint2);
68 G4Step* newstep =
new G4Step(*a_step);
69 newstep->SetPreStepPoint(startpoint);
70 newstep->SetPostStepPoint(endpoint);
71 newstep->SetStepLength((subpoint1 - subpoint2).
mag());
72 newstep->SetTotalEnergyDeposit(a_step->GetTotalEnergyDeposit() /
74 steps.push_back(newstep);
78 steps.push_back(a_step);
82 G4cout <<
"LArFCS_StepInfoSD::ProcessHits(): original step in Volume: "
83 << a_step->GetPreStepPoint()->GetPhysicalVolume()->GetName()
84 <<
" position: " << a_step->GetPreStepPoint()->GetPosition()
85 <<
" Length=" << a_step->GetStepLength() /
CLHEP::mm
86 <<
" E=" << a_step->GetTotalEnergyDeposit() << G4endl;
87 std::vector<LArHitData> processedHits;
90 G4cout <<
" #LArHitData=" << processedHits.size();
91 for (
const auto& lhd : processedHits) {
92 G4cout <<
" ; id=" << (std::string)lhd.id <<
" E=" << lhd.energy
98 G4cout <<
"LArFCS_StepInfoSD::ProcessHits(): #substep=" <<
steps.size()
103 for (
const G4Step* substep :
steps) {
105 G4ThreeVector stepPosition =
106 0.5 * (substep->GetPreStepPoint()->GetPosition() +
107 substep->GetPostStepPoint()->GetPosition());
108 std::vector<LArHitData> processedHits;
110 G4cout <<
" LArFCS_StepInfoSD::ProcessHits(): substep in Volume: "
111 << substep->GetPreStepPoint()->GetPhysicalVolume()->GetName()
112 <<
" position: " << substep->GetPreStepPoint()->GetPosition()
113 <<
" Length=" << substep->GetStepLength() /
CLHEP::mm
114 <<
" E=" << substep->GetTotalEnergyDeposit() << G4endl;
117 for (
const auto& larhit : processedHits) {
119 et_all += larhit.energy;
122 G4cout <<
" substep #LArHitData=" << processedHits.size();
123 for (
const auto& lhd : processedHits) {
124 G4cout <<
" ; id=" << (std::string)lhd.id <<
" E=" << lhd.energy
132 G4cout << this->GetName()
133 <<
" WARNING ProcessHits: Call to ILArCalculatorSvc::Process "
135 << G4endl <<
" " <<
"Volume: "
136 << a_step->GetPreStepPoint()->GetPhysicalVolume()->GetName()
140 << substep->GetPreStepPoint()->GetPosition() <<
" / "
141 << substep->GetPostStepPoint()->GetPosition() << G4endl
154 G4cout << this->GetName()
155 <<
" WARNING ProcessHits: Total negative energy: " <<
et
156 <<
" not processing..." << G4endl;
161 const size_t numberOfProcessedHits = processedHits.size();
162 const G4ThreeVector originalStepPosition = stepPosition;
163 double maxSubHitEnergy = -999.;
164 int maxSubHitEnergyindex = -1;
165 if (numberOfProcessedHits > 0) {
166 maxSubHitEnergy = processedHits[0].energy;
167 maxSubHitEnergyindex = 0;
170 for (
size_t i = 1;
i < numberOfProcessedHits; ++
i) {
171 if (maxSubHitEnergy < processedHits[
i].
energy) {
172 maxSubHitEnergy = processedHits[
i].energy;
173 maxSubHitEnergyindex =
i;
176 if (maxSubHitEnergyindex ==
178 G4cout << this->GetName()
179 <<
" WARNING ProcessHits: numberOfProcessedHits is zero"
185 this->
ConvertID(processedHits[maxSubHitEnergyindex].
id);
191 for (
const auto& larhit : processedHits) {
193 if (larhit.id[0] == 10) {
195 G4cout << this->GetName()
196 <<
" VERBOSE ProcessHits: Dead Material LArG4Identifier: "
197 << (std::string)larhit.id << G4endl <<
" " <<
id
198 << G4endl <<
" " <<
id.getString() << G4endl
200 << a_step->GetPreStepPoint()
201 ->GetPhysicalVolume()
204 << G4endl <<
" numberOfProcessedHits: "
205 << numberOfProcessedHits << G4endl;
206 G4cout <<
" " << invalidIdentifier << G4endl;
208 }
else if (
id == invalidIdentifier) {
211 <<
" WARNING ProcessHits: Something wrong with LArG4Identifier: "
212 << (std::string)larhit.id << G4endl <<
" " <<
id
213 << G4endl <<
" " <<
id.
getString() << G4endl
215 << a_step->GetPreStepPoint()
216 ->GetPhysicalVolume()
220 <<
" numberOfProcessedHits: " << numberOfProcessedHits
222 G4cout <<
" " << invalidIdentifier << G4endl;
225 if (numberOfProcessedHits > 1) {
229 G4cout << this->GetName()
230 <<
" WARNING ProcessHits: Outside LAr barrel, but "
231 "numberOfProcessedHits="
232 << numberOfProcessedHits
233 <<
", LArG4Identifier: " << (std::string)larhit.id << G4endl;
237 if (maxSubHitEnergyindex == -1) {
240 <<
" WARNING ProcessHits: no subhit index with e>-999??? "
245 G4cout << this->GetName()
246 <<
" VERBOSE ProcessHits: shifting subhits: largest "
247 "energy subhit index is "
248 << maxSubHitEnergyindex <<
" E: " << maxSubHitEnergy
249 <<
" identifier: " << maxEnergyIdentifier.
getString()
255 if (!maxEnergyCell) {
257 G4cout << this->GetName()
258 <<
" WARNING ProcessHits: maxEnergyCell failed: "
259 << maxEnergyIdentifier.
getString() << G4endl
262 << G4endl <<
" " << originalStepPosition.eta()
263 << G4endl <<
" " << originalStepPosition.phi()
265 stepPosition = originalStepPosition;
266 }
else if (maxEnergyCell == thiscell) {
269 G4cout << this->GetName()
270 <<
" VERBOSE ProcessHits: Original step position: "
271 << originalStepPosition.x() <<
" "
272 << originalStepPosition.y() <<
" "
273 << originalStepPosition.z() << G4endl <<
" "
274 <<
"This cell: " << thiscell->
x() <<
" "
275 << thiscell->
y() <<
" " << thiscell->
z() << G4endl
276 <<
" " <<
"No shift" << G4endl;
278 stepPosition = originalStepPosition;
281 G4ThreeVector
diff(thiscell->
x() - maxEnergyCell->
x(),
282 thiscell->
y() - maxEnergyCell->
y(),
283 thiscell->
z() - maxEnergyCell->
z());
284 stepPosition = originalStepPosition +
diff;
289 originalStepPosition.eta(),
290 originalStepPosition.phi());
291 G4cout << this->GetName()
292 <<
" VERBOSE ProcessHits: Original step position: "
293 << originalStepPosition.x() <<
" "
294 << originalStepPosition.y() <<
" "
295 << originalStepPosition.z() << G4endl <<
" "
296 <<
"This cell: " << thiscell->
x() <<
" "
297 << thiscell->
y() <<
" " << thiscell->
z() << G4endl
299 <<
"Highest E cell: " << maxEnergyCell->
x() <<
" "
300 << maxEnergyCell->
y() <<
" " << maxEnergyCell->
z()
302 <<
"(Best cell: " << bestcell->
x() <<
" "
303 << bestcell->
y() <<
" " << bestcell->
z() <<
")"
305 <<
"Shifted step position: " << stepPosition.x() <<
" "
306 << stepPosition.y() <<
" " << stepPosition.z()
316 double time = larhit.time;
321 G4cout << this->GetName()
322 <<
" DEBUG update_map: bad identifier: " <<
id.getString()
323 <<
" skipping this hit." << G4endl;
329 numberOfProcessedHits);
335 while (!
steps.empty()) {
341 G4cout <<
"LArFCS_StepInfoSD::ProcessHits(): Etotal substeps=" << et_all
342 << G4endl << G4endl << G4endl;