Skip to content

Commit

Permalink
Merge pull request #36230 from quark2/GEM-onlineDQM_update_211124-12_2_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
  • Loading branch information
cmsbuild authored Nov 25, 2021
2 parents 5a0d088 + acc4357 commit d69b215
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 26 deletions.
41 changes: 40 additions & 1 deletion 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 Down
3 changes: 3 additions & 0 deletions DQM/GEM/interface/GEMDigiSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class GEMDigiSource : public GEMDQMBase {
edm::EDGetTokenT<LumiScalersCollection> lumiScalers_;

MEMap3Inf mapTotalDigi_layer_;
MEMap3Inf mapDigiWheel_layer_;
MEMap3Inf mapDigiOcc_ieta_;
MEMap3Inf mapDigiOcc_phi_;
MEMap3Inf mapTotalDigiPerEvtLayer_;
Expand All @@ -60,6 +61,8 @@ class GEMDigiSource : public GEMDQMBase {
MonitorElement* h2SummaryOcc_;

Int_t nBXMin_, nBXMax_;
Float_t fRadiusMin_;
Float_t fRadiusMax_;

Bool_t bModeRelVal_;
};
Expand Down
46 changes: 34 additions & 12 deletions DQM/GEM/plugins/GEMDQMHarvester.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,21 @@ 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 fCutErr_, fCutWarnErr_, fCutWarn_;

Float_t fReportSummary_;
std::string strOutFile_;
Expand All @@ -62,6 +67,9 @@ class GEMDQMHarvester : public DQMEDHarvester {
std::string strDirRecHit_;
std::string strDirStatus_;

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

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

Expand All @@ -71,6 +79,10 @@ GEMDQMHarvester::GEMDQMHarvester(const edm::ParameterSet &cfg) {
strDirSummary_ = "GEM/EventInfo";
strDirRecHit_ = "GEM/RecHits";
strDirStatus_ = "GEM/DAQStatus";

fCutErr_ = 0.05;
fCutWarnErr_ = 0.00;
fCutWarn_ = 0.05;
}

void GEMDQMHarvester::fillDescriptions(edm::ConfigurationDescriptions &descriptions) {
Expand Down Expand Up @@ -104,20 +116,24 @@ 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));
Expand Down Expand Up @@ -178,10 +194,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 > fCutWarnErr_ * 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,7 +209,8 @@ 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,
Expand All @@ -207,7 +227,7 @@ Float_t GEMDQMHarvester::refineSummaryHistogram(MonitorElement *h2Sum,
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 +239,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 +252,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
29 changes: 26 additions & 3 deletions DQM/GEM/plugins/GEMDigiSource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,14 @@ void GEMDigiSource::bookHistograms(DQMStore::IBooker& ibooker, edm::Run const&,

nBXMin_ = -10;
nBXMax_ = 10;
fRadiusMin_ = 120.0;
fRadiusMax_ = 250.0;
float radS = -5.0 / 180 * M_PI;
float radL = 355.0 / 180 * M_PI;

mapTotalDigi_layer_ = MEMap3Inf(this, "det", "Digi Occupancy", 36, 0.5, 36.5, 24, -0.5, 24 - 0.5, "Chamber", "VFAT");
mapDigiWheel_layer_ = MEMap3Inf(
this, "rphi_occ", "Digi R-Phi Occupancy", 360, radS, radL, 8, fRadiusMin_, fRadiusMax_, "#phi (rad)", "R [cm]");
mapDigiOcc_ieta_ = MEMap3Inf(this, "occ_ieta", "Digi iEta Occupancy", 8, 0.5, 8.5, "iEta", "Number of fired digis");
mapDigiOcc_phi_ =
MEMap3Inf(this, "occ_phi", "Digi Phi Occupancy", 108, -5, 355, "#phi (degree)", "Number of fired digis");
Expand All @@ -39,6 +45,7 @@ void GEMDigiSource::bookHistograms(DQMStore::IBooker& ibooker, edm::Run const&,
99.5,
"Number of fired digis",
"Events");
mapTotalDigiPerEvtLayer_.SetNoUnderOverflowBin();
mapTotalDigiPerEvtIEta_ = MEMap3Inf(this,
"digis_per_ieta",
"Total number of digis per event for each eta partitions",
Expand All @@ -47,13 +54,15 @@ void GEMDigiSource::bookHistograms(DQMStore::IBooker& ibooker, edm::Run const&,
99.5,
"Number of fired digis",
"Events");
mapTotalDigiPerEvtIEta_.SetNoUnderOverflowBin();

mapBX_ = MEMap2Inf(this, "bx", "Digi Bunch Crossing", 21, nBXMin_ - 0.5, nBXMax_ + 0.5, "Bunch crossing");

mapDigiOccPerCh_ = MEMap4Inf(this, "occ", "Digi Occupancy", 1, -0.5, 1.5, 1, 0.5, 1.5, "Digi", "iEta");

if (bModeRelVal_) {
mapTotalDigi_layer_.TurnOff();
mapDigiWheel_layer_.TurnOff();
mapDigiOccPerCh_.TurnOff();
}

Expand Down Expand Up @@ -84,12 +93,20 @@ int GEMDigiSource::ProcessWithMEMap2WithEta(BookingHelper& bh, ME3IdsKey key) {
int GEMDigiSource::ProcessWithMEMap3(BookingHelper& bh, ME3IdsKey key) {
MEStationInfo& stationInfo = mapStationInfo_[key];

int nNumVFATPerEta = stationInfo.nMaxVFAT_ / stationInfo.nNumEtaPartitions_;

mapTotalDigi_layer_.SetBinConfX(stationInfo.nNumChambers_);
mapTotalDigi_layer_.SetBinConfY(stationInfo.nMaxVFAT_, -0.5);
mapTotalDigi_layer_.bookND(bh, key);
mapTotalDigi_layer_.SetLabelForChambers(key, 1);
mapTotalDigi_layer_.SetLabelForVFATs(key, stationInfo.nNumEtaPartitions_, 2);

mapDigiWheel_layer_.SetBinLowEdgeX(stationInfo.fMinPhi_);
mapDigiWheel_layer_.SetBinHighEdgeX(stationInfo.fMinPhi_ + 2 * M_PI);
mapDigiWheel_layer_.SetNbinsX(nNumVFATPerEta * stationInfo.nNumChambers_);
mapDigiWheel_layer_.SetNbinsY(stationInfo.nNumEtaPartitions_);
mapDigiWheel_layer_.bookND(bh, key);

mapDigiOcc_ieta_.SetBinConfX(stationInfo.nNumEtaPartitions_);
mapDigiOcc_ieta_.bookND(bh, key);
mapDigiOcc_ieta_.SetLabelForIEta(key, 1);
Expand Down Expand Up @@ -130,6 +147,7 @@ void GEMDigiSource::analyze(edm::Event const& event, edm::EventSetup const& even
ME4IdsKey key4Ch{gid.region(), gid.station(), gid.layer(), gid.chamber()};
std::map<Int_t, bool> bTagVFAT;
bTagVFAT.clear();
MEStationInfo& stationInfo = mapStationInfo_[key3];
const BoundPlane& surface = GEMGeometry_->idToDet(gid)->surface();
if (total_digi_layer.find(key3) == total_digi_layer.end())
total_digi_layer[key3] = 0;
Expand All @@ -148,11 +166,16 @@ void GEMDigiSource::analyze(edm::Event const& event, edm::EventSetup const& even
mapDigiOcc_ieta_.Fill(key3, eId.ieta()); // Eta (partition)

GlobalPoint digi_global_pos = surface.toGlobal(iEta->centreOfStrip(d->strip()));
Float_t fPhiDeg = ((Float_t)digi_global_pos.phi()) * 180.0 / 3.141592;
if (fPhiDeg < -5.0)
fPhiDeg += 360.0;
Float_t fPhi = (Float_t)digi_global_pos.phi();
Float_t fPhiDeg = fPhi * 180.0 / M_PI;
fPhiDeg = (fPhiDeg >= -0.5 ? fPhiDeg : fPhiDeg + 360);
mapDigiOcc_phi_.Fill(key3, fPhiDeg); // Phi

// Filling of R-Phi occupancy
Float_t fR = fRadiusMin_ + (fRadiusMax_ - fRadiusMin_) * (eId.ieta() - 0.5) / stationInfo.nNumEtaPartitions_;
Float_t fPhiShift = (fPhi >= stationInfo.fMinPhi_ ? fPhi : fPhi + 2 * M_PI);
mapDigiWheel_layer_.Fill(key3, fPhiShift, fR);

mapDigiOccPerCh_.Fill(key4Ch, d->strip(), eId.ieta()); // Per chamber

// For total digis
Expand Down
Loading

0 comments on commit d69b215

Please sign in to comment.