Main processing method.
38 if(a_step->GetTotalEnergyDeposit() <= 0.) {
return result; }
46 const G4ThreeVector
preStepPosition = a_step->GetPreStepPoint()->GetPosition();
47 const G4ThreeVector
postStepPosition = a_step->GetPostStepPoint()->GetPosition();
48 std::vector<const G4Step*>
steps;
49 bool madeSubSteps(
false);
53 G4double delta=1./((
double) nsub_step);
55 for (G4int
i=0;
i<nsub_step;
i++) {
56 G4double fraction1 = ((G4double)
i)*delta;
57 G4double fraction2 = (((G4double)
i) + 1.)*delta;
60 G4StepPoint *startpoint =
new G4StepPoint(*(a_step->GetPreStepPoint()));
61 G4StepPoint *endpoint =
new G4StepPoint(*(a_step->GetPostStepPoint()));
62 startpoint->SetPosition(subpoint1);
63 endpoint->SetPosition(subpoint2);
65 G4Step* newstep =
new G4Step(*a_step);
66 newstep->SetPreStepPoint(startpoint);
67 newstep->SetPostStepPoint(endpoint);
68 newstep->SetStepLength( (subpoint1-subpoint2).
mag());
69 newstep->SetTotalEnergyDeposit(a_step->GetTotalEnergyDeposit()/nsub_step);
70 steps.push_back(newstep);
75 steps.push_back(a_step);
79 G4cout <<
"LArFCS_StepInfoSD::ProcessHits(): original step in Volume: "<<
80 a_step->GetPreStepPoint()->GetPhysicalVolume()->GetName()<<
81 " position: "<<a_step->GetPreStepPoint()->GetPosition()<<
" Length="<<a_step->GetStepLength()/
CLHEP::mm<<
82 " E="<<a_step->GetTotalEnergyDeposit()<<G4endl;
83 std::vector<LArHitData> processedHits;
86 G4cout <<
" #LArHitData="<<processedHits.size();
87 for(
const auto& lhd:processedHits) {
88 G4cout <<
" ; id="<<(std::string)lhd.id<<
" E="<<lhd.energy<<G4endl;
93 G4cout <<
"LArFCS_StepInfoSD::ProcessHits(): #substep="<<
steps.size()<<G4endl;
97 for (
const G4Step* substep :
steps) {
99 G4ThreeVector stepPosition = 0.5*(substep->GetPreStepPoint()->GetPosition()+substep->GetPostStepPoint()->GetPosition());
100 std::vector<LArHitData> processedHits;
102 G4cout <<
" LArFCS_StepInfoSD::ProcessHits(): substep in Volume: "<<
103 substep->GetPreStepPoint()->GetPhysicalVolume()->GetName()<<
104 " position: "<<substep->GetPreStepPoint()->GetPosition()<<
" Length="<<substep->GetStepLength()/
CLHEP::mm<<
105 " E="<<substep->GetTotalEnergyDeposit()<<G4endl;
108 for (
const auto& larhit: processedHits) {
110 et_all += larhit.energy;
113 G4cout <<
" substep #LArHitData="<<processedHits.size();
114 for(
const auto& lhd:processedHits) {
115 G4cout <<
" ; id="<<(std::string)lhd.id<<
" E="<<lhd.energy<<G4endl;
122 G4cout << this->GetName()<<
" WARNING ProcessHits: Call to ILArCalculatorSvc::Process failed! Details:" << G4endl
123 <<
" " <<
"Volume: "<< a_step->GetPreStepPoint()->GetPhysicalVolume()->GetName()<<
" "<<
m_calculator<<
" position: "<<stepPosition<<
" SL: "<<
StepLength<<G4endl
124 <<
" " <<
"Orig position: "<<substep->GetPreStepPoint()->GetPosition()<<
" / "<<substep->GetPostStepPoint()->GetPosition()<<G4endl
134 G4cout << this->GetName()<<
" WARNING ProcessHits: Total negative energy: " <<
et <<
" not processing..." << G4endl;
139 const size_t numberOfProcessedHits = processedHits.size();
140 const G4ThreeVector originalStepPosition = stepPosition;
141 double maxSubHitEnergy = -999.;
142 int maxSubHitEnergyindex =-1;
143 if (numberOfProcessedHits>0) {
144 maxSubHitEnergy = processedHits[0].energy;
145 maxSubHitEnergyindex = 0;
148 for (
size_t i=1;
i<numberOfProcessedHits; ++
i) {
149 if (maxSubHitEnergy<processedHits[
i].
energy) {
150 maxSubHitEnergy = processedHits[
i].energy;
151 maxSubHitEnergyindex =
i;
154 if (maxSubHitEnergyindex == -1){
155 G4cout << this->GetName()<<
" WARNING ProcessHits: numberOfProcessedHits is zero" << G4endl;
164 for (
const auto& larhit: processedHits) {
166 if(larhit.id[0]==10) {
168 G4cout << this->GetName()<<
" VERBOSE ProcessHits: Dead Material LArG4Identifier: "<<(std::string) larhit.id<<G4endl
170 <<
" "<<
id.getString()<<G4endl
171 <<
" "<< a_step->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetName()<<G4endl
172 <<
" numberOfProcessedHits: "<<numberOfProcessedHits<<G4endl;
173 G4cout <<
" "<<invalidIdentifier<<G4endl;
176 else if (
id == invalidIdentifier) {
177 G4cout << this->GetName()<<
" WARNING ProcessHits: Something wrong with LArG4Identifier: "<<(std::string) larhit.id<<G4endl
180 <<
" "<< a_step->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetName()<<G4endl
181 <<
" numberOfProcessedHits: "<<numberOfProcessedHits<<G4endl;
182 G4cout <<
" "<<invalidIdentifier<<G4endl;
185 if (numberOfProcessedHits>1) {
188 G4cout << this->GetName()<<
" WARNING ProcessHits: Outside LAr barrel, but numberOfProcessedHits="<<numberOfProcessedHits
189 <<
", LArG4Identifier: "<<(std::string) larhit.id<<G4endl;
194 if (maxSubHitEnergyindex == -1) {
195 G4cout << this->GetName()<<
" WARNING ProcessHits: no subhit index with e>-999??? "<<G4endl;
199 G4cout << this->GetName()<<
" VERBOSE ProcessHits: shifting subhits: largest energy subhit index is "<<maxSubHitEnergyindex<<
" E: "<<maxSubHitEnergy<<
" identifier: "<<maxEnergyIdentifier.
getString()<<G4endl;
203 if (!maxEnergyCell) {
205 G4cout << this->GetName()<<
" WARNING ProcessHits: maxEnergyCell failed: "<<maxEnergyIdentifier.
getString()<<G4endl
207 <<
" "<<originalStepPosition.eta()<<G4endl
208 <<
" "<< originalStepPosition.phi()<<G4endl;
209 stepPosition = originalStepPosition;
211 else if (maxEnergyCell == thiscell) {
214 G4cout << this->GetName()<<
" VERBOSE ProcessHits: Original step position: "<<originalStepPosition.x()<<
" "<<originalStepPosition.y()<<
" "<<originalStepPosition.z()<<G4endl
215 <<
" "<<
"This cell: "<<thiscell->
x()<<
" "<<thiscell->
y()<<
" "<<thiscell->
z()<<G4endl
216 <<
" "<<
"No shift"<<G4endl;
218 stepPosition = originalStepPosition;
222 G4ThreeVector
diff(thiscell->
x()-maxEnergyCell->
x(), thiscell->
y()-maxEnergyCell->
y(), thiscell->
z()-maxEnergyCell->
z());
223 stepPosition = originalStepPosition+
diff;
226 G4cout << this->GetName()<<
" VERBOSE ProcessHits: Original step position: "<<originalStepPosition.x()<<
" "<<originalStepPosition.y()<<
" "<<originalStepPosition.z()<<G4endl
227 <<
" "<<
"This cell: "<<thiscell->
x()<<
" "<<thiscell->
y()<<
" "<<thiscell->
z()<<G4endl
228 <<
" "<<
"Highest E cell: "<<maxEnergyCell->
x()<<
" "<<maxEnergyCell->
y()<<
" "<<maxEnergyCell->
z()<<G4endl
229 <<
" "<<
"(Best cell: "<<bestcell->
x()<<
" "<<bestcell->
y()<<
" "<<bestcell->
z()<<
")"<<G4endl
230 <<
" "<<
"Shifted step position: "<<stepPosition.x()<<
" "<<stepPosition.y()<<
" "<<stepPosition.z()<<G4endl;
238 double time = larhit.time;
243 G4cout<<this->GetName()<<
" DEBUG update_map: bad identifier: "<<
id.getString()<<
" skipping this hit."<<G4endl;
251 this->
update_map(stepPosition,
id,
energy,
time,
true, numberOfProcessedHits, timeWindow, distanceWindow);
259 G4cout <<
"LArFCS_StepInfoSD::ProcessHits(): Etotal substeps="<<et_all<<G4endl<<G4endl<<G4endl;