CMS 3D CMS Logo

ElectronIsolatorFromEffectiveArea.cc
Go to the documentation of this file.
6 
11 
13 
15 public:
19 
20 private:
21  bool filter(edm::Event&, const edm::EventSetup&) override;
31  static std::map<std::string, EEA::ElectronEffectiveAreaType> EEA_type();
32  static std::map<std::string, EEA::ElectronEffectiveAreaTarget> EEA_target();
33 };
34 
36  : gsfElectronTag(edm::InputTag("")),
37  pfElectronTag(edm::InputTag("")),
38  patElectronTag(edm::InputTag("")),
39  rhoIsoToken(consumes<double>(config.getParameter<edm::InputTag>("rhoIso"))),
40  modeEEA(EEA_type()[config.getParameter<std::string>("EffectiveAreaType")]),
41  targetEEA(EEA_target()[config.getParameter<std::string>("EffectiveAreaTarget")]) {
42  if (config.existsAs<edm::InputTag>("gsfElectrons"))
43  gsfElectronTag = config.getParameter<edm::InputTag>("gsfElectrons");
44  if (config.existsAs<edm::InputTag>("pfElectrons"))
45  pfElectronTag = config.getParameter<edm::InputTag>("pfElectrons");
46  if (config.existsAs<edm::InputTag>("patElectrons"))
47  patElectronTag = config.getParameter<edm::InputTag>("patElectrons");
48  if (!gsfElectronTag.label().empty())
49  gsfElectronToken = consumes<reco::GsfElectronCollection>(gsfElectronTag);
50  if (!pfElectronTag.label().empty())
51  pfElectronToken = consumes<reco::PFCandidateCollection>(pfElectronTag);
52  if (!patElectronTag.label().empty())
53  patElectronToken = consumes<pat::ElectronCollection>(patElectronTag);
54  produces<CandDoubleMap>();
55 }
56 
58  std::unique_ptr<CandDoubleMap> product(new CandDoubleMap());
59  CandDoubleMap::Filler filler(*product);
60 
62  event.getByToken(rhoIsoToken, rho);
63 
64  if (!gsfElectronTag.label().empty()) {
66  event.getByToken(gsfElectronToken, gsfElectrons);
67  std::vector<double> gsfCorrectionsEA;
68  if (gsfElectrons.isValid()) {
69  for (reco::GsfElectronCollection::const_iterator it = gsfElectrons->begin(); it != gsfElectrons->end(); ++it)
70  gsfCorrectionsEA.push_back((*rho) *
71  EEA::GetElectronEffectiveArea(modeEEA, it->superCluster()->eta(), targetEEA));
72  filler.insert(gsfElectrons, gsfCorrectionsEA.begin(), gsfCorrectionsEA.end());
73  }
74  }
75 
76  if (!pfElectronTag.label().empty()) {
78  event.getByToken(pfElectronToken, pfElectrons);
79  std::vector<double> pfCorrectionsEA;
80  if (pfElectrons.isValid()) {
81  for (reco::PFCandidateCollection::const_iterator it = pfElectrons->begin(); it != pfElectrons->end(); ++it)
82  pfCorrectionsEA.push_back(
83  (*rho) * EEA::GetElectronEffectiveArea(modeEEA, it->gsfElectronRef()->superCluster()->eta(), targetEEA));
84  filler.insert(pfElectrons, pfCorrectionsEA.begin(), pfCorrectionsEA.end());
85  }
86  }
87 
88  if (!patElectronTag.label().empty()) {
90  event.getByToken(patElectronToken, patElectrons);
91  std::vector<double> patCorrectionsEA;
92  if (patElectrons.isValid()) {
93  for (pat::ElectronCollection::const_iterator it = patElectrons->begin(); it != patElectrons->end(); ++it)
94  patCorrectionsEA.push_back((*rho) *
95  EEA::GetElectronEffectiveArea(modeEEA, it->superCluster()->eta(), targetEEA));
96  filler.insert(patElectrons, patCorrectionsEA.begin(), patCorrectionsEA.end());
97  }
98  }
99 
100  filler.fill();
101  event.put(std::move(product));
102  return true;
103 }
104 
105 // These maps should really be static const members of interface/ElectronEffectiveArea.h
106 // Here mapping strings to only a subset of the enum
107 std::map<std::string, ElectronEffectiveArea::ElectronEffectiveAreaType> ElectronIsolatorFromEffectiveArea::EEA_type() {
108  std::map<std::string, EEA::ElectronEffectiveAreaType> m;
109  m["kEleGammaAndNeutralHadronIso03"] = EEA::kEleGammaAndNeutralHadronIso03;
110  m["kEleGammaAndNeutralHadronIso04"] = EEA::kEleGammaAndNeutralHadronIso04;
111  return m;
112 }
113 
114 std::map<std::string, ElectronEffectiveArea::ElectronEffectiveAreaTarget>
116  std::map<std::string, EEA::ElectronEffectiveAreaTarget> m;
117  m["kEleEANoCorr"] = EEA::kEleEANoCorr;
118  m["kEleEAData2011"] = EEA::kEleEAData2011;
119  m["kEleEASummer11MC"] = EEA::kEleEASummer11MC;
120  m["kEleEAFall11MC"] = EEA::kEleEAFall11MC;
121  m["kEleEAData2012"] = EEA::kEleEAData2012;
122  return m;
123 }
124 
ElectronEffectiveArea::GetElectronEffectiveArea
static Double_t GetElectronEffectiveArea(ElectronEffectiveAreaType type, Double_t SCEta, ElectronEffectiveAreaTarget EffectiveAreaTarget=kEleEAData2011)
Definition: ElectronEffectiveArea.h:59
ElectronIsolatorFromEffectiveArea::EEA_target
static std::map< std::string, EEA::ElectronEffectiveAreaTarget > EEA_target()
Definition: ElectronIsolatorFromEffectiveArea.cc:115
ElectronIsolatorFromEffectiveArea::pfElectronToken
edm::EDGetTokenT< reco::PFCandidateCollection > pfElectronToken
Definition: ElectronIsolatorFromEffectiveArea.cc:26
ElectronEffectiveArea::kEleGammaAndNeutralHadronIso03
Definition: ElectronEffectiveArea.h:40
PFCandidate.h
edm::EDGetTokenT< reco::GsfElectronCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89281
ElectronIsolatorFromEffectiveArea
Definition: ElectronIsolatorFromEffectiveArea.cc:14
EDFilter.h
ElectronIsolatorFromEffectiveArea::gsfElectronTag
edm::InputTag gsfElectronTag
Definition: ElectronIsolatorFromEffectiveArea.cc:22
electronIsolatorFromEffectiveArea_cfi.gsfElectrons
gsfElectrons
Definition: electronIsolatorFromEffectiveArea_cfi.py:4
edm::Handle< double >
ElectronIsolatorFromEffectiveArea::rhoIsoToken
edm::EDGetTokenT< double > rhoIsoToken
Definition: ElectronIsolatorFromEffectiveArea.cc:28
ElectronEffectiveArea::ElectronEffectiveAreaTarget
ElectronEffectiveAreaTarget
Definition: ElectronEffectiveArea.h:57
config
Definition: config.py:1
edm::InputTag::label
std::string const & label() const
Definition: InputTag.h:36
MakerMacros.h
ElectronIsolatorFromEffectiveArea::EEA_type
static std::map< std::string, EEA::ElectronEffectiveAreaType > EEA_type()
Definition: ElectronIsolatorFromEffectiveArea.cc:107
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
ElectronIsolatorFromEffectiveArea::CandDoubleMap
edm::ValueMap< double > CandDoubleMap
Definition: ElectronIsolatorFromEffectiveArea.cc:16
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
ElectronEffectiveArea::kEleEANoCorr
Definition: ElectronEffectiveArea.h:57
ElectronIsolatorFromEffectiveArea::targetEEA
const EEA::ElectronEffectiveAreaTarget targetEEA
Definition: ElectronIsolatorFromEffectiveArea.cc:30
GsfElectron.h
DDAxes::rho
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:47
ElectronEffectiveArea::kEleGammaAndNeutralHadronIso04
Definition: ElectronEffectiveArea.h:44
Event.h
electronIsolatorFromEffectiveArea_cfi.pfElectrons
pfElectrons
Definition: electronIsolatorFromEffectiveArea_cfi.py:5
ElectronEffectiveArea::kEleEAFall11MC
Definition: ElectronEffectiveArea.h:57
trigObjTnPSource_cfi.filler
filler
Definition: trigObjTnPSource_cfi.py:21
ElectronIsolatorFromEffectiveArea::modeEEA
const EEA::ElectronEffectiveAreaType modeEEA
Definition: ElectronIsolatorFromEffectiveArea.cc:29
ElectronIsolatorFromEffectiveArea::pfElectronTag
edm::InputTag pfElectronTag
Definition: ElectronIsolatorFromEffectiveArea.cc:23
edm::EDFilter
Definition: EDFilter.h:38
edm::EventSetup
Definition: EventSetup.h:58
ElectronEffectiveArea::kEleEASummer11MC
Definition: ElectronEffectiveArea.h:57
ValueMap.h
ElectronIsolatorFromEffectiveArea::patElectronToken
edm::EDGetTokenT< pat::ElectronCollection > patElectronToken
Definition: ElectronIsolatorFromEffectiveArea.cc:27
ElectronEffectiveArea.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
Frameworkfwd.h
edm::ValueMap
Definition: ValueMap.h:107
ElectronIsolatorFromEffectiveArea::filter
bool filter(edm::Event &, const edm::EventSetup &) override
Definition: ElectronIsolatorFromEffectiveArea.cc:57
Electron.h
patElectronEAIsoCorrectionProducer_cfi.patElectrons
patElectrons
Definition: patElectronEAIsoCorrectionProducer_cfi.py:4
ElectronEffectiveArea
Definition: ElectronEffectiveArea.h:25
ElectronIsolatorFromEffectiveArea::ElectronIsolatorFromEffectiveArea
ElectronIsolatorFromEffectiveArea(const edm::ParameterSet &)
Definition: ElectronIsolatorFromEffectiveArea.cc:35
ElectronEffectiveArea::ElectronEffectiveAreaType
ElectronEffectiveAreaType
Definition: ElectronEffectiveArea.h:30
edm::helper::Filler
Definition: ValueMap.h:22
ElectronIsolatorFromEffectiveArea::gsfElectronToken
edm::EDGetTokenT< reco::GsfElectronCollection > gsfElectronToken
Definition: ElectronIsolatorFromEffectiveArea.cc:25
ParameterSet.h
event
Definition: event.py:1
ElectronEffectiveArea::kEleEAData2011
Definition: ElectronEffectiveArea.h:57
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
ElectronIsolatorFromEffectiveArea::patElectronTag
edm::InputTag patElectronTag
Definition: ElectronIsolatorFromEffectiveArea.cc:24
ElectronIsolatorFromEffectiveArea::EEA
ElectronEffectiveArea EEA
Definition: ElectronIsolatorFromEffectiveArea.cc:17
ElectronEffectiveArea::kEleEAData2012
Definition: ElectronEffectiveArea.h:57