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();
82 std::vector<std::string> &listLayers,
83 std::map<std::string, int> &mapIdxLayer,
84 std::map<int, int> &mapNumChPerChamber);
111 std::string strName, Int_t nIdxX, Int_t nIdxY, Float_t fAll, Float_t fNumOcc, Float_t fNumErr, Float_t fNumWarn);
113 Int_t UpdateStatusChamber(Int_t nIdxLayer, Int_t nIdxCh, Int_t nLumiCurr, NumStatus numStatus);
114 Int_t UpdateStatusChamber(Int_t nIdxLayer, Int_t nIdxCh, Int_t nIdxVFAT, Int_t nLumiCurr, NumStatus numStatus);
115 Int_t UpdateStatusChamber(std::vector<StatusInfo> &listStatus,
116 NumStatus &numStatus,
118 NumStatus numStatusNew);
127 const Int_t nCodeFine_ = 1;
128 const Int_t nCodeError_ = 2;
129 const Int_t nCodeWarning_ = 3;
130 const Int_t nCodeLowError_ = 4;
132 const Int_t nBitWarnVFAT_ = 7;
133 const Int_t nBitErrVFAT_ = 6;
134 const Int_t nBitWarnOH_ = 5;
135 const Int_t nBitErrOH_ = 4;
136 const Int_t nBitWarnAMC_ = 3;
137 const Int_t nBitErrAMC_ = 2;
138 const Int_t nBitErrAMC13_ = 1;
139 const Int_t nBitOcc_ = 0;
141 const Int_t nNumVFATs_ = 24;
143 const Int_t nMaxLumi_ = 6000;
166 nResolutionLumi_ = cfg.
getParameter<
int>(
"resolutionLumi");
167 bIsStatusChambersInit_ =
false;
172 desc.
add<
double>(
"cutErr", 0.05);
173 desc.
add<
double>(
"cutLowErr", 0.00);
174 desc.
add<
double>(
"cutWarn", 0.05);
175 desc.
add<
int>(
"resolutionLumi", 1);
176 descriptions.
add(
"GEMDQMHarvester", desc);
185 drawSummaryHistogram(store, nLumiCurr);
189 Float_t fReportSummary = -1.0;
191 std::string strSrcDigiOcc =
"GEM/Digis/summaryOccDigi";
192 std::string strSrcStatusA =
"GEM/DAQStatus/chamberAllStatus";
193 std::string strSrcStatusE =
"GEM/DAQStatus/chamberErrors";
194 std::string strSrcStatusW =
"GEM/DAQStatus/chamberWarnings";
195 std::string strSrcStatusEVFAT =
"GEM/DAQStatus/chamberVFATErrors";
196 std::string strSrcStatusWVFAT =
"GEM/DAQStatus/chamberVFATWarnings";
197 std::string strSrcStatusEOH =
"GEM/DAQStatus/chamberOHErrors";
198 std::string strSrcStatusWOH =
"GEM/DAQStatus/chamberOHWarnings";
199 std::string strSrcStatusEAMC =
"GEM/DAQStatus/chamberAMCErrors";
200 std::string strSrcStatusWAMC =
"GEM/DAQStatus/chamberAMCWarnings";
201 std::string strSrcStatusEAMC13 =
"GEM/DAQStatus/chamberAMC13Errors";
204 std::string strSrcVFATStatusW =
"GEM/DAQStatus/vfat_statusWarnSum";
205 std::string strSrcVFATStatusE =
"GEM/DAQStatus/vfat_statusErrSum";
223 if (h2SrcDigiOcc !=
nullptr && h2SrcStatusA !=
nullptr && h2SrcStatusE !=
nullptr && h2SrcStatusW !=
nullptr &&
224 h2SrcStatusEVFAT !=
nullptr && h2SrcStatusWVFAT !=
nullptr && h2SrcStatusEOH !=
nullptr &&
225 h2SrcStatusWOH !=
nullptr && h2SrcStatusEAMC !=
nullptr && h2SrcStatusWAMC !=
nullptr &&
226 h2SrcStatusEAMC13 !=
nullptr) {
228 createSummaryHist(store, h2SrcStatusEOH, h2Sum, listLayer_, mapIdxLayer_, mapNumChPerChamber_);
229 createTableWatchingSummary();
230 fReportSummary = refineSummaryHistogram(strTitleSummary,
245 for (
const auto &strSuffix : listLayer_) {
246 auto nIdxLayer = mapIdxLayer_[strSuffix];
250 if (h2SrcVFATOcc ==
nullptr || h2SrcVFATStatusW ==
nullptr || h2SrcVFATStatusE ==
nullptr)
254 createSummaryVFAT(store, h2SrcVFATStatusE, strSuffix, h2SumVFAT);
255 refineSummaryVFAT(strSuffix, h2SumVFAT, h2SrcVFATOcc, h2SrcVFATStatusE, h2SrcVFATStatusW, nLumiCurr, nIdxLayer);
256 TString strNewTitle = h2SrcVFATStatusE->
getTitle();
257 h2SumVFAT->
setTitle((
const char *)strNewTitle.ReplaceAll(
"errors",
"errors/warnings"));
261 createLumiFuncHist(store, strSuffix, nIdxLayer, nLumiCurr);
269 if (bIsStatusChambersInit_)
272 for (
const auto &[nIdxLayer, nNumCh] : mapNumChPerChamber_) {
273 for (Int_t
i = 1;
i <= nNumCh;
i++) {
274 mapStatusChambersSummary_[{nIdxLayer,
i}] = std::vector<StatusInfo>();
275 mapNumStatusChambersSummary_[{nIdxLayer,
i}] =
NumStatus();
276 for (Int_t
j = 1;
j <= nNumVFATs_;
j++) {
277 mapStatusVFATsSummary_[{nIdxLayer,
i,
j}] = std::vector<StatusInfo>();
278 mapNumStatusVFATsSummary_[{nIdxLayer,
i,
j}] =
NumStatus();
283 bIsStatusChambersInit_ =
true;
289 for (Int_t
i = 1;
i <= nBinX;
i++) {
292 for (Int_t
i = 1;
i <= nBinY;
i++) {
303 std::vector<std::string> &listLayers,
304 std::map<std::string, int> &mapIdxLayer,
305 std::map<int, int> &mapNumChPerChamber) {
309 h2Sum = store->
book2D(
"reportSummaryMap",
"", nBinX, 0.5, nBinX + 0.5, nBinY, 0.5, nBinY + 0.5);
316 mapNumChPerChamber.clear();
318 for (Int_t
i = 1;
i <= nBinX;
i++)
320 for (Int_t
i = 1;
i <= nBinY;
i++) {
323 auto nPos = strLabelFull.find(
';');
324 auto strLabel = strLabelFull.substr(0, nPos);
325 auto strLayer = strLabelFull.substr(nPos + 1);
326 listLayers.push_back(strLabelFull.substr(nPos + 1));
328 mapIdxLayer[strLayer] =
i;
329 mapNumChPerChamber[
i] = nBinXActual;
341 h2Sum = store->
book2D(
"vfat_statusSummary" + strSuffix,
"", nBinX, 0.5, nBinX + 0.5, nBinY, -0.5, nBinY - 0.5);
342 copyLabels(h2Src, h2Sum);
346 std::string strName, Int_t nIdxX, Int_t nIdxY, Float_t fAll, Float_t fNumOcc, Float_t fNumErr, Float_t fNumWarn) {
347 if (fNumErr > fCutErr_ * fAll)
349 else if (fNumErr > fCutLowErr_ * fAll)
350 return nCodeLowError_;
351 else if (fNumWarn > fCutWarn_ * fAll)
352 return nCodeWarning_;
353 else if (fNumOcc > 0)
375 Int_t nAllBin = 0, nFineBin = 0;
376 for (Int_t
j = 1;
j <= nBinY;
j++) {
379 for (Int_t
i = 1;
i <= nBinX;
i++) {
400 UpdateStatusChamber(
j,
i, nLumiCurr, numStatus);
402 Int_t nRes = assessOneBin(strName,
i,
j, fStatusAll, fOcc, fStatusErr, fStatusWarn);
411 return ((Float_t)nFineBin) / nAllBin;
422 for (Int_t
j = 1;
j <= nBinY;
j++) {
424 for (Int_t
i = 1;
i <= nBinX;
i++) {
428 Float_t fStatusAll = fOcc + fStatusErr + fStatusWarn;
429 NumStatus numStatus(fStatusAll, fOcc, fStatusErr, fStatusWarn, 0, 0, 0, 0, 0);
430 UpdateStatusChamber(nIdxLayer,
i,
j, nLumiCurr, numStatus);
432 Int_t nRes = assessOneBin(strName,
i,
j, fStatusAll, fOcc, fStatusErr, fStatusWarn);
441 if (!bIsStatusChambersInit_)
443 if (0 >= nIdxCh || nIdxCh > mapNumChPerChamber_[nIdxLayer])
445 auto &listStatus = mapStatusChambersSummary_[{nIdxLayer, nIdxCh}];
446 auto &numStatusPrev = mapNumStatusChambersSummary_[{nIdxLayer, nIdxCh}];
447 return UpdateStatusChamber(listStatus, numStatusPrev, nLumiCurr, numStatus);
451 Int_t nIdxLayer, Int_t nIdxCh, Int_t nIdxVFAT, Int_t nLumiCurr,
NumStatus numStatus) {
452 if (!bIsStatusChambersInit_)
454 if (0 >= nIdxCh || nIdxCh > mapNumChPerChamber_[nIdxLayer])
456 if (0 >= nIdxVFAT || nIdxVFAT > nNumVFATs_)
458 auto &listStatus = mapStatusVFATsSummary_[{nIdxLayer, nIdxCh, nIdxVFAT}];
459 auto &numStatusPrev = mapNumStatusVFATsSummary_[{nIdxLayer, nIdxCh, nIdxVFAT}];
460 return UpdateStatusChamber(listStatus, numStatusPrev, nLumiCurr, numStatus);
488 nStatus = (numStatusNew.
fNumOcc_ > 0 ? 1 << nBitOcc_ : 0) | (fNumAddErrAMC13 > 0 ? 1 << nBitErrAMC13_ : 0) |
489 (fNumAddErrAMC > 0 ? 1 << nBitErrAMC_ : 0) | (fNumAddWarnAMC > 0 ? 1 << nBitWarnAMC_ : 0) |
490 (fNumAddErrOH > 0 ? 1 << nBitErrOH_ : 0) | (fNumAddWarnOH > 0 ? 1 << nBitWarnOH_ : 0) |
491 (fNumAddErrVFAT > 0 ? 1 << nBitErrVFAT_ : 0) | (fNumAddWarnVFAT > 0 ? 1 << nBitWarnVFAT_ : 0);
499 if (listStatus.empty()) {
500 listStatus.push_back(statusNew);
502 auto &statusLastPre = listStatus.back();
503 if (statusLastPre.nStatus == nStatus) {
504 statusLastPre.nLumiEnd = nLumiCurr;
506 listStatus.push_back(statusNew);
517 auto &nNumCh = mapNumChPerChamber_[nIdxLayer];
522 Int_t nNumBinLumi = ((nLumiCurr - 1) / nResolutionLumi_) + 1;
526 if (mapHistLumiFunc_.find(nIdxLayer) == mapHistLumiFunc_.end()) {
528 h2Summary = store->
book2S(
"chamberStatus_inLumi" + strSuffix,
529 "Chamber status on lumi-block " + strSuffix.substr(1),
530 nMaxLumi_ / nResolutionLumi_,
532 (Float_t)(nMaxLumi_ + 1),
537 mapHistLumiFunc_[nIdxLayer] = h2Summary;
539 h2Summary->
setXTitle(
"Luminosity block");
541 for (Int_t
i = 1;
i <= nNumCh;
i++) {
545 h2Summary = mapHistLumiFunc_[nIdxLayer];
548 for (Int_t nIdxCh = 1; nIdxCh <= nNumCh; nIdxCh++) {
549 auto &listStatus = mapStatusChambersSummary_[{nIdxLayer, nIdxCh}];
551 Int_t nIdxStatus = 0;
552 for (Int_t nIdxLumi = 0; nIdxLumi < nNumBinLumi; nIdxLumi++) {
554 Int_t nLumiStart = 1 + nIdxLumi * nResolutionLumi_;
555 Int_t nLumiEnd = (1 + nIdxLumi) * nResolutionLumi_;
556 if (nLumiEnd > nLumiCurr)
557 nLumiEnd = nLumiCurr;
559 Int_t nStatusSum = 0;
563 if (listStatus[nIdxStatus].nLumiEnd < nLumiStart) {
565 if (nIdxStatus >= (
int)listStatus.size()) {
571 nStatusSum = listStatus[nIdxStatus].nStatus;
574 if (nIdxStatus + 1 >= (
int)listStatus.size() || listStatus[nIdxStatus].nLumiEnd >= nLumiEnd) {
579 if (nIdxStatus >= (
int)listStatus.size()) {
585 if (nMaxBin < nIdxLumi + 1)
586 nMaxBin = nIdxLumi + 1;
590 for (Int_t nX = 1; nX <= nMaxBin; nX++) {
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
#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::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
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)
void createSummaryHist(edm::Service< DQMStore > &store, MonitorElement *h2Src, MonitorElement *&h2Sum, std::vector< std::string > &listLayers, std::map< std::string, int > &mapIdxLayer, std::map< int, int > &mapNumChPerChamber)
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
Int_t refineSummaryVFAT(std::string strName, MonitorElement *h2Sum, MonitorElement *h2SrcOcc, MonitorElement *h2SrcStatusE, MonitorElement *h2SrcStatusW, Int_t nLumiCurr, Int_t nIdxLayer)
Float_t refineSummaryHistogram(std::string strName, MonitorElement *h2Sum, MonitorElement *h2SrcOcc, 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