CMS 3D CMS Logo

ElectronIsolatorFromEffectiveArea.cc
Go to the documentation of this file.
6 
11 
13 
15 
16  public:
20 
21  private:
22  bool filter(edm::Event&, const edm::EventSetup&) override;
32  static std::map<std::string,EEA::ElectronEffectiveAreaType> EEA_type();
33  static std::map<std::string,EEA::ElectronEffectiveAreaTarget> EEA_target();
34 };
35 
36 
37 
40  : gsfElectronTag( edm::InputTag( "" ) )
41  , pfElectronTag( edm::InputTag( "" ) )
42  , patElectronTag( edm::InputTag( "" ) )
43  , rhoIsoToken( consumes<double>( config.getParameter<edm::InputTag>("rhoIso") ) )
44  , modeEEA( EEA_type()[ config.getParameter<std::string>("EffectiveAreaType") ] )
45  , targetEEA( EEA_target()[ config.getParameter<std::string>("EffectiveAreaTarget") ] )
46 {
47  if ( config.existsAs<edm::InputTag>("gsfElectrons") ) gsfElectronTag = config.getParameter<edm::InputTag>("gsfElectrons");
48  if ( config.existsAs<edm::InputTag>("pfElectrons") ) pfElectronTag = config.getParameter<edm::InputTag>("pfElectrons");
49  if ( config.existsAs<edm::InputTag>("patElectrons") ) patElectronTag = config.getParameter<edm::InputTag>("patElectrons");
50  if ( !gsfElectronTag.label().empty() ) gsfElectronToken = consumes<reco::GsfElectronCollection>( gsfElectronTag );
51  if ( !pfElectronTag.label().empty() ) pfElectronToken = consumes<reco::PFCandidateCollection>( pfElectronTag );
52  if ( !patElectronTag.label().empty() ) patElectronToken = consumes<pat::ElectronCollection>( patElectronTag );
53  produces<CandDoubleMap>();
54 }
55 
56 
57 
60 {
61  std::unique_ptr<CandDoubleMap> product(new CandDoubleMap());
62  CandDoubleMap::Filler filler(*product);
63 
64  edm::Handle<double> rho; event.getByToken(rhoIsoToken, rho);
65 
66  if ( !gsfElectronTag.label().empty() ) {
68  std::vector<double> gsfCorrectionsEA;
69  if(gsfElectrons.isValid()) {
70  for ( reco::GsfElectronCollection::const_iterator it = gsfElectrons->begin(); it != gsfElectrons->end(); ++it)
71  gsfCorrectionsEA.push_back( (*rho) * EEA::GetElectronEffectiveArea( modeEEA, it->superCluster()->eta(), targetEEA ) );
72  filler.insert(gsfElectrons, gsfCorrectionsEA.begin(), gsfCorrectionsEA.end() );
73  }
74  }
75 
76  if ( !pfElectronTag.label().empty() ) {
77  edm::Handle<reco::PFCandidateCollection> pfElectrons; event.getByToken( pfElectronToken, pfElectrons);
78  std::vector<double> pfCorrectionsEA;
79  if(pfElectrons.isValid()) {
80  for ( reco::PFCandidateCollection::const_iterator it = pfElectrons->begin(); it != pfElectrons->end(); ++it)
81  pfCorrectionsEA.push_back( (*rho) * EEA::GetElectronEffectiveArea( modeEEA, it->gsfElectronRef()->superCluster()->eta(), targetEEA ) );
82  filler.insert( pfElectrons, pfCorrectionsEA.begin(), pfCorrectionsEA.end() );
83  }
84  }
85 
86  if ( !patElectronTag.label().empty() ) {
87  edm::Handle<pat::ElectronCollection> patElectrons; event.getByToken( patElectronToken, patElectrons);
88  std::vector<double> patCorrectionsEA;
89  if(patElectrons.isValid()) {
90  for ( pat::ElectronCollection::const_iterator it = patElectrons->begin(); it != patElectrons->end(); ++it)
91  patCorrectionsEA.push_back( (*rho) * EEA::GetElectronEffectiveArea( modeEEA, it->superCluster()->eta(), targetEEA ) );
92  filler.insert( patElectrons, patCorrectionsEA.begin(), patCorrectionsEA.end() );
93  }
94  }
95 
96  filler.fill();
97  event.put(std::move(product));
98  return true;
99 }
100 
101 
102 
103 
104 // These maps should really be static const members of interface/ElectronEffectiveArea.h
105 // Here mapping strings to only a subset of the enum
106 std::map<std::string,ElectronEffectiveArea::ElectronEffectiveAreaType>
108 {
109  std::map<std::string,EEA::ElectronEffectiveAreaType> m;
110  m["kEleGammaAndNeutralHadronIso03"] = EEA::kEleGammaAndNeutralHadronIso03;
111  m["kEleGammaAndNeutralHadronIso04"] = EEA::kEleGammaAndNeutralHadronIso04;
112  return m;
113 }
114 
115 std::map<std::string,ElectronEffectiveArea::ElectronEffectiveAreaTarget>
117 {
118  std::map<std::string,EEA::ElectronEffectiveAreaTarget > m;
119  m["kEleEANoCorr"] = EEA::kEleEANoCorr;
120  m["kEleEAData2011"] = EEA::kEleEAData2011;
121  m["kEleEASummer11MC"] = EEA::kEleEASummer11MC;
122  m["kEleEAFall11MC"] = EEA::kEleEAFall11MC;
123  m["kEleEAData2012"] = EEA::kEleEAData2012;
124  return m;
125 }
126 
T getParameter(std::string const &) const
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:161
static std::map< std::string, EEA::ElectronEffectiveAreaTarget > EEA_target()
static std::map< std::string, EEA::ElectronEffectiveAreaType > EEA_type()
bool filter(edm::Event &, const edm::EventSetup &) override
void insert(const H &h, I begin, I end)
Definition: ValueMap.h:53
static Double_t GetElectronEffectiveArea(ElectronEffectiveAreaType type, Double_t SCEta, ElectronEffectiveAreaTarget EffectiveAreaTarget=kEleEAData2011)
edm::EDGetTokenT< pat::ElectronCollection > patElectronToken
Definition: config.py:1
const EEA::ElectronEffectiveAreaType modeEEA
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
bool isValid() const
Definition: HandleBase.h:74
ElectronIsolatorFromEffectiveArea(const edm::ParameterSet &)
edm::EDGetTokenT< reco::PFCandidateCollection > pfElectronToken
std::string const & label() const
Definition: InputTag.h:36
HLT enums.
const EEA::ElectronEffectiveAreaTarget targetEEA
edm::EDGetTokenT< reco::GsfElectronCollection > gsfElectronToken
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1