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

Adding HLT_Ele50_CaloIdVT_GsfTrkIdT_PFJet165_v* to B2G HLT Monitoring #19407

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
33c0800
Update Prompt DQM for HLT Jet
physicist87 Jun 9, 2017
ad4178b
Update Prompt DQM for HLT Jet
physicist87 Jun 9, 2017
0710087
Update To use edm::View<reco::Jet>
physicist87 Jun 15, 2017
5eeaf13
Update To use edm::View<reco::Jet>
physicist87 Jun 15, 2017
97f4f26
Ratio Plot(HEP17/HEM17) for eta phi pT
physicist87 Jun 15, 2017
aaa57c0
To avoid the case of non ak4pfjet, bug fix
physicist87 Jun 21, 2017
35d562d
added HTmonitoring, HT plots inside METmonitor, added in ExoClient
sudhaahuja May 23, 2017
485aba9
edited METmonitor with HT plots
sudhaahuja May 23, 2017
48fa1af
METmonitor and HTmonitor updated
sudhaahuja May 26, 2017
97a7d82
updates after comment on PR
sudhaahuja May 31, 2017
8d65020
updated hltpaths in HTmonitor & other changes
sudhaahuja Jun 6, 2017
5bd2752
small correction in HT/MET clients
sudhaahuja Jun 12, 2017
e38b9de
Create ExoticaMonitoring_Client_cff.py
sudhaahuja Jun 12, 2017
dd5e105
B2G monitor added from PR19214 & small changes HT/MET monitor
sudhaahuja Jun 15, 2017
e2f9710
Code review updates
rappoccio Jun 16, 2017
e7bad20
Commenting out JME-dependent modules until it is integrated
rappoccio Jun 16, 2017
c775c26
A few edits and corrections
rappoccio Jun 16, 2017
16ad01d
Changing EDAnalyzer to EDProducer
rappoccio Jun 16, 2017
6cc2aaf
Adding ele50+PFjet165 trigger to B2G HLT Monitoring
UBParker Jun 20, 2017
0766139
add b2gMonitorHLT_elplusJet to sequence
UBParker Jun 21, 2017
c56d739
Removing stray ) in B2GTnPMonitor_cfi.py
UBParker Jun 21, 2017
cfcf9a4
Remove L167
UBParker Jun 30, 2017
a77f1d9
Import HT and MET clients
UBParker Jun 30, 2017
7aabfe7
Removing PFMETNoMu90_PFMHTNoMu90 , MET200 & MonoCentralPFJet80_PFMET…
UBParker Jun 30, 2017
fe94e27
Again removing PFMETNoMu90_PFMHTNoMu90 , MET200 & MonoCentralPFJet80…
UBParker Jun 30, 2017
e6a6fe0
fix uncertainty for simpleratio in DQMGenericClient
physicist87 Jul 3, 2017
f5ce0b7
There is no need to use JetPomptDQMPostProcessor, because we will use…
physicist87 Jul 3, 2017
933b1cf
Update JetMETPromptMonitoring_Client_cff, To use DQMGenericClient ins…
physicist87 Jul 3, 2017
4776002
Merge branch 'master' into AddingHLTEl50PFJet165
UBParker Jul 3, 2017
33c405d
Update ExoticaMonitoring_cff.py
UBParker Jul 3, 2017
e2a3e7b
Removing fixed binning in METmonitor
UBParker Jul 3, 2017
b79f6e7
Remove fixed binning in HTmonitor
UBParker Jul 3, 2017
9b599be
add muon flag
UBParker Jul 3, 2017
0c63302
Merge branch 'master' into AddingHLTEl50PFJet165
UBParker Jul 4, 2017
dd7fdb2
Merged refs/pull/19178/head from repository cms-sw
UBParker Jul 4, 2017
681da97
Implement changes for after PR 19178 is merged and added HLT_AK8PFJet…
UBParker Jul 4, 2017
491bd35
fix typo in metVsLS_ name
UBParker Jul 4, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DQMOffline/Trigger/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<use name="DQMServices/Core"/>
<use name="CommonTools/Utils"/>
<use name="CommonTools/TriggerUtils"/>
<use name="DataFormats/VertexReco"/>
<use name="root"/>
<use name="roofit"/>
<use name="boost"/>
Expand Down
311 changes: 311 additions & 0 deletions DQMOffline/Trigger/plugins/HTMonitor.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,311 @@
#include "DQMOffline/Trigger/plugins/HTMonitor.h"

