CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EgammaHLTEcalRecIsolationProducer.cc
Go to the documentation of this file.
1 
2 //*****************************************************************************
3 // File: EgammaHLTEcalRecIsolationProducer.cc
4 // ----------------------------------------------------------------------------
5 // OrigAuth: Matthias Mozer , adapted from EgammaHcalIsolationProducer by S. Harper
6 // Institute: IIHE-VUB
7 //=============================================================================
8 //*****************************************************************************
9 
10 
12 
13 
14 // Framework
15 //#include "FWCore/Framework/interface/ESHandle.h"
16 //#include "FWCore/MessageLogger/interface/MessageLogger.h"
17 //#include "FWCore/Utilities/interface/Exception.h"
19 
21 //nclude "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
22 
26 
30 
32  // use configuration file to setup input/output collection names
33  //inputs
34  recoEcalCandidateProducer_ = consumes<reco::RecoEcalCandidateCollection>(conf_.getParameter<edm::InputTag>("recoEcalCandidateProducer"));
35  ecalBarrelRecHitProducer_ = consumes<EcalRecHitCollection>(conf_.getParameter<edm::InputTag>("ecalBarrelRecHitProducer"));
36  ecalEndcapRecHitProducer_ = consumes<EcalRecHitCollection>(conf_.getParameter<edm::InputTag>("ecalEndcapRecHitProducer"));
37  rhoProducer_ = consumes<double>(config.getParameter<edm::InputTag>("rhoProducer"));
38 
39  doRhoCorrection_ = config.getParameter<bool>("doRhoCorrection");
40  rhoMax_ = config.getParameter<double>("rhoMax");
41  rhoScale_ = config.getParameter<double>("rhoScale");
42 
43  //vetos
44  egIsoPtMinBarrel_ = conf_.getParameter<double>("etMinBarrel");
45  egIsoEMinBarrel_ = conf_.getParameter<double>("eMinBarrel");
46  egIsoPtMinEndcap_ = conf_.getParameter<double>("etMinEndcap");
47  egIsoEMinEndcap_ = conf_.getParameter<double>("eMinEndcap");
48  egIsoConeSizeInBarrel_ = conf_.getParameter<double>("intRadiusBarrel");
49  egIsoConeSizeInEndcap_ = conf_.getParameter<double>("intRadiusEndcap");
50  egIsoConeSizeOut_ = conf_.getParameter<double>("extRadius");
51  egIsoJurassicWidth_ = conf_.getParameter<double>("jurassicWidth");
52  effectiveAreaBarrel_ = config.getParameter<double>("effectiveAreaBarrel");
53  effectiveAreaEndcap_ = config.getParameter<double>("effectiveAreaEndcap");
54 
55  // options
56  useIsolEt_ = conf_.getParameter<bool>("useIsolEt");
57  tryBoth_ = conf_.getParameter<bool>("tryBoth");
58  subtract_ = conf_.getParameter<bool>("subtract");
59  useNumCrystals_ = conf_.getParameter<bool>("useNumCrystals");
60 
61  //register your products
62  produces < reco::RecoEcalCandidateIsolationMap >();
63 }
64 
66 {}
67 
69 
71  desc.add<edm::InputTag>("recoEcalCandidateProducer", edm::InputTag("hltL1SeededRecoEcalCandidate"));
72  desc.add<edm::InputTag>("ecalBarrelRecHitProducer", edm::InputTag("hltEcalRegionalEgammaRecHit", "EcalRecHitsEB"));
73  desc.add<edm::InputTag>("ecalEndcapRecHitProducer", edm::InputTag("hltEcalRegionalEgammaRecHit", "EcalRecHitsEE"));
74  desc.add<edm::InputTag>("rhoProducer", edm::InputTag("fixedGridRhoFastjetAllCalo"));
75  desc.add<bool>("doRhoCorrection", false);
76  desc.add<double>("rhoMax", 9.9999999E7);
77  desc.add<double>("rhoScale", 1.0);
78  desc.add<double>("etMinBarrel", -9999.0);
79  desc.add<double>("eMinBarrel", 0.095);
80  desc.add<double>("etMinEndcap", 0.11);
81  desc.add<double>("eMinEndcap", -9999.0);
82  desc.add<double>("intRadiusBarrel", 3.0);
83  desc.add<double>("intRadiusEndcap", 3.0);
84  desc.add<double>("extRadius", 0.3);
85  desc.add<double>("jurassicWidth", 3.0);
86  desc.add<double>("effectiveAreaBarrel", 0.101);
87  desc.add<double>("effectiveAreaEndcap", 0.046);
88  desc.add<bool>("useIsolEt", true);
89  desc.add<bool>("tryBoth", true);
90  desc.add<bool>("subtract", false);
91  desc.add<bool>("useNumCrystals", true);
92 
93  descriptions.add(("hltEgammaHLTEcalRecIsolationProducer"), desc);
94 }
95 
97 
98  // Get the RecoEcalCandidate Collection
100  iEvent.getByToken(recoEcalCandidateProducer_,recoecalcandHandle);
101 
102  // Next get Ecal hits barrel
103  edm::Handle<EcalRecHitCollection> ecalBarrelRecHitHandle; //EcalRecHitCollection is a typedef to
104  iEvent.getByToken(ecalBarrelRecHitProducer_, ecalBarrelRecHitHandle);
105 
106  // Next get Ecal hits endcap
107  edm::Handle<EcalRecHitCollection> ecalEndcapRecHitHandle;
108  iEvent.getByToken(ecalEndcapRecHitProducer_, ecalEndcapRecHitHandle);
109 
110  //create the meta hit collections inorder that we can pass them into the isolation objects
111 
112  EcalRecHitMetaCollection ecalBarrelHits(*ecalBarrelRecHitHandle);
113  EcalRecHitMetaCollection ecalEndcapHits(*ecalEndcapRecHitHandle);
114 
115  //Get Calo Geometry
117  iSetup.get<CaloGeometryRecord>().get(pG);
118  const CaloGeometry* caloGeom = pG.product();
119 
121  iSetup.get<EcalSeverityLevelAlgoRcd>().get(sevlv);
122  const EcalSeverityLevelAlgo* sevLevel = sevlv.product();
123 
124  edm::Handle<double> rhoHandle;
125  double rho = 0.0;
126  if (doRhoCorrection_) {
127  iEvent.getByToken(rhoProducer_, rhoHandle);
128  rho = *(rhoHandle.product());
129  }
130 
131  if (rho > rhoMax_)
132  rho = rhoMax_;
133 
134  rho = rho*rhoScale_;
135 
136  //prepare product
138 
139  //create algorithm objects
141  ecalBarrelIsol.setUseNumCrystals(useNumCrystals_);
143  ecalEndcapIsol.setUseNumCrystals(useNumCrystals_);
144 
145  for (reco::RecoEcalCandidateCollection::const_iterator iRecoEcalCand= recoecalcandHandle->begin(); iRecoEcalCand!=recoecalcandHandle->end(); iRecoEcalCand++) {
146 
147  //create reference for storage in isolation map
148  reco::RecoEcalCandidateRef recoecalcandref(reco::RecoEcalCandidateRef(recoecalcandHandle,iRecoEcalCand -recoecalcandHandle ->begin()));
149 
150  //ecal isolation is centered on supecluster
151  reco::SuperClusterRef superClus = iRecoEcalCand->get<reco::SuperClusterRef>();
152 
153  //i need to know if its in the barrel/endcap so I get the supercluster handle to find out the detector eta
154  //this might not be the best way, are we guaranteed that eta<1.5 is barrel
155  //this can be safely replaced by another method which determines where the emobject is
156  //then we either get the isolation Et or isolation Energy depending on user selection
157  float isol =0.;
158 
159  if(tryBoth_){ //barrel + endcap
160  if(useIsolEt_) isol = ecalBarrelIsol.getEtSum(&(*iRecoEcalCand)) + ecalEndcapIsol.getEtSum(&(*iRecoEcalCand));
161  else isol = ecalBarrelIsol.getEnergySum(&(*iRecoEcalCand)) + ecalEndcapIsol.getEnergySum(&(*iRecoEcalCand));
162  }
163  else if( fabs(superClus->eta())<1.479) { //barrel
164  if(useIsolEt_) isol = ecalBarrelIsol.getEtSum(&(*iRecoEcalCand));
165  else isol = ecalBarrelIsol.getEnergySum(&(*iRecoEcalCand));
166  }
167  else{ //endcap
168  if(useIsolEt_) isol = ecalEndcapIsol.getEtSum(&(*iRecoEcalCand));
169  else isol = ecalEndcapIsol.getEnergySum(&(*iRecoEcalCand));
170  }
171 
172  //we subtract off the electron energy here as well
173  double subtractVal=0;
174 
175  if(useIsolEt_) subtractVal = superClus.get()->rawEnergy()*sin(2*atan(exp(-superClus.get()->eta())));
176  else subtractVal = superClus.get()->rawEnergy();
177 
178  if(subtract_) isol-= subtractVal;
179 
180  if (doRhoCorrection_) {
181  if (fabs(superClus->eta()) < 1.442)
182  isol = isol - rho*effectiveAreaBarrel_;
183  else
184  isol = isol - rho*effectiveAreaEndcap_;
185  }
186 
187  isoMap.insert(recoecalcandref, isol);
188  }
189 
190  std::auto_ptr<reco::RecoEcalCandidateIsolationMap> isolMap(new reco::RecoEcalCandidateIsolationMap(isoMap));
191  iEvent.put(isolMap);
192 
193 }
194 
195 
T getParameter(std::string const &) const
virtual void produce(edm::Event &, const edm::EventSetup &)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
double getEtSum(const reco::Candidate *emObject) const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Definition: DDAxes.h:10
double getEnergySum(const reco::Candidate *emObject) const
void setUseNumCrystals(bool b=true)
int iEvent
Definition: GenABIO.cc:243
edm::EDGetTokenT< EcalRecHitCollection > ecalEndcapRecHitProducer_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void insert(const key_type &k, const data_type &v)
insert an association
const T & get() const
Definition: EventSetup.h:55
edm::EDGetTokenT< reco::RecoEcalCandidateCollection > recoEcalCandidateProducer_
T const * product() const
Definition: ESHandle.h:62
void add(std::string const &label, ParameterSetDescription const &psetDescription)
T const * product() const
Definition: Handle.h:81
#define begin
Definition: vmac.h:30
EgammaHLTEcalRecIsolationProducer(const edm::ParameterSet &)
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:242
edm::EDGetTokenT< EcalRecHitCollection > ecalBarrelRecHitProducer_