Skip to content

Commit

Permalink
Merge pull request #11 from sroychow/updateTotopdqm
Browse files Browse the repository at this point in the history
Update top hlt dqm code to include PV cuts to be used by higgs montoring
  • Loading branch information
defranchis authored Jun 7, 2017
2 parents 5b9627b + c817647 commit a0f4163
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 7 deletions.
47 changes: 44 additions & 3 deletions DQMOffline/Trigger/plugins/TopMonitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ TopMonitor::TopMonitor( 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") ) )
, eleToken_ ( mayConsume<edm::View<reco::GsfElectron> >(iConfig.getParameter<edm::InputTag>("electrons") ) )
, muoToken_ ( mayConsume<reco::MuonCollection> (iConfig.getParameter<edm::InputTag>("muons") ) )
// Marina
, jetTagToken_ ( mayConsume<reco::JetTagCollection> (iConfig.getParameter<edm::InputTag>("btagalgo") ))
//Suvankar
, vtxToken_ ( mayConsume<reco::VertexCollection> (iConfig.getParameter<edm::InputTag>("vertices") ) )
, met_binning_ ( getHistoPSet (iConfig.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet> ("metPSet") ) )
, ls_binning_ ( getHistoLSPSet (iConfig.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet> ("lsPSet") ) )
, phi_binning_ ( getHistoPSet (iConfig.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet> ("phiPSet") ) )
Expand Down Expand Up @@ -50,6 +52,7 @@ TopMonitor::TopMonitor( const edm::ParameterSet& iConfig ) :
, eleSelection_ ( iConfig.getParameter<std::string>("eleSelection") )
, muoSelection_ ( iConfig.getParameter<std::string>("muoSelection") )
, HTdefinition_ ( iConfig.getParameter<std::string>("HTdefinition") )
, vtxSelection_ ( iConfig.getParameter<std::string>("vertexSelection") )
, bjetSelection_( iConfig.getParameter<std::string>("bjetSelection"))
, njets_ ( iConfig.getParameter<unsigned int>("njets" ) )
, nelectrons_ ( iConfig.getParameter<unsigned int>("nelectrons" ) )
Expand All @@ -59,6 +62,8 @@ TopMonitor::TopMonitor( const edm::ParameterSet& iConfig ) :
// Marina
, nbjets_ ( iConfig.getParameter<unsigned int>("nbjets"))
, workingpoint_(iConfig.getParameter<double>("workingpoint"))
//Suvankar
, usePVcuts_ ( iConfig.getParameter<bool>("applyleptonPVcuts") )
{

METME empty;
Expand Down Expand Up @@ -133,7 +138,9 @@ TopMonitor::TopMonitor( const edm::ParameterSet& iConfig ) :
bjetPtEta_.push_back(empty);
bjetEtaPhi_.push_back(empty);
}

//Suvankar
lepPVcuts_.dxy = (iConfig.getParameter<edm::ParameterSet>("leptonPVcuts")).getParameter<double>("dxy");
lepPVcuts_.dz = (iConfig.getParameter<edm::ParameterSet>("leptonPVcuts")).getParameter<double>("dz");
}