#include "CommonTools/TriggerUtils/interface/GenericTriggerEventFlag.h"

#include "DataFormats/Math/interface/deltaPhi.h"

// -----------------------------
// constructors and destructor
// -----------------------------

HTMonitor::HTMonitor( const edm::ParameterSet& iConfig ) :
folderName_ ( iConfig.getParameter<std::string>("FolderName") )
, metToken_ ( consumes<reco::PFMETCollection> (iConfig.getParameter<edm::InputTag>("met") ) )
, jetToken_ ( mayConsume<reco::PFJetCollection> (iConfig.getParameter<edm::InputTag>("jets") ) )
, eleToken_ ( mayConsume<reco::GsfElectronCollection>(iConfig.getParameter<edm::InputTag>("electrons") ) )
, muoToken_ ( mayConsume<reco::MuonCollection> (iConfig.getParameter<edm::InputTag>("muons") ) )
, vtxToken_ ( mayConsume<reco::VertexCollection> (iConfig.getParameter<edm::InputTag>("vertices") ) )
, ht_variable_binning_ ( iConfig.getParameter<edm::ParameterSet>("histoPSet").getParameter<std::vector<double> >("htBinning") )
, ls_binning_ ( getHistoLSPSet (iConfig.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet> ("lsPSet") ) )
, num_genTriggerEventFlag_(new GenericTriggerEventFlag(iConfig.getParameter<edm::ParameterSet>("numGenericTriggerEventPSet"),consumesCollector(), *this))
, den_genTriggerEventFlag_(new GenericTriggerEventFlag(iConfig.getParameter<edm::ParameterSet>("denGenericTriggerEventPSet"),consumesCollector(), *this))
, metSelection_ ( iConfig.getParameter<std::string>("metSelection") )
, jetSelection_ ( iConfig.getParameter<std::string>("jetSelection") )
, eleSelection_ ( iConfig.getParameter<std::string>("eleSelection") )
, muoSelection_ ( iConfig.getParameter<std::string>("muoSelection") )
, jetSelection_HT_ ( iConfig.getParameter<std::string>("jetSelection_HT") )
, njets_ ( iConfig.getParameter<unsigned>("njets" ) )
, nelectrons_ ( iConfig.getParameter<unsigned>("nelectrons" ) )
, nmuons_ ( iConfig.getParameter<unsigned>("nmuons" ) )
{

htME_variableBinning_.numerator = nullptr;
htME_variableBinning_.denominator = nullptr;
htVsLS_.numerator = nullptr;
htVsLS_.denominator = nullptr;
deltaphimetj1ME_.numerator = nullptr;
deltaphimetj1ME_.denominator = nullptr;
deltaphij1j2ME_.numerator = nullptr;
deltaphij1j2ME_.denominator = nullptr;

}

HTMonitor::~HTMonitor()
{
}

HTMonitor::MEHTbinning HTMonitor::getHistoPSet(edm::ParameterSet pset)
{
return HTMonitor::MEHTbinning{
pset.getParameter<int32_t>("nbins"),
pset.getParameter<double>("xmin"),
pset.getParameter<double>("xmax"),
};
}

HTMonitor::MEHTbinning HTMonitor::getHistoLSPSet(edm::ParameterSet pset)
{
return HTMonitor::MEHTbinning{
pset.getParameter<int32_t>("nbins"),
0.,
double(pset.getParameter<int32_t>("nbins"))
};
}

void HTMonitor::setHTitle(HTME& me, std::string titleX, std::string titleY)
{
me.numerator->setAxisTitle(titleX,1);
me.numerator->setAxisTitle(titleY,2);
me.denominator->setAxisTitle(titleX,1);
me.denominator->setAxisTitle(titleY,2);

}

