Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GEM DQM updates - full GE1/1, backport to 11_0_X #28878

Merged
merged 10 commits into from Feb 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
98 changes: 96 additions & 2 deletions DQM/GEM/plugins/GEMDQMHarvester.cc
Expand Up @@ -11,23 +11,117 @@
//DQM services
#include "DQMServices/Core/interface/DQMStore.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "DQMServices/Core/interface/MonitorElement.h"
#include "DQMServices/Core/interface/DQMEDHarvester.h"

#include <TH2F.h>
#include <TFile.h>
#include <TDirectoryFile.h>
#include <TKey.h>

using namespace edm;

class GEMDQMHarvester : public DQMEDHarvester {
public:
GEMDQMHarvester(const edm::ParameterSet &){};
GEMDQMHarvester(const edm::ParameterSet &);
~GEMDQMHarvester() override{};
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);

protected:
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override{};
void endRun(edm::Run const &, edm::EventSetup const &) override;
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override{}; // Cannot use; it is called after dqmSaver

void refineSummaryHistogram(edm::Service<DQMStore> &);
void refineSummaryHistogramCore(TH3F *, std::string &, TH2F *&, std::string strTmpPrefix = "tmp_");

void fillUnderOverflowBunchCrossing(edm::Service<DQMStore> &, std::string);

std::string strOutFile_;
};

GEMDQMHarvester::GEMDQMHarvester(const edm::ParameterSet &cfg) {
strOutFile_ = cfg.getParameter<std::string>("fromFile");
}

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

void GEMDQMHarvester::endRun(edm::Run const &, edm::EventSetup const &) {
edm::Service<DQMStore> store;
refineSummaryHistogram(store);

store->setCurrentFolder("GEM/StatusDigi");
auto listME = store->getMEs();

for (auto strName : listME) {
if (strName.find("vfatStatus_BC_") != std::string::npos) {
fillUnderOverflowBunchCrossing(store, strName);
}
}
}

void GEMDQMHarvester::refineSummaryHistogram(edm::Service<DQMStore> &store) {
std::string strDirCurr = "GEM/EventInfo";
std::string strNameSrc = "reportSummaryMapPreliminary";
std::string strNewName = "reportSummaryMap";

store->setCurrentFolder(strDirCurr);

MonitorElement *h3Curr = store->get(strDirCurr + "/" + strNameSrc);
TH2F *h2New = nullptr;

refineSummaryHistogramCore(h3Curr->getTH3F(), strNewName, h2New);
store->book2D(strNewName, h2New);
}

void GEMDQMHarvester::refineSummaryHistogramCore(TH3F *h3Src,
std::string &strNewName,
TH2F *&h2New,
std::string strTmpPrefix) {
Int_t i, j;

Int_t nNBinX = h3Src->GetNbinsX();
Int_t nNBinY = h3Src->GetNbinsY();

Float_t arrfBinX[128], arrfBinY[32];

for (i = 0; i <= nNBinX; i++)
arrfBinX[i] = h3Src->GetXaxis()->GetBinLowEdge(i + 1);
for (i = 0; i <= nNBinY; i++)
arrfBinY[i] = h3Src->GetYaxis()->GetBinLowEdge(i + 1);

h2New = new TH2F(strNewName.c_str(), h3Src->GetTitle(), nNBinX, arrfBinX, nNBinY, arrfBinY);

for (i = 0; i < nNBinX; i++) {
h2New->GetXaxis()->SetBinLabel(i + 1, h3Src->GetXaxis()->GetBinLabel(i + 1));
for (j = 0; j < nNBinY; j++) {
h2New->GetYaxis()->SetBinLabel(j + 1, h3Src->GetYaxis()->GetBinLabel(j + 1));

if (h3Src->GetBinContent(i + 1, j + 1, 2) != 0) {
h2New->SetBinContent(i + 1, j + 1, 2);
} else if (h3Src->GetBinContent(i + 1, j + 1, 1) != 0) {
h2New->SetBinContent(i + 1, j + 1, 1);
}
}
}
}

