28 vector<std::string> HltPaths_;
29 int StatusBadChannel = 1;
30 int ChannelStatus[14][16]{};
31 int N_GoodChannels = 224;
32 int EtowerLastModule = 5;
44 Qrms_DEAD = Qrms_DEAD * Qrms_DEAD;
48 LogPrint(
"CastorDigi") <<
"enum CastorChannelStatus::StatusBit::BAD=" << StatusBadChannel
49 <<
"EtowerLastModule = " << EtowerLastModule << endl;
60 LogPrint(
"CastorMonitorModule") <<
"Digi bookHist(start)";
65 sprintf(sTileIndex,
"Cell(=moduleZ*16+sector#phi)");
71 "average E(digi) in BX",
"Castor average E (digi);Event.BX;fC", 3601, -0.5, 3600.5, 0., 1.e10,
"");
74 string trname = HltPaths_[0];
75 hpBXtrig = ibooker.
bookProfile(
"average E(digi) in BXtrig",
76 "Castor average E (digi) trigger:'" + trname +
"';Event.BX;fC",
86 "E(digi)vsTriggerIndex",
"Castor average E(digi) by triggerIndex;triggerIndex;fC", 512, 0., 512, 0., 1.e10,
"");
92 h2digierr = ibooker.
bookProfile2D(s2, s2, 14, 0., 14., 16, 0., 16., 100, 0, 1.e10,
"");
94 h2digierr->getTProfile2D()->GetYaxis()->SetTitle(
"Sector #phi");
95 h2digierr->getTProfile2D()->SetMaximum(1.);
96 h2digierr->getTProfile2D()->SetMinimum(QIEerrThreshold);
97 h2digierr->getTProfile2D()->SetOption(
"colz");
99 sprintf(s,
"CASTORreportSummaryMap");
100 h2repsum = ibooker.
bookProfile2D(s, s, 14, 0., 14., 16, 0., 16., 100, 0, 1.e10,
"");
102 h2repsum->getTProfile2D()->GetYaxis()->SetTitle(
"Sector #phi");
103 h2repsum->getTProfile2D()->SetMaximum(1.);
104 h2repsum->getTProfile2D()->SetMinimum(QIEerrThreshold);
105 h2repsum->getTProfile2D()->SetOption(
"colz");
107 sprintf(s,
"CASTOR BadChannelsMap");
108 h2status = ibooker.
book2D(s, s, 14, 0., 14., 16, 0., 16.);
109 h2status->
getTH2F()->GetXaxis()->SetTitle(
"Module Z");
110 h2status->getTH2F()->GetYaxis()->SetTitle(
"Sector #phi");
111 h2status->getTH2F()->SetOption(
"colz");
113 sprintf(s,
"CASTOR TSmax Significance Map");
114 h2TSratio = ibooker.
book2D(s, s, 14, 0., 14., 16, 0., 16.);
115 h2TSratio->
getTH2F()->GetXaxis()->SetTitle(
"Module Z");
116 h2TSratio->getTH2F()->GetYaxis()->SetTitle(
"Sector #phi");
117 h2TSratio->getTH2F()->SetOption(
"colz");
119 sprintf(s,
"CASTOR TSmax Significance All chan");
120 hTSratio = ibooker.
book1D(s, s, 105, 0., 1.05);
122 sprintf(s,
"DigiSize");
123 hdigisize = ibooker.
book1DD(s, s, 20, 0., 20.);
124 sprintf(s,
"ModuleZ(fC)_allTS");
125 hModule = ibooker.
book1D(s, s, 14, 0., 14.);
126 hModule->
getTH1F()->GetXaxis()->SetTitle(
"ModuleZ");
127 hModule->getTH1F()->GetYaxis()->SetTitle(
"QIE(fC)");
128 sprintf(s,
"Sector #phi(fC)_allTS");
129 hSector = ibooker.
book1D(s, s, 16, 0., 16.);
130 hSector->
getTH1F()->GetXaxis()->SetTitle(
"Sector #phi");
131 hSector->getTH1F()->GetYaxis()->SetTitle(
"QIE(fC)");
133 st =
"Castor cells avr digi(fC) per event Map TS vs Channel";
135 ibooker.
bookProfile2D(st, st +
";" +
string(sTileIndex) +
";TS", 224, 0., 224., 10, 0., 10., 0., 1.e10,
"");
138 st =
"Castor cells avr digiRMS(fC) per event Map TS vs Channel";
139 h2QrmsTSvsCh = ibooker.
book2D(st, st +
";" +
string(sTileIndex) +
";TS", 224, 0., 224., 10, 0., 10.);
140 h2QrmsTSvsCh->
getTH2F()->SetOption(
"colz");
142 sprintf(s,
"CASTOR data quality");
143 h2qualityMap = ibooker.
book2D(s, s, 14, 0, 14, 16, 0, 16);
144 h2qualityMap->
getTH2F()->GetXaxis()->SetTitle(
"module Z");
145 h2qualityMap->getTH2F()->GetYaxis()->SetTitle(
"Sector #phi");
146 h2qualityMap->getTH2F()->SetOption(
"colz");
148 hReport = ibooker.
bookFloat(
"CASTOR reportSummary");
150 sprintf(s,
"QmeanfC_map(allTS)");
151 h2QmeanMap = ibooker.
book2D(s, s, 14, 0., 14., 16, 0., 16.);
152 h2QmeanMap->
getTH2F()->GetXaxis()->SetTitle(
"Module Z");
153 h2QmeanMap->getTH2F()->GetYaxis()->SetTitle(
"Sector #phi");
154 h2QmeanMap->getTH2F()->SetOption(
"textcolz");
156 const int NEtow = 20;
157 float EhadTow[NEtow + 1];
158 float EMTow[NEtow + 1];
159 float ETower[NEtow + 2];
160 double E0tow = 500. / 1024.;
167 double lnBtow =
log(1.8);
168 for (
int j = 1; j < NEtow; j++)
169 EMTow[j + 1] = E0tow *
exp(j * lnBtow);
170 for (
int j = 1; j < NEtow; j++)
171 EhadTow[j + 1] = E0tow *
exp(j * lnBtow);
172 for (
int j = 1; j <= NEtow; j++)
173 ETower[j + 1] = E0tow *
exp(j * lnBtow);
175 sprintf(s,
"CASTOR_Tower_EMvsEhad(fC)");
176 h2towEMvsHAD = ibooker.
book2D(s, s, NEtow, EhadTow, NEtow, EMTow);
177 h2towEMvsHAD->
getTH2F()->GetXaxis()->SetTitle(
"Ehad [fC]");
178 h2towEMvsHAD->getTH2F()->GetYaxis()->SetTitle(
"EM [fC]");
179 h2towEMvsHAD->getTH2F()->SetOption(
"colz");
181 sprintf(s,
"CASTOR_TowerTotalEnergy(fC)");
182 htowE = ibooker.
book1D(s, s, NEtow + 1, ETower);
183 htowE->
getTH1F()->GetXaxis()->SetTitle(
"fC");
185 for (
int ts = 0; ts <= 1; ts++) {
186 sprintf(s,
"QIErms_TS=%d", ts);
187 hQIErms[ts] = ibooker.
book1D(s, s, 1000, 0., 100.);
188 hQIErms[ts]->
getTH1F()->GetXaxis()->SetTitle(
"QIErms(fC)");
191 for (
int ind = 0; ind < 224; ind++)
192 for (
int ts = 0; ts < 10; ts++)
193 QrmsTS[ind][ts] = QmeanTS[ind][ts] = 0.;
203 LogPrint(
"CastorDigiMonitor") <<
"processEvent(begin)";
205 if (castorDigis.
empty()) {
207 for (
int sec = 0; sec < 16; sec++)
208 h2repsum->Fill(
mod, sec, 0.);
210 fillTrigRes(event, TrigResults, 0.);
214 float Ecell[14][16]{};
219 int sector = digi.
id().
sector() - 1;
220 if (ChannelStatus[module][sector] == StatusBadChannel)
224 hdigisize->Fill(digi.
size());
226 int err = 0, err2 = 0;
227 for (
int i = 0;
i < digi.
size();
i++) {
233 err |= (capid != capid1) | er << 1 | (!dv) << 2;
234 err2 += (capid != capid1) | er | (!dv);
236 int ind = ModSecToIndex(module, sector);
239 Ecell[module][sector] =
q;
241 QrmsTS[ind][
i] += (q *
q);
242 QmeanTS[ind][
i] +=
q;
243 if (err != 0 && fVerbosity > 0)
244 LogPrint(
"CastorDigiMonitor") <<
"event/idigi=" << ievt_ <<
"/" <<
i <<
" cap=cap1_dv_er_err: " << capid <<
"=" 245 << capid1 <<
" " << dv <<
" " << er <<
" " << err;
251 h2digierr->Fill(module, sector, err);
252 h2repsum->Fill(module, sector, 1. - err2 / digi.
size());
258 for (
int sec = 0; sec < 16; sec++)
260 Etotal = Ecell[
mod][sec];
262 fillTrigRes(event, TrigResults, Etotal);
264 for (
int sec = 0; sec < 16; sec++) {
265 float em = Ecell[0][sec] + Ecell[1][sec];
267 for (
int mod = 2;
mod < EtowerLastModule;
mod++)
268 ehad += Ecell[
mod][sec];
269 h2towEMvsHAD->Fill(em, ehad);
270 htowE->Fill(em + ehad);
273 const float repChanBAD = 0.9;
274 const float repChanWarning = 0.95;
275 if (ievt_ % 100 != 0)
278 float ModuleSum[14], SectorSum[16];
279 for (
int m = 0;
m < 14;
m++)
281 for (
int s = 0;
s < 16;
s++)
284 for (
int sec = 0; sec < 16; sec++) {
285 for (
int ts = 0; ts <= 1; ts++) {
286 int ind = ModSecToIndex(
mod, sec);
287 double Qmean = QmeanTS[ind][ts] / ievt_;
288 double Qrms =
sqrt(QrmsTS[ind][ts] / ievt_ - Qmean * Qmean);
289 hQIErms[ts]->Fill(Qrms);
293 for (
int ts = 1; ts <= TS_MAX; ts++) {
294 int ind = ModSecToIndex(
mod, sec) + 1;
296 h2QmeantsvsCh->getTProfile2D()->GetBinContent(ind, ts);
298 double Qmean = QmeanTS[ind - 1][ts - 1] / ievt_;
299 double Qrms = QrmsTS[ind - 1][ts - 1] / ievt_ - Qmean * Qmean;
300 h2QrmsTSvsCh->getTH2F()->SetBinContent(ind, ts,
sqrt(Qrms));
302 ModuleSum[
mod] += sum;
303 SectorSum[sec] += sum;
304 float isum =
float(
int(sum * 10. + 0.5)) / 10.;
305 if (ChannelStatus[
mod][sec] != StatusBadChannel)
306 h2QmeanMap->getTH2F()->SetBinContent(
mod + 1, sec + 1, isum);
310 hModule->getTH1F()->SetBinContent(
mod + 1, ModuleSum[
mod]);
311 for (
int sec = 0; sec < 16; sec++)
312 hSector->getTH1F()->SetBinContent(sec + 1, SectorSum[sec]);
316 for (
int mod = 0; mod < 14; mod++)
317 for (
int sec = 0; sec < 16; sec++) {
318 if (ChannelStatus[mod][sec] == StatusBadChannel)
320 int ind = ModSecToIndex(mod, sec);
321 double Qmean = QmeanTS[ind][TSped] / ievt_;
322 double Qrms = QrmsTS[ind][TSped] / ievt_ - Qmean * Qmean;
323 float ChanStatus = 0.;
324 if (Qrms < Qrms_DEAD)
326 h2status->getTH2F()->SetBinContent(mod + 1, sec + 1, ChanStatus);
329 for (
int ts = 0; ts < TS_MAX - 1; ts++) {
330 float a = h2QmeantsvsCh->getTProfile2D()->GetBinContent(ind + 1, ts + 1) +
331 h2QmeantsvsCh->getTProfile2D()->GetBinContent(ind + 1, ts + 2);
337 for (
int ts = 0; ts < TS_MAX; ts++)
338 sum += h2QmeantsvsCh->getTProfile2D()->GetBinContent(ind + 1, ts + 1);
342 r = 1. - (sum - am) / (TS_MAX - 2) / am * 2.;
345 h2TSratio->getTH2F()->SetBinContent(mod + 1, sec + 1, r);
348 float statusTS = 1.0;
349 if (r > RatioThresh1)
350 statusTS = repChanWarning;
352 statusTS = repChanBAD;
353 float gChanStatus = statusTS;
355 gChanStatus = repChanBAD;
356 h2qualityMap->getTH2F()->SetBinContent(mod + 1, sec + 1, gChanStatus);
357 if (gChanStatus > repChanBAD)
360 hReport->Fill(
float(nGoodCh) / N_GoodChannels);
366 LogPrint(
"CastorDigiMonitor") <<
"DigiMonitor::endRun: trigger max index = " << TrigIndexMax
367 <<
" TriggerIndexies(N):" << endl;
368 for (
int i = 1;
i < hpTrigRes->getTProfile()->GetNbinsX();
i++)
369 if (hpTrigRes->getTProfile()->GetBinContent(
i) > 0)
370 LogPrint(
"CastorDigiMonitor") <<
i - 1 <<
"(" << hpTrigRes->getTProfile()->GetBinContent(
i) <<
") ";
374 int nTriggers = TrigResults.
size();
376 bool event_triggered =
false;
378 for (
int iTrig = 0; iTrig < nTriggers; ++iTrig) {
379 if (TrigResults.
accept(iTrig)) {
381 if (TrigIndexMax < index)
382 TrigIndexMax =
index;
385 <<
" index= " << index << endl;
386 hpTrigRes->Fill(index, Etotal);
387 for (
int n = 0;
n <
int(HltPaths_.size());
n++) {
388 if (trigName.
triggerName(iTrig).find(HltPaths_[
n]) != std::string::npos)
389 event_triggered =
true;
402 if (fVerbosity > 0) {
403 LogPrint(
"CastorDigiMonitor") <<
" CastorChQuality in CondDB=" << dbChQuality.
isValid() << endl;
408 for (
int sec = 0; sec < 16; sec++)
409 ChannelStatus[
mod][sec] = 0;
411 N_GoodChannels = 224 - channels.size();
413 LogPrint(
"CastorDigiMonitor") <<
"CastorDigiMonitor::getDBData: QualityRcdSize=" << channels.size();
414 for (std::vector<DetId>::iterator ch = channels.begin(); ch != channels.end(); ch++) {
417 int rawId = quality->
rawId();
421 if (mod > 0 && mod < 16 && sec > 0 && sec < 16)
424 LogPrint(
"CastorDigiMonitor") << chInd <<
" module=" << mod <<
" sec=" << sec <<
" rawId=" << rawId
425 <<
" value=" << value << endl;
431 int ind = sector + module * 16;
TProfile * getTProfile() const
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
TProfile2D * getTProfile2D() const
int sector() const
get the sector (1-16)
MonitorElement * bookProfile(Args &&...args)
constexpr bool er() const
is the error bit set?
const HcalQIESample & sample(int i) const
access a sample
bool accept() const
Has at least one path accepted the event?
std::vector< T >::const_iterator const_iterator
std::vector< DetId > getAllChannels() const
int bunchCrossing() const
int module() const
get the module (1-2 for EM, 1-12 for HAD)
const Item * getValues(DetId fId, bool throwOnFail=true) const
Strings const & triggerNames() const
void processEvent(edm::Event const &event, const CastorDigiCollection &cast, const edm::TriggerResults &trig, const CastorDbService &cond)
CastorDigiMonitor(const edm::ParameterSet &ps)
void getDbData(const edm::EventSetup &iSetup)
void setCurrentFolder(std::string const &fullpath)
unsigned int triggerIndex(std::string const &name) const
uint32_t getValue() const
MonitorElement * bookProfile2D(Args &&...args)
unsigned int size() const
Get number of paths stored.
MonitorElement * book1D(Args &&...args)
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &)
void fillTrigRes(edm::Event const &event, const edm::TriggerResults &TrigResults, double Etot)
constexpr int adc() const
get the ADC sample
const_iterator end() const
static const float LedMonAdc2fc[128]
MonitorElement * book2D(Args &&...args)
std::string const & triggerName(unsigned int index) const
int ModSecToIndex(int module, int sector)
constexpr bool dv() const
is the Data Valid bit set?
constexpr int capid() const
get the Capacitor id
MonitorElement * bookFloat(Args &&...args)
const HcalCastorDetId & id() const
T mod(const T &a, const T &b)
int size() const
total number of samples in the digi
MonitorElement * book1DD(Args &&...args)
const_iterator begin() const