10#include <klm/bklm/modules/bklmDigitAnalyzer/BKLMDigitAnalyzerModule.h>
13#include <framework/datastore/StoreObjPtr.h>
14#include <framework/dataobjects/EventMetaData.h>
27 m_outputRootFile(nullptr),
30 for (
int i = 0; i < 2; ++i) {
34 for (
int s = 0; s < 8; ++s) {
36 for (
int p = 0; p < 2; ++p) {
46 setDescription(
"Module useful to quickly analyze BKLM unpacked data.");
49 addParam(
"outputRootName",
m_outputRootName,
"Name of output .root file (without .root!)", std::string(
"bklmHitmap"));
69 struct tm* tm = gmtime(&rawTime);
77 outputRootNameTString +=
"_run" + runNumberTString +
".root";
79 const TString label[2] = {
"BF",
"BB"};
82 B2INFO(
"BKLMDigitAnalyzer:: the output file '" << outputRootNameTString.Data() <<
"' will be created for run " <<
m_runNumber);
92 m_extraInfo =
new TTree(
"extraInfo",
"Extra information");
101 exp = eventMetaData->getExperiment();
103 year = tm->tm_year + 1900;
104 month = tm->tm_mon + 1;
113 for (
int fb = 0; fb < 2; fb++) {
116 "Layer (0-based)", 17, -0.5, 8.,
"BF Sector", 0,
m_histoList);
118 for (
int isRPCorPhi = 0; isRPCorPhi < 2; isRPCorPhi++) {
122 label[fb] +
" Hitmap of plane z -- run" + runNumberTString, 31, -0.5, 15.,
"Layer (0-based)", 17, -0.5, 8.,
"BF Sector", 0,
126 label[fb] +
" Hitmap of plane phi -- run" + runNumberTString, 31, -0.5, 15.,
"Layer (0-based)", 17, -0.5, 8.,
"BF Sector", 0,
129 for (
int iSector = 0; iSector < 8; iSector++) {
131 TString iSectorTString(
toString(iSector).c_str());
132 TString nameSector = label[fb] + iSectorTString;
134 if (isRPCorPhi == 0) {
137 m_histoLayer[fb][iSector] =
createTH1(
"Layer" + nameSector, nameSector +
" Layer -- run" + runNumberTString, 31, -0.5, 15.,
141 nameSector +
" Plane z, electronic channels -- run" + runNumberTString, 31,
142 -0.5, 15.,
"Layer (0-based)", 130, -0.5, 64.5,
"Channel", 1,
m_histoList);
145 nameSector +
" Plane z, strips -- run" + runNumberTString,
146 31, -0.5, 15.,
"Layer (0-based)", 130, -0.5, 64.5,
"Strip", 1,
m_histoList);
149 nameSector +
" TDC (Scintillators) -- run" + runNumberTString, 60, 0, 30,
"TDC",
"Counts", 1,
m_histoList);
152 nameSector +
" CTime diff. (Scintillators) -- run" + runNumberTString, 200, -200, -100,
"Sci_CTime - Trg_CTime [ns]",
"Counts", 1,
158 nameSector +
" Plane phi, electronic channels -- run" + runNumberTString,
159 31, -0.5, 15.,
"Layer (0-based)", 130, -0.5, 64.5,
"Channel", 1,
m_histoList);
162 nameSector +
" Plane phi, strips -- run" + runNumberTString,
163 31, -0.5, 15.,
"Layer (0-based)", 130, -0.5, 64.5,
"Strip", 1,
m_histoList);
165 m_histoTdc[fb][iSector][isRPCorPhi] =
createTH1(
"RPCTdc" + nameSector, nameSector +
" TDC (RPCs) -- run" + runNumberTString, 230,
169 nameSector +
" CTime diff. (RPCs) -- run" + runNumberTString, 350, -3000, 500,
"RPC_CTime - Trg_CTime [ns]",
"Counts", 1,
185 B2WARNING(
"BKLMDigitAnalyzer:: the total number of BKLMDigit differs from the sum of RPC and scintillator hits stored in BKLMEventDigitDebug!");
187 B2WARNING(
"BKLMDigitAnalyzer:: the total number of BKLMDigit differs from the number of outOfRange-flagged hits stored in BKLMEventDigitDebug!");
195 m_histoLayerVsSector[1 - digit.getSection()]->Fill(digit.getLayer() - 1, digit.getSector() - 1);
199 m_histoLayer[1 - digit.getSection()][digit.getSector() - 1]->Fill(digit.getLayer() - 1);
201 m_histoChannel[1 - digit.getSection()][digit.getSector() - 1][digit.isPhiReadout()]->Fill(digit.getLayer() - 1,
204 m_histoStrip[1 - digit.getSection()][digit.getSector() - 1][digit.isPhiReadout()]->Fill(digit.getLayer() - 1,
205 digit.getStrip() - 1);
208 m_histoTdc[1 - digit.getSection()][digit.getSector() - 1][digit.inRPC()]->Fill(digit.getTime());
210 m_histoCTimeDiff[1 - digit.getSection()][digit.getSector() - 1][digit.inRPC()]->Fill(digit.getCTime() -
229 while ((obj = nextHisto()))
230 obj->Write(
"", TObject::kWriteDelete);
240 const char* titleX,
const char* titleY,
bool drawStat, TList* histoList)
242 TH1F* hist =
new TH1F(name, title, nbinsX, minX, maxX);
243 hist->GetXaxis()->SetTitle(titleX);
244 hist->GetYaxis()->SetTitle(titleY);
245 TGaxis::SetMaxDigits(3);
246 hist->SetLineWidth(1);
247 hist->SetLineColor(kRed);
251 histoList->Add(hist);
256 const char* titleX, Int_t nbinsY, Double_t minY, Double_t maxY,
const char* titleY,
bool drawStat, TList* histoList)
258 TH2F* hist =
new TH2F(name, title, nbinsX, minX, maxX, nbinsY, minY, maxY);
259 hist->GetXaxis()->SetTitle(titleX);
260 hist->GetYaxis()->SetTitle(titleY);
261 TGaxis::SetMaxDigits(3);
265 histoList->Add(hist);
int m_runNumber
Run number of the current data set.
TH2F * m_histoLayerVsSector[2]
Pointer to occupancy 2D histograms (numerator, denominator) of layer vs sector.
BKLMDigitAnalyzerModule()
Constructor.
void initialize() override
Initializer.
void event() override
This method is called for each event.
void endRun() override
This method is called if the current run ends.
TFile * m_outputRootFile
Pointer to ROOT output file.
void terminate() override
This method is called at the end of the event processing.
StoreArray< KLMDigitEventInfo > m_digitEventInfo
Output data array of analyzed KLMDigit information.
TH2F * createTH2(const char *name, const char *title, Int_t nBinsX, Double_t minX, Double_t maxX, const char *titleX, Int_t nBinsY, Double_t minY, Double_t maxY, const char *titleY, bool drawStat, TList *histoList=nullptr)
Create a ROOT 2D histogram.
TH1F * m_histoLayer[2][8]
Pointer to occupancy 1D histogram of each layer for each sector.
StoreArray< KLMDigit > m_digitOutOfRange
Input BKLMDigits whose time is out of range.
TH1F * createTH1(const char *name, const char *title, Int_t nBinsX, Double_t minX, Double_t maxX, const char *titleX, const char *titleY, bool drawStat, TList *histoList=nullptr)
Create a ROOT 1D histogram.
void beginRun() override
Called when entering a new run.
StoreArray< KLMDigit > m_digit
Input KLMDigits.
~BKLMDigitAnalyzerModule() override
Destructor.
TH2F * m_histoChannel[2][8][2]
Pointer to occupancy 2D histogram of each channel.
TList * m_histoList
Pointer to ROOT list of histograms.
TH2F * m_histoLayerVsSectorPerPlane[2][2]
Pointer to occupancy 2D histogram of layer vs sector for each view (=plane)
TH1F * m_histoTdc[2][8][2]
Pointer to TDC 1D histogram of each channel for each sector and view.
TH2F * m_histoStrip[2][8][2]
Pointer to occupancy 2D histogram of each strip.
std::string toString(T val)
Convert a number of type T into a string.
std::string m_outputRootName
Output filename.
TH1F * m_histoCTimeDiff[2][8][2]
Pointer to TDC-difference 1D histogram of each channel for each sector and view.
TTree * m_extraInfo
Pointer to ROOT tree with extra info.
StoreArray< KLMDigitRaw > m_digitRaw
Input raw BLMDigits.
@ c_Event
Different object in each event, all objects/arrays are invalidated after event() function has been ca...
Class to store debugging information from the unpacker (event based).
int getRPCHits() const
Returns the number of RPC hits in the event.
int getIntTriggerCTime() const
Returns trigger CTIME as int.
int getOutOfRangeHits() const
Returns the number of OutOfRange-flagged hits in the event.
int getSciHits() const
Returns the number of scintillator hits in the event.
Class to store the raw words from the unpacker, digit-by-digit.
uint16_t getChannel() const
Get the channel number.
KLM digit (class representing a digitized hit in RPCs or scintillators).
void setDescription(const std::string &description)
Sets the description of the module.
TO * getRelatedTo(const std::string &name="", const std::string &namedRelation="") const
Get the object to which this object has a relation.
RelationVector< FROM > getRelationsFrom(const std::string &name="", const std::string &namedRelation="") const
Get the relations that point from another store array to this object.
RelationVector< TO > getRelationsTo(const std::string &name="", const std::string &namedRelation="") const
Get the relations that point from this object to another store array.
Type-safe access to single objects in the data store.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.