10#include "CbmKFPrimaryVertexFinder.h"
12#include "CbmKFTrackInterface.h"
14#include "CbmKFVertexInterface.h"
15#include "CbmMCTrack.h"
21#include "CbmStsTrack.h"
22#include "CbmTrackMatch.h"
24#include "FairMCApplication.h"
25#include "FairRootManager.h"
66 } Table[10] = {{
"x",
"Residual X [#mum]", 100, -100., 100.},
67 {
"y",
"Residual Y [#mum]", 100, -100., 100.},
68 {
"tx",
"Residual Tx [mrad]", 100, -2., 2.},
69 {
"ty",
"Residual Ty [mrad]", 100, -2., 2.},
70 {
"P",
"Resolution P/Q [100%]", 100, -.1, .1},
71 {
"px",
"Pull X [residual/estimated_error]", 100, -10., 10.},
72 {
"py",
"Pull Y [residual/estimated_error]", 100, -10., 10.},
73 {
"ptx",
"Pull Tx [residual/estimated_error]", 100, -10., 10.},
74 {
"pty",
"Pull Ty [residual/estimated_error]", 100, -10., 10.},
75 {
"pQP",
"Pull Q/P [residual/estimated_error]", 100, -10., 10.}};
77 for (
int i = 0;
i < 10;
i++) {
79 sprintf(
n,
"%s_%s", name, Table[
i].name);
80 sprintf(t,
"%s %s", title, Table[
i].title);
81 hist[
i] =
new TH1D(
n, t, Table[
i].
n, Table[
i].l, Table[
i].r);
94 {
"x",
"Residual X [#mum]", 100, -5., 5.},
95 {
"y",
"Residual Y [#mum]", 100, -5., 5.},
96 {
"z",
"Residual Z [#mum]", 100, -40., 40.},
97 {
"px",
"Pull X [residual/estimated_error]", 100, -10., 10.},
98 {
"py",
"Pull Y [residual/estimated_error]", 100, -10., 10.},
99 {
"pz",
"Pull Z [residual/estimated_error]", 100, -10., 10.},
100 {
"chi2",
"Chi2/NDF", 100, 0., 10.},
101 {
"prob",
"Prob(Chi2,NDF)", 100, 0., 1.},
102 {
"ntracks",
"N tracks", 100, 0., 1000.},
105 for (
int i = 0;
i < 9;
i++) {
107 sprintf(
n,
"%s_%s", name, Table[
i].name);
108 sprintf(t,
"%s %s", title, Table[
i].title);
109 hist[
i] =
new TH1D(
n, t, Table[
i].
n, Table[
i].l, Table[
i].r);
121 } Table[14] = {{
"x",
"Residual X [#mum]", 100, -100., 100.},
122 {
"y",
"Residual Y [#mum]", 100, -100., 100.},
123 {
"z",
"Residual Z [#mum]", 100, -500., 500.},
124 {
"px",
"Pull X [residual/estimated_error]", 100, -10., 10.},
125 {
"py",
"Pull Y [residual/estimated_error]", 100, -10., 10.},
126 {
"pz",
"Pull Z [residual/estimated_error]", 100, -10., 10.},
127 {
"chi2",
"Chi2/NDF", 100, 0., 10.},
128 {
"prob",
"Prob(Chi2,NDF)", 100, 0., 1.},
129 {
"mass",
"Residual Mass", 100, -.1, .1},
130 {
"pmass",
"Pull Mass [residual/estimated_error]", 100, -10., 10.},
131 {
"KaonP",
"Kaon P resolution", 100, -.05, .05},
132 {
"PionP",
"Pion P resolution", 100, -.05, .05},
133 {
"KaonP0",
"Kaon P resolution before fit", 100, -.05, .05},
134 {
"PionP0",
"Pion P resolutionbefore fit", 100, -.05, .05}};
136 for (
int i = 0;
i < 14;
i++) {
138 sprintf(
n,
"%s_%s", name, Table[
i].name);
139 sprintf(t,
"%s %s", title, Table[
i].title);
140 hist[
i] =
new TH1D(
n, t, Table[
i].
n, Table[
i].l, Table[
i].r);
230 fhChi2 =
new TH1D(
"hChi2",
"hChi2", 100, 0, 10);
231 fhProb =
new TH1D(
"hProb",
"hProb", 100, 0, 1.0);
233 fhDP =
new TH1D(
"hDP",
"hDP", 1000, -.005, .005);
234 fhDP2 =
new TH2D(
"hDP2",
"hDP2", 100, 0., 5.0, 1000, -.005, .005);
236 fhDsP =
new TH1D(
"hDsP",
"hDsP", 100, -1, 1);
237 fhDsP2 =
new TH2D(
"hDsP2",
"hDsP2", 100, 0., 5.0, 100, -1, 1);
239 fhZMCf =
new TH1D(
"hZMCf",
"h Z MC first", 102, -1.0, 101.0);
240 fhZRecof =
new TH1D(
"hZRecof",
"h Z Reco first", 102, -1.0, 101.0);
241 fhZMCl =
new TH1D(
"hZMCl",
"h Z MC last", 102, -1.0, 101.0);
242 fhZRecol =
new TH1D(
"hZRecol",
"h Z Reco last", 102, -1.0, 101.0);
245 new TH2D(
"hRes_vs_Mom_f",
"TX Resolusion vs Momentum (first hit)", 100, 0.0, 5.0, 100, -50.0, 50.0);
247 new TH2D(
"hRes_vs_Mom_l",
"TX Resolusion vs Momentum (last hit)", 100, 0.0, 5.0, 100, -10.0, 10.0);
250 new TH2D(
"hExtraTracks2ndMVD",
"ExtraTracks in the 2nd MVD", 200, -10.0, 10.0, 200, -10.0, 10.0);
279 fhPq =
new TH2D(
"Pq",
"Resolution P/Q at impact point vs P", 100, 0, 10, 100, -.1, .1);
284 for (
int i = 0;
i < 10;
i++) {
286 sprintf(
n,
"hHitDens%i",
i);
287 sprintf(t,
"Hit Density, Sts station %i",
i);
306 for (
int i = 0;
i < 13;
i++) {
307 char name[225], namedir[225], title[225];
309 sprintf(namedir,
"AllTracks");
310 sprintf(name,
"Vall");
311 sprintf(title,
"for Primary Vertex on all tracks");
313 sprintf(namedir,
"%iTracks",
i * 50);
314 sprintf(name,
"V%i",
i * 50);
315 sprintf(title,
"for Primary Vertex on %i tracks",
i * 50);
341 gDirectory->mkdir(
"Mass+Topological constraint");
342 gDirectory->cd(
"Mass+Topological constraint");
356 FairRootManager* fManger = FairRootManager::Instance();
374 cout <<
"Event: " << ++
fEvent <<
" ";
377 cout <<
" nTracks: " << nTracks << endl;
384 Int_t Quality[nTracks];
386 for (
Int_t iTrack = 0; iTrack < nTracks; iTrack++) {
394 if (
m->GetNofTrueHits() < 0.7 * (
m->GetNofTrueHits() +
m->GetNofWrongHits() +
m->GetNofFakeHits()))
396 Int_t mcTrackID =
m->GetMCTrackId();
417 cout <<
"Mvd hit density..." << endl;
418 for (
int ih = 0; ih < nMvdHits; ih++) {
424 double V[3] = {2 * h1->GetDx() * h1->GetDx(), 2 * 0, 2 * h1->GetDy() * h1->GetDy()};
425 Double_t v = 1. / (V[0] * V[2] - V[1] * V[1]);
430 for (
int jh = 0; jh < nMvdHits; jh++) {
438 Double_t dx = h1->GetX() - h2->GetX();
439 Double_t dy = h1->GetY() - h2->GetY();
440 Double_t d2 =
fabs(dx * dx * V[0] - 2 * dx * dy * V[1] + dy * dy * V[2]);
446 cout <<
"Sts hit density..." << endl;
447 for (
int ih = 0; ih < nStsHits; ih++) {
453 double V[3] = {2 * h1->GetDx() * h1->GetDx(), 2 * h1->
GetCovXY(), 2 * h1->GetDy() * h1->GetDy()};
454 Double_t v = 1. / (V[0] * V[2] - V[1] * V[1]);
459 for (
int jh = 0; jh < nStsHits; jh++) {
471 Double_t dx = h1->GetX() - h2->GetX();
472 Double_t dy = h1->GetY() - h2->GetY();
473 Double_t d2 =
fabs(dx * dx * V[0] - 2 * dx * dy * V[1] + dy * dy * V[2]);
482 cout <<
"Track density..." << endl;
484 double sC[nTracks][8][15];
485 double sT[nTracks][8][5];
486 for (
Int_t iTrack = 0; iTrack < nTracks; iTrack++) {
493 double z[8] = {0.2, 1, 2, 3, 4, 5, 10, 100};
494 for (
int iz = 0; iz < 8; iz++) {
495 FairTrackParam paramI;
496 fFitter.Extrapolate(trackI, z[iz], ¶mI);
498 if (!finite(sC[iTrack][iz][0]) || sC[iTrack][iz][0] < 0 || sC[iTrack][iz][0] > 10.) {
504 for (
Int_t iTrack = 0; iTrack < nTracks; iTrack++) {
506 if (iTrack % 10 == 0)
507 cout << iTrack << endl;
511 for (
int iz = 0; iz < 8; iz++)
513 double Chi2L = 1.e10;
515 for (
Int_t jTrack = 0; jTrack < nTracks; jTrack++) {
516 if (jTrack == iTrack)
521 for (
int iz = 0; iz < 8; iz++) {
523 for (
int i = 0;
i < 15;
i++)
524 C[
i] = sC[iTrack][iz][
i] + sC[jTrack][iz][
i];
525 for (
int i = 0;
i < 5;
i++)
526 d[
i] = sT[iTrack][iz][
i] - sT[jTrack][iz][
i];
530 for (
int i = 0;
i < 5;
i++) {
532 for (
int j = 0; j < 5; j++)
542 for (
int i = 0;
i < 4;
i++) {
544 for (
int j = 0; j < 4; j++)
554 for (
int iz = 0; iz < 8; iz++) {
561 for (
Int_t iTrack = 0; iTrack < nTracks; iTrack++) {
562 if (Quality[iTrack] < 1)
572 vector<CbmStsPoint*> vPoints;
580 Int_t pointID = hit->GetRefIndex();
586 vPoints.push_back(point);
588 vector<CbmMvdPoint*> vMPoints;
596 Int_t pointID = hit->GetRefIndex();
602 vMPoints.push_back(point);
607 if (
fabs(pzi) > 1.e-4)
611 mci[2] = mcTrack->
GetPx() * pzi;
612 mci[3] = mcTrack->
GetPy() * pzi;
615 if (!vPoints.empty()) {
619 vPoints.back()->MomentumOut(mom);
629 if (!vMPoints.empty())
652 for (vector<CbmStsPoint*>::iterator
i = vPoints.begin();
i != vPoints.end();
i++) {
653 int id = (*i)->GetDetectorID();
676 FairTrackParam param;
677 fFitter.Extrapolate(track, z, ¶m);
678 if (
fabs(mci[4]) > 1.e-4 &&
fabs(param.GetQp()) > 1.e-4)
679 fhPq->Fill(
fabs(1. / mci[4]), (mci[4] / param.GetQp() - 1.));
682 if (track->
GetNDF() > 0) {
697 Int_t nvtracks = 0, nvtrackscurr = 0;
699 for (
Int_t iTrack = 0; iTrack < nMCTracks; iTrack++) {
704 if (!Is_MC_V ||
fabs(z - MC_Vcurr.
Z()) > 1.e-7) {
706 if (nvtrackscurr > nvtracks) {
708 nvtracks = nvtrackscurr;
715 if (nvtrackscurr > nvtracks)
730 for (
Int_t iTrack = 0; iTrack < nTracks; iTrack++) {
731 if (Quality[iTrack] < 1)
754 for (
Int_t iK = 0; iK < nTracks; iK++) {
764 double zK = mcK->
GetPz();
765 if (zK - MC_V.
Z() < 1.e-5)
767 double MCPK = mcK->
GetP();
770 for (
Int_t iP = 0; iP < nTracks; iP++) {
783 if (
fabs(zP - zK) > 1.e-8)
785 double MCPP = mcP->
GetP();
787 const double D0 = 1.8645;
796 for (
int iconst = 0; iconst < 4; iconst++) {
825 SVFinder.
GetMass(&mass, &mass_err);
834 fhD0[iconst][0]->Fill(1.E4 * dx);
835 fhD0[iconst][1]->Fill(1.E4 * dy);
836 fhD0[iconst][2]->Fill(1.E4 * dz);
838 fhD0[iconst][3]->Fill(dx /
sqrt(sx));
840 fhD0[iconst][4]->Fill(dy /
sqrt(sy));
842 fhD0[iconst][5]->Fill(dz /
sqrt(sz));
847 fhD0[iconst][8]->Fill((mass - D0));
848 if (mass_err > 1.e-10)
849 fhD0[iconst][9]->Fill((mass - D0) / mass_err);
875 if ((mc[5] > 31.0) || (mc[5] < 29.0)) {
881 FairTrackParam param;
883 fFitter.Extrapolate(track, z, ¶m);
889 for (
int i = 0;
i < 6;
i++)
890 ok = ok && finite(t[
i]);
891 for (
int i = 0;
i < 15;
i++)
892 ok = ok && finite(c[
i]);
897 hist[0]->
Fill(1.E4 * (t[0] - mc[0]));
898 hist[1]->
Fill(1.E4 * (t[1] - mc[1]));
899 hist[2]->
Fill(1.E3 * (t[2] - mc[2]));
900 hist[3]->
Fill(1.E3 * (t[3] - mc[3]));
901 if (
fabs(t[4]) > 1.e-10)
902 hist[4]->
Fill((mc[4] / t[4] - 1.));
909 hist[5]->
Fill((t[0] - mc[0]) /
sqrt(c[0]));
911 hist[6]->
Fill((t[1] - mc[1]) /
sqrt(c[2]));
913 hist[7]->
Fill((t[2] - mc[2]) /
sqrt(c[5]));
915 hist[8]->
Fill((t[3] - mc[3]) /
sqrt(c[9]));
917 hist[9]->
Fill((t[4] - mc[4]) /
sqrt(c[14]));
926 Double_t s2x = V->GetCovariance(0, 0);
927 Double_t s2y = V->GetCovariance(1, 1);
928 Double_t s2z = V->GetCovariance(2, 2);
930 hist[0]->
Fill(1.E4 * dx);
931 hist[1]->
Fill(1.E4 * dy);
932 hist[2]->
Fill(1.E4 * dz);
939 hist[6]->
Fill(V->GetChi2() / V->GetNDF());
941 hist[8]->
Fill(V->GetNTracks());
949 Int_t mcTrackID = point->GetTrackID();
965 if (
fabs(pzi) > 1.e-4)
969 mc[4] = p.
Mag() > 1.e-4 ? q / p.
Mag() : 0;
979 Int_t mcTrackID = point->GetTrackID();
995 if (
fabs(pzi) > 1.e-4)
999 mc[4] = p.
Mag() > 1.e-4 ? q / p.
Mag() : 0;
1012 q = particlePDG->
Charge() / 3.;
1024 Int_t stmin = 1000, stmax = -1000;
1025 Int_t st, iHit, hitID;
1026 for (iHit = 0; iHit < nHits; iHit++) {
1034 if (stmax - stmin + 1 < 4)
friend F32vec4 fabs(const F32vec4 &a)
Double_t GetCovXY() const
Accessors.
static void CopyTrackParam2TC(FairTrackParam *par, Double_t T[], Double_t C[])
static Bool_t invS(Double_t A[], Int_t N)
static Int_t indexS(Int_t i, Int_t j)
The CbmKF Kalman Filter algorithm.
std::map< Int_t, Int_t > MvdStationIDMap
static CbmKF * Instance()
std::map< Int_t, Int_t > StsStationIDMap
Double_t GetStartZ() const
Double_t GetStartY() const
Int_t GetMotherId() const
Double_t GetStartX() const
void GetStartVertex(TVector3 &vertex) const
Int_t GetPdgCode() const
Accessors.
virtual Int_t GetStationNr() const
void MomentumOut(TVector3 &mom)
void PositionOut(TVector3 &pos)
Int_t FindPrimaryVertex(TClonesArray *tracks, CbmVertex *vertex)
Execution of PV finding.
virtual Int_t GetStationNr() const
Int_t GetDigi(Int_t iSide) const
The CbmStsKFSecondaryVertexFinder class.
void SetMassConstraint(Double_t MotherMass=-1)
void GetVertex(CbmVertex &vtx)
void SetTopoConstraint(CbmVertex *Parent=0)
void AddTrack(CbmStsTrack *Track)
void GetMass(Double_t *M, Double_t *Error)
void PositionOut(TVector3 &pos)
void MomentumOut(TVector3 &mom)
FairTrackParam * GetParamLast()
Int_t GetNMvdHits() const
Int_t GetMvdHitIndex(Int_t iHit) const
Int_t GetNStsHits() const
Accessors.
Int_t GetStsHitIndex(Int_t iHit) const
FairTrackParam * GetParamFirst()
Double_t GetX() const
Accessors.
Double_t GetCovariance(Int_t i, Int_t j) const
static TDatabasePDG * Instance()
TParticlePDG * GetParticle(const char *name) const
virtual TDirectory * mkdir(const char *name, const char *title="", Bool_t returnExistingDirectory=kFALSE)
virtual Int_t Fill(const char *name, Double_t w)
TObject * At(Int_t idx) const override
virtual Bool_t IsFolder() const
virtual const char * GetName() const
virtual Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
RVec< PromoteType< T > > abs(const RVec< T > &v)
RVec< PromoteType< T > > sqrt(const RVec< T > &v)
*brief user defined string literal for JSON values *sa std::size_t n
Double_t Prob(Double_t chi2, Int_t ndf)
Double_t Sqrt(Double_t x)