28 vector<std::string> HltPaths_;
29 int StatusBadChannel = 1;
30 int ChannelStatus[14][16] {};
31 int N_GoodChannels = 224;
32 int EtowerLastModule = 5;
43 HltPaths_ = ps.
getParameter<vector<string> >(
"HltPaths");
45 Qrms_DEAD = Qrms_DEAD * Qrms_DEAD;
49 LogPrint(
"CastorDigi") <<
"enum CastorChannelStatus::StatusBit::BAD=" 51 <<
"EtowerLastModule = " << EtowerLastModule << endl;
61 if (fVerbosity > 0)
LogPrint(
"CastorMonitorModule") <<
"Digi bookHist(start)";
66 sprintf(sTileIndex,
"Cell(=moduleZ*16+sector#phi)");
72 "Castor average E (digi);Event.BX;fC", 3601, -0.5,
73 3600.5, 0., 1.e10,
"");
76 string trname = HltPaths_[0];
78 "average E(digi) in BXtrig",
79 "Castor average E (digi) trigger:'" + trname +
"';Event.BX;fC", 3601,
80 -0.5, 3600.5, 0., 1.e10,
"");
84 "E(digi)vsTriggerIndex",
85 "Castor average E(digi) by triggerIndex;triggerIndex;fC", 512, 0., 512,
92 h2digierr = ibooker.
bookProfile2D(s2, s2, 14, 0., 14., 16, 0., 16., 100, 0,
95 h2digierr->getTProfile2D()->GetYaxis()->SetTitle(
"Sector #phi");
96 h2digierr->getTProfile2D()->SetMaximum(1.);
97 h2digierr->getTProfile2D()->SetMinimum(QIEerrThreshold);
98 h2digierr->getTProfile2D()->SetOption(
"colz");
100 sprintf(s,
"CASTORreportSummaryMap");
102 ibooker.
bookProfile2D(s, s, 14, 0., 14., 16, 0., 16., 100, 0, 1.e10,
"");
104 h2repsum->getTProfile2D()->GetYaxis()->SetTitle(
"Sector #phi");
105 h2repsum->getTProfile2D()->SetMaximum(1.);
106 h2repsum->getTProfile2D()->SetMinimum(QIEerrThreshold);
107 h2repsum->getTProfile2D()->SetOption(
"colz");
109 sprintf(s,
"CASTOR BadChannelsMap");
110 h2status = ibooker.
book2D(s, s, 14, 0., 14., 16, 0., 16.);
111 h2status->
getTH2F()->GetXaxis()->SetTitle(
"Module Z");
112 h2status->getTH2F()->GetYaxis()->SetTitle(
"Sector #phi");
113 h2status->getTH2F()->SetOption(
"colz");
115 sprintf(s,
"CASTOR TSmax Significance Map");
116 h2TSratio = ibooker.
book2D(s, s, 14, 0., 14., 16, 0., 16.);
117 h2TSratio->
getTH2F()->GetXaxis()->SetTitle(
"Module Z");
118 h2TSratio->getTH2F()->GetYaxis()->SetTitle(
"Sector #phi");
119 h2TSratio->getTH2F()->SetOption(
"colz");
121 sprintf(s,
"CASTOR TSmax Significance All chan");
122 hTSratio = ibooker.
book1D(s, s, 105, 0., 1.05);
124 sprintf(s,
"DigiSize");
125 hdigisize = ibooker.
book1DD(s, s, 20, 0., 20.);
126 sprintf(s,
"ModuleZ(fC)_allTS");
127 hModule = ibooker.
book1D(s, s, 14, 0., 14.);
128 hModule->
getTH1F()->GetXaxis()->SetTitle(
"ModuleZ");
129 hModule->getTH1F()->GetYaxis()->SetTitle(
"QIE(fC)");
130 sprintf(s,
"Sector #phi(fC)_allTS");
131 hSector = ibooker.
book1D(s, s, 16, 0., 16.);
132 hSector->
getTH1F()->GetXaxis()->SetTitle(
"Sector #phi");
133 hSector->getTH1F()->GetYaxis()->SetTitle(
"QIE(fC)");
135 st =
"Castor cells avr digi(fC) per event Map TS vs Channel";
137 ibooker.
bookProfile2D(st, st +
";" +
string(sTileIndex) +
";TS", 224, 0.,
138 224., 10, 0., 10., 0., 1.e10,
"");
141 st =
"Castor cells avr digiRMS(fC) per event Map TS vs Channel";
142 h2QrmsTSvsCh = ibooker.
book2D(st, st +
";" +
string(sTileIndex) +
";TS", 224,
143 0., 224., 10, 0., 10.);
144 h2QrmsTSvsCh->
getTH2F()->SetOption(
"colz");
146 sprintf(s,
"CASTOR data quality");
147 h2qualityMap = ibooker.
book2D(s, s, 14, 0, 14, 16, 0, 16);
148 h2qualityMap->
getTH2F()->GetXaxis()->SetTitle(
"module Z");
149 h2qualityMap->getTH2F()->GetYaxis()->SetTitle(
"Sector #phi");
150 h2qualityMap->getTH2F()->SetOption(
"colz");
152 hReport = ibooker.
bookFloat(
"CASTOR reportSummary");
154 sprintf(s,
"QmeanfC_map(allTS)");
155 h2QmeanMap = ibooker.
book2D(s, s, 14, 0., 14., 16, 0., 16.);
156 h2QmeanMap->
getTH2F()->GetXaxis()->SetTitle(
"Module Z");
157 h2QmeanMap->getTH2F()->GetYaxis()->SetTitle(
"Sector #phi");
158 h2QmeanMap->getTH2F()->SetOption(
"textcolz");
160 const int NEtow = 20;
161 float EhadTow[NEtow + 1];
162 float EMTow[NEtow + 1];
163 float ETower[NEtow + 2];
164 double E0tow = 500. / 1024.;
171 double lnBtow =
log(1.8);
172 for (
int j = 1; j < NEtow; j++) EMTow[j + 1] = E0tow *
exp(j * lnBtow);
173 for (
int j = 1; j < NEtow; j++) EhadTow[j + 1] = E0tow *
exp(j * lnBtow);
174 for (
int j = 1; j <= NEtow; j++) ETower[j + 1] = E0tow *
exp(j * lnBtow);
176 sprintf(s,
"CASTOR_Tower_EMvsEhad(fC)");
177 h2towEMvsHAD = ibooker.
book2D(s, s, NEtow, EhadTow, NEtow, EMTow);
178 h2towEMvsHAD->
getTH2F()->GetXaxis()->SetTitle(
"Ehad [fC]");
179 h2towEMvsHAD->getTH2F()->GetYaxis()->SetTitle(
"EM [fC]");
180 h2towEMvsHAD->getTH2F()->SetOption(
"colz");
182 sprintf(s,
"CASTOR_TowerTotalEnergy(fC)");
183 htowE = ibooker.
book1D(s, s, NEtow + 1, ETower);
184 htowE->
getTH1F()->GetXaxis()->SetTitle(
"fC");
186 for (
int ts = 0; ts <= 1; ts++) {
187 sprintf(s,
"QIErms_TS=%d", ts);
188 hQIErms[ts] = ibooker.
book1D(s, s, 1000, 0., 100.);
189 hQIErms[ts]->
getTH1F()->GetXaxis()->SetTitle(
"QIErms(fC)");
192 for (
int ind = 0; ind < 224; ind++)
193 for (
int ts = 0; ts < 10; ts++) QrmsTS[ind][ts] = QmeanTS[ind][ts] = 0.;
202 if (fVerbosity > 1)
LogPrint(
"CastorDigiMonitor") <<
"processEvent(begin)";
204 if (castorDigis.
empty()) {
206 for (
int sec = 0; sec < 16; sec++) h2repsum->Fill(
mod, sec, 0.);
208 fillTrigRes(event, TrigResults, 0.);
212 float Ecell[14][16] {};
214 j != castorDigis.
end(); j++) {
218 int sector = digi.
id().
sector() - 1;
219 if (ChannelStatus[module][sector] == StatusBadChannel)
continue;
222 hdigisize->Fill(digi.
size());
224 int err = 0, err2 = 0;
225 for (
int i = 0;
i < digi.
size();
i++) {
231 err |= (capid != capid1) | er << 1 | (!dv) << 2;
232 err2 += (capid != capid1) | er | (!dv);
234 int ind = ModSecToIndex(module, sector);
237 Ecell[module][sector] =
q;
239 QrmsTS[ind][
i] += (q *
q);
240 QmeanTS[ind][
i] +=
q;
241 if (err != 0 && fVerbosity > 0)
243 <<
"event/idigi=" << ievt_ <<
"/" <<
i 244 <<
" cap=cap1_dv_er_err: " << capid <<
"=" << capid1 <<
" " << dv
245 <<
" " << 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++)
259 for (
int mod = 0;
mod < 14;
mod++) Etotal = Ecell[
mod][sec];
261 fillTrigRes(event, TrigResults, Etotal);
263 for (
int sec = 0; sec < 16; sec++) {
264 float em = Ecell[0][sec] + Ecell[1][sec];
266 for (
int mod = 2;
mod < EtowerLastModule;
mod++) ehad += Ecell[
mod][sec];
267 h2towEMvsHAD->Fill(em, ehad);
268 htowE->Fill(em + ehad);
271 const float repChanBAD = 0.9;
272 const float repChanWarning = 0.95;
273 if (ievt_ % 100 != 0)
return;
275 float ModuleSum[14], SectorSum[16];
276 for (
int m = 0;
m < 14;
m++) ModuleSum[
m] = 0.;
277 for (
int s = 0;
s < 16;
s++) SectorSum[
s] = 0.;
279 for (
int sec = 0; sec < 16; sec++) {
280 for (
int ts = 0; ts <= 1; ts++) {
281 int ind = ModSecToIndex(
mod, sec);
282 double Qmean = QmeanTS[ind][ts] / ievt_;
283 double Qrms =
sqrt(QrmsTS[ind][ts] / ievt_ - Qmean * Qmean);
284 hQIErms[ts]->Fill(Qrms);
288 for (
int ts = 1; ts <= TS_MAX; ts++) {
289 int ind = ModSecToIndex(
mod, sec) + 1;
291 h2QmeantsvsCh->getTProfile2D()->GetBinContent(ind, ts);
293 double Qmean = QmeanTS[ind - 1][ts - 1] / ievt_;
294 double Qrms = QrmsTS[ind - 1][ts - 1] / ievt_ - Qmean * Qmean;
295 h2QrmsTSvsCh->getTH2F()->SetBinContent(ind, ts,
sqrt(Qrms));
297 ModuleSum[
mod] += sum;
298 SectorSum[sec] += sum;
299 float isum =
float(
int(sum * 10. + 0.5)) / 10.;
300 if (ChannelStatus[
mod][sec] != StatusBadChannel)
301 h2QmeanMap->getTH2F()->SetBinContent(
mod + 1, sec + 1, isum);
305 hModule->getTH1F()->SetBinContent(
mod + 1, ModuleSum[
mod]);
306 for (
int sec = 0; sec < 16; sec++)
307 hSector->getTH1F()->SetBinContent(sec + 1, SectorSum[sec]);
311 for (
int mod = 0; mod < 14; mod++)
312 for (
int sec = 0; sec < 16; sec++) {
313 if (ChannelStatus[mod][sec] == StatusBadChannel)
continue;
314 int ind = ModSecToIndex(mod, sec);
315 double Qmean = QmeanTS[ind][TSped] / ievt_;
316 double Qrms = QrmsTS[ind][TSped] / ievt_ - Qmean * Qmean;
317 float ChanStatus = 0.;
318 if (Qrms < Qrms_DEAD) ChanStatus = 1.;
319 h2status->getTH2F()->SetBinContent(mod + 1, sec + 1, ChanStatus);
322 for (
int ts = 0; ts < TS_MAX - 1; ts++) {
324 h2QmeantsvsCh->getTProfile2D()->GetBinContent(ind + 1, ts + 1) +
325 h2QmeantsvsCh->getTProfile2D()->GetBinContent(ind + 1, ts + 2);
330 for (
int ts = 0; ts < TS_MAX; ts++)
331 sum += h2QmeantsvsCh->getTProfile2D()->GetBinContent(ind + 1, ts + 1);
334 if (am > 0.) r = 1. - (sum - am) / (TS_MAX - 2) / am * 2.;
337 h2TSratio->getTH2F()->SetBinContent(mod + 1, sec + 1, r);
340 float statusTS = 1.0;
341 if (r > RatioThresh1)
342 statusTS = repChanWarning;
344 statusTS = repChanBAD;
345 float gChanStatus = statusTS;
346 if (ChanStatus > 0.) gChanStatus = repChanBAD;
347 h2qualityMap->getTH2F()->SetBinContent(mod + 1, sec + 1, gChanStatus);
348 if (gChanStatus > repChanBAD) ++nGoodCh;
350 hReport->Fill(
float(nGoodCh) / N_GoodChannels);
357 <<
"DigiMonitor::endRun: trigger max index = " << TrigIndexMax
358 <<
" TriggerIndexies(N):" << endl;
359 for (
int i = 1;
i < hpTrigRes->getTProfile()->GetNbinsX();
i++)
360 if (hpTrigRes->getTProfile()->GetBinContent(
i) > 0)
362 <<
i - 1 <<
"(" << hpTrigRes->getTProfile()->GetBinContent(
i) <<
") ";
368 int nTriggers = TrigResults.
size();
370 bool event_triggered =
false;
372 for (
int iTrig = 0; iTrig < nTriggers; ++iTrig) {
373 if (TrigResults.
accept(iTrig)) {
375 if (TrigIndexMax < index) TrigIndexMax =
index;
378 <<
"trigger[" << iTrig <<
"] name:" << trigName.
triggerName(iTrig)
379 <<
" index= " << index << endl;
380 hpTrigRes->Fill(index, Etotal);
381 for (
int n = 0;
n <
int(HltPaths_.size());
n++) {
384 event_triggered =
true;
389 if (event_triggered) hpBXtrig->Fill(event.
bunchCrossing(), Etotal);
396 if (fVerbosity > 0) {
398 <<
" CastorChQuality in CondDB=" << dbChQuality.
isValid() << endl;
403 for (
int sec = 0; sec < 16; sec++) ChannelStatus[
mod][sec] = 0;
405 N_GoodChannels = 224 - channels.size();
408 <<
"CastorDigiMonitor::getDBData: QualityRcdSize=" << channels.size();
409 for (std::vector<DetId>::iterator ch = channels.begin(); ch != channels.end();
413 int rawId = quality->
rawId();
417 if (mod > 0 && mod < 16 && sec > 0 && sec < 16)
421 << chInd <<
" module=" << mod <<
" sec=" << sec <<
" rawId=" << rawId
422 <<
" value=" << value << endl;
428 int ind = sector + module * 16;
429 if (ind > 223) ind = 223;
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< CastorDataFrame >::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