271 {
272
274
275
276 unsigned int SampleID =
cell->caloDDE()->getSampling();
277
278
279 double pathl = 0.;
280 double Layer1X(
exit->position().x()),Layer1Y(
exit->position().y()),Layer1Z(
exit->position().z());
282
283 double CellPhi(
cell->caloDDE()->phi()),CellDPhi(
cell->caloDDE()->dphi());
284 double CellPhimin = CellPhi-CellDPhi/2.;
285 double CellPhimax = CellPhi+CellDPhi/2.;
286 double CellEta(
cell->caloDDE()->eta());
287 double CellZ(
cell->caloDDE()->z()),CellDZ(
cell->caloDDE()->dz());
288 double CellZmin = CellZ-CellDZ/2.;
289 double CellZmax = CellZ+CellDZ/2.;
290 double CellR(
cell->caloDDE()->r()),CellDR(
cell->caloDDE()->dr());
291 double CellRmin = CellR-CellDR/2.;
292 double CellRmax = CellR+CellDR/2.;
293
294
295 double RLBAmin = 2300;
296 double RLBAmax = 2600;
297 double RLBBmin = 2600;
298 double RLBBmax = 2990;
299 double RLBCmin = 2990;
300 double RLBCmax = 3440;
301 double RLBDmin = 3440;
302 double RLBDmax = 3820;
303
304 double REBAmin = 2300;
305 double REBAmax = 2600;
306 double REBBmin = 2600;
307 double REBBmax = 3140;
308 double REBDmin = 3140;
309 double REBDmax = 3820;
310
311 double RITC_D4_min = 3630 - 380./2.;
312 double RITC_C10_min = 3215 - 450./2.;
313 double RITC_E1_min = 2803 - 313./2.;
314 double RITC_E2_min = 2476 - 341./2.;
315 double RITC_E3_min = 2066 - 478./2.;
316 double RITC_E4_min = 1646 - 362./2.;
317
318 double RITC_D4_max = 3630 + 380./2.;
319 double RITC_C10_max = 3215 + 450./2.;
320 double RITC_E1_max = 2803 + 313./2.;
321 double RITC_E2_max = 2476 + 341./2.;
322 double RITC_E3_max = 2066 + 478./2.;
323 double RITC_E4_max = 1646 + 362./2.;
324
325 double ZITC_D4_a = 3405;
326 double ZITC_C10_a = 3511;
327 double ZITC_E1_a = 3552;
328
329 double ZITC_E3_a = 3536;
330
331
332 double ZITC_D4_c = 3395;
333 double ZITC_C10_c = 3501;
334 double ZITC_E1_c = 3542;
335
336 double ZITC_E3_c = 3526;
337
338
339 double ZDITC_D4 = 309.;
340 double ZDITC_C10 = 95.;
341 double ZDITC_E1 = 12.;
342
343 double ZDITC_E3 = 6.;
344
345
346 double CellZB[9] = {141.495, 424.49, 707.485, 999.605, 1300.855, 1615.8, 1949., 2300.46, 2651.52};
347 double CellDZB[9] = {282.99, 283., 282.99, 301.25, 301.25, 328.64, 337.76, 365.16, 336.96};
348 double CellZC[9] = {159.755, 483.83, 812.465, 1150.23, 1497.125, 1857.71, 2241.12, 2628.695,0};
349 double CellDZC[9] = {319.51, 328.64, 328.63, 346.9, 346.89, 374.28, 392.54, 382.61,0};
350
351 double CellXimp[2], CellYimp[2], CellZimp[2];
352
353 double X(0),
Y(0),
Z(0),
R(0),
Phi(0);
354 double DeltaPhi;
355
356 int etaInd(-1);
357
358 float samplecellmap[81] = {
359 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
360 13, 13, 13, 13, 13, 13, 13, 13, 13,
361 14, 14, 14, 14,
362 16, 15, 17, 17, 17, 17,
363 18, 18, 18, 18, 18,
364 19, 19, 19, 19, 19,
365 20, 20,
366 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
367 13, 13, 13, 13, 13, 13, 13, 13, 13,
368 14, 14, 14,
369 16, 15, 17, 17, 17, 17,
370 18, 18, 18, 18, 18,
371 19, 19, 19, 19, 19,
372 20, 20
373 };
374 float etacellmap[81] = { 0.05,0.15,0.25,0.35,0.45,0.55,0.65,0.75,0.85,0.95,
375 0.05,0.15,0.25,0.35,0.45,0.55,0.65,0.75,0.85,
376 0.0, 0.2,0.4,0.6,
377 0.8579205,0.9583722,1.0589020,1.1593041,1.3098471,1.5103633,
378 1.1594202,1.2586680,1.3579534,1.4572804,1.556651,
379 1.0586925,1.1580252,1.2573844,1.3567756,1.4562022,
380 1.0074122,1.2063241,
381 -0.05,-0.15,-0.25,-0.35,-0.45,-0.55,-0.65,-0.75,-0.85,-0.95,
382 -0.05,-0.15,-0.25,-0.35,-0.45,-0.55,-0.65,-0.75,-0.85,
383 -0.2,-0.4,-0.6,
384 -0.855940, -0.956279, -1.056676, -1.156978,-1.307385,-1.507772,
385 -1.157065,-1.256501,-1.355965,-1.455460,-1.554988,
386 -1.056519,-1.156018,-1.255538,-1.355081,-1.454651,
387 -1.005559,-1.204743
388 };
389
390 for(
int i=0;
i<81;
i++){
391 if(SampleID==samplecellmap[i] && fabs(CellEta-etacellmap[i])<0.001) etaInd =
i;
392 }
393
394
395 bool compute = true;
396 int lBC(0);
397 while(compute){
398 if(lBC==1 && (etaInd==18 || etaInd==59) ) break;
399 int Np = 0;
400 if(sqrt((Layer1X-Layer2X)*(Layer1X-Layer2X)+(Layer1Y-Layer2Y)*(Layer1Y-Layer2Y)) < 3818.5){
401 if(SampleID == 15){
402 CellRmin = RITC_C10_min;
403 CellRmax = RITC_C10_max;
404 if(CellEta > 0){
405 if(CellZmin < ZITC_C10_a-ZDITC_C10/2.) CellZmin = ZITC_C10_a-ZDITC_C10/2.;
406 if(CellZmax > ZITC_C10_a+ZDITC_C10/2.) CellZmax = ZITC_C10_a+ZDITC_C10/2.;
407 }
408 else if(CellEta < 0){
409 if(CellZmin < -ZITC_C10_c-ZDITC_C10/2.) CellZmin = -ZITC_C10_c-ZDITC_C10/2.;
410 if(CellZmax > -ZITC_C10_c+ZDITC_C10/2.) CellZmax = -ZITC_C10_c+ZDITC_C10/2.;
411 }
412 }
413 else if(SampleID == 16){
414 CellRmin=RITC_D4_min;
415 CellRmax=RITC_D4_max;
416 if(CellEta > 0){
417 if(CellZmin < ZITC_D4_a-ZDITC_D4/2.) CellZmin = ZITC_D4_a-ZDITC_D4/2.;
418 if(CellZmax > ZITC_D4_a+ZDITC_D4/2.) CellZmax = ZITC_D4_a+ZDITC_D4/2.;
419 }
420 else if(CellEta < 0){
421 if(CellZmin < -ZITC_D4_c-ZDITC_D4/2.) CellZmin = -ZITC_D4_c-ZDITC_D4/2.;
422 if(CellZmax > -ZITC_D4_c+ZDITC_D4/2.) CellZmax = -ZITC_D4_c+ZDITC_D4/2.;
423 }
424 }
425 else if(SampleID == 17){
426 if( etaInd==25 || etaInd==65 ){
427 CellRmax = RITC_E1_max;
428 CellRmin = RITC_E1_min;
429 }
430 else if( etaInd==26 || etaInd==66 ){
431 CellRmax = RITC_E2_max;
432 CellRmin = RITC_E2_min;
433 }
434 else if( etaInd==27 || etaInd==67 ){
435 CellRmax = RITC_E3_max;
436 CellRmin = RITC_E3_min;
437 }
438 else if( etaInd==28 || etaInd==68 ){
439 CellRmax = RITC_E4_max;
440 CellRmin = RITC_E4_min;
441 }
442 if( (etaInd>=25 && etaInd<=26) || (etaInd>=65 && etaInd<=66) ){
443 if(CellEta > 0){
444 if(CellZmin < ZITC_E1_a-ZDITC_E1/2.) CellZmin=ZITC_E1_a-ZDITC_E1/2.;
445 if(CellZmax > ZITC_E1_a+ZDITC_E1/2.) CellZmax=ZITC_E1_a+ZDITC_E1/2.;
446 }
447 else if(CellEta < 0){
448 if(CellZmin < -ZITC_E1_c-ZDITC_E1/2.) CellZmin= -ZITC_E1_c-ZDITC_E1/2.;
449 if(CellZmax > -ZITC_E1_c+ZDITC_E1/2.) CellZmax= -ZITC_E1_c+ZDITC_E1/2.;
450 }
451 }
452 else if( (etaInd>=27 && etaInd<=28) || (etaInd>=67 && etaInd<=68) ){
453 if(CellEta > 0){
454 if(CellZmin < ZITC_E3_a-ZDITC_E3/2.) CellZmin=ZITC_E3_a-ZDITC_E3/2.;
455 if(CellZmax > ZITC_E3_a+ZDITC_E3/2.) CellZmax=ZITC_E3_a+ZDITC_E3/2.;
456 }
457 else if(CellEta < 0){
458 if(CellZmin < -ZITC_E3_c-ZDITC_E3/2.) CellZmin= -ZITC_E3_c-ZDITC_E3/2.;
459 if(CellZmax > -ZITC_E3_c+ZDITC_E3/2.) CellZmax= -ZITC_E3_c+ZDITC_E3/2.;
460 }
461 }
462 }
463 else if(SampleID == 12){
464 CellRmin = RLBAmin;
465 CellRmax = RLBAmax;
466
467 if(CellZmin <-2802.5439) CellZmin=-2802.5439;
468 if(CellZmax > 2802.5454) CellZmax=2802.5454;
469 }
470 else if(SampleID == 13 && lBC == 0){
471 CellRmin = RLBBmin;
472 CellRmax = RLBBmax;
473 int cpos = fabs(CellEta)/0.1;
474 CellZ = CellZB[cpos];
475 if(CellEta < 0) CellZ=-CellZ;
476 CellDZ = CellDZB[cpos];
477 CellZmin = CellZ-CellDZ/2;
478 CellZmax = CellZ+CellDZ/2;
479 if(CellZmin <-2802.5439) CellZmin=-2802.5439;
480 if(CellZmax > 2802.5454) CellZmax=2802.5454;
481 }
482 else if(SampleID == 13 && lBC == 1){
483 CellRmin = RLBCmin;
484 CellRmax = RLBCmax;
485 int cpos = fabs(CellEta)/0.1;
486 if(cpos >= 8) return 0;
487 CellZ = CellZC[cpos];
488 if(CellEta < 0) CellZ=-CellZ;
489 CellDZ = CellDZC[cpos];
490 CellZmin = CellZ-CellDZ/2;
491 CellZmax = CellZ+CellDZ/2;
492 if(CellZmin <-2802.5439) CellZmin=-2802.5439;
493 if(CellZmax >2802.5454) CellZmax=2802.5454;
494 }
495 else if(SampleID == 14){
496 CellRmin = RLBDmin;
497 CellRmax = RLBDmax;
498 if(CellZmin <-2802.5439) CellZmin=-2802.5439;
499 if(CellZmax >2802.5454) CellZmax=2802.5454;
500 }
501 if(SampleID == 18){
502 CellRmin = REBAmin;
503 CellRmax = REBAmax;
504 if(CellEta > 0){
505 if(CellZmin <3574.5027) CellZmin=3574.4978;
506 if(CellZmax >6130.0039) CellZmax=6130.0039;
507 }
508 else if(CellEta < 0){
509 if(CellZmin <-6120.0018) CellZmin=-6120.0018;
510 if(CellZmax >-3564.5006) CellZmax=-3564.5006;
511 }
512 }
513 if(SampleID == 19){
514 CellRmin = REBBmin;
515 CellRmax = REBBmax;
516 if(CellEta > 0){
517 if(CellZmin <3574.5027) CellZmin=3574.4978;
518 if(CellZmax >6130.0039) CellZmax=6130.0039;
519 }
520 else if(CellEta < 0){
521 if(CellZmin <-6120.0018) CellZmin=-6120.0018;
522 if(CellZmax >-3564.5006) CellZmax=-3564.5006;
523 }
524 }
525 if(SampleID == 20){
526 CellRmin = REBDmin;
527 CellRmax = REBDmax;
528 if(CellEta > 0){
529 if(CellZmin <3574.5027) CellZmin=3574.4978;
530 if(CellZmax >6130.0039) CellZmax=6130.0039;
531 }
532 else if(CellEta < 0){
533 if(CellZmin <-6120.0018) CellZmin=-6120.0018;
534 if(CellZmax >-3564.5006) CellZmax=-3564.5006;
535 }
536 }
537
538
539
541
542 double x0int(
exit->position().x()), x1int(entrance->
position().x()),
543 y0int(
exit->position().y()), y1int(entrance->
position().y()),
544 z0int(
exit->position().z()), z1int(entrance->
position().z());
545 double S((y1int-y0int)/(x1int-x0int));
546 double a(1+S*S),
b(2*S*y0int-2*S*S*x0int),
c(y0int*y0int-Radius*Radius+S*S*x0int*x0int-2*y0int*S*x0int);
547 double x1((-b+sqrt(b*b-4*
a*c))/(2*
a)),
x2((-b-sqrt(b*b-4*
a*c))/(2*
a));
548 double y1(y0int+S*(x1-x0int)),
y2(y0int+S*(x2-x0int));
549 double S1 = ((z1int-z0int)/(x1int-x0int));
550 double z1(z0int+
S1*(x1-x0int)), z2(z0int+
S1*(x2-x0int));
551
555
556 if( ((x1-x0int)*(x1-x0int)+(y1-y0int)*(y1-y0int)+(z1-z0int)*(z1-z0int)) >
557 ((x2-x0int)*(x2-x0int)+(y2-y0int)*(y2-y0int)+(z2-z0int)*(z2-z0int)) ){
561 }
562
563 Phi = acos(X/sqrt(X*X+Y*Y));
566
567 if(Z>=CellZmin && Z<=CellZmax && Phi>=CellPhimin &&
Phi<=CellPhimax){
571 Np=Np+1;
572
573 }
574
576
578 x1 = ((-
b+sqrt(b*b-4*
a*c))/(2*
a));
579 x2 = ((-
b-sqrt(b*b-4*
a*c))/(2*
a));
580 y1 = (y0int+
S*(
x1-x0int));
581 y2 = (y0int+
S*(
x2-x0int));
582 z1 = (z0int+
S1*(
x1-x0int));
583 z2 = (z0int+
S1*(
x2-x0int));
584 S1 = ((z1int-z0int)/(x1int-x0int));
585
589
590 if( ((x1-x0int)*(x1-x0int)+(y1-y0int)*(y1-y0int)+(z1-z0int)*(z1-z0int)) >
591 ((x2-x0int)*(x2-x0int)+(y2-y0int)*(y2-y0int)+(z2-z0int)*(z2-z0int)) ){
595 }
596
597 Phi=std::acos(X/sqrt(X*X+Y*Y));
600
601 if(Z>=CellZmin && Z<=CellZmax && Phi>=CellPhimin &&
Phi<=CellPhimax){
602 CellXimp[Np]=
X; CellYimp[Np]=
Y; CellZimp[Np]=
Z;
603 Np=Np+1;
604
605 }
606
607
608 if(Np < 2){
609 double Sxz = (Layer2X-Layer1X)/(Layer2Z-Layer1Z);
610 double Syz = (Layer2Y-Layer1Y)/(Layer2Z-Layer1Z);
612 X = Layer1X+Sxz*(
Z-Layer1Z);
613 Y = Layer1Y+Syz*(
Z-Layer1Z);
615 Phi = std::acos(X/R);
617 if(R>=CellRmin && R<=CellRmax && Phi>=CellPhimin &&
Phi<=CellPhimax){
618 CellXimp[Np]=
X; CellYimp[Np]=
Y; CellZimp[Np]=
Z;
619 Np=Np+1;
620
621 }
622 }
623
624 if(Np < 2){
625 double Sxz = (Layer2X-Layer1X)/(Layer2Z-Layer1Z);
626 double Syz = (Layer2Y-Layer1Y)/(Layer2Z-Layer1Z);
628 X = Layer1X+Sxz*(
Z-Layer1Z);
629 Y = Layer1Y+Syz*(
Z-Layer1Z);
631 Phi = std::acos(X/R);
633 if(R>=CellRmin && R<=CellRmax && Phi>=CellPhimin &&
Phi<=CellPhimax){
634 CellXimp[Np]=
X; CellYimp[Np]=
Y; CellZimp[Np]=
Z;
635 Np=Np+1;
636
637 }
638 }
639
640
641 if(Np < 2){
642 double Sxy=(Layer2X-Layer1X)/(Layer2Y-Layer1Y);
643 double Sxz=(Layer2X-Layer1X)/(Layer2Z-Layer1Z);
644 X = (Layer1X-Sxy*Layer1Y)/(1-Sxy*
tan(CellPhimin));
645 Y =
X*std::tan(CellPhimin);
646 Z = Layer1Z+(1/Sxz)*(X-Layer1X);
648 Phi = std::acos(X/R);
650 DeltaPhi=fabs(
Phi-CellPhimin);
651 if(DeltaPhi > 3.141593) DeltaPhi=fabs(
Phi+CellPhimin);
652 if(R>=CellRmin && R<=CellRmax && Z>=CellZmin && Z<=CellZmax && DeltaPhi<0.0001){
653 CellXimp[Np]=
X; CellYimp[Np]=
Y; CellZimp[Np]=
Z;
654 Np=Np+1;
655 }
656 }
657 if(Np < 2){
658 double Sxy=(Layer2X-Layer1X)/(Layer2Y-Layer1Y);
659 double Sxz=(Layer2X-Layer1X)/(Layer2Z-Layer1Z);
660 X = (Layer1X-Sxy*Layer1Y)/(1-Sxy*
tan(CellPhimax));
661 Y =
X*std::tan(CellPhimax);
662 Z = Layer1Z+(1/Sxz)*(X-Layer1X);
666 DeltaPhi=fabs(
Phi-CellPhimax);
667 if(DeltaPhi > 3.141593) DeltaPhi=fabs(
Phi+CellPhimax);
668 if(R>=CellRmin && R<=CellRmax && Z>=CellZmin && Z<=CellZmax && DeltaPhi<0.0001){
669 CellXimp[Np]=
X; CellYimp[Np]=
Y; CellZimp[Np]=
Z;
670 Np=Np+1;
671 }
672 }
673
674
675 if(Np == 2){
676
677 pathl += sqrt( (CellXimp[0]-CellXimp[1])*(CellXimp[0]-CellXimp[1]) +
678 (CellYimp[0]-CellYimp[1])*(CellYimp[0]-CellYimp[1]) +
679 (CellZimp[0]-CellZimp[1])*(CellZimp[0]-CellZimp[1]) );
680 }
681 }
682 if(SampleID == 13 && lBC == 0) ++lBC;
683 else compute = false;
684 }
685
686 return pathl;
687}
struct TBPatternUnitContext S1
const Amg::Vector3D & position() const
Access method for the position.
double R(const INavigable4Momentum *p1, const double v_eta, const double v_phi)