56 #include <TDatabasePDG.h>
57 #include <TLorentzVector.h>
66 #include "FairMCPoint.h"
98 {
"SE++",
"SE+-",
"SE--",
"ME++",
"ME-+",
"ME+-",
"ME--",
"TR+-"};
109 : TNamed(name, title)
110 , fEventFilter(
"EventFilter")
111 , fTrackFilter(
"TrackFilter")
112 , fPairPreFilterLegs(
"PairPreFilterLegs")
113 , fPairPreFilter(
"PairPreFilter")
114 , fFinalTrackFilter(
"FinalTrackFilter")
115 , fPairFilter(
"PairFilter")
116 , fTrackFilterMC(
"TrackFilterMC")
117 , fPairFilterMC(
"PairFilterMC")
119 , fPairCandidates(new TObjArray(8)) {
236 Fatal(
"Process",
"No vertex found!");
244 TDatabasePDG::Instance()->GetParticle(
fPdgMother)->Mass());
276 if (ev1 && cutmask != selectedMask)
return kFALSE;
291 for (Int_t itrackArr1 = 0; itrackArr1 < 2; ++itrackArr1) {
292 for (Int_t itrackArr2 = itrackArr1; itrackArr2 < 2; ++itrackArr2) {
309 Double_t ntracks =
fTracks[0].GetEntriesFast() +
fTracks[1].GetEntriesFast();
343 if (!nSignals)
return;
347 Bool_t bFillHF = kFALSE;
348 Bool_t bFillHist = kFALSE;
349 for (Int_t isig = 0; isig < nSignals; isig++) {
353 TString sigName = sigMC->GetName();
356 fHistos->HasHistClass(Form(
"Pair_%s_MCtruth", sigName.Data()));
358 fHistos->HasHistClass(Form(
"Track.Leg_%s_MCtruth", sigName.Data()));
359 bFillHist |=
fHistos->HasHistClass(
364 fHistoArray->HasHistClass(Form(
"Pair_%s_MCtruth", sigName.Data()));
366 fHistoArray->HasHistClass(Form(
"Track.Leg_%s_MCtruth", sigName.Data()));
373 if (!bFillHF && !bFillHist)
return;
379 labels1 =
new Int_t*[nSignals];
380 labels2 =
new Int_t*[nSignals];
381 labels12 =
new Int_t*[nSignals];
382 Int_t* indexes1 =
new Int_t[nSignals];
383 Int_t* indexes2 =
new Int_t[nSignals];
384 Int_t* indexes12 =
new Int_t[nSignals];
385 for (Int_t isig = 0; isig < nSignals; ++isig) {
390 labels1[isig][ip] = -1;
391 labels2[isig][ip] = -1;
392 labels12[isig][ip] = -1;
399 Bool_t truth1 = kFALSE;
400 Bool_t truth2 = kFALSE;
406 for (Int_t ipart = 0; ipart < papaMC->
GetNMCTracks(); ++ipart) {
425 if (cutmask != selectedMask)
continue;
428 for (Int_t isig = 0; isig < nSignals; ++isig) {
444 if (truth1 && truth2) {
445 labels12[isig][indexes12[isig]] = ipart;
449 labels1[isig][indexes1[isig]] = ipart;
453 labels2[isig][indexes2[isig]] = ipart;
467 for (Int_t isig = 0; isig < nSignals; ++isig) {
470 for (Int_t i1 = 0; i1 < indexes1[isig]; ++i1) {
482 for (Int_t i2 = i1; i2 < indexes2[isig]; ++i2) {
505 if (cutmask != selectedMask)
continue;
517 for (Int_t i1 = 0; i1 < indexes12[isig]; ++i1) {
518 for (Int_t i2 = 0; i2 < i1; ++i2) {
539 if (cutmask != selectedMask)
continue;
553 for (Int_t isig = 0; isig < nSignals; ++isig) {
554 delete[] * (labels1 + isig);
555 delete[] * (labels2 + isig);
556 delete[] * (labels12 + isig);
573 TString className, className2;
578 for (Int_t
i = 0;
i < 2; ++
i) {
580 if (!
fHistos->GetHistogramList()->FindObject(className.Data()))
continue;
581 Int_t ntracks =
tracks[
i]->GetEntriesFast();
582 for (Int_t itrack = 0; itrack < ntracks; ++itrack) {
584 fHistos->FillClass(className, values);
612 Bool_t pairInfoOnly) {
617 TString className, className2, className3;
625 fHistos->FillClass(
"Event", values);
632 TBits trkClassMC(nsig);
633 TBits trkClassMChf(nsig);
639 Bool_t mergedtrkClass =
fHistos->HasHistClass(className2);
640 Bool_t mergedtrkClass2 =
643 for (Int_t isig = 0; isig < nsig; isig++) {
644 sigName = className2 +
"_" +
fSignalsMC->At(isig)->GetName();
645 trkClassMC.SetBitNumber(isig,
fHistos->HasHistClass(sigName));
646 trkClassMChf.SetBitNumber(
652 Bool_t trkClass =
fHistos->HasHistClass(className);
655 (mergedtrkClass || mergedtrkClass2 || trkClass || trkClass2);
657 if (!fill && !trkClassMC.CountBits() && !trkClassMChf.CountBits())
659 Int_t ntracks =
fTracks[
i].GetEntriesFast();
661 for (Int_t itrack = 0; itrack < ntracks; ++itrack) {
665 if (trkClass)
fHistos->FillClass(className, values);
667 if (mergedtrkClass)
fHistos->FillClass(className2, values);
671 for (Int_t isig = 0; isig < nsig; isig++) {
672 if (!trkClassMC.TestBitNumber(isig)
673 && !trkClassMChf.TestBitNumber(isig))
682 sigName = className2 +
"_" +
fSignalsMC->At(isig)->GetName();
684 if (fillMC.TestBitNumber(isig)) {
685 if (trkClassMC.TestBitNumber(isig))
686 fHistos->FillClass(sigName, values);
687 if (trkClassMChf.TestBitNumber(isig))
700 TBits legClassMC(nsig);
701 TBits legClassMChf(nsig);
702 TBits pairClassMC(nsig);
703 TBits pairClassMChf(nsig);
704 TObjArray arrLegs(100);
708 Bool_t pairClass =
fHistos->HasHistClass(className);
710 Bool_t legClass =
fHistos->HasHistClass(className2);
713 Bool_t legClassHits = kFALSE;
723 legClassHits =
fHistos->HasHistClass(className3);
724 if (legClassHits)
break;
728 for (Int_t isig = 0; isig < nsig; isig++) {
729 sigName = Form(
"Pair_%s",
fSignalsMC->At(isig)->GetName());
730 pairClassMC.SetBitNumber(isig,
fHistos->HasHistClass(sigName));
731 pairClassMChf.SetBitNumber(
734 sigName = Form(
"Track.Legs_%s",
fSignalsMC->At(isig)->GetName());
735 legClassMC.SetBitNumber(isig,
fHistos->HasHistClass(sigName));
736 legClassMChf.SetBitNumber(
747 sigName = className3 +
"_" +
fSignalsMC->At(isig)->GetName();
748 legClassHits =
fHistos->HasHistClass(className3);
757 (pairClass || pairClass2 || legClass || legClass2 || legClassHits);
758 if (!fill && !legClassMC.CountBits() && !legClassMChf.CountBits()
759 && !pairClassMC.CountBits() && !pairClassMChf.CountBits())
765 Int_t npairs =
PairArray(
i)->GetEntriesFast();
766 for (Int_t ipair = 0; ipair < npairs; ++ipair) {
771 if (pairClass || pairClass2 || pairClassMC.CountBits()
772 || pairClassMChf.CountBits()) {
781 if (cutMask != selectedMask)
continue;
786 if (pairClass)
fHistos->FillClass(className, values);
790 fillMC.ResetAllBits();
792 for (Int_t isig = 0; isig < nsig; isig++) {
794 if (!pairClassMC.TestBitNumber(isig)
795 && !pairClassMChf.TestBitNumber(isig))
800 Bool_t isMCtruth = mc->
IsMCTruth(pair, sigMC);
801 fillMC.SetBitNumber(isig, isMCtruth);
802 if (!isMCtruth)
continue;
803 sigName = Form(
"Pair_%s", sigMC->GetName());
804 if (pairClassMC.TestBitNumber(isig))
805 fHistos->FillClass(sigName, values);
806 if (pairClassMChf.TestBitNumber(isig))
817 if (legClass || legClass2 || legClassMC.CountBits()
818 || legClassMChf.CountBits() || legClassHits) {
821 if (!arrLegs.FindObject(d1)) {
823 if (legClass)
fHistos->FillClass(className2, values);
827 for (Int_t isig = 0; isig < nsig; isig++) {
828 if (!fillMC.TestBitNumber(isig))
continue;
830 sigName = Form(
"Track.Legs_%s", sigMC->GetName());
831 if (legClassMC.TestBitNumber(isig))
832 fHistos->FillClass(sigName, values);
833 if (legClassMChf.TestBitNumber(isig))
843 if (!arrLegs.FindObject(d2)) {
845 if (legClass)
fHistos->FillClass(className2, values);
849 for (Int_t isig = 0; isig < nsig; isig++) {
850 if (!fillMC.TestBitNumber(isig))
continue;
852 sigName = Form(
"Track.Legs_%s", sigMC->GetName());
853 if (legClassMC.TestBitNumber(isig))
854 fHistos->FillClass(sigName, values);
855 if (legClassMChf.TestBitNumber(isig))
867 if (legClass || legClass2) arrLegs.Clear();
872 Bool_t fromPreFilter ) {
879 TString className, className2;
884 TObjArray arrLegs(100);
885 const Int_t type = pair->
GetType();
894 Bool_t pairClass =
fHistos->HasHistClass(className);
896 Bool_t legClass =
fHistos->HasHistClass(className2);
900 if (pairClass || pairClass2) {
902 if (pairClass)
fHistos->FillClass(className, values);
906 if (legClass || legClass2) {
909 if (legClass)
fHistos->FillClass(className2, values);
914 if (legClass)
fHistos->FillClass(className2, values);
935 for (Int_t itrack = 0; itrack < ntracks; ++itrack) {
957 fHistos->FillClass(
"Track.noCuts", values);
965 if (cutmask != selectedMask)
continue;
971 for (Int_t isig = 0; isig <
fSignalsMC->GetEntriesFast(); isig++) {
974 Double_t wght = sigMC->
GetWeight(values);
975 Bool_t useMCweight = (TMath::Abs(wght - 1.) > 1.0e-15);
976 if (!useMCweight)
continue;
978 if (papaMC->
IsMCTruth(particle, sigMC, 1)
979 || papaMC->
IsMCTruth(particle, sigMC, 2)) {
989 Bool_t hasMCweight = (TMath::Abs(wght - 1.) > 1.0e-15);
994 while (!hasMCweight) {
997 if (motherLabel == -1)
break;
1000 for (Int_t isig = 0; isig <
fSignalsMC->GetEntriesFast(); isig++) {
1003 Double_t wghtMC = sigMC->
GetWeight(values);
1004 Bool_t useMCweight = (TMath::Abs(wghtMC - 1.) > 1.0e-15);
1005 if (!useMCweight)
continue;
1007 if (papaMC->
IsMCTruth(motherLabel, sigMC, 1)
1008 || papaMC->
IsMCTruth(motherLabel, sigMC, 2)) {
1010 hasMCweight = kTRUE;
1015 label = motherLabel;
1021 Short_t charge = particle->
Charge();
1024 else if (charge < 0)
1032 TObjArray& arrTracks1,
1033 TObjArray& arrTracks2) {
1046 Double_t mass = TDatabasePDG::Instance()->GetParticle(
fPdgLeg1)->Mass();
1047 Double_t pt = gRandom->Exp(3.);
1048 if (pt < 0.075) pt = 0.075;
1049 Double_t eta = -TMath::Log(
1050 TMath::Tan((gRandom->Uniform(2.5, 25.) / 180. *
TMath::Pi()) / 2));
1051 Double_t phi = gRandom->Uniform(TMath::TwoPi());
1054 t1->
GetMomentum()->SetPtEtaPhiM(pt, eta, phi, mass);
1057 mass = TDatabasePDG::Instance()->GetParticle(
fPdgLeg2)->Mass();
1058 pt = gRandom->Exp(3.);
1059 if (pt < 0.075) pt = 0.075;
1061 TMath::Tan((gRandom->Uniform(2.5, 25.) / 180. *
TMath::Pi()) / 2));
1062 phi = gRandom->Uniform(TMath::TwoPi());
1065 t2->
GetMomentum()->SetPtEtaPhiM(pt, eta, phi, mass);
1072 UInt_t selectedMaskLeg =
1074 Bool_t isLeg1selected = kTRUE;
1075 Bool_t isLeg2selected = kTRUE;
1078 Int_t ntrack1 = arrTracks1.GetEntriesFast();
1079 Int_t ntrack2 = arrTracks2.GetEntriesFast();
1082 Bool_t* bTracks1 =
new Bool_t[ntrack1];
1083 for (Int_t itrack1 = 0; itrack1 < ntrack1; ++itrack1)
1084 bTracks1[itrack1] = kFALSE;
1085 Bool_t* bTracks2 =
new Bool_t[ntrack2];
1086 for (Int_t itrack2 = 0; itrack2 < ntrack2; ++itrack2)
1087 bTracks2[itrack2] = kFALSE;
1090 bTracks1[ntrack1 - 1] = kTRUE;
1091 bTracks2[ntrack2 - 1] = kTRUE;
1103 Int_t nRejPasses = 1;
1107 for (Int_t iRP = 0; iRP < nRejPasses; ++iRP) {
1110 Int_t arr1RP = arr1, arr2RP = arr2;
1111 TObjArray* arrTracks1RP = &arrTracks1;
1112 TObjArray* arrTracks2RP = &arrTracks2;
1113 Bool_t* bTracks1RP = bTracks1;
1114 Bool_t* bTracks2RP = bTracks2;
1121 arrTracks1RP = &arrTracks1;
1122 arrTracks2RP = &arrTracks1;
1123 bTracks1RP = bTracks1;
1124 bTracks2RP = bTracks1;
1129 arrTracks1RP = &arrTracks2;
1130 arrTracks2RP = &arrTracks2;
1131 bTracks1RP = bTracks2;
1132 bTracks2RP = bTracks2;
1137 Int_t ntrack1RP = (*arrTracks1RP).GetEntriesFast();
1138 Int_t ntrack2RP = (*arrTracks2RP).GetEntriesFast();
1142 for (Int_t itrack1 = 0; itrack1 < ntrack1RP; ++itrack1) {
1143 Int_t end = ntrack2RP;
1144 if (arr1RP == arr2RP) end = itrack1;
1146 TObject* track1 = (*arrTracks1RP).UncheckedAt(itrack1);
1147 if (!track1)
continue;
1150 if (selectedMaskLeg) {
1153 == selectedMaskLeg);
1158 for (Int_t itrack2 = 0; itrack2 < end; ++itrack2) {
1159 TObject* track2 = (*arrTracks2RP).UncheckedAt(itrack2);
1160 if (!track2)
continue;
1169 == selectedMaskLeg);
1172 if (!isLeg2selected)
continue;
1175 if (!isLeg2selected)
continue;
1178 if (isLeg1selected == isLeg2selected)
continue;
1189 candidate->
SetType(pairIndex);
1194 Bool_t testParticle =
1195 (track1 == t1 || track1 == t2 || track2 == t1 || track2 == t2);
1201 if (!testParticle) {
1207 if (cutmask != selectedMask) {
continue; }
1222 bTracks1RP[itrack1] = kTRUE;
1223 bTracks2RP[itrack2] = kTRUE;
1233 for (Int_t itrack1 = 0; itrack1 < ntrack1; ++itrack1) {
1234 if (bTracks1[itrack1]) arrTracks1.AddAt(0x0, itrack1);
1236 for (Int_t itrack2 = 0; itrack2 < ntrack2; ++itrack2) {
1237 if (bTracks2[itrack2]) arrTracks2.AddAt(0x0, itrack2);
1245 arrTracks1.Compress();
1246 arrTracks2.Compress();
1288 TObjArray& arrTracks2) {
1302 for (Int_t itrack = 0; itrack < arrTracks1.GetEntriesFast(); ++itrack) {
1323 if (cutmask != selectedMask) arrTracks1.AddAt(0x0, itrack);
1325 arrTracks1.Compress();
1328 for (Int_t itrack = 0; itrack < arrTracks2.GetEntriesFast(); ++itrack) {
1350 if (cutmask != selectedMask) arrTracks2.AddAt(0x0, itrack);
1352 arrTracks2.Compress();
1361 TObjArray arrTracks1 =
fTracks[arr1];
1362 TObjArray arrTracks2 =
fTracks[arr2];
1369 Int_t ntrack1 = arrTracks1.GetEntriesFast();
1370 Int_t ntrack2 = arrTracks2.GetEntriesFast();
1382 candidate->
SetType(pairIndex);
1386 for (Int_t itrack1 = 0; itrack1 < ntrack1; ++itrack1) {
1387 Int_t end = ntrack2;
1388 if (arr1 == arr2) end = itrack1;
1389 for (Int_t itrack2 = 0; itrack2 < end; ++itrack2) {
1415 if (cutMask != selectedMask)
continue;
1431 candidate->
SetType(pairIndex);
1444 Int_t ntrack1 =
fTracks[0].GetEntriesFast();
1445 Int_t ntrack2 =
fTracks[1].GetEntriesFast();
1457 for (Int_t itrack1 = 0; itrack1 < ntrack1; ++itrack1) {
1458 for (Int_t itrack2 = 0; itrack2 < ntrack2; ++itrack2) {
1475 if (cutMask != selectedMask)
continue;
1526 TString className = Form(
"Pair_%s_MCtruth", sigMC->GetName());
1527 TString className2 = Form(
"Track.Legs_%s_MCtruth", sigMC->GetName());
1528 TString className3 =
1530 Bool_t pairClass =
fHistos->HasHistClass(className.Data());
1531 Bool_t legClass =
fHistos->HasHistClass(className2.Data());
1532 Bool_t trkClass =
fHistos->HasHistClass(className3.Data());
1534 if (!pairClass && !legClass && !trkClass)
return kFALSE;
1539 if (!part1 && !part2)
return kFALSE;
1540 if (part1 && part2) {
1551 && mLabel1 != mLabel2)
1554 && mLabel1 == mLabel2)
1562 if (legClass || trkClass) {
1566 if (part1 && trkClass)
fHistos->FillClass(className3, values);
1567 if (part1 && part2 && legClass)
fHistos->FillClass(className2, values);
1571 if (part2 && trkClass)
fHistos->FillClass(className3, values);
1572 if (part1 && part2 && legClass)
fHistos->FillClass(className2, values);
1576 FairMCPoint* pnt = NULL;
1579 for (Int_t ipart = 0; ipart < 2; ipart++) {
1582 Int_t label = (!ipart ? label1 : label2);
1583 if (!part)
continue;
1587 for (Int_t ileg = 0; ileg < 2; ileg++) {
1593 className4 = Form(
"Hit.%s", (ileg ?
"Legs." :
""));
1595 + sigMC->GetName() +
"_MCtruth";
1596 if (!
fHistos->HasHistClass(className4))
continue;
1600 if (!npnts)
continue;
1605 Int_t psize =
points->GetSize();
1606 if (!
points || psize < 1)
continue;
1609 for (Int_t idx = 0; idx < psize; idx++) {
1610 if (nfnd == npnts)
break;
1612 pnt =
static_cast<FairMCPoint*
>(
points->At(idx));
1613 if (pnt->GetTrackID() == label) {
1617 fHistos->FillClass(className4, values);
1626 if (pairClass && part1 && part2) {
1630 fHistos->FillClass(className, values);
1638 Bool_t pairInfoOnly ) {
1643 TString className, className2;
1648 if (!pairInfoOnly) {
1649 if (
fHistos->GetHistogramList()->FindObject(
"Event")) {
1657 TObjArray arrLegs(100);
1659 Int_t npairs =
PairArray(
i)->GetEntriesFast();
1660 if (npairs < 1)
continue;
1664 Bool_t pairClass =
fHistos->HasHistClass(className);
1665 Bool_t legClass =
fHistos->HasHistClass(className2);
1668 for (Int_t ipair = 0; ipair < npairs; ++ipair) {
1682 if (cutMask != selectedMask)
continue;
1693 fHistos->FillClass(className, values);
1700 if (!arrLegs.FindObject(d1)) {
1702 fHistos->FillClass(className2, values);
1705 if (!arrLegs.FindObject(d2)) {
1707 fHistos->FillClass(className2, values);
1712 if (legClass) arrLegs.Clear();
1720 const Double_t* values) {
1728 TString classNameMC;
1731 PairAnalysisHistos histo;
1733 TIter next(filter->
GetCuts());
1739 for (Int_t isig = 0; isig < nsig; isig++) {
1742 classNameMC = classNamePM +
"_" + sigMC->GetName();
1749 if (isig && !isMCtruth)
continue;
1761 UInt_t cutRef = (1 << (iCut + 1)) - 1;
1765 if ((cutmask & cutRef) == cutRef) {
1769 histo.SetHistogramList(
1775 histo.FillClass(classNamePM, values);
1778 histo.FillClass(className, values);
1782 if (isMCtruth) histo.FillClass(classNameMC, values);
1793 const Double_t* values) {
1801 TString classNameMC;
1804 PairAnalysisHistos histo;
1806 TIter next(filter->
GetCuts());
1812 for (Int_t isig = 0; isig < nsig; isig++) {
1815 classNameMC = classNamePM +
"_" + sigMC->GetName() +
"_MCtruth";
1825 if (isig && !isMCtruth)
continue;
1837 UInt_t cutRef = (1 << (iCut + 1)) - 1;
1840 if ((cutmask & cutRef) == cutRef) {
1843 histo.SetHistogramList(
1848 if (isMCtruth) histo.FillClass(classNameMC, values);
1867 TBits hitClassMC(nsig);
1868 TBits hitClassMChf(nsig);
1890 className.Form(
"Hit.%s", (trackIsLeg ?
"Legs." :
""));
1893 Bool_t hitClass =
fHistos->HasHistClass(className);
1897 for (Int_t isig = 0; isig < nsig; isig++) {
1898 sigName = className +
"_" +
fSignalsMC->At(isig)->GetName();
1899 hitClassMC.SetBitNumber(isig,
fHistos->HasHistClass(sigName));
1900 hitClassMChf.SetBitNumber(
1903 if (!hitClass && !hitClass2 && !hitClassMC.CountBits()
1904 && !hitClassMChf.CountBits())
1909 if (!
hits ||
hits->GetSize() < 1)
continue;
1933 if (trkl) nhits =
static_cast<CbmStsTrack*
>(trkl)->GetNofMvdHits();
1936 if (trkl) nhits =
static_cast<CbmStsTrack*
>(trkl)->GetNofStsHits();
1954 FairMCPoint* pnt = 0x0;
1955 for (Int_t ihit = 0; ihit < nhits; ihit++) {
1959 idx =
static_cast<CbmStsTrack*
>(trkl)->GetMvdHitIndex(ihit);
1962 idx =
static_cast<CbmStsTrack*
>(trkl)->GetStsHitIndex(ihit);
1978 Bool_t trueHit = kTRUE;
1979 Bool_t fakeHit = kTRUE;
1991 for (Int_t iLink = 0; iLink < nlinks; iLink++) {
1992 pnt =
static_cast<FairMCPoint*
>(
2005 Int_t lbl = pnt->GetTrackID();
2008 if (lbl != mctrk && lblM != mctrk && lblG != mctrk)
2019 if (hitClass)
fHistos->FillClass(className, values);
2023 if (hitClass)
fHistos->FillClass(className +
"_true", values);
2025 }
else if (fakeHit) {
2026 if (hitClass)
fHistos->FillClass(className +
"_fake", values);
2029 if (hitClass)
fHistos->FillClass(className +
"_dist", values);
2033 for (Int_t isig = 0; isig < nsig; isig++) {
2034 sigName = className +
"_" +
fSignalsMC->At(isig)->GetName();
2035 if (fillMC->TestBitNumber(isig)) {
2036 if (hitClassMC.TestBitNumber(isig))
2037 fHistos->FillClass(sigName, values);
2038 if (hitClassMChf.TestBitNumber(isig))