Skip to content

Commit

Permalink
Merge pull request #36254 from quark2/GEM-onlineDQM_update_211125-12_0_X
Browse files Browse the repository at this point in the history
Modification on r-phi distribution plots and fix on under/overflow bins in GEM onlineDQM, a backport to 12_0_X
  • Loading branch information
cmsbuild authored Dec 1, 2021
2 parents efdce4f + 87361c3 commit 400ccef
Show file tree
Hide file tree
Showing 6 changed files with 163 additions and 50 deletions.
49 changes: 47 additions & 2 deletions DQM/GEM/interface/GEMDQMBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class GEMDQMBase : public DQMEDAnalyzer {
template <class M, class K>
class MEMapInfT {
public:
MEMapInfT() : bOperating_(false){};
MEMapInfT() : bOperating_(false), bIsNoUnderOverflowBin_(false){};

MEMapInfT(
GEMDQMBase *pDQMBase, TString strName, TString strTitle, TString strTitleX = "", TString strTitleY = "Entries")
Expand All @@ -126,6 +126,7 @@ class GEMDQMBase : public DQMEDAnalyzer {
strTitleY_(strTitleY),
bOperating_(true),
bIsProfile_(false),
bIsNoUnderOverflowBin_(false),
nBinsX_(nBinsX),
dXL_(dXL),
dXH_(dXH),
Expand All @@ -145,6 +146,7 @@ class GEMDQMBase : public DQMEDAnalyzer {
strTitleY_(strTitleY),
bOperating_(true),
bIsProfile_(false),
bIsNoUnderOverflowBin_(false),
nBinsX_(-1),
nBinsY_(-1),
log_category_own_(pDQMBase->log_category_) {
Expand All @@ -170,6 +172,7 @@ class GEMDQMBase : public DQMEDAnalyzer {
strTitleY_(strTitleY),
bOperating_(true),
bIsProfile_(false),
bIsNoUnderOverflowBin_(false),
nBinsX_(nBinsX),
dXL_(dXL),
dXH_(dXH),
Expand Down Expand Up @@ -200,6 +203,7 @@ class GEMDQMBase : public DQMEDAnalyzer {
strTitleY_(strTitleY),
bOperating_(true),
bIsProfile_(true),
bIsNoUnderOverflowBin_(false),
nBinsX_(nBinsX),
dXL_(dXL),
dXH_(dXH),
Expand All @@ -223,6 +227,7 @@ class GEMDQMBase : public DQMEDAnalyzer {
// strTitleX_(strTitleX),
// strTitleY_(strTitleY),
// bOperating_(true),
// bIsNoUnderOverflowBin_(false),
// nBinsX_(nBinsX),
// dXL_(dXL),
// dXH_(dXH),
Expand All @@ -237,6 +242,7 @@ class GEMDQMBase : public DQMEDAnalyzer {
void SetOperating(Bool_t bOperating) { bOperating_ = bOperating; };
void TurnOn() { bOperating_ = true; };
void TurnOff() { bOperating_ = false; };
void SetNoUnderOverflowBin() { bIsNoUnderOverflowBin_ = true; };

Bool_t isProfile() { return bIsProfile_; };
void SetProfile(Bool_t bIsProfile) { bIsProfile_ = bIsProfile; };
Expand Down Expand Up @@ -286,10 +292,20 @@ class GEMDQMBase : public DQMEDAnalyzer {
dYH_ = dH;
};

void SetPointUOFlow() {
dXU_ = dXL_ + (dXH_ - dXL_) / nBinsX_ * 0.5;
dXO_ = dXL_ + (dXH_ - dXL_) / nBinsX_ * (nBinsX_ - 0.5);
dYU_ = dYL_ + (dYH_ - dYL_) / nBinsY_ * 0.5;
dYO_ = dYL_ + (dYH_ - dYL_) / nBinsY_ * (nBinsY_ - 0.5);
dZU_ = dZL_ + (dZH_ - dZL_) / nBinsZ_ * 0.5;
dZO_ = dZL_ + (dZH_ - dZL_) / nBinsZ_ * (nBinsZ_ - 0.5);
};

M &map() { return mapHist; }
int bookND(BookingHelper &bh, K key) {
if (!bOperating_)
return 0;
SetPointUOFlow();
if (bIsProfile_) {
mapHist[key] = bh.bookProfile2D(
strName_, strTitle_, nBinsX_, dXL_, dXH_, nBinsY_, dYL_, dYH_, dZL_, dZH_, strTitleX_, strTitleY_);
Expand Down Expand Up @@ -364,6 +380,12 @@ class GEMDQMBase : public DQMEDAnalyzer {
dqm::impl::MonitorElement *hist = FindHist(key);
if (hist == nullptr)
return -999;
if (bIsNoUnderOverflowBin_) {
if (x <= dXL_)
x = dXU_;
else if (x >= dXH_)
x = dXO_;
}
hist->Fill(x);
return 1;
};
Expand All @@ -374,6 +396,16 @@ class GEMDQMBase : public DQMEDAnalyzer {
dqm::impl::MonitorElement *hist = FindHist(key);
if (hist == nullptr)
return -999;
if (bIsNoUnderOverflowBin_) {
if (x <= dXL_)
x = dXU_;
else if (x >= dXH_)
x = dXO_;
if (y <= dYL_)
y = dYU_;
else if (y >= dYH_)
y = dYO_;
}
hist->Fill(x, y, w);
return 1;
};
Expand Down Expand Up @@ -404,13 +436,18 @@ class GEMDQMBase : public DQMEDAnalyzer {
TString strName_, strTitle_, strTitleX_, strTitleY_;
Bool_t bOperating_;
Bool_t bIsProfile_;
Bool_t bIsNoUnderOverflowBin_;

std::vector<double> x_binning_;
Int_t nBinsX_;
Double_t dXL_, dXH_;
Int_t nBinsY_;
Double_t dYL_, dYH_;
Int_t nBinsZ_;
Double_t dZL_, dZH_;
Double_t dXU_, dXO_;
Double_t dYU_, dYO_;
Double_t dZU_, dZO_;

std::string log_category_own_;
};
Expand Down Expand Up @@ -450,6 +487,8 @@ class GEMDQMBase : public DQMEDAnalyzer {
Int_t nNumEtaPartitions_; // the number of eta partitions of the chambers
Int_t nMaxVFAT_; // the number of all VFATs in each chamber (= # of VFATs in eta partition * nNumEtaPartitions_)
Int_t nNumDigi_; // the number of digis of each VFAT

Float_t fMinPhi_;
};

public:
Expand All @@ -461,7 +500,6 @@ class GEMDQMBase : public DQMEDAnalyzer {
protected:
int initGeometry(edm::EventSetup const &iSetup);
int loadChambers();
int readRadiusEtaPartition(int nRegion, int nStation);

int GenerateMEPerChamber(DQMStore::IBooker &ibooker);
virtual int ProcessWithMEMap2(BookingHelper &bh, ME2IdsKey key) { return 0; }; // must be overrided
Expand Down Expand Up @@ -507,6 +545,7 @@ class GEMDQMBase : public DQMEDAnalyzer {
inline int getIEtaFromVFATGE11(const int vfat);
inline int getMaxVFAT(const int);
inline int getDetOccXBin(const int, const int, const int);
inline Float_t restrictAngle(const Float_t fTheta, const Float_t fStart);

const GEMGeometry *GEMGeometry_;
edm::ESGetToken<GEMGeometry, MuonGeometryRecord> geomToken_;
Expand Down Expand Up @@ -576,4 +615,10 @@ inline int GEMDQMBase::getDetOccXBin(const int chamber, const int layer, const i
return n_chambers * (chamber - 1) + layer;
}

inline Float_t GEMDQMBase::restrictAngle(const Float_t fTheta, const Float_t fStart) {
Float_t fLoop = (fTheta - fStart) / (2 * M_PI);
int nLoop = (fLoop >= 0 ? (int)fLoop : (int)fLoop - 1);
return fTheta - nLoop * 2 * M_PI;
}

#endif // DQM_GEM_INTERFACE_GEMDQMBase_h
6 changes: 5 additions & 1 deletion DQM/GEM/interface/GEMDigiSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class GEMDigiSource : public GEMDQMBase {

private:
int ProcessWithMEMap2WithEta(BookingHelper& bh, ME3IdsKey key) override;
int ProcessWithMEMap2(BookingHelper& bh, ME2IdsKey key) override;
int ProcessWithMEMap3(BookingHelper& bh, ME3IdsKey key) override;
int ProcessWithMEMap3WithChamber(BookingHelper& bh, ME4IdsKey key) override;

Expand All @@ -48,17 +49,20 @@ class GEMDigiSource : public GEMDQMBase {
edm::EDGetTokenT<LumiScalersCollection> lumiScalers_;

MEMap3Inf mapTotalDigi_layer_;
MEMap3Inf mapDigiWheel_layer_;
MEMap3Inf mapDigiOcc_ieta_;
MEMap3Inf mapDigiOcc_phi_;
MEMap3Inf mapTotalDigiPerEvtLayer_;
MEMap3Inf mapTotalDigiPerEvtIEta_;
MEMap3Inf mapBX_iEta_;
MEMap2Inf mapBX_;

MEMap4Inf mapDigiOccPerCh_;

MonitorElement* h2SummaryOcc_;

Int_t nBXMin_, nBXMax_;
Float_t fRadiusMin_;
Float_t fRadiusMax_;

Bool_t bModeRelVal_;
};
Expand Down
68 changes: 42 additions & 26 deletions DQM/GEM/plugins/GEMDQMHarvester.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,38 +44,43 @@ class GEMDQMHarvester : public DQMEDHarvester {
MonitorElement *h2Src,
std::string strSuffix,
MonitorElement *&h2Sum);
Float_t refineSummaryHistogram(MonitorElement *h2Sum,
Float_t refineSummaryHistogram(std::string strName,
MonitorElement *h2Sum,
MonitorElement *h2SrcOcc,
MonitorElement *h2SrcAllNum,
MonitorElement *h2SrcStatusE,
MonitorElement *h2SrcStatusW);
Int_t refineSummaryVFAT(MonitorElement *h2Sum,
Int_t refineSummaryVFAT(std::string strName,
MonitorElement *h2Sum,
MonitorElement *h2SrcOcc,
MonitorElement *h2SrcStatusE,
MonitorElement *h2SrcStatusW);
Int_t assessOneBin(Float_t fAll, Float_t fNumOcc, Float_t fNumWarn, Float_t fNumErr);
Int_t assessOneBin(
std::string strName, Int_t nIdxX, Int_t nIdxY, Float_t fAll, Float_t fNumOcc, Float_t fNumWarn, Float_t fNumErr);

Float_t fReportSummary_;
std::string strOutFile_;
Float_t fCutErr_, fCutLowErr_, fCutWarn_;

std::string strDirSummary_;
std::string strDirRecHit_;
std::string strDirStatus_;
const std::string strDirSummary_ = "GEM/EventInfo";
const std::string strDirRecHit_ = "GEM/RecHits";
const std::string strDirStatus_ = "GEM/DAQStatus";

typedef std::vector<std::vector<Float_t>> TableStatusOcc;
typedef std::vector<std::vector<Int_t>> TableStatusNum;

std::vector<std::string> listLayer_;
};

GEMDQMHarvester::GEMDQMHarvester(const edm::ParameterSet &cfg) {
fReportSummary_ = -1.0;
strOutFile_ = cfg.getParameter<std::string>("fromFile");
strDirSummary_ = "GEM/EventInfo";
strDirRecHit_ = "GEM/RecHits";
strDirStatus_ = "GEM/DAQStatus";
fCutErr_ = cfg.getParameter<double>("cutErr");
fCutLowErr_ = cfg.getParameter<double>("cutLowErr");
fCutWarn_ = cfg.getParameter<double>("cutWarn");
}

void GEMDQMHarvester::fillDescriptions(edm::ConfigurationDescriptions &descriptions) {
edm::ParameterSetDescription desc;
desc.add<std::string>("fromFile", "");
desc.add<double>("cutErr", 0.05);
desc.add<double>("cutLowErr", 0.00);
desc.add<double>("cutWarn", 0.05);
descriptions.add("GEMDQMHarvester", desc);
}

Expand All @@ -88,6 +93,8 @@ void GEMDQMHarvester::dqmEndLuminosityBlock(DQMStore::IBooker &,
}

void GEMDQMHarvester::drawSummaryHistogram(edm::Service<DQMStore> &store) {
Float_t fReportSummary = -1.0;

std::string strSrcDigiOcc = "GEM/Digis/summaryOccDigi";
std::string strSrcStatusA = "GEM/DAQStatus/chamberAllStatus";
std::string strSrcStatusW = "GEM/DAQStatus/chamberWarnings";
Expand All @@ -104,28 +111,32 @@ void GEMDQMHarvester::drawSummaryHistogram(edm::Service<DQMStore> &store) {
MonitorElement *h2SrcStatusW = store->get(strSrcStatusW);
MonitorElement *h2SrcStatusE = store->get(strSrcStatusE);

std::string strTitleSummary = "summary";

if (h2SrcDigiOcc != nullptr && h2SrcStatusA != nullptr && h2SrcStatusW != nullptr && h2SrcStatusE != nullptr) {
MonitorElement *h2Sum = nullptr;
createSummaryHist(store, h2SrcStatusE, h2Sum, listLayer_);
fReportSummary_ = refineSummaryHistogram(h2Sum, h2SrcDigiOcc, h2SrcStatusA, h2SrcStatusE, h2SrcStatusW);
fReportSummary =
refineSummaryHistogram(strTitleSummary, h2Sum, h2SrcDigiOcc, h2SrcStatusA, h2SrcStatusE, h2SrcStatusW);

for (const auto &strSuffix : listLayer_) {
MonitorElement *h2SrcVFATOcc = store->get(strSrcVFATOcc + strSuffix);
MonitorElement *h2SrcVFATStatusW = store->get(strSrcVFATStatusW + strSuffix);
MonitorElement *h2SrcVFATStatusE = store->get(strSrcVFATStatusE + strSuffix);
if (h2SrcVFATOcc == nullptr || h2SrcVFATStatusW == nullptr || h2SrcVFATStatusE == nullptr)
continue;

MonitorElement *h2SumVFAT = nullptr;
createSummaryVFAT(store, h2SrcVFATStatusE, strSuffix, h2SumVFAT);
refineSummaryVFAT(h2SumVFAT, h2SrcVFATOcc, h2SrcVFATStatusE, h2SrcVFATStatusW);
refineSummaryVFAT(strSuffix, h2SumVFAT, h2SrcVFATOcc, h2SrcVFATStatusE, h2SrcVFATStatusW);
TString strNewTitle = h2SrcVFATStatusE->getTitle();
h2SumVFAT->setTitle((const char *)strNewTitle.ReplaceAll("errors", "errors/warnings"));
h2SumVFAT->setXTitle(h2SrcVFATStatusE->getAxisTitle(1));
h2SumVFAT->setYTitle(h2SrcVFATStatusE->getAxisTitle(2));
}
}

store->bookFloat("reportSummary")->Fill(fReportSummary_);
store->bookFloat("reportSummary")->Fill(fReportSummary);
}

void GEMDQMHarvester::copyLabels(MonitorElement *h2Src, MonitorElement *h2Dst) {
Expand Down Expand Up @@ -178,10 +189,13 @@ void GEMDQMHarvester::createSummaryVFAT(edm::Service<DQMStore> &store,
copyLabels(h2Src, h2Sum);
}

Int_t GEMDQMHarvester::assessOneBin(Float_t fAll, Float_t fNumOcc, Float_t fNumWarn, Float_t fNumErr) {
if (fNumErr > 0.05 * fAll) // The error status criterion
Int_t GEMDQMHarvester::assessOneBin(
std::string strName, Int_t nIdxX, Int_t nIdxY, Float_t fAll, Float_t fNumOcc, Float_t fNumWarn, Float_t fNumErr) {
if (fNumErr > fCutErr_ * fAll) // The error status criterion
return 2;
else if (fNumErr > 0.00 * fAll || fNumWarn > 0.05 * fAll) // The warning status criterion
else if (fNumErr > fCutLowErr_ * fAll) // The low-error status criterion
return 4;
else if (fNumWarn > fCutWarn_ * fAll) // The warning status criterion
return 3;
else if (fNumOcc > 0)
return 1;
Expand All @@ -190,24 +204,24 @@ Int_t GEMDQMHarvester::assessOneBin(Float_t fAll, Float_t fNumOcc, Float_t fNumW
}

// FIXME: Need more study about how to summarize
Float_t GEMDQMHarvester::refineSummaryHistogram(MonitorElement *h2Sum,
Float_t GEMDQMHarvester::refineSummaryHistogram(std::string strName,
MonitorElement *h2Sum,
MonitorElement *h2SrcOcc,
MonitorElement *h2SrcStatusA,
MonitorElement *h2SrcStatusE,
MonitorElement *h2SrcStatusW) {
Int_t nBinY = h2Sum->getNbinsY();
Int_t nAllBin = 0, nFineBin = 0;
for (Int_t j = 1; j <= nBinY; j++) {
Int_t nBinX = h2Sum->getNbinsX();
nBinX = (Int_t)(h2SrcOcc->getBinContent(0, j) + 0.5);
Int_t nBinX = (Int_t)(h2SrcOcc->getBinContent(0, j) + 0.5);
h2Sum->setBinContent(0, j, nBinX);
for (Int_t i = 1; i <= nBinX; i++) {
Float_t fOcc = h2SrcOcc->getBinContent(i, j);
Float_t fStatusAll = h2SrcStatusA->getBinContent(i, j);
Float_t fStatusWarn = h2SrcStatusW->getBinContent(i, j);
Float_t fStatusErr = h2SrcStatusE->getBinContent(i, j);

Int_t nRes = assessOneBin(fStatusAll, fOcc, fStatusWarn, fStatusErr);
Int_t nRes = assessOneBin(strName, i, j, fStatusAll, fOcc, fStatusWarn, fStatusErr);
if (nRes == 1)
nFineBin++;

Expand All @@ -219,7 +233,8 @@ Float_t GEMDQMHarvester::refineSummaryHistogram(MonitorElement *h2Sum,
return ((Float_t)nFineBin) / nAllBin;
}

Int_t GEMDQMHarvester::refineSummaryVFAT(MonitorElement *h2Sum,
Int_t GEMDQMHarvester::refineSummaryVFAT(std::string strName,
MonitorElement *h2Sum,
MonitorElement *h2SrcOcc,
MonitorElement *h2SrcStatusE,
MonitorElement *h2SrcStatusW) {
Expand All @@ -231,7 +246,8 @@ Int_t GEMDQMHarvester::refineSummaryVFAT(MonitorElement *h2Sum,
Float_t fStatusWarn = h2SrcStatusW->getBinContent(i, j);
Float_t fStatusErr = h2SrcStatusE->getBinContent(i, j);
Float_t fStatusAll = fOcc + fStatusWarn + fStatusErr;
Int_t nRes = assessOneBin(fStatusAll, fOcc, fStatusWarn, fStatusErr);

Int_t nRes = assessOneBin(strName, i, j, fStatusAll, fOcc, fStatusWarn, fStatusErr);
h2Sum->setBinContent(i, j, (Float_t)nRes);
}
}
Expand Down
Loading

0 comments on commit 400ccef

Please sign in to comment.