10 #include <klm/dataobjects/KLMChannelArrayIndex.h>
11 #include <klm/dataobjects/KLMChannelIndex.h>
12 #include <klm/dataobjects/KLMElementNumbers.h>
13 #include <klm/dataobjects/KLMSectorArrayIndex.h>
16 #include <framework/logging/Logger.h>
30 int main(
int argc,
char* argv[])
33 if (argc == 1 or std::string(argv[1]) ==
"--help" or std::string(argv[1]) ==
"-h") {
34 std::cout <<
"Usage: " << argv[0] <<
" [INPUT_FILE] [CHANNEL1] [CHANNEL2] ... [CHANNELN]\n\n"
35 " This tool masks the given channels of the KLM DQM reference plots stored\n"
36 " in the given input file (here 'channel' means 'channel number').\n\n"
37 " The plots on which this tool acts are:\n"
38 " KLM/masked_channels;\n"
39 " KLM/strip_hits_subdetector_<X>_section_<Y>_sector_<W>_<Z>.\n\n"
40 " This tool is not intended to be run standalone, since it is executed\n"
41 " by 'b2klm-mask-dqm', which automatically detects the channels to be masked.\n";
45 int nChannels = argc - 2;
47 B2ERROR(
"There are no channels to mask!");
50 std::string inputFileName(argv[1]);
51 if (inputFileName.find(
".root") == std::string::npos) {
52 B2ERROR(
"The input file is not a .root file!");
55 if (gSystem->AccessPathName(inputFileName.c_str())) {
56 B2ERROR(
"The input file does not exist!");
59 TFile* inputFile =
new TFile(inputFileName.c_str(),
"UPDATE");
60 if (!inputFile or inputFile->IsZombie()) {
61 B2ERROR(
"The input file is not working!");
69 TH1* histoSummary = (TH1*)inputFile->Get(
"KLM/masked_channels");
71 B2ERROR(
"The histogram KLM/masked_channels is not found!");
74 for (
int i = 2; i <= nChannels + 1; ++i) {
76 int subdetector, section, sector, layer, plane, strip;
78 channelNumber, &subdetector, §ion, §or, &layer, &plane, &strip);
86 for (
int j = 0; j < nHistoOccupancy; ++j) {
87 std::string histoOccupancyName =
"KLM/strip_hits_subdetector_" + std::to_string(subdetector) +
88 "_section_" + std::to_string(section) +
89 "_sector_" + std::to_string(sector) +
90 "_" + std::to_string(j);
91 TH1* histoOccupancy = (TH1*)inputFile->Get(histoOccupancyName.c_str());
92 if (!histoOccupancy) {
93 B2ERROR(
"The histogram " << histoOccupancyName <<
" is not found!");
96 TAxis* xAxis = histoOccupancy->GetXaxis();
97 double xMin = xAxis->GetXmin();
98 double xMax = xAxis->GetXmax();
99 if ((channelIndex >= xMin) and (channelIndex < xMax)) {
100 int bin = xAxis->FindBin(channelIndex);
101 histoOccupancy->SetBinContent(bin, 0);
102 inputFile->Write(
"", TObject::kOverwrite);
111 uint16_t sectorIndex = sectorArrayIndex->
getIndex(sectorNumber);
112 histoSummary->Fill(sectorIndex);
114 inputFile->Write(
"", TObject::kOverwrite);
117 B2INFO(
"Masking complete: the reference file " << inputFileName <<
" is now ready.");
static const KLMChannelArrayIndex & Instance()
Instantiation.
uint16_t getIndex(uint16_t number) const
Get element index.
KLMSectorNumber sectorNumberEKLM(int section, int sector) const
Get sector number for EKLM.
static const KLMElementNumbers & Instance()
Instantiation.
void channelNumberToElementNumbers(KLMChannelNumber channel, int *subdetector, int *section, int *sector, int *layer, int *plane, int *strip) const
Get element numbers by channel number.
KLMSectorNumber sectorNumberBKLM(int section, int sector) const
Get sector number for BKLM.
static const KLMSectorArrayIndex & Instance()
Instantiation.
uint16_t KLMSectorNumber
Sector number.
uint16_t KLMChannelNumber
Channel number.
Abstract base class for different kinds of events.
int main(int argc, char **argv)
Run all tests.