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