360{
361 Log(3,
"EdbShowAlg_GS::FindPairs",
"FindPairs()");
362
364 Int_t RecoShowerArrayN=0;
365 TArrayI* SegmentPIDArray = new TArrayI(9999);
366 TArrayI* SegmentIDArray = new TArrayI(9999);
367 TArrayI* Segment2PIDArray = new TArrayI(9999);
368 TArrayI* Segment2IDArray = new TArrayI(9999);
371 Float_t x_av,y_av,z_av,tx_av,ty_av,distZ;
373
374 Float_t IP_Pair_To_InBT=0;
375 Int_t IP_Pair_To_InBT_SegSmaller=0;
376
378 if (
NULL==InitiatorBT) {
381 InBT->
SetX(pat->
X());
382 InBT->
SetY(pat->
Y());
383 InBT->
SetZ(pat->
Z());
386 InBT->
SetMC(-999,-999);
387 cout << "WARNING EdbShowAlg_GS::FindPairs InBT==NULL. Create a dummy InBT:" << endl;
389 }
390 else {
391 InBT=InitiatorBT;
392 }
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
420 Int_t pat_one_bt_cnt_max,pat_two_bt_cnt_max=0;
423
424 for (Int_t pat_one_cnt=0; pat_one_cnt<
npat; ++pat_one_cnt) {
427
428
429 distZ=pat_one->
Z()-InBT->
Z();
431 cout << "EdbShowerAlg_GS::FindPairs Check if dist Z to vtx (BT) is ok: distZ=" << distZ << endl;
432 }
434 if (distZ<0) continue;
435
436 if (
gEDBDEBUGLEVEL>2) cout <<
"Searching patterns: pat_one_cnt=" << pat_one_cnt <<
" pat_one->Z() = " << pat_one->
Z() <<
" pat_one_bt_cnt_max= "<< pat_one_bt_cnt_max <<endl;
437
438
439 for (Int_t pat_two_cnt=0; pat_two_cnt<
npat; ++pat_two_cnt) {
440
441
442 if (TMath::Abs(pat_one_cnt-pat_two_cnt)>
eParaValue[5])
continue;
443
446
447
448 if (
gEDBDEBUGLEVEL>2) cout <<
" Searching patterns: pat_two_cnt=" << pat_two_cnt <<
" pat_two->Z() = " << pat_two->
Z() <<
" pat_two_bt_cnt_max= "<< pat_two_bt_cnt_max <<endl;
449
450 for (Int_t pat_one_bt_cnt=0; pat_one_bt_cnt<pat_one_bt_cnt_max; ++pat_one_bt_cnt) {
452
453 Float_t IP_Pair_To_InBT_Seg =
CalcIP(Segment, InBT->
X(),InBT->
Y(),InBT->
Z());
454
456
457
458 for (Int_t pat_two_bt_cnt=0; pat_two_bt_cnt<pat_two_bt_cnt_max; ++pat_two_bt_cnt) {
459
461 if (Segment2==Segment) continue;
462 if (Segment2->
ID()==Segment->
ID()&&Segment2->
PID()==Segment->
PID())
continue;
463
464
465 if (
CheckPairDuplications(Segment->
PID(),Segment->
ID(),Segment2->
PID(),Segment2->
ID(), SegmentPIDArray,SegmentIDArray,Segment2PIDArray,Segment2IDArray, RecoShowerArrayN))
continue;
466
467
468
472
473
474
476 if (Segment->
MCEvt()>0&&Segment2->
MCEvt()>0) {
477 if ((Segment2->
Flag()+Segment->
Flag())!=0)
continue;
478 }
479 }
480
481
483
485
487
488
489 distZ=Segment->
Z()-InBT->
Z();
491
492 x_av=Segment2->
X()+(Segment->
X()-Segment2->
X())/2.0;
493 y_av=Segment2->
Y()+(Segment->
Y()-Segment2->
Y())/2.0;
494 z_av=Segment2->
Z()+(Segment->
Z()-Segment2->
Z())/2.0;
495 tx_av=Segment2->
TX()+(Segment->
TX()-Segment2->
TX())/2.0;
496 ty_av=Segment2->
TY()+(Segment->
TY()-Segment2->
TY())/2.0;
497 Segment_Sum->
SetX(x_av);
498 Segment_Sum->
SetY(y_av);
499 Segment_Sum->
SetTX(tx_av);
500 Segment_Sum->
SetTY(ty_av);
501 Segment_Sum->
SetZ(z_av);
502
503
504
505 Float_t IP_Pair_To_InBT_Seg2 =
CalcIP(Segment2, InBT->
X(),InBT->
Y(),InBT->
Z());
506 if (IP_Pair_To_InBT_Seg2>
eParaValue[0])
continue;
507
508
509
510 Float_t IP_Pair_To_InBT_SegSum=
CalcIP(Segment_Sum, InBT->
X(),InBT->
Y(),InBT->
Z());
511 Float_t IP_Pair_To_InBT_SegSmaller=0;
512
513
514
515
516
517
518 if ( IP_Pair_To_InBT_Seg>IP_Pair_To_InBT_Seg2 ) {
519 IP_Pair_To_InBT_SegSmaller=0;
520 }
521 else {
522 IP_Pair_To_InBT_SegSmaller=1;
523 }
524
525
526
527
528
529
530
532
533
534
535
536
537
540
541 Float_t GammaChi2 = ((IP_Pair_To_InBT-80)*(IP_Pair_To_InBT-80)/60/60)+((dminDist-3.5)*(dminDist-3.5)/4.7/4.7)+((dtheta-0.021)*(dtheta-0.021)/0.012/0.012);
542 GammaChi2=GammaChi2/3.0;
543
544
546 cout <<
"EdbShowAlg_GS::FindPairs Pair (" << Segment->
PID() <<
"," << Segment->
ID()<<
";"<< Segment2->
PID() <<
"," << Segment2->
ID() <<
") has passed all cuts w.r.t to InBT:" << endl;
547 cout << "EdbShowAlg_GS::FindPairs IP_Pair_To_InBT = " << IP_Pair_To_InBT << endl;
548 cout << "EdbShowAlg_GS::FindPairs (IP_Pair_To_InBT==0 can mean that there was no InVtxArray and Vtx has been extrapolated from tracks.)" << endl;
549 cout <<
"EdbShowAlg_GS::FindPairs GetMinimumDist(Segment,Segment2) = " <<
GetMinimumDist(Segment,Segment2) << endl;
550 cout << "EdbShowAlg_GS::FindPairs CalcIP(BetterSegment,InBT) = " << IP_Pair_To_InBT << endl;
551 cout << "EdbShowAlg_GS::FindPairs CalcIP(Segment_Sum,InBT) = " << IP_Pair_To_InBT_SegSum << endl;
552 cout <<
"EdbShowAlg_GS::FindPairs GetSpatialDist(Segment_Sum,InBT) = " <<
GetSpatialDist(Segment_Sum,InBT) << endl;
553 cout << "EdbShowAlg_GS::FindPairs GammaChi2 = " << GammaChi2 << endl;
554 }
555
556
557
558 SegmentPIDArray->AddAt(Segment->
PID(),RecoShowerArrayN);
559 SegmentIDArray->AddAt(Segment->
ID(),RecoShowerArrayN);
560 Segment2PIDArray->AddAt(Segment2->
PID(),RecoShowerArrayN);
561 Segment2IDArray->AddAt(Segment2->
ID(),RecoShowerArrayN);
562
563
565 if (IP_Pair_To_InBT_SegSmaller==0) {
566 RecoShower -> AddSegment(Segment);
567 RecoShower -> AddSegment(Segment2);
568 }
569 else {
570 RecoShower -> AddSegment(Segment2);
571 RecoShower -> AddSegment(Segment);
572 }
573
574 RecoShower->
SetZ(TMath::Min(Segment->
Z(),Segment2->
Z()));
575 RecoShower->
SetX(Segment_Sum->
X());
576 RecoShower->
SetY(Segment_Sum->
Y());
577 RecoShower->
SetTX(Segment_Sum->
TX());
578 RecoShower->
SetTY(Segment_Sum->
TY());
580 RecoShower->
SetID(RecoShowerArrayN);
582
583
585
586
587
589 ++RecoShowerArrayN;
590
591 }
592 }
593 }
594 }
595
596
597 cout <<
"EdbShowAlg_GS::FindPairs For the InBT/Vtx at __" << InBT <<
"__, we have found " <<
RecoShowerArray->GetEntries() <<
" compatible pairs in the PVRec volume." << endl;
598
599
600
601 delete SegmentPIDArray;
602 delete Segment2PIDArray;
603 delete SegmentIDArray;
604 delete Segment2IDArray;
605
606 Log(3,
"EdbShowAlg_GS::FindPairs",
"FindPairs()....done.");
608}
Int_t npat
Definition: Xi2HatStartScript.C:33
Definition: EdbPattern.h:273
EdbPattern * GetPatternZLowestHighest(Bool_t lowestZ=kTRUE) const
Definition: EdbPattern.cxx:1816
Int_t Npatterns() const
Definition: EdbPattern.h:366
EdbPattern * GetPattern(int id) const
Definition: EdbPattern.cxx:1721
void SetPID(int pid)
Definition: EdbSegP.h:129
void SetY(Float_t y)
Definition: EdbSegP.h:178
Int_t ID() const
Definition: EdbSegP.h:147
void SetID(int id)
Definition: EdbSegP.h:128
void SetX(Float_t x)
Definition: EdbSegP.h:177
Int_t PID() const
Definition: EdbSegP.h:148
Float_t Z() const
Definition: EdbPattern.h:84
Float_t Y() const
Definition: EdbPattern.h:83
Int_t GetN() const
Definition: EdbPattern.h:65
EdbSegP * GetSegment(int i) const
Definition: EdbPattern.h:66
Float_t X() const
Definition: EdbPattern.h:82
Bool_t IsPossibleFakeDoublet(EdbSegP *s1, EdbSegP *s2)
Definition: EdbShowAlg_GS.cxx:722
Bool_t CheckPairDuplications(Int_t SegPID, Int_t SegID, Int_t Seg2PID, Int_t Seg2ID, TArrayI *SegmentPIDArray, TArrayI *SegmentIDArray, TArrayI *Segment2PIDArray, TArrayI *Segment2IDArray, int RecoShowerArrayN)
Definition: EdbShowAlg_GS.cxx:236
Float_t eParaValue[10]
Definition: EdbShowAlg.h:52
Double_t GetSpatialDist(EdbSegP *s1, EdbSegP *s2)
Definition: EdbShowAlg.cxx:463
Double_t GetMinimumDist(EdbSegP *seg1, EdbSegP *seg2)
Definition: EdbShowAlg.cxx:1943
Double_t DeltaR_WithPropagation(EdbSegP *s, EdbSegP *stest)
Definition: EdbShowAlg.cxx:411