13 #include "TDatabasePDG.h"
14 #include "TGeoManager.h"
40 #ifdef MAKE_DISPERSE_2D_HISTOS
44 #endif //MAKE_DISPERSE_2D_HISTOS
62 std::vector<LxMCPoint>
64 std::vector<LxMCTrack>
68 #ifdef MAKE_DISPERSE_2D_HISTOS
71 #endif //MAKE_DISPERSE_2D_HISTOS
77 #endif //MAKE_EFF_CALC
79 #ifdef CALC_MUCH_DETECTORS_EFF
81 Int_t mcPointsTriggered;
82 #endif //CALC_MUCH_DETECTORS_EFF
90 , listMuchPixelDigiMatches(0)
122 #ifdef CALC_MUCH_DETECTORS_EFF
124 , mcPointsTriggered(0)
135 GetHistoRMS(
const char* histoNameBase, Int_t histoNumber, Double_t& retVal) {
140 sprintf(name,
"%s/%s_%d.root", dir_name, histoNameBase, histoNumber);
141 TFile* curFile = TFile::CurrentFile();
142 TFile*
f =
new TFile(name);
144 if (!
f->IsZombie()) {
145 sprintf(name,
"%s_%d", histoNameBase, histoNumber);
146 TH1F*
h =
static_cast<TH1F*
>(
f->Get(name));
147 retVal =
h->GetRMS();
152 TFile::CurrentFile() = curFile;
163 sprintf(name,
"configuration/%s_%d.root", histoNameBase, histoNumber);
164 TFile* curFile = TFile::CurrentFile();
165 TFile*
f =
new TFile(name);
167 if (!
f->IsZombie()) {
168 sprintf(name,
"%s_%d", histoNameBase, histoNumber);
169 TH2F*
h =
static_cast<TH2F*
>(
f->Get(name));
170 retVal =
h->GetCovariance(axis1, axis2);
175 TFile::CurrentFile() = curFile;
181 cout <<
"LxFinderTriplet::Init() called at " <<
nTimes++ <<
" time" << endl;
185 FairRootManager* fManager = FairRootManager::Instance();
188 LX_DYNAMIC_CAST<TClonesArray*>(fManager->GetObject(
"MuchPixelHit"));
189 listMCTracks = LX_DYNAMIC_CAST<TClonesArray*>(fManager->GetObject(
"MCTrack"));
191 LX_DYNAMIC_CAST<TClonesArray*>(fManager->GetObject(
"MuchPoint"));
193 LX_DYNAMIC_CAST<TClonesArray*>(fManager->GetObject(
"MuchCluster"));
195 LX_DYNAMIC_CAST<TClonesArray*>(fManager->GetObject(
"MuchDigiMatch"));
197 LX_DYNAMIC_CAST<TClonesArray*>(fManager->GetObject(
"StsTrack"));
199 LX_DYNAMIC_CAST<TClonesArray*>(fManager->GetObject(
"StsTrackMatch"));
200 listStsPts = LX_DYNAMIC_CAST<TClonesArray*>(fManager->GetObject(
"StsPoint"));
222 for (Int_t j = 0; j <
LXLAYERS; ++j) {
223 TString muchStLrPath =
224 Form(
"/cave_1/much_0/muchstation%02i_0/muchstation%02ilayer%01i_0",
228 gGeoManager->cd(muchStLrPath.Data());
229 Double_t localCoords[3] = {0., 0., 0.};
230 Double_t globalCoords[3];
231 gGeoManager->LocalToMaster(localCoords, globalCoords);
232 aStation->
layers[j]->zCoord = globalCoords[2];
233 #ifdef MAKE_DISPERSE_2D_HISTOS
235 #endif //MAKE_DISPERSE_2D_HISTOS
240 bool readHistoResult =
true;
262 #ifdef OUT_DISP_BY_TRIPLET_DIR
264 "muchOutStationXDispByTriplet",
i, aStation->xOutDispTriplet);
265 aStation->xOutDispTriplet2 =
266 aStation->xOutDispTriplet * aStation->xOutDispTriplet;
268 "muchOutStationYDispByTriplet",
i, aStation->yOutDispTriplet);
269 aStation->yOutDispTriplet2 =
270 aStation->yOutDispTriplet * aStation->yOutDispTriplet;
271 #else //OUT_DISP_BY_TRIPLET_DIR
280 #endif //OUT_DISP_BY_TRIPLET_DIR
285 GetHistoRMS(
"muchOutStationTxBreakLeft",
i, anLStation->txBreakRight);
286 anLStation->txBreakRight2 =
287 anLStation->txBreakRight * anLStation->txBreakRight;
289 GetHistoRMS(
"muchOutStationTyBreakLeft",
i, anLStation->tyBreakRight);
290 anLStation->tyBreakRight2 =
291 anLStation->tyBreakRight * anLStation->tyBreakRight;
293 GetHistoRMS(
"muchOutStationTxBreakRight",
i, aStation->txBreakLeft);
294 aStation->txBreakLeft2 = aStation->txBreakLeft * aStation->txBreakLeft;
296 GetHistoRMS(
"muchOutStationTyBreakRight",
i, aStation->tyBreakLeft);
297 aStation->tyBreakLeft2 = aStation->tyBreakLeft * aStation->tyBreakLeft;
307 #endif //USE_SEGMENTS
310 if (!
GetHistoRMS(
"muchClusterXDispHisto",
i, rms))
return kFATAL;
312 aStation->clusterXLimit = rms;
313 aStation->clusterXLimit2 = rms * rms;
315 if (!
GetHistoRMS(
"muchClusterYDispHisto",
i, rms))
return kFATAL;
317 aStation->clusterYLimit = rms;
318 aStation->clusterYLimit2 = rms * rms;
320 if (!
GetHistoRMS(
"muchClusterTxDispHisto",
i, rms))
return kFATAL;
322 aStation->clusterTxLimit = rms;
323 aStation->clusterTxLimit2 = rms * rms;
325 if (!
GetHistoRMS(
"muchClusterTyDispHisto",
i, rms))
return kFATAL;
327 aStation->clusterTyLimit = rms;
328 aStation->clusterTyLimit2 = rms * rms;
329 #endif //CLUSTER_MODE
334 "muchSegmentTxBreakHisto",
i, aStation->txInterStationBreak);
335 aStation->txInterStationBreak2 =
336 aStation->txInterStationBreak * aStation->txInterStationBreak;
338 "muchSegmentTyBreakHisto",
i, aStation->tyInterStationBreak);
339 aStation->tyInterStationBreak2 =
340 aStation->tyInterStationBreak * aStation->tyInterStationBreak;
342 #endif //USE_SEGMENTS
345 if (!readHistoResult)
return kFATAL;
347 #ifdef USE_KALMAN_FIT
349 for (Int_t j = 0; j <= 1; ++j) {
350 for (Int_t k = 0; k <= 1; ++k) {
359 #endif //USE_KALMAN_FIT
365 "MuchTrack",
"Much",
listRecoTracks, IsOutputBranchPersistent(
"MuchTrack"));
368 massHisto =
new TH1F(
"jpsi_mass",
"jpsi_mass", 100, 2., 4.);
373 new TTree(
"SuperEventTracks",
"Tracks for building a super event");
379 signalChi2Histo =
new TH1F(
"signal_chi2",
"signal_chi2", 200, 0., 20.);
382 new TH1F(
"background_chi2",
"background_chi2", 200, 0., 20.);
391 for (
int i = 0;
i < 6; ++
i) {
392 #ifdef MAKE_DISPERSE_2D_HISTOS
393 sprintf(histoName,
"disperseL_%d",
i);
395 new TProfile2D(histoName, histoName, 30, -3., 3., 30, -3., 3.);
397 sprintf(histoName,
"disperseR_%d",
i);
399 new TProfile2D(histoName, histoName, 30, -3., 3., 30, -3., 3.);
401 sprintf(histoName,
"disperseD_%d",
i);
403 new TProfile2D(histoName, histoName, 30, -3., 3., 30, -3., 3.);
405 #endif //MAKE_DISPERSE_2D_HISTOS
411 "Reconstruction efficiency by momentum",
418 stsTrackChi2 =
new TH1F(
"stsTrackChi2",
"stsTrackChi2", 200, 0., 10.);
420 stsTrackX =
new TH1F(
"stsTrackX",
"stsTrackX", 200, -0.2, 0.2);
422 stsTrackY =
new TH1F(
"stsTrackY",
"stsTrackY", 200, -0.2, 0.2);
426 "Distance between signal tracks",
432 "Distance between background tracks",
438 new TH1F(
"signalSignDefect",
"signalSignDefect", 200, -0.15, 0.15);
440 bgrSignDefect =
new TH1F(
"bgrSignDefect",
"bgrSignDefect", 200, -0.15, 0.15);
443 new TH1F(
"signalYAtZ0",
"Signal track Y at Z=0", 200, -40.0, 40.0);
446 new TH1F(
"bgrYAtZ0",
"Background track Y at Z=0", 200, -40.0, 40.0);
449 new TH1F(
"signalYAtZ0_2",
"Signal track Y at Z=0 (2)", 200, -40.0, 40.0);
452 new TH1F(
"bgrYAtZ0_2",
"Background track Y at Z=0 (2)", 200, -40.0, 40.0);
457 #endif //MAKE_EFF_CALC
465 cout <<
"LxFinderTriplet::Exec() called at " <<
nTimes++ <<
" time" << endl;
466 timeval bTime, eTime;
468 gettimeofday(&bTime, 0);
475 for (
int i = 0;
i < 8; ++
i)
478 #ifdef MAKE_DISPERSE_2D_HISTOS
483 #endif //MAKE_DISPERSE_2D_HISTOS
490 cout <<
"There are: " << nEnt <<
" of MC tracks" << endl;
494 Int_t* root2lxmctrackmap =
new Int_t[nEnt];
497 for (
int i = 0;
i < nEnt; ++
i) {
499 mcTrack.
p = mct->
GetP();
502 if (abs(pdgCode) >= 10000) {
503 root2lxmctrackmap[
i] = -1;
507 root2lxmctrackmap[
i] = mapCnt++;
509 mcTrack.
q = TDatabasePDG::Instance()->GetParticle(pdgCode)->Charge() / 3.0;
518 mcTrack.
pdg = pdgCode;
524 cout <<
"There are: " << nEnt <<
" of STS MC points" << endl;
526 for (
int i = 0;
i < nEnt; ++
i) {
527 TVector3 xyzI,
PI, xyzO, PO;
530 if (0 == stsPt)
continue;
533 stsPt->Position(xyzI);
537 TVector3 xyz = .5 * (xyzI + xyzO);
538 TVector3 P = .5 * (
PI + PO);
539 stsMCPoint.
x = xyz.X();
540 stsMCPoint.
y = xyz.Y();
541 stsMCPoint.
z = xyz.Z();
542 stsMCPoint.
px = P.X();
543 stsMCPoint.
py = P.Y();
544 stsMCPoint.
pz = P.Z();
547 + stsMCPoint.
pz * stsMCPoint.
pz));
550 Int_t trackId = root2lxmctrackmap[stsPt->GetTrackID()];
563 cout <<
"There are: " << nEnt <<
" of MUCH MC points" << endl;
567 Int_t* root2lxmcpointmap =
new Int_t
572 Int_t maxReferencedPtsIndex = 0;
574 for (
int i = 0;
i < nEnt; ++
i) {
575 TVector3 xyzI,
PI, xyzO, PO;
579 root2lxmcpointmap[
i] = -1;
583 Int_t trackId = root2lxmctrackmap[pt->GetTrackID()];
586 root2lxmcpointmap[
i] = -1;
593 root2lxmcpointmap[
i] = mapCnt++;
599 TVector3 xyz = .5 * (xyzI + xyzO);
600 TVector3 P = .5 * (
PI + PO);
608 + mcPoint.
pz * mcPoint.
pz));
613 Int_t ptId = root2lxmcpointmap[
i];
622 #ifdef MAKE_DISPERSE_2D_HISTOS
625 #endif //MAKE_DISPERSE_2D_HISTOS
634 if ((13 != track.
pdg && -13 == track.
pdg) || track.
mother_ID >= 0)
continue;
636 if (track.
p < 3)
continue;
638 Double_t pt2 = track.
px * track.
px + track.
py * track.
py;
640 if (pt2 < 1)
continue;
645 for (vector<LxMCPoint*>::iterator j = track.
Points.begin();
653 #ifdef MAKE_DISPERSE_2D_HISTOS
656 Double_t tx = mPoint->
x / mPoint->
z;
657 Double_t ty = mPoint->
y / mPoint->
z;
659 Double_t
x = mPoint->
x + tx * diffZ;
660 Double_t
y = mPoint->
y + ty * diffZ;
663 for (list<LxMCPoint*>::iterator k = lPoints.begin(); k != lPoints.end();
674 x = mPoint->
x + tx * diffZ;
675 y = mPoint->
y + ty * diffZ;
678 for (list<LxMCPoint*>::iterator k = rPoints.begin(); k != rPoints.end();
691 Double_t tx = rPoint->
x / rPoint->
z;
692 Double_t ty = rPoint->
y / rPoint->
z;
694 Double_t
x = rPoint->
x + tx * diffZ;
695 Double_t
y = rPoint->
y + ty * diffZ;
698 for (list<LxMCPoint*>::iterator k = lPoints.begin(); k != lPoints.end();
708 #endif //MAKE_DISPERSE_2D_HISTOS
716 cout <<
"There are: " << nEnt <<
" of MUCH pixel hits" << endl;
718 Double_t minXErr = 1000;
719 Double_t minYErr = 1000;
721 for (Int_t
i = 0;
i < nEnt; ++
i) {
730 Double_t
x =
pos.X();
731 Double_t
y =
pos.Y();
732 Double_t z =
pos.Z();
734 if (
x !=
x ||
y !=
y || z != z)
737 if (minXErr > err.X()) minXErr = err.X();
739 if (minYErr > err.Y()) minYErr = err.Y();
745 stationNumber, layerNumber,
i,
x,
y, z, err.X(), err.Y(), err.Z());
752 for (Int_t j = 0; j < nDigis; ++j) {
757 for (Int_t k = 0; k < nMCs; ++k) {
761 if (mcIndex > maxReferencedPtsIndex) maxReferencedPtsIndex = mcIndex;
763 Int_t mcIndexMapped = root2lxmcpointmap[mcIndex];
765 if (-1 == mcIndexMapped)
continue;
768 MCPoints[mcIndexMapped].lxPoints.push_back(lxPoint);
770 }
else if (
MCPoints[mcIndexMapped].lxPoints.empty()) {
781 MCPoints[mcIndexMapped].lxPoints.push_back(lxPoint);
788 cout <<
"minXErr = " << minXErr <<
" ; minYErr = " << minYErr << endl << endl;
791 gettimeofday(&eTime, 0);
793 (eTime.tv_sec - bTime.tv_sec) * 1000000 + eTime.tv_usec - bTime.tv_usec;
794 cout <<
"Execution duration 1 was: " << exeDuration << endl;
799 bTime.tv_sec = eTime.tv_sec;
800 bTime.tv_usec = eTime.tv_usec;
801 gettimeofday(&eTime, 0);
803 (eTime.tv_sec - bTime.tv_sec) * 1000000 + eTime.tv_usec - bTime.tv_usec;
804 cout <<
"Execution duration 2 was: " << exeDuration << endl;
809 #endif //CLUSTER_MODE
810 bTime.tv_sec = eTime.tv_sec;
811 bTime.tv_usec = eTime.tv_usec;
812 gettimeofday(&eTime, 0);
814 (eTime.tv_sec - bTime.tv_sec) * 1000000 + eTime.tv_usec - bTime.tv_usec;
815 cout <<
"Execution duration 3 was: " << exeDuration << endl;
820 #endif //CLUSTER_MODE
821 bTime.tv_sec = eTime.tv_sec;
822 bTime.tv_usec = eTime.tv_usec;
823 gettimeofday(&eTime, 0);
825 (eTime.tv_sec - bTime.tv_sec) * 1000000 + eTime.tv_usec - bTime.tv_usec;
826 cout <<
"Execution duration 4 was: " << exeDuration << endl;
831 #endif //CLUSTER_MODE
833 bTime.tv_sec = eTime.tv_sec;
834 bTime.tv_usec = eTime.tv_usec;
835 gettimeofday(&eTime, 0);
837 (eTime.tv_sec - bTime.tv_sec) * 1000000 + eTime.tv_usec - bTime.tv_usec;
838 cout <<
"Execution duration 5 was: " << exeDuration << endl;
851 for (
int i = 0;
i < nEnt; ++
i) {
860 if (lpa[0] != lpa[0] || lpa[1] != lpa[1] || lpa[2] != lpa[2]
861 || lpa[3] != lpa[3] || lpa[4] != lpa[4])
873 FairTrackParam params;
875 Double_t p = 1 / params.GetQp();
878 if (p2 < 3.0 * 3.0)
continue;
887 Double_t tx2 = params.GetTx() * params.GetTx();
888 Double_t ty2 = params.GetTy() * params.GetTy();
889 Double_t pt2 = p2 * (tx2 + ty2) / (1 + tx2 + ty2);
891 if (pt2 < 1.0)
continue;
894 extTrack.
track = stsTrack;
904 Int_t mappedId = root2lxmctrackmap[mcTrackId];
906 if (-1 != mappedId) {
907 MCTracks[mappedId].externalTrack = stsTrack;
921 cout <<
"External tracks are read" << endl;
925 cout <<
"External tracks are connected" << endl;
977 delete[] root2lxmctrackmap;
978 delete[] root2lxmcpointmap;
991 if (0 == stsTrack)
continue;
1006 FairTrackParam parFirst;
1010 FairTrackParam parLast(parFirst);
1014 new ((*listRecoTracks)[trackNo++])
CbmMuchTrack(muchTrack);
1030 Int_t pdg1 = mcTrack1 ? mcTrack1->
pdg : 10000;
1031 map<Int_t, map<Int_t, int>>::iterator j =
particleCounts.find(pdg1);
1035 .insert(pair<Int_t, map<Int_t, int>>(pdg1, map<Int_t, int>()))
1038 Int_t pdg2 = mcTrack2 ? mcTrack2->
pdg : 10000;
1040 map<Int_t, int>::iterator k = j->second.find(pdg2);
1042 if (k != j->second.end())
1045 j->second.insert(pair<Int_t, int>(pdg2, 1));
1063 if (!mcTrack2 || (mcTrack2->
pdg != 13 && mcTrack2->
pdg != -13)
1069 FairTrackParam t1param;
1072 if (t1param.GetQp() <= 0)
continue;
1074 Double_t p1 = 1 / t1param.GetQp();
1075 Double_t tx12 = t1param.GetTx() * t1param.GetTx();
1076 Double_t ty12 = t1param.GetTy() * t1param.GetTy();
1077 Double_t pt12 = p1 * p1 * (tx12 + ty12) / (1 + tx12 + ty12);
1079 if (pt12 < 1)
continue;
1093 || (mcSecondTrack->
pdg != 13 && mcSecondTrack->
pdg != -13)
1100 FairTrackParam t2param;
1103 if (t2param.GetQp() >= 0)
continue;
1105 Double_t p2 = 1 / t2param.GetQp();
1106 Double_t tx22 = t2param.GetTx() * t2param.GetTx();
1107 Double_t ty22 = t2param.GetTy() * t2param.GetTy();
1108 Double_t pt22 = p2 * p2 * (tx22 + ty22) / (1 + tx22 + ty22);
1110 if (pt22 < 1)
continue;
1113 vector<CbmKFTrackInterface*> kfData;
1114 kfData.push_back(&muPlus);
1115 kfData.push_back(&muMinus);
1130 TFile fh(name,
"RECREATE");
1161 TFile* curFile = TFile::CurrentFile();
1163 char histoFileName[128];
1165 for (
int i = 0;
i < 6; ++
i) {
1166 #ifdef MAKE_DISPERSE_2D_HISTOS
1167 sprintf(histoFileName,
"disperseL_histo_%d.root",
i);
1169 sprintf(histoFileName,
"disperseR_histo_%d.root",
i);
1171 sprintf(histoFileName,
"disperseD_histo_%d.root",
i);
1173 #endif //MAKE_DISPERSE_2D_HISTOS
1175 #endif //MAKE_HISTOS
1178 TFile fh(
"effByMomentumProfile.root",
"RECREATE");
1200 TFile::CurrentFile() = curFile;
1202 #ifdef MAKE_EFF_CALC
1204 #endif //MAKE_EFF_CALC
1208 FairTask::FinishTask();
1212 TFile* curFile = TFile::CurrentFile();
1214 TFile fh(
"jpsi_inv_mass_histo.root",
"RECREATE");
1219 TFile::CurrentFile() = curFile;
1234 vector<CbmKFTrackInterface*> kfData;
1235 kfData.push_back(&muPlus);
1236 kfData.push_back(&muMinus);
1248 TFile* curFile = TFile::CurrentFile();
1250 TFile fh(
"tracks_tree.root",
"RECREATE");
1255 TFile::CurrentFile() = curFile;