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 
11 // Framework
18 
26 
30 
31 
33 
35 {
36 
37  electronProducer_ = config.getParameter<edm::InputTag>("electronProducer");
38  trackProducer_ = config.getParameter<edm::InputTag>("trackProducer");
39  recoEcalCandidateProducer_ = config.getParameter<edm::InputTag>("recoEcalCandidateProducer");
40  beamSpotProducer_ = config.getParameter<edm::InputTag>("beamSpotProducer");
41 
42  useGsfTrack_ = config.getParameter<bool>("useGsfTrack");
43  useSCRefs_ = config.getParameter<bool>("useSCRefs");
44 
45  egTrkIsoPtMin_ = config.getParameter<double>("egTrkIsoPtMin");
46  egTrkIsoConeSize_ = config.getParameter<double>("egTrkIsoConeSize");
47  egTrkIsoZSpan_ = config.getParameter<double>("egTrkIsoZSpan");
48  egTrkIsoRSpan_ = config.getParameter<double>("egTrkIsoRSpan");
49  egTrkIsoVetoConeSizeBarrel_ = config.getParameter<double>("egTrkIsoVetoConeSizeBarrel");
50  egTrkIsoVetoConeSizeEndcap_ = config.getParameter<double>("egTrkIsoVetoConeSizeEndcap");
51  // egCheckForOtherEleInCone_ = config.getUntrackedParameter<bool>("egCheckForOtherEleInCone",false);
52  egTrkIsoStripBarrel_ = config.getParameter<double>("egTrkIsoStripBarrel");
53  egTrkIsoStripEndcap_ = config.getParameter<double>("egTrkIsoStripEndcap");
54 
55 
56 
57 
58  //register your products
59  if(useSCRefs_) produces < reco::RecoEcalCandidateIsolationMap >();
60  else produces < reco::ElectronIsolationMap >();
61 }
62 
63 
65 
66 
67 //
68 // member functions
69 //
70 
71 // ------------ method called to produce the data ------------
72 void
74 {
75 
77  iEvent.getByLabel(electronProducer_,electronHandle);
78 
79 
80  // Get the general tracks
82  iEvent.getByLabel(trackProducer_, trackHandle);
83  const reco::TrackCollection* trackCollection = trackHandle.product();
84 
87 
88  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
89  iEvent.getByLabel(beamSpotProducer_,recoBeamSpotHandle);
90 
91  const reco::BeamSpot::Point& beamSpotPosition = recoBeamSpotHandle->position();
92 
94 
95  if(useSCRefs_){
97  iEvent.getByLabel(recoEcalCandidateProducer_,recoEcalCandHandle);
98  for(reco::RecoEcalCandidateCollection::const_iterator iRecoEcalCand = recoEcalCandHandle->begin(); iRecoEcalCand != recoEcalCandHandle->end(); iRecoEcalCand++){
99 
100  reco::RecoEcalCandidateRef recoEcalCandRef(recoEcalCandHandle,iRecoEcalCand-recoEcalCandHandle->begin());
101 
102  reco::ElectronRef eleRef;
103  for(reco::ElectronCollection::const_iterator eleIt = electronHandle->begin(); eleIt != electronHandle->end(); eleIt++){
104  if(eleIt->superCluster()==recoEcalCandRef->superCluster()){
105  eleRef = reco::ElectronRef(electronHandle,eleIt - electronHandle->begin());
106  break;
107  }
108  }
109  float isol=999999;
110  if(eleRef.isNonnull()){
111  const reco::Track* eleTrk = useGsfTrack_ ? &*eleRef->gsfTrack() : &*eleRef->track();
112  isol = isoAlgo.getIso(eleTrk).second;
113  }
114  recoEcalCandMap.insert(recoEcalCandRef,isol);
115  }//end reco ecal candidate ref
116  }else{ //we are going to loop over electron instead
117  for(reco::ElectronCollection::const_iterator iElectron = electronHandle->begin(); iElectron != electronHandle->end(); iElectron++){
118  reco::ElectronRef eleRef(reco::ElectronRef(electronHandle,iElectron - electronHandle->begin()));
119  const reco::Track* eleTrk = useGsfTrack_ ? &*eleRef->gsfTrack() : &*eleRef->track();
120  float isol = isoAlgo.getIso(eleTrk).second;
121  eleMap.insert(eleRef, isol);
122  }
123  }
124 
125  if(useSCRefs_){
126  std::auto_ptr<reco::RecoEcalCandidateIsolationMap> mapForEvent(new reco::RecoEcalCandidateIsolationMap(recoEcalCandMap));
127  iEvent.put(mapForEvent);
128  }else{
129  std::auto_ptr<reco::ElectronIsolationMap> mapForEvent(new reco::ElectronIsolationMap(eleMap));
130  iEvent.put(mapForEvent);
131  }
132 
133 
134 }
135 
136 //define this as a plug-in
137 //DEFINE_FWK_MODULE(EgammaHLTTrackIsolationProducers);
T getParameter(std::string const &) const
virtual void produce(edm::Event &, const edm::EventSetup &)
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
math::XYZPoint Point
point in the space
Definition: BeamSpot.h:30
edm::Ref< ElectronCollection > ElectronRef
reference to an object in a collection of Electron objects
Definition: ElectronFwd.h:15
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
std::pair< int, double > getIso(const reco::GsfElectron *) const
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
void insert(const key_type &k, const data_type &v)
insert an association
T const * product() const
Definition: Handle.h:74