17#include <FairRootManager.h>
18#include <FairRunAna.h>
19#include <FairRuntimeDb.h>
23#include <TClonesArray.h>
27#include <TGeoManager.h>
33#include <TProfile2D.h>
34#include <TStopwatch.h>
48 Bool_t plotMergedResults)
54 , fDigiChargeSpectrum(new TH1I(
"DigiChargeSpectrum",
"DigiChargeSpectrum", 1e6, 0, 1.0e-3))
55 , fLayerDummy(new TH2I(
"LayerDummy",
"", 1200, -400, 400, 1000, -300, 300))
60 , fModuleOccupancyMap()
61 , fModuleOccupancyMapIt()
62 , fModuleOccupancyMemoryMap()
63 , fModuleOccupancyMemoryMapIt()
64 , fLayerOccupancyMap()
65 , fLayerOccupancyMapIt()
66 , fLayerAverageOccupancyMap()
67 , fLayerAverageOccupancyMapIt()
68 , fTriggerThreshold(triggerThreshold)
69 , fNeigbourReadout(true)
70 , fPlotMergedResults(plotMergedResults)
95 FairRootManager* ioman = FairRootManager::Instance();
129 cout <<
" * CbmTrdOccupancyQa * :: SetParContainers() " << endl;
131 FairRunAna* ana = FairRunAna::Instance();
132 FairRuntimeDb* rtdb = ana->GetRuntimeDb();
139 cout <<
" * CbmTrdClusterizer * :: ReInit() " << endl;
140 FairRunAna* ana = FairRunAna::Instance();
141 FairRuntimeDb* rtdb = ana->GetRuntimeDb();
151 cout <<
" * CbmTrdOccupancyQa * :: Init() " << endl;
152 FairRootManager* ioman = FairRootManager::Instance();
157 fClusters = (TClonesArray*) ioman->GetObject(
"TrdCluster");
159 cout <<
"-W CbmTrdHitDensityQa::Init: No TrdCluster array!" << endl;
160 cout <<
" Task will be inactive" << endl;
173 printf(
"================CbmTrdOccupancyQa=====================\n");
187 Int_t digiCounter(0), digiTriggerCounter(0);
200 Int_t nCluster =
fClusters->GetEntriesFast();
201 for (Int_t iCluster = 0; iCluster < nCluster; iCluster++) {
205 for (Int_t iDigi = 0; iDigi < nDigisInCluster; iDigi++) {
209 digiTriggerCounter++;
217 Int_t combiId = 10 * Station + Layer;
223 title.Form(
"Module_%i", moduleAddress);
227 new TH2I(title, title, nCols, -0.5, nCols - 0.5, nRows, -0.5, nRows - 0.5);
229 title.Form(
"M_%i", moduleAddress);
238 fModuleMap[moduleAddress]->moduleAddress = moduleAddress;
242 title.Form(
"S%i_L%i", Station, Layer);
243 printf(
" new %s\n", title.Data());
248 title.Form(
"Station%i_Layer%i", Station, Layer);
249 printf(
" new %s\n", title.Data());
258 Int_t ixBin(iCol + 1), iyBin(iRow + 1);
265 for (Int_t iDigi = 0; iDigi < nEntries; iDigi++) {
272 Int_t combiId = 10 * Station + Layer;
280 digiTriggerCounter++;
283 title.Form(
"Module_%i", moduleAddress);
287 new TH2I(title, title, nCols, -0.5, nCols - 0.5, nRows, -0.5, nRows - 0.5);
289 title.Form(
"M_%i", moduleAddress);
298 fModuleMap[moduleAddress]->moduleAddress = moduleAddress;
301 title.Form(
"S%i_L%i", Station, Layer);
302 printf(
" new %s\n", title.Data());
307 title.Form(
"Station%i_Layer%i", Station, Layer);
308 printf(
" new %s\n", title.Data());
317 Int_t ixBin(iCol + 1), iyBin(iRow + 1);
348 printf(
"%6i primary triggered digis\n%6i including neigbouring triggered digis\n", digiTriggerCounter, digiCounter);
353 Double_t rtime = timer.RealTime();
354 Double_t ctime = timer.CpuTime();
356 printf(
"\n\n******************** Reading Test **********************\n");
357 printf(
" RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime);
358 printf(
"*********************************************************\n\n");
402 TFile* oldFile = gFile;
403 TDirectory* oldDir = gDirectory;
405 TString filename =
"data/result.root";
406 TFile* Target =
new TFile(filename,
"READ");
411 std::cout << histName << std::endl;
414 static_cast<TH2I*
>(Target->Get<TH2I>(
"TrdOccupancy/Module/" + histName)->Clone(histName +
"_result"));
418 cout <<
"No merged data/result.root found" << endl;
430 TFile* oldFile = gFile;
431 TString origpath = gDirectory->GetPath();
432 printf(
"\n%s\n", origpath.Data());
434 TString newpath = origpath;
435 newpath.ReplaceAll(
"eds",
"oc_qa");
436 newpath.ReplaceAll(
":/",
"");
438 TFile* tempFile =
new TFile(newpath,
"recreate");
440 cout <<
"CreateLayerView" << endl;
441 Bool_t debug =
false;
461 if (debug) printf(
" <O>:%6.2f ", occupancy);
462 title.Form(
"%.1f#pm%.1f%%", occupancy, occupancyE);
463 if (debug) printf(
"%s\n", title.Data());
472 text->SetFillStyle(1001);
473 text->SetLineColor(1);
476 std::vector<Int_t> fColors;
477 std::vector<Double_t> fZLevel;
478 for (Int_t i = 0; i < TColor::GetNumberOfColors(); i++) {
479 fColors.push_back(TColor::GetColorPalette(i));
481 fZLevel.push_back(
fmin + (
fmax / TColor::GetNumberOfColors() * i));
485 while ((occupancy > fZLevel[j]) && (j < (Int_t) fZLevel.size())) {
489 text->SetFillColor(fColors[j]);
490 if (j >= (Int_t) fZLevel.size()) text->SetFillColor(2);
492 if (fColors[j] < 65) text->SetTextColor(kWhite);
559 text->AddText(title);
564 TDirectoryFile* TopLayerDir;
565 gDirectory->GetObject(
"Occupancy", TopLayerDir);
567 std::cout <<
"unknown Directory Occupancy" << std::endl;
568 gDirectory->mkdir(
"Occupancy");
569 gDirectory->GetObject(
"Occupancy", TopLayerDir);
573 TDirectoryFile* Triggerdir;
575 gDirectory->GetObject(title, Triggerdir);
577 std::cout <<
"unknown Directory Trigger Dir" << std::endl;
578 gDirectory->mkdir(title);
579 gDirectory->GetObject(title, Triggerdir);
593 gDirectory->Cd(
"..");
594 TCanvas* c =
new TCanvas(
"c",
"c", 800, 600);
618 gDirectory->Cd(
"..");
625 gDirectory->Cd(origpath);
633 TFile* oldFile = gFile;
634 TString origpath = gDirectory->GetPath();
635 printf(
"\n%s\n", origpath.Data());
637 TString newpath = origpath;
638 newpath.ReplaceAll(
"eds",
"oc_qa");
639 newpath.ReplaceAll(
":/",
"");
641 TFile* tempFile =
new TFile(newpath,
"Update");
644 cout <<
"SaveHistos2File" << endl;
651 TDirectoryFile* Basedir;
652 gDirectory->GetObject(
"TrdOccupancy", Basedir);
654 gDirectory->mkdir(
"TrdOccupancy");
655 std::cout <<
"unknown Directory Basedir" << std::endl;
656 gDirectory->GetObject(
"TrdOccupancy", Basedir);
679 TDirectoryFile* Moduledir;
680 gDirectory->GetObject(
"Module1D", Moduledir);
682 gDirectory->mkdir(
"Module1D");
683 std::cout <<
"unknown Directory Module1D" << std::endl;
684 gDirectory->GetObject(
"Module1D", Moduledir);
693 gDirectory->Cd(
"..");
694 gDirectory->Cd(
"..");
701 gDirectory->Cd(origpath);
ClassImp(CbmConverterManager)
@ kTrd
Transition Radiation Detector.
Helper class to convert unique channel ID back and forth.
Data Container for TRD clusters.
Helper class to extract information from the GeoManager.
struct OccupancyModule OccupancyModule
int32_t GetDigi(int32_t index) const
Get digi at position index.
int32_t GetNofDigis() const
Number of digis in cluster.
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.
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 GetLayerId(uint32_t address)
Return layer 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...
double GetCharge() const
Common purpose charge getter.
void Init(Bool_t isSimulation=kFALSE)
virtual ~CbmTrdOccupancyQa()
std::map< Int_t, TCanvas * >::iterator fLayerOccupancyMapIt
std::map< Int_t, OccupancyModule * >::iterator fModuleMapIt
void CopyEvent2MemoryMap()
Double_t fTriggerThreshold
Bool_t fPlotMergedResults
void SetNeighbourReadout(Bool_t neighbourReadout)
CbmTrdParSetGeo * fGeoPar
virtual void FinishEvent()
virtual void FinishTask()
std::map< Int_t, TH2I * > fModuleOccupancyMap
virtual InitStatus ReInit()
std::map< Int_t, TProfile * >::iterator fLayerAverageOccupancyMapIt
void SetTriggerThreshold(Double_t triggerthreshold)
CbmTrdParSetDigi * fDigiPar
virtual void SetParContainers()
std::map< Int_t, TH1F * > fModuleOccupancyMemoryMap
std::map< Int_t, TH1F * >::iterator fModuleOccupancyMemoryMapIt
std::map< Int_t, TH2I * >::iterator fModuleOccupancyMapIt
std::map< Int_t, OccupancyModule * > fModuleMap
virtual InitStatus Init()
TH1I * fDigiChargeSpectrum
CbmTrdGeoHandler * fGeoHandler
void SetNeighbourTrigger(Bool_t trigger)
std::map< Int_t, TProfile * > fLayerAverageOccupancyMap
virtual void Exec(Option_t *option)
void SwitchToMergedFile()
std::map< Int_t, TCanvas * > fLayerOccupancyMap
Definition of chamber gain conversion for one TRD module.
Double_t GetSizeY() const
Int_t GetNofColumns() const
Double_t GetSizeX() const
Int_t GetModuleRow(Int_t §orId, Int_t &rowId) const
Definition of geometry for one TRD module.
virtual Double_t GetY() const
virtual Double_t GetX() const
virtual void clear()
Reset all parameters.
virtual const CbmTrdParMod * GetModulePar(Int_t detId) const