27 #include "FairMCApplication.h"
28 #include "FairRootManager.h"
30 #include "TDatabasePDG.h"
32 #include "TParticlePDG.h"
51 TDirectory* cur = gDirectory;
52 TDirectory* sub = cur->mkdir(obj->GetName());
54 TList* listSub = ((TDirectory*) obj)->GetList();
56 while (TObject* obj1 = it())
71 {
"x",
"Residual X [#mum]", 100, -100., 100.},
72 {
"y",
"Residual Y [#mum]", 100, -100., 100.},
73 {
"tx",
"Residual Tx [mrad]", 100, -2., 2.},
74 {
"ty",
"Residual Ty [mrad]", 100, -2., 2.},
75 {
"P",
"Resolution P/Q [100%]", 100, -.1, .1},
76 {
"px",
"Pull X [residual/estimated_error]", 100, -10., 10.},
77 {
"py",
"Pull Y [residual/estimated_error]", 100, -10., 10.},
78 {
"ptx",
"Pull Tx [residual/estimated_error]", 100, -10., 10.},
79 {
"pty",
"Pull Ty [residual/estimated_error]", 100, -10., 10.},
80 {
"pQP",
"Pull Q/P [residual/estimated_error]", 100, -10., 10.}};
82 for (
int i = 0;
i < 10;
i++) {
84 sprintf(n,
"%s_%s", name, Table[
i].name);
85 sprintf(t,
"%s %s", title, Table[
i].title);
86 hist[
i] =
new TH1D(n, t, Table[
i].n, Table[
i].l, Table[
i].r);
99 {
"x",
"Residual X [#mum]", 100, -5., 5.},
100 {
"y",
"Residual Y [#mum]", 100, -5., 5.},
101 {
"z",
"Residual Z [#mum]", 100, -40., 40.},
102 {
"px",
"Pull X [residual/estimated_error]", 100, -10., 10.},
103 {
"py",
"Pull Y [residual/estimated_error]", 100, -10., 10.},
104 {
"pz",
"Pull Z [residual/estimated_error]", 100, -10., 10.},
105 {
"chi2",
"Chi2/NDF", 100, 0., 10.},
106 {
"prob",
"Prob(Chi2,NDF)", 100, 0., 1.},
107 {
"ntracks",
"N tracks", 100, 0., 1000.},
110 for (
int i = 0;
i < 9;
i++) {
112 sprintf(n,
"%s_%s", name, Table[
i].name);
113 sprintf(t,
"%s %s", title, Table[
i].title);
114 hist[
i] =
new TH1D(n, t, Table[
i].n, Table[
i].l, Table[
i].r);
127 {
"x",
"Residual X [#mum]", 100, -100., 100.},
128 {
"y",
"Residual Y [#mum]", 100, -100., 100.},
129 {
"z",
"Residual Z [#mum]", 100, -500., 500.},
130 {
"px",
"Pull X [residual/estimated_error]", 100, -10., 10.},
131 {
"py",
"Pull Y [residual/estimated_error]", 100, -10., 10.},
132 {
"pz",
"Pull Z [residual/estimated_error]", 100, -10., 10.},
133 {
"chi2",
"Chi2/NDF", 100, 0., 10.},
134 {
"prob",
"Prob(Chi2,NDF)", 100, 0., 1.},
135 {
"mass",
"Residual Mass", 100, -.1, .1},
136 {
"pmass",
"Pull Mass [residual/estimated_error]", 100, -10., 10.},
137 {
"KaonP",
"Kaon P resolution", 100, -.05, .05},
138 {
"PionP",
"Pion P resolution", 100, -.05, .05},
139 {
"KaonP0",
"Kaon P resolution before fit", 100, -.05, .05},
140 {
"PionP0",
"Pion P resolutionbefore fit", 100, -.05, .05}};
142 for (
int i = 0;
i < 14;
i++) {
144 sprintf(n,
"%s_%s", name, Table[
i].name);
145 sprintf(t,
"%s %s", title, Table[
i].title);
146 hist[
i] =
new TH1D(n, t, Table[
i].n, Table[
i].l, Table[
i].r);
154 : FairTask(name, iVerbose)
198 fhExtraTracks2ndMVD(0)
230 TDirectory* curdir = gDirectory;
231 histodir = gDirectory->mkdir(
"StsFitPerformance");
234 gDirectory->mkdir(
"TrackFit");
235 gDirectory->cd(
"TrackFit");
237 fhChi2 =
new TH1D(
"hChi2",
"hChi2", 100, 0, 10);
238 fhProb =
new TH1D(
"hProb",
"hProb", 100, 0, 1.0);
240 fhDP =
new TH1D(
"hDP",
"hDP", 1000, -.005, .005);
241 fhDP2 =
new TH2D(
"hDP2",
"hDP2", 100, 0., 5.0, 1000, -.005, .005);
243 fhDsP =
new TH1D(
"hDsP",
"hDsP", 100, -1, 1);
244 fhDsP2 =
new TH2D(
"hDsP2",
"hDsP2", 100, 0., 5.0, 100, -1, 1);
246 fhZMCf =
new TH1D(
"hZMCf",
"h Z MC first", 102, -1.0, 101.0);
247 fhZRecof =
new TH1D(
"hZRecof",
"h Z Reco first", 102, -1.0, 101.0);
248 fhZMCl =
new TH1D(
"hZMCl",
"h Z MC last", 102, -1.0, 101.0);
249 fhZRecol =
new TH1D(
"hZRecol",
"h Z Reco last", 102, -1.0, 101.0);
252 "TX Resolusion vs Momentum (first hit)",
260 "TX Resolusion vs Momentum (last hit)",
269 "ExtraTracks in the 2nd MVD",
277 gDirectory->mkdir(
"AtFirstHit");
278 gDirectory->cd(
"AtFirstHit");
280 gDirectory->cd(
"..");
281 gDirectory->mkdir(
"AtLastHit");
282 gDirectory->cd(
"AtLastHit");
284 gDirectory->cd(
"..");
285 gDirectory->mkdir(
"AtImpactPoint");
286 gDirectory->cd(
"AtImpactPoint");
288 gDirectory->cd(
"..");
289 gDirectory->mkdir(
"AtImpactPointPion");
290 gDirectory->cd(
"AtImpactPointPion");
292 gDirectory->cd(
"..");
293 gDirectory->mkdir(
"InTheMiddle");
294 gDirectory->cd(
"InTheMiddle");
296 gDirectory->cd(
"..");
297 gDirectory->mkdir(
"FittedToVertex");
298 gDirectory->cd(
"FittedToVertex");
300 gDirectory->cd(
"..");
302 gDirectory->mkdir(
"PSlidesOnP");
303 gDirectory->cd(
"PSlidesOnP");
305 "Pq",
"Resolution P/Q at impact point vs P", 100, 0, 10, 100, -.1, .1);
306 gDirectory->cd(
"..");
308 gDirectory->cd(
"..");
310 for (
int i = 0;
i < 10;
i++) {
312 sprintf(n,
"hHitDens%i",
i);
313 sprintf(t,
"Hit Density, Sts station %i",
i);
317 new TH1D(
"hTrackDensity0",
"Track Density 0cm", 300, 0, 300);
319 new TH1D(
"hTrackDensity0L",
"Track Density Line 0cm", 300, 0, 300);
321 new TH1D(
"hTrackDensity1",
"Track Density 1cm", 300, 0, 300);
323 new TH1D(
"hTrackDensity2",
"Track Density 2cm", 300, 0, 300);
325 new TH1D(
"hTrackDensity3",
"Track Density 3cm", 300, 0, 300);
327 new TH1D(
"hTrackDensity4",
"Track Density 4cm", 300, 0, 300);
329 new TH1D(
"hTrackDensity5",
"Track Density 5cm", 300, 0, 300);
331 new TH1D(
"hTrackDensity10",
"Track Density 10cm", 300, 0, 300);
333 new TH1D(
"hTrackDensity100",
"Track Density 1m", 300, 0, 300);
335 gDirectory->mkdir(
"VertexFit");
336 gDirectory->cd(
"VertexFit");
339 gDirectory->mkdir(
"VertexOnNTracks");
340 gDirectory->cd(
"VertexOnNTracks");
341 for (
int i = 0;
i < 13;
i++) {
342 char name[225], namedir[225], title[225];
344 sprintf(namedir,
"AllTracks");
345 sprintf(name,
"Vall");
346 sprintf(title,
"for Primary Vertex on all tracks");
348 sprintf(namedir,
"%iTracks",
i * 50);
349 sprintf(name,
"V%i",
i * 50);
350 sprintf(title,
"for Primary Vertex on %i tracks",
i * 50);
352 gDirectory->mkdir(namedir);
353 gDirectory->cd(namedir);
355 gDirectory->cd(
"..");
357 gDirectory->cd(
"..");
359 gDirectory->cd(
"..");
361 gDirectory->mkdir(
"D0Fit");
362 gDirectory->cd(
"D0Fit");
364 gDirectory->mkdir(
"No constraints");
365 gDirectory->cd(
"No constraints");
367 gDirectory->cd(
"..");
368 gDirectory->mkdir(
"Topological constraint");
369 gDirectory->cd(
"Topological constraint");
371 gDirectory->cd(
"..");
372 gDirectory->mkdir(
"Mass constraint");
373 gDirectory->cd(
"Mass constraint");
375 gDirectory->cd(
"..");
376 gDirectory->mkdir(
"Mass+Topological constraint");
377 gDirectory->cd(
"Mass+Topological constraint");
379 gDirectory->cd(
"..");
381 gDirectory->cd(
"..");
390 FairRootManager* fManger = FairRootManager::Instance();
392 reinterpret_cast<TClonesArray*
>(fManger->GetObject(
"MCTrack"));
394 reinterpret_cast<TClonesArray*
>(fManger->GetObject(
"StsPoint"));
396 reinterpret_cast<TClonesArray*
>(fManger->GetObject(
"MvdPoint"));
398 reinterpret_cast<TClonesArray*
>(fManger->GetObject(
"StsTrack"));
399 fStsHitArray =
reinterpret_cast<TClonesArray*
>(fManger->GetObject(
"StsHit"));
400 fMvdHitArray =
reinterpret_cast<TClonesArray*
>(fManger->GetObject(
"MvdHit"));
406 dynamic_cast<CbmVertex*
>(fManger->GetObject(
"PrimaryVertex."));
409 dynamic_cast<CbmVertex*
>(fManger->GetObject(
"PrimaryVertex"));
412 cout <<
"-W- CbmStsFitPerformanceTask::ReInit : "
413 <<
"no Primary Vertex!" << endl;
417 reinterpret_cast<TClonesArray*
>(fManger->GetObject(
"StsTrackMatch"));
427 cout <<
"Event: " << ++
fEvent <<
" ";
430 cout <<
" nTracks: " << nTracks << endl;
436 Int_t Quality[nTracks];
438 for (Int_t iTrack = 0; iTrack < nTracks; iTrack++) {
441 if (!track)
continue;
444 if (
m->GetNofTrueHits() < 0.7
445 * (
m->GetNofTrueHits() +
m->GetNofWrongHits()
446 +
m->GetNofFakeHits()))
448 Int_t mcTrackID =
m->GetMCTrackId();
449 if (mcTrackID < 0)
continue;
450 if (!
IsLong(track))
continue;
453 if (!mcTrack)
continue;
464 cout <<
"Mvd hit density..." << endl;
465 for (
int ih = 0; ih < nMvdHits; ih++) {
466 if (ih % 100 == 0) cout << ih << endl;
471 Double_t
v = 1. / (V[0] * V[2] - V[1] * V[1]);
476 for (
int jh = 0; jh < nMvdHits; jh++) {
477 if (ih == jh)
continue;
481 Double_t dx = h1->
GetX() - h2->
GetX();
482 Double_t dy = h1->
GetY() - h2->
GetY();
484 fabs(dx * dx * V[0] - 2 * dx * dy * V[1] + dy * dy * V[2]);
485 if (d2 < D2) D2 = d2;
489 cout <<
"Sts hit density..." << endl;
490 for (
int ih = 0; ih <
nStsHits; ih++) {
491 if (ih % 1000 == 0) cout << ih << endl;
497 Double_t
v = 1. / (V[0] * V[2] - V[1] * V[1]);
502 for (
int jh = 0; jh <
nStsHits; jh++) {
503 if (ih == jh)
continue;
513 Double_t dx = h1->
GetX() - h2->
GetX();
514 Double_t dy = h1->
GetY() - h2->
GetY();
516 fabs(dx * dx * V[0] - 2 * dx * dy * V[1] + dy * dy * V[2]);
517 if (d2 < D2) D2 = d2;
522 ->Fill(
sqrt(D2 / 2));
527 cout <<
"Track density..." << endl;
529 double sC[nTracks][8][15];
530 double sT[nTracks][8][5];
531 for (Int_t iTrack = 0; iTrack < nTracks; iTrack++) {
535 if (!
IsLong(trackI))
continue;
537 double z[8] = {0.2, 1, 2, 3, 4, 5, 10, 100};
538 for (
int iz = 0; iz < 8; iz++) {
539 FairTrackParam paramI;
542 if (!
finite(sC[iTrack][iz][0]) || sC[iTrack][iz][0] < 0
543 || sC[iTrack][iz][0] > 10.) {
549 for (Int_t iTrack = 0; iTrack < nTracks; iTrack++) {
551 if (iTrack % 10 == 0) cout << iTrack << endl;
552 if (!flag[iTrack])
continue;
554 for (
int iz = 0; iz < 8; iz++)
556 double Chi2L = 1.e10;
558 for (Int_t jTrack = 0; jTrack < nTracks; jTrack++) {
559 if (jTrack == iTrack)
continue;
560 if (!flag[jTrack])
continue;
562 for (
int iz = 0; iz < 8; iz++) {
563 Double_t C[15],
d[5];
564 for (
int i = 0;
i < 15;
i++)
565 C[
i] = sC[iTrack][iz][
i] + sC[jTrack][iz][
i];
566 for (
int i = 0;
i < 5;
i++)
567 d[
i] = sT[iTrack][iz][
i] - sT[jTrack][iz][
i];
571 for (
int i = 0;
i < 5;
i++) {
573 for (
int j = 0; j < 5; j++)
578 if (chi2 < Chi2[iz]) Chi2[iz] = chi2;
582 for (
int i = 0;
i < 4;
i++) {
584 for (
int j = 0; j < 4; j++)
589 if (chi2 < Chi2L) Chi2L = chi2;
593 for (
int iz = 0; iz < 8; iz++) {
600 for (Int_t iTrack = 0; iTrack < nTracks; iTrack++) {
601 if (Quality[iTrack] < 1)
continue;
609 vector<CbmStsPoint*> vPoints;
612 if (hitID < 0)
continue;
616 if (pointID < 0)
continue;
618 if (!point)
continue;
619 vPoints.push_back(point);
621 vector<CbmMvdPoint*> vMPoints;
624 if (hitID < 0)
continue;
628 if (pointID < 0)
continue;
630 if (!point)
continue;
631 vMPoints.push_back(point);
635 Double_t pzi = mcTrack->
GetPz();
636 if (
fabs(pzi) > 1.e-4) pzi = 1. / pzi;
639 mci[2] = mcTrack->
GetPx() * pzi;
640 mci[3] = mcTrack->
GetPy() * pzi;
641 mci[4] = (
fabs(mcTrack->
GetP()) > 1.e-4)
645 if (!vPoints.empty()) {
647 Double_t p1 = mcTrack->
GetP();
649 vPoints.back()->MomentumOut(mom);
650 Double_t p2 = mom.Mag();
652 * TMath::Sqrt(TMath::Abs(
655 (p1 - p2) * TMath::Sqrt(1 + mci[2] * mci[2] + mci[3] * mci[3]);
662 if (!vMPoints.empty())
685 for (vector<CbmStsPoint*>::iterator
i = vPoints.begin();
688 int id = (*i)->GetDetectorID();
711 FairTrackParam param;
713 if (
fabs(mci[4]) > 1.e-4 &&
fabs(param.GetQp()) > 1.e-4)
714 fhPq->Fill(
fabs(1. / mci[4]), (mci[4] / param.GetQp() - 1.));
717 if (track->
GetNDF() > 0) {
728 TVector3 MC_V(0, 0, 0);
731 TVector3 MC_Vcurr(0, 0, 0);
732 Int_t nvtracks = 0, nvtrackscurr = 0;
734 for (Int_t iTrack = 0; iTrack <
nMCTracks; iTrack++) {
738 if (!Is_MC_V ||
fabs(z - MC_Vcurr.Z()) > 1.e-7) {
740 if (nvtrackscurr > nvtracks) {
742 nvtracks = nvtrackscurr;
749 if (nvtrackscurr > nvtracks) MC_V = MC_Vcurr;
762 TClonesArray TracksToFit(
"CbmStsTrack");
764 for (Int_t iTrack = 0; iTrack < nTracks; iTrack++) {
765 if (Quality[iTrack] < 1)
continue;
770 if (N % 50 != 0)
continue;
772 if (
i >= 13)
continue;
786 for (Int_t iK = 0; iK < nTracks; iK++) {
787 if (Quality[iK] < 1)
continue;
793 double zK = mcK->
GetPz();
794 if (zK - MC_V.Z() < 1.e-5)
continue;
795 double MCPK = mcK->
GetP();
798 for (Int_t iP = 0; iP < nTracks; iP++) {
799 if (Quality[iP] < 1)
continue;
809 if (
fabs(zP - zK) > 1.e-8)
continue;
810 double MCPP = mcP->
GetP();
812 const double D0 = 1.8645;
821 for (
int iconst = 0; iconst < 4; iconst++) {
845 Double_t mass, mass_err;
849 SVFinder.
GetMass(&mass, &mass_err);
850 if (sv.
GetNDF() <= 0)
continue;
851 Double_t dx = sv.
GetX() - mc_.X();
852 Double_t dy = sv.
GetY() - mc_.Y();
853 Double_t dz = sv.
GetZ() - mc_.Z();
857 fhD0[iconst][0]->Fill(1.E4 * dx);
858 fhD0[iconst][1]->Fill(1.E4 * dy);
859 fhD0[iconst][2]->Fill(1.E4 * dz);
860 if (sx > 1.e-10)
fhD0[iconst][3]->Fill(dx /
sqrt(sx));
861 if (sy > 1.e-10)
fhD0[iconst][4]->Fill(dy /
sqrt(sy));
862 if (sz > 1.e-10)
fhD0[iconst][5]->Fill(dz /
sqrt(sz));
867 fhD0[iconst][8]->Fill((mass - D0));
868 if (mass_err > 1.e-10)
869 fhD0[iconst][9]->Fill((mass - D0) / mass_err);
873 fhD0[iconst][12]->Fill(
876 fhD0[iconst][13]->Fill(
897 if ((mc[5] > 31.0) || (mc[5] < 29.0)) {
903 FairTrackParam param;
911 for (
int i = 0;
i < 6;
i++)
913 for (
int i = 0;
i < 15;
i++)
918 hist[0]->Fill(1.E4 * (t[0] - mc[0]));
919 hist[1]->Fill(1.E4 * (t[1] - mc[1]));
920 hist[2]->Fill(1.E3 * (t[2] - mc[2]));
921 hist[3]->Fill(1.E3 * (t[3] - mc[3]));
922 if (
fabs(t[4]) > 1.e-10) hist[4]->Fill((mc[4] / t[4] - 1.));
928 if (c[0] > 1.e-10) hist[5]->Fill((t[0] - mc[0]) /
sqrt(c[0]));
929 if (c[2] > 1.e-10) hist[6]->Fill((t[1] - mc[1]) /
sqrt(c[2]));
930 if (c[5] > 1.e-10) hist[7]->Fill((t[2] - mc[2]) /
sqrt(c[5]));
931 if (c[9] > 1.e-10) hist[8]->Fill((t[3] - mc[3]) /
sqrt(c[9]));
932 if (c[14] > 1.e-10) hist[9]->Fill((t[4] - mc[4]) /
sqrt(c[14]));
939 Double_t dx = V->
GetX() - mc.X();
940 Double_t dy = V->
GetY() - mc.Y();
941 Double_t dz = V->
GetZ() - mc.Z();
946 hist[0]->Fill(1.E4 * dx);
947 hist[1]->Fill(1.E4 * dy);
948 hist[2]->Fill(1.E4 * dz);
949 if (s2x > 1.e-10) hist[3]->Fill(dx /
sqrt(s2x));
950 if (s2y > 1.e-10) hist[4]->Fill(dy /
sqrt(s2y));
951 if (s2z > 1.e-10) hist[5]->Fill(dz /
sqrt(s2z));
962 Int_t mcTrackID = point->GetTrackID();
964 if (!mcTrack)
return;
977 if (
fabs(pzi) > 1.e-4) pzi = 1. / pzi;
980 mc[4] = p.Mag() > 1.e-4 ? q / p.Mag() : 0;
990 Int_t mcTrackID = point->GetTrackID();
992 if (!mcTrack)
return;
1005 if (
fabs(pzi) > 1.e-4) pzi = 1. / pzi;
1006 mc[2] = p.x() * pzi;
1007 mc[3] = p.y() * pzi;
1008 mc[4] = p.Mag() > 1.e-4 ? q / p.Mag() : 0;
1019 TParticlePDG* particlePDG = TDatabasePDG::Instance()->GetParticle(pdgCode);
1021 q = particlePDG->Charge() / 3.;
1031 if (nHits < 4)
return 0;
1032 Int_t stmin = 1000, stmax = -1000;
1033 Int_t st, iHit, hitID;
1034 for (iHit = 0; iHit < nHits; iHit++) {
1037 if (st < stmin) stmin = st;
1038 if (st > stmax) stmax = st;
1040 if (stmax - stmin + 1 < 4)
return 0;