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
21 
24 
27 
30 
32 
36 
38 
40 
42 {
43  // use configuration file to setup input/output collection names
44  //inputs
45  recoEcalCandidateProducer_ = conf_.getParameter<edm::InputTag>("recoEcalCandidateProducer");
46  ecalBarrelRecHitProducer_ = conf_.getParameter<edm::InputTag>("ecalBarrelRecHitProducer");
47  ecalBarrelRecHitCollection_ = conf_.getParameter<edm::InputTag>("ecalBarrelRecHitCollection");
48  ecalEndcapRecHitProducer_ = conf_.getParameter<edm::InputTag>("ecalEndcapRecHitProducer");
49  ecalEndcapRecHitCollection_ = conf_.getParameter<edm::InputTag>("ecalEndcapRecHitCollection");
50  rhoProducer_ = config.getParameter<edm::InputTag>("rhoProducer");
51  doRhoCorrection_ = config.getParameter<bool>("doRhoCorrection");
52  rhoMax_ = config.getParameter<double>("rhoMax");
53  rhoScale_ = config.getParameter<double>("rhoScale");
54 
55  //vetos
56  egIsoPtMinBarrel_ = conf_.getParameter<double>("etMinBarrel");
57  egIsoEMinBarrel_ = conf_.getParameter<double>("eMinBarrel");
58  egIsoPtMinEndcap_ = conf_.getParameter<double>("etMinEndcap");
59  egIsoEMinEndcap_ = conf_.getParameter<double>("eMinEndcap");
60  egIsoConeSizeInBarrel_ = conf_.getParameter<double>("intRadiusBarrel");
61  egIsoConeSizeInEndcap_ = conf_.getParameter<double>("intRadiusEndcap");
62  egIsoConeSizeOut_ = conf_.getParameter<double>("extRadius");
63  egIsoJurassicWidth_ = conf_.getParameter<double>("jurassicWidth");
64  effectiveAreaBarrel_ = config.getParameter<double>("effectiveAreaBarrel");
65  effectiveAreaEndcap_ = config.getParameter<double>("effectiveAreaEndcap");
66 
67  // options
68  useIsolEt_ = conf_.getParameter<bool>("useIsolEt");
69  tryBoth_ = conf_.getParameter<bool>("tryBoth");
70  subtract_ = conf_.getParameter<bool>("subtract");
71  useNumCrystals_ = conf_.getParameter<bool>("useNumCrystals");
72 
73  //register your products
74  produces < reco::RecoEcalCandidateIsolationMap >();
75 }
76 
78 
79 // ------------ method called to produce the data ------------
80 
82 
83  // Get the RecoEcalCandidate Collection
85  iEvent.getByLabel(recoEcalCandidateProducer_,recoecalcandHandle);
86 
87  // Next get Ecal hits barrel
88  edm::Handle<EcalRecHitCollection> ecalBarrelRecHitHandle; //EcalRecHitCollection is a typedef to
90 
91  // Next get Ecal hits endcap
92  edm::Handle<EcalRecHitCollection> ecalEndcapRecHitHandle;
94 
95  //create the meta hit collections inorder that we can pass them into the isolation objects
96 
97  EcalRecHitMetaCollection ecalBarrelHits(*ecalBarrelRecHitHandle);
98  EcalRecHitMetaCollection ecalEndcapHits(*ecalEndcapRecHitHandle);
99 
100  //Get Calo Geometry
102  iSetup.get<CaloGeometryRecord>().get(pG);
103  const CaloGeometry* caloGeom = pG.product();
104 
106  iSetup.get<EcalSeverityLevelAlgoRcd>().get(sevlv);
107  const EcalSeverityLevelAlgo* sevLevel = sevlv.product();
108 
109  edm::Handle<double> rhoHandle;
110  double rho = 0.0;
111  if (doRhoCorrection_) {
112  iEvent.getByLabel(rhoProducer_, rhoHandle);
113  rho = *(rhoHandle.product());
114  }
115 
116  if (rho > rhoMax_)
117  rho = rhoMax_;
118 
119  rho = rho*rhoScale_;
120 
121  //prepare product
123 
124  //create algorithm objects
126  ecalBarrelIsol.setUseNumCrystals(useNumCrystals_);
128  ecalEndcapIsol.setUseNumCrystals(useNumCrystals_);
129 
130  for (reco::RecoEcalCandidateCollection::const_iterator iRecoEcalCand= recoecalcandHandle->begin(); iRecoEcalCand!=recoecalcandHandle->end(); iRecoEcalCand++) {
131 
132  //create reference for storage in isolation map
133  reco::RecoEcalCandidateRef recoecalcandref(reco::RecoEcalCandidateRef(recoecalcandHandle,iRecoEcalCand -recoecalcandHandle ->begin()));
134 
135  //ecal isolation is centered on supecluster
136  reco::SuperClusterRef superClus = iRecoEcalCand->get<reco::SuperClusterRef>();
137 
138  //i need to know if its in the barrel/endcap so I get the supercluster handle to find out the detector eta
139  //this might not be the best way, are we guaranteed that eta<1.5 is barrel
140  //this can be safely replaced by another method which determines where the emobject is
141  //then we either get the isolation Et or isolation Energy depending on user selection
142  float isol =0.;
143 
144  if(tryBoth_){ //barrel + endcap
145  if(useIsolEt_) isol = ecalBarrelIsol.getEtSum(&(*iRecoEcalCand)) + ecalEndcapIsol.getEtSum(&(*iRecoEcalCand));
146  else isol = ecalBarrelIsol.getEnergySum(&(*iRecoEcalCand)) + ecalEndcapIsol.getEnergySum(&(*iRecoEcalCand));
147  }
148  else if( fabs(superClus->eta())<1.479) { //barrel
149  if(useIsolEt_) isol = ecalBarrelIsol.getEtSum(&(*iRecoEcalCand));
150  else isol = ecalBarrelIsol.getEnergySum(&(*iRecoEcalCand));
151  }
152  else{ //endcap
153  if(useIsolEt_) isol = ecalEndcapIsol.getEtSum(&(*iRecoEcalCand));
154  else isol = ecalEndcapIsol.getEnergySum(&(*iRecoEcalCand));
155  }
156 
157  //we subtract off the electron energy here as well
158  double subtractVal=0;
159 
160  if(useIsolEt_) subtractVal = superClus.get()->rawEnergy()*sin(2*atan(exp(-superClus.get()->eta())));
161  else subtractVal = superClus.get()->rawEnergy();
162 
163  if(subtract_) isol-= subtractVal;
164 
165  if (doRhoCorrection_) {
166  if (fabs(superClus->eta()) < 1.442)
167  isol = isol - rho*effectiveAreaBarrel_;
168  else
169  isol = isol - rho*effectiveAreaEndcap_;
170  }
171 
172  isoMap.insert(recoecalcandref, isol);
173  }
174 
175  std::auto_ptr<reco::RecoEcalCandidateIsolationMap> isolMap(new reco::RecoEcalCandidateIsolationMap(isoMap));
176  iEvent.put(isolMap);
177 
178 }
179 
180 
T getParameter(std::string const &) const
virtual void produce(edm::Event &, const edm::EventSetup &)
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
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
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
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
T const * product() const
Definition: Handle.h:74
std::string const & label() const
Definition: InputTag.h:42
#define begin
Definition: vmac.h:31
EgammaHLTEcalRecIsolationProducer(const edm::ParameterSet &)
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:242