CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EgammaHLTElectronTrackIsolationProducers.cc
Go to the documentation of this file.
1 
10 
14 
18 
20  electronProducer_ (consumes<reco::ElectronCollection>(config.getParameter<edm::InputTag>("electronProducer"))),
21  trackProducer_ (consumes<reco::TrackCollection>(config.getParameter<edm::InputTag>("trackProducer"))),
22  recoEcalCandidateProducer_ (consumes<reco::RecoEcalCandidateCollection>(config.getParameter<edm::InputTag>("recoEcalCandidateProducer"))),
23  beamSpotProducer_ (consumes<reco::BeamSpot>(config.getParameter<edm::InputTag>("beamSpotProducer"))),
24  useGsfTrack_ (config.getParameter<bool>("useGsfTrack")),
25  useSCRefs_ (config.getParameter<bool>("useSCRefs")),
26  egTrkIsoPtMin_ (config.getParameter<double>("egTrkIsoPtMin")),
27  egTrkIsoConeSize_ (config.getParameter<double>("egTrkIsoConeSize")),
28  egTrkIsoZSpan_ (config.getParameter<double>("egTrkIsoZSpan")),
29  egTrkIsoRSpan_ (config.getParameter<double>("egTrkIsoRSpan")),
30  egTrkIsoVetoConeSizeBarrel_ (config.getParameter<double>("egTrkIsoVetoConeSizeBarrel")),
31  egTrkIsoVetoConeSizeEndcap_ (config.getParameter<double>("egTrkIsoVetoConeSizeEndcap")),
32  egTrkIsoStripBarrel_ (config.getParameter<double>("egTrkIsoStripBarrel")),
33  egTrkIsoStripEndcap_ (config.getParameter<double>("egTrkIsoStripEndcap")) {
34 
35  //register your products
36  if(useSCRefs_)
37  produces < reco::RecoEcalCandidateIsolationMap >();
38  else
39  produces < reco::ElectronIsolationMap >();
40 }
41 
43 {}
44 
47  desc.add<edm::InputTag>("electronProducer", edm::InputTag("hltEleAnyWP80PixelMatchElectronsL1Seeded"));
48  desc.add<edm::InputTag>("trackProducer", edm::InputTag("hltL1SeededEgammaRegionalCTFFinalFitWithMaterial"));
49  desc.add<edm::InputTag>("recoEcalCandidateProducer", edm::InputTag());
50  desc.add<edm::InputTag>("beamSpotProducer", edm::InputTag("hltOnlineBeamSpot"));
51  desc.add<double>("egTrkIsoPtMin", 1.0);
52  desc.add<double>("egTrkIsoConeSize", 0.3);
53  desc.add<double>("egTrkIsoZSpan", 0.15);
54  desc.add<double>("egTrkIsoRSpan", 999999.0);
55  desc.add<double>("egTrkIsoVetoConeSizeBarrel", 0.03);
56  desc.add<double>("egTrkIsoVetoConeSizeEndcap", 0.03);
57  desc.add<double>("egTrkIsoStripBarrel", 0.03);
58  desc.add<double>("egTrkIsoStripEndcap", 0.03);
59  desc.add<bool>("useGsfTrack", false);
60  desc.add<bool>("useSCRefs", false);
61 
62  descriptions.add("hltEgammaHLTElectronTrackIsolationProducers", desc);
63 }
65 
67  iEvent.getByToken(electronProducer_,electronHandle);
68 
69  // Get the general tracks
71  iEvent.getByToken(trackProducer_, trackHandle);
72  const reco::TrackCollection* trackCollection = trackHandle.product();
73 
74  reco::ElectronIsolationMap eleMap(electronHandle);
75 
76  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
77  iEvent.getByToken(beamSpotProducer_,recoBeamSpotHandle);
78 
79  const reco::BeamSpot::Point& beamSpotPosition = recoBeamSpotHandle->position();
80 
82 
83  if(useSCRefs_){
84 
86  iEvent.getByToken(recoEcalCandidateProducer_,recoEcalCandHandle);
87  reco::RecoEcalCandidateIsolationMap recoEcalCandMap(recoEcalCandHandle);
88 
89  for(reco::RecoEcalCandidateCollection::const_iterator iRecoEcalCand = recoEcalCandHandle->begin(); iRecoEcalCand != recoEcalCandHandle->end(); iRecoEcalCand++){
90 
91  reco::RecoEcalCandidateRef recoEcalCandRef(recoEcalCandHandle,iRecoEcalCand-recoEcalCandHandle->begin());
92 
93  reco::ElectronRef eleRef;
94  for(reco::ElectronCollection::const_iterator eleIt = electronHandle->begin(); eleIt != electronHandle->end(); eleIt++){
95  if(eleIt->superCluster()==recoEcalCandRef->superCluster()){
96  eleRef = reco::ElectronRef(electronHandle,eleIt - electronHandle->begin());
97  break;
98  }
99  }
100  float isol=999999;
101  if(eleRef.isNonnull()){
102  const reco::Track* eleTrk = useGsfTrack_ ? &*eleRef->gsfTrack() : &*eleRef->track();
103  isol = isoAlgo.getIso(eleTrk).second;
104  }
105  recoEcalCandMap.insert(recoEcalCandRef,isol);
106  }//end reco ecal candidate ref
107 
108  std::auto_ptr<reco::RecoEcalCandidateIsolationMap> mapForEvent(new reco::RecoEcalCandidateIsolationMap(recoEcalCandMap));
109  iEvent.put(mapForEvent);
110 
111  }else{ //we are going to loop over electron instead
112  for(reco::ElectronCollection::const_iterator iElectron = electronHandle->begin(); iElectron != electronHandle->end(); iElectron++){
113  reco::ElectronRef eleRef(reco::ElectronRef(electronHandle,iElectron - electronHandle->begin()));
114  const reco::Track* eleTrk = useGsfTrack_ ? &*eleRef->gsfTrack() : &*eleRef->track();
115  float isol = isoAlgo.getIso(eleTrk).second;
116  eleMap.insert(eleRef, isol);
117  }
118 
119  std::auto_ptr<reco::ElectronIsolationMap> mapForEvent(new reco::ElectronIsolationMap(eleMap));
120  iEvent.put(mapForEvent);
121  }
122 }
123 
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
const edm::EDGetTokenT< reco::RecoEcalCandidateCollection > recoEcalCandidateProducer_
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
math::XYZPoint Point
point in the space
Definition: BeamSpot.h:29
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:230
const edm::EDGetTokenT< reco::BeamSpot > beamSpotProducer_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const edm::EDGetTokenT< reco::ElectronCollection > electronProducer_
std::pair< int, double > getIso(const reco::GsfElectron *) const
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::vector< Electron > ElectronCollection
collectin of Electron objects
Definition: ElectronFwd.h:9
T const * product() const
Definition: Handle.h:81
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
const edm::EDGetTokenT< reco::TrackCollection > trackProducer_