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

[100X] GEM Online DQM #22580

Merged
merged 5 commits into from
Mar 12, 2018
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
3 changes: 3 additions & 0 deletions DQM/GEM/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<export>
<lib name="1"/>
</export>
20 changes: 20 additions & 0 deletions DQM/GEM/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<library file="*.cc" name="DQMGEMPlugins">
<flags EDM_PLUGIN="1"/>

<use name="FWCore/Framework"/>
<use name="FWCore/ParameterSet"/>
<use name="FWCore/Utilities"/>

<use name="DQMServices/Core"/>

<use name="DataFormats/Common"/>
<use name="DataFormats/MuonDetId"/>
<use name="DataFormats/GEMDigi"/>
<use name="DataFormats/GEMRecHit"/>

<use name="Geometry/Records"/>
<use name="Geometry/CommonDetUnit"/>
<use name="Geometry/GEMGeometry"/>

<use name="DQM/GEM"/>
</library>
35 changes: 35 additions & 0 deletions DQM/GEM/plugins/GEMDQMHarvester.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/Run.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Framework/interface/ESHandle.h"

//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"

using namespace edm;

class GEMDQMHarvester: public DQMEDHarvester
{
public:
GEMDQMHarvester(const edm::ParameterSet&) {};
~GEMDQMHarvester() override {};
static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
protected:
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override {};
};

void GEMDQMHarvester::fillDescriptions(edm::ConfigurationDescriptions & descriptions)
{
edm::ParameterSetDescription desc;
descriptions.add("GEMDQMHarvester", desc);
}

DEFINE_FWK_MODULE(GEMDQMHarvester);
157 changes: 157 additions & 0 deletions DQM/GEM/plugins/GEMDQMSource.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/PluginManager/interface/ModuleDef.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"


#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"
#include "DataFormats/GEMDigi/interface/GEMDigiCollection.h"

#include "Geometry/GEMGeometry/interface/GEMGeometry.h"
#include "Geometry/Records/interface/MuonGeometryRecord.h"

#include <string>

//----------------------------------------------------------------------------------------------------

class GEMDQMSource: public DQMEDAnalyzer
{
public:
GEMDQMSource(const edm::ParameterSet& cfg);
~GEMDQMSource() override {};
static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
protected:
void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override {};
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
void analyze(edm::Event const& e, edm::EventSetup const& eSetup) override;
void beginLuminosityBlock(edm::LuminosityBlock const& lumi, edm::EventSetup const& eSetup) override {};
void endLuminosityBlock(edm::LuminosityBlock const& lumi, edm::EventSetup const& eSetup) override {};
void endRun(edm::Run const& run, edm::EventSetup const& eSetup) override {};

private:
edm::EDGetToken tagRecHit_;

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

const GEMGeometry* GEMGeometry_;

std::vector<GEMChamber> gemChambers_;

std::unordered_map<UInt_t, MonitorElement*> recHitME_;
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_;

};

using namespace std;
using namespace edm;

int GEMDQMSource::findVFAT(float min_, float max_, float x_, int roll_) {
float step = abs(max_-min_)/3.0;
if ( x_ < (min(min_,max_)+step) ) { return 8 - roll_;}
else if ( x_ < (min(min_,max_)+2.0*step) ) { return 16 - roll_;}
else { return 24 - roll_;}
}

const GEMGeometry* GEMDQMSource::initGeometry(edm::EventSetup const & iSetup) {
const GEMGeometry* GEMGeometry_ = nullptr;
try {
edm::ESHandle<GEMGeometry> hGeom;
iSetup.get<MuonGeometryRecord>().get(hGeom);
GEMGeometry_ = &*hGeom;
}
catch( edm::eventsetup::NoProxyException<GEMGeometry>& e) {
edm::LogError("MuonGEMBaseValidation") << "+++ Error : GEM geometry is unavailable on event loop. +++\n";
return nullptr;
}
return GEMGeometry_;
}

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

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

void GEMDQMSource::bookHistograms(DQMStore::IBooker &ibooker, edm::Run const &, edm::EventSetup const & iSetup)
{
GEMGeometry_ = initGeometry(iSetup);
if ( GEMGeometry_ == nullptr) return ;

const std::vector<const GEMSuperChamber*>& superChambers_ = GEMGeometry_->superChambers();
for (auto sch : superChambers_){
int n_lay = sch->nChambers();
for (int l=0;l<n_lay;l++){
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);
}
}

