test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ElectronIsolatorFromEffectiveArea.cc
Go to the documentation of this file.
6 
11 
13 
15 
16  public:
20 
21  private:
22  virtual bool filter(edm::Event&, const edm::EventSetup&);
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() ) {
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:186
static std::map< std::string, EEA::ElectronEffectiveAreaTarget > EEA_target()
static std::map< std::string, EEA::ElectronEffectiveAreaType > EEA_type()
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void insert(const H &h, I begin, I end)
Definition: ValueMap.h:52
static Double_t GetElectronEffectiveArea(ElectronEffectiveAreaType type, Double_t SCEta, ElectronEffectiveAreaTarget EffectiveAreaTarget=kEleEAData2011)
edm::EDGetTokenT< pat::ElectronCollection > patElectronToken
const EEA::ElectronEffectiveAreaType modeEEA
def move
Definition: eostools.py:510
virtual bool filter(edm::Event &, const edm::EventSetup &)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
bool isValid() const
Definition: HandleBase.h:75
ElectronIsolatorFromEffectiveArea(const edm::ParameterSet &)
edm::EDGetTokenT< reco::PFCandidateCollection > pfElectronToken
std::string const & label() const
Definition: InputTag.h:36
const EEA::ElectronEffectiveAreaTarget targetEEA
edm::EDGetTokenT< reco::GsfElectronCollection > gsfElectronToken