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

Electron ID overhaul #34

Merged
merged 13 commits into from
Jun 6, 2018
2 changes: 1 addition & 1 deletion AnaTools/interface/CMSSWVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#define CMSSW_VERSION_CODE 0

#if CMSSW_VERSION_CODE < CMSSW_VERSION(7,0,0)
#error "Only CMSSW_7_0_0 and higher are supported. If this is already the case, you must run changeDataFormats.py before compiling."
#error "Only CMSSW_7_0_0 and higher are supported. If this is already the case, you must run setupFramework.py before compiling."
#endif

#endif
25 changes: 25 additions & 0 deletions Collections/interface/Electron.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,33 @@ namespace osu
Electron (const TYPE(electrons) &, const edm::Handle<vector<osu::Mcparticle> > &);
Electron (const TYPE(electrons) &, const edm::Handle<vector<osu::Mcparticle> > &, const edm::ParameterSet &);
Electron (const TYPE(electrons) &, const edm::Handle<vector<osu::Mcparticle> > &, const edm::ParameterSet &, const osu::Met &);

const float rho() const;
const float AEff () const;
const double pfdRhoIsoCorr () const;
const double sumChargedHadronPtCorr () const;
const double sumPUPtCorr () const;
const int electronPVIndex () const;
const double genD0 () const;
const float dEtaInSeed () const;
const bool pass_GsfEleHadronicOverEMEnergyScaledCut (const float c0, const float cE, const float cR) const;

const int missingInnerHitsFromAllHits () const;
const int missingInnerHitsFromTrackerLayersWithoutMeasurements () const;
const int missingMiddleHitsFromTrackerLayersWithoutMeasurements () const;
const int missingOuterHitsFromTrackerLayersWithoutMeasurements () const;

const bool passesTightID_noIsolation () const;

const bool passesVID_vetoID () const;
const bool passesVID_looseID () const;
const bool passesVID_mediumID () const;
const bool passesVID_tightID () const;

const bool match_HLT_Ele25_eta2p1_WPTight_Gsf_v () const;
const bool match_HLT_Ele22_eta2p1_WPLoose_Gsf_v () const;
const bool match_HLT_Ele35_WPTight_Gsf_v () const;

void set_rho (float value) { rho_ = value; }
void set_AEff (float value) { AEff_ = value; }
void set_pfdRhoIsoCorr (double value) { pfdRhoIsoCorr_ = value; }
Expand All @@ -39,8 +52,13 @@ namespace osu
void set_electronPVIndex (int value) { electronPVIndex_ = value; };
void set_genD0 (double value) { genD0_ = value; };
void set_passesTightID_noIsolation (const reco::BeamSpot &, const TYPE(primaryvertexs) &, const edm::Handle<vector<reco::Conversion> > &);
void set_passesVID_vetoID (const bool);
void set_passesVID_looseID (const bool);
void set_passesVID_mediumID (const bool);
void set_passesVID_tightID (const bool);
void set_match_HLT_Ele25_eta2p1_WPTight_Gsf_v (const bool);
void set_match_HLT_Ele22_eta2p1_WPLoose_Gsf_v (const bool);
void set_match_HLT_Ele35_WPTight_Gsf_v (const bool);

const double metMinusOnePt () const;
const double metMinusOnePx () const;
Expand Down Expand Up @@ -82,8 +100,15 @@ namespace osu
double sumPUPtCorr_;
double genD0_;
bool passesTightID_noIsolation_;

bool passesVID_vetoID_;
bool passesVID_looseID_;
bool passesVID_mediumID_;
bool passesVID_tightID_;

bool match_HLT_Ele25_eta2p1_WPTight_Gsf_v_;
bool match_HLT_Ele22_eta2p1_WPLoose_Gsf_v_;
bool match_HLT_Ele35_WPTight_Gsf_v_;

double metMinusOnePt_;
double metMinusOnePx_;
Expand Down
75 changes: 51 additions & 24 deletions Collections/plugins/OSUElectronProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,21 @@
#include "OSUT3Analysis/AnaTools/interface/CommonUtils.h"

