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},
45 m_FE_BKLM_Layer_0(nullptr),
46 m_FE_BKLM_Layer_1(nullptr),
47 m_FE_EKLM_Plane_0(nullptr),
48 m_FE_EKLM_Plane_1(nullptr),
57 "Directory for KLM DQM histograms in ROOT file.",
60 "Min time for RPC time histogram.",
double(-1223.5));
62 "Max time for RPC time histogram.",
double(-199.5));
64 "Min time for BKLM scintillator time histogram.",
double(-5300));
66 "Max time for BKLM scintillator time histogram.",
double(-4300));
68 "Min time for EKLM scintillator time histogram.",
double(-5300));
70 "Max time for EKLM scintillator time histogram.",
double(-4300));
95 TDirectory* oldDirectory, *newDirectory;
96 oldDirectory = gDirectory;
100 m_DAQInclusion =
new TH1F(
"daq_inclusion",
"Is KLM included in DAQ?", 2, 0.0, 2.0);
105 m_TimeRPC->GetXaxis()->SetTitle(
"Time, ns");
107 new TH1F(
"time_scintillator_bklm",
"Scintillator hit time (BKLM)",
111 new TH1F(
"time_scintillator_eklm",
"Scintillator hit time (EKLM)",
116 "BKLM plane occupancy (#phi readout)",
120 "BKLM plane occupancy (z readout)",
123 m_PlaneEKLM =
new TH1F(
"plane_eklm",
"EKLM plane occupancy (both readouts)", 208, 0.5, 208.5);
126 int nChannelHistograms =
146 int layerIncrease = (klmSector.getSection() == 1) ? 4 : 5;
149 1 + layerIncrease, 1, 1);
153 1 + layerIncrease * 2, 1, 1);
170 for (
int j = 0; j < nHistograms; j++) {
172 "strip_hits_subdetector_" + std::to_string(klmSector.getSubdetector()) +
173 "_section_" + std::to_string(klmSector.getSection()) +
174 "_sector_" + std::to_string(klmSector.getSector()) +
175 "_" + std::to_string(j);
176 std::string title =
"Sector " + std::to_string(klmSector.getSector()) +
" -- " +
179 name.c_str(), title.c_str(),
180 firstChannelNumbers[i + 1] - firstChannelNumbers[i],
181 firstChannelNumbers[i] - 0.5, firstChannelNumbers[i + 1] - 0.5);
185 delete[] firstChannelNumbers;
190 totalSectors, -0.5, totalSectors - 0.5);
199 m_DigitsKLM =
new TH1F(
"digits_klm",
"Number of KLM digits",
201 m_DigitsKLM->GetXaxis()->SetTitle(
"Number of digits");
202 m_DigitsRPC =
new TH1F(
"digits_rpc",
"Number of RPC digits",
204 m_DigitsRPC->GetXaxis()->SetTitle(
"Number of digits");
218 m_TriggerBitsBKLM =
new TH1F(
"trigger_bits_bklm",
"Trigger bits of multi-strip digits (BKLM)",
224 m_TriggerBitsEKLM =
new TH1F(
"trigger_bits_eklm",
"Trigger bits of multi-strip digits (EKLM)",
232 m_DigitsAfterLERInj =
new TH1F(
"KLMOccInjLER",
"KLM digits after LER injection / Time;Time [#mus];Number of KLM digits / (5 #mus)",
234 m_TriggersLERInj =
new TH1F(
"KLMTrigInjLER",
"Triggers after KER injection / Time;Time [#mus];Number of triggers / (5 #mus)",
236 m_DigitsAfterHERInj =
new TH1F(
"KLMOccInjHER",
"KLM digits after HER injection / Time;Time [#mus];Number of KLM digits / (5 #mus)",
238 m_TriggersHERInj =
new TH1F(
"KLMTrigInjHER",
"Triggers after HER injection / Time;Time [#mus];Number of triggers / (5 #mus)",
249 for (
int j = 1; j <= maximalLayerNumber; ++j) {
250 std::string name =
"spatial_2d_hits_subdetector_" + std::to_string(subdetector) +
251 "_section_" + std::to_string(section) +
252 "_layer_" + std::to_string(j);
253 std::string title =
"Endcap " + sectionName +
" , Layer " + std::to_string(j);
256 340 * 2 / 10, -340, 340,
257 340 * 2 / 10, -340, 340);
268 "BKLM Scintillator Standard Readout;FEE Card", bklmSectors * 2, 0.5, 0.5 + bklmSectors * 2);
270 "BKLM Scintillator Feature Extraction;FEE Card", bklmSectors * 2, 0.5, 0.5 + bklmSectors * 2);
272 "EKLM Standard Readout;Plane number", eklmPlanes, 0.5, 0.5 + eklmPlanes);
274 "EKLM Feature Extraction;Plane number", eklmPlanes, 0.5, 0.5 + eklmPlanes);
314 for (
int j = 0; j < nHistograms; j++)
338 int maximalLayerNumber =
340 for (
int j = 1; j <= maximalLayerNumber; ++j)
353 int nDigits =
m_Digits.getEntries();
354 int nDigitsRPC = 0, nDigitsScintillatorBKLM = 0, nDigitsScintillatorEKLM = 0;
355 int nDigitsMultiStripBKLM = 0, nDigitsMultiStripEKLM = 0;
366 nDigitsScintillatorEKLM++;
367 int section = digit.getSection();
368 int sector = digit.getSector();
369 int layer = digit.getLayer();
370 int plane = digit.getPlane();
371 int strip = digit.getStrip();
372 if (not digit.isMultiStrip()) {
378 double xMin =
m_ChannelHits[klmSectorIndex][j]->GetXaxis()->GetXmin();
379 double xMax =
m_ChannelHits[klmSectorIndex][j]->GetXaxis()->GetXmax();
380 if ((xMin > channelIndex) || (xMax < channelIndex))
385 nDigitsMultiStripEKLM++;
389 if (digit.isMultiStrip()) {
392 if ((triggerBits & 0x1) != 0)
394 if ((triggerBits & 0x2) != 0)
396 if ((triggerBits & 0x4) != 0)
398 if ((triggerBits & 0x8) != 0)
412 int section = digit.getSection();
413 int sector = digit.getSector();
414 int layer = digit.getLayer();
415 int plane = digit.getPlane();
416 int strip = digit.getStrip();
421 if (not digit.isMultiStrip()) {
425 double xMin =
m_ChannelHits[klmSectorIndex][j]->GetXaxis()->GetXmin();
426 double xMax =
m_ChannelHits[klmSectorIndex][j]->GetXaxis()->GetXmax();
427 if ((xMin > channelIndex) || (xMax < channelIndex))
432 nDigitsMultiStripBKLM++;
437 nDigitsScintillatorBKLM++;
448 if (digit.isMultiStrip()) {
451 if ((triggerBits & 0x1) != 0)
453 if ((triggerBits & 0x2) != 0)
455 if ((triggerBits & 0x4) != 0)
457 if ((triggerBits & 0x8) != 0)
462 B2FATAL(
"Not a BKLM or a EKLM digit, something went really wrong.");
465 int section = hit1d.getSection();
466 int sector = hit1d.getSector();
467 int layer = hit1d.getLayer();
469 section, sector, layer);
470 if (hit1d.isPhiReadout())
480 if (nDigitsMultiStripBKLM > 0)
482 if (nDigitsMultiStripEKLM > 0)
486 unsigned int difference = rawFtsw.GetTimeSinceLastInjection(0);
487 if (difference != 0x7FFFFFFF) {
489 float differenceInUs = difference / 127.;
490 if (rawFtsw.GetIsHER(0)) {
508 int section = hit2d.getSection();
509 int layer = hit2d.getLayer();
510 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.
static constexpr int getMaximalPlaneGlobalNumber()
Get maximal plane global 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_FE_EKLM_Plane_1
feature extraction status 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_FE_BKLM_Layer_1
feature extraction status for BKLM Scintillator
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.
TH1F * m_FE_EKLM_Plane_0
Standard Readout status for EKLM.
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.
TH1F * m_FE_BKLM_Layer_0
Standard Readout status for BKLM Scintillator.
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.
uint16_t getFEStatus()
Get FE.
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.
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.
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.