void HTMonitor::bookME(DQMStore::IBooker &ibooker, HTME& me, const std::string& histname, const std::string& histtitle, int nbins, double min, double max)
{
me.numerator = ibooker.book1D(histname+"_numerator", histtitle+" (numerator)", nbins, min, max);
me.denominator = ibooker.book1D(histname+"_denominator", histtitle+" (denominator)", nbins, min, max);
}
void HTMonitor::bookME(DQMStore::IBooker &ibooker, HTME& me, const std::string& histname, const std::string& histtitle, const std::vector<double>& binning)
{
int nbins = binning.size()-1;
std::vector<float> fbinning(binning.begin(),binning.end());
float* arr = &fbinning[0];
me.numerator = ibooker.book1D(histname+"_numerator", histtitle+" (numerator)", nbins, arr);
me.denominator = ibooker.book1D(histname+"_denominator", histtitle+" (denominator)", nbins, arr);
}
void HTMonitor::bookME(DQMStore::IBooker &ibooker, HTME& me, const std::string& histname, const std::string& histtitle, int nbinsX, double xmin, double xmax, double ymin, double ymax)
{
me.numerator = ibooker.bookProfile(histname+"_numerator", histtitle+" (numerator)", nbinsX, xmin, xmax, ymin, ymax);
me.denominator = ibooker.bookProfile(histname+"_denominator", histtitle+" (denominator)", nbinsX, xmin, xmax, ymin, ymax);
}
void HTMonitor::bookME(DQMStore::IBooker &ibooker, HTME& me, const std::string& histname, const std::string& histtitle, int nbinsX, double xmin, double xmax, int nbinsY, double ymin, double ymax)
{
me.numerator = ibooker.book2D(histname+"_numerator", histtitle+" (numerator)", nbinsX, xmin, xmax, nbinsY, ymin, ymax);
me.denominator = ibooker.book2D(histname+"_denominator", histtitle+" (denominator)", nbinsX, xmin, xmax, nbinsY, ymin, ymax);
}
void HTMonitor::bookME(DQMStore::IBooker &ibooker, HTME& me, const std::string& histname, const std::string& histtitle, const std::vector<double>& binningX, const std::vector<double>& binningY)
{
int nbinsX = binningX.size()-1;
std::vector<float> fbinningX(binningX.begin(),binningX.end());
float* arrX = &fbinningX[0];
int nbinsY = binningY.size()-1;
std::vector<float> fbinningY(binningY.begin(),binningY.end());
float* arrY = &fbinningY[0];

me.numerator = ibooker.book2D(histname+"_numerator", histtitle+" (numerator)", nbinsX, arrX, nbinsY, arrY);
me.denominator = ibooker.book2D(histname+"_denominator", histtitle+" (denominator)", nbinsX, arrX, nbinsY, arrY);
}

void HTMonitor::bookME(DQMStore::IBooker &ibooker, HTME& me, const std::string& histname, const std::string& histtitle,int nbinsX, double xmin, double xmax , const std::vector<double>& binningY)
{

int nbinsY = binningY.size()-1;
std::vector<float> fbinningY(binningY.begin(),binningY.end());
float* arrY = &fbinningY[0];

me.numerator = ibooker.book2D(histname+"_numerator", histtitle+" (numerator)", nbinsX, xmin, xmax , nbinsY, arrY);
me.denominator = ibooker.book2D(histname+"_denominator", histtitle+" (denominator)", nbinsX, xmin, xmax , nbinsY, arrY);
}

void HTMonitor::bookHistograms(DQMStore::IBooker & ibooker,
edm::Run const & iRun,
edm::EventSetup const & iSetup)
{

std::string histname, histtitle;

std::string currentFolder = folderName_ ;
ibooker.setCurrentFolder(currentFolder.c_str());

histname = "ht_variable"; histtitle = "HT";
bookME(ibooker,htME_variableBinning_,histname,histtitle,ht_variable_binning_);
setHTitle(htME_variableBinning_,"HT [GeV]","events / [GeV]");

histname = "htVsLS"; histtitle = "HT vs LS";
bookME(ibooker,htVsLS_,histname,histtitle,ls_binning_.nbins, ls_binning_.xmin, ls_binning_.xmax,ht_variable_binning_);
setHTitle(htVsLS_,"LS","HT [GeV]");

histname = "deltaphi_metjet1"; histtitle = "DPHI_METJ1";
bookME(ibooker,deltaphimetj1ME_,histname,histtitle,phi_binning_.nbins, phi_binning_.xmin, phi_binning_.xmax);
setHTitle(deltaphimetj1ME_,"delta phi (met, j1)","events / 0.1 rad");

histname = "deltaphi_jet1jet2"; histtitle = "DPHI_J1J2";
bookME(ibooker,deltaphij1j2ME_,histname,histtitle,phi_binning_.nbins, phi_binning_.xmin, phi_binning_.xmax);
setHTitle(deltaphij1j2ME_,"delta phi (j1, j2)","events / 0.1 rad");

// Initialize the GenericTriggerEventFlag
if ( num_genTriggerEventFlag_ && num_genTriggerEventFlag_->on() ) num_genTriggerEventFlag_->initRun( iRun, iSetup );
if ( den_genTriggerEventFlag_ && den_genTriggerEventFlag_->on() ) den_genTriggerEventFlag_->initRun( iRun, iSetup );

}