TopMonitor::~TopMonitor()
Expand Down Expand Up @@ -511,11 +518,27 @@ void TopMonitor::bookHistograms(DQMStore::IBooker & ibooker,
#include "FWCore/Framework/interface/EventSetup.h"
#include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
#include "Geometry/Records/interface/TrackerTopologyRcd.h"
//Suvankar
#include "DataFormats/GsfTrackReco/interface/GsfTrackFwd.h"
#include "DataFormats/GsfTrackReco/interface/GsfTrack.h"

void TopMonitor::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;

//Suvankar
edm::Handle<reco::VertexCollection> primaryVertices;
iEvent.getByToken(vtxToken_, primaryVertices);
//Primary Vertex selection
const reco::Vertex* pv = nullptr;
for(auto const& v: *primaryVertices) {
if ( !vtxSelection_( v ) ) continue;
pv = &v;
break;
}
if(usePVcuts_ && pv == nullptr) return;

edm::Handle<reco::PFMETCollection> metHandle;
iEvent.getByToken( metToken_, metHandle );
if (!metHandle.isValid()){
Expand All @@ -528,7 +551,7 @@ void TopMonitor::analyze(edm::Event const& iEvent, edm::EventSetup const& iSetup
float met = pfmet.pt();
float phi = pfmet.phi();

edm::Handle<reco::GsfElectronCollection> eleHandle;
edm::Handle<edm::View<reco::GsfElectron> > eleHandle;
iEvent.getByToken( eleToken_, eleHandle );
if (!eleHandle.isValid()){
edm::LogWarning("TopMonitor") << "Electron handle not valid \n";
Expand All @@ -538,6 +561,9 @@ void TopMonitor::analyze(edm::Event const& iEvent, edm::EventSetup const& iSetup
if ( eleHandle->size() < nelectrons_ ) return;
for ( auto const & e : *eleHandle ) {
if ( eleSelection_( e ) ) electrons.push_back(e);
//Suvankar
if ( usePVcuts_ &&
(std::fabs(e.gsfTrack()->dxy(pv->position())) >= lepPVcuts_.dxy || std::fabs(e.gsfTrack()->dz(pv->position())) >= lepPVcuts_.dz) ) continue;
}
if ( electrons.size() < nelectrons_ ) return;

Expand All @@ -551,6 +577,9 @@ void TopMonitor::analyze(edm::Event const& iEvent, edm::EventSetup const& iSetup
std::vector<reco::Muon> muons;
for ( auto const & m : *muoHandle ) {
if ( muoSelection_( m ) ) muons.push_back(m);
//Suvankar
if ( usePVcuts_ &&
(std::fabs(m.muonBestTrack()->dxy(pv->position())) >= lepPVcuts_.dxy || std::fabs(m.muonBestTrack()->dz(pv->position())) >= lepPVcuts_.dz) ) continue;
}
if ( muons.size() < nmuons_ ) return;

Expand Down Expand Up @@ -857,13 +886,17 @@ void TopMonitor::fillDescriptions(edm::ConfigurationDescriptions & descriptions)
desc.add<edm::InputTag>( "jets", edm::InputTag("ak4PFJetsCHS") );
desc.add<edm::InputTag>( "electrons",edm::InputTag("gedGsfElectrons") );
desc.add<edm::InputTag>( "muons", edm::InputTag("muons") );
//Suvankar
desc.add<edm::InputTag>( "vertices", edm::InputTag("offlinePrimaryVertices") );
// Marina
desc.add<edm::InputTag>( "btagalgo", edm::InputTag("pfCombinedSecondaryVertexV2BJetTags") );
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>("HTdefinition", "pt > 0");
//Suvankar
desc.add<std::string>("vertexSelection", "!isFake");
desc.add<std::string>("bjetSelection","pt > 0");
desc.add<unsigned int>("njets", 0);
desc.add<unsigned int>("nelectrons", 0);
Expand All @@ -873,6 +906,8 @@ void TopMonitor::fillDescriptions(edm::ConfigurationDescriptions & descriptions)
// Marina
desc.add<unsigned int>("nbjets", 0);
desc.add<double>("workingpoint", 0.8484); // medium CSV
//Suvankar
desc.add<bool>("applyleptonPVcuts", false);

edm::ParameterSetDescription genericTriggerEventPSet;
genericTriggerEventPSet.add<bool>("andOr");
Expand Down Expand Up @@ -941,10 +976,16 @@ void TopMonitor::fillDescriptions(edm::ConfigurationDescriptions & descriptions)
histoPSet.add<edm::ParameterSetDescription>("lsPSet", lsPSet);

desc.add<edm::ParameterSetDescription>("histoPSet",histoPSet);
//Suvankar
edm::ParameterSetDescription lPVcutPSet;
lPVcutPSet.add<double>( "dxy", 9999. );
lPVcutPSet.add<double>( "dz", 9999. );
desc.add<edm::ParameterSetDescription>("leptonPVcuts", lPVcutPSet);

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

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

25 changes: 21 additions & 4 deletions DQMOffline/Trigger/plugins/TopMonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@
#include "DataFormats/EgammaCandidates/interface/PhotonFwd.h"
// Marina
#include "DataFormats/BTauReco/interface/JetTag.h"

//Suvankar
#include "DataFormats/VertexReco/interface/Vertex.h"
#include "DataFormats/VertexReco/interface/VertexFwd.h"

//root
#include "TLorentzVector.h"
Expand All @@ -56,6 +58,13 @@ struct METME {
MonitorElement* numerator;
MonitorElement* denominator;
};

//Suvankar
struct PVcut {
double dxy;
double dz;
};

//
// class declaration
//
Expand Down Expand Up @@ -101,11 +110,12 @@ class TopMonitor : public DQMEDAnalyzer

edm::EDGetTokenT<reco::PFMETCollection> metToken_;
edm::EDGetTokenT<reco::PFJetCollection> jetToken_;
edm::EDGetTokenT<reco::GsfElectronCollection> eleToken_;
edm::EDGetTokenT<edm::View<reco::GsfElectron> > eleToken_;
edm::EDGetTokenT<reco::MuonCollection> muoToken_;
// Marina
edm::EDGetTokenT<reco::JetTagCollection> jetTagToken_ ;

//Suvankar
edm::EDGetTokenT<reco::VertexCollection> vtxToken_;

MEbinning met_binning_;
MEbinning ls_binning_;
Expand Down Expand Up @@ -217,16 +227,23 @@ class TopMonitor : public DQMEDAnalyzer
StringCutObjectSelector<reco::GsfElectron,true> eleSelection_;
StringCutObjectSelector<reco::Muon,true> muoSelection_;
StringCutObjectSelector<reco::PFJet,true > HTdefinition_;
//Suvankar
StringCutObjectSelector<reco::Vertex,true> vtxSelection_;

StringCutObjectSelector<reco::Jet,true > bjetSelection_;

unsigned int njets_;
unsigned int njets_;
unsigned int nelectrons_;
unsigned int nmuons_;
double leptJetDeltaRmin_;
double HTcut_;
// Marina
unsigned int nbjets_;
double workingpoint_;

//Suvankar
PVcut lepPVcuts_;
bool usePVcuts_;

};

Expand Down
8 changes: 8 additions & 0 deletions DQMOffline/Trigger/python/TopMonitor_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@
xmax = cms.double( 1.0 ),
)

#Suvankar
hltTOPmonitoring.applyleptonPVcuts = cms.bool(False)
hltTOPmonitoring.leptonPVcuts = cms.PSet(
dxy = cms.double( 9999. ),
dz = cms.double( 9999. ),
)

#MET and HT binning
hltTOPmonitoring.histoPSet.metBinning = cms.vdouble(0,20,40,60,80,100,125,150,175,200)
Expand Down Expand Up @@ -65,6 +71,8 @@
hltTOPmonitoring.jets = cms.InputTag("pfJetsEI") # ak4PFJets, ak4PFJetsCHS
hltTOPmonitoring.electrons = cms.InputTag("gedGsfElectrons") # while pfIsolatedElectronsEI are reco::PFCandidate !
hltTOPmonitoring.muons = cms.InputTag("muons") # while pfIsolatedMuonsEI are reco::PFCandidate !
#Suvankar
hltTOPmonitoring.vertices = cms.InputTag("offlinePrimaryVertices")

# Marina
hltTOPmonitoring.btagalgo = cms.InputTag("pfCombinedSecondaryVertexV2BJetTags")
Expand Down

0 comments on commit a0f4163

Please sign in to comment.