13 #include "CbmMuchHit.h"
18 #include "CbmStsTrackMatch.h"
20 #include "FairRootManager.h"
22 #include "TClonesArray.h"
24 #include "TLorentzVector.h"
40 : FairTask(name, iVerbose) {
53 (TClonesArray*) FairRootManager::Instance()->GetObject(
"MuchPoint");
54 fMuchHits = (TClonesArray*) FairRootManager::Instance()->GetObject(
"MuchHit");
56 (TClonesArray*) FairRootManager::Instance()->GetObject(
"StsTrack");
58 (TClonesArray*) FairRootManager::Instance()->GetObject(
"MuchTrack");
59 fMCTracks = (TClonesArray*) FairRootManager::Instance()->GetObject(
"MCTrack");
65 FairRootManager::Instance()->GetObject(
"PrimaryVertex."));
68 FairRootManager::Instance()->GetObject(
"PrimaryVertex"));
71 Error(
"CbmL1MuchFinderQa::ReInit",
"vertex not found!");
76 (TClonesArray*) FairRootManager::Instance()->GetObject(
"StsTrackMatch");
88 static int EventCounter = 0;
90 cout <<
" MuRecQa event " << EventCounter << endl;
92 static bool first_call = 1;
98 TDirectory* curdir = gDirectory;
99 histodir = gDirectory->mkdir(
"MuRecQa");
103 new TProfile(
"eff_signal",
"Signal Mu eff vs mom", 60, 0, 30);
104 fhPerfAll =
new TProfile(
"eff_all",
"All Mu eff vs mom", 60, 0, 30);
105 fhGhost =
new TProfile(
"ghost",
"ghost vs mom", 60, 0, 30);
107 char S1[255], S2[255];
108 for (
int ist = 0; ist < MuNStations; ist++) {
109 sprintf(S1,
"station %i", ist);
112 sprintf(S1,
"Pull_x_%i", ist);
113 sprintf(S2,
"Pull_x of sts track at Mu detector %i ", ist);
114 histPull_dx[ist] =
new TH1F(S1, S2, 100, -10., 10.);
115 sprintf(S1,
"Pull_y_%i", ist);
116 sprintf(S2,
"Pull_y of sts track at Mu detector %i ", ist);
117 histPull_dy[ist] =
new TH1F(S1, S2, 100, -10., 10.);
118 sprintf(S1,
"Pull_tx_%i", ist);
119 sprintf(S2,
"Pull_tx of sts track at Mu detector %i ", ist);
120 histPull_tx[ist] =
new TH1F(S1, S2, 100, -10., 10.);
121 sprintf(S1,
"Pull_ty_%i", ist);
122 sprintf(S2,
"Pull_ty of sts track at Mu detector %i ", ist);
123 histPull_ty[ist] =
new TH1F(S1, S2, 100, -10., 10.);
124 sprintf(S1,
"Pull_qp_%i", ist);
125 sprintf(S2,
"Pull_qp of sts track at Mu detector %i ", ist);
126 histPull_qp[ist] =
new TH1F(S1, S2, 100, -10., 10.);
128 sprintf(S1,
"chi2hit_%i", ist);
129 sprintf(S2,
"chi2 between track and hit at Mu detector %i ", ist);
130 histChi2[ist] =
new TH1F(S1, S2, 1000, 0, 100);
133 sprintf(S1,
"b_Pull_x_%i", ist);
134 sprintf(S2,
"b_Pull_x of sts track at Mu detector %i ", ist);
135 histPull_dx[20 + ist] =
new TH1F(S1, S2, 100, -10., 10.);
136 sprintf(S1,
"b_Pull_y_%i", ist);
137 sprintf(S2,
"b_Pull_y of sts track at Mu detector %i ", ist);
138 histPull_dy[20 + ist] =
new TH1F(S1, S2, 100, -10., 10.);
139 sprintf(S1,
"b_Pull_tx_%i", ist);
140 sprintf(S2,
"b_Pull_tx of sts track at Mu detector %i ", ist);
141 histPull_tx[20 + ist] =
new TH1F(S1, S2, 100, -10., 10.);
142 sprintf(S1,
"b_Pull_ty_%i", ist);
143 sprintf(S2,
"b_Pull_ty of sts track at Mu detector %i ", ist);
144 histPull_ty[20 + ist] =
new TH1F(S1, S2, 100, -10., 10.);
145 sprintf(S1,
"b_Pull_qp_%i", ist);
146 sprintf(S2,
"b_Pull_qp of sts track at Mu detector %i ", ist);
147 histPull_qp[20 + ist] =
new TH1F(S1, S2, 100, -10., 10.);
165 bool was_problem = 0;
167 static int NMu5 = 0, NMuRec5 = 0, NMu10 = 0, NMuRec10 = 0;
168 static int NMuS5 = 0, NMuSRec5 = 0, NMuS10 = 0, NMuSRec10 = 0;
169 static int NGhost5 = 0, NGhostRec5 = 0, NGhost10 = 0, NGhostRec10 = 0;
171 int IndMuTrack[NStsTracks];
173 for (
int itr = 0; itr < NStsTracks; itr++)
174 IndMuTrack[itr] = -1;
176 for (
int itr = 0; itr < NMuchTracks; itr++) {
179 int ists = Tmu->GetStsTrackID();
180 if (ists < 0)
continue;
181 IndMuTrack[ists] = itr;
184 for (
int ists = 0; ists < NStsTracks; ists++) {
190 1. *
m->GetNofTrueHits()
191 / (
m->GetNofTrueHits() +
m->GetNofWrongHits() +
m->GetNofFakeHits());
192 if (ratio < .7)
continue;
193 Int_t mcTrackID =
m->GetMCTrackId();
194 if (mcTrackID < 0)
continue;
196 if (!mcTrack)
continue;
200 Double_t P = mcTrack->
GetP();
203 int NMissedStations = 0;
206 for (
int ih = 0; ih < NH; ih++) {
207 CbmMuchHit*
h = (CbmMuchHit*)
fMuchHits->At(ih);
208 int ist =
h->GetStationNr() - 1;
209 if (ist != ista_last + 1) { NMissedStations += ist - 1 - ista_last; }
211 int ip =
h->GetRefIndex();
212 if (ip < 0)
continue;
214 if (mcTrackID == p->GetTrackID()) NMuHits++;
217 if (Tsts->GetNStsHits() + Tsts->GetNMvdHits() < 4)
continue;
219 bool Muon = (abs(mcTrack->
GetPdgCode()) == 13);
220 bool Signal = (mcTrack->
GetMotherId() < 0 && mcTrackID < 3 && Muon);
222 if (Muon && (NMuHits < 3 || NMissedStations > 0))
continue;
225 if (IndMuTrack[ists] >= 0) {
227 if (Tmu && Tmu->GetNHits() + Tmu->GetNMissedHits() >= 3)
228 MuonFlag = Tmu->GetNMissedHits() <= 2 && Tmu->GetNMissedStations() == 0;
237 NMuSRec5 += MuonFlag;
240 NMuSRec10 += MuonFlag;
249 NMuRec10 += MuonFlag;
251 if (!MuonFlag) was_problem = 1;
256 NGhostRec5 += MuonFlag;
259 NGhostRec10 += MuonFlag;
264 cout <<
" N Signal Mu Total/Reconstructed <5Gev = " << NMuS5 <<
"/"
265 << NMuSRec5 <<
"; >=5Gev = " << NMuS10 <<
"/" << NMuSRec10 << endl;
266 cout <<
" N Mu Total/Reconstructed <5Gev = " << NMu5 <<
"/" << NMuRec5
267 <<
"; >=5Gev = " << NMu10 <<
"/" << NMuRec10 << endl;
268 cout <<
" N Ghost Total/Reconstructed <5Gev = " << NGhost5 <<
"/"
269 << NGhostRec5 <<
"; >=5Gev = " << NGhost10 <<
"/" << NGhostRec10 << endl;
273 vector<CbmL1MuchHit> vMuchHits;
275 for (
int ih = 0; ih < NHits; ih++) {
276 CbmMuchHit*
h = (CbmMuchHit*)
fMuchHits->At(ih);
278 vMuchHits.push_back(
m);
309 for (
int itr = 0; itr < NStsTracks; itr++) {
312 if (Tsts->GetNStsHits() + Tsts->GetNMvdHits() < 4)
continue;
316 Int_t mcTrackID =
m->GetMCTrackId();
317 if (mcTrackID < 0)
continue;
319 if (!mcTrack)
continue;
320 if (abs(mcTrack->
GetPdgCode()) != 13)
continue;
322 1. *
m->GetNofTrueHits()
323 / (
m->GetNofTrueHits() +
m->GetNofWrongHits() +
m->GetNofFakeHits());
324 if (ratio < .7)
continue;
334 for (
int ist = 0; ist < MuNStations; ist++) {
337 if (
fabs(tr.
T[4]) > 100.)
break;
338 for (
int ih = 0; ih < NHits; ih++) {
340 if (
h.iStation != ist)
continue;
341 CbmMuchHit* mh = (CbmMuchHit*)
fMuchHits->At(
h.index);
342 int ip = mh->GetRefIndex();
343 if (ip < 0)
continue;
345 if (p->GetTrackID() != mcTrackID)
continue;
347 double dx = tr.
T[0] -
h.FitPoint.x;
348 double dy = tr.
T[1] -
h.FitPoint.y;
349 double c0 = tr.
C[0] +
h.FitPoint.V[0];
350 double c1 = tr.
C[1] +
h.FitPoint.V[1];
351 double c2 = tr.
C[2] +
h.FitPoint.V[2];
352 double chi2 = 0.5 * (dx * dx * c0 - 2 * dx * dy * c1 + dy * dy * c2)
353 / (c0 * c2 - c1 * c1);
363 double sx =
sqrt(tt.
C[0]);
364 double sy =
sqrt(tt.
C[2]);
365 double stx =
sqrt(tt.
C[5]);
366 double sty =
sqrt(tt.
C[9]);
367 double sqp =
sqrt(tt.
C[14]);
368 double dx = (tt.
T[0] -
pos.X()) / sx;
369 double dy = (tt.
T[1] -
pos.Y()) / sy;
370 double dtx = (tt.
T[2] - mom.X() / mom.Z()) / stx;
371 double dty = (tt.
T[3] - mom.Y() / mom.Z()) / sty;
372 double dqp = (
fabs(tt.
T[4]) - 1. / mom.Mag()) / sqp;
380 double qp0 = tr.
T[4];
381 h.Filter(tr, 1, qp0);
407 if (EventCounter < 100 && EventCounter % 10 == 0
408 || EventCounter >= 100 && EventCounter % 100 == 0)
414 TFile HistoFile(
"MuRecQa.root",
"RECREATE");
420 if (!obj->IsFolder())
423 TDirectory* cur = gDirectory;
424 TDirectory* sub = cur->mkdir(obj->GetName());
426 TList* listSub = ((TDirectory*) obj)->GetList();
428 while (TObject* obj1 = it())