CbmRoot
Loading...
Searching...
No Matches
CbmMuchHitFinderQa.cxx
Go to the documentation of this file.
1/* Copyright (C) 2007-2021 Facility for Antiproton and Ion Research in Europe, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Evgeny Kryshen, Dominik Smith [committer], Sergey Gorbunov */
4
5// -------------------------------------------------------------------------
6// ----- CbmMuchHitProducerQa source file -----
7// ----- Modified since 21/06/2019 by Ekata Nandy (ekata@vecc.gov.in) -Inclusion of RPC detector type
8// ----- Modified 02/18 by Vikas Singhal -----
9// ----- Created 16/11/07 by E. Kryshen -----
10// -------------------------------------------------------------------------
11// AUG 18 RELEASE VERSION
12
13#include "CbmMuchHitFinderQa.h"
14
15#include "CbmDefs.h"
16#include "CbmDigiManager.h"
17#include "CbmLink.h"
18#include "CbmMCDataArray.h"
19#include "CbmMCDataManager.h"
20#include "CbmMCTrack.h"
21#include "CbmMatch.h"
22#include "CbmMuchAddress.h"
23#include "CbmMuchCluster.h"
24#include "CbmMuchDigi.h"
25#include "CbmMuchGeoScheme.h"
26#include "CbmMuchModuleGem.h"
27#include "CbmMuchPixelHit.h"
28#include "CbmMuchPoint.h"
29#include "CbmQaCanvas.h"
30#include "CbmTimeSlice.h"
31#include "FairRootManager.h"
32#include "TArrayI.h"
33#include "TF1.h"
34#include "TFile.h"
35#include "TObjArray.h"
36#include "TParameter.h"
37#include "TPaveStats.h"
38#include "TStyle.h"
39
40#include <FairSink.h>
41#include <FairTask.h>
42#include <Logger.h>
43
44#include <TClonesArray.h>
45#include <TGenericClassInfo.h>
46#include <TH1.h>
47#include <TMathBase.h>
48#include <TString.h>
49
50#include <boost/exception/exception.hpp>
51#include <boost/type_index/type_index_facade.hpp>
52
53#include <algorithm>
54#include <iostream>
55#include <map>
56#include <vector>
57
58#include <stdio.h>
59
60using std::cout;
61using std::endl;
62using std::map;
63using std::vector;
64// -------------------------------------------------------------------------
65CbmMuchHitFinderQa::CbmMuchHitFinderQa(const char* name, Int_t verbose)
66 : FairTask(name, verbose)
67 , fGeoScheme(CbmMuchGeoScheme::Instance())
68 , fGeoFileName()
69 , fFileName()
70 , fVerbose(verbose)
71 , fOutFolder("MuchHitFinderQA", "MuchHitFinderQA")
72 , fhPointsInCluster()
73 , fhDigisInCluster()
74 , fhHitsPerCluster()
75 , fNevents("nEvents", 0)
76 , fSignalPoints("SignalPoints", 0)
77 , fSignalHits("SignalHits", 0)
78 , fPointsTotal("PointsTotal", 0)
79 , fPointsUnderCounted("PointsUnderCounted", 0)
80 , fPointsOverCounted("PointsOverCounted", 0)
81{
82}
83// -------------------------------------------------------------------------
84
85
86// -------------------------------------------------------------------------
88// -------------------------------------------------------------------------
89
90// -------------------------------------------------------------------------
92{
93 fPoints = nullptr;
94 fDigiManager = nullptr;
95 fClusters = nullptr;
96 fHits = nullptr;
97 fMCTracks = nullptr;
98 histFolder = nullptr;
99 fOutFolder.Clear();
100
101 SafeDelete(fhPullX);
102 SafeDelete(fhPullY);
103 SafeDelete(fhPullT);
104 SafeDelete(fhResidualX);
105 SafeDelete(fhResidualY);
106 SafeDelete(fhResidualT);
107
108 for (uint i = 0; i < fhPointsInCluster.size(); i++) {
109 SafeDelete(fhPointsInCluster[i]);
110 }
111 for (uint i = 0; i < fhDigisInCluster.size(); i++) {
112 SafeDelete(fhDigisInCluster[i]);
113 }
114 for (uint i = 0; i < fhHitsPerCluster.size(); i++) {
115 SafeDelete(fhHitsPerCluster[i]);
116 }
117 fhPointsInCluster.clear();
118 fhDigisInCluster.clear();
119 fhHitsPerCluster.clear();
120
121 SafeDelete(fCanvPointsInCluster);
122 SafeDelete(fCanvDigisInCluster);
123 SafeDelete(fCanvHitsPerCluster);
124 SafeDelete(fCanvPull);
125 SafeDelete(fCanvResidual);
126
127 fVerbose = 0;
128 fFlag = 0;
129 fNstations = 0;
130
131 fNevents.SetVal(0);
132 fSignalPoints.SetVal(0);
133 fSignalHits.SetVal(0);
134 fPointsTotal.SetVal(0);
135 fPointsUnderCounted.SetVal(0);
136 fPointsOverCounted.SetVal(0);
137}
138// -------------------------------------------------------------------------
139
140
141// -------------------------------------------------------------------------
143{
144
145 DeInit();
146
147 fManager = FairRootManager::Instance();
148 fMcManager = dynamic_cast<CbmMCDataManager*>(fManager->GetObject("MCDataManager"));
149
150 fTimeSlice = (CbmTimeSlice*) fManager->GetObject("TimeSlice.");
151
152 if (fMcManager) {
153 fMCTracks = fMcManager->InitBranch("MCTrack");
154 fPoints = fMcManager->InitBranch("MuchPoint");
155 }
156
157 fHits = (TClonesArray*) fManager->GetObject("MuchPixelHit");
158 fClusters = (TClonesArray*) fManager->GetObject("MuchCluster");
159 // Reading Much Digis from CbmMuchDigiManager which are stored as vector
161
163 TFile* oldFile = gFile;
164 TDirectory* oldDir = gDirectory;
165
166 TFile* f = new TFile(fGeoFileName, "R");
167 LOG_IF(fatal, !f) << "Could not open file " << fGeoFileName;
168
170 gFile = oldFile;
171 gDirectory = oldDir;
172
173 TObjArray* stations = f->Get<TObjArray>("stations");
174 LOG_IF(fatal, !stations) << "TObjArray stations not found in file " << fGeoFileName;
175 fGeoScheme->Init(stations, fFlag);
176
177 if (!fManager) {
178 LOG(fatal) << "Can not find FairRootManager";
179 return kFATAL;
180 }
181 if (!fDigiManager) {
182 LOG(fatal) << "Can not find Much digi manager";
183 return kFATAL;
184 }
185 if (!fGeoScheme) {
186 LOG(fatal) << "Can not find Much geo scheme";
187 return kFATAL;
188 }
189 if (!fMCTracks) {
190 LOG(error) << "No MC tracks found";
191 return kERROR;
192 }
193 if (!fPoints) {
194 LOG(error) << "No MC points found";
195 return kERROR;
196 }
197 if (!fHits) {
198 LOG(error) << "No hits found";
199 return kERROR;
200 }
201 if (!fClusters) {
202 LOG(error) << "No hits found";
203 return kERROR;
204 }
205 histFolder = fOutFolder.AddFolder("hist", "Histogramms");
206
207 fNevents.SetVal(0);
208 fSignalPoints.SetVal(0);
209 fSignalHits.SetVal(0);
210 fPointsTotal.SetVal(0);
211 fPointsUnderCounted.SetVal(0);
212 fPointsOverCounted.SetVal(0);
213
214 histFolder->Add(&fNevents);
216 histFolder->Add(&fSignalHits);
220
223 LOG(debug) << "Init(): fNstations = " << fNstations;
224
228
229 for (Int_t i = 0; i < fNstations; i++) {
230
232 new TH1I(Form("hMCPointsInCluster%i", i + 1), Form("MC Points in Cluster : Station %i ", i + 1), 10, 0, 10);
234 new TH1I(Form("hDigisInCluster%i", i + 1), Form("Digis in Cluster : Station %i ", i + 1), 10, 0, 10);
236 new TH1I(Form("hHitsPerCluster%i", i + 1), Form("Hits per Cluster : Station %i ", i + 1), 10, 0, 10);
240 }
241 gStyle->SetOptStat(1);
242
243 //Pull Distribution
244 fhPullX = new TH1D("hPullX", "Pull distribution X;(x_{RC} - x_{MC}) / dx_{RC}", 500, -5, 5);
245 fhPullY = new TH1D("hPullY", "Pull distribution Y;(y_{RC} - y_{MC}) / dy_{RC}", 500, -5, 5);
246 fhPullT = new TH1D("hPullT", "Pull distribution T;(t_{RC} - t_{MC}) / dt_{RC}", 120, -5, 5);
247
248 //Residual Distribution
249 fhResidualX = new TH1D("hResidualX", "Residual distribution X;(x_{RC} - x_{MC})(cm)", 500, -3, 3);
250 fhResidualY = new TH1D("hResidualY", "Residual distribution Y;(y_{RC} - y_{MC})(cm)", 500, -3, 3);
251 fhResidualT = new TH1D("hResidualT", "Residual distribution T;(t_{RC} - t_{MC})(ns)", 140, -17, 17);
252
253 histFolder->Add(fhPullX);
254 histFolder->Add(fhPullY);
255 histFolder->Add(fhPullT);
259
260 fCanvPointsInCluster = new CbmQaCanvas("cMCPointsInCluster", "MC Points In Cluster", 2 * 400, 2 * 400);
262
263 fCanvDigisInCluster = new CbmQaCanvas("cDigisInCluster", "Digis In Cluster", 2 * 400, 2 * 400);
265
266 fCanvHitsPerCluster = new CbmQaCanvas("cHitsPerCluster", "Hits Per Cluster", 2 * 400, 2 * 400);
268
269 fCanvPull = new CbmQaCanvas("cPull", "Pull Distribution", 3 * 600, 1 * 400);
271
272 fCanvResidual = new CbmQaCanvas("cResidual", "Residual Distribution", 3 * 600, 1 * 400);
274
280
281 return kSUCCESS;
282}
283// -------------------------------------------------------------------------
284
285
286// -------------------------------------------------------------------------
288{
289 // Get run and runtime database
290 // FairRuntimeDb* db = FairRuntimeDb::instance();
291 // if ( ! db ) Fatal("SetParContainers", "No runtime database");
292 // Get MUCH geometry parameter container
293 // fGeoPar = (CbmGeoMuchPar*) db->getContainer("CbmGeoMuchPar");
294}
295// -------------------------------------------------------------------------
296
297
298// -------------------------------------------------------------------------x
300{
301 fNevents.SetVal(fNevents.GetVal() + 1);
302 LOG(debug) << "Event: " << fNevents.GetVal();
303
304 PullsQa();
305 StatisticsQa();
307}
308// -------------------------------------------------------------------------
309
310
311// -------------------------------------------------------------------------
313{
314
315 if (fVerbose > 0) {
316 printf(" CbmMuchHitFinderQa FinishTask\n");
317 }
318
319 gStyle->SetPaperSize(20, 20);
320
321 for (Int_t i = 0; i < fNstations; i++) {
322 fhPointsInCluster[i]->Scale(1. / fNevents.GetVal());
323 fhDigisInCluster[i]->Scale(1. / fNevents.GetVal());
324 fhHitsPerCluster[i]->Scale(1. / fNevents.GetVal());
325 }
326
327 std::vector<TH1D*> vResHistos;
328 vResHistos.push_back(fhPullX);
329 vResHistos.push_back(fhPullY);
330 vResHistos.push_back(fhPullT);
331 vResHistos.push_back(fhResidualX);
332 vResHistos.push_back(fhResidualY);
333 vResHistos.push_back(fhResidualT);
334
335 for (UInt_t i = 0; i < vResHistos.size(); i++) {
336 TH1D* histo = vResHistos[i];
337 histo->Sumw2();
338 if (histo->GetRMS() > 0.) {
339 histo->Fit("gaus", "Q");
340 auto f = histo->GetFunction("gaus");
341 if (f) {
342 f->SetLineWidth(3);
343 f->SetLineColor(kRed);
344 }
345 }
346 // histo->SetStats(kTRUE);
347 }
348
349 if (fVerbose > 0) {
350 printf("===================================\n");
351 printf("StatisticsQa:\n");
352 printf("Total number of points: %i\n", fPointsTotal.GetVal());
353 printf("Points overcounted: %i\n", fPointsOverCounted.GetVal());
354 printf("Points undercounted: %i\n", fPointsUnderCounted.GetVal());
355 printf("Signal points: %i\n", fSignalPoints.GetVal());
356 printf("Signal hits: %i\n", fSignalHits.GetVal());
357 }
358
359 DrawCanvases();
360
361 FairSink* sink = FairRootManager::Instance()->GetSink();
362 sink->WriteObject(&fOutFolder, nullptr);
363}
364// -------------------------------------------------------------------------
365
366
367// -------------------------------------------------------------------------
369{
370 for (Int_t i = 0; i < fNstations; i++) {
371 fCanvPointsInCluster->cd(i + 1);
372 fhPointsInCluster[i]->DrawCopy("", "");
373
374 fCanvDigisInCluster->cd(i + 1);
375 fhDigisInCluster[i]->DrawCopy("", "");
376
377 fCanvHitsPerCluster->cd(i + 1);
378 fhHitsPerCluster[i]->DrawCopy("", "");
379 }
380
381 std::vector<TH1D*> vPullHistos;
382 vPullHistos.push_back(fhPullX);
383 vPullHistos.push_back(fhPullY);
384 vPullHistos.push_back(fhPullT);
385
386 for (UInt_t i = 0; i < vPullHistos.size(); i++) {
387 TH1D* histo = vPullHistos[i];
388 fCanvPull->cd(i + 1);
389 histo->Draw(); //necessary to create stats pointer
390 fCanvPull->Update();
391 TPaveStats* st = (TPaveStats*) histo->FindObject("stats");
392 if (st) {
393 st->SetX1NDC(0.621);
394 st->SetX2NDC(0.940);
395 st->SetY1NDC(0.657);
396 st->SetY2NDC(0.929);
397 st->SetOptStat(1110);
398 st->SetOptFit(11);
399 //st->SetTextSize(0.04);
400 }
401 histo->DrawCopy("", "");
402 //version below only changes canvas but not hist folder
403 //TH1* hClone = histo->DrawCopy("", "");
404 //fCanvPull->Update();
405 //TPaveStats *st = (TPaveStats*)hClone->FindObject("stats");
406 //st->SetOptStat(1110);
407 //st->SetOptFit(11);
408 }
409
410 std::vector<TH1D*> vResHistos;
411 vResHistos.push_back(fhResidualX);
412 vResHistos.push_back(fhResidualY);
413 vResHistos.push_back(fhResidualT);
414
415 for (UInt_t i = 0; i < vResHistos.size(); i++) {
416 TH1D* histo = vResHistos[i];
417 fCanvResidual->cd(i + 1);
418 histo->Draw(); //necessary to create stats pointer
419 fCanvResidual->Update();
420 TPaveStats* st = (TPaveStats*) histo->FindObject("stats");
421 if (st) {
422 st->SetX1NDC(0.621);
423 st->SetX2NDC(0.940);
424 st->SetY1NDC(0.657);
425 st->SetY2NDC(0.929);
426 st->SetOptStat(1110);
427 st->SetOptFit(11);
428 //st->SetTextSize(0.04);
429 }
430 histo->DrawCopy("", "");
431 }
432}
433// -------------------------------------------------------------------------
434
435
436// -------------------------------------------------------------------------
438{
439 // Bool_t verbose = (fVerbose>2);
440 Int_t nClusters = fClusters->GetEntriesFast();
441 TArrayI hitsInCluster;
442 TArrayI pointsInCluster;
443 hitsInCluster.Set(nClusters);
444 pointsInCluster.Set(nClusters);
445 LOG(debug) << " start Stat QA ";
446 for (Int_t i = 0; i < nClusters; i++)
447 hitsInCluster[i] = 0;
448 for (Int_t i = 0; i < nClusters; i++)
449 pointsInCluster[i] = 0;
450
451 for (Int_t i = 0; i < fHits->GetEntriesFast(); i++) {
452 CbmMuchPixelHit* hit = (CbmMuchPixelHit*) fHits->At(i);
453 //cout<<" hit index "<<i<<" plane id "<<hit->GetPlaneId()<<" x "<<hit->GetX()<<" y "<<hit->GetY()<<" z "<<hit->GetZ()<<" cluster Id "<< hit->GetRefId()<<endl;
454
455 // cout<<" hit index "<<i<<" plane id "<<hit->GetPlaneId()<<endl;
456 Int_t clusterId = hit->GetRefId();
457 hitsInCluster[clusterId]++;
458 }
459
460 for (Int_t i = 0; i < nClusters; i++) {
461 CbmMuchCluster* cluster = (CbmMuchCluster*) fClusters->At(i);
462
463 map<Int_t, Int_t> map_points;
464 Int_t nDigis = cluster->GetNofDigis();
465
466 auto address = cluster->GetAddress();
467 auto StationIndex = CbmMuchAddress::GetStationIndex(address);
468 //cout<<" station index "<<StationIndex<<endl;
469
470 fhDigisInCluster[StationIndex]->Fill(nDigis);
471
473 for (Int_t digiId = 0; digiId < nDigis; digiId++) {
474 Int_t index = cluster->GetDigi(digiId);
475 //Access Match from CbmDigi only
477 if (!match) {
478 LOG(fatal) << "CbmMuchHitFinderQa::StatisticsQa(): Match should be "
479 "present but is null.";
480 return;
481 }
482 Int_t nPoints = match->GetNofLinks();
483 for (Int_t iRefPoint = 0; iRefPoint < nPoints; iRefPoint++) {
484 Int_t pointId = match->GetLink(iRefPoint).GetIndex();
485 map_points[pointId] = 1;
486 }
487 }
488 }
489 pointsInCluster[i] = map_points.size();
490 map_points.clear();
491 }
492
493 for (Int_t i = 0; i < nClusters; i++) {
494 // added
495 CbmMuchCluster* cluster = (CbmMuchCluster*) fClusters->At(i);
496 auto address = cluster->GetAddress();
497 auto StationIndex = CbmMuchAddress::GetStationIndex(address);
498 //cout<<" station index "<<StationIndex<<endl;
500
501 Int_t nPts = pointsInCluster[i];
502 Int_t nHits = hitsInCluster[i];
503 fhPointsInCluster[StationIndex]->Fill(nPts);
504 fhHitsPerCluster[StationIndex]->Fill(nHits);
505 if (nPts > nHits) fPointsUnderCounted.SetVal(fPointsUnderCounted.GetVal() + (nPts - nHits));
506 if (nHits > nPts) fPointsOverCounted.SetVal(fPointsOverCounted.GetVal() + (nHits - nPts));
507 fPointsTotal.SetVal(fPointsTotal.GetVal() + nPts);
508 }
509}
510// -------------------------------------------------------------------------
511
512
513// -------------------------------------------------------------------------
515{
516 Bool_t verbose = (fVerbose > 2);
517 // Filling residuals and pulls for hits at the first layer
518 for (Int_t i = 0; i < fHits->GetEntriesFast(); i++) {
519 CbmMuchPixelHit* hit = (CbmMuchPixelHit*) fHits->At(i);
520 // Select hits from the first station only
521 Int_t iStation = CbmMuchAddress::GetStationIndex(hit->GetAddress());
522 Int_t iLayer = CbmMuchAddress::GetLayerIndex(hit->GetAddress());
523 // if((iStation !=0 && iStation !=1))continue;
524 // if((iStation !=0 && iStation !=1))continue;
525 // cout<<" PULLS QA STATION INDEX "<<iStation<<endl;
526 //Earlier finding for only one station
527 //if(!(iStation == 0)) continue;
528 // if(!(iStation == 3 && iLayer == 0)) continue;
529 if (verbose) printf(" Hit %i, station %i, layer %i ", i, iStation, iLayer);
530
531 Int_t clusterId = hit->GetRefId();
532 Bool_t hit_unique = 1;
533 for (Int_t j = i + 1; j < fHits->GetEntriesFast(); j++) {
534 CbmMuchPixelHit* hit1 = (CbmMuchPixelHit*) fHits->At(j);
535 //if (hit1->GetStationNr()>stationNr) break;
536 if (hit1->GetRefId() == clusterId) {
537 hit_unique = 0;
538 break;
539 }
540 }
541 if (verbose) printf("hit_unique=%i", hit_unique);
542 if (!hit_unique) {
543 if (verbose) printf("\n");
544 continue;
545 }
546
547 // Select hits with clusters formed by only one MC Point
548 CbmMuchCluster* cluster = (CbmMuchCluster*) fClusters->At(clusterId);
549 Bool_t point_unique = 1;
550 CbmLink link;
551
552 for (Int_t digiId = 0; digiId < cluster->GetNofDigis(); digiId++) {
553 Int_t index = cluster->GetDigi(digiId);
554 // printf("%i\n",index);
556 // cout<<" check 1"<<endl;
557 if (!digi) {
558 LOG(fatal) << "CbmMuchHitFinderQa::PullsQa(): Error, digi not found.";
559 return;
560 }
561 if (index < 0) {
562 LOG(fatal) << "CbmMuchHitFinderQa::PullsQa(): Error, index out of bounds.";
563 return;
564 }
566 if (!match) {
567 LOG(fatal) << "CbmMuchHitFinderQa::PullsQa(): Error, match not found.";
568 return;
569 }
570 // Not unique if the pad has several mcPoint references
571 if (verbose) printf(" n=%i", match->GetNofLinks());
572 if (match->GetNofLinks() == 0) {
573 printf(" noise hit");
574 point_unique = 0;
575 break;
576 }
577 if (match->GetNofLinks() > 1) {
578 point_unique = 0;
579 break;
580 }
581 CbmLink currentLink = match->GetLink(0);
582
584 if (!module) {
585 LOG(fatal) << "CbmMuchHitFinderQa::PullsQa(): Error, module not found.";
586 return;
587 }
588 if (digiId == 0) {
589 link = currentLink;
590 continue;
591 }
592 // Not unique if mcPoint references differ for different digis
593 if (!(currentLink == link)) {
594 point_unique = 0;
595 break;
596 }
597 }
598
599 if (verbose) printf(" point_unique=%i", point_unique);
600 if (!point_unique) {
601 if (verbose) printf("\n");
602 continue;
603 }
604
605 if (verbose) {
606 printf(" file %i event %i pointId %i", link.GetFile(), link.GetEntry(), link.GetIndex());
607 }
608 CbmMuchPoint* point = (CbmMuchPoint*) fPoints->Get(link);
609
610 Double_t xMC = 0.5 * (point->GetXIn() + point->GetXOut());
611 Double_t yMC = 0.5 * (point->GetYIn() + point->GetYOut());
612 Double_t tMC = point->GetTime();
613 // cout<<" MC point time "<<tMC<<" z "<<point->GetZ()<<endl;
614 Double_t xRC = hit->GetX();
615 Double_t yRC = hit->GetY();
616 Double_t dx = hit->GetDx();
617 Double_t dy = hit->GetDy();
618
619 Double_t tRC = hit->GetTime();
620 Double_t dt = hit->GetTimeError();
621 // cout<<" Rec Hit time "<<tRC<<endl;
622
623 if (dx < 1.e-10) {
624 LOG(error) << "Anomalously small dx";
625 continue;
626 }
627 if (dy < 1.e-10) {
628 LOG(error) << "Anomalously small dy";
629 continue;
630 }
631 fhPullX->Fill((xRC - xMC) / dx);
632 fhPullY->Fill((yRC - yMC) / dy);
633 fhPullT->Fill((tRC - tMC) / dt);
634 fhResidualX->Fill((xRC - xMC));
635 fhResidualY->Fill((yRC - yMC));
636 fhResidualT->Fill((tRC - tMC));
637
638 if (verbose) printf("\n");
639 }
640}
641// -------------------------------------------------------------------------
642
643
644// -------------------------------------------------------------------------
646{
647
648 Int_t nClusters = fClusters->GetEntriesFast();
649 vector<CbmLink> vPoints;
650
651 {
652 const CbmMatch& match = fTimeSlice->GetMatch();
653 for (int iLink = 0; iLink < match.GetNofLinks(); iLink++) {
654 CbmLink link = match.GetLink(iLink);
655 int nMuchPoints = fPoints->Size(link);
656 for (Int_t iPoint = 0; iPoint < nMuchPoints; iPoint++) {
657 link.SetIndex(iPoint);
658 link.SetWeight(0.);
659 if (IsSignalPoint(link)) {
660 fSignalPoints.SetVal(fSignalPoints.GetVal() + 1);
661 }
662 vPoints.push_back(link);
663 }
664 }
665 }
666
667 std::sort(vPoints.begin(), vPoints.end());
668
669 for (Int_t iCluster = 0; iCluster < nClusters; ++iCluster) {
670 CbmMuchCluster* cluster = (CbmMuchCluster*) fClusters->At(iCluster);
671 if (!cluster) {
672 LOG(fatal) << "CbmMuchHitFinderQa::ClusterDeconvQa(): Error, cluster not found.";
673 return;
674 }
675 Int_t nDigis = cluster->GetNofDigis();
676 for (Int_t id = 0; id < nDigis; ++id) {
677 Int_t iDigi = cluster->GetDigi(id);
679 if (!match) {
680 LOG(fatal) << "CbmMuchHitFinderQa::ClusterDeconvQa(): Error, match not found.";
681 return;
682 }
683 for (Int_t ip = 0; ip < match->GetNofLinks(); ++ip) {
684 CbmLink pointLink = match->GetLink(ip);
685 auto it = find(vPoints.begin(), vPoints.end(), pointLink);
686 assert(it != vPoints.end());
687 if (it->GetWeight() > 0.) continue;
688 it->SetWeight(1.);
689 if (IsSignalPoint(pointLink)) {
690 fSignalHits.SetVal(fSignalHits.GetVal() + 1);
691 }
692 }
693 }
694 }
695}
696// -------------------------------------------------------------------------
697
699{
700
701 CbmMuchPoint* point = (CbmMuchPoint*) fPoints->Get(pointLink);
702 if (!point) return kFALSE;
703 Int_t iTrack = point->GetTrackID();
704 CbmMCTrack* track = (CbmMCTrack*) fMCTracks->Get(pointLink.GetFile(), pointLink.GetEntry(), iTrack);
705 if (!track) return kFALSE;
706
707 if (iTrack != 0 && iTrack != 1) return kFALSE; // Signal tracks must be fist ones
708 // Verify if it is a signal muon
709 if (track->GetMotherId() < 0) { // No mother for signal
710 Int_t pdgCode = track->GetPdgCode();
711 if (TMath::Abs(pdgCode) == 13) { // If it is a muon
712 return kTRUE;
713 }
714 }
715 return kFALSE;
716}
717
ClassImp(CbmConverterManager)
@ kMuch
Muon detection system.
Data container for MUCH clusters.
Class for pixel hits in MUCH detector.
Definition of the CbmQaCanvas class.
int32_t GetAddress() const
Definition CbmCluster.h:90
int32_t GetDigi(int32_t index) const
Get digi at position index.
Definition CbmCluster.h:76
int32_t GetNofDigis() const
Number of digis in cluster.
Definition CbmCluster.h:69
static Bool_t IsMatchPresent(ECbmModuleId systemId)
Presence of a digi match branch.
InitStatus Init()
Initialisation.
const Digi * Get(Int_t index) const
Get a digi object.
static CbmDigiManager * Instance()
Static instance.
const CbmMatch * GetMatch(ECbmModuleId systemId, UInt_t index) const
Get a match object.
double GetTimeError() const
Definition CbmHit.h:77
double GetTime() const
Definition CbmHit.h:76
int32_t GetAddress() const
Definition CbmHit.h:74
int32_t GetRefId() const
Definition CbmHit.h:73
TObject * Get(const CbmLink *lnk)
Int_t Size(Int_t fileNumber, Int_t eventNumber)
Task class creating and managing CbmMCDataArray objects.
CbmMCDataArray * InitBranch(const char *name)
int32_t GetMotherId() const
Definition CbmMCTrack.h:69
int32_t GetPdgCode() const
Definition CbmMCTrack.h:68
const CbmLink & GetLink(int32_t i) const
Definition CbmMatch.h:39
int32_t GetNofLinks() const
Definition CbmMatch.h:42
static int32_t GetLayerIndex(int32_t address)
static int32_t GetStationIndex(int32_t address)
Data container for MUCH clusters.
int32_t GetAddress() const
Definition CbmMuchDigi.h:93
void Init(TObjArray *stations, Int_t flag)
Int_t GetNStations() const
CbmMuchModule * GetModuleByDetId(Int_t detId) const
TParameter< int > fPointsTotal
CbmMuchGeoScheme * fGeoScheme
CbmMuchHitFinderQa(const char *name="MuchHitFinderQa", Int_t verbose=1)
TParameter< int > fNevents
FairRootManager * fManager
CbmMCDataArray * fMCTracks
std::vector< TH1I * > fhDigisInCluster
TParameter< int > fPointsUnderCounted
TParameter< int > fSignalPoints
number of processed events
TClonesArray * fClusters
subfolder for histograms
CbmTimeSlice * fTimeSlice
CbmDigiManager * fDigiManager
CbmQaCanvas * fCanvDigisInCluster
CbmMCDataArray * fPoints
virtual void Exec(Option_t *option)
TFolder * histFolder
output folder with histos and canvases
TParameter< int > fSignalHits
CbmQaCanvas * fCanvResidual
virtual InitStatus Init()
Bool_t IsSignalPoint(CbmLink pointLink)
std::vector< TH1I * > fhHitsPerCluster
CbmQaCanvas * fCanvPointsInCluster
virtual void SetParContainers()
CbmMCDataManager * fMcManager
CbmQaCanvas * fCanvHitsPerCluster
std::vector< TH1I * > fhPointsInCluster
TParameter< int > fPointsOverCounted
double GetYOut() const
double GetYIn() const
double GetXOut() const
double GetXIn() const
double GetDy() const
Definition CbmPixelHit.h:76
double GetDx() const
Definition CbmPixelHit.h:75
double GetY() const
Definition CbmPixelHit.h:74
double GetX() const
Definition CbmPixelHit.h:73
void Divide2D(int nPads)
Divide canvas into nPads in 2D in a nice way.
Bookkeeping of time-slice content.
const CbmMatch & GetMatch() const