19 #include <TDirectoryFile.h>
31 typedef std::tuple<int, int, int>
IdVFAT;
42 Float_t fNumErrVFAT = 0,
43 Float_t fNumWarnVFAT = 0,
44 Float_t fNumErrOH = 0,
45 Float_t fNumWarnOH = 0,
46 Float_t fNumErrAMC = 0,
47 Float_t fNumWarnAMC = 0,
48 Float_t fNumErrAMC13 = 0)
49 : fNumTotal_(fNumTotal),
51 fNumErrVFAT_(fNumErrVFAT),
52 fNumWarnVFAT_(fNumWarnVFAT),
53 fNumErrOH_(fNumErrOH),
54 fNumWarnOH_(fNumWarnOH),
55 fNumErrAMC_(fNumErrAMC),
56 fNumWarnAMC_(fNumWarnAMC),
57 fNumErrAMC13_(fNumErrAMC13) {}
77 void createTableWatchingSummary();
87 std::vector<MonitorElement *> &listOccPlots,
107 std::string strName, Int_t nIdxX, Int_t nIdxY, Float_t fAll, Float_t fNumOcc, Float_t fNumErr, Float_t fNumWarn);
109 Int_t UpdateStatusChamber(Int_t nIdxLayer, Int_t nIdxCh, Int_t nLumiCurr, NumStatus numStatus);
110 Int_t UpdateStatusChamber(Int_t nIdxLayer, Int_t nIdxCh, Int_t nIdxVFAT, Int_t nLumiCurr, NumStatus numStatus);
111 Int_t UpdateStatusChamber(std::vector<StatusInfo> &listStatus,
112 NumStatus &numStatus,
114 NumStatus numStatusNew);
124 const Int_t nCodeFine_ = 1;
125 const Int_t nCodeError_ = 2;
126 const Int_t nCodeWarning_ = 3;
127 const Int_t nCodeLowError_ = 4;
129 const Int_t nBitWarnVFAT_ = 7;
130 const Int_t nBitErrVFAT_ = 6;
131 const Int_t nBitWarnOH_ = 5;
132 const Int_t nBitErrOH_ = 4;
133 const Int_t nBitWarnAMC_ = 3;
134 const Int_t nBitErrAMC_ = 2;
135 const Int_t nBitErrAMC13_ = 1;
136 const Int_t nBitOcc_ = 0;
138 const Int_t nNumVFATs_ = 24;
140 const Int_t nMaxLumi_ = 6000;
163 nResolutionLumi_ = cfg.
getParameter<
int>(
"resolutionLumi");
164 bIsStatusChambersInit_ =
false;
169 desc.
add<
double>(
"cutErr", 0.05);
170 desc.
add<
double>(
"cutLowErr", 0.00);
171 desc.
add<
double>(
"cutWarn", 0.05);
172 desc.
add<
int>(
"resolutionLumi", 1);
173 descriptions.
add(
"GEMDQMHarvester", desc);
182 drawSummaryHistogram(store, nLumiCurr);
186 Float_t fReportSummary = -1.0;
188 std::string strSrcStatusA =
"GEM/DAQStatus/chamberAllStatus";
189 std::string strSrcStatusE =
"GEM/DAQStatus/chamberErrors";
190 std::string strSrcStatusW =
"GEM/DAQStatus/chamberWarnings";
191 std::string strSrcStatusEVFAT =
"GEM/DAQStatus/chamberVFATErrors";
192 std::string strSrcStatusWVFAT =
"GEM/DAQStatus/chamberVFATWarnings";
193 std::string strSrcStatusEOH =
"GEM/DAQStatus/chamberOHErrors";
194 std::string strSrcStatusWOH =
"GEM/DAQStatus/chamberOHWarnings";
195 std::string strSrcStatusEAMC =
"GEM/DAQStatus/chamberAMCErrors";
196 std::string strSrcStatusWAMC =
"GEM/DAQStatus/chamberAMCWarnings";
197 std::string strSrcStatusEAMC13 =
"GEM/DAQStatus/chamberAMC13Errors";
200 std::string strSrcVFATStatusW =
"GEM/DAQStatus/vfat_statusWarnSum";
201 std::string strSrcVFATStatusE =
"GEM/DAQStatus/vfat_statusErrSum";
218 getGeometryInfo(store, h2SrcStatusEOH);
220 if (h2SrcStatusA !=
nullptr && h2SrcStatusE !=
nullptr && h2SrcStatusW !=
nullptr && h2SrcStatusEVFAT !=
nullptr &&
221 h2SrcStatusWVFAT !=
nullptr && h2SrcStatusEOH !=
nullptr && h2SrcStatusWOH !=
nullptr &&
222 h2SrcStatusEAMC !=
nullptr && h2SrcStatusWAMC !=
nullptr && h2SrcStatusEAMC13 !=
nullptr) {
224 createSummaryHist(store, h2SrcStatusEOH, h2Sum);
225 createTableWatchingSummary();
227 std::vector<MonitorElement *> listOccPlots(listLayer_.size() + 1);
228 for (
const auto &strSuffix : listLayer_) {
229 if (mapIdxLayer_.find(strSuffix) == mapIdxLayer_.end())
231 auto nIdxLayer = mapIdxLayer_[strSuffix];
233 if (h2SrcVFATOcc ==
nullptr)
235 listOccPlots[nIdxLayer] = h2SrcVFATOcc;
238 fReportSummary = refineSummaryHistogram(strTitleSummary,
253 for (
const auto &strSuffix : listLayer_) {
254 if (mapIdxLayer_.find(strSuffix) == mapIdxLayer_.end())
256 auto nIdxLayer = mapIdxLayer_[strSuffix];
260 if (h2SrcVFATOcc ==
nullptr || h2SrcVFATStatusW ==
nullptr || h2SrcVFATStatusE ==
nullptr)
264 createSummaryVFAT(store, h2SrcVFATStatusE, strSuffix, h2SumVFAT);
265 refineSummaryVFAT(strSuffix, h2SumVFAT, h2SrcVFATOcc, h2SrcVFATStatusE, h2SrcVFATStatusW, nLumiCurr, nIdxLayer);
266 TString strNewTitle = h2SrcVFATStatusE->
getTitle();
267 h2SumVFAT->
setTitle((
const char *)strNewTitle.ReplaceAll(
"errors",
"errors/warnings"));
271 createLumiFuncHist(store, strSuffix, nIdxLayer, nLumiCurr);
275 for (
const auto &strSuffix : listLayer_) {
276 if (mapIdxLayer_.find(strSuffix) == mapIdxLayer_.end())
278 auto nNumChamber = mapNumChPerChamber_[mapIdxLayer_[strSuffix]];
279 createInactiveChannelFracHist(store, strSuffix, nNumChamber);
286 if (bIsStatusChambersInit_)
289 for (
const auto &[nIdxLayer, nNumCh] : mapNumChPerChamber_) {
290 for (Int_t
i = 1;
i <= nNumCh;
i++) {
291 mapStatusChambersSummary_[{nIdxLayer,
i}] = std::vector<StatusInfo>();
292 mapNumStatusChambersSummary_[{nIdxLayer,
i}] =
NumStatus();
293 for (Int_t
j = 1;
j <= nNumVFATs_;
j++) {
294 mapStatusVFATsSummary_[{nIdxLayer,
i,
j}] = std::vector<StatusInfo>();
295 mapNumStatusVFATsSummary_[{nIdxLayer,
i,
j}] =
NumStatus();
300 bIsStatusChambersInit_ =
true;
306 for (Int_t
i = 1;
i <= nBinX;
i++) {
309 for (Int_t
i = 1;
i <= nBinY;
i++) {
318 if (h2Src !=
nullptr) {
320 mapIdxLayer_.clear();
321 mapNumChPerChamber_.clear();
324 listLayer_.push_back(
"");
326 for (Int_t
i = 1;
i <= nBinY;
i++) {
329 auto nPos = strLabelFull.find(
';');
330 auto strLayer = strLabelFull.substr(nPos + 1);
331 listLayer_.push_back(strLayer);
332 mapIdxLayer_[strLayer] =
i;
333 mapNumChPerChamber_[
i] = nBinXActual;
336 listLayer_.push_back(
"");
337 if (store->
get(
"GEM/Digis/occupancy_GE11-M-L1/occ_GE11-M-01L1-S") !=
nullptr) {
338 listLayer_.push_back(
"_GE11-P-L2");
339 listLayer_.push_back(
"_GE11-P-L1");
340 listLayer_.push_back(
"_GE11-M-L1");
341 listLayer_.push_back(
"_GE11-M-L2");
342 mapIdxLayer_[
"_GE11-P-L2"] = 1;
343 mapIdxLayer_[
"_GE11-P-L1"] = 2;
344 mapIdxLayer_[
"_GE11-M-L1"] = 3;
345 mapIdxLayer_[
"_GE11-M-L2"] = 4;
346 mapNumChPerChamber_[1] = 36;
347 mapNumChPerChamber_[2] = 36;
348 mapNumChPerChamber_[3] = 36;
349 mapNumChPerChamber_[4] = 36;
359 h2Sum = store->
book2D(
"reportSummaryMap",
"", nBinX, 0.5, nBinX + 0.5, nBinY, 0.5, nBinY + 0.5);
364 for (Int_t
i = 1;
i <= nBinX;
i++)
366 for (Int_t
i = 1;
i <= nBinY;
i++)
378 h2Sum = store->
book2D(
"vfat_statusSummary" + strSuffix,
"", nBinX, 0.5, nBinX + 0.5, nBinY, -0.5, nBinY - 0.5);
379 copyLabels(h2Src, h2Sum);
383 std::string strName, Int_t nIdxX, Int_t nIdxY, Float_t fAll, Float_t fNumOcc, Float_t fNumErr, Float_t fNumWarn) {
384 if (fNumErr > fCutErr_ * fAll)
386 else if (fNumErr > fCutLowErr_ * fAll)
387 return nCodeLowError_;
388 else if (fNumWarn > fCutWarn_ * fAll)
389 return nCodeWarning_;
390 else if (fNumOcc > 0)
399 std::vector<MonitorElement *> &listOccPlots,
412 Int_t nAllBin = 0, nFineBin = 0;
413 for (Int_t
j = 1;
j <= nBinY;
j++) {
415 auto h2SrcOcc = listOccPlots[
j];
417 if (h2SrcOcc !=
nullptr) {
418 nBinYOcc = h2SrcOcc->getNbinsY();
422 for (Int_t
i = 1;
i <= nBinX;
i++) {
424 for (Int_t
r = 1;
r <= nBinYOcc;
r++) {
425 fOcc += h2SrcOcc->getBinContent(
i,
r);
447 UpdateStatusChamber(
j,
i, nLumiCurr, numStatus);
449 Int_t nRes = assessOneBin(strName,
i,
j, fStatusAll, fOcc, fStatusErr, fStatusWarn);
458 return ((Float_t)nFineBin) / nAllBin;
469 for (Int_t
j = 1;
j <= nBinY;
j++) {
471 for (Int_t
i = 1;
i <= nBinX;
i++) {
475 Float_t fStatusAll = fOcc + fStatusErr + fStatusWarn;
476 NumStatus numStatus(fStatusAll, fOcc, fStatusErr, fStatusWarn, 0, 0, 0, 0, 0);
477 UpdateStatusChamber(nIdxLayer,
i,
j, nLumiCurr, numStatus);
479 Int_t nRes = assessOneBin(strName,
i,
j, fStatusAll, fOcc, fStatusErr, fStatusWarn);
488 if (!bIsStatusChambersInit_)
490 if (0 >= nIdxCh || nIdxCh > mapNumChPerChamber_[nIdxLayer])
492 auto &listStatus = mapStatusChambersSummary_[{nIdxLayer, nIdxCh}];
493 auto &numStatusPrev = mapNumStatusChambersSummary_[{nIdxLayer, nIdxCh}];
494 return UpdateStatusChamber(listStatus, numStatusPrev, nLumiCurr, numStatus);
498 Int_t nIdxLayer, Int_t nIdxCh, Int_t nIdxVFAT, Int_t nLumiCurr,
NumStatus numStatus) {
499 if (!bIsStatusChambersInit_)
501 if (0 >= nIdxCh || nIdxCh > mapNumChPerChamber_[nIdxLayer])
503 if (0 >= nIdxVFAT || nIdxVFAT > nNumVFATs_)
505 auto &listStatus = mapStatusVFATsSummary_[{nIdxLayer, nIdxCh, nIdxVFAT}];
506 auto &numStatusPrev = mapNumStatusVFATsSummary_[{nIdxLayer, nIdxCh, nIdxVFAT}];
507 return UpdateStatusChamber(listStatus, numStatusPrev, nLumiCurr, numStatus);
535 nStatus = (numStatusNew.
fNumOcc_ > 0 ? 1 << nBitOcc_ : 0) | (fNumAddErrAMC13 > 0 ? 1 << nBitErrAMC13_ : 0) |
536 (fNumAddErrAMC > 0 ? 1 << nBitErrAMC_ : 0) | (fNumAddWarnAMC > 0 ? 1 << nBitWarnAMC_ : 0) |
537 (fNumAddErrOH > 0 ? 1 << nBitErrOH_ : 0) | (fNumAddWarnOH > 0 ? 1 << nBitWarnOH_ : 0) |
538 (fNumAddErrVFAT > 0 ? 1 << nBitErrVFAT_ : 0) | (fNumAddWarnVFAT > 0 ? 1 << nBitWarnVFAT_ : 0);
546 if (listStatus.empty()) {
547 listStatus.push_back(statusNew);
549 auto &statusLastPre = listStatus.back();
550 if (statusLastPre.nStatus == nStatus) {
551 statusLastPre.nLumiEnd = nLumiCurr;
553 listStatus.push_back(statusNew);
564 auto &nNumCh = mapNumChPerChamber_[nIdxLayer];
569 Int_t nNumBinLumi = ((nLumiCurr - 1) / nResolutionLumi_) + 1;
573 if (mapHistLumiFunc_.find(nIdxLayer) == mapHistLumiFunc_.end()) {
575 h2Summary = store->
book2S(
"chamberStatus_inLumi" + strSuffix,
576 "Chamber status on lumi-block " + strSuffix.substr(1),
577 nMaxLumi_ / nResolutionLumi_,
579 (Float_t)(nMaxLumi_ + 1),
584 mapHistLumiFunc_[nIdxLayer] = h2Summary;
586 h2Summary->
setXTitle(
"Luminosity block");
588 for (Int_t
i = 1;
i <= nNumCh;
i++) {
592 h2Summary = mapHistLumiFunc_[nIdxLayer];
595 for (Int_t nIdxCh = 1; nIdxCh <= nNumCh; nIdxCh++) {
596 auto &listStatus = mapStatusChambersSummary_[{nIdxLayer, nIdxCh}];
598 Int_t nIdxStatus = 0;
599 for (Int_t nIdxLumi = 0; nIdxLumi < nNumBinLumi; nIdxLumi++) {
601 Int_t nLumiStart = 1 + nIdxLumi * nResolutionLumi_;
602 Int_t nLumiEnd = (1 + nIdxLumi) * nResolutionLumi_;
603 if (nLumiEnd > nLumiCurr)
604 nLumiEnd = nLumiCurr;
606 Int_t nStatusSum = 0;
610 if (listStatus[nIdxStatus].nLumiEnd < nLumiStart) {
612 if (nIdxStatus >= (
int)listStatus.size()) {
618 nStatusSum = listStatus[nIdxStatus].nStatus;
621 if (nIdxStatus + 1 >= (
int)listStatus.size() || listStatus[nIdxStatus].nLumiEnd >= nLumiEnd) {
626 if (nIdxStatus >= (
int)listStatus.size()) {
631 nStatusSum &= ~(1 << nBitOcc_);
633 if (nMaxBin < nIdxLumi + 1)
634 nMaxBin = nIdxLumi + 1;
638 for (Int_t nX = 1; nX <= nMaxBin; nX++) {
645 std::string strChType = (nIdxCh % 2 == 0 ?
"L" :
"S");
648 if (strSuffix.find(
"-M-") != std::string::npos)
650 else if (strSuffix.find(
"-P-") != std::string::npos)
655 if (strSuffix.find(
"-L1") != std::string::npos)
657 else if (strSuffix.find(
"-L2") != std::string::npos)
662 return Form(
"GEM/Digis/occupancy_GE11-%s-L%i/occ_GE11-%s-%02iL%i-%s",
682 std::string strTitle =
"The fraction of inactive channels in " + strSuffix.substr(1);
684 store->
book1D(
"inactive_frac_chamber" + strSuffix, strTitle, nNumChamber, 0.5, nNumChamber + 0.5);
686 h2InactiveChannel->
setYTitle(
"Fraction of inactive channels");
687 for (Int_t
i = 1;
i <= nNumChamber;
i++) {
693 if (strSuffix.find(
"_GE11") != std::string::npos) {
695 }
else if (strSuffix.find(
"_GE21") != std::string::npos) {
699 for (Int_t nIdxCh = 1; nIdxCh <= nNumChamber; nIdxCh++) {
700 std::string strNameCh = funcNameCh(strSuffix, nIdxCh);
702 if (h2SrcChamberOcc ==
nullptr) {
707 Int_t nNumBinX = h2SrcChamberOcc->
getNbinsX();
708 Int_t nNumBinY = h2SrcChamberOcc->
getNbinsY();
709 Int_t nNumChannelInactive = 0;
710 for (Int_t
i = 1;
i <= nNumBinX;
i++)
711 for (Int_t
j = 1;
j <= nNumBinY;
j++) {
713 nNumChannelInactive++;
717 Int_t nNumAllChannel = nNumBinX * nNumBinY;
718 h2InactiveChannel->
setBinContent(nIdxCh, ((Double_t)nNumChannelInactive) / nNumAllChannel);
LuminosityBlockID id() const
virtual std::string getTitle() const
get MonitorElement title
virtual void setTitle(const std::string &title)
set (ie. change) histogram/profile title
std::map< std::string, int > mapIdxLayer_
virtual TH2F * getTH2F() const
MonitorElement * bookFloat(TString const &name, FUNC onbooking=NOOP())
void createSummaryVFAT(edm::Service< DQMStore > &store, MonitorElement *h2Src, std::string strSuffix, MonitorElement *&h2Sum)
MonitorElement * book2S(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
virtual int getNbinsY() const
get # of bins in Y-axis
void createInactiveChannelFracHist(edm::Service< DQMStore > &store, std::string strSuffix, Int_t nNumChamber)
#define DEFINE_FWK_MODULE(type)
void setCurrentFolder(std::string const &fullpath) override
~GEMDQMHarvester() override
virtual std::string getAxisTitle(int axis=1) const
get x-, y- or z-axis title (axis=1, 2, 3 respectively)
void copyLabels(MonitorElement *h2Src, MonitorElement *h2Dst)
void dqmEndLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &iLumi, edm::EventSetup const &) override
std::map< IdChamber, std::vector< StatusInfo > > mapStatusChambersSummary_
std::map< IdVFAT, NumStatus > mapNumStatusVFATsSummary_
void createTableWatchingSummary()
std::string getNameChamberOccNull(std::string strSuffix, Int_t nIdxChamber)
std::vector< std::string > listLayer_
std::map< IdVFAT, std::vector< StatusInfo > > mapStatusVFATsSummary_
void drawSummaryHistogram(edm::Service< DQMStore > &store, Int_t nLumiCurr)
virtual void setXTitle(std::string const &title)
virtual int getNbinsX() const
get # of bins in X-axis
std::tuple< int, int > IdChamber
std::vector< std::vector< Float_t > > TableStatusOcc
virtual MonitorElement * get(std::string const &fullpath) const
std::string getNameChamberOccGE11(std::string strSuffix, Int_t nIdxCh)
Bool_t bIsStatusChambersInit_
NumStatus(Float_t fNumTotal=0, Float_t fNumOcc=0, Float_t fNumErrVFAT=0, Float_t fNumWarnVFAT=0, Float_t fNumErrOH=0, Float_t fNumWarnOH=0, Float_t fNumErrAMC=0, Float_t fNumWarnAMC=0, Float_t fNumErrAMC13=0)
std::map< int, MonitorElement * > mapHistLumiFunc_
Int_t assessOneBin(std::string strName, Int_t nIdxX, Int_t nIdxY, Float_t fAll, Float_t fNumOcc, Float_t fNumErr, Float_t fNumWarn)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
virtual void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
virtual double getBinContent(int binx) const
get content of bin (1-D)
std::string getNameChamberOccGE21(std::string strSuffix, Int_t nIdxChamber)
void getGeometryInfo(edm::Service< DQMStore > &store, MonitorElement *h2Src)
virtual void setYTitle(std::string const &title)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
T getParameter(std::string const &) const
GEMDQMHarvester(const edm::ParameterSet &)
LuminosityBlockNumber_t luminosityBlock() const
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Int_t UpdateStatusChamber(Int_t nIdxLayer, Int_t nIdxCh, Int_t nLumiCurr, NumStatus numStatus)
std::map< IdChamber, NumStatus > mapNumStatusChambersSummary_
std::vector< std::vector< Int_t > > TableStatusNum
void createSummaryHist(edm::Service< DQMStore > &store, MonitorElement *h2Src, MonitorElement *&h2Sum)
Int_t refineSummaryVFAT(std::string strName, MonitorElement *h2Sum, MonitorElement *h2SrcOcc, MonitorElement *h2SrcStatusE, MonitorElement *h2SrcStatusW, Int_t nLumiCurr, Int_t nIdxLayer)
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Float_t refineSummaryHistogram(std::string strName, MonitorElement *h2Sum, std::vector< MonitorElement * > &listOccPlots, MonitorElement *h2SrcStatusA, MonitorElement *h2SrcStatusE, MonitorElement *h2SrcStatusW, MonitorElement *h2SrcStatusEVFAT, MonitorElement *h2SrcStatusWVFAT, MonitorElement *h2SrcStatusEOH, MonitorElement *h2SrcStatusWOH, MonitorElement *h2SrcStatusEAMC, MonitorElement *h2SrcStatusWAMC, MonitorElement *h2SrcStatusEAMC13, Int_t nLumiCurr)
std::map< int, int > mapNumChPerChamber_
void createLumiFuncHist(edm::Service< DQMStore > &store, std::string strSuffix, Int_t nIdxLayer, Int_t nLumiCurr)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::tuple< int, int, int > IdVFAT
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override