void GEMDQMSource::analyze(edm::Event const& event, edm::EventSetup const& eventSetup)
{
const GEMGeometry* GEMGeometry_ = initGeometry(eventSetup);
if ( GEMGeometry_ == nullptr) return;

edm::Handle<GEMRecHitCollection> gemRecHits;
event.getByToken( this->tagRecHit_, gemRecHits);
if (!gemRecHits.isValid()) {
edm::LogError("GEMDQMSource") << "GEM recHit is not valid.\n";
return ;
}
for (auto ch : gemChambers_){
GEMDetId cId = ch.id();
for(auto roll : ch.etaPartitions()){
GEMDetId rId = roll->id();
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());
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());
}
}
}
}
}

DEFINE_FWK_MODULE(GEMDQMSource);
133 changes: 133 additions & 0 deletions DQM/GEM/plugins/GEMDQMSourceDigi.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/PluginManager/interface/ModuleDef.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

#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"

#include "Geometry/GEMGeometry/interface/GEMGeometry.h"
#include "Geometry/Records/interface/MuonGeometryRecord.h"

#include <string>

//----------------------------------------------------------------------------------------------------

class GEMDQMSourceDigi: public DQMEDAnalyzer
{
public:
GEMDQMSourceDigi(const edm::ParameterSet& cfg);
~GEMDQMSourceDigi() override {};
static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
protected:
void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override {};
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
void analyze(edm::Event const& e, edm::EventSetup const& eSetup) override;
void beginLuminosityBlock(edm::LuminosityBlock const& lumi, edm::EventSetup const& eSetup) override {};
void endLuminosityBlock(edm::LuminosityBlock const& lumi, edm::EventSetup const& eSetup) override {};
void endRun(edm::Run const& run, edm::EventSetup const& eSetup) override {};

private:
edm::EDGetToken tagDigi_;

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

const GEMGeometry* GEMGeometry_;

std::vector<GEMChamber> gemChambers_;

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

};

using namespace std;
using namespace edm;

int GEMDQMSourceDigi::findVFAT(float min_, float max_, float x_, int roll_) {
float step = max_/3;
if ( x_ < (min_+step) ) { return 8 - roll_;}
else if ( x_ < (min_+2*step) ) { return 16 - roll_;}
else { return 24 - roll_;}
}

const GEMGeometry* GEMDQMSourceDigi::initGeometry(edm::EventSetup const & iSetup) {
const GEMGeometry* GEMGeometry_ = nullptr;
try {
edm::ESHandle<GEMGeometry> hGeom;
iSetup.get<MuonGeometryRecord>().get(hGeom);
GEMGeometry_ = &*hGeom;
}
catch( edm::eventsetup::NoProxyException<GEMGeometry>& e) {
edm::LogError("MuonGEMBaseValidation") << "+++ Error : GEM geometry is unavailable on event loop. +++\n";
return nullptr;
}

return GEMGeometry_;
}

GEMDQMSourceDigi::GEMDQMSourceDigi(const edm::ParameterSet& cfg)
{
tagDigi_ = consumes<GEMDigiCollection>(cfg.getParameter<edm::InputTag>("digisInputLabel"));
}

void GEMDQMSourceDigi::fillDescriptions(edm::ConfigurationDescriptions & descriptions)
{
edm::ParameterSetDescription desc;
desc.add<edm::InputTag>("digisInputLabel", edm::InputTag("muonGEMDigis", ""));
descriptions.add("GEMDQMSourceDigi", desc);
}

void GEMDQMSourceDigi::bookHistograms(DQMStore::IBooker &ibooker, edm::Run const &, edm::EventSetup const & iSetup)
{
GEMGeometry_ = initGeometry(iSetup);
if ( GEMGeometry_ == nullptr) return ;

const std::vector<const GEMSuperChamber*>& superChambers_ = GEMGeometry_->superChambers();
for (auto sch : superChambers_){
int n_lay = sch->nChambers();
for (int l=0;l<n_lay;l++){
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);
}
}

void GEMDQMSourceDigi::analyze(edm::Event const& event, edm::EventSetup const& eventSetup)
{
const GEMGeometry* GEMGeometry_ = initGeometry(eventSetup);
if ( GEMGeometry_ == nullptr) return;

edm::Handle<GEMDigiCollection> gemDigis;
event.getByToken( this->tagDigi_, gemDigis);
for (auto ch : gemChambers_){
GEMDetId cId = ch.id();
for(auto roll : ch.etaPartitions()){
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){
Digi_2D_[ cId ]->Fill(d->strip(), rId.roll());
Digi_1D_[ cId ]->Fill(findVFAT(1, roll->nstrips(), d->strip(), rId.roll()));
}
}
}
}

DEFINE_FWK_MODULE(GEMDQMSourceDigi);