void GEMDQMHarvester::fillUnderOverflowBunchCrossing(edm::Service<DQMStore> &store, std::string strNameSrc) {
std::string strDirCurr = "GEM/StatusDigi";

store->setCurrentFolder(strDirCurr);
MonitorElement *h2Curr = store->get(strDirCurr + "/" + strNameSrc);

Int_t nNBinX = h2Curr->getNbinsX();
Int_t nNBinY = h2Curr->getNbinsY();

for (Int_t i = 0; i < nNBinY; i++) {
h2Curr->setBinContent(1, i, h2Curr->getBinContent(0, i) + h2Curr->getBinContent(1, i));
h2Curr->setBinContent(nNBinX, i, h2Curr->getBinContent(nNBinX, i) + h2Curr->getBinContent(nNBinX + 1, i));
}
}

DEFINE_FWK_MODULE(GEMDQMHarvester);
111 changes: 92 additions & 19 deletions DQM/GEM/plugins/GEMDQMSource.cc
Expand Up @@ -9,6 +9,7 @@

#include "DQMServices/Core/interface/DQMEDAnalyzer.h"
#include "DQMServices/Core/interface/DQMStore.h"
#include "DQMServices/Core/interface/MonitorElement.h"

#include "DataFormats/GEMRecHit/interface/GEMRecHit.h"
#include "DataFormats/GEMRecHit/interface/GEMRecHitCollection.h"
Expand All @@ -35,6 +36,11 @@ class GEMDQMSource : public DQMEDAnalyzer {
private:
edm::EDGetToken tagRecHit_;

float fGlobXMin_, fGlobXMax_;
float fGlobYMin_, fGlobYMax_;

int nIdxFirstStrip_;

const GEMGeometry* initGeometry(edm::EventSetup const& iSetup);
int findVFAT(float min_, float max_, float x_, int roll_);

Expand All @@ -46,6 +52,7 @@ class GEMDQMSource : public DQMEDAnalyzer {
std::unordered_map<UInt_t, MonitorElement*> VFAT_vs_ClusterSize_;
std::unordered_map<UInt_t, MonitorElement*> StripsFired_vs_eta_;
std::unordered_map<UInt_t, MonitorElement*> rh_vs_eta_;
std::unordered_map<UInt_t, MonitorElement*> recGlobalPos;
};

using namespace std;
Expand Down Expand Up @@ -77,15 +84,32 @@ const GEMGeometry* GEMDQMSource::initGeometry(edm::EventSetup const& iSetup) {

GEMDQMSource::GEMDQMSource(const edm::ParameterSet& cfg) {
tagRecHit_ = consumes<GEMRecHitCollection>(cfg.getParameter<edm::InputTag>("recHitsInputLabel"));

nIdxFirstStrip_ = cfg.getParameter<int>("idxFirstStrip");

fGlobXMin_ = cfg.getParameter<double>("global_x_bound_min");
fGlobXMax_ = cfg.getParameter<double>("global_x_bound_max");
fGlobYMin_ = cfg.getParameter<double>("global_y_bound_min");
fGlobYMax_ = cfg.getParameter<double>("global_y_bound_max");
}

void GEMDQMSource::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.add<edm::InputTag>("recHitsInputLabel", edm::InputTag("gemRecHits", ""));

desc.add<int>("idxFirstStrip", 0);

desc.add<double>("global_x_bound_min", -350);
desc.add<double>("global_x_bound_max", 350);
desc.add<double>("global_y_bound_min", -260);
desc.add<double>("global_y_bound_max", 260);

descriptions.add("GEMDQMSource", desc);
}

void GEMDQMSource::bookHistograms(DQMStore::IBooker& ibooker, edm::Run const&, edm::EventSetup const& iSetup) {
std::vector<GEMDetId> listLayerOcc;

GEMGeometry_ = initGeometry(iSetup);
if (GEMGeometry_ == nullptr)
return;
Expand All @@ -94,31 +118,74 @@ void GEMDQMSource::bookHistograms(DQMStore::IBooker& ibooker, edm::Run const&, e
for (auto sch : superChambers_) {
int n_lay = sch->nChambers();
for (int l = 0; l < n_lay; l++) {
Bool_t bExist = false;
for (auto ch : gemChambers_)
if (ch.id() == sch->chamber(l + 1)->id())
bExist = true;
if (bExist)
continue;

gemChambers_.push_back(*sch->chamber(l + 1));
}
}

ibooker.cd();
ibooker.setCurrentFolder("GEM/recHit");

for (auto ch : gemChambers_) {
GEMDetId gid = ch.id();
string hName = "recHit_Gemini_" + to_string(gid.chamber()) + "_la_" + to_string(gid.layer());
string hTitle = "recHit Gemini chamber : " + to_string(gid.chamber()) + ", layer : " + to_string(gid.layer());
recHitME_[ch.id()] = ibooker.book1D(hName, hTitle, 24, 0, 24);

string hName_2 = "VFAT_vs_ClusterSize_Gemini_" + to_string(gid.chamber()) + "_la_" + to_string(gid.layer());
string hTitle_2 =
"VFAT vs ClusterSize Gemini chamber : " + to_string(gid.chamber()) + ", layer : " + to_string(gid.layer());
VFAT_vs_ClusterSize_[ch.id()] = ibooker.book2D(hName_2, hTitle_2, 9, 1, 10, 24, 0, 24);

string hName_fired = "StripFired_Gemini_" + to_string(gid.chamber()) + "_la_" + to_string(gid.layer());
string hTitle_fired =
"StripsFired Gemini chamber : " + to_string(gid.chamber()) + ", layer : " + to_string(gid.layer());
StripsFired_vs_eta_[ch.id()] = ibooker.book2D(hName_fired, hTitle_fired, 384, 1, 385, 8, 1, 9);

string hName_rh = "recHit_x_Gemini_" + to_string(gid.chamber()) + "_la_" + to_string(gid.layer());
string hTitle_rh =
"recHit local x Gemini chamber : " + to_string(gid.chamber()) + ", layer : " + to_string(gid.layer());
rh_vs_eta_[ch.id()] = ibooker.book2D(hName_rh, hTitle_rh, 50, -25, 25, 8, 1, 9);

std::string strIdxName = "Gemini_" + to_string(gid.chamber()) + "_GE" + (gid.region() > 0 ? "p" : "m") +
to_string(gid.station()) + "_" + to_string(gid.layer());
std::string strIdxTitle = "GEMINIm" + to_string(gid.chamber()) + " in GE" + (gid.region() > 0 ? "+" : "-") +
to_string(gid.station()) + "/" + to_string(gid.layer());

std::string strStId = (gid.region() > 0 ? "p" : "m") + std::to_string(gid.station());
std::string strStT = (gid.region() > 0 ? "+" : "-") + std::to_string(gid.station());

std::string strLa = std::to_string(gid.layer());
std::string strCh = std::to_string(gid.chamber());

string hName = "recHit_" + strIdxName;
string hTitle = "recHit " + strIdxTitle;
hTitle += ";VFAT;";
recHitME_[gid] = ibooker.book1D(hName, hTitle, 24, 0, 24);

string hName_2 = "VFAT_vs_ClusterSize_" + strIdxName;
string hTitle_2 = "VFAT vs ClusterSize " + strIdxTitle;
hTitle_2 += ";Cluster size;VFAT";
VFAT_vs_ClusterSize_[gid] = ibooker.book2D(hName_2, hTitle_2, 9, 1, 10, 24, 0, 24);

string hName_fired = "StripFired_" + strIdxName;
string hTitle_fired = "StripsFired " + strIdxTitle;
hTitle_fired += ";Strip;iEta";
StripsFired_vs_eta_[gid] = ibooker.book2D(hName_fired, hTitle_fired, 384, 1, 385, 8, 1, 9);

string hName_rh = "recHit_x_" + strIdxName;
string hTitle_rh = "recHit local x " + strIdxTitle;
hTitle_rh += ";Local x (cm);iEta";
rh_vs_eta_[gid] = ibooker.book2D(hName_rh, hTitle_rh, 50, -25, 25, 8, 1, 9);

GEMDetId lid(gid.region(), gid.ring(), gid.station(), gid.layer(), 0, 0);
Int_t nIdxOcc = 0;

for (; nIdxOcc < (Int_t)listLayerOcc.size(); nIdxOcc++)
if (listLayerOcc[nIdxOcc] == lid)
break;
if (nIdxOcc >= (Int_t)listLayerOcc.size())
listLayerOcc.push_back(lid);
}

for (auto gid : listLayerOcc) {
std::string strIdxName =
std::string("GE") + (gid.region() > 0 ? "p" : "m") + to_string(gid.station()) + "_" + to_string(gid.layer());
std::string strIdxTitle =
std::string("GE") + (gid.region() > 0 ? "+" : "-") + to_string(gid.station()) + "/" + to_string(gid.layer());

string hName_rh = "recHit_globalPos_Gemini_" + strIdxName;
string hTitle_rh = "recHit global position Gemini chamber : " + strIdxTitle;
hTitle_rh += ";Global X (cm);Global Y (cm)";
recGlobalPos[gid] = ibooker.book2D(hName_rh, hTitle_rh, 100, fGlobXMin_, fGlobXMax_, 100, fGlobYMin_, fGlobYMax_);
}
}

Expand All @@ -140,13 +207,19 @@ void GEMDQMSource::analyze(edm::Event const& event, edm::EventSetup const& event
const auto& recHitsRange = gemRecHits->get(rId);
auto gemRecHit = recHitsRange.first;
for (auto hit = gemRecHit; hit != recHitsRange.second; ++hit) {
int nVfat = findVFAT(1.0, 385.0, hit->firstClusterStrip() + 0.5 * hit->clusterSize(), rId.roll());
//int nVfat = findVFAT(0.0, 384.0, hit->firstClusterStrip()+0.5*hit->clusterSize(), rId.roll());
Int_t nIdxStrip = hit->firstClusterStrip() + 0.5 * hit->clusterSize() - nIdxFirstStrip_;
Int_t nVfat = 8 * ((Int_t)(nIdxStrip / (roll->nstrips() / 3)) + 1) - rId.roll(); // Strip:Start at 0
recHitME_[cId]->Fill(nVfat);
rh_vs_eta_[cId]->Fill(hit->localPosition().x(), rId.roll());
VFAT_vs_ClusterSize_[cId]->Fill(hit->clusterSize(), nVfat);
for (int i = hit->firstClusterStrip(); i < (hit->firstClusterStrip() + hit->clusterSize()); i++) {
StripsFired_vs_eta_[cId]->Fill(i, rId.roll());
}

GlobalPoint recHitGP = GEMGeometry_->idToDet(hit->gemId())->surface().toGlobal(hit->localPosition());
GEMDetId idLayer(rId.region(), rId.ring(), rId.station(), rId.layer(), 0, 0);
recGlobalPos[idLayer]->Fill(recHitGP.x(), recHitGP.y());
}
}
}
Expand Down
33 changes: 28 additions & 5 deletions DQM/GEM/plugins/GEMDQMSourceDigi.cc
Expand Up @@ -10,6 +10,7 @@
#include "DQMServices/Core/interface/DQMEDAnalyzer.h"
#include "DQMServices/Core/interface/DQMEDAnalyzer.h"
#include "DQMServices/Core/interface/DQMStore.h"
#include "DQMServices/Core/interface/MonitorElement.h"

#include "DataFormats/GEMDigi/interface/GEMDigiCollection.h"

Expand Down Expand Up @@ -43,6 +44,7 @@ class GEMDQMSourceDigi : public DQMEDAnalyzer {

std::unordered_map<UInt_t, MonitorElement*> Digi_2D_;
std::unordered_map<UInt_t, MonitorElement*> Digi_1D_;
std::unordered_map<UInt_t, MonitorElement*> BxVsVFAT;
};

using namespace std;
Expand Down Expand Up @@ -92,17 +94,36 @@ void GEMDQMSourceDigi::bookHistograms(DQMStore::IBooker& ibooker, edm::Run const
for (auto sch : superChambers_) {
int n_lay = sch->nChambers();
for (int l = 0; l < n_lay; l++) {
Bool_t bExist = false;
for (auto ch : gemChambers_)
if (ch.id() == sch->chamber(l + 1)->id())
bExist = true;
if (bExist)
continue;

gemChambers_.push_back(*sch->chamber(l + 1));
}
}
ibooker.cd();
ibooker.setCurrentFolder("GEM/digi");
for (auto ch : gemChambers_) {
GEMDetId gid = ch.id();
string hName_digi = "Digi_Strips_Gemini_" + to_string(gid.chamber()) + "_l_" + to_string(gid.layer());
string hTitle_digi = "Digi Strip GEMINIm" + to_string(gid.chamber()) + "l" + to_string(gid.layer());
Digi_2D_[ch.id()] = ibooker.book2D(hName_digi, hTitle_digi, 384, 1, 385, 8, 0.5, 8.5);
Digi_1D_[ch.id()] = ibooker.book1D(hName_digi + "_VFAT", hTitle_digi + " VFAT", 24, 0, 24);

std::string strIdxName = "Gemini_" + to_string(gid.chamber()) + "_GE" + (gid.region() > 0 ? "p" : "m") +
to_string(gid.station()) + "_" + to_string(gid.layer());
std::string strIdxTitle = "GEMINIm" + to_string(gid.chamber()) + " in GE" + (gid.region() > 0 ? "+" : "-") +
to_string(gid.station()) + "/" + to_string(gid.layer());

string hName_digi = "Digi_Strips_" + strIdxName;
string hTitle_digi = "Digi Strip " + strIdxTitle;
string hAxis_digi = ";Strip;iEta";
Digi_2D_[ch.id()] = ibooker.book2D(hName_digi, hTitle_digi + hAxis_digi, 384, 1, 385, 8, 0.5, 8.5);
Digi_1D_[ch.id()] = ibooker.book1D(hName_digi + "_VFAT", hTitle_digi + " VFAT" + hAxis_digi, 24, 0, 24);

string hNameBx = "bx_vs_VFAT_" + strIdxName;
string hTitleBx = "bx vs VFAT " + strIdxTitle;
hTitleBx += ";Bunch crossing;VFAT";
BxVsVFAT[ch.id()] = ibooker.book2D(hNameBx, hTitleBx, 10, -5, 5, 24, 0, 24);
}
}

Expand All @@ -119,8 +140,10 @@ void GEMDQMSourceDigi::analyze(edm::Event const& event, edm::EventSetup const& e
GEMDetId rId = roll->id();
const auto& digis_in_det = gemDigis->get(rId);
for (auto d = digis_in_det.first; d != digis_in_det.second; ++d) {
auto nVFAT = findVFAT(1, roll->nstrips(), d->strip(), rId.roll());
Digi_2D_[cId]->Fill(d->strip(), rId.roll());
Digi_1D_[cId]->Fill(findVFAT(1, roll->nstrips(), d->strip(), rId.roll()));
Digi_1D_[cId]->Fill(nVFAT);
BxVsVFAT[cId]->Fill(d->bx(), nVFAT);
}
}
}
Expand Down