154{
155
156 hdata.clear();
157
158 LArG4Identifier identifier2;
159 LArG4Identifier identifier_xt1;
160 LArG4Identifier identifier_xt2;
161
162
163 G4double thisStepEnergyDeposit =
step->GetTotalEnergyDeposit() *
step->GetTrack()->GetWeight();
164 G4double thisStepLength =
step->GetStepLength() / Units::mm;
165
166#ifdef DEBUGSTEP
167 ATH_MSG_DEBUG(
"****** LArBarrelCalculator: Step energy,length "
168 << thisStepEnergyDeposit << " " << thisStepLength);
169#endif
170
171 if(thisStepEnergyDeposit <= 0. || thisStepLength <= 0.)
172 {
173#ifdef DEBUGSTEP2
175#endif
176 return false;
177 }
178
179
180 G4StepPoint *thisStepPoint =
step->GetPreStepPoint();
181 G4StepPoint *thisStepBackPoint =
step->GetPostStepPoint();
182 G4ThreeVector startPoint = thisStepPoint->GetPosition();
183 G4ThreeVector endPoint = thisStepBackPoint->GetPosition();
184
185#ifdef DEBUGSTEP
187 << startPoint.x() << " " << startPoint.y() << " " << startPoint.z());
188#endif
189
190
191 G4int zSide = 1;
193 const G4NavigationHistory* g4navigation = thisStepPoint->GetTouchable()->GetHistory();
194 G4int ndep = g4navigation->GetDepth();
195 for (G4int ii=0;ii<=ndep;ii++) {
196 G4VPhysicalVolume* v1 = g4navigation->GetVolume(ii);
197 G4String vname = v1->GetName();
198 if ( vname.find("NegPhysical") != std::string::npos) zSide=-1;
199 }
200 }
201
202
203
204
205 const G4AffineTransform transformation =
206 thisStepPoint->GetTouchable()->GetHistory()->GetTopTransform();
207
208 G4ThreeVector startPointinLocal =
209 transformation.TransformPoint(startPoint);
210 G4ThreeVector endPointinLocal =
211 transformation.TransformPoint (endPoint);
212
213#ifdef DEBUGSTEP
215 << startPointinLocal.x() << " " << startPointinLocal.y() << " "
216 << startPointinLocal.z());
218 << endPointinLocal.x() << " " << endPointinLocal.y() << " "
219 << endPointinLocal.z());
220#endif
221
222 G4double
energy =
step->GetTotalEnergyDeposit() *
step->GetTrack()->GetWeight();
223
225 const double EField = 10.;
226 const double wholeStepLengthCm =
step->GetStepLength() / CLHEP::cm;
227 energy = (*m_birksLaw)(
energy, wholeStepLengthCm, EField);
228 }
229
230
231
232
233
234
235 G4int nsub_step=1;
237
238 G4double delta=1./((
double) nsub_step);
239#ifdef DEBUGSTEP
240 ATH_MSG_DEBUG(
" nsub_step,delta " << nsub_step <<
" " << delta);
241#endif
242
244
245
246
247 for (G4int i=0;
i<nsub_step;
i++) {
248
249 bool Xtalk = false;
250
251 G4double fraction=(((G4double)
i)+0.5)*delta;
252 G4ThreeVector subinLocal=startPointinLocal*(1-fraction) + endPointinLocal*fraction;
253 G4double xloc = subinLocal.x();
254 G4double yloc = subinLocal.y();
255 G4double zloc = subinLocal.z();
256 G4double etaloc = subinLocal.pseudoRapidity();
257 G4double philoc = subinLocal.phi();
258 if(philoc<0.) philoc = philoc + 2.*
M_PI;
259 G4double radloc = sqrt( xloc*xloc + yloc*yloc );
260#ifdef DEBUGSTEP
262 << xloc << " " << yloc << " " << zloc);
263#endif
264
265
267#ifdef DEBUGSTEP
269#endif
270 continue;
271 }
272 LArG4::Barrel::CalcData currentCellData;
274
275 if (currentCellData.
cellID == 0)
276 {
277#ifdef DEBUGSTEP
278 ATH_MSG_DEBUG(
"LArBarrelCalculator: Invalid hit CELLID == 0 ");
279 ATH_MSG_DEBUG(
"x,y,z local " << xloc <<
" " << yloc <<
" " << zloc);
280 ATH_MSG_DEBUG(
"radius " << radloc <<
" etaloc "<< etaloc <<
" philoc " << philoc);
281#endif
282 continue;
283 }
284 G4int region = currentCellData.
region;
287 G4int sampling = currentCellData.
sampling;
288
289 if( zSide == -1 )
290 {
291
292 if( sampling == 1 && region ==0 )
293 {
295 if(phiBin < 0 )
phiBin += 64;
296 }
297 if( sampling == 1 && region ==1 )
298 {
300 if(phiBin < 0 )
phiBin += 256;
301 }
302 if( sampling >= 2 )
303 {
305 if(phiBin < 0 )
phiBin += 256;
306 }
307 }
308#ifdef DEBUGSTEP
309 ATH_MSG_DEBUG(
" region,side,sampling,eta,phi " << region <<
" " << zSide <<
" "
310 << sampling << " " << etaBin << " " << phiBin);
313 ATH_MSG_DEBUG(
" local coordinates " << currentCellData.
x0 <<
" " << currentCellData.
y0);
314#endif
315
318#ifdef DEBUGSTEP
319 ATH_MSG_DEBUG(
" hit in absorber or electrode radius:" << radloc);
320#endif
321 continue;
322 }
323
325 identifier2 << 4
326 << 1
327 << zSide
328 << sampling
329 << region
332
333
334
335
336
337
338
339
340
341
342
343
344
346 ( thisStepPoint->GetGlobalTime() - ( thisStepPoint->GetPosition().
mag()/CLHEP::
c_light ) ) / Units::
ns;
347
348#ifdef DEBUGSTEP
350#endif
351
352 G4double Current;
353 G4double Current_xt1,Current_xt2;
354 Current_xt1=0;
355 Current_xt2=0;
357
359 }
360 else {
361
362 G4double xmap,ymap;
363 G4int nfold = currentCellData.
nfold;
364 G4double x0=currentCellData.
x0;
365 G4double y0=currentCellData.
y0;
366 if (x0<1500 || x0>1960 || y0>30 || y0<-30) {
368 }
369#ifdef DEBUGSTEP
370 G4double
rr = sqrt(x0*x0+y0*y0);
372#endif
373 const CurrMap* mapOfCurrent(nullptr);
374 bool UseFold=false;
375
376 if ((x0 >
m_accmap->GetXmin(nfold) || nfold==0) &&
377 x0 < m_accmap->GetXmax(nfold) &&
379 y0 < m_accmap->GetYmax(nfold) &&
380 (nfold != 13 || x0 < 1957.5) &&
381 (nfold>0 || x0 < 1504.6) ) {
382 xmap=x0;
383 ymap=y0;
384#ifdef DEBUGSTEP
385 ATH_MSG_DEBUG(
" Map for fold xmap,ymap " << nfold <<
" " << xmap <<
" " << ymap);
386#endif
387 UseFold=true;
388 G4int sampMap = currentCellData.
sampMap;
390 mapOfCurrent =
m_accmap->GetMap(nfold,region,sampMap,etaMap);
391
392 if (!mapOfCurrent) {
394 ATH_MSG_WARNING(
" region,sampling,eta,fold " << region <<
" " << sampMap <<
" "
395 << etaMap << " " << nfold);
396 return false;
397 }
398 }
399 else {
401 G4int nstraight = currentCellData.
nstraight;
402 if (nstraight%2==0)
n=22;
404 mapOfCurrent =
m_accmap->GetMap(n,region,sampling,etaBin);
405
406 if (!mapOfCurrent) {
408 return false;
409 }
410 xmap = currentCellData.
xl;
412
413 if (nstraight==0) xmap = 0.5*(xmap+1.);
414#ifdef DEBUGSTEP
415 ATH_MSG_DEBUG(
" Map for straight xl,delec " << xmap <<
" " << ymap);
416#endif
417 }
419 double current0,current1,current2;
420
421 mapOfCurrent->GetAll(xmap,ymap,&gap,¤t0,¤t1,¤t2);
422 G4double gap2=std::fabs(currentCellData.
distElec)+std::fabs(currentCellData.
distAbs)
424
425
426 int ipm,ielec,ieta,iside;
427 if (zSide==1) ipm=1;
428 else ipm=0;
429 ielec=currentCellData.
phiGap;
430 if (zSide==-1) {
431 ielec = 511 - ielec;
432 if(ielec < 0 ) ielec += 1024;
433 }
434 ieta=((
int) (etaloc*(1./0.2)));
435 if (ieta>6) ieta=6;
436 iside=0;
437 if ((currentCellData.
distElec>0 && zSide==1)
438 || (currentCellData.
distElec<0 && zSide==-1) ) iside=1;
439
440
442 double hv=
m_hv[ipm][ielec][ieta][iside];
443 if (hv>1995.)
current=current0;
446
447
448
449
450
451
452
453 double dgap=0;
454 if (gap>1e-3 && gap2 >1e-3) dgap=
gap/gap2-1;
456
457#ifdef DEBUGSTEP
459 ATH_MSG_DEBUG(
" Gap from Map/calculator " << gap <<
" " << gap2);
460#endif
461
463
464
465 if (!UseFold && std::fabs(currentCellData.
distElec)>2.1 && current0 < 0.1) {
468 <<
" str number " << currentCellData.
nstraight
469 << " sampling,eta " << sampling << " " << etaBin << " "
470 << " current/E " << current0);
471 }
472
473
474
475
476
477 bool InTrans=false;
478
480 float etaTrans=0.8;
481 if (fabs(etaloc-etaTrans) < 0.025) {
482 double x=std::fabs(zloc-radloc*sinh(etaTrans))/cosh(etaTrans);
483 double y=std::fabs(currentCellData.
distElec);
485 double resp;
487 Current = Current*resp;
488 InTrans=true;
489 }
490 }
491 }
492
493
494
495
496 if (region==0) {
497
498 double resp,xt0,xt1,xt2,deta;
499 if (sampling==1) {
502 &resp,&xt0,&xt1,&xt2);
503#ifdef DEBUGSTEP
504 ATH_MSG_DEBUG(
"hit in strip etaloc,etaBin,deta,delec,resp,xt0,xt1,xt2 "
505 << etaloc <<
" " << etaBin <<
" " << deta*1000 <<
" " << currentCellData.
distElec
506 << " " << resp << " " << xt0 << " " << xt1 << " " << xt2);
507#endif
508 if (!InTrans) Current = Current*resp;
509 if (
m_IflXtalk && etaBin > 1 && etaBin < 446) {
510 Xtalk=true;
511 if (deta>0) {
512 identifier_xt1.
clear();
513 identifier_xt1 << 4 << 1 << zSide << sampling << region << (
etaBin+1) << phiBin;
514 Current_xt1 = Current*xt1;
515 identifier_xt2.
clear();
516 identifier_xt2 << 4 << 1 << zSide << sampling << region << (
etaBin-1) << phiBin;
517 Current_xt2 = Current*xt2;
518 }
519 else {
520 identifier_xt1.
clear();
521 identifier_xt1 << 4 << 1 << zSide << sampling << region << (
etaBin-1) << phiBin;
522 Current_xt1 = Current*xt1;
523 identifier_xt2.
clear();
524 identifier_xt2 << 4 << 1 << zSide << sampling << region << (
etaBin+1) << phiBin;
525 Current_xt2 = Current*xt2;
526 }
527 Current = Current*xt0;
528 }
529 }
530 else if (sampling==2 && !InTrans) {
533 &resp);
534#ifdef DEBUGSTEP
535 ATH_MSG_DEBUG(
"hit in middle etaloc,etaBin,deta,delec,resp,xt0,xt1,xt2 "
536 << etaloc <<
" " << etaBin <<
" " << deta*1000 <<
" " << currentCellData.
distElec
537 << " " << resp);
538#endif
539 Current = Current*resp;
540 }
541
542 }
543
544 }
545
546
547
548
550 for (
unsigned int i=0;
i<hdata.size();
i++) {
551 if (hdata[i].id==identifier2) {
552 hdata[
i].energy += Current;
553 hdata[
i].time +=
time*Current;
555 break;
556 }
557 }
558 if (!found) {
559 hdata.emplace_back(LArHitData{identifier2,
time*Current, Current});
560 }
561
562 if (Xtalk) {
563 for (
unsigned int i=0;
i<hdata.size();
i++) {
564 if (hdata[i].id==identifier_xt1) {
565 hdata[
i].energy += Current_xt1;
566 hdata[
i].time +=
time*Current_xt1;
568 break;
569 }
570 }
571 if (!found) {
572 hdata.emplace_back(LArHitData{identifier_xt1,
time*Current_xt1, Current_xt1});
573 }
575 for (
unsigned int i=0;
i<hdata.size();
i++) {
576 if (hdata[i].id==identifier_xt2) {
577 hdata[
i].energy += Current_xt2;
578 hdata[
i].time +=
time*Current_xt2;
580 break;
581 }
582 }
583 if (!found) {
584 hdata.emplace_back(LArHitData{identifier_xt2,
time*Current_xt2, Current_xt2});
585 }
586 }
587
588
589 }
590
591#ifdef DEBUGSTEP
592 ATH_MSG_DEBUG(
"Number of hits for this step " << m_nhits <<
" "
593 << hdata.size());
594#endif
595
596
597 for (
unsigned int i=0;
i<hdata.size();
i++) {
598 if (std::fabs(hdata[i].energy)>1e-6) hdata[
i].time=hdata[
i].time/hdata[
i].energy;
599 else hdata[
i].time=0.;
600#ifdef DEBUGSTEP
602 << hdata[i].energy << " " << hdata[i].time);
603#endif
604 }
605
606 if (hdata.size()>0) return true;
607 return false;
608}
const boost::regex rr(r_r)
Scalar mag() const
mag method
Gaudi::Property< bool > m_IflXtalk
double ScaleHV(double, double, double, double) const
G4bool FiducialCuts(G4double, G4double, G4double) const
Gaudi::Property< double > m_dstep
gap(flags, cells_name, *args, **kw)
time(flags, cells_name, *args, **kw)
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setPhiMap phiBin
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap etaBin
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner etaMap