OSUElectronProducer::OSUElectronProducer (const edm::ParameterSet &cfg) :
collections_ (cfg.getParameter<edm::ParameterSet> ("collections")),
cfg_ (cfg),
pfCandidate_ (cfg.getParameter<edm::InputTag> ("pfCandidate")),
conversions_ (cfg.getParameter<edm::InputTag> ("conversions")),
rho_ (cfg.getParameter<edm::InputTag> ("rho"))
collections_ (cfg.getParameter<edm::ParameterSet> ("collections")),
cfg_ (cfg),
pfCandidate_ (cfg.getParameter<edm::InputTag> ("pfCandidate")),
conversions_ (cfg.getParameter<edm::InputTag> ("conversions")),
rho_ (cfg.getParameter<edm::InputTag> ("rho")),
vidVetoIdMap_ (cfg.getParameter<edm::InputTag> ("vidVetoIdMap")),
vidLooseIdMap_ (cfg.getParameter<edm::InputTag> ("vidLooseIdMap")),
vidMediumIdMap_ (cfg.getParameter<edm::InputTag> ("vidMediumIdMap")),
vidTightIdMap_ (cfg.getParameter<edm::InputTag> ("vidTightIdMap")),
effectiveAreas_ ((cfg.getParameter<edm::FileInPath> ("effAreasPayload")).fullPath())
{
collection_ = collections_.getParameter<edm::InputTag> ("electrons");
produces<vector<osu::Electron> > (collection_.instance ());

token_ = consumes<vector<TYPE(electrons)> > (collection_);
token_ = consumes<edm::View<TYPE(electrons)> > (collection_);
mcparticleToken_ = consumes<vector<osu::Mcparticle> > (collections_.getParameter<edm::InputTag> ("mcparticles"));
prunedParticleToken_ = consumes<vector<reco::GenParticle> > (collections_.getParameter<edm::InputTag> ("hardInteractionMcparticles"));
pfCandidateToken_ = consumes<vector<pat::PackedCandidate>>(pfCandidate_);
Expand All @@ -25,6 +30,11 @@ OSUElectronProducer::OSUElectronProducer (const edm::ParameterSet &cfg) :
rhoToken_ = consumes<double> (rho_);
triggersToken_ = consumes<edm::TriggerResults> (collections_.getParameter<edm::InputTag> ("triggers"));
trigobjsToken_ = consumes<vector<pat::TriggerObjectStandAlone> > (collections_.getParameter<edm::InputTag> ("trigobjs"));

vidVetoIdMapToken_ = consumes<edm::ValueMap<bool> > (vidVetoIdMap_);
vidLooseIdMapToken_ = consumes<edm::ValueMap<bool> > (vidLooseIdMap_);
vidMediumIdMapToken_ = consumes<edm::ValueMap<bool> > (vidMediumIdMap_);
vidTightIdMapToken_ = consumes<edm::ValueMap<bool> > (vidTightIdMap_);
}

OSUElectronProducer::~OSUElectronProducer ()
Expand All @@ -38,7 +48,7 @@ OSUElectronProducer::produce (edm::Event &event, const edm::EventSetup &setup)
using namespace edm;
using namespace reco;

Handle<vector<TYPE(electrons)> > collection;
Handle<edm::View<TYPE(electrons)> > collection;
event.getByToken(token_, collection);

Handle<vector<pat::PackedCandidate> > cands;
Expand Down Expand Up @@ -71,39 +81,56 @@ OSUElectronProducer::produce (edm::Event &event, const edm::EventSetup &setup)
Handle<vector<pat::TriggerObjectStandAlone> > trigobjs;
event.getByToken (trigobjsToken_, trigobjs);

edm::Handle<edm::ValueMap<bool> > vidVetoIdMap;
event.getByToken(vidVetoIdMapToken_, vidVetoIdMap);

edm::Handle<edm::ValueMap<bool> > vidLooseIdMap;
event.getByToken(vidLooseIdMapToken_, vidLooseIdMap);

edm::Handle<edm::ValueMap<bool> > vidMediumIdMap;
event.getByToken(vidMediumIdMapToken_, vidMediumIdMap);

edm::Handle<edm::ValueMap<bool> > vidTightIdMap;
event.getByToken(vidTightIdMapToken_, vidTightIdMap);

pl_ = unique_ptr<vector<osu::Electron> > (new vector<osu::Electron> ());

unsigned iEle = -1;

