CMS 3D CMS Logo

EgammaHLTElectronTrackIsolationProducers.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: EgammaHLTProducers
4 // Class: EgammaHLTElectronTrackIsolationProducers
5 //
8 //
9 // Original Author: Monica Vazquez Acosta (CERN)
10 //
11 // $Id: EgammaHLTElectronTrackIsolationProducers.h,v 1.3 2011/12/19 11:16:45 sani Exp $
12 //
13 //
14 
15 // system include files
16 #include <memory>
17 
18 // user include files
24 
31 
35 
39 
41 public:
44  void produce(edm::StreamID sid, edm::Event&, const edm::EventSetup&) const override;
45  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
46 
47 private:
52 
53  const bool useGsfTrack_;
54  const bool useSCRefs_;
55 
56  const double egTrkIsoPtMin_;
57  const double egTrkIsoConeSize_;
58  const double egTrkIsoZSpan_;
59  const double egTrkIsoRSpan_;
62  const double egTrkIsoStripBarrel_;
63  const double egTrkIsoStripEndcap_;
64 };
65 
67  : electronProducer_(consumes<reco::ElectronCollection>(config.getParameter<edm::InputTag>("electronProducer"))),
68  trackProducer_(consumes<reco::TrackCollection>(config.getParameter<edm::InputTag>("trackProducer"))),
69  recoEcalCandidateProducer_(
70  consumes<reco::RecoEcalCandidateCollection>(config.getParameter<edm::InputTag>("recoEcalCandidateProducer"))),
71  beamSpotProducer_(consumes<reco::BeamSpot>(config.getParameter<edm::InputTag>("beamSpotProducer"))),
72  useGsfTrack_(config.getParameter<bool>("useGsfTrack")),
73  useSCRefs_(config.getParameter<bool>("useSCRefs")),
74  egTrkIsoPtMin_(config.getParameter<double>("egTrkIsoPtMin")),
75  egTrkIsoConeSize_(config.getParameter<double>("egTrkIsoConeSize")),
76  egTrkIsoZSpan_(config.getParameter<double>("egTrkIsoZSpan")),
77  egTrkIsoRSpan_(config.getParameter<double>("egTrkIsoRSpan")),
78  egTrkIsoVetoConeSizeBarrel_(config.getParameter<double>("egTrkIsoVetoConeSizeBarrel")),
79  egTrkIsoVetoConeSizeEndcap_(config.getParameter<double>("egTrkIsoVetoConeSizeEndcap")),
80  egTrkIsoStripBarrel_(config.getParameter<double>("egTrkIsoStripBarrel")),
81  egTrkIsoStripEndcap_(config.getParameter<double>("egTrkIsoStripEndcap")) {
82  //register your products
83  if (useSCRefs_)
84  produces<reco::RecoEcalCandidateIsolationMap>();
85  else
86  produces<reco::ElectronIsolationMap>();
87 }
88 
90 
93  desc.add<edm::InputTag>("electronProducer", edm::InputTag("hltEleAnyWP80PixelMatchElectronsL1Seeded"));
94  desc.add<edm::InputTag>("trackProducer", edm::InputTag("hltL1SeededEgammaRegionalCTFFinalFitWithMaterial"));
95  desc.add<edm::InputTag>("recoEcalCandidateProducer", edm::InputTag());
96  desc.add<edm::InputTag>("beamSpotProducer", edm::InputTag("hltOnlineBeamSpot"));
97  desc.add<double>("egTrkIsoPtMin", 1.0);
98  desc.add<double>("egTrkIsoConeSize", 0.3);
99  desc.add<double>("egTrkIsoZSpan", 0.15);
100  desc.add<double>("egTrkIsoRSpan", 999999.0);
101  desc.add<double>("egTrkIsoVetoConeSizeBarrel", 0.03);
102  desc.add<double>("egTrkIsoVetoConeSizeEndcap", 0.03);
103  desc.add<double>("egTrkIsoStripBarrel", 0.03);
104  desc.add<double>("egTrkIsoStripEndcap", 0.03);
105  desc.add<bool>("useGsfTrack", false);
106  desc.add<bool>("useSCRefs", false);
107 
108  descriptions.add("hltEgammaHLTElectronTrackIsolationProducers", desc);
109 }
112  const edm::EventSetup&) const {
114  iEvent.getByToken(electronProducer_, electronHandle);
115 
116  // Get the general tracks
118  iEvent.getByToken(trackProducer_, trackHandle);
119  const reco::TrackCollection* trackCollection = trackHandle.product();
120 
121  reco::ElectronIsolationMap eleMap(electronHandle);
122 
123  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
124  iEvent.getByToken(beamSpotProducer_, recoBeamSpotHandle);
125 
126  const reco::BeamSpot::Point& beamSpotPosition = recoBeamSpotHandle->position();
127 
137  beamSpotPosition);
138 
139  if (useSCRefs_) {
141  iEvent.getByToken(recoEcalCandidateProducer_, recoEcalCandHandle);
142  reco::RecoEcalCandidateIsolationMap recoEcalCandMap(recoEcalCandHandle);
143 
144  for (reco::RecoEcalCandidateCollection::const_iterator iRecoEcalCand = recoEcalCandHandle->begin();
145  iRecoEcalCand != recoEcalCandHandle->end();
146  iRecoEcalCand++) {
147  reco::RecoEcalCandidateRef recoEcalCandRef(recoEcalCandHandle, iRecoEcalCand - recoEcalCandHandle->begin());
148 
149  reco::ElectronRef eleRef;
150  for (reco::ElectronCollection::const_iterator eleIt = electronHandle->begin(); eleIt != electronHandle->end();
151  eleIt++) {
152  if (eleIt->superCluster() == recoEcalCandRef->superCluster()) {
153  eleRef = reco::ElectronRef(electronHandle, eleIt - electronHandle->begin());
154  break;
155  }
156  }
157  float isol = 999999;
158  if (eleRef.isNonnull()) {
159  const reco::Track* eleTrk = useGsfTrack_ ? &*eleRef->gsfTrack() : &*eleRef->track();
160  isol = isoAlgo.getIso(eleTrk).second;
161  }
162  recoEcalCandMap.insert(recoEcalCandRef, isol);
163  } //end reco ecal candidate ref
164 
165  iEvent.put(std::make_unique<reco::RecoEcalCandidateIsolationMap>(recoEcalCandMap));
166 
167  } else { //we are going to loop over electron instead
168  for (reco::ElectronCollection::const_iterator iElectron = electronHandle->begin();
169  iElectron != electronHandle->end();
170  iElectron++) {
171  reco::ElectronRef eleRef(reco::ElectronRef(electronHandle, iElectron - electronHandle->begin()));
172  const reco::Track* eleTrk = useGsfTrack_ ? &*eleRef->gsfTrack() : &*eleRef->track();
173  float isol = isoAlgo.getIso(eleTrk).second;
174  eleMap.insert(eleRef, isol);
175  }
176 
177  iEvent.put(std::make_unique<reco::ElectronIsolationMap>(eleMap));
178  }
179 }
180 
const Point & position() const
position
Definition: BeamSpot.h:59
const edm::EDGetTokenT< reco::RecoEcalCandidateCollection > recoEcalCandidateProducer_
T const * product() const
Definition: Handle.h:70
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
math::XYZPoint Point
point in the space
Definition: BeamSpot.h:27
Definition: config.py:1
void produce(edm::StreamID sid, edm::Event &, const edm::EventSetup &) const override
edm::Ref< ElectronCollection > ElectronRef
reference to an object in a collection of Electron objects
Definition: ElectronFwd.h:15
int iEvent
Definition: GenABIO.cc:224
const edm::EDGetTokenT< reco::BeamSpot > beamSpotProducer_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const edm::EDGetTokenT< reco::ElectronCollection > electronProducer_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::vector< Electron > ElectronCollection
collectin of Electron objects
Definition: ElectronFwd.h:9
trackCollection
Definition: JetHT_cfg.py:50
void insert(const key_type &k, const data_type &v)
insert an association
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::vector< RecoEcalCandidate > RecoEcalCandidateCollection
collectin of RecoEcalCandidate objects
fixed size matrix
HLT enums.
std::pair< int, double > getIso(const reco::GsfElectron *) const
const edm::EDGetTokenT< reco::TrackCollection > trackProducer_