17 #include <TDirectoryFile.h> 29 typedef std::tuple<int, int, int>
IdVFAT;
40 Float_t fNumErrVFAT = 0,
41 Float_t fNumWarnVFAT = 0,
42 Float_t fNumErrOH = 0,
43 Float_t fNumWarnOH = 0,
44 Float_t fNumErrAMC = 0,
45 Float_t fNumWarnAMC = 0,
46 Float_t fNumErrAMC13 = 0)
47 : fNumTotal_(fNumTotal),
49 fNumErrVFAT_(fNumErrVFAT),
50 fNumWarnVFAT_(fNumWarnVFAT),
51 fNumErrOH_(fNumErrOH),
52 fNumWarnOH_(fNumWarnOH),
53 fNumErrAMC_(fNumErrAMC),
54 fNumWarnAMC_(fNumWarnAMC),
55 fNumErrAMC13_(fNumErrAMC13) {}
75 void createTableWatchingSummary();
85 std::vector<MonitorElement *> &listOccPlots,
105 std::string strName, Int_t nIdxX, Int_t nIdxY, Float_t fAll, Float_t fNumOcc, Float_t fNumErr, Float_t fNumWarn);
107 Int_t UpdateStatusChamber(Int_t nIdxLayer, Int_t nIdxCh, Int_t nLumiCurr, NumStatus numStatus);
108 Int_t UpdateStatusChamber(Int_t nIdxLayer, Int_t nIdxCh, Int_t nIdxVFAT, Int_t nLumiCurr, NumStatus numStatus);
109 Int_t UpdateStatusChamber(std::vector<StatusInfo> &listStatus,
110 NumStatus &numStatus,
112 NumStatus numStatusNew);
122 const Int_t nCodeFine_ = 1;
123 const Int_t nCodeError_ = 2;
124 const Int_t nCodeWarning_ = 3;
125 const Int_t nCodeLowError_ = 4;
127 const Int_t nBitWarnVFAT_ = 7;
128 const Int_t nBitErrVFAT_ = 6;
129 const Int_t nBitWarnOH_ = 5;
130 const Int_t nBitErrOH_ = 4;
131 const Int_t nBitWarnAMC_ = 3;
132 const Int_t nBitErrAMC_ = 2;
133 const Int_t nBitErrAMC13_ = 1;
134 const Int_t nBitOcc_ = 0;
136 const Int_t nNumVFATs_ = 24;
138 const Int_t nMaxLumi_ = 6000;
158 fCutErr_ =
cfg.getParameter<
double>(
"cutErr");
159 fCutLowErr_ =
cfg.getParameter<
double>(
"cutLowErr");
160 fCutWarn_ =
cfg.getParameter<
double>(
"cutWarn");
161 nResolutionLumi_ =
cfg.getParameter<
int>(
"resolutionLumi");
162 bIsStatusChambersInit_ =
false;
167 desc.add<
double>(
"cutErr", 0.05);
168 desc.add<
double>(
"cutLowErr", 0.00);
169 desc.add<
double>(
"cutWarn", 0.05);
170 desc.add<
int>(
"resolutionLumi", 1);
171 descriptions.
add(
"GEMDQMHarvester",
desc);
180 drawSummaryHistogram(store, nLumiCurr);
184 Float_t fReportSummary = -1.0;
186 std::string strSrcStatusA =
"GEM/DAQStatus/chamberAllStatus";
187 std::string strSrcStatusE =
"GEM/DAQStatus/chamberErrors";
188 std::string strSrcStatusW =
"GEM/DAQStatus/chamberWarnings";
189 std::string strSrcStatusEVFAT =
"GEM/DAQStatus/chamberVFATErrors";
190 std::string strSrcStatusWVFAT =
"GEM/DAQStatus/chamberVFATWarnings";
191 std::string strSrcStatusEOH =
"GEM/DAQStatus/chamberOHErrors";
192 std::string strSrcStatusWOH =
"GEM/DAQStatus/chamberOHWarnings";
193 std::string strSrcStatusEAMC =
"GEM/DAQStatus/chamberAMCErrors";
194 std::string strSrcStatusWAMC =
"GEM/DAQStatus/chamberAMCWarnings";
195 std::string strSrcStatusEAMC13 =
"GEM/DAQStatus/chamberAMC13Errors";
198 std::string strSrcVFATStatusW =
"GEM/DAQStatus/vfat_statusWarnSum";
199 std::string strSrcVFATStatusE =
"GEM/DAQStatus/vfat_statusErrSum";
216 getGeometryInfo(store, h2SrcStatusE);
218 if (h2SrcStatusA !=
nullptr && h2SrcStatusE !=
nullptr && h2SrcStatusW !=
nullptr) {
220 createSummaryHist(store, h2SrcStatusE, h2Sum);
221 createTableWatchingSummary();
223 std::vector<MonitorElement *> listOccPlots(listLayer_.size() + 1);
224 for (
const auto &strSuffix : listLayer_) {
225 if (mapIdxLayer_.find(strSuffix) == mapIdxLayer_.end())
227 auto nIdxLayer = mapIdxLayer_[strSuffix];
229 if (h2SrcVFATOcc ==
nullptr)
231 listOccPlots[nIdxLayer] = h2SrcVFATOcc;
234 fReportSummary = refineSummaryHistogram(strTitleSummary,
249 for (
const auto &strSuffix : listLayer_) {
250 if (mapIdxLayer_.find(strSuffix) == mapIdxLayer_.end())
252 auto nIdxLayer = mapIdxLayer_[strSuffix];
256 if (h2SrcVFATOcc ==
nullptr || h2SrcVFATStatusW ==
nullptr || h2SrcVFATStatusE ==
nullptr)
260 createSummaryVFAT(store, h2SrcVFATStatusE, strSuffix, h2SumVFAT);
261 refineSummaryVFAT(strSuffix, h2SumVFAT, h2SrcVFATOcc, h2SrcVFATStatusE, h2SrcVFATStatusW, nLumiCurr, nIdxLayer);
262 TString strNewTitle = h2SrcVFATStatusE->
getTitle();
263 h2SumVFAT->
setTitle((
const char *)strNewTitle.ReplaceAll(
"errors",
"errors/warnings"));
267 createLumiFuncHist(store, strSuffix, nIdxLayer, nLumiCurr);
271 for (
const auto &strSuffix : listLayer_) {
272 if (mapIdxLayer_.find(strSuffix) == mapIdxLayer_.end())
275 Int_t nNumChamber = 36;
276 createInactiveChannelFracHist(store, strSuffix, nNumChamber);
283 if (bIsStatusChambersInit_)
286 for (
const auto &[nIdxLayer, nNumCh] : mapNumChPerChamber_) {
287 for (Int_t
i = 1;
i <= nNumCh;
i++) {
288 mapStatusChambersSummary_[{nIdxLayer,
i}] = std::vector<StatusInfo>();
289 mapNumStatusChambersSummary_[{nIdxLayer,
i}] =
NumStatus();
290 for (Int_t
j = 1;
j <= nNumVFATs_;
j++) {
291 mapStatusVFATsSummary_[{nIdxLayer,
i,
j}] = std::vector<StatusInfo>();
292 mapNumStatusVFATsSummary_[{nIdxLayer,
i,
j}] =
NumStatus();
297 bIsStatusChambersInit_ =
true;
303 for (Int_t
i = 1;
i <=
nBinX;
i++) {
306 for (Int_t
i = 1;
i <=
nBinY;
i++) {
316 mapIdxLayer_.clear();
317 mapNumChPerChamber_.clear();
319 if (h2Src !=
nullptr) {
321 listLayer_.push_back(
"");
323 for (Int_t
i = 1;
i <=
nBinY;
i++) {
325 auto nPos = strLabelFull.find(
';');
326 auto strLayer = strLabelFull.substr(nPos + 1);
328 if (nBinXActual > 108) {
329 if (strLayer.find(
"GE11") != std::string::npos) {
331 }
else if (strLayer.find(
"GE21") != std::string::npos) {
333 }
else if (strLayer.find(
"GE01") != std::string::npos) {
337 listLayer_.push_back(strLayer);
338 mapIdxLayer_[strLayer] =
i;
339 mapNumChPerChamber_[
i] = nBinXActual;
342 listLayer_.push_back(
"");
343 if (store->
get(
"GEM/Digis/occupancy_GE11-M-L1/occ_GE11-M-01L1-S") !=
nullptr) {
344 listLayer_.push_back(
"_GE11-P-L2");
345 listLayer_.push_back(
"_GE11-P-L1");
346 listLayer_.push_back(
"_GE11-M-L1");
347 listLayer_.push_back(
"_GE11-M-L2");
348 mapIdxLayer_[
"_GE11-P-L2"] = 1;
349 mapIdxLayer_[
"_GE11-P-L1"] = 2;
350 mapIdxLayer_[
"_GE11-M-L1"] = 3;
351 mapIdxLayer_[
"_GE11-M-L2"] = 4;
352 mapNumChPerChamber_[1] = 36;
353 mapNumChPerChamber_[2] = 36;
354 mapNumChPerChamber_[3] = 36;
355 mapNumChPerChamber_[4] = 36;
385 copyLabels(h2Src, h2Sum);
389 std::string strName, Int_t nIdxX, Int_t nIdxY, Float_t fAll, Float_t fNumOcc, Float_t fNumErr, Float_t fNumWarn) {
390 if (fNumErr > fCutErr_ * fAll)
392 else if (fNumErr > fCutLowErr_ * fAll)
393 return nCodeLowError_;
394 else if (fNumWarn > fCutWarn_ * fAll)
395 return nCodeWarning_;
396 else if (fNumOcc > 0)
405 std::vector<MonitorElement *> &listOccPlots,
418 Int_t nAllBin = 0, nFineBin = 0;
419 for (Int_t
j = 1;
j <=
nBinY;
j++) {
421 auto h2SrcOcc = listOccPlots[
j];
423 if (h2SrcOcc !=
nullptr) {
424 nBinYOcc = h2SrcOcc->getNbinsY();
428 for (Int_t
i = 1;
i <=
nBinX;
i++) {
430 for (Int_t r = 1; r <= nBinYOcc; r++) {
431 fOcc += h2SrcOcc->getBinContent(
i, r);
437 Float_t fStatusErrVFAT = h2SrcStatusEVFAT !=
nullptr ? h2SrcStatusEVFAT->
getBinContent(
i,
j) : 0;
438 Float_t fStatusWarnVFAT = h2SrcStatusWVFAT !=
nullptr ? h2SrcStatusWVFAT->
getBinContent(
i,
j) : 0;
439 Float_t fStatusErrOH = h2SrcStatusEOH !=
nullptr ? h2SrcStatusEOH->
getBinContent(
i,
j) : 0;
440 Float_t fStatusWarnOH = h2SrcStatusWOH !=
nullptr ? h2SrcStatusWOH->
getBinContent(
i,
j) : 0;
441 Float_t fStatusErrAMC = h2SrcStatusEAMC !=
nullptr ? h2SrcStatusEAMC->
getBinContent(
i,
j) : 0;
442 Float_t fStatusWarnAMC = h2SrcStatusWAMC !=
nullptr ? h2SrcStatusWAMC->
getBinContent(
i,
j) : 0;
443 Float_t fStatusErrAMC13 = h2SrcStatusEAMC13 !=
nullptr ? h2SrcStatusEAMC13->
getBinContent(
i,
j) : 0;
453 UpdateStatusChamber(
j,
i, nLumiCurr, numStatus);
455 Int_t nRes = assessOneBin(strName,
i,
j, fStatusAll, fOcc, fStatusErr, fStatusWarn);
464 return ((Float_t)nFineBin) / nAllBin;
475 for (Int_t
j = 1;
j <=
nBinY;
j++) {
477 for (Int_t
i = 1;
i <=
nBinX;
i++) {
481 Float_t fStatusAll = fOcc + fStatusErr + fStatusWarn;
482 NumStatus numStatus(fStatusAll, fOcc, fStatusErr, fStatusWarn, 0, 0, 0, 0, 0);
483 UpdateStatusChamber(nIdxLayer,
i,
j, nLumiCurr, numStatus);
485 Int_t nRes = assessOneBin(strName,
i,
j, fStatusAll, fOcc, fStatusErr, fStatusWarn);
494 if (!bIsStatusChambersInit_)
496 if (0 >= nIdxCh || nIdxCh > mapNumChPerChamber_[nIdxLayer])
498 auto &listStatus = mapStatusChambersSummary_[{nIdxLayer, nIdxCh}];
499 auto &numStatusPrev = mapNumStatusChambersSummary_[{nIdxLayer, nIdxCh}];
500 return UpdateStatusChamber(listStatus, numStatusPrev, nLumiCurr, numStatus);
504 Int_t nIdxLayer, Int_t nIdxCh, Int_t nIdxVFAT, Int_t nLumiCurr,
NumStatus numStatus) {
505 if (!bIsStatusChambersInit_)
507 if (0 >= nIdxCh || nIdxCh > mapNumChPerChamber_[nIdxLayer])
509 if (0 >= nIdxVFAT || nIdxVFAT > nNumVFATs_)
511 auto &listStatus = mapStatusVFATsSummary_[{nIdxLayer, nIdxCh, nIdxVFAT}];
512 auto &numStatusPrev = mapNumStatusVFATsSummary_[{nIdxLayer, nIdxCh, nIdxVFAT}];
513 return UpdateStatusChamber(listStatus, numStatusPrev, nLumiCurr, numStatus);
541 nStatus = (numStatusNew.
fNumOcc_ > 0 ? 1 << nBitOcc_ : 0) | (fNumAddErrAMC13 > 0 ? 1 << nBitErrAMC13_ : 0) |
542 (fNumAddErrAMC > 0 ? 1 << nBitErrAMC_ : 0) | (fNumAddWarnAMC > 0 ? 1 << nBitWarnAMC_ : 0) |
543 (fNumAddErrOH > 0 ? 1 << nBitErrOH_ : 0) | (fNumAddWarnOH > 0 ? 1 << nBitWarnOH_ : 0) |
544 (fNumAddErrVFAT > 0 ? 1 << nBitErrVFAT_ : 0) | (fNumAddWarnVFAT > 0 ? 1 << nBitWarnVFAT_ : 0);
552 if (listStatus.empty()) {
553 listStatus.push_back(statusNew);
555 auto &statusLastPre = listStatus.back();
556 if (statusLastPre.nStatus == nStatus) {
557 statusLastPre.nLumiEnd = nLumiCurr;
559 listStatus.push_back(statusNew);
570 auto &nNumCh = mapNumChPerChamber_[nIdxLayer];
575 Int_t nNumBinLumi = ((nLumiCurr - 1) / nResolutionLumi_) + 1;
579 if (mapHistLumiFunc_.find(nIdxLayer) == mapHistLumiFunc_.end()) {
581 h2Summary = store->
book2S(
"chamberStatus_inLumi" + strSuffix,
582 "Chamber status on lumi-block " + strSuffix.substr(1),
583 nMaxLumi_ / nResolutionLumi_,
585 (Float_t)(nMaxLumi_ + 1),
590 mapHistLumiFunc_[nIdxLayer] = h2Summary;
592 h2Summary->
setXTitle(
"Luminosity block");
594 for (Int_t
i = 1;
i <= nNumCh;
i++) {
598 h2Summary = mapHistLumiFunc_[nIdxLayer];
601 for (Int_t nIdxCh = 1; nIdxCh <= nNumCh; nIdxCh++) {
602 auto &listStatus = mapStatusChambersSummary_[{nIdxLayer, nIdxCh}];
604 Int_t nIdxStatus = 0;
605 for (Int_t nIdxLumi = 0; nIdxLumi < nNumBinLumi; nIdxLumi++) {
607 Int_t nLumiStart = 1 + nIdxLumi * nResolutionLumi_;
608 Int_t nLumiEnd = (1 + nIdxLumi) * nResolutionLumi_;
609 if (nLumiEnd > nLumiCurr)
610 nLumiEnd = nLumiCurr;
612 Int_t nStatusSum = 0;
616 if (listStatus[nIdxStatus].nLumiEnd < nLumiStart) {
618 if (nIdxStatus >= (
int)listStatus.size()) {
624 nStatusSum = listStatus[nIdxStatus].nStatus;
627 if (nIdxStatus + 1 >= (
int)listStatus.size() || listStatus[nIdxStatus].nLumiEnd >= nLumiEnd) {
632 if (nIdxStatus >= (
int)listStatus.size()) {
638 if (nMaxBin < nIdxLumi + 1)
639 nMaxBin = nIdxLumi + 1;
643 for (Int_t nX = 1; nX <= nMaxBin; nX++) {
650 char cChType = (nIdxCh % 2 == 0 ?
'L' :
'S');
653 if (strSuffix.find(
"-M-") != std::string::npos)
655 else if (strSuffix.find(
"-P-") != std::string::npos)
660 if (strSuffix.find(
"-L1") != std::string::npos)
662 else if (strSuffix.find(
"-L2") != std::string::npos)
668 "GEM/Digis/occupancy_GE11-%c-L%i/occ_GE11-%c-%02iL%i-%c", cRegion, nLayer, cRegion, nIdxCh, nLayer, cChType);
674 char cChType = (nIdxCh % 2 == 0 ?
'L' :
'S');
677 if (strSuffix.find(
"-M-") != std::string::npos)
679 else if (strSuffix.find(
"-P-") != std::string::npos)
684 if (strSuffix.find(
"-L1") != std::string::npos)
686 else if (strSuffix.find(
"-L2") != std::string::npos)
692 "GEM/Digis/occupancy_GE21-%c-L%i/occ_GE21-%c-%02iL%i-%c", cRegion, nLayer, cRegion, nIdxCh, nLayer, cChType);
702 std::string strTitle =
"The fraction of inactive channels in " + strSuffix.substr(1);
704 store->
book1D(
"inactive_frac_chamber" + strSuffix, strTitle, nNumChamber, 0.5, nNumChamber + 0.5);
706 h2InactiveChannel->
setYTitle(
"Fraction of inactive channels");
707 for (Int_t
i = 1;
i <= nNumChamber;
i++) {
713 if (strSuffix.find(
"_GE11") != std::string::npos) {
715 }
else if (strSuffix.find(
"_GE21") != std::string::npos) {
719 for (Int_t nIdxCh = 1; nIdxCh <= nNumChamber; nIdxCh++) {
720 std::string strNameCh = funcNameCh(strSuffix, nIdxCh);
722 if (h2SrcChamberOcc ==
nullptr) {
727 Int_t nNumBinX = h2SrcChamberOcc->
getNbinsX();
728 Int_t nNumBinY = h2SrcChamberOcc->
getNbinsY();
729 Int_t nNumAllChannel = nNumBinX * nNumBinY;
730 auto *histData = h2SrcChamberOcc->
getTH2F();
731 auto *pdData = histData->GetArray();
732 Int_t nNumChannelInactive = 0;
733 for (Int_t
j = 1;
j <= nNumBinY;
j++)
734 for (Int_t
i = 1;
i <= nNumBinX;
i++) {
735 if (pdData[
j * (nNumBinX + 2) +
i] <= 0) {
736 nNumChannelInactive++;
739 h2InactiveChannel->
setBinContent(nIdxCh, ((Double_t)nNumChannelInactive) / nNumAllChannel);
virtual void setTitle(const std::string &title)
set (ie. change) histogram/profile title
std::map< std::string, int > mapIdxLayer_
LuminosityBlockNumber_t luminosityBlock() 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())
void createInactiveChannelFracHist(edm::Service< DQMStore > &store, std::string strSuffix, Int_t nNumChamber)
void setCurrentFolder(std::string const &fullpath) override
virtual std::string getAxisTitle(int axis=1) const
get x-, y- or z-axis title (axis=1, 2, 3 respectively)
~GEMDQMHarvester() override
std::string getNameChamberOccGE21(std::string strSuffix, Int_t nIdxCh)
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)
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_
virtual TH2F * getTH2F() const
std::map< IdVFAT, std::vector< StatusInfo > > mapStatusVFATsSummary_
void drawSummaryHistogram(edm::Service< DQMStore > &store, Int_t nLumiCurr)
virtual void setXTitle(std::string const &title)
std::tuple< int, int > IdChamber
std::vector< std::vector< Float_t > > TableStatusOcc
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_
#define DEFINE_FWK_MODULE(type)
Int_t assessOneBin(std::string strName, Int_t nIdxX, Int_t nIdxY, Float_t fAll, Float_t fNumOcc, Float_t fNumErr, Float_t fNumWarn)
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 int getNbinsY() const
get # of bins in Y-axis
void getGeometryInfo(edm::Service< DQMStore > &store, MonitorElement *h2Src)
virtual std::string getTitle() const
get MonitorElement title
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)
LuminosityBlockID id() const
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
GEMDQMHarvester(const edm::ParameterSet &)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Int_t UpdateStatusChamber(Int_t nIdxLayer, Int_t nIdxCh, Int_t nLumiCurr, NumStatus numStatus)
virtual MonitorElement * get(std::string const &fullpath) const
std::map< IdChamber, NumStatus > mapNumStatusChambersSummary_
std::vector< std::vector< Int_t > > TableStatusNum
virtual int getNbinsX() const
get # of bins in X-axis
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())
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
virtual double getBinContent(int binx) const
get content of bin (1-D)
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override