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 
RecoEcalCandidateIsolation.h
ConfigurationDescriptions.h
edm::StreamID
Definition: StreamID.h:30
reco::RecoEcalCandidateCollection
std::vector< RecoEcalCandidate > RecoEcalCandidateCollection
collectin of RecoEcalCandidate objects
Definition: RecoEcalCandidateFwd.h:9
electrons_cff.bool
bool
Definition: electrons_cff.py:366
edm::Handle::product
T const * product() const
Definition: Handle.h:70
align::BeamSpot
Definition: StructureType.h:95
edm::EDGetTokenT< reco::ElectronCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89285
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
EgammaHLTElectronTrackIsolationProducers::egTrkIsoPtMin_
const double egTrkIsoPtMin_
Definition: EgammaHLTElectronTrackIsolationProducers.cc:56
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::Handle
Definition: AssociativeIterator.h:50
reco::ElectronRef
edm::Ref< ElectronCollection > ElectronRef
reference to an object in a collection of Electron objects
Definition: ElectronFwd.h:15
EgammaHLTElectronTrackIsolationProducers::egTrkIsoVetoConeSizeBarrel_
const double egTrkIsoVetoConeSizeBarrel_
Definition: EgammaHLTElectronTrackIsolationProducers.cc:60
edm::Ref
Definition: AssociativeIterator.h:58
EgammaHLTElectronTrackIsolationProducers::egTrkIsoStripEndcap_
const double egTrkIsoStripEndcap_
Definition: EgammaHLTElectronTrackIsolationProducers.cc:63
config
Definition: config.py:1
MakerMacros.h
TrackingRecHit.h
Track.h
TrackFwd.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
EgammaHLTElectronTrackIsolationProducers::beamSpotProducer_
const edm::EDGetTokenT< reco::BeamSpot > beamSpotProducer_
Definition: EgammaHLTElectronTrackIsolationProducers.cc:51
reco::Track
Definition: Track.h:27
reco::BeamSpot::position
const Point & position() const
position
Definition: BeamSpot.h:59
EgammaHLTElectronTrackIsolationProducers::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: EgammaHLTElectronTrackIsolationProducers.cc:91
ParameterSetDescription.h
ElectronTkIsolation
Definition: ElectronTkIsolation.h:19
edm::global::EDProducer
Definition: EDProducer.h:32
EgammaHLTElectronTrackIsolationProducers::trackProducer_
const edm::EDGetTokenT< reco::TrackCollection > trackProducer_
Definition: EgammaHLTElectronTrackIsolationProducers.cc:49
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
EgammaHLTElectronTrackIsolationProducers::egTrkIsoVetoConeSizeEndcap_
const double egTrkIsoVetoConeSizeEndcap_
Definition: EgammaHLTElectronTrackIsolationProducers.cc:61
ElectronFwd.h
edm::ParameterSet
Definition: ParameterSet.h:47
duplicaterechits_cfi.trackCollection
trackCollection
Definition: duplicaterechits_cfi.py:4
Event.h
edm::AssociationMap
Definition: AssociationMap.h:48
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:58
ElectronTkIsolation::getIso
std::pair< int, double > getIso(const reco::GsfElectron *) const
Definition: ElectronTkIsolation.cc:41
reco::ElectronCollection
std::vector< Electron > ElectronCollection
collectin of Electron objects
Definition: ElectronFwd.h:9
edm::AssociationMap::insert
void insert(const key_type &k, const data_type &v)
insert an association
Definition: AssociationMap.h:166
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
Electron.h
RecoEcalCandidate.h
EgammaHLTElectronTrackIsolationProducers::useSCRefs_
const bool useSCRefs_
Definition: EgammaHLTElectronTrackIsolationProducers.cc:54
EgammaHLTElectronTrackIsolationProducers
Definition: EgammaHLTElectronTrackIsolationProducers.cc:40
EgammaHLTElectronTrackIsolationProducers::electronProducer_
const edm::EDGetTokenT< reco::ElectronCollection > electronProducer_
Definition: EgammaHLTElectronTrackIsolationProducers.cc:48
Frameworkfwd.h
EgammaHLTElectronTrackIsolationProducers::egTrkIsoConeSize_
const double egTrkIsoConeSize_
Definition: EgammaHLTElectronTrackIsolationProducers.cc:57
EgammaHLTElectronTrackIsolationProducers::egTrkIsoStripBarrel_
const double egTrkIsoStripBarrel_
Definition: EgammaHLTElectronTrackIsolationProducers.cc:62
EgammaHLTElectronTrackIsolationProducers::~EgammaHLTElectronTrackIsolationProducers
~EgammaHLTElectronTrackIsolationProducers() override
Definition: EgammaHLTElectronTrackIsolationProducers.cc:89
EgammaHLTElectronTrackIsolationProducers::produce
void produce(edm::StreamID sid, edm::Event &, const edm::EventSetup &) const override
Definition: EgammaHLTElectronTrackIsolationProducers.cc:110
ElectronIsolationAssociation.h
EgammaHLTElectronTrackIsolationProducers::useGsfTrack_
const bool useGsfTrack_
Definition: EgammaHLTElectronTrackIsolationProducers.cc:53
RecoEcalCandidateFwd.h
reco::BeamSpot::Point
math::XYZPoint Point
point in the space
Definition: BeamSpot.h:27
EgammaHLTElectronTrackIsolationProducers::egTrkIsoZSpan_
const double egTrkIsoZSpan_
Definition: EgammaHLTElectronTrackIsolationProducers.cc:58
ParameterSet.h
EDProducer.h
ElectronTkIsolation.h
edm::Event
Definition: Event.h:73
EgammaHLTElectronTrackIsolationProducers::recoEcalCandidateProducer_
const edm::EDGetTokenT< reco::RecoEcalCandidateCollection > recoEcalCandidateProducer_
Definition: EgammaHLTElectronTrackIsolationProducers.cc:50
edm::InputTag
Definition: InputTag.h:15
reco::TrackCollection
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
EgammaHLTElectronTrackIsolationProducers::egTrkIsoRSpan_
const double egTrkIsoRSpan_
Definition: EgammaHLTElectronTrackIsolationProducers.cc:59
EgammaHLTElectronTrackIsolationProducers::EgammaHLTElectronTrackIsolationProducers
EgammaHLTElectronTrackIsolationProducers(const edm::ParameterSet &)
Definition: EgammaHLTElectronTrackIsolationProducers.cc:66