CbmRoot
Loading...
Searching...
No Matches
CbmTrdRecoQa.cxx
Go to the documentation of this file.
1/* Copyright (C) 2007-2021 Institut fuer Kernphysik, Westfaelische Wilhelms-Universitaet Muenster, Muenster
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Florian Uhlig, Cyrano Bergmann [committer] */
4
5// -----------------------------------------------------------------------
6// ----- CbmTrdRecoQa -----
7// ----- Created 24.02.07 by F. Uhlig -----
8// -----------------------------------------------------------------------
9
10#include "CbmTrdRecoQa.h"
11
12#include "CbmDigiManager.h"
13#include "CbmMCTrack.h"
14#include "CbmTrdCluster.h"
15#include "CbmTrdDigi.h"
16#include "CbmTrdGeoHandler.h"
17#include "CbmTrdHit.h"
18#include "CbmTrdParModDigi.h"
19#include "CbmTrdParSetDigi.h"
20#include "CbmTrdPoint.h"
21#include "CbmTrdUtils.h"
22#include "FairRootManager.h"
23#include "FairRunAna.h"
24#include "FairRuntimeDb.h"
25#include "TCanvas.h"
26#include "TClonesArray.h"
27#include "TColor.h"
28#include "TFrame.h"
29#include "TGeoManager.h"
30#include "TGraph.h"
31#include "TGraphErrors.h"
32#include "TH1.h"
33#include "TH2.h"
34#include "TLine.h"
35#include "TMath.h"
36#include "TMultiGraph.h"
37#include "TPad.h"
38#include "TPaveText.h"
39#include "TPolyLine.h"
40#include "TStopwatch.h"
41#include "TVector3.h"
42
43#include <Logger.h>
44
45#include <iostream>
46
47using std::cout;
48using std::endl;
49using std::map;
50
51// ---- Default constructor -------------------------------------------------
52
54
55// ---- Standard constructor ------------------------------------------------
56CbmTrdRecoQa::CbmTrdRecoQa(const char* name, const char*)
57 : FairTask(name)
58 , fTrianglePads(false)
59 , fTriggerTH(1.0e-6)
60 , fClusters(NULL)
61 , fHits(NULL)
62 , fMCPoints(NULL)
63 , fDigiPar(NULL)
64 , fModuleInfo(NULL)
65 , fGeoHandler(new CbmTrdGeoHandler())
66 , fModuleMap()
67 , fModuleMapPoint()
68 , fModuleMapDigi()
69 , fModuleMapCluster()
70 , fModuleMapHit()
71 , fModuleMapTrack()
72{
73}
74// --------------------------------------------------------------------------
75
76
77// ---- Destructor ----------------------------------------------------------
79// --------------------------------------------------------------------------
80void CbmTrdRecoQa::SetTriggerThreshold(Double_t minCharge)
81{
82 fTriggerTH = minCharge; // To be used for test beam data processing
83}
84
85// ---- Initialisation ------------------------------------------------------
87{
88 // Get pointer to the ROOT I/O manager
89 FairRootManager* rootMgr = FairRootManager::Instance();
90 if (NULL == rootMgr) {
91 cout << "-E- CbmTrdRecoQa::Init : "
92 << "ROOT manager is not instantiated !" << endl;
93 return kFATAL;
94 }
95
96
97 // Get pointer to TRD point array
98 fMCPoints = (TClonesArray*) rootMgr->GetObject("TrdPoint");
99 if (NULL == fMCPoints) {
100 cout << "-W- CbmTrdRecoQa::Init : "
101 << "no MC point array !" << endl;
102 return kERROR;
103 }
104
106 if (!CbmDigiManager::Instance()->IsPresent(ECbmModuleId::kTrd)) LOG(fatal) << GetName() << "Missing Trd digi branch.";
107
108
109 // Get pointer to TRD point array
110 fClusters = (TClonesArray*) rootMgr->GetObject("TrdCluster");
111 if (NULL == fClusters) {
112 cout << "-W- CbmTrdRecoQa::Init : "
113 << "no cluster array !" << endl;
114 return kERROR;
115 }
116
117 // Get pointer to TRD point array
118 fHits = (TClonesArray*) rootMgr->GetObject("TrdHit");
119 if (NULL == fHits) {
120 cout << "-W- CbmTrdRecoQa::Init : "
121 << "no hit array !" << endl;
122 return kERROR;
123 }
124
125 fGeoHandler->Init();
126
127 return kSUCCESS;
128}
129
130// --------------------------------------------------------------------------
131
132// ---- Initialisation ----------------------------------------------
134{
135 cout << " * CbmTrdRecoQa * :: SetParContainers() " << endl;
136
137
138 // Get Base Container
139 FairRunAna* ana = FairRunAna::Instance();
140 FairRuntimeDb* rtdb = ana->GetRuntimeDb();
141
142 fDigiPar = (CbmTrdParSetDigi*) (rtdb->getContainer("CbmTrdParSetDigi"));
143}
144// --------------------------------------------------------------------
145
146// ---- ReInit -------------------------------------------------------
148{
149
150 cout << " * CbmTrdRecoQa * :: ReInit() " << endl;
151
152
153 FairRunAna* ana = FairRunAna::Instance();
154 FairRuntimeDb* rtdb = ana->GetRuntimeDb();
155
156 fDigiPar = (CbmTrdParSetDigi*) (rtdb->getContainer("CbmTrdParSetDigi"));
157
158 return kSUCCESS;
159}
160void CbmTrdRecoQa::SetTriangularPads(Bool_t triangles) { fTrianglePads = triangles; }
161/*
162TPolyLine *CbmTrdRecoQa::CreateTriangularPad(Int_t column, Int_t row, Double_t content){
163 const Int_t nCoordinates = 4;
164 Double_t x[nCoordinates] = {column-0.5,column+0.5,column+0.5,column-0.5};
165 Double_t y[nCoordinates] = {row-0.5, row-0.5, row+0.5, row-0.5 };
166 if (row%2 != 0){
167 y[1] = row+0.5;
168 y[2] = row+0.5;
169 }
170 TPolyLine *pad = new TPolyLine(nCoordinates,x,y);
171 pad->SetFillColor(content);
172 return pad;
173}
174*/
175// ---- Task execution ------------------------------------------------------
176void CbmTrdRecoQa::Exec(Option_t*)
177{
178 CbmTrdUtils* utils = new CbmTrdUtils();
179 TStopwatch timer;
180 timer.Start();
181 cout << "================CbmTrdRecoQa==============" << endl;
182 // Declare variables
183 CbmTrdPoint* point = NULL;
184 const CbmTrdDigi* digi = NULL;
185 CbmTrdCluster* cluster = NULL;
186 CbmTrdHit* hit = NULL;
187
188 Int_t nPoints(0), nDigis(0), nClusters(0), nHits(0);
190 if (fClusters) nClusters = fClusters->GetEntriesFast();
191 if (fMCPoints) nPoints = fMCPoints->GetEntriesFast();
192 if (fHits) nHits = fHits->GetEntriesFast();
193
194 TH1D* digiMaxSpectrum = new TH1D("digiMaxSpectrum", "digiMaxSpectrum", 10000, 0, 1e-4);
195 TH1D* digiSpectrum = new TH1D("digiSpectrum", "digiSpectrum", 10000, 0, 1e-4);
196
197 LOG(info) << "CbmTrdRecoQa::Exec : MC-Points:" << nPoints;
198 LOG(info) << "CbmTrdRecoQa::Exec : Digis: " << nDigis;
199 LOG(info) << "CbmTrdRecoQa::Exec : Cluster: " << nClusters;
200 LOG(info) << "CbmTrdRecoQa::Exec : Hits: " << nHits;
201 Int_t moduleAddress(-1), moduleId(-1);
202
203 // Double_t dummy_x(-1), dummy_y(-1);
204 TString name;
205 //cout << "Points" << endl;
206 Int_t pointCounter = 0;
207 for (Int_t iPoint = 0; iPoint < nPoints; iPoint++) {
208 //cout << iPoint << endl;
209 point = (CbmTrdPoint*) fMCPoints->At(iPoint);
210 Double_t in[3] = {point->GetXIn(), point->GetYIn(), point->GetZIn()};
211 Double_t out[3] = {point->GetXOut(), point->GetYOut(), point->GetZOut()};
212 gGeoManager->FindNode((out[0] + in[0]) / 2, (out[1] + in[1]) / 2, (out[2] + in[2]) / 2);
213 if (!TString(gGeoManager->GetPath()).Contains("gas")) {
214 LOG(error) << "CbmTrdRecoQa::Exec: MC-track not in TRD! Node:" << TString(gGeoManager->GetPath()).Data()
215 << " gGeoManager->MasterToLocal() failed!";
216 continue;
217 }
218 //std::map<Int_t, std::vector<TH2D*> >::iterator it = fModuleMap.find(moduleAddress);
219 moduleAddress = CbmTrdAddress::GetModuleAddress(point->GetDetectorID()); //
220 moduleId = CbmTrdAddress::GetModuleId(point->GetDetectorID());
221 //printf("Address:%i ID:%i\n",moduleAddress,moduleId);
223 //printf("Address:%i ID:%i\n",moduleAddress,moduleId);
224 if (fModuleInfo) {
225 std::map<Int_t, TGraphErrors*>::iterator it = fModuleMapPoint.find(moduleAddress);
226 if (it == fModuleMapPoint.end()) {
227 name.Form("ModuleAddress%05i", moduleAddress);
228 fModuleMap[moduleAddress] = new TCanvas(name, name, 1000, 1000);
229 fModuleMap[moduleAddress]->Divide(2, 2);
230 //name.Form("ModuleAddress%iPoints",moduleAddress);
231 fModuleMapPoint[moduleAddress] = new TGraphErrors();
232 fModuleMapPoint[moduleAddress]->SetMarkerStyle(20);
233 fModuleMapPoint[moduleAddress]->SetMarkerSize(0.5);
234 fModuleMapPoint[moduleAddress]->SetMarkerColor(15);
235 //fModuleMapPoint[moduleAddress] = new TH2I(name,name,fModuleInfo->GetNofColumns(),-0.5,fModuleInfo->GetNofColumns()-0.5,fModuleInfo->GetNofRows(),-0.5,fModuleInfo->GetNofRows()-0.5);
236 TH2I* dummy = new TH2I(name, name, fModuleInfo->GetNofColumns(), -0.5, fModuleInfo->GetNofColumns() - 0.5,
237 fModuleInfo->GetNofRows(), -0.5, fModuleInfo->GetNofRows() - 0.5);
238 dummy->SetStats(kFALSE);
239 name.Form("ModuleAddress%05iDigis", moduleAddress);
240 fModuleMapDigi[moduleAddress] =
241 new TH2D(name, name, fModuleInfo->GetNofColumns(), -0.5, fModuleInfo->GetNofColumns() - 0.5,
242 fModuleInfo->GetNofRows(), -0.5, fModuleInfo->GetNofRows() - 0.5);
243 fModuleMapDigi[moduleAddress]->SetContour(99);
244 fModuleMapDigi[moduleAddress]->SetStats(kFALSE);
245 name.Form("ModuleAddress%05iClusters", moduleAddress);
246 fModuleMapCluster[moduleAddress] =
247 new TH2I(name, name, fModuleInfo->GetNofColumns(), -0.5, fModuleInfo->GetNofColumns() - 0.5,
248 fModuleInfo->GetNofRows(), -0.5, fModuleInfo->GetNofRows() - 0.5);
249 fModuleMapCluster[moduleAddress]->SetContour(99);
250 fModuleMapCluster[moduleAddress]->SetStats(kFALSE);
251 name.Form("ModuleAddress%05iHits", moduleAddress);
252 fModuleMapHit[moduleAddress] =
253 new TGraphErrors(); //name,name,fModuleInfo->GetNofColumns(),-0.5,fModuleInfo->GetNofColumns()-0.5,fModuleInfo->GetNofRows(),-0.5,fModuleInfo->GetNofRows()-0.5);
254 fModuleMapHit[moduleAddress]->SetMarkerStyle(24);
255 fModuleMapTrack[moduleAddress] = new std::vector<TLine*>;
256 fModuleMap[moduleAddress]->cd(1);
257 dummy->Draw(); /*
258 fModuleMapPoint[moduleAddress]->Draw("AP");
259 fModuleMapPoint[it->first]->SetMaximum(fModuleMapDigi[it->first]->GetYaxis()->GetXmax());
260 fModuleMapPoint[it->first]->SetMinimum(fModuleMapDigi[it->first]->GetYaxis()->GetXmin());
261 fModuleMapPoint[it->first]->GetXaxis()->SetLimits(fModuleMapDigi[it->first]->GetXaxis()->GetXmin(),
262 fModuleMapDigi[it->first]->GetXaxis()->GetXmax());
263 fModuleMapPoint[moduleAddress]->Draw("AP");
264 */
265 }
266 //cout << iPoint << endl;
267
268
269 Double_t local_in[3];
270 Double_t local_out[3];
271 gGeoManager->MasterToLocal(in, local_in);
272 gGeoManager->MasterToLocal(out, local_out);
273
274 for (Int_t i = 0; i < 3; i++)
275 local_out[i] =
276 local_in[i]
277 + 0.975 * (local_out[i] - local_in[i]); // cut last 2.5% of tracklet, to move exit point within gas volume
278
279 Int_t row_in(0), row_out(0), col_in(0), col_out(0), sec_in(0), sec_out(0);
280 Double_t x_in(0), y_in(0), x_out(0), y_out(0);
281 if (!fModuleInfo->GetPadInfo(local_in, sec_in, col_in, row_in)) continue;
282 //printf("a: local_in (%f,%f,%f) sec:%i, col:%i row:%i\n",local_in[0],local_in[1],local_in[2], sec_in, col_in, row_in);
283 if ((sec_in < 0) || (sec_in > 2)) {
284 cout << "sec_in:" << sec_in << endl;
285 continue;
286 }
287 fModuleInfo->TransformToLocalPad(local_in, x_in, y_in);
288 //printf("b: local_in (%f,%f,%f) sec:%i, col:%i row:%i (%f,%f)\n",local_in[0],local_in[1],local_in[2], sec_in, col_in, row_in, x_in, y_in);
289 row_in = fModuleInfo->GetModuleRow(sec_in, row_in);
290 //printf("c: local_in (%f,%f,%f) sec:%i, col:%i row:%i/%i (%f,%f)\n",local_in[0],local_in[1],local_in[2], sec_in, col_in, row_in, fModuleInfo->GetNofRows(), x_in, y_in);
291 if ((sec_out < 0) || (sec_out > 2)) {
292 cout << "sec_out:" << sec_out << endl;
293 continue;
294 }
295 //printf("d1: local_out (%f,%f,%f) sec:%i, col:%i row:%i\n",local_out[0],local_out[1],local_out[2], sec_out, col_out, row_out);
296 if (!fModuleInfo->GetPadInfo(local_out, sec_out, col_out, row_out)) continue;
297 //printf("d: local_out (%f,%f,%f) sec:%i, col:%i row:%i\n",local_out[0],local_out[1],local_out[2], sec_out, col_out, row_out);
298 fModuleInfo->TransformToLocalPad(local_out, x_out, y_out);
299 //printf("e: local_out (%f,%f,%f) sec:%i, col:%i row:%i (%f,%f)\n",local_out[0],local_out[1],local_out[2], sec_out, col_out, row_out, x_out, y_out);
300 row_out = fModuleInfo->GetModuleRow(sec_out, row_out);
301 //printf("f: local_out (%f,%f,%f) sec:%i, col:%i row:%i/%i (%f,%f)\n",local_out[0],local_out[1],local_out[2], sec_out, col_out,row_out, fModuleInfo->GetNofRows(), x_out, y_out);
302 Double_t W_in(fModuleInfo->GetPadSizeX(sec_in)), W_out(fModuleInfo->GetPadSizeX(sec_out));
303 Double_t H_in(fModuleInfo->GetPadSizeY(sec_in)), H_out(fModuleInfo->GetPadSizeY(sec_out));
304
305
306 pointCounter = fModuleMapPoint[moduleAddress]->GetN();
307 fModuleMapPoint[moduleAddress]->SetPoint(pointCounter, ((col_in + x_in / W_in) + (col_out + x_out / W_out)) / 2.,
308 ((row_in + y_in / H_in) + (row_out + y_out / H_out)) / 2.);
309 //pointCounter++;
310 fModuleMap[moduleAddress]->cd();
311 TLine* l =
312 new TLine(col_in + x_in / W_in, row_in + y_in / H_in, col_out + x_out / W_out, row_out + y_out / H_out);
313 l->SetLineWidth(2);
314 l->SetLineColor(15);
315 fModuleMapTrack[moduleAddress]->push_back(l);
316 fModuleMap[moduleAddress]->cd(1);
317 l->Draw("same");
318 /*
319 fModuleMap[moduleAddress]->cd(2);
320 l->Draw("same");
321 fModuleMap[moduleAddress]->cd(3);
322 l->Draw("same");
323 fModuleMap[moduleAddress]->cd(4);
324 l->Draw("same");
325 */
326 }
327 else {
328 printf("Address:%i ID:%i\n", moduleAddress, moduleId);
329 break;
330 }
331 }
332 //fModuleMap[moduleAddress]->cd(1);
333 //name.Form("%i Points",pointCounter);
334 //TPaveText *textpoints = new TPaveText(10,2.5,50,3);
335 //textpoints->SetTextSize(0.035);
336 //textpoints->AddText(name);
337 //textpoints->Draw("same");
338 //cout << "Digis" << endl;
339 for (Int_t iDigi = 0; iDigi < nDigis; iDigi++) {
340 digi = CbmDigiManager::Instance()->Get<CbmTrdDigi>(iDigi);
341 digiSpectrum->Fill(digi->GetCharge());
342 Int_t digiAddress = digi->GetAddress();
343 moduleAddress = CbmTrdAddress::GetModuleAddress(digiAddress);
345 Int_t sec(CbmTrdAddress::GetSectorId(digiAddress)), row(CbmTrdAddress::GetRowId(digiAddress));
346 row = fModuleInfo->GetModuleRow(sec, row);
347 fModuleMapDigi[moduleAddress]->Fill(CbmTrdAddress::GetColumnId(digiAddress), row, digi->GetCharge());
348 }
349 //cout << "Clusters" << endl;
350 Int_t lastModule(0), iCounter(0);
351 for (Int_t iCluster = 0; iCluster < nClusters; iCluster++) {
352 Double_t charge(0), chargeMax(0);
353 cluster = (CbmTrdCluster*) fClusters->At(iCluster);
354 Int_t nDigisInCluster = cluster->GetNofDigis();
355 iCounter++;
356 for (Int_t iDigi = 0; iDigi < nDigisInCluster; iDigi++) {
357 digi = CbmDigiManager::Instance()->Get<CbmTrdDigi>(cluster->GetDigi(iDigi));
358 // digi = (CbmTrdDigi*)fDigis->At(cluster->GetDigi(iDigi));
359 Int_t digiAddress = digi->GetAddress();
360 moduleAddress = CbmTrdAddress::GetModuleAddress(digiAddress);
361 if (iDigi == 0 && lastModule != moduleAddress) {
362 iCounter = 0;
363 lastModule = moduleAddress;
364 }
365 //cout << moduleAddress << endl;
367 Int_t sec(CbmTrdAddress::GetSectorId(digiAddress)), row(CbmTrdAddress::GetRowId(digiAddress));
368 row = fModuleInfo->GetModuleRow(sec, row);
369 fModuleMapCluster[moduleAddress]->Fill(CbmTrdAddress::GetColumnId(digiAddress), row, iCounter + 1);
370 //fModuleMapCluster[moduleAddress]->SetBinContent(CbmTrdAddress::GetColumnId(digiAddress)+1, row+1, iCounter+1);
371 charge = digi->GetCharge();
372 if (charge > chargeMax) chargeMax = charge;
373 }
374 digiMaxSpectrum->Fill(chargeMax);
375 }
376
377 //cout << "Hits" << endl;
378 Int_t modHit = 0;
379 for (Int_t iHit = 0; iHit < nHits; iHit++) {
380 hit = (CbmTrdHit*) fHits->At(iHit);
381
382 moduleAddress = hit->GetAddress(); //GetDetectorID();//?????
384 if (fModuleInfo == NULL) {
385 //printf("MA:%6i not found!\n",moduleAddress);
386 continue;
387 }
388
389 Double_t pos[3] = {hit->GetX(), hit->GetY(), hit->GetZ()};
390 gGeoManager->FindNode(pos[0], pos[1], pos[2] - 0.3);
391 Double_t local_pos[3];
392 gGeoManager->MasterToLocal(pos, local_pos);
393 Int_t sec(-1), col(-1), row(-1);
394 fModuleInfo->GetPadInfo(local_pos, sec, col, row);
395 row = fModuleInfo->GetModuleRow(sec, row);
396 Double_t x(-1), y(-1);
397 fModuleInfo->TransformToLocalPad(local_pos, x, y);
398
399 Double_t W(fModuleInfo->GetPadSizeX(sec)), H(fModuleInfo->GetPadSizeY(sec));
400 modHit = fModuleMapHit[moduleAddress]->GetN();
401 fModuleMapHit[moduleAddress]->SetPoint(modHit, col + x / W, row + y / H);
402
403 if (hit->GetDx() <= W)
404 fModuleMapHit[moduleAddress]->SetPointError(modHit, hit->GetDx() / W, hit->GetDy() / H);
405 else
406 fModuleMapHit[moduleAddress]->SetPointError(modHit, hit->GetDy() / W, hit->GetDx() / H);
407 }
408
409 gDirectory->mkdir("TrdRecoQA");
410 gDirectory->cd("TrdRecoQA");
411 digiMaxSpectrum->Write("", TObject::kOverwrite);
412 digiSpectrum->Write("", TObject::kOverwrite);
413 map<Int_t, TCanvas*>::iterator it;
414 for (it = fModuleMap.begin(); it != fModuleMap.end(); it++) {
415 it->second->cd(1);
416 name.Form("%i Points", fModuleMapPoint[it->first]->GetN());
417 fModuleMapPoint[it->first]->SetNameTitle(name, name);
418 fModuleMapPoint[it->first]->SetFillStyle(0);
419 TPaveText* ptext = new TPaveText(10, 3.5, 11, 4.0);
420 ptext->SetTextSize(0.035);
421 ptext->SetTextColor(15);
422 ptext->SetFillStyle(0);
423 ptext->SetLineColor(0);
424 ptext->AddText(name);
425 //fModuleMapPoint[it->first]->Draw("P");
426
427
428 //fModuleMapPoint[it->first]->Draw("P,same");
429 ptext->Draw("same");
430 it->second->cd(1)->Update();
431 it->second->cd(2);
432 fModuleMapDigi[it->first]->GetZaxis()->SetRangeUser(0, 0.0001);
433 fModuleMapDigi[it->first]->DrawCopy("colz");
434
435 {
436 TPolyLine* pad = NULL;
437 const Int_t nRow = fModuleMapDigi[it->first]->GetNbinsY();
438 const Int_t nCol = fModuleMapDigi[it->first]->GetNbinsX();
439 const Double_t max_Range = fModuleMapDigi[it->first]->GetBinContent(fModuleMapDigi[it->first]->GetMaximumBin());
440 for (Int_t iRow = 1; iRow <= nRow; iRow++) {
441 for (Int_t iCol = 1; iCol <= nCol; iCol++) {
442 Double_t charge = fModuleMapDigi[it->first]->GetBinContent(iCol, iRow);
443 if (charge > 0.0) {
444 if (fTrianglePads)
445 pad = utils->CreateTriangularPad(iCol - 1, iRow - 1, charge, 0.0, max_Range, false);
446 else
447 pad = utils->CreateRectangularPad(iCol - 1, iRow - 1, charge, 0.0, max_Range, false);
448 pad->Draw("f,same");
449 }
450 }
451 }
452 }
453
454 for (UInt_t t = 0; t < fModuleMapTrack[it->first]->size(); t++)
455 fModuleMapTrack[it->first]->at(t)->Draw("same");
456 /*
457 it->second->cd(3)->SetLogz(1);
458 fModuleMapDigi[it->first]->GetZaxis()->SetRangeUser(fTriggerTH,fModuleMapDigi[it->first]->GetBinContent(fModuleMapDigi[it->first]->GetMaximumBin()));
459 fModuleMapDigi[it->first]->DrawCopy("colz");
460 {
461 TPolyLine *pad = NULL;
462 const Int_t nRow = fModuleMapDigi[it->first]->GetNbinsY();
463 const Int_t nCol = fModuleMapDigi[it->first]->GetNbinsX();
464 const Double_t max_Range = fModuleMapDigi[it->first]->GetBinContent(fModuleMapDigi[it->first]->GetMaximumBin());
465 for (Int_t iRow = 1; iRow <= nRow; iRow++){
466 for (Int_t iCol = 1; iCol <= nCol; iCol++){
467 Double_t charge = fModuleMapDigi[it->first]->GetBinContent(iCol, iRow);
468 if (charge >= fTriggerTH){
469 if (fTrianglePads)
470 pad = utils->CreateTriangularPad(iCol-1, iRow-1, charge, 0, max_Range, true);
471 else
472 pad = utils->CreateRectangularPad(iCol-1, iRow-1, charge, 0.0, max_Range, false);
473 pad->Draw("f,same");
474 }
475 }
476 }
477 }
478 */
479
480
481 for (UInt_t t = 0; t < fModuleMapTrack[it->first]->size(); t++)
482 fModuleMapTrack[it->first]->at(t)->Draw("same");
483
484 it->second->cd(3);
485 fModuleMapCluster[it->first]->DrawCopy("colz");
486 {
487 TPolyLine* pad = NULL;
488 const Int_t nRow = fModuleMapCluster[it->first]->GetNbinsY();
489 const Int_t nCol = fModuleMapCluster[it->first]->GetNbinsX();
490 const Double_t max_Range =
491 fModuleMapCluster[it->first]->GetBinContent(fModuleMapCluster[it->first]->GetMaximumBin());
492 for (Int_t iRow = 1; iRow <= nRow; iRow++) {
493 for (Int_t iCol = 1; iCol <= nCol; iCol++) {
494 Double_t clusterId = fModuleMapCluster[it->first]->GetBinContent(iCol, iRow);
495 if (clusterId > 0) {
496 if (fTrianglePads)
497 pad = utils->CreateTriangularPad(iCol - 1, iRow - 1, clusterId, 0, max_Range, false);
498 else
499 pad = utils->CreateRectangularPad(iCol - 1, iRow - 1, clusterId, 0.0, max_Range, false);
500 pad->Draw("f,same");
501 }
502 }
503 }
504 }
505 for (UInt_t t = 0; t < fModuleMapTrack[it->first]->size(); t++)
506 fModuleMapTrack[it->first]->at(t)->Draw("same");
507 it->second->cd(3)->Update();
508 it->second->cd(4);
509 //fModuleMapPoint[it->first]->Draw();
510 //fModuleMapHit[it->first]->Draw("P,same");
511 if (fHits) {
512 /*
513 fModuleMapHit[it->first]->SetMaximum(fModuleMapDigi[it->first]->GetYaxis()->GetXmax());
514 fModuleMapHit[it->first]->SetMinimum(fModuleMapDigi[it->first]->GetYaxis()->GetXmin());
515 fModuleMapHit[it->first]->GetXaxis()->SetLimits(fModuleMapDigi[it->first]->GetXaxis()->GetXmin(),
516 fModuleMapDigi[it->first]->GetXaxis()->GetXmax());
517 */
518 name.Form("%i Hits", fModuleMapHit[it->first]->GetN());
519 fModuleMapHit[it->first]->SetNameTitle(name, name);
520 TPaveText* text = new TPaveText(10, 2.0, 11, 2.5);
521 text->SetFillStyle(0);
522 text->SetLineColor(0);
523 text->SetTextSize(0.035);
524 text->AddText(name);
525 TMultiGraph* mg = new TMultiGraph();
526
527 //fModuleMapHit[it->first]->Draw("AP");
528 //fModuleMapPoint[it->first]->Draw("P,same");
529 mg->Draw("AP");
530 mg->Add(fModuleMapHit[it->first]);
531 mg->Add(fModuleMapPoint[it->first]);
532 mg->SetMaximum(fModuleMapDigi[it->first]->GetYaxis()->GetXmax());
533 mg->SetMinimum(fModuleMapDigi[it->first]->GetYaxis()->GetXmin());
534 mg->GetXaxis()->SetLimits(fModuleMapDigi[it->first]->GetXaxis()->GetXmin(),
535 fModuleMapDigi[it->first]->GetXaxis()->GetXmax());
536 text->Draw("same");
537 ptext->Draw("same");
538 }
539 it->second->Update();
540 it->second->SaveAs("pics/" + (TString)(it->second->GetName()) + ".png");
541 it->second->Write("", TObject::kOverwrite);
542 it->second->Close();
543 }
544 gDirectory->cd("..");
545 timer.Stop();
546 Double_t rtime = timer.RealTime();
547 Double_t ctime = timer.CpuTime();
548
549 printf("\n\n******************** Reading Test **********************\n");
550 printf(" RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime);
551 printf("*********************************************************\n\n");
552}
553
554// --------------------------------------------------------------------------
555//Int_t CbmTrdRecoQa::SecRowToGlobalRow(Int_t secRow)
556//{
557
558//}
559
560// ---- Finish --------------------------------------------------------------
562// --------------------------------------------------------------------------
563
564// ---- Write test histograms ------------------------------------------------
565
567{
568 /*
569 // Write histos to output
570 gDirectory->mkdir("TrdTracksPidQA");
571 gDirectory->cd("TrdTracksPidQA");
572
573 if(WknPI) WknPI->Write();
574 if(WknEL) WknEL->Write();
575 if(WknALL) WknALL->Write();
576 if(WknLowPI) WknLowPI->Write();
577 if(WknLowEL) WknLowEL->Write();
578 if(WknLowALL) WknLowALL->Write();
579 if(WknHighPI) WknHighPI->Write();
580 if(WknHighEL) WknHighEL->Write();
581 if(WknHighALL) WknHighALL->Write();
582
583 if(AnnPI) AnnPI->Write();
584 if(AnnEL) AnnEL->Write();
585 if(AnnALL) AnnALL->Write();
586 if(AnnLowPI) AnnLowPI->Write();
587 if(AnnLowEL) AnnLowEL->Write();
588 if(AnnLowALL) AnnLowALL->Write();
589 if(AnnHighPI) AnnHighPI->Write();
590 if(AnnHighEL) AnnHighEL->Write();
591 if(AnnHighALL) AnnHighALL->Write();
592
593 if(LikePI) LikePI->Write();
594 if(LikeEL) LikeEL->Write();
595 if(LikeALL) LikeALL->Write();
596 if(LikeHighPI) LikeHighPI->Write();
597 if(LikeHighEL) LikeHighEL->Write();
598 if(LikeHighALL) LikeHighALL->Write();
599 if(LikeLowPI) LikeLowPI->Write();
600 if(LikeLowEL) LikeLowEL->Write();
601 if(LikeLowALL) LikeLowALL->Write();
602
603 if(PartID) PartID->Write();
604 if(NrTRDHits) NrTRDHits->Write();
605 if(ELossPI) ELossPI->Write();
606 if(ELossEL) ELossEL->Write();
607 if(ELossALL) ELossALL->Write();
608 if(MomPI) MomPI->Write();
609 if(MomEL) MomEL->Write();
610 if(MomALL) MomALL->Write();
611 if(MOMvsELossPI) MOMvsELossPI->Write();
612 if(MOMvsELossEL) MOMvsELossEL->Write();
613 if(MOMvsELossALL) MOMvsELossALL->Write();
614
615 gDirectory->cd("..");
616 */
617}
618
619// --------------------------------------------------------------------------
620
@ kTrd
Transition Radiation Detector.
static FairRootManager * rootMgr
Data Container for TRD clusters.
Helper class to extract information from the GeoManager.
Class for hits in TRD detector.
ClassImp(CbmTrdRecoQa)
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 Int_t GetNofDigis(ECbmModuleId systemId)
InitStatus Init()
Initialisation.
const Digi * Get(Int_t index) const
Get a digi object.
static CbmDigiManager * Instance()
Static instance.
int32_t GetAddress() const
Definition CbmHit.h:74
double GetZ() const
Definition CbmHit.h:71
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
static uint32_t GetModuleId(uint32_t address)
Return module ID from address.
static uint32_t GetSectorId(uint32_t address)
Return sector ID from address.
static uint32_t GetColumnId(uint32_t address)
Return column ID from address.
static uint32_t GetModuleAddress(uint32_t address)
Return unique module ID from address.
static uint32_t GetRowId(uint32_t address)
Return row ID from address.
Data Container for TRD clusters.
int32_t GetAddress() const
Address getter for module in the format defined by CbmTrdDigi (format of CbmTrdAddress can be accesse...
Definition CbmTrdDigi.h:112
double GetCharge() const
Common purpose charge getter.
void Init(Bool_t isSimulation=kFALSE)
data class for a reconstructed Energy-4D measurement in the TRD
Definition CbmTrdHit.h:40
Definition of chamber gain conversion for one TRD module.
Bool_t GetPadInfo(const Double_t *local_point, Int_t &sectorId, Int_t &columnId, Int_t &rowId) const
Int_t GetNofRows() const
Double_t GetPadSizeY(Int_t i) const
Double_t GetPadSizeX(Int_t i) const
Int_t GetNofColumns() const
void TransformToLocalPad(const Double_t *local_point, Double_t &posX, Double_t &posY) const
Int_t GetModuleRow(Int_t &sectorId, Int_t &rowId) const
virtual const CbmTrdParMod * GetModulePar(Int_t detId) const
double GetYOut() const
Definition CbmTrdPoint.h:69
double GetXIn() const
Definition CbmTrdPoint.h:65
double GetZIn() const
Definition CbmTrdPoint.h:67
double GetXOut() const
Definition CbmTrdPoint.h:68
double GetYIn() const
Definition CbmTrdPoint.h:66
double GetZOut() const
Definition CbmTrdPoint.h:70
virtual ~CbmTrdRecoQa()
Bool_t fTrianglePads
std::map< Int_t, std::vector< TLine * > * > fModuleMapTrack
CbmTrdParModDigi * fModuleInfo
TClonesArray * fHits
std::map< Int_t, TGraphErrors * > fModuleMapHit
std::map< Int_t, TCanvas * > fModuleMap
TClonesArray * fMCPoints
void WriteHistograms()
void SetTriangularPads(Bool_t triangles)
void SetParContainers()
std::map< Int_t, TH2D * > fModuleMapDigi
virtual void Finish()
InitStatus ReInit()
std::map< Int_t, TH2I * > fModuleMapCluster
Double_t fTriggerTH
void SetTriggerThreshold(Double_t triggerthreshold)
virtual void Exec(Option_t *option)
InitStatus Init()
CbmTrdGeoHandler * fGeoHandler
TClonesArray * fClusters
CbmTrdParSetDigi * fDigiPar
std::map< Int_t, TGraphErrors * > fModuleMapPoint
TPolyLine * CreateTriangularPad(Int_t column, Int_t row, Double_t value, Double_t min_range, Double_t max_range, Bool_t logScale)
TPolyLine * CreateRectangularPad(Int_t column, Int_t row, Double_t value, Double_t min_range, Double_t max_range, Bool_t logScale)