12 #include "TDatabasePDG.h"
18 #include <sys/types.h>
25 static Double_t
xRms = 1.202;
28 static Double_t
yRms = 1.061;
31 static Double_t
txRms = 0.02426;
34 static Double_t
tyRms = 0.01082;
79 if (mom < 3.0)
return false;
81 if (txBreak < 0) txBreak = -txBreak;
83 Double_t inv = mom * txBreak;
84 return inv > 0.18 && inv < 0.52;
90 while (!linkedStsTracks.empty()) {
91 pair<LxSimpleTrack*, Double_t> trackDesc = linkedStsTracks.front();
92 linkedStsTracks.pop_front();
95 if (0 == anotherMuchTrack
96 || trackDesc.second < trackDesc.first->linkedMuchTrack.second) {
97 trackDesc.first->linkedMuchTrack.first =
this;
98 trackDesc.first->linkedMuchTrack.second = trackDesc.second;
99 linkedStsTrack = trackDesc.first;
112 , listMuchPixelHits(0)
113 , listMuchClusters(0)
114 , listMuchPixelDigiMatches(0)
118 , superEventTracks(0)
119 , superEventBrachTrack(0, 0, 0, 0, 0, 0, 0, 0)
120 , useHitsInStat(false)
121 , averagePoints(false)
122 , dontTouchNonPrimary(true)
123 , useChargeSignInCuts(false)
124 , buildConnectStat(false)
125 , buildBgrInvMass(false)
126 , buildSigInvMass(false)
128 , buildNearestHitDist(false)
130 , buildSegmentsStat(true)
132 , segmentsAnalyzer(*this) {}
137 for (vector<LxSimpleTrack*>::iterator
i =
allTracks.begin();
148 FairRootManager* fManager = FairRootManager::Instance();
149 listMCTracks =
static_cast<TClonesArray*
>(fManager->GetObject(
"MCTrack"));
153 listStsPts =
static_cast<TClonesArray*
>(fManager->GetObject(
"StsPoint"));
157 listMuchPts =
static_cast<TClonesArray*
>(fManager->GetObject(
"MuchPoint"));
163 static_cast<TClonesArray*
>(fManager->GetObject(
"MuchPixelHit"));
168 static_cast<TClonesArray*
>(fManager->GetObject(
"MuchCluster"));
173 static_cast<TClonesArray*
>(fManager->GetObject(
"MuchDigiMatch"));
180 "muchStsBreakX",
"Break in prediction of X in STS", 100, -20., 20.);
183 "muchStsBreakY",
"Break in prediction of Y in STS", 100, -20., 20.);
186 "muchStsBreakTx",
"Break in prediction of Tx in STS", 100, -0.15, 0.15);
189 "muchStsBreakTy",
"Break in prediction of Ty in STS", 100, -0.15, 0.15);
193 "stsMuchBreakX",
"Break in prediction of X in MUCH", 100, -20., 20.);
196 "stsMuchBreakY",
"Break in prediction of Y in MUCH", 100, -20., 20.);
199 signalChi2 =
new TH1F(
"signalChi2",
"Chi2 of signal", 100, 0., 15.);
201 bgrChi2 =
new TH1F(
"bgrChi2",
"Chi2 of background", 100, 0., 20.);
208 "Invariant mass distribution for background",
215 new TTree(
"SuperEventTracks",
"Tracks for building a super event");
223 "sigInvMass",
"Invariant mass distribution for signal", 1000, 2., 4.);
232 sprintf(name,
"nearestHitDist_%d",
i);
234 title,
"Distance from a MC point to the nearest hit at %d station",
i);
237 sprintf(name,
"hitsDist_%d",
i);
238 sprintf(title,
"Distance from a MC point to the hits at %d station",
i);
239 hitsDist[
i] =
new TH1F(name, title, 100, 0., 7.);
245 new TH1F(
"muPlusStsTxDiff",
"muPlusStsTxDiff", 100, -0.2, 0.2);
248 new TH1F(
"muMinusStsTxDiff",
"muMinusStsTxDiff", 100, -0.2, 0.2);
251 new TH1F(
"muPlusStsXDiff",
"muPlusStsXDiff", 100, -10.0, 10.0);
254 new TH1F(
"muMinusStsXDiff",
"muMinusStsXDiff", 100, -10.0, 10.0);
257 new TH1F(
"muPlusVertexTxDiff",
"muPlusVertexTxDiff", 100, -0.2, 0.2);
260 new TH1F(
"muMinusVertexTxDiff",
"muMinusVertexTxDiff", 100, -0.2, 0.2);
264 "muPlusStsBeginTxDiff2D",
273 "muMinusStsBeginTxDiff2D",
282 deltaPhiPi =
new TH1F(
"deltaPhiPi",
"deltaPhiPi", 100, 0., 1.0);
286 "jPsiMuonsMomsHisto",
"J/Psi muons momenta distribution", 200, 0., 25.);
299 DIR* dir = opendir(dir_name);
304 mkdir(dir_name, 0700);
307 sprintf(file_name,
"%s/%s", dir_name, name);
308 TFile fh(file_name,
"RECREATE");
315 list<LxSimpleTrack*>& nTracks,
317 for (list<LxSimpleTrack*>::iterator
i = pTracks.begin();
i != pTracks.end();
321 for (list<LxSimpleTrack*>::iterator j = nTracks.begin(); j != nTracks.end();
324 Double_t E12 = posTrack->
e + negTrack->
e;
325 Double_t px12 = posTrack->
px + negTrack->
px;
326 Double_t py12 = posTrack->
py + negTrack->
py;
327 Double_t pz12 = posTrack->
pz + negTrack->
pz;
328 Double_t m122 = E12 * E12 - px12 * px12 - py12 * py12 - pz12 * pz12;
329 Double_t m12 = m122 > 1.e-20 ?
sqrt(m122) : 0.;
336 for (list<CbmStsTrack*>::iterator
i = stsTracks.begin();
i != stsTracks.end();
345 Double_t t1Qp = t1param->GetQp();
346 list<CbmStsTrack*>::iterator j =
i;
349 for (; j != stsTracks.end(); ++j) {
354 const FairTrackParam* t2param = negTrack->
GetParamLast();
356 Double_t t2Qp = t2param->GetQp();
358 if (t1Qp * t2Qp >= 0)
continue;
361 vector<CbmKFTrackInterface*> kfData;
364 kfData.push_back(&muPlus);
365 kfData.push_back(&muMinus);
367 kfData.push_back(&muMinus);
368 kfData.push_back(&muPlus);
382 TFile* curFile = TFile::CurrentFile();
399 TFile fh(
"tracks_tree.root");
405 list<CbmStsTrack*> stsTracks;
408 for (Int_t
i = 0;
i < nEnt; ++
i) {
413 stsTracks.push_back(t);
419 for (list<CbmStsTrack*>::iterator
i = stsTracks.begin();
420 i != stsTracks.end();
424 TFile fh(
"tracks_tree.root",
"RECREATE");
440 sprintf(fileName,
"%s.root",
hitsDist[
i]->GetName());
457 "muMinusStsBeginTxDiff2D.root");
465 TFile::CurrentFile() = curFile;
466 FairTask::FinishTask();
476 cout <<
"There are: " << nEnt <<
" of MC tracks" << endl;
478 for (Int_t
i = 0;
i < nEnt; ++
i) {
495 cout <<
"There are: " << nEnt <<
" of STS MC points" << endl;
497 for (Int_t
i = 0;
i < nEnt; ++
i) {
499 Int_t mcTrackId = stsPt->GetTrackID();
502 stsPt->Position(xyzI);
504 TVector3 xyz = .5 * (xyzI + xyzO);
505 TVector3 pxyzI, pxyzO;
506 stsPt->Momentum(pxyzI);
508 TVector3 pxyz = .5 * (pxyzI + pxyzO);
510 xyz.X(), xyz.Y(), xyz.Z(), pxyz.X() / pxyz.Z(), pxyz.Y() / pxyz.Z());
513 track->
stsPoints[stationNr].push_back(point);
517 cout <<
"There are: " << nEnt <<
" of MUCH MC points" << endl;
519 for (Int_t
i = 0;
i < nEnt; ++
i) {
521 Int_t mcTrackId = mcPoint->GetTrackID();
527 mcPoint->Position(xyzI);
529 TVector3 xyz = .5 * (xyzI + xyzO);
530 TVector3 pxyzI, pxyzO;
531 mcPoint->Momentum(pxyzI);
533 TVector3 pxyz = .5 * (pxyzI + pxyzO);
535 xyz.X(), xyz.Y(), xyz.Z(), pxyz.X() / pxyz.Z(), pxyz.Y() / pxyz.Z());
538 track->
muchMCPts[stationNr][layerNr].push_back(point);
540 track->
muchPoints[stationNr][layerNr].push_back(point);
545 cout <<
"There are: " << nEnt <<
" of MUCH pixel hits" << endl;
547 for (Int_t
i = 0;
i < nEnt; ++
i) {
556 Double_t
x =
pos.X();
557 Double_t
y =
pos.Y();
558 Double_t z =
pos.Z();
560 if (
x !=
x ||
y !=
y || z != z)
563 set<LxSimpleTrack*>
tracks;
570 for (Int_t j = 0; j < nDigis; ++j) {
575 for (Int_t k = 0; k < nMCs; ++k) {
580 Int_t mcTrackId = mcPoint->GetTrackID();
589 for (set<LxSimpleTrack*>::iterator j =
tracks.begin(); j !=
tracks.end();
593 track->
muchPoints[stationNumber][layerNumber].push_back(point);
598 cout <<
"There are: " << nEnt <<
" of MUCH clusters" << endl;
601 cout <<
"There are: " << nEnt <<
" of MUCH pixel digi matches" << endl;
625 for (list<LxSimplePoint>::iterator
i =
points.begin();
i !=
points.end();
642 points.push_back(averagedPoint);
652 for (Int_t j = 0; j <
LXLAYERS; ++j)
657 for (Int_t j = 0; j <
LXLAYERS; ++j)
664 for (vector<LxSimpleTrack*>::iterator
i =
allTracks.begin();
696 for (list<LxSimplePoint>::iterator k =
701 Double_t diffZMuch = muchPt0.
z - muchPt1.
z;
702 Double_t txMuch = (muchPt0.
x - muchPt1.
x) / diffZMuch;
703 Double_t tyMuch = (muchPt0.
y - muchPt1.
y) / diffZMuch;
706 Double_t txDiff = txMuch - muchPt0.
x / muchPt0.
z;
713 txMuch - (p1.
x - p0.
x) / (p1.
z - p0.
z));
715 (p1.
x - p0.
x) / (p1.
z - p0.
z) - txMuch);
718 }
else if (13 == track->
pdgCode) {
719 Double_t txDiff = txMuch - muchPt0.
x / muchPt0.
z;
726 txMuch - (p1.
x - p0.
x) / (p1.
z - p0.
z));
728 (p1.
x - p0.
x) / (p1.
z - p0.
z) - txMuch);
733 for (list<LxSimplePoint>::iterator l = track->
stsPoints[7].begin();
737 Double_t diffZ = stsPt7.
z - muchPt0.
z;
738 Double_t extX = muchPt0.
x + txMuch * diffZ;
739 Double_t extY = muchPt0.
y + tyMuch * diffZ;
740 Double_t dx = stsPt7.
x - extX;
741 Double_t dy = stsPt7.
y - extY;
746 Double_t extXmu = muchPt0.
x + (txMuch - 0.00671) * diffZ;
748 }
else if (13 == track->
pdgCode) {
749 Double_t extXmu = muchPt0.
x + (txMuch + 0.00691) * diffZ;
753 for (list<LxSimplePoint>::iterator
m = track->
stsPoints[6].begin();
757 Double_t diffZSts = stsPt6.
z - stsPt7.
z;
758 Double_t txSts = (stsPt6.
x - stsPt7.
x) / diffZSts;
759 Double_t tySts = (stsPt6.
y - stsPt7.
y) / diffZSts;
762 Double_t dtx = txSts - txMuch;
763 Double_t dty = tySts - tyMuch;
781 diffZ = muchPt0.
z - stsPt7.
z;
782 extX = stsPt7.
x + txSts * diffZ;
783 extY = stsPt7.
y + tySts * diffZ;
784 dx = muchPt0.
x - extX;
785 dy = muchPt0.
y - extY;
795 static Double_t maxDist = 0;
796 static Double_t mcX = 0;
797 static Double_t hitX = 0;
798 static Double_t mcY = 0;
799 static Double_t hitY = 0;
801 static Double_t maxMinDist = 0;
802 static Double_t mcMinX = 0;
803 static Double_t hitMinX = 0;
804 static Double_t mcMinY = 0;
805 static Double_t hitMinY = 0;
806 static Int_t nMinHits = 0;
816 Double_t minDist = -1;
817 Double_t mcMinX0 = 0;
818 Double_t hitMinX0 = 0;
819 Double_t mcMinY0 = 0;
820 Double_t hitMinY0 = 0;
821 Double_t hitMinZ0 = 0;
824 for (list<LxSimplePoint>::iterator j =
829 Double_t dx = hitPoint.
x - mcPoint.
x;
830 Double_t dy = hitPoint.
y - mcPoint.
y;
831 Double_t dist =
sqrt(dx * dx + dy * dy);
837 if (minDist > dist || minDist < 0) {
841 hitMinX0 = hitPoint.
x;
843 hitMinY0 = hitPoint.
y;
844 hitMinZ0 = hitPoint.
z;
848 if (maxDist < dist) {
868 if (maxMinDist < minDist) {
869 maxMinDist = minDist;
874 nMinHits = nMinHits0;
879 cout <<
"BuildNearestHitStat: maxDist=" << maxDist <<
" MC x=" << mcX
880 <<
" Hit x=" << hitX <<
" MC y=" << mcY <<
" Hit y=" << hitY << endl;
881 cout <<
"BuildNearestHitStat: maxMinDist=" << maxMinDist <<
" MC x=" << mcMinX
882 <<
" Hit x=" << hitMinX <<
" MC y=" << mcMinY <<
" Hit y=" << hitMinY
883 <<
" n hits=" << nMinHits << endl;
889 for (vector<LxSimpleTrack*>::iterator
i =
allTracks.begin();
910 cout <<
"Statistics is built maxTracks=" <<
maxTracks
916 static Int_t jpsiTrackCount = 0;
917 static Int_t jpsiTrackCountCutted = 0;
918 static Int_t jpsiMatchedCount = 0;
919 static Int_t jpsiMatchedCountCutted = 0;
921 static Int_t otherTrackCount = 0;
922 static Int_t otherTrackCountCutted = 0;
923 static Int_t otherMatchedCount = 0;
924 static Int_t otherMatchedCountCutted = 0;
926 for (vector<LxSimpleTrack*>::iterator
i =
allTracks.begin();
936 for (list<LxSimplePoint>::iterator j =
942 for (list<LxSimplePoint>::iterator k =
947 Double_t diffZMuch = muchPt0.
z - muchPt1.
z;
948 Double_t txMuch = (muchPt0.
x - muchPt1.
x) / diffZMuch;
950 Double_t tyMuch = (muchPt0.
y - muchPt1.
y) / diffZMuch;
951 Connect(muchTrack, muchPt0, txMuch, tyMuch, useCuts);
959 ++jpsiTrackCountCutted;
961 if (muchTrack == muchTrack->
linkedStsTrack) ++jpsiMatchedCountCutted;
977 ++otherTrackCountCutted;
981 ++otherMatchedCountCutted;
1002 Double_t efficiency = jpsiMatchedCountCutted * 100;
1003 efficiency /= jpsiTrackCountCutted;
1004 cout <<
"J/psi (with cuts) connection efficiency = " << efficiency <<
"% ( "
1005 << jpsiMatchedCountCutted <<
" / " << jpsiTrackCountCutted <<
" )"
1007 efficiency = otherMatchedCountCutted * 100;
1008 efficiency /= otherTrackCountCutted;
1009 cout <<
"Others (with cuts) connection efficiency = " << efficiency
1010 <<
"% ( " << otherMatchedCountCutted <<
" / " << otherTrackCountCutted
1013 Double_t efficiency = jpsiMatchedCount * 100;
1014 efficiency /= jpsiTrackCount;
1015 cout <<
"J/psi (without cuts) connection efficiency = " << efficiency
1016 <<
"% ( " << jpsiMatchedCount <<
" / " << jpsiTrackCount <<
" )"
1018 efficiency = otherMatchedCount * 100;
1019 efficiency /= otherTrackCount;
1020 cout <<
"Others (without cuts) connection efficiency = " << efficiency
1021 <<
"% ( " << otherMatchedCount <<
" / " << otherTrackCount <<
" )"
1031 for (vector<LxSimpleTrack*>::iterator l =
allTracks.begin();
1036 if (stsTrack->
p < 3.0 || stsTrack->
pt < 1.0)
continue;
1046 if (!stsTrack->
stsPoints[n0].empty())
break;
1050 if (n0 <= m0 + 2)
break;
1056 for (;
m > 0; --
m) {
1060 for (; n >=
m - 2 && n >= 0; --n) {
1061 if (!stsTrack->
stsPoints[n].empty())
break;
1065 if (n >=
m - 2)
break;
1068 if (n >= 0 &&
m > n && n >=
m - 2) {
1076 Double_t txSts0 = (stsPtN0.
x - stsPtM0.
x) / (stsPtN0.
z - stsPtM0.
z);
1078 for (list<LxSimplePoint>::iterator o = stsTrack->
stsPoints[
m].begin();
1082 Double_t deltaZ = stsPtM.
z - muchPt0.
z;
1083 Double_t extX = muchPt0.
x + txMuch * deltaZ;
1084 Double_t extY = muchPt0.
y + tyMuch * deltaZ;
1085 Double_t dx = stsPtM.
x - extX;
1086 Double_t dy = stsPtM.
y - extY;
1088 if (dx < 0) dx = -dx;
1090 if (dy < 0) dy = -dy;
1094 for (list<LxSimplePoint>::iterator p = stsTrack->
stsPoints[n].begin();
1098 Double_t diffZSts = stsPtN.
z - stsPtM.
z;
1099 Double_t txSts = (stsPtN.
x - stsPtM.
x) / diffZSts;
1100 Double_t tySts = (stsPtN.
y - stsPtM.
y) / diffZSts;
1101 Double_t dtx = txSts - txMuch;
1102 Double_t dty = tySts - tyMuch;
1104 Double_t stsCharge =
1105 TDatabasePDG::Instance()->GetParticle(stsTrack->
pdgCode)->Charge();
1106 Double_t muchCharge = txMuch - txSts0;
1107 bool chargesSignsTheSame = (stsCharge > 0 && muchCharge > 0)
1108 || (stsCharge < 0 && muchCharge < 0);
1110 if (dtx < 0) dtx = -dtx;
1112 if (dty < 0) dty = -dty;
1116 && (!chargesSignsTheSame
1123 stsTrack->
charge = stsCharge;
1126 || chi2 < stsTrack->linkedMuchTrack.second) {
1127 list<pair<LxSimpleTrack*, Double_t>>::iterator r =
1134 pair<LxSimpleTrack*, Double_t> trackDesc(stsTrack, chi2);
1143 pair<LxSimpleTrack*, Double_t> trackDesc =
1147 trackDesc.first->linkedMuchTrack.first = muchTrack;