Skip to content

Commit

Permalink
Merge pull request #7908 from ndaci/ExoValDev_75X_PR1
Browse files Browse the repository at this point in the history
Added Dxy plots (only for electron/muon at this moment)
  • Loading branch information
cmsbuild committed Feb 28, 2015
2 parents e512264 + 5003e10 commit 8d9df8c
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 11 deletions.
4 changes: 3 additions & 1 deletion HLTriggerOffline/Exotica/interface/HLTExoticaPlotter.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ class HLTExoticaPlotter {
void plotterBookHistos(DQMStore::IBooker & iBooker, const edm::Run & iRun, const edm::EventSetup & iSetup);
void analyze(const bool & isPassTrigger, const std::string & source,
const std::vector<reco::LeafCandidate> & matches,
std::map<int,double> theSumEt);
std::map<int,double> theSumEt,
std::vector<float> & dxys);

inline const std::string gethltpath() const
{
Expand All @@ -74,6 +75,7 @@ class HLTExoticaPlotter {
std::vector<double> _parametersEta;
std::vector<double> _parametersPhi;
std::vector<double> _parametersTurnOn;
std::vector<double> _parametersDxy;

std::map<std::string, MonitorElement *> _elements;
};
Expand Down
8 changes: 7 additions & 1 deletion HLTriggerOffline/Exotica/interface/HLTExoticaSubAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "DataFormats/METReco/interface/CaloMET.h"
#include "DataFormats/METReco/interface/CaloMETCollection.h"
#include "DataFormats/L1Trigger/interface/L1EtMissParticle.h"
#include "DataFormats/BeamSpot/interface/BeamSpot.h"
#include "DataFormats/TauReco/interface/PFTau.h"
#include "DataFormats/TauReco/interface/PFTauFwd.h"
#include "DataFormats/JetReco/interface/PFJet.h"
Expand Down Expand Up @@ -104,7 +105,9 @@ class HLTExoticaSubAnalysis {
/// This function applies the selectors initialized previously to the objects,
/// and matches the passing objects to HLT objects.
void insertCandidates(const unsigned int & objtype, const EVTColContainer * col,
std::vector<reco::LeafCandidate> * matches, std::map<int,double> & theSumEt);
std::vector<reco::LeafCandidate> * matches,
std::map<int,double> & theSumEt,
std::map<int, std::vector<const reco::Track*> > & trkObjs);

/// The internal functions to book and fill histograms
void bookHist(DQMStore::IBooker &iBooker, const std::string & source, const std::string & objType,
Expand Down Expand Up @@ -132,16 +135,19 @@ class HLTExoticaSubAnalysis {
std::string _hltProcessName;
edm::InputTag _genParticleLabel;
edm::InputTag _trigResultsLabel;
edm::InputTag _beamSpotLabel;
std::map<unsigned int, edm::InputTag> _recLabels;
/// And also the tokens to get the object collections
edm::EDGetTokenT<reco::GenParticleCollection> _genParticleToken;
edm::EDGetTokenT<edm::TriggerResults> _trigResultsToken;
edm::EDGetTokenT<reco::BeamSpot> _bsToken;
std::map<unsigned int, edm::EDGetToken> _tokens;

/// Some kinematical parameters
std::vector<double> _parametersEta;
std::vector<double> _parametersPhi;
std::vector<double> _parametersTurnOn;
std::vector<double> _parametersDxy;

/// gen/rec objects cuts
std::map<unsigned int, std::string> _genCut;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ def efficiency_string(objtype,plot_type,triggerpath):
title = "#phi Efficiency"
xAxis = "#phi of Generated %s " % (objtype)
input_type = "gen%sPhi" % (objtype)
if plot_type == "EffDxy":
title = "Dxy Efficiency"
xAxis = "Dxy of Generated %s " % (objtype)
input_type = "gen%sDxy" % (objtype)

yAxis = "%s / %s" % (numer_description, denom_description)
all_titles = "%s for trigger %s; %s; %s" % (title, triggerpath,
Expand All @@ -59,7 +63,7 @@ def add_reco_strings(strings):
strings.extend(reco_strings)


plot_types = ["TurnOn1", "TurnOn2", "TurnOn3", "EffEta", "EffPhi"]
plot_types = ["TurnOn1", "TurnOn2", "TurnOn3", "EffEta", "EffPhi", "EffDxy"]
#--- IMPORTANT: Update this collection whenever you introduce a new object
# in the code (from EVTColContainer::getTypeString)
obj_types = ["Mu","refittedStandAloneMuons","Track","Ele","Photon","PFTau","PFJet","MET","PFMET","PFMHT","GenMET","CaloJet"
Expand Down
4 changes: 4 additions & 0 deletions HLTriggerOffline/Exotica/python/hltExoticaValidator_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@
# -- The instance name of the reco::GenParticles collection
genParticleLabel = cms.string("genParticles"),

# -- The instance name of the reco::BeamSpot collection
beamSpotLabel = cms.string("offlineBeamSpot"),

# -- The binning of the Pt efficiency plots
# NOTICE: these DEFINITELY should be tuned for the different analyses.
# What we have there is a generic, 0-100 GeV uniform binning.
Expand All @@ -89,6 +92,7 @@
# -- (NBins, minVal, maxValue) for the Eta and Phi efficiency plots
parametersEta = cms.vdouble(48, -2.400, 2.400),
parametersPhi = cms.vdouble(50, -3.142, 3.142),
parametersDxy = cms.vdouble(50, -0.015, 0.015),

# Definition of generic cuts on generated and reconstructed objects (note that
# these cuts can be overloaded inside a particular analysis)
Expand Down
5 changes: 4 additions & 1 deletion HLTriggerOffline/Exotica/src/EVTColContainer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ struct EVTColContainer {
const std::vector<reco::PFJet> * pfJets;
const std::vector<reco::CaloJet> * caloJets;
const edm::TriggerResults * triggerResults ;
const reco::BeamSpot * bs;

EVTColContainer():
nOfCollections(6),
Expand All @@ -98,7 +99,8 @@ struct EVTColContainer {
pfTaus(0),
pfJets(0),
caloJets(0),
triggerResults(0)
triggerResults(0),
bs(0)
{
}
///
Expand Down Expand Up @@ -131,6 +133,7 @@ struct EVTColContainer {
pfJets = 0;
caloJets = 0;
triggerResults = 0;
bs = 0;
}

/// Setter: multiple overloaded function
Expand Down
31 changes: 28 additions & 3 deletions HLTriggerOffline/Exotica/src/HLTExoticaPlotter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include "TPRegexp.h"

#include "HLTriggerOffline/Exotica/src/EVTColContainer.cc"

#include<set>
#include<cctype>
Expand All @@ -25,7 +26,8 @@ HLTExoticaPlotter::HLTExoticaPlotter(const edm::ParameterSet & pset,
_nObjects(objectsType.size()),
_parametersEta(pset.getParameter<std::vector<double> >("parametersEta")),
_parametersPhi(pset.getParameter<std::vector<double> >("parametersPhi")),
_parametersTurnOn(pset.getParameter<std::vector<double> >("parametersTurnOn"))
_parametersTurnOn(pset.getParameter<std::vector<double> >("parametersTurnOn")),
_parametersDxy(pset.getParameter<std::vector<double> >("parametersDxy"))
{
LogDebug("ExoticaValidation") << "In HLTExoticaPlotter::constructor()";
}
Expand Down Expand Up @@ -67,6 +69,13 @@ void HLTExoticaPlotter::plotterBookHistos(DQMStore::IBooker & iBooker,
bookHist(iBooker, source, objTypeStr, "MaxPt2");
bookHist(iBooker, source, objTypeStr, "Eta");
bookHist(iBooker, source, objTypeStr, "Phi");

// If the target is electron or muon,
// we will add Dxy plots.
if ( *it == EVTColContainer::ELEC ||
*it == EVTColContainer::MUON ) {
bookHist(iBooker, source, objTypeStr, "Dxy");
}
}
} else { // reco
if ( TString(objTypeStr).Contains("MET") ||
Expand All @@ -78,6 +87,13 @@ void HLTExoticaPlotter::plotterBookHistos(DQMStore::IBooker & iBooker,
bookHist(iBooker, source, objTypeStr, "MaxPt2");
bookHist(iBooker, source, objTypeStr, "Eta");
bookHist(iBooker, source, objTypeStr, "Phi");

// If the target is electron or muon,
// we will add Dxy plots.
if ( *it == EVTColContainer::ELEC ||
*it == EVTColContainer::MUON ) {
bookHist(iBooker, source, objTypeStr, "Dxy");
}
}
}

Expand All @@ -88,7 +104,8 @@ void HLTExoticaPlotter::plotterBookHistos(DQMStore::IBooker & iBooker,
void HLTExoticaPlotter::analyze(const bool & isPassTrigger,
const std::string & source,
const std::vector<reco::LeafCandidate> & matches,
std::map<int,double> theSumEt)
std::map<int,double> theSumEt,
std::vector<float> & dxys)
{
LogDebug("ExoticaValidation") << "In HLTExoticaPlotter::analyze()";
if (!isPassTrigger) {
Expand Down Expand Up @@ -128,6 +145,8 @@ void HLTExoticaPlotter::analyze(const bool & isPassTrigger,
}
}

if ( dxys.size() ) this->fillHist(isPassTrigger, source, objTypeStr, "Dxy", dxys[j] );

if (countobjects[objType] == 0) {
if ( !( TString(objTypeStr).Contains("MET") || TString(objTypeStr).Contains("MHT") ) || source!="gen" ) {
this->fillHist(isPassTrigger, source, objTypeStr, "MaxPt1", pt);
Expand Down Expand Up @@ -175,7 +194,13 @@ void HLTExoticaPlotter::bookHist(DQMStore::IBooker & iBooker,
h = new TH1F(name.c_str(), title.c_str(), nBins, edges);
delete[] edges;
}

else if (variable.find("Dxy") != std::string::npos) {
std::string title = "Dxy " + sourceUpper + " " + objType;
int nBins = _parametersDxy[0];
double min = _parametersDxy[1];
double max = _parametersDxy[2];
h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
}
else if (variable.find("MaxPt") != std::string::npos) {
std::string desc = (variable == "MaxPt1") ? "Leading" : "Next-to-Leading";
std::string title = "pT of " + desc + " " + sourceUpper + " " + objType + " "
Expand Down
71 changes: 67 additions & 4 deletions HLTriggerOffline/Exotica/src/HLTExoticaSubAnalysis.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ HLTExoticaSubAnalysis::HLTExoticaSubAnalysis(const edm::ParameterSet & pset,
_hltProcessName(pset.getParameter<std::string>("hltProcessName")),
_genParticleLabel(pset.getParameter<std::string>("genParticleLabel")),
_trigResultsLabel("TriggerResults", "", _hltProcessName),
_beamSpotLabel(pset.getParameter<std::string>("beamSpotLabel")),
_parametersEta(pset.getParameter<std::vector<double> >("parametersEta")),
_parametersPhi(pset.getParameter<std::vector<double> >("parametersPhi")),
_parametersTurnOn(pset.getParameter<std::vector<double> >("parametersTurnOn")),
_parametersDxy(pset.getParameter<std::vector<double> >("parametersDxy")),
_recMuonSelector(0),
_recMuonTrkSelector(0),
_recTrackSelector(0),
Expand Down Expand Up @@ -208,6 +210,13 @@ void HLTExoticaSubAnalysis::subAnalysisBookHistos(DQMStore::IBooker &iBooker,
bookHist(iBooker, source, objStr, "MaxPt2");
bookHist(iBooker, source, objStr, "Eta");
bookHist(iBooker, source, objStr, "Phi");

// If the target is electron or muon,
// we will add Dxy plots.
if ( it->first == EVTColContainer::ELEC ||
it->first == EVTColContainer::MUON ) {
bookHist(iBooker, source, objStr, "Dxy");
}
}
} else { // reco
if ( TString(objStr).Contains("MET") ||
Expand All @@ -219,6 +228,13 @@ void HLTExoticaSubAnalysis::subAnalysisBookHistos(DQMStore::IBooker &iBooker,
bookHist(iBooker, source, objStr, "MaxPt2");
bookHist(iBooker, source, objStr, "Eta");
bookHist(iBooker, source, objStr, "Phi");

// If the target is electron or muon,
// we will add Dxy plots.
if ( it->first == EVTColContainer::ELEC ||
it->first == EVTColContainer::MUON ) {
bookHist(iBooker, source, objStr, "Dxy");
}
}
}

Expand Down Expand Up @@ -365,6 +381,7 @@ void HLTExoticaSubAnalysis::analyze(const edm::Event & iEvent, const edm::EventS
std::vector<reco::LeafCandidate> matchesGen; matchesGen.clear();
std::vector<reco::LeafCandidate> matchesReco; matchesReco.clear();
std::map<int , double> theSumEt; // map< pdgId ; SumEt > in order to keep track of the MET type
std::map<int, std::vector<const reco::Track*> > trkObjs;

// --- deal with GEN objects first.
// Make each good GEN object into the base cand for a MatchStruct
Expand Down Expand Up @@ -426,7 +443,7 @@ void HLTExoticaSubAnalysis::analyze(const edm::Event & iEvent, const edm::EventS
// before or not) ### Thiago ---> Then why don't we put it in the beginRun???
this->initSelector(it->first);
// -- Storing the matchesReco
this->insertCandidates(it->first, cols, &matchesReco, theSumEt);
this->insertCandidates(it->first, cols, &matchesReco, theSumEt, trkObjs);
if(verbose>0) std::cout << "--- " << EVTColContainer::getTypeString(it->first)
<< " sumEt=" << theSumEt[it->first] << std::endl;
}
Expand Down Expand Up @@ -487,6 +504,8 @@ void HLTExoticaSubAnalysis::analyze(const edm::Event & iEvent, const edm::EventS
break;
}
}

std::vector<float> dxys; dxys.clear();

for (size_t j = 0; ( j != matchesGen.size() ) && isPassedLeadingCut; ++j) {
const unsigned int objType = matchesGen[j].pdgId();
Expand Down Expand Up @@ -522,6 +541,17 @@ void HLTExoticaSubAnalysis::analyze(const edm::Event & iEvent, const edm::EventS
this->fillHist("gen", objTypeStr, "Eta", eta);
this->fillHist("gen", objTypeStr, "Phi", phi);

// If the target is electron or muon,
// we will add Dxy plots.
if ( objType == EVTColContainer::MUON ||
objType == EVTColContainer::ELEC ) {
const math::XYZPoint & vtx = matchesGen[j].vertex();
float momphi = matchesGen[j].momentum().phi();
float dxyGen = (-(vtx.x()-cols->bs->x0())*sin(momphi)+(vtx.y()-cols->bs->y0())*cos(momphi));
dxys.push_back(dxyGen);
this->fillHist("gen", objTypeStr, "Dxy", dxyGen);
}

} // Closes loop in gen

// Calling to the plotters analysis (where the evaluation of the different trigger paths are done)
Expand All @@ -530,7 +560,7 @@ void HLTExoticaSubAnalysis::analyze(const edm::Event & iEvent, const edm::EventS
const std::string hltPath = _shortpath2long[an->gethltpath()];
const bool ispassTrigger = cols->triggerResults->accept(trigNames.triggerIndex(hltPath));
LogDebug("ExoticaValidation") << " preparing to call the plotters analysis";
an->analyze(ispassTrigger, "gen", matchesGen, theSumEt);
an->analyze(ispassTrigger, "gen", matchesGen, theSumEt, dxys);
LogDebug("ExoticaValidation") << " called the plotter";
}
} /// Close GEN case
Expand Down Expand Up @@ -567,6 +597,7 @@ void HLTExoticaSubAnalysis::analyze(const edm::Event & iEvent, const edm::EventS
/// Debugging.
//std::cout << "Our RECO vector has matchesReco.size() = " << matchesReco.size() << std::endl;

std::vector<float> dxys; dxys.clear();

bool isPassedLeadingCut = true;
// We will proceed only when cuts for the pt-leading are satisified.
Expand Down Expand Up @@ -621,6 +652,12 @@ void HLTExoticaSubAnalysis::analyze(const edm::Event & iEvent, const edm::EventS
else {
this->fillHist("rec", objTypeStr, "SumEt", theSumEt[objType]);
}

if (trkObjs[objType].size()>=j+1) {
float dxyRec = trkObjs[objType].at(j)->dxy(cols->bs->position());
this->fillHist("rec", objTypeStr, "Dxy", dxyRec);
dxys.push_back(dxyRec);
}

} // Closes loop in reco

Expand All @@ -633,7 +670,7 @@ void HLTExoticaSubAnalysis::analyze(const edm::Event & iEvent, const edm::EventS
const std::string hltPath = _shortpath2long[an->gethltpath()];
const bool ispassTrigger = cols->triggerResults->accept(trigNames.triggerIndex(hltPath));
LogDebug("ExoticaValidation") << " preparing to call the plotters analysis";
an->analyze(ispassTrigger, "rec", matchesReco, theSumEt);
an->analyze(ispassTrigger, "rec", matchesReco, theSumEt, dxys);
LogDebug("ExoticaValidation") << " called the plotter";
}
} /// Close RECO case
Expand Down Expand Up @@ -763,6 +800,10 @@ void HLTExoticaSubAnalysis::registerConsumes(edm::ConsumesCollector & iC)

// Register that we are getting the trigger results
_trigResultsToken = iC.consumes<edm::TriggerResults>(_trigResultsLabel);

// Register beamspot
_bsToken = iC.consumes<reco::BeamSpot>(_beamSpotLabel);

// Loop over _recLabels, see what we need, and register.
// Then save the registered token in _tokens.
// Remember: _recLabels is a map<uint, edm::InputTag>
Expand Down Expand Up @@ -869,6 +910,13 @@ void HLTExoticaSubAnalysis::getHandlesToObjects(const edm::Event & iEvent, EVTCo
col->genParticles = genPart.product();
LogDebug("ExoticaValidation") << "Added handle to genParticles";
}

// BeamSpot for dxy
edm::Handle<reco::BeamSpot> bsHandle;
iEvent.getByToken(_bsToken, bsHandle);
if (bsHandle.isValid()) {
col->bs = bsHandle.product();
}
}

// Loop over the tokens and extract all other objects
Expand Down Expand Up @@ -975,6 +1023,14 @@ void HLTExoticaSubAnalysis::bookHist(DQMStore::IBooker & iBooker,
delete[] edges;
}

else if (variable.find("Dxy") != std::string::npos) {
std::string title = "Dxy " + sourceUpper + " " + objType;
int nBins = _parametersDxy[0];
double min = _parametersDxy[1];
double max = _parametersDxy[2];
h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
}

else if (variable.find("MaxPt") != std::string::npos) {
std::string desc = (variable == "MaxPt1") ? "Leading" : "Next-to-Leading";
std::string title = "pT of " + desc + " " + sourceUpper + " " + objType;
Expand Down Expand Up @@ -1062,7 +1118,8 @@ void HLTExoticaSubAnalysis::initSelector(const unsigned int & objtype)
}

// Insert the HLT candidates
void HLTExoticaSubAnalysis::insertCandidates(const unsigned int & objType, const EVTColContainer * cols, std::vector<reco::LeafCandidate> * matches, std::map<int,double> & theSumEt)
void HLTExoticaSubAnalysis::insertCandidates(const unsigned int & objType, const EVTColContainer * cols, std::vector<reco::LeafCandidate> * matches,
std::map<int,double> & theSumEt, std::map<int,std::vector<const reco::Track*> > & trkObjs )
{

LogDebug("ExoticaValidation") << "In HLTExoticaSubAnalysis::insertCandidates()";
Expand All @@ -1075,6 +1132,9 @@ void HLTExoticaSubAnalysis::insertCandidates(const unsigned int & objType, const
if (_recMuonSelector->operator()(cols->muons->at(i))) {
reco::LeafCandidate m(0, cols->muons->at(i).p4(), cols->muons->at(i).vertex(), objType, 0, true);
matches->push_back(m);

// for making dxy plots
trkObjs[objType].push_back(cols->muons->at(i).bestTrack());
}
}
} else if (objType == EVTColContainer::MUTRK) {
Expand Down Expand Up @@ -1105,6 +1165,9 @@ void HLTExoticaSubAnalysis::insertCandidates(const unsigned int & objType, const
if (_recElecSelector->operator()(cols->electrons->at(i))) {
reco::LeafCandidate m(0, cols->electrons->at(i).p4(), cols->electrons->at(i).vertex(), objType, 0, true);
matches->push_back(m);

// for making dxy plots
trkObjs[objType].push_back(cols->electrons->at(i).bestTrack());
}
}
} else if (objType == EVTColContainer::PHOTON) {
Expand Down

0 comments on commit 8d9df8c

Please sign in to comment.