12 #include "TDatabasePDG.h"
13 #include "TGeoManager.h"
19 #include <sys/types.h>
87 if (mom < 3.0)
return false;
89 if (txBreak < 0) txBreak = -txBreak;
92 return inv > 0.18 && inv < 0.52;
98 while (!linkedStsTracks.empty()) {
99 pair<LxSimpleTrack*, scaltype> trackDesc = linkedStsTracks.front();
100 linkedStsTracks.pop_front();
103 if (0 == anotherMuchTrack
105 trackDesc.first->linkedMuchTrack.first =
this;
106 trackDesc.first->linkedMuchTrack.second = trackDesc.second;
107 linkedStsTrack = trackDesc.first;
120 , listMuchPixelHits(0)
121 , listMuchClusters(0)
122 , listMuchPixelDigiMatches(0)
126 , superEventTracks(0)
127 , superEventBrachTrack(0, 0, 0, 0, 0, 0, 0, 0)
128 , useHitsInStat(false)
129 , averagePoints(false)
130 , dontTouchNonPrimary(true)
131 , useChargeSignInCuts(false)
132 , buildConnectStat(false)
133 , buildBgrInvMass(false)
134 , buildSigInvMass(false)
136 , buildNearestHitDist(false)
138 , buildSegmentsStat(true)
140 , segmentsAnalyzer(*this) {}
145 for (vector<LxSimpleTrack*>::iterator
i =
allTracks.begin();
156 FairRootManager* fManager = FairRootManager::Instance();
157 listMCTracks =
static_cast<TClonesArray*
>(fManager->GetObject(
"MCTrack"));
161 listStsPts =
static_cast<TClonesArray*
>(fManager->GetObject(
"StsPoint"));
165 listMuchPts =
static_cast<TClonesArray*
>(fManager->GetObject(
"MuchPoint"));
171 static_cast<TClonesArray*
>(fManager->GetObject(
"MuchPixelHit"));
176 static_cast<TClonesArray*
>(fManager->GetObject(
"MuchCluster"));
181 static_cast<TClonesArray*
>(fManager->GetObject(
"MuchDigiMatch"));
188 "muchStsBreakX",
"Break in prediction of X in STS", 100, -20., 20.);
191 "muchStsBreakY",
"Break in prediction of Y in STS", 100, -20., 20.);
194 "muchStsBreakTx",
"Break in prediction of Tx in STS", 100, -0.15, 0.15);
197 "muchStsBreakTy",
"Break in prediction of Ty in STS", 100, -0.15, 0.15);
201 "stsMuchBreakX",
"Break in prediction of X in MUCH", 100, -20., 20.);
204 "stsMuchBreakY",
"Break in prediction of Y in MUCH", 100, -20., 20.);
207 signalChi2 =
new TH1F(
"signalChi2",
"Chi2 of signal", 100, 0., 15.);
209 bgrChi2 =
new TH1F(
"bgrChi2",
"Chi2 of background", 100, 0., 20.);
216 "Invariant mass distribution for background",
223 new TTree(
"SuperEventTracks",
"Tracks for building a super event");
231 "sigInvMass",
"Invariant mass distribution for signal", 1000, 2., 4.);
240 sprintf(name,
"nearestHitDist_%d",
i);
242 title,
"Distance from a MC point to the nearest hit at %d station",
i);
245 sprintf(name,
"hitsDist_%d",
i);
246 sprintf(title,
"Distance from a MC point to the hits at %d station",
i);
247 hitsDist[
i] =
new TH1F(name, title, 100, 0., 7.);
253 new TH1F(
"muPlusStsTxDiff",
"muPlusStsTxDiff", 100, -0.2, 0.2);
256 new TH1F(
"muMinusStsTxDiff",
"muMinusStsTxDiff", 100, -0.2, 0.2);
259 new TH1F(
"muPlusStsXDiff",
"muPlusStsXDiff", 100, -10.0, 10.0);
262 new TH1F(
"muMinusStsXDiff",
"muMinusStsXDiff", 100, -10.0, 10.0);
265 new TH1F(
"muPlusVertexTxDiff",
"muPlusVertexTxDiff", 100, -0.2, 0.2);
268 new TH1F(
"muMinusVertexTxDiff",
"muMinusVertexTxDiff", 100, -0.2, 0.2);
272 "muPlusStsBeginTxDiff2D",
281 "muMinusStsBeginTxDiff2D",
290 deltaPhiPi =
new TH1F(
"deltaPhiPi",
"deltaPhiPi", 100, 0., 1.0);
294 "jPsiMuonsMomsHisto",
"J/Psi muons momenta distribution", 200, 0., 25.);
297 gGeoManager->cd(
"/cave_1/Magnet_container_0");
298 Double_t localCoords[3] = {0., 0., 0.};
299 Double_t globalCoords[3];
300 gGeoManager->LocalToMaster(localCoords, globalCoords);
306 "dtxMomProductHisto",
"Dtx x Momentum distribution", 100, -0.5, 2.5);
310 new TH1F(
"stsEndTrackCountHisto",
"stsEndTrackCountHisto", 200, 0, 2000.0);
313 "muchBeginTrackCountHisto",
"muchBeginTrackCountHisto", 200, 0, 3000.0);
324 DIR* dir = opendir(dir_name);
329 mkdir(dir_name, 0700);
332 sprintf(file_name,
"%s/%s", dir_name, name);
333 TFile fh(file_name,
"RECREATE");
340 list<LxSimpleTrack*>& nTracks,
342 for (list<LxSimpleTrack*>::iterator
i = pTracks.begin();
i != pTracks.end();
346 for (list<LxSimpleTrack*>::iterator j = nTracks.begin(); j != nTracks.end();
353 scaltype m122 = E12 * E12 - px12 * px12 - py12 * py12 - pz12 * pz12;
361 for (list<CbmStsTrack*>::iterator
i = stsTracks.begin();
i != stsTracks.end();
371 list<CbmStsTrack*>::iterator j =
i;
374 for (; j != stsTracks.end(); ++j) {
379 const FairTrackParam* t2param = negTrack->
GetParamLast();
383 if (t1Qp * t2Qp >= 0)
continue;
386 vector<CbmKFTrackInterface*> kfData;
389 kfData.push_back(&muPlus);
390 kfData.push_back(&muMinus);
392 kfData.push_back(&muMinus);
393 kfData.push_back(&muPlus);
407 TFile* curFile = TFile::CurrentFile();
424 TFile fh(
"tracks_tree.root");
430 list<CbmStsTrack*> stsTracks;
433 for (Int_t
i = 0;
i < nEnt; ++
i) {
438 stsTracks.push_back(t);
444 for (list<CbmStsTrack*>::iterator
i = stsTracks.begin();
445 i != stsTracks.end();
449 TFile fh(
"tracks_tree.root",
"RECREATE");
465 sprintf(fileName,
"%s.root",
hitsDist[
i]->GetName());
482 "muMinusStsBeginTxDiff2D.root");
496 TFile::CurrentFile() = curFile;
497 FairTask::FinishTask();
507 cout <<
"There are: " << nEnt <<
" of MC tracks" << endl;
509 for (Int_t
i = 0;
i < nEnt; ++
i) {
523 cout <<
"There are: " << nEnt <<
" of STS MC points" << endl;
525 for (Int_t
i = 0;
i < nEnt; ++
i) {
527 Int_t mcTrackId = stsPt->GetTrackID();
530 stsPt->Position(xyzI);
532 TVector3 xyz = .5 * (xyzI + xyzO);
533 TVector3 pxyzI, pxyzO;
534 stsPt->Momentum(pxyzI);
536 TVector3 pxyz = .5 * (pxyzI + pxyzO);
538 xyz.X(), xyz.Y(), xyz.Z(), pxyz.X() / pxyz.Z(), pxyz.Y() / pxyz.Z());
541 track->
stsPoints[stationNr].push_back(point);
545 cout <<
"There are: " << nEnt <<
" of MUCH MC points" << endl;
547 for (Int_t
i = 0;
i < nEnt; ++
i) {
549 Int_t mcTrackId = mcPoint->GetTrackID();
555 mcPoint->Position(xyzI);
557 TVector3 xyz = .5 * (xyzI + xyzO);
558 TVector3 pxyzI, pxyzO;
559 mcPoint->Momentum(pxyzI);
561 TVector3 pxyz = .5 * (pxyzI + pxyzO);
563 xyz.X(), xyz.Y(), xyz.Z(), pxyz.X() / pxyz.Z(), pxyz.Y() / pxyz.Z());
566 track->
muchMCPts[stationNr][layerNr].push_back(point);
568 track->
muchPoints[stationNr][layerNr].push_back(point);
573 cout <<
"There are: " << nEnt <<
" of MUCH pixel hits" << endl;
575 for (Int_t
i = 0;
i < nEnt; ++
i) {
588 if (
x !=
x ||
y !=
y || z != z)
596 for (Int_t j = 0; j < nDigis; ++j) {
601 for (Int_t k = 0; k < nMCs; ++k) {
606 Int_t mcTrackId = mcPoint->GetTrackID();
613 track->
muchPoints[stationNr][layerNr].push_back(point);
619 cout <<
"There are: " << nEnt <<
" of MUCH clusters" << endl;
622 cout <<
"There are: " << nEnt <<
" of MUCH pixel digi matches" << endl;
646 for (list<LxSimplePoint>::iterator
i =
points.begin();
i !=
points.end();
663 points.push_back(averagedPoint);
673 for (Int_t j = 0; j <
LXLAYERS; ++j)
678 for (Int_t j = 0; j <
LXLAYERS; ++j)
685 for (vector<LxSimpleTrack*>::iterator
i =
allTracks.begin();
717 for (list<LxSimplePoint>::iterator k =
723 scaltype txMuch = (muchPt0.
x - muchPt1.
x) / diffZMuch;
724 scaltype tyMuch = (muchPt0.
y - muchPt1.
y) / diffZMuch;
727 scaltype magX = muchPt0.
x + txMuch * diffZMag;
729 scaltype diffMagTx = txMuch - magTx;
737 scaltype txDiff = txMuch - muchPt0.
x / muchPt0.
z;
744 txMuch - (p1.
x - p0.
x) / (p1.
z - p0.
z));
746 (p1.
x - p0.
x) / (p1.
z - p0.
z) - txMuch);
749 }
else if (13 == track->
pdgCode) {
750 scaltype txDiff = txMuch - muchPt0.
x / muchPt0.
z;
757 txMuch - (p1.
x - p0.
x) / (p1.
z - p0.
z));
759 (p1.
x - p0.
x) / (p1.
z - p0.
z) - txMuch);
764 for (list<LxSimplePoint>::iterator l = track->
stsPoints[7].begin();
769 scaltype extX = muchPt0.
x + txMuch * diffZ;
770 scaltype extY = muchPt0.
y + tyMuch * diffZ;
777 scaltype extXmu = muchPt0.
x + (txMuch - 0.00671) * diffZ;
779 }
else if (13 == track->
pdgCode) {
780 scaltype extXmu = muchPt0.
x + (txMuch + 0.00691) * diffZ;
784 for (list<LxSimplePoint>::iterator
m = track->
stsPoints[6].begin();
789 scaltype txSts = (stsPt6.
x - stsPt7.
x) / diffZSts;
790 scaltype tySts = (stsPt6.
y - stsPt7.
y) / diffZSts;
812 diffZ = muchPt0.
z - stsPt7.
z;
813 extX = stsPt7.
x + txSts * diffZ;
814 extY = stsPt7.
y + tySts * diffZ;
815 dx = muchPt0.
x - extX;
816 dy = muchPt0.
y - extY;
837 static Int_t nMinHits = 0;
855 for (list<LxSimplePoint>::iterator j =
868 if (minDist > dist || minDist < 0) {
872 hitMinX0 = hitPoint.
x;
874 hitMinY0 = hitPoint.
y;
875 hitMinZ0 = hitPoint.
z;
879 if (maxDist < dist) {
899 if (maxMinDist < minDist) {
900 maxMinDist = minDist;
905 nMinHits = nMinHits0;
910 cout <<
"BuildNearestHitStat: maxDist=" << maxDist <<
" MC x=" << mcX
911 <<
" Hit x=" << hitX <<
" MC y=" << mcY <<
" Hit y=" << hitY << endl;
912 cout <<
"BuildNearestHitStat: maxMinDist=" << maxMinDist <<
" MC x=" << mcMinX
913 <<
" Hit x=" << hitMinX <<
" MC y=" << mcMinY <<
" Hit y=" << hitMinY
914 <<
" n hits=" << nMinHits << endl;
920 Int_t stsEndTracks = 0;
921 Int_t muchBeginTracks = 0;
923 for (vector<LxSimpleTrack*>::iterator
i =
allTracks.begin();
928 if (!track->
stsPoints[7].empty()) ++stsEndTracks;
953 cout <<
"Statistics is built maxTracks=" <<
maxTracks
959 static Int_t jpsiTrackCount = 0;
960 static Int_t jpsiTrackCountCutted = 0;
961 static Int_t jpsiMatchedCount = 0;
962 static Int_t jpsiMatchedCountCutted = 0;
964 static Int_t otherTrackCount = 0;
965 static Int_t otherTrackCountCutted = 0;
966 static Int_t otherMatchedCount = 0;
967 static Int_t otherMatchedCountCutted = 0;
969 for (vector<LxSimpleTrack*>::iterator
i =
allTracks.begin();
979 for (list<LxSimplePoint>::iterator j =
985 for (list<LxSimplePoint>::iterator k =
991 scaltype txMuch = (muchPt0.
x - muchPt1.
x) / diffZMuch;
993 scaltype tyMuch = (muchPt0.
y - muchPt1.
y) / diffZMuch;
994 Connect(muchTrack, muchPt0, txMuch, tyMuch, useCuts);
1002 ++jpsiTrackCountCutted;
1004 if (muchTrack == muchTrack->
linkedStsTrack) ++jpsiMatchedCountCutted;
1020 ++otherTrackCountCutted;
1024 ++otherMatchedCountCutted;
1039 ++otherMatchedCount;
1045 scaltype efficiency = jpsiMatchedCountCutted * 100;
1046 efficiency /= jpsiTrackCountCutted;
1047 cout <<
"J/psi (with cuts) connection efficiency = " << efficiency <<
"% ( "
1048 << jpsiMatchedCountCutted <<
" / " << jpsiTrackCountCutted <<
" )"
1050 efficiency = otherMatchedCountCutted * 100;
1051 efficiency /= otherTrackCountCutted;
1052 cout <<
"Others (with cuts) connection efficiency = " << efficiency
1053 <<
"% ( " << otherMatchedCountCutted <<
" / " << otherTrackCountCutted
1056 scaltype efficiency = jpsiMatchedCount * 100;
1057 efficiency /= jpsiTrackCount;
1058 cout <<
"J/psi (without cuts) connection efficiency = " << efficiency
1059 <<
"% ( " << jpsiMatchedCount <<
" / " << jpsiTrackCount <<
" )"
1061 efficiency = otherMatchedCount * 100;
1062 efficiency /= otherTrackCount;
1063 cout <<
"Others (without cuts) connection efficiency = " << efficiency
1064 <<
"% ( " << otherMatchedCount <<
" / " << otherTrackCount <<
" )"
1074 for (vector<LxSimpleTrack*>::iterator l =
allTracks.begin();
1079 if (stsTrack->
p < 3.0 || stsTrack->
pt < 1.0)
continue;
1089 if (!stsTrack->
stsPoints[n0].empty())
break;
1093 if (n0 <= m0 + 2)
break;
1099 for (;
m > 0; --
m) {
1103 for (; n >=
m - 2 && n >= 0; --n) {
1104 if (!stsTrack->
stsPoints[n].empty())
break;
1108 if (n >=
m - 2)
break;
1111 if (n >= 0 &&
m > n && n >=
m - 2) {
1119 scaltype txSts0 = (stsPtN0.
x - stsPtM0.
x) / (stsPtN0.
z - stsPtM0.
z);
1121 for (list<LxSimplePoint>::iterator o = stsTrack->
stsPoints[
m].begin();
1126 scaltype extX = muchPt0.
x + txMuch * deltaZ;
1127 scaltype extY = muchPt0.
y + tyMuch * deltaZ;
1131 if (dx < 0) dx = -dx;
1133 if (dy < 0) dy = -dy;
1137 for (list<LxSimplePoint>::iterator p = stsTrack->
stsPoints[n].begin();
1142 scaltype txSts = (stsPtN.
x - stsPtM.
x) / diffZSts;
1143 scaltype tySts = (stsPtN.
y - stsPtM.
y) / diffZSts;
1148 TDatabasePDG::Instance()->GetParticle(stsTrack->
pdgCode)->Charge();
1149 scaltype muchCharge = txMuch - txSts0;
1150 bool chargesSignsTheSame = (stsCharge > 0 && muchCharge > 0)
1151 || (stsCharge < 0 && muchCharge < 0);
1153 if (dtx < 0) dtx = -dtx;
1155 if (dty < 0) dty = -dty;
1159 && (!chargesSignsTheSame
1166 stsTrack->
charge = stsCharge;
1169 || chi2 < stsTrack->linkedMuchTrack.second) {
1170 list<pair<LxSimpleTrack*, scaltype>>::iterator r =
1177 pair<LxSimpleTrack*, scaltype> trackDesc(stsTrack, chi2);
1186 pair<LxSimpleTrack*, scaltype> trackDesc =
1190 trackDesc.first->linkedMuchTrack.first = muchTrack;