for (const auto &object : *collection)
{
++iEle;

pl_->emplace_back (object, particles, cfg_, met->at (0));
osu::Electron &electron = pl_->back ();

if(rho.isValid())
electron.set_rho((float)(*rho));

if(beamspot.isValid() && conversions.isValid() && vertices.isValid() && !vertices->empty ())
electron.set_passesTightID_noIsolation (*beamspot, vertices->at (0), conversions);

if(vidVetoIdMap.isValid())
electron.set_passesVID_vetoID ( (*vidVetoIdMap)[(*collection).refAt(iEle)] );

if(vidLooseIdMap.isValid())
electron.set_passesVID_looseID ( (*vidLooseIdMap)[(*collection).refAt(iEle)] );

if(vidMediumIdMap.isValid())
electron.set_passesVID_mediumID ( (*vidMediumIdMap)[(*collection).refAt(iEle)] );

if(vidTightIdMap.isValid())
electron.set_passesVID_tightID ( (*vidTightIdMap)[(*collection).refAt(iEle)] );

if(trigobjs.isValid())
{
electron.set_match_HLT_Ele25_eta2p1_WPTight_Gsf_v (anatools::isMatchedToTriggerObject (event, *triggers, object, *trigobjs, "hltEgammaCandidates::HLT", "hltEle25erWPTightGsfTrackIsoFilter"));
electron.set_match_HLT_Ele22_eta2p1_WPLoose_Gsf_v (anatools::isMatchedToTriggerObject (event, *triggers, object, *trigobjs, "hltEgammaCandidates::HLT", "hltSingleEle22WPLooseGsfTrackIsoFilter"));
electron.set_match_HLT_Ele35_WPTight_Gsf_v (anatools::isMatchedToTriggerObject (event, *triggers, object, *trigobjs, "hltEgammaCandidates::HLT", "hltEle35noerWPTightGsfTrackIsoFilter"));
}

float effectiveArea = 0;
// electron effective areas from https://indico.cern.ch/event/369239/contribution/4/attachments/1134761/1623262/talk_effective_areas_25ns.pdf
// (see slide 12)
if(abs(object.superCluster()->eta()) >= 0.0000 && abs(object.superCluster()->eta()) < 1.0000)
effectiveArea = 0.1752;
if(abs(object.superCluster()->eta()) >= 1.0000 && abs(object.superCluster()->eta()) < 1.4790)
effectiveArea = 0.1862;
if(abs(object.superCluster()->eta()) >= 1.4790 && abs(object.superCluster()->eta()) < 2.0000)
effectiveArea = 0.1411;
if(abs(object.superCluster()->eta()) >= 2.0000 && abs(object.superCluster()->eta()) < 2.2000)
effectiveArea = 0.1534;
if(abs(object.superCluster()->eta()) >= 2.2000 && abs(object.superCluster()->eta()) < 2.3000)
effectiveArea = 0.1903;
if(abs(object.superCluster()->eta()) >= 2.3000 && abs(object.superCluster()->eta()) < 2.4000)
effectiveArea = 0.2243;
if(abs(object.superCluster()->eta()) >= 2.4000 && abs(object.superCluster()->eta()) < 5.0000)
effectiveArea = 0.2687;
effectiveArea = effectiveAreas_.getEffectiveArea(fabs(object.superCluster()->eta()));
electron.set_AEff(effectiveArea);

//generator D0 must be done with prunedGenParticles because vertex is only right in this collection, not right in packedGenParticles
Expand Down Expand Up @@ -184,7 +211,7 @@ OSUElectronProducer::produce (edm::Event &event, const edm::EventSetup &setup)
event.put (std::move (pl_), collection_.instance ());
pl_.reset ();
#else
edm::Handle<vector<TYPE(electrons)> > collection;
edm::Handle<edm::View<TYPE(electrons)> > collection;
if (!event.getByToken (token_, collection))
return;
edm::Handle<vector<osu::Mcparticle> > particles;
Expand Down
12 changes: 11 additions & 1 deletion Collections/plugins/OSUElectronProducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class OSUElectronProducer : public edm::EDProducer
////////////////////////////////////////////////////////////////////////////
edm::ParameterSet collections_;
edm::InputTag collection_;
edm::EDGetTokenT<vector<TYPE(electrons)> > token_;
edm::EDGetTokenT<edm::View<TYPE(electrons)> > token_;
edm::EDGetTokenT<vector<osu::Mcparticle> > mcparticleToken_;
edm::EDGetTokenT<TYPE(beamspots)> beamspotToken_;
edm::EDGetTokenT<vector<reco::GenParticle> > prunedParticleToken_;
Expand All @@ -34,10 +34,20 @@ class OSUElectronProducer : public edm::EDProducer
edm::EDGetTokenT<edm::TriggerResults> triggersToken_;
edm::EDGetTokenT<vector<pat::TriggerObjectStandAlone> > trigobjsToken_;

edm::EDGetTokenT<edm::ValueMap<bool> > vidVetoIdMapToken_;
edm::EDGetTokenT<edm::ValueMap<bool> > vidLooseIdMapToken_;
edm::EDGetTokenT<edm::ValueMap<bool> > vidMediumIdMapToken_;
edm::EDGetTokenT<edm::ValueMap<bool> > vidTightIdMapToken_;

edm::ParameterSet cfg_;
edm::InputTag pfCandidate_;
edm::InputTag conversions_;
edm::InputTag rho_;
edm::InputTag vidVetoIdMap_;
edm::InputTag vidLooseIdMap_;
edm::InputTag vidMediumIdMap_;
edm::InputTag vidTightIdMap_;
EffectiveAreas effectiveAreas_;

////////////////////////////////////////////////////////////////////////////

Expand Down
Loading