#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
#include "Geometry/Records/interface/TrackerTopologyRcd.h"
void HTMonitor::analyze(edm::Event const& iEvent, edm::EventSetup const& iSetup) {

// Filter out events if Trigger Filtering is requested
if (den_genTriggerEventFlag_->on() && ! den_genTriggerEventFlag_->accept( iEvent, iSetup) ) return;

edm::Handle<reco::PFMETCollection> metHandle;
iEvent.getByToken( metToken_, metHandle );
reco::PFMET pfmet = metHandle->front();
if ( ! metSelection_( pfmet ) ) return;

float ht = 0.0;

edm::Handle<reco::PFJetCollection> jetHandle; //add a configurable jet collection & jet pt selection
iEvent.getByToken( jetToken_, jetHandle );
std::vector<reco::PFJet> jets;
jets.clear();
if ( jetHandle->size() < njets_ ) return;
for ( auto const & j : *jetHandle ) {
if ( jetSelection_( j ) ) {
jets.push_back(j);
}
}
for ( auto const & j : *jetHandle ) {
if ( jetSelection_HT_(j)) ht += j.pt();
}
if ( jets.size() < njets_ ) return;

float deltaPhi_met_j1 = 10.0;
float deltaPhi_j1_j2 = 10.0;

if (jets.size() >= 1) deltaPhi_met_j1 = fabs( deltaPhi( pfmet.phi(), jets[0].phi() ));
if (jets.size() >= 2) deltaPhi_j1_j2 = fabs( deltaPhi( jets[0].phi(), jets[1].phi() ));

edm::Handle<reco::GsfElectronCollection> eleHandle;
iEvent.getByToken( eleToken_, eleHandle );
std::vector<reco::GsfElectron> electrons;
electrons.clear();
if ( eleHandle->size() < nelectrons_ ) return;
for ( auto const & e : *eleHandle ) {
if ( eleSelection_( e ) ) electrons.push_back(e);
}
if ( electrons.size() < nelectrons_ ) return;

edm::Handle<reco::VertexCollection> vtxHandle;
iEvent.getByToken(vtxToken_, vtxHandle);

reco::Vertex vtx;
math::XYZPoint pv(0, 0, 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why don't you make use of the beam spot if the PV is not available/valid ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code was already present before I began working on this. If you would like me to make use of beam spot and if @rappoccio agrees that this is a necessary update then I will implement it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sudhaahuja Can you comment on this?

for (vector<reco::Vertex>::const_iterator v = vtxHandle->begin(); v != vtxHandle->end(); ++v) {
bool isFake = v->isFake() ;

if (!isFake) {
pv.SetXYZ(v->x(), v->y(), v->z());
vtx = *v;
break;
}
}

edm::Handle<reco::MuonCollection> muoHandle;
iEvent.getByToken( muoToken_, muoHandle );
if ( muoHandle->size() < nmuons_ ) return;
std::vector<reco::Muon> muons;
muons.clear();
for ( auto const & m : *muoHandle ) {
bool pass = m.isGlobalMuon() && m.isPFMuon() && m.globalTrack()->normalizedChi2() < 10. && m.globalTrack()->hitPattern().numberOfValidMuonHits() > 0 && m.numberOfMatchedStations() > 1 && fabs(m.muonBestTrack()->dxy(pv)) < 0.2 && fabs(m.muonBestTrack()->dz(pv)) < 0.5 && m.innerTrack()->hitPattern().numberOfValidPixelHits() > 0 && m.innerTrack()->hitPattern().trackerLayersWithMeasurement() > 5;
if ( muoSelection_( m ) && pass ) muons.push_back(m);
}
if ( muons.size() < nmuons_ ) return;

// filling histograms (denominator)
htME_variableBinning_.denominator -> Fill(ht);
deltaphimetj1ME_.denominator -> Fill(deltaPhi_met_j1);
deltaphij1j2ME_.denominator -> Fill(deltaPhi_j1_j2);

int ls = iEvent.id().luminosityBlock();
htVsLS_.denominator -> Fill(ls, ht);

// applying selection for numerator
if (num_genTriggerEventFlag_->on() && ! num_genTriggerEventFlag_->accept( iEvent, iSetup) ) return;

// filling histograms (num_genTriggerEventFlag_)
htME_variableBinning_.numerator -> Fill(ht);
htVsLS_.numerator -> Fill(ls, ht);
deltaphimetj1ME_.numerator -> Fill(deltaPhi_met_j1);
deltaphij1j2ME_.numerator -> Fill(deltaPhi_j1_j2);

}

void HTMonitor::fillHistoPSetDescription(edm::ParameterSetDescription & pset)
{
pset.add<int> ( "nbins");
pset.add<double>( "xmin" );
pset.add<double>( "xmax" );
}

void HTMonitor::fillHistoLSPSetDescription(edm::ParameterSetDescription & pset)
{
pset.add<int> ( "nbins", 2500);
}

void HTMonitor::fillDescriptions(edm::ConfigurationDescriptions & descriptions)
{
edm::ParameterSetDescription desc;
desc.add<std::string> ( "FolderName", "HLT/HT" );

desc.add<edm::InputTag>( "met", edm::InputTag("pfMet") );
desc.add<edm::InputTag>( "jets", edm::InputTag("ak4PFJetsCHS") );
desc.add<edm::InputTag>( "electrons",edm::InputTag("gedGsfElectrons") );
desc.add<edm::InputTag>( "muons", edm::InputTag("muons") );
desc.add<edm::InputTag>( "vertices",edm::InputTag("offlinePrimaryVertices") );
desc.add<std::string>("metSelection", "pt > 0");
desc.add<std::string>("jetSelection", "pt > 0");
desc.add<std::string>("eleSelection", "pt > 0");
desc.add<std::string>("muoSelection", "pt > 0");
desc.add<std::string>("jetSelection_HT", "pt > 30 && eta < 2.5");
desc.add<unsigned>("njets", 0);
desc.add<unsigned>("nelectrons", 0);
desc.add<unsigned>("nmuons", 0);

edm::ParameterSetDescription genericTriggerEventPSet;
genericTriggerEventPSet.add<bool>("andOr");
genericTriggerEventPSet.add<edm::InputTag>("dcsInputTag", edm::InputTag("scalersRawToDigi") );
genericTriggerEventPSet.add<std::vector<int> >("dcsPartitions",{});
genericTriggerEventPSet.add<bool>("andOrDcs", false);
genericTriggerEventPSet.add<bool>("errorReplyDcs", true);
genericTriggerEventPSet.add<std::string>("dbLabel","");
genericTriggerEventPSet.add<bool>("andOrHlt", true);
genericTriggerEventPSet.add<edm::InputTag>("hltInputTag", edm::InputTag("TriggerResults::HLT") );
genericTriggerEventPSet.add<std::vector<std::string> >("hltPaths",{});
genericTriggerEventPSet.add<std::string>("hltDBKey","");
genericTriggerEventPSet.add<bool>("errorReplyHlt",false);
genericTriggerEventPSet.add<unsigned int>("verbosityLevel",1);

desc.add<edm::ParameterSetDescription>("numGenericTriggerEventPSet", genericTriggerEventPSet);
desc.add<edm::ParameterSetDescription>("denGenericTriggerEventPSet", genericTriggerEventPSet);

edm::ParameterSetDescription histoPSet;
edm::ParameterSetDescription htPSet;
fillHistoPSetDescription(htPSet);
histoPSet.add<edm::ParameterSetDescription>("htPSet", htPSet);
std::vector<double> bins = {0.,20.,40.,60.,80.,90.,100.,110.,120.,130.,140.,150.,160.,170.,180.,190.,200.,220.,240.,260.,280.,300.,350.,400.,450.,500.,550.,600.,650.,700.,750.,800.,850.,900.,950.,1000.,1050.,1100.,1200.,1300.,1400.,1500.,2000.,2500.};
histoPSet.add<std::vector<double> >("htBinning", bins);

edm::ParameterSetDescription lsPSet;
fillHistoLSPSetDescription(lsPSet);
histoPSet.add<edm::ParameterSetDescription>("lsPSet", lsPSet);

desc.add<edm::ParameterSetDescription>("histoPSet",histoPSet);

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

// Define this as a plug-in
#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_FWK_MODULE(HTMonitor);
Loading