10 #include <klm/modules/KLMDQM/KLMDQMModule.h>
13 #include <klm/dataobjects/KLMChannelIndex.h>
14 #include <klm/dataobjects/KLMDigitRaw.h>
17 #include <TDirectory.h>
25 m_DAQInclusion{nullptr},
27 m_TimeScintillatorBKLM{nullptr},
28 m_TimeScintillatorEKLM{nullptr},
29 m_PlaneBKLMPhi{nullptr},
30 m_PlaneBKLMZ{nullptr},
32 m_MaskedChannelsPerSector{nullptr},
35 m_DigitsScintillatorBKLM{nullptr},
36 m_DigitsScintillatorEKLM{nullptr},
37 m_DigitsMultiStripBKLM{nullptr},
38 m_DigitsMultiStripEKLM{nullptr},
39 m_TriggerBitsBKLM{nullptr},
40 m_TriggerBitsEKLM{nullptr},
41 m_DigitsAfterLERInj{nullptr},
42 m_TriggersLERInj{nullptr},
43 m_DigitsAfterHERInj{nullptr},
44 m_TriggersHERInj{nullptr},
53 "Directory for KLM DQM histograms in ROOT file.",
56 "Min time for RPC time histogram.",
double(-1223.5));
58 "Max time for RPC time histogram.",
double(-199.5));
60 "Min time for BKLM scintillator time histogram.",
double(-5300));
62 "Max time for BKLM scintillator time histogram.",
double(-4300));
64 "Min time for EKLM scintillator time histogram.",
double(-5300));
66 "Max time for EKLM scintillator time histogram.",
double(-4300));
91 TDirectory* oldDirectory, *newDirectory;
92 oldDirectory = gDirectory;
96 m_DAQInclusion =
new TH1F(
"daq_inclusion",
"Is KLM included in DAQ?", 2, 0.0, 2.0);
101 m_TimeRPC->GetXaxis()->SetTitle(
"Time, ns");
103 new TH1F(
"time_scintillator_bklm",
"Scintillator hit time (BKLM)",
107 new TH1F(
"time_scintillator_eklm",
"Scintillator hit time (EKLM)",
112 "BKLM plane occupancy (#phi readout)",
116 "BKLM plane occupancy (z readout)",
119 m_PlaneEKLM =
new TH1F(
"plane_eklm",
"EKLM plane occupancy (both readouts)", 208, 0.5, 208.5);
122 int nChannelHistograms =
142 int layerIncrease = (klmSector.getSection() == 1) ? 4 : 5;
145 1 + layerIncrease, 1, 1);
149 1 + layerIncrease * 2, 1, 1);
166 for (
int j = 0; j < nHistograms; j++) {
168 "strip_hits_subdetector_" + std::to_string(klmSector.getSubdetector()) +
169 "_section_" + std::to_string(klmSector.getSection()) +
170 "_sector_" + std::to_string(klmSector.getSector()) +
171 "_" + std::to_string(j);
172 std::string title =
"Sector " + std::to_string(klmSector.getSector()) +
" -- " +
175 name.c_str(), title.c_str(),
176 firstChannelNumbers[i + 1] - firstChannelNumbers[i],
177 firstChannelNumbers[i] - 0.5, firstChannelNumbers[i + 1] - 0.5);
181 delete[] firstChannelNumbers;
186 totalSectors, -0.5, totalSectors - 0.5);
195 m_DigitsKLM =
new TH1F(
"digits_klm",
"Number of KLM digits",
197 m_DigitsKLM->GetXaxis()->SetTitle(
"Number of digits");
198 m_DigitsRPC =
new TH1F(
"digits_rpc",
"Number of RPC digits",
200 m_DigitsRPC->GetXaxis()->SetTitle(
"Number of digits");
214 m_TriggerBitsBKLM =
new TH1F(
"trigger_bits_bklm",
"Trigger bits of multi-strip digits (BKLM)",
220 m_TriggerBitsEKLM =
new TH1F(
"trigger_bits_eklm",
"Trigger bits of multi-strip digits (EKLM)",
228 m_DigitsAfterLERInj =
new TH1F(
"KLMOccInjLER",
"KLM digits after LER injection / Time;Time [#mus];Number of KLM digits / (5 #mus)",
230 m_TriggersLERInj =
new TH1F(
"KLMTrigInjLER",
"Triggers after KER injection / Time;Time [#mus];Number of triggers / (5 #mus)",
232 m_DigitsAfterHERInj =
new TH1F(
"KLMOccInjHER",
"KLM digits after HER injection / Time;Time [#mus];Number of KLM digits / (5 #mus)",
234 m_TriggersHERInj =
new TH1F(
"KLMTrigInjHER",
"Triggers after HER injection / Time;Time [#mus];Number of triggers / (5 #mus)",
245 for (
int j = 1; j <= maximalLayerNumber; ++j) {
246 std::string name =
"spatial_2d_hits_subdetector_" + std::to_string(subdetector) +
247 "_section_" + std::to_string(section) +
248 "_layer_" + std::to_string(j);
249 std::string title =
"Endcap " + sectionName +
" , Layer " + std::to_string(j);
252 340 * 2 / 10, -340, 340,
253 340 * 2 / 10, -340, 340);
298 for (
int j = 0; j < nHistograms; j++)
322 int maximalLayerNumber =
324 for (
int j = 1; j <= maximalLayerNumber; ++j)
332 int nDigits =
m_Digits.getEntries();
333 int nDigitsRPC = 0, nDigitsScintillatorBKLM = 0, nDigitsScintillatorEKLM = 0;
334 int nDigitsMultiStripBKLM = 0, nDigitsMultiStripEKLM = 0;
343 nDigitsScintillatorEKLM++;
344 int section = digit.getSection();
345 int sector = digit.getSector();
346 int layer = digit.getLayer();
347 int plane = digit.getPlane();
348 int strip = digit.getStrip();
349 if (not digit.isMultiStrip()) {
355 double xMin =
m_ChannelHits[klmSectorIndex][j]->GetXaxis()->GetXmin();
356 double xMax =
m_ChannelHits[klmSectorIndex][j]->GetXaxis()->GetXmax();
357 if ((xMin > channelIndex) || (xMax < channelIndex))
362 nDigitsMultiStripEKLM++;
366 if (digit.isMultiStrip()) {
370 if ((triggerBits & 0x1) != 0)
372 if ((triggerBits & 0x2) != 0)
374 if ((triggerBits & 0x4) != 0)
376 if ((triggerBits & 0x8) != 0)
381 int section = digit.getSection();
382 int sector = digit.getSector();
383 int layer = digit.getLayer();
384 int plane = digit.getPlane();
385 int strip = digit.getStrip();
386 if (not digit.isMultiStrip()) {
392 double xMin =
m_ChannelHits[klmSectorIndex][j]->GetXaxis()->GetXmin();
393 double xMax =
m_ChannelHits[klmSectorIndex][j]->GetXaxis()->GetXmax();
394 if ((xMin > channelIndex) || (xMax < channelIndex))
399 nDigitsMultiStripBKLM++;
404 nDigitsScintillatorBKLM++;
407 if (digit.isMultiStrip()) {
411 if ((triggerBits & 0x1) != 0)
413 if ((triggerBits & 0x2) != 0)
415 if ((triggerBits & 0x4) != 0)
417 if ((triggerBits & 0x8) != 0)
422 B2FATAL(
"Not a BKLM or a EKLM digit, something went really wrong.");
425 int section = hit1d.getSection();
426 int sector = hit1d.getSector();
427 int layer = hit1d.getLayer();
429 section, sector, layer);
430 if (hit1d.isPhiReadout())
440 if (nDigitsMultiStripBKLM > 0)
442 if (nDigitsMultiStripEKLM > 0)
446 unsigned int difference = rawFtsw.GetTimeSinceLastInjection(0);
447 if (difference != 0x7FFFFFFF) {
449 float differenceInUs = difference / 127.;
450 if (rawFtsw.GetIsHER(0)) {
468 int section = hit2d.getSection();
469 int layer = hit2d.getLayer();
470 m_Spatial2DHitsEKLM[section - 1][layer - 1]->Fill(hit2d.getPositionX(), hit2d.getPositionY());
static constexpr int getMaximalSectorGlobalNumber()
Get maximal sector global number.
static int layerGlobalNumber(int section, int sector, int layer)
Get layer global number.
Store one reconstructed BKLM 1D hit as a ROOT object.
int getMaximalDetectorLayerNumber(int section) const
Get maximal detector layer number.
@ c_ForwardSection
Forward.
int planeNumber(int section, int layer, int sector, int plane) const
Get plane number.
static constexpr int getMaximalSectorGlobalNumberKLMOrder()
Get maximal sector global number with KLM ordering (section, sector).
HistoModule.h is supposed to be used instead of Module.h for the modules with histogram definitions t...
int getSection() const
Get section.
int getSector() const
Get sector.
@ c_IndexLevelSection
Section.
@ c_IndexLevelSector
Sector.
@ c_IndexLevelStrip
Strip.
KLMChannelNumber getKLMChannelNumber() const
Get KLM channel number.
void setIndexLevel(enum IndexLevel indexLevel)
Set index level.
double m_BKLMScintTimeMin
Min time for BKLM Scint.
TH1F * m_DigitsMultiStripEKLM
Number of multi-strip digits: EKLM scintillators.
StoreArray< RawFTSW > m_RawFtsws
Raw FTSW.
const int m_ChannelHitHistogramsEKLM
Number of channel hit histograms per sector for EKLM.
TH1F * m_PlaneBKLMPhi
Plane occupancy: BKLM, phi readout.
TH1F * m_TriggerBitsBKLM
Trigger bits: BKLM scintillators.
~KLMDQMModule()
Destructor.
TH1F * m_TimeScintillatorEKLM
Time: EKLM scintillators.
double m_RPCTimeMax
Max time for RPC.
StoreArray< KLMDigit > m_Digits
KLM digits.
double m_RPCTimeMin
Min time for RPC.
void initialize() override
Initializer.
TH1F * m_DigitsScintillatorEKLM
Number of digits: EKLM scintillators.
TH1F ** m_ChannelHits[EKLMElementNumbers::getMaximalSectorGlobalNumberKLMOrder()+BKLMElementNumbers::getMaximalSectorGlobalNumber()]
Number of hits per channel.
TH1F * m_TimeRPC
Time: BKLM RPCs.
TH1F * m_DigitsKLM
Number of digits: whole KLM.
void event() override
This method is called for each event.
const KLMElementNumbers * m_ElementNumbers
KLM element numbers.
KLMDQMModule()
Constructor.
double m_EKLMScintTimeMax
Max time for EKLM Scint.
const int m_ChannelHitHistogramsBKLM
Number of channel hit histograms per sector for BKLM.
TH1F * m_TriggerBitsEKLM
Trigger bits: EKLM scintillators.
void endRun() override
This method is called if the current run ends.
const EKLMElementNumbers * m_eklmElementNumbers
Element numbers.
double m_BKLMScintTimeMax
Max time for BKLM Scint.
void terminate() override
This method is called at the end of the event processing.
TH1F * m_PlaneBKLMZ
Plane occupancy: BKLM, z readout.
TH1F * m_TimeScintillatorBKLM
Time: BKLM scintillators.
TH1F * m_DigitsRPC
Number of digits: BKLM RPCs.
TH1F * m_TriggersHERInj
Histogram to be used for normalization of occupancy after HER injection.
void beginRun() override
Called when entering a new run.
TH1F * m_DigitsAfterHERInj
Number of KLM Digits after LER injection.
TH1F * m_DigitsScintillatorBKLM
Number of digits: BKLM scintillators.
TH1F * m_TriggersLERInj
Histogram to be used for normalization of occupancy after LER injection.
TH1F * m_DigitsMultiStripBKLM
Number of multi-strip digits: BKLM scintillators.
const KLMSectorArrayIndex * m_SectorArrayIndex
KLM sector array index.
StoreArray< BKLMHit1d > m_BklmHit1ds
BKLM 1d hits.
TH1F * m_DigitsAfterLERInj
Number of KLM Digits after LER injection.
TH1F * m_DAQInclusion
KLM DAQ inclusion.
StoreArray< RawKLM > m_RawKlms
Raw KLM.
TH1F * m_PlaneEKLM
Plane occupancy: EKLM.
TH2F ** m_Spatial2DHitsEKLM[EKLMElementNumbers::getMaximalSectionNumber()]
Spatial distribution of EKLM 2d hits per layer.
TH1F * m_MaskedChannelsPerSector
Masked channels per sector.
double m_EKLMScintTimeMin
Min time for EKLM Scint.
const KLMChannelArrayIndex * m_ChannelArrayIndex
KLM channel array index.
std::string m_HistogramDirectoryName
Directory for KLM DQM histograms in ROOT file.
void defineHisto() override
Definition of the histograms.
StoreArray< KLMHit2d > m_Hit2ds
KLM 2d hits.
Class to store the raw words from the unpacker, digit-by-digit.
uint16_t getTriggerBits()
Get trigger bits.
KLM digit (class representing a digitized hit in RPCs or scintillators).
uint16_t getNElements() const
Get number of elements.
uint16_t getIndex(uint16_t number) const
Get element index.
KLMSectorNumber sectorNumberEKLM(int section, int sector) const
Get sector number for EKLM.
KLMChannelNumber channelNumberBKLM(int section, int sector, int layer, int plane, int strip) const
Get channel number for BKLM.
KLMSectorNumber sectorNumberBKLM(int section, int sector) const
Get sector number for BKLM.
std::string getSectorDAQName(int subdetector, int section, int sector) const
Get DAQ name for a given sector.
KLMChannelNumber channelNumberEKLM(int section, int sector, int layer, int plane, int strip) const
Get channel number for EKLM.
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
T * getRelated(const std::string &name="", const std::string &namedRelation="") const
Get the object to or from which this object has a relation.
REG_MODULE(arichBtest)
Register the Module.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
uint16_t KLMSectorNumber
Sector number.
uint16_t KLMChannelNumber
Channel number.
uint16_t KLMSubdetectorNumber
Subdetector number.
uint16_t KLMSectionNumber
Section number.
Abstract base class for different kinds of events.