18 #include "FairLogger.h"
19 #include "FairRootManager.h"
20 #include "FairRunAna.h"
21 #include "FairRuntimeDb.h"
27 #include "TClonesArray.h"
30 #include "TGeoManager.h"
32 #include "TGraphErrors.h"
37 #include "TMultiGraph.h"
39 #include "TPaveText.h"
40 #include "TPolyLine.h"
41 #include "TStopwatch.h"
58 , fTrianglePads(false)
71 , fModuleMapTrack() {}
85 FairRootManager*
rootMgr = FairRootManager::Instance();
87 cout <<
"-E- CbmTrdRecoQa::Init : "
88 <<
"ROOT manager is not instantiated !" << endl;
96 cout <<
"-W- CbmTrdRecoQa::Init : "
97 <<
"no MC point array !" << endl;
108 cout <<
"-W- CbmTrdRecoQa::Init : "
109 <<
"no cluster array !" << endl;
116 cout <<
"-W- CbmTrdRecoQa::Init : "
117 <<
"no hit array !" << endl;
130 cout <<
" * CbmTrdRecoQa * :: SetParContainers() " << endl;
134 FairRunAna* ana = FairRunAna::Instance();
135 FairRuntimeDb* rtdb = ana->GetRuntimeDb();
144 cout <<
" * CbmTrdRecoQa * :: ReInit() " << endl;
147 FairRunAna* ana = FairRunAna::Instance();
148 FairRuntimeDb* rtdb = ana->GetRuntimeDb();
176 cout <<
"================CbmTrdRecoQa==============" << endl;
183 Int_t nPoints(0), nDigis(0), nClusters(0), nHits(0);
189 TH1D* digiMaxSpectrum =
190 new TH1D(
"digiMaxSpectrum",
"digiMaxSpectrum", 10000, 0, 1e-4);
191 TH1D* digiSpectrum =
new TH1D(
"digiSpectrum",
"digiSpectrum", 10000, 0, 1e-4);
193 LOG(info) <<
"CbmTrdRecoQa::Exec : MC-Points:" << nPoints;
194 LOG(info) <<
"CbmTrdRecoQa::Exec : Digis: " << nDigis;
195 LOG(info) <<
"CbmTrdRecoQa::Exec : Cluster: " << nClusters;
196 LOG(info) <<
"CbmTrdRecoQa::Exec : Hits: " << nHits;
197 Int_t moduleAddress(-1), moduleId(-1);
202 Int_t pointCounter = 0;
203 for (Int_t iPoint = 0; iPoint < nPoints; iPoint++) {
208 gGeoManager->FindNode(
209 (out[0] + in[0]) / 2, (out[1] + in[1]) / 2, (out[2] + in[2]) / 2);
210 if (!TString(gGeoManager->GetPath()).Contains(
"gas")) {
211 LOG(error) <<
"CbmTrdRecoQa::Exec: MC-track not in TRD! Node:"
212 << TString(gGeoManager->GetPath()).Data()
213 <<
" gGeoManager->MasterToLocal() failed!";
224 std::map<Int_t, TGraphErrors*>::iterator it =
227 name.Form(
"ModuleAddress%05i", moduleAddress);
228 fModuleMap[moduleAddress] =
new TCanvas(name, name, 1000, 1000);
236 TH2I* dummy =
new TH2I(name,
244 dummy->SetStats(kFALSE);
245 name.Form(
"ModuleAddress%05iDigis", moduleAddress);
257 name.Form(
"ModuleAddress%05iClusters", moduleAddress);
269 name.Form(
"ModuleAddress%05iHits", moduleAddress);
287 Double_t local_in[3];
288 Double_t local_out[3];
289 gGeoManager->MasterToLocal(in, local_in);
290 gGeoManager->MasterToLocal(out, local_out);
292 for (Int_t
i = 0;
i < 3;
i++)
300 Int_t row_in(0), row_out(0), col_in(0), col_out(0), sec_in(0), sec_out(0);
301 Double_t x_in(0), y_in(0), x_out(0), y_out(0);
304 if ((sec_in < 0) || (sec_in > 2)) {
305 cout <<
"sec_in:" << sec_in << endl;
312 if ((sec_out < 0) || (sec_out > 2)) {
313 cout <<
"sec_out:" << sec_out << endl;
333 ((col_in + x_in / W_in) + (col_out + x_out / W_out)) / 2.,
334 ((row_in + y_in / H_in) + (row_out + y_out / H_out)) / 2.);
337 TLine* l =
new TLine(col_in + x_in / W_in,
338 row_in + y_in / H_in,
339 col_out + x_out / W_out,
340 row_out + y_out / H_out);
355 printf(
"Address:%i ID:%i\n", moduleAddress, moduleId);
366 for (Int_t iDigi = 0; iDigi < nDigis; iDigi++) {
380 Int_t lastModule(0), iCounter(0);
381 for (Int_t iCluster = 0; iCluster < nClusters; iCluster++) {
382 Double_t charge(0), chargeMax(0);
386 for (Int_t iDigi = 0; iDigi < nDigisInCluster; iDigi++) {
392 if (iDigi == 0 && lastModule != moduleAddress) {
394 lastModule = moduleAddress;
406 if (charge > chargeMax) chargeMax = charge;
408 digiMaxSpectrum->Fill(chargeMax);
413 for (Int_t iHit = 0; iHit < nHits; iHit++) {
425 gGeoManager->FindNode(
pos[0],
pos[1],
pos[2] - 0.3);
426 Double_t local_pos[3];
427 gGeoManager->MasterToLocal(
pos, local_pos);
428 Int_t sec(-1), col(-1), row(-1);
431 Double_t
x(-1),
y(-1);
436 fModuleMapHit[moduleAddress]->SetPoint(modHit, col +
x / W, row +
y / H);
438 if (hit->
GetDx() <= W)
446 gDirectory->mkdir(
"TrdRecoQA");
447 gDirectory->cd(
"TrdRecoQA");
448 digiMaxSpectrum->Write(
"", TObject::kOverwrite);
449 digiSpectrum->Write(
"", TObject::kOverwrite);
450 map<Int_t, TCanvas*>::iterator it;
456 TPaveText* ptext =
new TPaveText(10, 3.5, 11, 4.0);
457 ptext->SetTextSize(0.035);
458 ptext->SetTextColor(15);
459 ptext->SetFillStyle(0);
460 ptext->SetLineColor(0);
461 ptext->AddText(name);
467 it->second->cd(1)->Update();
473 TPolyLine* pad = NULL;
476 const Double_t max_Range =
fModuleMapDigi[it->first]->GetBinContent(
478 for (Int_t iRow = 1; iRow <= nRow; iRow++) {
479 for (Int_t iCol = 1; iCol <= nCol; iCol++) {
485 iCol - 1, iRow - 1, charge, 0.0, max_Range,
false);
488 iCol - 1, iRow - 1, charge, 0.0, max_Range,
false);
528 TPolyLine* pad = NULL;
533 for (Int_t iRow = 1; iRow <= nRow; iRow++) {
534 for (Int_t iCol = 1; iCol <= nCol; iCol++) {
540 iCol - 1, iRow - 1, clusterId, 0, max_Range,
false);
543 iCol - 1, iRow - 1, clusterId, 0.0, max_Range,
false);
551 it->second->cd(3)->Update();
564 TPaveText* text =
new TPaveText(10, 2.0, 11, 2.5);
565 text->SetFillStyle(0);
566 text->SetLineColor(0);
567 text->SetTextSize(0.035);
569 TMultiGraph* mg =
new TMultiGraph();
578 mg->GetXaxis()->SetLimits(
584 it->second->Update();
585 it->second->SaveAs(
"pics/" + (TString)(it->second->GetName()) +
".png");
586 it->second->Write(
"", TObject::kOverwrite);
589 gDirectory->cd(
"..");
591 Double_t rtime = timer.RealTime();
592 Double_t ctime = timer.CpuTime();
594 printf(
"\n\n******************** Reading Test **********************\n");
595 printf(
" RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime);
596 printf(
"*********************************************************\n\n");