12 #include <FairRootManager.h>
13 #include <FairRunAna.h>
14 #include <FairRuntimeDb.h>
19 #include <TClonesArray.h>
23 #include <TGeoManager.h>
27 #include <TPaveText.h>
29 #include <TProfile2D.h>
30 #include <TStopwatch.h>
48 Double_t triggerThreshold,
49 Bool_t plotMergedResults)
55 , fDigiChargeSpectrum(
56 new TH1I(
"DigiChargeSpectrum",
"DigiChargeSpectrum", 1e6, 0, 1.0e-3))
57 , fLayerDummy(new TH2I(
"LayerDummy",
"", 1200, -400, 400, 1000, -300, 300))
62 , fModuleOccupancyMap()
63 , fModuleOccupancyMapIt()
64 , fModuleOccupancyMemoryMap()
65 , fModuleOccupancyMemoryMapIt()
66 , fLayerOccupancyMap()
67 , fLayerOccupancyMapIt()
68 , fLayerAverageOccupancyMap()
69 , fLayerAverageOccupancyMapIt()
70 , fTriggerThreshold(triggerThreshold)
71 , fNeigbourReadout(true)
72 , fPlotMergedResults(plotMergedResults)
96 FairRootManager* ioman = FairRootManager::Instance();
133 cout <<
" * CbmTrdOccupancyQa * :: SetParContainers() " << endl;
135 FairRunAna* ana = FairRunAna::Instance();
136 FairRuntimeDb* rtdb = ana->GetRuntimeDb();
142 cout <<
" * CbmTrdClusterizer * :: ReInit() " << endl;
143 FairRunAna* ana = FairRunAna::Instance();
144 FairRuntimeDb* rtdb = ana->GetRuntimeDb();
153 cout <<
" * CbmTrdOccupancyQa * :: Init() " << endl;
154 FairRootManager* ioman = FairRootManager::Instance();
159 fClusters = (TClonesArray*) ioman->GetObject(
"TrdCluster");
161 cout <<
"-W CbmTrdHitDensityQa::Init: No TrdCluster array!" << endl;
162 cout <<
" Task will be inactive" << endl;
176 printf(
"================CbmTrdOccupancyQa=====================\n");
185 Int_t digiCounter(0), digiTriggerCounter(0);
198 Int_t nCluster =
fClusters->GetEntries();
199 for (Int_t iCluster = 0; iCluster < nCluster; iCluster++) {
204 for (Int_t iDigi = 0; iDigi < nDigisInCluster; iDigi++) {
209 digiTriggerCounter++;
219 Int_t combiId = 10 * Station + Layer;
228 title.Form(
"Module_%i", moduleAddress);
232 title, title, nCols, -0.5, nCols - 0.5, nRows, -0.5, nRows - 0.5);
234 title.Form(
"M_%i", moduleAddress);
236 new TH1F(title, title, 10000, 0, 100);
244 fModuleMap[moduleAddress]->moduleAddress = moduleAddress;
248 title.Form(
"S%i_L%i", Station, Layer);
249 printf(
" new %s\n", title.Data());
254 title.Form(
"Station%i_Layer%i", Station, Layer);
255 printf(
" new %s\n", title.Data());
257 new TProfile(title, title, 1e6, 0, 1.0e-3);
259 "Average layer occupancy [%]");
267 Int_t ixBin(iCol + 1), iyBin(iRow + 1);
274 for (Int_t iDigi = 0; iDigi < nEntries; iDigi++) {
284 Int_t combiId = 10 * Station + Layer;
294 digiTriggerCounter++;
298 title.Form(
"Module_%i", moduleAddress);
302 title, title, nCols, -0.5, nCols - 0.5, nRows, -0.5, nRows - 0.5);
304 title.Form(
"M_%i", moduleAddress);
306 new TH1F(title, title, 10000, 0, 100);
314 fModuleMap[moduleAddress]->moduleAddress = moduleAddress;
317 title.Form(
"S%i_L%i", Station, Layer);
318 printf(
" new %s\n", title.Data());
323 title.Form(
"Station%i_Layer%i", Station, Layer);
324 printf(
" new %s\n", title.Data());
326 new TProfile(title, title, 1e6, 0, 1.0e-3);
328 "Average layer occupancy [%]");
337 Int_t ixBin(iCol + 1), iyBin(iRow + 1);
370 "%6i primary triggered digis\n%6i including neigbouring triggered digis\n",
377 Double_t rtime = timer.RealTime();
378 Double_t ctime = timer.CpuTime();
380 printf(
"\n\n******************** Reading Test **********************\n");
381 printf(
" RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime);
382 printf(
"*********************************************************\n\n");
426 TString filename =
"data/result.root";
427 TFile* Target =
new TFile(filename,
"READ");
429 gDirectory = Target->CurrentDirectory();
434 std::cout << histName << std::endl;
437 (TH2I*) Target->Get(
"TrdOccupancy/Module/" + histName)
438 ->Clone(histName +
"_result");
441 cout <<
"No merged data/result.root found" << endl;
446 TString origpath = gDirectory->GetPath();
447 printf(
"\n%s\n", origpath.Data());
448 TString newpath = origpath;
449 newpath.ReplaceAll(
"eds",
"oc_qa");
450 newpath.ReplaceAll(
":/",
"");
452 TFile* tempFile =
new TFile(newpath,
"recreate");
453 gDirectory = tempFile->CurrentDirectory();
455 cout <<
"CreateLayerView" << endl;
456 Bool_t debug =
false;
477 if (debug) printf(
" <O>:%6.2f ", occupancy);
478 title.Form(
"%.1f#pm%.1f%%", occupancy, occupancyE);
479 if (debug) printf(
"%s\n", title.Data());
480 TPaveText* text =
new TPaveText(
489 text->SetFillStyle(1001);
490 text->SetLineColor(1);
493 std::vector<Int_t> fColors;
494 std::vector<Double_t> fZLevel;
495 for (Int_t
i = 0;
i < TColor::GetNumberOfColors();
i++) {
496 fColors.push_back(TColor::GetColorPalette(
i));
499 fmin + (
fmax / TColor::GetNumberOfColors() *
i));
503 while ((occupancy > fZLevel[j]) && (j < (Int_t) fZLevel.size())) {
507 text->SetFillColor(fColors[j]);
508 if (j >= (Int_t) fZLevel.size()) text->SetFillColor(2);
510 if (fColors[j] < 65) text->SetTextColor(kWhite);
578 text->AddText(title);
583 TDirectoryFile* TopLayerDir;
584 gDirectory->GetObject(
"Occupancy", TopLayerDir);
586 std::cout <<
"unknown Directory Occupancy" << std::endl;
587 gDirectory->mkdir(
"Occupancy");
588 gDirectory->GetObject(
"Occupancy", TopLayerDir);
592 TDirectoryFile* Triggerdir;
594 gDirectory->GetObject(title, Triggerdir);
596 std::cout <<
"unknown Directory Trigger Dir" << std::endl;
597 gDirectory->mkdir(title);
598 gDirectory->GetObject(title, Triggerdir);
606 title.Form(
"pics/Occupancy_%.2E_%s_%s.pdf",
611 title.Form(
"pics/Occupancy_%.2E_%s_%s.png",
617 gDirectory->Cd(
"..");
618 TCanvas* c =
new TCanvas(
"c",
"c", 800, 600);
643 gDirectory->Cd(
"..");
647 gDirectory->Cd(origpath);
657 TString origpath = gDirectory->GetPath();
658 printf(
"\n%s\n", origpath.Data());
659 TString newpath = origpath;
660 newpath.ReplaceAll(
"eds",
"oc_qa");
661 newpath.ReplaceAll(
":/",
"");
663 TFile* tempFile =
new TFile(newpath,
"Update");
664 gDirectory = tempFile->CurrentDirectory();
667 cout <<
"SaveHistos2File" << endl;
674 TDirectoryFile* Basedir;
675 gDirectory->GetObject(
"TrdOccupancy", Basedir);
677 gDirectory->mkdir(
"TrdOccupancy");
678 std::cout <<
"unknown Directory Basedir" << std::endl;
679 gDirectory->GetObject(
"TrdOccupancy", Basedir);
702 TDirectoryFile* Moduledir;
703 gDirectory->GetObject(
"Module1D", Moduledir);
705 gDirectory->mkdir(
"Module1D");
706 std::cout <<
"unknown Directory Module1D" << std::endl;
707 gDirectory->GetObject(
"Module1D", Moduledir);
717 gDirectory->Cd(
"..");
718 gDirectory->Cd(
"..");
722 gDirectory->Cd(origpath);