27 vector<std::string> HltPaths_;
28 int StatusBadChannel = 1;
30 int N_GoodChannels = 224;
31 int EtowerLastModule = 5;
43 Qrms_DEAD = Qrms_DEAD * Qrms_DEAD;
47 LogPrint(
"CastorDigi") <<
"enum CastorChannelStatus::StatusBit::BAD=" << StatusBadChannel
48 <<
"EtowerLastModule = " << EtowerLastModule << endl;
59 LogPrint(
"CastorMonitorModule") <<
"Digi bookHist(start)";
64 sprintf(sTileIndex,
"Cell(=moduleZ*16+sector#phi)");
70 "average E(digi) in BX",
"Castor average E (digi);Event.BX;fC", 3601, -0.5, 3600.5, 0., 1.e10,
"");
73 string trname = HltPaths_[0];
74 hpBXtrig = ibooker.
bookProfile(
"average E(digi) in BXtrig",
75 "Castor average E (digi) trigger:'" + trname +
"';Event.BX;fC",
85 "E(digi)vsTriggerIndex",
"Castor average E(digi) by triggerIndex;triggerIndex;fC", 512, 0., 512, 0., 1.e10,
"");
91 h2digierr = ibooker.
bookProfile2D(s2, s2, 14, 0., 14., 16, 0., 16., 100, 0, 1.e10,
"");
93 h2digierr->getTProfile2D()->GetYaxis()->SetTitle(
"Sector #phi");
94 h2digierr->getTProfile2D()->SetMaximum(1.);
95 h2digierr->getTProfile2D()->SetMinimum(QIEerrThreshold);
96 h2digierr->getTProfile2D()->SetOption(
"colz");
98 sprintf(s,
"CASTORreportSummaryMap");
99 h2repsum = ibooker.
bookProfile2D(s, s, 14, 0., 14., 16, 0., 16., 100, 0, 1.e10,
"");
101 h2repsum->getTProfile2D()->GetYaxis()->SetTitle(
"Sector #phi");
102 h2repsum->getTProfile2D()->SetMaximum(1.);
103 h2repsum->getTProfile2D()->SetMinimum(QIEerrThreshold);
104 h2repsum->getTProfile2D()->SetOption(
"colz");
106 sprintf(s,
"CASTOR BadChannelsMap");
107 h2status = ibooker.
book2D(s, s, 14, 0., 14., 16, 0., 16.);
109 h2status->setAxisTitle(
"Sector #phi", 2);
110 h2status->setOption(
"colz");
112 sprintf(s,
"CASTOR TSmax Significance Map");
113 h2TSratio = ibooker.
book2D(s, s, 14, 0., 14., 16, 0., 16.);
115 h2TSratio->setAxisTitle(
"Sector #phi", 2);
116 h2TSratio->setOption(
"colz");
118 sprintf(s,
"CASTOR TSmax Significance All chan");
119 hTSratio = ibooker.
book1D(s, s, 105, 0., 1.05);
121 sprintf(s,
"DigiSize");
122 hdigisize = ibooker.
book1DD(s, s, 20, 0., 20.);
123 sprintf(s,
"ModuleZ(fC)_allTS");
124 hModule = ibooker.
book1D(s, s, 14, 0., 14.);
126 hModule->setAxisTitle(
"QIE(fC)", 2);
127 sprintf(s,
"Sector #phi(fC)_allTS");
128 hSector = ibooker.
book1D(s, s, 16, 0., 16.);
130 hSector->setAxisTitle(
"QIE(fC)", 2);
132 st =
"Castor cells avr digi(fC) per event Map TS vs Channel";
134 ibooker.
bookProfile2D(st, st +
";" +
string(sTileIndex) +
";TS", 224, 0., 224., 10, 0., 10., 0., 1.e10,
"");
137 st =
"Castor cells avr digiRMS(fC) per event Map TS vs Channel";
138 h2QrmsTSvsCh = ibooker.
book2D(st, st +
";" +
string(sTileIndex) +
";TS", 224, 0., 224., 10, 0., 10.);
141 sprintf(s,
"CASTOR data quality");
142 h2qualityMap = ibooker.
book2D(s, s, 14, 0, 14, 16, 0, 16);
144 h2qualityMap->setAxisTitle(
"Sector #phi", 2);
145 h2qualityMap->setOption(
"colz");
147 hReport = ibooker.
bookFloat(
"CASTOR reportSummary");
149 sprintf(s,
"QmeanfC_map(allTS)");
150 h2QmeanMap = ibooker.
book2D(s, s, 14, 0., 14., 16, 0., 16.);
152 h2QmeanMap->setAxisTitle(
"Sector #phi", 2);
153 h2QmeanMap->setOption(
"textcolz");
155 const int NEtow = 20;
156 float EhadTow[NEtow + 1];
157 float EMTow[NEtow + 1];
158 float ETower[NEtow + 2];
159 double E0tow = 500. / 1024.;
166 double lnBtow =
log(1.8);
167 for (
int j = 1;
j < NEtow;
j++)
168 EMTow[
j + 1] = E0tow *
exp(
j * lnBtow);
169 for (
int j = 1;
j < NEtow;
j++)
170 EhadTow[
j + 1] = E0tow *
exp(
j * lnBtow);
171 for (
int j = 1;
j <= NEtow;
j++)
172 ETower[
j + 1] = E0tow *
exp(
j * lnBtow);
174 sprintf(s,
"CASTOR_Tower_EMvsEhad(fC)");
175 h2towEMvsHAD = ibooker.
book2D(s, s, NEtow, EhadTow, NEtow, EMTow);
177 h2towEMvsHAD->setAxisTitle(
"EM [fC]", 2);
178 h2towEMvsHAD->setOption(
"colz");
180 sprintf(s,
"CASTOR_TowerTotalEnergy(fC)");
181 htowE = ibooker.
book1D(s, s, NEtow + 1, ETower);
184 for (
int ts = 0; ts <= 1; ts++) {
185 sprintf(s,
"QIErms_TS=%d", ts);
186 hQIErms[ts] = ibooker.
book1D(s, s, 1000, 0., 100.);
190 for (
int ind = 0; ind < 224; ind++)
191 for (
int ts = 0; ts < 10; ts++)
192 QrmsTS[ind][ts] = QmeanTS[ind][ts] = 0.;
202 LogPrint(
"CastorDigiMonitor") <<
"processEvent(begin)";
204 if (castorDigis.
empty()) {
207 h2repsum->Fill(
mod,
sec, 0.);
209 fillTrigRes(event, TrigResults, 0.);
213 float Ecell[14][16]{};
218 int sector = digi.
id().
sector() - 1;
223 hdigisize->Fill(digi.
size());
225 int err = 0, err2 = 0;
226 for (
int i = 0;
i < digi.
size();
i++) {
232 err |= (capid != capid1) | er << 1 | (!dv) << 2;
233 err2 += (capid != capid1) | er | (!dv);
235 int ind = ModSecToIndex(module, sector);
238 Ecell[module][sector] =
q;
240 QrmsTS[ind][
i] += (q *
q);
241 QmeanTS[ind][
i] +=
q;
242 if (err != 0 && fVerbosity > 0)
243 LogPrint(
"CastorDigiMonitor") <<
"event/idigi=" << ievt_ <<
"/" <<
i <<
" cap=cap1_dv_er_err: " << capid <<
"=" 244 << capid1 <<
" " << dv <<
" " << er <<
" " <<
err;
250 h2digierr->Fill(module, sector, err);
251 h2repsum->Fill(module, sector, 1. - err2 / digi.
size());
261 fillTrigRes(event, TrigResults, Etotal);
264 float em = Ecell[0][
sec] + Ecell[1][
sec];
266 for (
int mod = 2;
mod < EtowerLastModule;
mod++)
268 h2towEMvsHAD->Fill(em, ehad);
269 htowE->Fill(em + ehad);
272 const float repChanBAD = 0.9;
273 const float repChanWarning = 0.95;
274 if (ievt_ % 100 != 0)
277 float ModuleSum[14], SectorSum[16];
278 for (
int m = 0;
m < 14;
m++)
280 for (
int s = 0;
s < 16;
s++)
284 for (
int ts = 0; ts <= 1; ts++) {
285 int ind = ModSecToIndex(
mod,
sec);
286 double Qmean = QmeanTS[ind][ts] / ievt_;
287 double Qrms =
sqrt(QrmsTS[ind][ts] / ievt_ - Qmean * Qmean);
288 hQIErms[ts]->Fill(Qrms);
292 for (
int ts = 1; ts <= TS_MAX; ts++) {
293 int ind = ModSecToIndex(
mod,
sec) + 1;
295 h2QmeantsvsCh->getTProfile2D()->GetBinContent(ind, ts);
297 double Qmean = QmeanTS[ind - 1][ts - 1] / ievt_;
298 double Qrms = QrmsTS[ind - 1][ts - 1] / ievt_ - Qmean * Qmean;
299 h2QrmsTSvsCh->setBinContent(ind, ts,
sqrt(Qrms));
301 ModuleSum[
mod] += sum;
302 SectorSum[
sec] += sum;
303 float isum =
float(
int(sum * 10. + 0.5)) / 10.;
305 h2QmeanMap->setBinContent(
mod + 1,
sec + 1, isum);
309 hModule->setBinContent(
mod + 1, ModuleSum[
mod]);
311 hSector->setBinContent(
sec + 1, SectorSum[
sec]);
315 for (
int mod = 0; mod < 14; mod++)
316 for (
int sec = 0; sec < 16; sec++) {
319 int ind = ModSecToIndex(mod, sec);
320 double Qmean = QmeanTS[ind][TSped] / ievt_;
321 double Qrms = QrmsTS[ind][TSped] / ievt_ - Qmean * Qmean;
322 float ChanStatus = 0.;
323 if (Qrms < Qrms_DEAD)
325 h2status->setBinContent(mod + 1, sec + 1, ChanStatus);
328 for (
int ts = 0; ts < TS_MAX - 1; ts++) {
329 float a = h2QmeantsvsCh->getTProfile2D()->GetBinContent(ind + 1, ts + 1) +
330 h2QmeantsvsCh->getTProfile2D()->GetBinContent(ind + 1, ts + 2);
336 for (
int ts = 0; ts < TS_MAX; ts++)
337 sum += h2QmeantsvsCh->getTProfile2D()->GetBinContent(ind + 1, ts + 1);
341 r = 1. - (sum - am) / (TS_MAX - 2) / am * 2.;
344 h2TSratio->setBinContent(mod + 1, sec + 1, r);
347 float statusTS = 1.0;
348 if (r > RatioThresh1)
349 statusTS = repChanWarning;
351 statusTS = repChanBAD;
352 float gChanStatus = statusTS;
354 gChanStatus = repChanBAD;
355 h2qualityMap->setBinContent(mod + 1, sec + 1, gChanStatus);
356 if (gChanStatus > repChanBAD)
359 hReport->Fill(
float(nGoodCh) / N_GoodChannels);
365 LogPrint(
"CastorDigiMonitor") <<
"DigiMonitor::endRun: trigger max index = " << TrigIndexMax
366 <<
" TriggerIndexies(N):" << endl;
367 for (
int i = 1;
i < hpTrigRes->getTProfile()->GetNbinsX();
i++)
368 if (hpTrigRes->getTProfile()->GetBinContent(
i) > 0)
369 LogPrint(
"CastorDigiMonitor") <<
i - 1 <<
"(" << hpTrigRes->getTProfile()->GetBinContent(
i) <<
") ";
373 int nTriggers = TrigResults.
size();
375 bool event_triggered =
false;
377 for (
int iTrig = 0; iTrig < nTriggers; ++iTrig) {
378 if (TrigResults.
accept(iTrig)) {
380 if (TrigIndexMax < index)
381 TrigIndexMax =
index;
384 <<
" index= " << index << endl;
385 hpTrigRes->Fill(index, Etotal);
386 for (
int n = 0;
n <
int(HltPaths_.size());
n++) {
387 if (trigName.
triggerName(iTrig).find(HltPaths_[
n]) != std::string::npos)
388 event_triggered =
true;
401 if (fVerbosity > 0) {
402 LogPrint(
"CastorDigiMonitor") <<
" CastorChQuality in CondDB=" << dbChQuality.
isValid() << endl;
410 N_GoodChannels = 224 - channels.size();
412 LogPrint(
"CastorDigiMonitor") <<
"CastorDigiMonitor::getDBData: QualityRcdSize=" << channels.size();
413 for (std::vector<DetId>::iterator ch = channels.begin(); ch != channels.end(); ch++) {
416 int rawId = quality->
rawId();
420 if (mod > 0 && mod < 16 && sec > 0 && sec < 16)
423 LogPrint(
"CastorDigiMonitor") << chInd <<
" module=" << mod <<
" sec=" << sec <<
" rawId=" << rawId
424 <<
" value=" << value << endl;
430 int ind = sector + module * 16;
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int sector() const
get the sector (1-16)
MonitorElement * bookFloat(TString const &name)
constexpr bool er() const
is the error bit set?
virtual void setOption(const char *option)
void setCurrentFolder(std::string const &fullpath)
const HcalQIESample & sample(int i) const
access a sample
MonitorElement * book1DD(TString const &name, TString const &title, int nchX, double lowX, double highX)
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
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)
unsigned int triggerIndex(std::string const &name) const
uint32_t getValue() const
unsigned int size() const
Get number of paths stored.
MonitorElement * bookProfile(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, char const *option="s")
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &)
MonitorElement * bookProfile2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, double lowZ, double highZ, char const *option="s")
virtual TProfile2D * getTProfile2D() 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]
std::string const & triggerName(unsigned int index) const
virtual TProfile * getTProfile() 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 * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
const HcalCastorDetId & id() const
T mod(const T &a, const T &b)
int size() const
total number of samples in the digi
const_iterator begin() const
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)