Imperial Analysis
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ICElectronHcalDepthCalculator.cc
Go to the documentation of this file.
2 #include <vector>
3 #include "FWCore/Framework/interface/Event.h"
4 #include "FWCore/Framework/interface/EventSetup.h"
5 #include "FWCore/Framework/interface/MakerMacros.h"
6 #include "FWCore/ParameterSet/interface/ParameterSet.h"
7 #include "FWCore/Utilities/interface/InputTag.h"
8 #include "DataFormats/Common/interface/Handle.h"
9 #include "DataFormats/Common/interface/ValueMap.h"
10 
11 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
12 #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
13 #include "DataFormats/CaloTowers/interface/CaloTower.h"
14 #include "DataFormats/CaloTowers/interface/CaloTowerFwd.h"
15 #include "RecoEgamma/EgammaIsolationAlgos/interface/EgammaTowerIsolation.h"
17 
19  const edm::ParameterSet& config)
20  : input_(config.getParameter<edm::InputTag>("input")) {
21  consumes<reco::GsfElectronCollection>(input_);
22  consumes<CaloTowerCollection>({"towerMaker"});
23  produces<edm::ValueMap<float> >();
24 }
25 
27 
28 void ICElectronHcalDepthCalculator::produce(edm::Event& event,
29  const edm::EventSetup& setup) {
30  std::auto_ptr<edm::ValueMap<float> > product(new edm::ValueMap<float>());
31  edm::Handle<reco::GsfElectronCollection> elecs_handle;
32  event.getByLabel(input_, elecs_handle);
33 
34  edm::Handle<CaloTowerCollection> tower_handle;
35  event.getByLabel("towerMaker", tower_handle);
36  EgammaTowerIsolation had_depth1_iso03(0.3, 0.0, 0.0, 1,
37  tower_handle.product());
38  EgammaTowerIsolation had_depth2_iso03(0.3, 0.0, 0.0, 2,
39  tower_handle.product());
40 
41  std::vector<float> values(elecs_handle->size(), 0.);
42  for (unsigned i = 0; i < elecs_handle->size(); ++i) {
43  reco::GsfElectron const& src = elecs_handle->at(i);
44  float had_depth1_sum_et_03 = had_depth1_iso03.getTowerEtSum(&src);
45  float had_depth2_sum_et_03 = had_depth2_iso03.getTowerEtSum(&src);
46  values[i] = had_depth1_sum_et_03 + had_depth2_sum_et_03;
47  }
48 
49  edm::ValueMap<float>::Filler filler(*product);
50  filler.insert(elecs_handle, values.begin(), values.end());
51  filler.fill();
52 
53  event.put(product);
54 }
55 
56 void ICElectronHcalDepthCalculator::beginJob() {}
57 
58 void ICElectronHcalDepthCalculator::endJob() {}
59 
60 // define this as a plug-in
ICElectronHcalDepthCalculator(const edm::ParameterSet &)
Produces an edm::ValueMap for the electron HCAL energy depth sum.
Definition: Consumes.h:19
DEFINE_FWK_MODULE(ICElectronHcalDepthCalculator)