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