CbmRoot
Loading...
Searching...
No Matches
CbmLitFitQa.cxx
Go to the documentation of this file.
1/* Copyright (C) 2011-2020 GSI/JINR-LIT, Darmstadt/Dubna
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Andrey Lebedev [committer], Timur Ablyazimov */
4
10#include "CbmLitFitQa.h"
11
13#include "CbmEvent.h"
14#include "CbmGlobalTrack.h"
15#include "CbmHistManager.h"
16#include "CbmLitFitQaReport.h"
17#include "CbmMCDataArray.h"
18#include "CbmMCDataManager.h"
19#include "CbmMCTrack.h"
20#include "CbmMuchGeoScheme.h"
21#include "CbmMvdHit.h"
22#include "CbmStsAddress.h"
23#include "CbmStsHit.h"
24#include "CbmStsSetup.h"
25#include "CbmStsTrack.h"
26#include "CbmTrack.h"
27#include "CbmTrackMatchNew.h"
28#include "CbmTrdAddress.h"
29#include "TClonesArray.h"
30#include "TH1.h"
31#include "TH1F.h"
32#include "TH2F.h"
33
34#include <FairRootManager.h>
35
36#include <TFile.h>
37
38#include <boost/assign/list_of.hpp>
39
40#include <vector>
41using std::make_pair;
42using std::pair;
43using std::vector;
44
46 : fIsFixedBounds(true)
47 , fMvdMinNofHits(0)
48 , fStsMinNofHits(0)
49 , fTrdMinNofHits(0)
50 , fMuchMinNofHits(0)
51 , fOutputDir("./test/")
52 , fPRangeMin(0.)
53 , fPRangeMax(10.)
54 , fPRangeBins(20)
55 , fHM(NULL)
56 , fGlobalTracks(NULL)
57 , fStsTracks(NULL)
58 , fStsTrackMatches(NULL)
59 , fStsHits(NULL)
60 , fMvdHits(NULL)
61 , fTrdTracks(NULL)
62 , fTrdTrackMatches(NULL)
63 , fTrdHits(NULL)
64 , fMuchTracks(NULL)
65 , fMuchTrackMatches(NULL)
66 , fMuchPixelHits(NULL)
67 , fMuchStripHits(NULL)
68 , fMCTracks(NULL)
69 , fEvents(NULL)
70 , fQuota(0.7)
71 , fPrimVertex(NULL)
72 , fKFFitter()
73 , fMCTrackCreator(NULL)
74 , fDet()
75{
76}
77
79{
80 if (fHM) delete fHM;
81}
82
93
94void CbmLitFitQa::Exec(Option_t*)
95{
96 static Int_t nofEvents = 0;
97 nofEvents++;
98 std::cout << "CbmLitFitQa::Exec: event=" << nofEvents << std::endl;
99 fMCTrackCreator->Create(nofEvents - 1);
103}
104
106{
107 TDirectory* oldir = gDirectory;
108 TFile* outFile = FairRootManager::Instance()->GetOutFile();
109 if (outFile != NULL) {
110 outFile->cd();
111 fHM->WriteToFile();
112 }
113 gDirectory->cd(oldir->GetPath());
114
115 fHM->ShrinkEmptyBinsH1ByPattern("htf_.+_WrongCov_.+");
117 report->Create(fHM, fOutputDir);
118 delete report;
119}
120
122{
123 FairRootManager* ioman = FairRootManager::Instance();
124 assert(ioman != NULL);
125
126 fGlobalTracks = (TClonesArray*) ioman->GetObject("GlobalTrack");
127 fStsTracks = (TClonesArray*) ioman->GetObject("StsTrack");
128 fStsTrackMatches = (TClonesArray*) ioman->GetObject("StsTrackMatch");
129 fStsHits = (TClonesArray*) ioman->GetObject("StsHit");
130 fMvdHits = (TClonesArray*) ioman->GetObject("MvdHit");
131 fMuchTracks = (TClonesArray*) ioman->GetObject("MuchTrack");
132 fMuchTrackMatches = (TClonesArray*) ioman->GetObject("MuchTrackMatch");
133 fMuchPixelHits = (TClonesArray*) ioman->GetObject("MuchPixelHit");
134 fMuchStripHits = (TClonesArray*) ioman->GetObject("MuchStripHit");
135 fTrdTracks = (TClonesArray*) ioman->GetObject("TrdTrack");
136 fTrdTrackMatches = (TClonesArray*) ioman->GetObject("TrdTrackMatch");
137 fTrdHits = (TClonesArray*) ioman->GetObject("TrdHit");
138
139 CbmMCDataManager* mcManager = (CbmMCDataManager*) ioman->GetObject("MCDataManager");
140
141 if (0 == mcManager) LOG(fatal) << "CbmMatchRecoToMC::ReadAndCreateDataBranches() NULL MCDataManager.";
142
143 fMCTracks = mcManager->InitBranch("MCTrack");
144 fEvents = dynamic_cast<TClonesArray*>(ioman->GetObject("CbmEvent"));
145 // fPrimVertex = (CbmVertex*) ioman->GetObject("PrimaryVertex");
146 // Get pointer to PrimaryVertex object from IOManager if it exists
147 // The old name for the object is "PrimaryVertex" the new one
148 // "PrimaryVertex." Check first for the new name
149 fPrimVertex = dynamic_cast<CbmVertex*>(ioman->GetObject("PrimaryVertex."));
150 if (nullptr == fPrimVertex) {
151 fPrimVertex = dynamic_cast<CbmVertex*>(ioman->GetObject("PrimaryVertex"));
152 }
153 if (nullptr == fPrimVertex) {
154 // LOG(fatal) << "No primary vertex";
155 }
156}
157
159{
160 Int_t nofGlobalTracks = fGlobalTracks->GetEntriesFast();
161 for (Int_t iTrack = 0; iTrack < nofGlobalTracks; iTrack++) {
162 const CbmGlobalTrack* globalTrack = static_cast<const CbmGlobalTrack*>(fGlobalTracks->At(iTrack));
163 ProcessStsTrack(globalTrack->GetStsTrackIndex());
164 ProcessTrdTrack(globalTrack->GetTrdTrackIndex());
165 ProcessMuchTrack(globalTrack->GetMuchTrackIndex());
166 }
167}
168
170{
171 if (NULL == fStsTracks || NULL == fStsTrackMatches || trackId < 0) return;
172
173 CbmTrackMatchNew* match = static_cast<CbmTrackMatchNew*>(fStsTrackMatches->At(trackId));
174 if (match->GetNofLinks() < 1) return;
175 Int_t mcId = match->GetMatchedLink().GetIndex();
176 Int_t mcEventId = match->GetMatchedLink().GetEntry();
177 if (mcId < 0) return; // Ghost or fake track
178
179 // Check correctness of reconstructed track
180 if (match->GetTrueOverAllHitsRatio() < fQuota) return;
181
182 CbmStsTrack* track = static_cast<CbmStsTrack*>(fStsTracks->At(trackId));
183 Int_t nofStsHits = track->GetNofStsHits();
184 Int_t nofMvdHits = track->GetNofMvdHits();
185 if (nofStsHits < 1) return; // No hits in STS
186 if (nofMvdHits < fMvdMinNofHits || nofStsHits + nofMvdHits < fStsMinNofHits)
187 return; // cut on number of hits in track
188
189 const CbmLitMCTrack& mcTrack = fMCTrackCreator->GetTrack(mcEventId, mcId);
190
191 const FairTrackParam* firstParam = track->GetParamFirst();
192 const FairTrackParam* lastParam = track->GetParamLast();
193
194 FillTrackParamHistogramm("htp_Sts_FirstParam", firstParam);
195 FillTrackParamHistogramm("htp_Sts_LastParam", lastParam);
196
197 // Fill histograms for first track parameters
198 if (nofMvdHits > 0) { // first track parameters in MVD
199 const CbmMvdHit* firstHit = static_cast<const CbmMvdHit*>(fMvdHits->At(track->GetMvdHitIndex(0)));
200 Int_t firstStation = firstHit->GetStationNr() - 1; // to start with 0
201 if (mcTrack.GetNofPointsAtStation(ECbmModuleId::kMvd, firstStation) > 0) {
202 const CbmLitMCPoint& firstPoint = mcTrack.GetPointAtStation(ECbmModuleId::kMvd, firstStation, 0);
203 FillResidualsAndPulls(firstParam, &firstPoint, "htf_Sts_FirstParam_", nofMvdHits + nofStsHits,
205 }
206 }
207 else { // first track parameters in STS
208 const CbmStsHit* firstHit = static_cast<const CbmStsHit*>(fStsHits->At(track->GetStsHitIndex(0)));
209 Int_t firstStation = CbmStsSetup::Instance()->GetStationNumber(firstHit->GetAddress())
210 - 1; //firstHit->GetStationNr() - 1; // to start with 0
211 if (mcTrack.GetNofPointsAtStation(ECbmModuleId::kSts, firstStation) > 0) {
212 const CbmLitMCPoint& firstPoint = mcTrack.GetPointAtStation(ECbmModuleId::kSts, firstStation, 0);
213 FillResidualsAndPulls(firstParam, &firstPoint, "htf_Sts_FirstParam_", nofMvdHits + nofStsHits,
215 }
216 }
217
218 // Fill histograms for last track parameters
219 const CbmStsHit* lastHit = static_cast<const CbmStsHit*>(fStsHits->At(track->GetStsHitIndex(nofStsHits - 1)));
220 Int_t lastStation = CbmStsSetup::Instance()->GetStationNumber(lastHit->GetAddress())
221 - 1; //lastHit->GetStationNr() - 1; // to start with 0
222 if (mcTrack.GetNofPointsAtStation(ECbmModuleId::kSts, lastStation) > 0) {
223 const CbmLitMCPoint& lastPoint = mcTrack.GetPointAtStation(ECbmModuleId::kSts, lastStation, 0);
224 FillResidualsAndPulls(lastParam, &lastPoint, "htf_Sts_LastParam_", nofMvdHits + nofStsHits, ECbmModuleId::kSts);
225 }
226}
227
229{
230 if (NULL == fTrdTracks || NULL == fTrdTrackMatches || trackId < 0) return;
231
232 CbmTrackMatchNew* match = static_cast<CbmTrackMatchNew*>(fTrdTrackMatches->At(trackId));
233 Int_t mcId = match->GetMatchedLink().GetIndex();
234 Int_t mcEntryId = match->GetMatchedLink().GetEntry();
235 if (mcId < 0) return; // Ghost or fake track
236
237 // Check correctness of reconstructed track
238 if (match->GetTrueOverAllHitsRatio() < fQuota) return;
239
240 CbmTrack* track = static_cast<CbmTrack*>(fTrdTracks->At(trackId));
241 Int_t nofHits = track->GetNofHits();
242 if (nofHits < 1) return; // No hits
243 if (nofHits < fTrdMinNofHits) return; // cut on number of hits in track
244
245 const CbmLitMCTrack& mcTrack = fMCTrackCreator->GetTrack(mcEntryId, mcId);
246
247 const FairTrackParam* firstParam = track->GetParamFirst();
248 const FairTrackParam* lastParam = track->GetParamLast();
249
250 FillTrackParamHistogramm("htp_Trd_FirstParam", firstParam);
251 FillTrackParamHistogramm("htp_Trd_LastParam", lastParam);
252
253 // Fill histograms for first track parameters
254 const CbmHit* firstHit = static_cast<const CbmHit*>(fTrdHits->At(track->GetHitIndex(0)));
255 //Int_t firstStation = 10 * CbmTrdAddress::GetStationNr(firstHit->GetAddress()) + CbmTrdAddress::GetLayerNr(firstHit->GetAddress());
256 Int_t firstStation = CbmTrdAddress::GetLayerId(firstHit->GetAddress());
257 if (mcTrack.GetNofPointsAtStation(ECbmModuleId::kTrd, firstStation) > 0) {
258 const CbmLitMCPoint& firstPoint = mcTrack.GetPointAtStation(ECbmModuleId::kTrd, firstStation, 0);
259 FillResidualsAndPulls(firstParam, &firstPoint, "htf_Trd_FirstParam_", nofHits, ECbmModuleId::kTrd);
260 }
261
262 // Fill histograms for last track parameters
263 const CbmHit* lastHit = static_cast<const CbmHit*>(fTrdHits->At(track->GetHitIndex(nofHits - 1)));
264 //Int_t lastStation = 10 * CbmTrdAddress::GetStationNr(lastHit->GetAddress()) + CbmTrdAddress::GetLayerNr(lastHit->GetAddress());
265 Int_t lastStation = CbmTrdAddress::GetLayerId(lastHit->GetAddress());
266 if (mcTrack.GetNofPointsAtStation(ECbmModuleId::kTrd, lastStation) > 0) {
267 const CbmLitMCPoint& lastPoint = mcTrack.GetPointAtStation(ECbmModuleId::kTrd, lastStation, 0);
268 FillResidualsAndPulls(lastParam, &lastPoint, "htf_Trd_LastParam_", nofHits, ECbmModuleId::kTrd);
269 }
270}
271
273{
274 if (NULL == fMuchTracks || NULL == fMuchTrackMatches || trackId < 0) return;
275
276 const CbmTrackMatchNew* match = static_cast<const CbmTrackMatchNew*>(fMuchTrackMatches->At(trackId));
277 Int_t mcId = match->GetMatchedLink().GetIndex();
278 Int_t mcEventId = match->GetMatchedLink().GetEntry();
279 if (mcId < 0) return; // Ghost or fake track
280
281 // Check correctness of reconstructed track
282 if (match->GetTrueOverAllHitsRatio() < fQuota) return;
283
284 CbmTrack* track = static_cast<CbmTrack*>(fMuchTracks->At(trackId));
285 Int_t nofHits = track->GetNofHits();
286 if (nofHits < 1) return; // No hits
287 if (nofHits < fMuchMinNofHits) return; // cut on number of hits in track
288
289 const CbmLitMCTrack& mcTrack = fMCTrackCreator->GetTrack(mcEventId, mcId);
290
291 const FairTrackParam* firstParam = track->GetParamFirst();
292 const FairTrackParam* lastParam = track->GetParamLast();
293
294 FillTrackParamHistogramm("htp_Much_FirstParam", firstParam);
295 FillTrackParamHistogramm("htp_Much_LastParam", lastParam);
296
297 // Fill histograms for first track parameters
298 const CbmHit* firstHit = static_cast<const CbmHit*>(fMuchPixelHits->At(track->GetHitIndex(0)));
299 // Int_t firstStation = firstHit->GetPlaneId();
300 Int_t firstStation = 100 * CbmMuchGeoScheme::GetStationIndex(firstHit->GetAddress())
303 if (mcTrack.GetNofPointsAtStation(ECbmModuleId::kMuch, firstStation) > 0) {
304 const CbmLitMCPoint& firstPoint = mcTrack.GetPointAtStation(ECbmModuleId::kMuch, firstStation, 0);
305 FillResidualsAndPulls(firstParam, &firstPoint, "htf_Much_FirstParam_", nofHits, ECbmModuleId::kMuch);
306 }
307
308 // Fill histograms for last track parameters
309 const CbmHit* lastHit = static_cast<const CbmHit*>(fMuchPixelHits->At(track->GetHitIndex(nofHits - 1)));
310 // Int_t lastStation = lastHit->GetPlaneId();
311 Int_t lastStation = 100 * CbmMuchGeoScheme::GetStationIndex(lastHit->GetAddress())
314 if (mcTrack.GetNofPointsAtStation(ECbmModuleId::kMuch, lastStation) > 0) {
315 const CbmLitMCPoint& lastPoint = mcTrack.GetPointAtStation(ECbmModuleId::kMuch, lastStation, 0);
316 FillResidualsAndPulls(lastParam, &lastPoint, "htf_Much_LastParam_", nofHits, ECbmModuleId::kMuch);
317 }
318}
319
320void CbmLitFitQa::FillResidualsAndPulls(const FairTrackParam* par, const CbmLitMCPoint* mcPoint, const string& histName,
321 Float_t wrongPar, ECbmModuleId detId)
322{
323 // Residuals
324 Double_t resX = 0., resY = 0., resTx = 0., resTy = 0., resQp = 0.;
325 if (detId == ECbmModuleId::kMvd) { // Use MC average for MVD
326 resX = par->GetX() - mcPoint->GetX();
327 resY = par->GetY() - mcPoint->GetY();
328 resTx = par->GetTx() - mcPoint->GetTx();
329 resTy = par->GetTy() - mcPoint->GetTy();
330 resQp = par->GetQp() - mcPoint->GetQp();
331 }
332 else if (detId == ECbmModuleId::kSts) { // Use MC average for STS
333 resX = par->GetX() - mcPoint->GetX();
334 resY = par->GetY() - mcPoint->GetY();
335 resTx = par->GetTx() - mcPoint->GetTx();
336 resTy = par->GetTy() - mcPoint->GetTy();
337 resQp = par->GetQp() - mcPoint->GetQp();
338 }
339 else if (detId == ECbmModuleId::kTrd) { // Use MC out for TRD
340 resX = par->GetX() - mcPoint->GetXOut();
341 resY = par->GetY() - mcPoint->GetYOut();
342 resTx = par->GetTx() - mcPoint->GetTxOut();
343 resTy = par->GetTy() - mcPoint->GetTyOut();
344 resQp = par->GetQp() - mcPoint->GetQpOut();
345 }
346 else if (detId == ECbmModuleId::kMuch) { // Use MC average for MUCH
347 resX = par->GetX() - mcPoint->GetX();
348 resY = par->GetY() - mcPoint->GetY();
349 resTx = par->GetTx() - mcPoint->GetTx();
350 resTy = par->GetTy() - mcPoint->GetTy();
351 resQp = par->GetQp() - mcPoint->GetQp();
352 }
353 Double_t mcP = mcPoint->GetP();
354
355 fHM->H2(histName + "Res_X")->Fill(mcP, resX);
356 fHM->H2(histName + "Res_Y")->Fill(mcP, resY);
357 fHM->H2(histName + "Res_Tx")->Fill(mcP, resTx);
358 fHM->H2(histName + "Res_Ty")->Fill(mcP, resTy);
359 fHM->H2(histName + "Res_Qp")->Fill(mcP, resQp);
360
361 // Pulls
362 Double_t C[15];
363 par->CovMatrix(C);
364
365 Double_t sigmaX = (C[0] > 0.) ? std::sqrt(C[0]) : -1.;
366 Double_t sigmaY = (C[5] > 0.) ? std::sqrt(C[5]) : -1.;
367 Double_t sigmaTx = (C[9] > 0.) ? std::sqrt(C[9]) : -1.;
368 Double_t sigmaTy = (C[12] > 0.) ? std::sqrt(C[12]) : -1.;
369 Double_t sigmaQp = (C[14] > 0.) ? std::sqrt(C[14]) : -1.;
370 if (sigmaX < 0)
371 fHM->H2(histName + "WrongCov_X")->Fill(mcP, wrongPar);
372 else
373 fHM->H2(histName + "Pull_X")->Fill(mcP, resX / sigmaX);
374 if (sigmaY < 0)
375 fHM->H2(histName + "WrongCov_Y")->Fill(mcP, wrongPar);
376 else
377 fHM->H2(histName + "Pull_Y")->Fill(mcP, resY / sigmaY);
378 if (sigmaTx < 0)
379 fHM->H2(histName + "WrongCov_Tx")->Fill(mcP, wrongPar);
380 else
381 fHM->H2(histName + "Pull_Tx")->Fill(mcP, resTx / sigmaTx);
382 if (sigmaTy < 0)
383 fHM->H2(histName + "WrongCov_Ty")->Fill(mcP, wrongPar);
384 else
385 fHM->H2(histName + "Pull_Ty")->Fill(mcP, resTy / sigmaTy);
386 if (sigmaQp < 0)
387 fHM->H2(histName + "WrongCov_Qp")->Fill(mcP, wrongPar);
388 else
389 fHM->H2(histName + "Pull_Qp")->Fill(mcP, resQp / sigmaQp);
390}
391
392void CbmLitFitQa::FillTrackParamHistogramm(const string& histName, const FairTrackParam* par)
393{
394 fHM->H1(histName + "_X")->Fill(par->GetX());
395 fHM->H1(histName + "_Y")->Fill(par->GetY());
396 fHM->H1(histName + "_Z")->Fill(par->GetZ());
397 fHM->H1(histName + "_Tx")->Fill(par->GetTx());
398 fHM->H1(histName + "_Ty")->Fill(par->GetTy());
399 fHM->H1(histName + "_Qp")->Fill(par->GetQp());
400 Double_t p = (par->GetQp() != 0) ? std::fabs(1. / par->GetQp()) : 0.;
401 fHM->H1(histName + "_p")->Fill(p);
402 TVector3 mom;
403 par->Momentum(mom);
404 Double_t pt = std::sqrt(mom.X() * mom.X() + mom.Y() * mom.Y());
405 fHM->H1(histName + "_pt")->Fill(pt);
406}
407
409{
410 if (fEvents) {
411 Int_t nofEvents = fEvents->GetEntriesFast();
412
413 for (int i = 0; i < nofEvents; ++i)
414 ProcessTrackParamsAtVertex(static_cast<CbmEvent*>(fEvents->At(i)));
415 }
416 else
418}
419
421{
422 Int_t nofTracks = event ? event->GetNofData(ECbmDataType::kStsTrack) : fStsTracks->GetEntriesFast();
423
424 for (Int_t i = 0; i < nofTracks; ++i) {
425 Int_t iTrack = event ? event->GetIndex(ECbmDataType::kStsTrack, i) : i;
426 CbmStsTrack* track = static_cast<CbmStsTrack*>(fStsTracks->At(iTrack));
427
428 CbmTrackMatchNew* match = static_cast<CbmTrackMatchNew*>(fStsTrackMatches->At(iTrack));
429 if (match->GetNofLinks() < 1) continue;
430 Int_t mcId = match->GetMatchedLink().GetIndex();
431 Int_t mcEventId = match->GetMatchedLink().GetEntry();
432 if (mcId < 0) continue; // Ghost or fake track
433
434 const CbmMCTrack* mcTrack = static_cast<const CbmMCTrack*>(fMCTracks->Get(0, mcEventId, mcId));
435 if (mcTrack->GetMotherId() != -1) continue; // only for primaries
436 //if (mcTrack->GetP() < 1.) continue; // only for momentum large 1 GeV/c
437
438 // Check correctness of reconstructed track
439 if (match->GetTrueOverAllHitsRatio() < fQuota) continue;
440
441 CbmVertex* primVertex = event ? event->GetVertex() : fPrimVertex;
442 fKFFitter.DoFit(track, 211);
443 Double_t chiPrimary = fKFFitter.GetChiToVertex(track, primVertex);
444 fHM->H1("htf_ChiPrimary")->Fill(chiPrimary);
445
446 FairTrackParam vtxTrack;
447 fKFFitter.FitToVertex(track, primVertex, &vtxTrack);
448
449 TVector3 momMC, momRec;
450 mcTrack->GetMomentum(momMC);
451 vtxTrack.Momentum(momRec);
452
453 Double_t dpp = 100. * (momMC.Mag() - momRec.Mag()) / momMC.Mag();
454 fHM->H1("htf_MomRes_Mom")->Fill(momMC.Mag(), dpp);
455 }
456}
457
459{
460 Int_t nofTracks = fGlobalTracks->GetEntriesFast();
461
462 for (int i = 0; i < nofTracks; ++i) {
463 CbmGlobalTrack* globalTrack = static_cast<CbmGlobalTrack*>(fGlobalTracks->At(i));
464 Int_t stsId = globalTrack->GetStsTrackIndex();
465 //CbmStsTrack* stsTrack = static_cast<CbmStsTrack*>(fStsTracks->At(stsId));
466 CbmTrackMatchNew* match = static_cast<CbmTrackMatchNew*>(fStsTrackMatches->At(stsId));
467
468 if (match->GetNofLinks() < 1) continue;
469
470 Int_t mcId = match->GetMatchedLink().GetIndex();
471 Int_t mcEventId = match->GetMatchedLink().GetEntry();
472
473 if (mcId < 0) continue; // Ghost or fake track
474
475 const CbmMCTrack* mcTrack = static_cast<const CbmMCTrack*>(fMCTracks->Get(0, mcEventId, mcId));
476
477 if (mcTrack->GetMotherId() != -1) continue; // only for primaries
478
479 // Check correctness of reconstructed track
480 if (match->GetTrueOverAllHitsRatio() < fQuota) continue;
481
482 const CbmTrackParam* vtxParam = globalTrack->GetParamVertex();
483 TVector3 momMC;
484 mcTrack->GetMomentum(momMC);
485
486 fHM->H1("htp_PrimaryVertexResidualPx")->Fill(vtxParam->GetPx() - momMC.x());
487 fHM->H1("htp_PrimaryVertexResidualPy")->Fill(vtxParam->GetPy() - momMC.y());
488 fHM->H1("htp_PrimaryVertexResidualPz")->Fill(vtxParam->GetPz() - momMC.z());
489
490 fHM->H1("htp_PrimaryVertexPullPx")->Fill((vtxParam->GetPx() - momMC.x()) / vtxParam->GetDpx());
491 fHM->H1("htp_PrimaryVertexPullPy")->Fill((vtxParam->GetPy() - momMC.y()) / vtxParam->GetDpy());
492 fHM->H1("htp_PrimaryVertexPullPz")->Fill((vtxParam->GetPz() - momMC.z()) / vtxParam->GetDpz());
493
494 fHM->H1("htp_PrimaryVertexResidualTx")->Fill(vtxParam->GetTx() - mcTrack->GetPx() / mcTrack->GetPz());
495 fHM->H1("htp_PrimaryVertexResidualTy")->Fill(vtxParam->GetTy() - mcTrack->GetPy() / mcTrack->GetPz());
496 fHM->H1("htp_PrimaryVertexResidualQp")->Fill(vtxParam->GetQp() - 1 / mcTrack->GetP());
497
498 Double_t cov[15];
499 vtxParam->CovMatrix(cov);
500 fHM->H1("htp_PrimaryVertexPullTx")
501 ->Fill((vtxParam->GetTx() - mcTrack->GetPx() / mcTrack->GetPz()) / TMath::Sqrt(cov[9]));
502 fHM->H1("htp_PrimaryVertexPullTy")
503 ->Fill((vtxParam->GetTy() - mcTrack->GetPy() / mcTrack->GetPz()) / TMath::Sqrt(cov[12]));
504 fHM->H1("htp_PrimaryVertexPullQp")->Fill((vtxParam->GetQp() - 1 / mcTrack->GetP()) / TMath::Sqrt(cov[14]));
505 }
506}
507
509{
512
515
518
519 // Momentum resolution vs momwntum
520 fHM->Add("htf_MomRes_Mom", new TH2F("htf_MomRes_Mom", "htf_MomRes_Mom;P [GeV/c];dP/P [%]", fPRangeBins, fPRangeMin,
521 fPRangeMax, 100, -3., 3.));
522 fHM->Add("htf_ChiPrimary", new TH1F("htf_ChiPrimary", "htf_ChiPrimary;#chi_{primary}", 100, 0, 10));
523 fHM->Add("htp_PrimaryVertexResidualPx",
524 new TH1F("htp_PrimaryVertexResidualPx", "htp_PrimaryVertexResidualPx;[cm]", 200, -1., 1.));
525 fHM->Add("htp_PrimaryVertexResidualPy",
526 new TH1F("htp_PrimaryVertexResidualPy", "htp_PrimaryVertexResidualPy;[cm]", 200, -1., 1.));
527 fHM->Add("htp_PrimaryVertexResidualPz",
528 new TH1F("htp_PrimaryVertexResidualPz", "htp_PrimaryVertexResidualPz;[cm]", 200, -1., 1.));
529 fHM->Add("htp_PrimaryVertexPullPx",
530 new TH1F("htp_PrimaryVertexPullPx", "htp_PrimaryVertexPullPx;[cm]", 200, -5., 5.));
531 fHM->Add("htp_PrimaryVertexPullPy",
532 new TH1F("htp_PrimaryVertexPullPy", "htp_PrimaryVertexPullPy;[cm]", 200, -5., 5.));
533 fHM->Add("htp_PrimaryVertexPullPz",
534 new TH1F("htp_PrimaryVertexPullPz", "htp_PrimaryVertexPullPz;[cm]", 200, -5., 5.));
535
536 fHM->Add("htp_PrimaryVertexResidualTx",
537 new TH1F("htp_PrimaryVertexResidualTx", "htp_PrimaryVertexResidualTx;[cm]", 200, -1., 1.));
538 fHM->Add("htp_PrimaryVertexResidualTy",
539 new TH1F("htp_PrimaryVertexResidualTy", "htp_PrimaryVertexResidualTy;[cm]", 200, -1., 1.));
540 fHM->Add("htp_PrimaryVertexResidualQp",
541 new TH1F("htp_PrimaryVertexResidualQ[", "htp_PrimaryVertexResidualQp;[cm]", 200, -1., 1.));
542 fHM->Add("htp_PrimaryVertexPullTx",
543 new TH1F("htp_PrimaryVertexPullTx", "htp_PrimaryVertexPullTx;[cm]", 200, -5., 5.));
544 fHM->Add("htp_PrimaryVertexPullTy",
545 new TH1F("htp_PrimaryVertexPullTy", "htp_PrimaryVertexPullTy;[cm]", 200, -5., 5.));
546 fHM->Add("htp_PrimaryVertexPullQp",
547 new TH1F("htp_PrimaryVertexPullQp", "htp_PrimaryVertexPullQp;[cm]", 200, -5., 5.));
548}
549
551{
552 if (!fDet.GetDet(detId)) return;
553
554 // Parameter names of the state vector (x, y, tx, ty, q/p)
555 string parameterNames[] = {"X", "Y", "Tx", "Ty", "Qp"};
556
557 // Axis titles for residual, pull and wrong covariance histograms
558 string xTitles[] = {
559 "Residual X [cm]", "Residual Y [cm]", "Residual Tx", "Residual Ty", "Residual q/p [(GeV/c)^{-1}]",
560 "Pull X", "Pull Y", "Pull Tx", "Pull Ty", "Pull q/p",
561 "Number of hits", "Number of hits", "Number of hits", "Number of hits", "Number of hits"};
562
563 // Category names: Residual, Pull, Wrong Covariance
564 string catNames[] = {"Res", "Pull", "WrongCov"};
565
566 vector<Int_t> bins(15, 200);
567 vector<pair<Float_t, Float_t>> bounds;
568 if (fIsFixedBounds) {
569 vector<pair<Float_t, Float_t>> tmp = boost::assign::list_of(make_pair(-1., 1.)) // X residual
570 (make_pair(-1., 1.)) // Y residual
571 (make_pair(-.01, .01)) // Tx residual
572 (make_pair(-.01, .01)) // Ty residual
573 (make_pair(-.1, .1)) // Qp residual
574 (make_pair(-5., 5.)) // X pull
575 (make_pair(-5., 5.)) // Y pull
576 (make_pair(-5., 5.)) // Tx pull
577 (make_pair(-5., 5.)) // Ty pull
578 (make_pair(-7., 7.)) // Qp pull
579 (make_pair(0., 200.)) // X wrong covariance
580 (make_pair(0., 200.)) // Y wrong covariance
581 (make_pair(0., 200.)) // Tx wrong covariance
582 (make_pair(0., 200.)) // Ty wrong covariance
583 (make_pair(0., 200.)); // Qp wrong covariance
584 bounds = tmp;
585 }
586 else {
587 bounds.assign(15, make_pair(0., 0.));
588 }
589
590 Double_t momentumMin = 0.;
591 Double_t momentumMax = 10.;
592 Int_t nofMomentumBins = 20;
593 string momentumAxisTitle = "P [GeV/c]";
594
595 // [0] - for the first track parameter, [1] - for the last track parameter
596 for (Int_t i = 0; i < 2; i++) {
597 string trackParamName = (i == 0) ? "FirstParam" : "LastParam";
598 // [0] - "Res", [1] - "Pull", [2] - "WrongCov"
599 for (Int_t iCat = 0; iCat < 3; iCat++) {
600 for (Int_t iPar = 0; iPar < 5; iPar++) {
601 string histName = "htf_" + detName + "_" + trackParamName + "_" + catNames[iCat] + "_" + parameterNames[iPar];
602 Int_t histId = iCat * 5 + iPar;
603 fHM->Add(histName,
604 new TH2F(histName.c_str(),
605 string(histName + ";" + momentumAxisTitle + +";" + xTitles[histId] + ";Counter").c_str(),
606 nofMomentumBins, momentumMin, momentumMax, bins[histId], bounds[histId].first,
607 bounds[histId].second));
608 }
609 }
610 }
611}
612
614{
615 if (!fDet.GetDet(detId)) return;
616
617 // Parameter names of the state vector (x, y, tx, ty, q/p)
618 string parameterNames[] = {"X", "Y", "Z", "Tx", "Ty", "Qp", "p", "pt"};
619
620 // Axis titles for state vector Components
621 string xTitles[] = {"X [cm]", "Y [cm]", "Z [cm]", "Tx", "Ty", "q/p [(GeV/c)^{-1}]",
622 "Momentum [GeV/c]", "P_{t} [GeV/c]"};
623
624 vector<Int_t> bins(8, 200);
625 vector<pair<Float_t, Float_t>> bounds;
626 if (fIsFixedBounds) {
627 vector<pair<Float_t, Float_t>> tmp = boost::assign::list_of(make_pair(-500., 500.)) // X
628 (make_pair(-500., 500.)) // Y
629 (make_pair(-500., 500.)) // Z
630 (make_pair(-1., 1.)) // Tx
631 (make_pair(-1., 1.)) // Ty
632 (make_pair(-2., 2.)) // Qp
633 (make_pair(0., 25.)) // Momentum
634 (make_pair(0., 5.)); // Pt
635 bounds = tmp;
636 }
637 else {
638 bounds.assign(8, make_pair(0., 0.));
639 }
640
641 // [0] - for the first track parameter, [1] - for the last track parameter
642 for (Int_t i = 0; i < 2; i++) {
643 string trackParamName = (i == 0) ? "FirstParam" : "LastParam";
644 for (Int_t iPar = 0; iPar < 8; iPar++) {
645 string histName = "htp_" + detName + "_" + trackParamName + "_" + parameterNames[iPar];
646 fHM->Add(histName, new TH1F(histName.c_str(), string(histName + ";" + xTitles[iPar] + ";Counter").c_str(),
647 bins[iPar], bounds[iPar].first, bounds[iPar].second));
648 }
649 }
650}
ClassImp(CbmConverterManager)
ECbmModuleId
Definition CbmDefs.h:39
@ kMvd
Micro-Vertex Detector.
@ kTrd
Transition Radiation Detector.
@ kSts
Silicon Tracking System.
@ kMuch
Muon detection system.
Histogram manager.
Create report for fit QA.
Track fit QA for track reconstruction.
Creates CbmLitMCTrack objects.
Data class for a reconstructed hit in the STS.
Data class for STS tracks.
Helper class to convert unique channel ID back and forth.
Class characterising one event by a collection of links (indices) to data objects,...
Definition CbmEvent.h:34
int32_t GetStsTrackIndex() const
const CbmTrackParam * GetParamVertex() const
int32_t GetMuchTrackIndex() const
int32_t GetTrdTrackIndex() const
Histogram manager.
void ShrinkEmptyBinsH1ByPattern(const std::string &pattern)
Shrink empty bins in H1.
TH2 * H2(const std::string &name) const
Return pointer to TH2 histogram.
void WriteToFile()
Write all objects to current opened file.
void Add(const std::string &name, TNamed *object)
Add new named object to manager.
TH1 * H1(const std::string &name) const
Return pointer to TH1 histogram.
int32_t GetAddress() const
Definition CbmHit.h:74
void DetermineSetup()
Determines detector presence using TGeoManager.
bool GetDet(ECbmModuleId detId) const
Return detector presence in setup.
Create report for fit QA.
Track fit QA for track reconstruction.
Definition CbmLitFitQa.h:43
TClonesArray * fGlobalTracks
Int_t fTrdMinNofHits
CbmMCDataArray * fMCTracks
CbmVertex * fPrimVertex
TClonesArray * fStsTrackMatches
virtual ~CbmLitFitQa()
Destructor.
void ProcessTrackMomentumAtVertex()
void CreateHistograms()
TClonesArray * fTrdTrackMatches
CbmStsKFTrackFitter fKFFitter
Int_t fPRangeBins
TClonesArray * fMuchPixelHits
TClonesArray * fEvents
TClonesArray * fTrdTracks
Double_t fPRangeMax
Bool_t fIsFixedBounds
TClonesArray * fTrdHits
Double_t fPRangeMin
void ProcessTrackParamsAtVertex()
void ProcessStsTrack(Int_t trackId)
void ReadDataBranches()
Reads data branches.
TClonesArray * fMvdHits
void FillTrackParamHistogramm(const string &histName, const FairTrackParam *par)
TClonesArray * fStsTracks
Int_t fMvdMinNofHits
CbmLitDetectorSetup fDet
virtual InitStatus Init()
Inherited from FairTask.
void FillResidualsAndPulls(const FairTrackParam *par, const CbmLitMCPoint *mcPoint, const string &histName, Float_t wrongPar, ECbmModuleId detId)
virtual void Finish()
Inherited from FairTask.
Double_t fQuota
void CreateTrackParamHistograms(ECbmModuleId detId, const string &detName)
Int_t fMuchMinNofHits
TClonesArray * fMuchTrackMatches
CbmLitFitQa()
Constructor.
void ProcessGlobalTracks()
TClonesArray * fStsHits
Int_t fStsMinNofHits
string fOutputDir
CbmLitMCTrackCreator * fMCTrackCreator
TClonesArray * fMuchTracks
void CreateResidualAndPullHistograms(ECbmModuleId detId, const string &detName)
CbmHistManager * fHM
virtual void Exec(Option_t *opt)
Inherited from FairTask.
void ProcessMuchTrack(Int_t trackId)
TClonesArray * fMuchStripHits
void ProcessTrdTrack(Int_t trackId)
Monte-Carlo point.
Double_t GetY() const
Double_t GetXOut() const
Double_t GetTxOut() const
Double_t GetQpOut() const
Double_t GetYOut() const
Double_t GetTy() const
Double_t GetX() const
Double_t GetP() const
Double_t GetTyOut() const
Double_t GetQp() const
Double_t GetTx() const
void Create(Int_t eventNum)
Creates array of CbmLitMCTracks for current event.
static CbmLitMCTrackCreator * Instance()
Singleton instance.
const CbmLitMCTrack & GetTrack(int mcEventId, int mcId) const
Return CbmLitMCTrack by its index.
Monte-Carlo track.
UInt_t GetNofPointsAtStation(ECbmModuleId detId, Int_t stationId) const
Return number of MC points for specified detector ID and station ID.
const CbmLitMCPoint & GetPointAtStation(ECbmModuleId detId, Int_t stationId, Int_t index) const
Return MC point for specified detector id and point index.
TObject * Get(const CbmLink *lnk)
Task class creating and managing CbmMCDataArray objects.
CbmMCDataObject * GetObject(const char *name)
CbmMCDataArray * InitBranch(const char *name)
double GetPz() const
Definition CbmMCTrack.h:72
double GetP() const
Definition CbmMCTrack.h:98
double GetPx() const
Definition CbmMCTrack.h:70
void GetMomentum(TVector3 &momentum) const
Definition CbmMCTrack.h:170
int32_t GetMotherId() const
Definition CbmMCTrack.h:69
double GetPy() const
Definition CbmMCTrack.h:71
int32_t GetNofLinks() const
Definition CbmMatch.h:42
const CbmLink & GetMatchedLink() const
Definition CbmMatch.h:41
static Int_t GetLayerSideIndex(Int_t address)
static Int_t GetStationIndex(Int_t address)
static Int_t GetLayerIndex(Int_t address)
virtual int32_t GetStationNr() const
Definition CbmMvdHit.h:61
Base class for simulation reports.
void Create(CbmHistManager *histManager, const std::string &outputDir)
Main function which creates report data.
data class for a reconstructed 3-d hit in the STS
Definition CbmStsHit.h:35
Double_t FitToVertex(CbmStsTrack *track, CbmVertex *vtx, FairTrackParam *v_track)
Double_t GetChiToVertex(CbmStsTrack *track, CbmVertex *vtx=nullptr)
Int_t DoFit(CbmStsTrack *track, Int_t pidHypo=211)
static CbmStsSetup * Instance()
Int_t GetStationNumber(Int_t address)
int32_t GetNofMvdHits() const
Definition CbmStsTrack.h:87
int32_t GetMvdHitIndex(int32_t iHit) const
Definition CbmStsTrack.h:75
int32_t GetStsHitIndex(int32_t iHit) const
int32_t GetNofStsHits() const
Definition CbmStsTrack.h:93
double GetTrueOverAllHitsRatio() const
double GetDpy() const
double GetPz() const
double GetDpx() const
double GetPx() const
double GetPy() const
double GetDpz() const
const FairTrackParam * GetParamLast() const
Definition CbmTrack.h:69
virtual int32_t GetNofHits() const
Definition CbmTrack.h:58
const FairTrackParam * GetParamFirst() const
Definition CbmTrack.h:68
int32_t GetHitIndex(int32_t iHit) const
Definition CbmTrack.h:59
static uint32_t GetLayerId(uint32_t address)
Return layer ID from address.