CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalClusterLazyTools.h
Go to the documentation of this file.
1 #ifndef RecoEcal_EgammaCoreTools_EcalClusterLazyTools_h
2 #define RecoEcal_EgammaCoreTools_EcalClusterLazyTools_h
3 
18 
20 
28 
29 
30 class CaloTopology;
31 class CaloGeometry;
33 
35  public:
39 
40 
41  // get time of basic cluster seed crystal
42  float BasicClusterSeedTime(const reco::BasicCluster &cluster);
43  // error-weighted average of time from constituents of basic cluster
44  float BasicClusterTime(const reco::BasicCluster &cluster, const edm::Event &ev);
45  // get BasicClusterSeedTime of the seed basic cluser of the supercluster
46  float SuperClusterSeedTime(const reco::SuperCluster &cluster);
47  // get BasicClusterTime of the seed basic cluser of the supercluster
48  float SuperClusterTime(const reco::SuperCluster &cluster, const edm::Event &ev);
49 
50  // mapping for preshower rechits
51  std::map<DetId, EcalRecHit> rechits_map_;
52  // get Preshower hit array
53  std::vector<float> getESHits(double X, double Y, double Z, const std::map<DetId, EcalRecHit>& rechits_map, const CaloGeometry* geometry, CaloSubdetectorTopology *topology_p, int row=0, int plane=1);
54  // get Preshower hit shape
55  float getESShape(const std::vector<float>& ESHits0);
56  // get Preshower effective sigmaRR
57  float eseffsirir( const reco::SuperCluster &cluster );
58  float eseffsixix( const reco::SuperCluster &cluster );
59  float eseffsiyiy( const reco::SuperCluster &cluster );
60 
61  // std::vector<int> flagsexcl_;
62  //std::vector<int> severitiesexcl_;
63  // const EcalSeverityLevelAlgo *sevLv;
64 
65  protected:
66  void getGeometry( const edm::EventSetup &es );
67  void getTopology( const edm::EventSetup &es );
68  void getEBRecHits( const edm::Event &ev );
69  void getEERecHits( const edm::Event &ev );
70  void getESRecHits( const edm::Event &ev );
72 
78 
80 
81  //const EcalIntercalibConstantMap& icalMap;
86  void getIntercalibConstants( const edm::EventSetup &es );
87  void getADCToGeV ( const edm::EventSetup &es );
88  void getLaserDbService ( const edm::EventSetup &es );
89 
90  // std::vector<int> flagsexcl_;
91  // std::vector<int> severitiesexcl_;
92 
93 }; // class EcalClusterLazyToolsBase
94 
95 template<class EcalClusterToolsImpl>
97  public:
98 
100  EcalClusterLazyToolsBase(ev,es,token1,token2) {}
101 
103  EcalClusterLazyToolsBase(ev,es,token1,token2,token3) {}
105 
106  // various energies in the matrix nxn surrounding the maximum energy crystal of the input cluster
107  //NOTE (29/10/08): we now use an eta/phi coordinate system rather than phi/eta
108  //to minmise possible screwups, for now e5x1 isnt defined all the majority of people who call it actually want e1x5 and
109  //it is thought it is better that their code doesnt compile rather than pick up the wrong function
110  //therefore in this version and later e1x5 = e5x1 in the old version
111  //so 1x5 is 1 crystal in eta and 5 crystals in phi
112  //note e3x2 does not have a definate eta/phi geometry, it takes the maximum 3x2 block containing the
113  //seed regardless of whether that 3 in eta or phi
114  float e1x3( const reco::BasicCluster &cluster );
115 
116  float e3x1( const reco::BasicCluster &cluster );
117 
118  float e1x5( const reco::BasicCluster &cluster );
119 
120  float e5x1( const reco::BasicCluster &cluster );
121 
122  float e2x2( const reco::BasicCluster &cluster );
123 
124  float e3x2( const reco::BasicCluster &cluster );
125 
126  float e3x3( const reco::BasicCluster &cluster );
127 
128  float e4x4( const reco::BasicCluster &cluster );
129 
130  float e5x5( const reco::BasicCluster &cluster );
131  int n5x5( const reco::BasicCluster &cluster );
132  // energy in the 2x5 strip right of the max crystal (does not contain max crystal)
133  // 2 crystals wide in eta, 5 wide in phi.
134  float e2x5Right( const reco::BasicCluster &cluster );
135  // energy in the 2x5 strip left of the max crystal (does not contain max crystal)
136  float e2x5Left( const reco::BasicCluster &cluster );
137  // energy in the 5x2 strip above the max crystal (does not contain max crystal)
138  // 5 crystals wide in eta, 2 wide in phi.
139  float e2x5Top( const reco::BasicCluster &cluster );
140 
141  // energy in the 5x2 strip below the max crystal (does not contain max crystal)
142  float e2x5Bottom( const reco::BasicCluster &cluster );
143  // energy in a 2x5 strip containing the seed (max) crystal.
144  // 2 crystals wide in eta, 5 wide in phi.
145  // it is the maximum of either (1x5left + 1x5center) or (1x5right + 1x5center)
146  float e2x5Max( const reco::BasicCluster &cluster );
147  // energies in the crystal left, right, top, bottom w.r.t. to the most energetic crystal
148  float eLeft( const reco::BasicCluster &cluster );
149 
150  float eRight( const reco::BasicCluster &cluster );
151 
152  float eTop( const reco::BasicCluster &cluster );
153 
154  float eBottom( const reco::BasicCluster &cluster );
155  // the energy of the most energetic crystal in the cluster
156  float eMax( const reco::BasicCluster &cluster );
157  // the energy of the second most energetic crystal in the cluster
158  float e2nd( const reco::BasicCluster &cluster );
159 
160  // get the DetId and the energy of the maximum energy crystal of the input cluster
161  std::pair<DetId, float> getMaximum( const reco::BasicCluster &cluster );
162 
163  std::vector<float> energyBasketFractionEta( const reco::BasicCluster &cluster );
164 
165  std::vector<float> energyBasketFractionPhi( const reco::BasicCluster &cluster );
166 
167  // return a vector v with v[0] = etaLat, v[1] = phiLat, v[2] = lat
168  std::vector<float> lat( const reco::BasicCluster &cluster, bool logW = true, float w0 = 4.7 );
169 
170  // return a vector v with v[0] = covEtaEta, v[1] = covEtaPhi, v[2] = covPhiPhi
171  std::vector<float> covariances(const reco::BasicCluster &cluster, float w0 = 4.7 );
172 
173  // return a vector v with v[0] = covIEtaIEta, v[1] = covIEtaIPhi, v[2] = covIPhiIPhi
174  //this function calculates differences in eta/phi in units of crystals not global eta/phi
175  //this is gives better performance in the crack regions of the calorimeter but gives otherwise identical results to covariances function
176  //this is only defined for the barrel, it returns covariances when the cluster is in the endcap
177  //Warning: covIEtaIEta has been studied by egamma, but so far covIPhiIPhi hasnt been studied extensively so there could be a bug in
178  // the covIPhiIEta or covIPhiIPhi calculations. I dont think there is but as it hasnt been heavily used, there might be one
179  std::vector<float> localCovariances(const reco::BasicCluster &cluster, float w0 = 4.7);
180 
181  std::vector<float> scLocalCovariances(const reco::SuperCluster &cluster, float w0 = 4.7);
182 
183  double zernike20( const reco::BasicCluster &cluster, double R0 = 6.6, bool logW = true, float w0 = 4.7 );
184  double zernike42( const reco::BasicCluster &cluster, double R0 = 6.6, bool logW = true, float w0 = 4.7 );
185 
186  // get the detId's of a matrix centered in the maximum energy crystal = (0,0)
187  // the size is specified by ixMin, ixMax, iyMin, iyMax in unit of crystals
188  std::vector<DetId> matrixDetId( DetId id, int ixMin, int ixMax, int iyMin, int iyMax );
189  // get the energy deposited in a matrix centered in the maximum energy crystal = (0,0)
190  // the size is specified by ixMin, ixMax, iyMin, iyMax in unit of crystals
191  float matrixEnergy( const reco::BasicCluster &cluster, DetId id, int ixMin, int ixMax, int iyMin, int iyMax );
192 
193 }; // class EcalClusterLazyToolsT
194 
195 template<class EcalClusterToolsImpl>
197 {
198  return EcalClusterToolsImpl::e1x3( cluster, getEcalRecHitCollection(cluster), topology_ );
199 }
200 
201 
202 template<class EcalClusterToolsImpl>
204 {
205  return EcalClusterToolsImpl::e3x1( cluster, getEcalRecHitCollection(cluster), topology_ );
206 }
207 
208 template<class EcalClusterToolsImpl>
210 {
211  return EcalClusterToolsImpl::e1x5( cluster, getEcalRecHitCollection(cluster), topology_ );
212 }
213 
214 
215 template<class EcalClusterToolsImpl>
217 {
218  return EcalClusterToolsImpl::e5x1( cluster, getEcalRecHitCollection(cluster), topology_ );
219 }
220 
221 template<class EcalClusterToolsImpl>
223 {
224  return EcalClusterToolsImpl::e2x2( cluster, getEcalRecHitCollection(cluster), topology_ );
225 }
226 
227 template<class EcalClusterToolsImpl>
229 {
230  return EcalClusterToolsImpl::e3x2( cluster, getEcalRecHitCollection(cluster), topology_ );
231 }
232 
233 template<class EcalClusterToolsImpl>
235 {
236  return EcalClusterToolsImpl::e3x3( cluster, getEcalRecHitCollection(cluster), topology_ );
237 }
238 
239 template<class EcalClusterToolsImpl>
241 {
242  return EcalClusterToolsImpl::e4x4( cluster, getEcalRecHitCollection(cluster), topology_ );
243 }
244 
245 template<class EcalClusterToolsImpl>
247 {
248  return EcalClusterToolsImpl::e5x5( cluster, getEcalRecHitCollection(cluster), topology_ );
249 }
250 
251 template<class EcalClusterToolsImpl>
253 {
254  return EcalClusterToolsImpl::n5x5( cluster, getEcalRecHitCollection(cluster), topology_ );
255 }
256 
257 template<class EcalClusterToolsImpl>
259 {
260  return EcalClusterToolsImpl::e2x5Right( cluster, getEcalRecHitCollection(cluster), topology_ );
261 }
262 
263 template<class EcalClusterToolsImpl>
265 {
266  return EcalClusterToolsImpl::e2x5Left( cluster, getEcalRecHitCollection(cluster), topology_ );
267 }
268 
269 template<class EcalClusterToolsImpl>
271 {
272  return EcalClusterToolsImpl::e2x5Top( cluster, getEcalRecHitCollection(cluster), topology_ );
273 }
274 
275 template<class EcalClusterToolsImpl>
277 {
278  return EcalClusterToolsImpl::e2x5Bottom( cluster, getEcalRecHitCollection(cluster), topology_ );
279 }
280 
281 template<class EcalClusterToolsImpl>
283 {
284  return EcalClusterToolsImpl::e2x5Max( cluster, getEcalRecHitCollection(cluster), topology_ );
285 }
286 
287 template<class EcalClusterToolsImpl>
289 {
290  return EcalClusterToolsImpl::eLeft( cluster, getEcalRecHitCollection(cluster), topology_ );
291 }
292 
293 template<class EcalClusterToolsImpl>
295 {
296  return EcalClusterToolsImpl::eRight( cluster, getEcalRecHitCollection(cluster), topology_ );
297 }
298 
299 template<class EcalClusterToolsImpl>
301 {
302  return EcalClusterToolsImpl::eTop( cluster, getEcalRecHitCollection(cluster), topology_ );
303 }
304 
305 template<class EcalClusterToolsImpl>
307 {
308  return EcalClusterToolsImpl::eBottom( cluster, getEcalRecHitCollection(cluster), topology_ );
309 }
310 
311 template<class EcalClusterToolsImpl>
313 {
314  return EcalClusterToolsImpl::eMax( cluster, getEcalRecHitCollection(cluster) );
315 }
316 
317 template<class EcalClusterToolsImpl>
319 {
320  return EcalClusterToolsImpl::e2nd( cluster, getEcalRecHitCollection(cluster) );
321 }
322 
323 template<class EcalClusterToolsImpl>
325 {
326  return EcalClusterToolsImpl::getMaximum( cluster, getEcalRecHitCollection(cluster) );
327 }
328 
329 template<class EcalClusterToolsImpl>
331 {
332  return EcalClusterToolsImpl::energyBasketFractionEta( cluster, getEcalRecHitCollection(cluster) );
333 }
334 
335 template<class EcalClusterToolsImpl>
337 {
338  return EcalClusterToolsImpl::energyBasketFractionPhi( cluster, getEcalRecHitCollection(cluster) );
339 }
340 
341 template<class EcalClusterToolsImpl>
342 std::vector<float> EcalClusterLazyToolsT<EcalClusterToolsImpl>::lat( const reco::BasicCluster &cluster, bool logW, float w0 )
343 {
344  return EcalClusterToolsImpl::lat( cluster, getEcalRecHitCollection(cluster), geometry_, logW, w0 );
345 }
346 
347 template<class EcalClusterToolsImpl>
349 {
350  return EcalClusterToolsImpl::covariances( cluster, getEcalRecHitCollection(cluster), topology_, geometry_, w0 );
351 }
352 
353 template<class EcalClusterToolsImpl>
355 {
356  return EcalClusterToolsImpl::localCovariances( cluster, getEcalRecHitCollection(cluster), topology_, w0 );
357 }
358 
359 template<class EcalClusterToolsImpl>
361 {
362  return EcalClusterToolsImpl::scLocalCovariances( cluster, getEcalRecHitCollection(cluster), topology_, w0 );
363 }
364 
365 template<class EcalClusterToolsImpl>
366 double EcalClusterLazyToolsT<EcalClusterToolsImpl>::zernike20( const reco::BasicCluster &cluster, double R0, bool logW, float w0 )
367 {
368  return EcalClusterToolsImpl::zernike20( cluster, getEcalRecHitCollection(cluster), geometry_, R0, logW, w0 );
369 }
370 
371 
372 template<class EcalClusterToolsImpl>
373 double EcalClusterLazyToolsT<EcalClusterToolsImpl>::zernike42( const reco::BasicCluster &cluster, double R0, bool logW, float w0 )
374 {
375  return EcalClusterToolsImpl::zernike42( cluster, getEcalRecHitCollection(cluster), geometry_, R0, logW, w0 );
376 }
377 
378 template<class EcalClusterToolsImpl>
379 std::vector<DetId> EcalClusterLazyToolsT<EcalClusterToolsImpl>::matrixDetId( DetId id, int ixMin, int ixMax, int iyMin, int iyMax )
380 {
381  return EcalClusterToolsImpl::matrixDetId( topology_, id, ixMin, ixMax, iyMin, iyMax );
382 }
383 
384 template<class EcalClusterToolsImpl>
385 float EcalClusterLazyToolsT<EcalClusterToolsImpl>::matrixEnergy( const reco::BasicCluster &cluster, DetId id, int ixMin, int ixMax, int iyMin, int iyMax )
386 {
387  return EcalClusterToolsImpl::matrixEnergy( cluster, getEcalRecHitCollection(cluster), topology_, id, ixMin, ixMax, iyMin, iyMax );
388 }
389 
390 namespace noZS {
392 }
394 
395 
396 
397 #endif
const double Z[kNumberCalorimeter]
edm::ESHandle< EcalIntercalibConstants > ical
const CaloGeometry * geometry_
const EcalRecHitCollection * esRecHits_
edm::EDGetTokenT< EcalRecHitCollection > eeRHToken_
float e5x5(const reco::BasicCluster &cluster)
EcalClusterLazyToolsT<::EcalClusterTools > EcalClusterLazyTools
float SuperClusterSeedTime(const reco::SuperCluster &cluster)
std::vector< float > energyBasketFractionEta(const reco::BasicCluster &cluster)
float e2x5Bottom(const reco::BasicCluster &cluster)
float BasicClusterTime(const reco::BasicCluster &cluster, const edm::Event &ev)
float e3x2(const reco::BasicCluster &cluster)
float e2x5Left(const reco::BasicCluster &cluster)
float SuperClusterTime(const reco::SuperCluster &cluster, const edm::Event &ev)
float e2nd(const reco::BasicCluster &cluster)
float e2x2(const reco::BasicCluster &cluster)
const EcalRecHitCollection * getEcalRecHitCollection(const reco::BasicCluster &cluster)
float getESShape(const std::vector< float > &ESHits0)
#define X(str)
Definition: MuonsGrabber.cc:48
void getADCToGeV(const edm::EventSetup &es)
bool ev
const EcalRecHitCollection * ebRecHits_
float eseffsixix(const reco::SuperCluster &cluster)
std::vector< float > energyBasketFractionPhi(const reco::BasicCluster &cluster)
float e3x3(const reco::BasicCluster &cluster)
EcalClusterLazyToolsT< noZS::EcalClusterTools > EcalClusterLazyTools
void getIntercalibConstants(const edm::EventSetup &es)
edm::ESHandle< EcalADCToGeVConstant > agc
float e2x5Right(const reco::BasicCluster &cluster)
std::vector< float > getESHits(double X, double Y, double Z, const std::map< DetId, EcalRecHit > &rechits_map, const CaloGeometry *geometry, CaloSubdetectorTopology *topology_p, int row=0, int plane=1)
float eLeft(const reco::BasicCluster &cluster)
float matrixEnergy(const reco::BasicCluster &cluster, DetId id, int ixMin, int ixMax, int iyMin, int iyMax)
EcalClusterLazyToolsBase(const edm::Event &ev, const edm::EventSetup &es, edm::EDGetTokenT< EcalRecHitCollection > token1, edm::EDGetTokenT< EcalRecHitCollection > token2)
float e2x5Max(const reco::BasicCluster &cluster)
float e3x1(const reco::BasicCluster &cluster)
void getESRecHits(const edm::Event &ev)
float e4x4(const reco::BasicCluster &cluster)
edm::EDGetTokenT< EcalRecHitCollection > esRHToken_
float e5x1(const reco::BasicCluster &cluster)
float e1x3(const reco::BasicCluster &cluster)
double zernike42(const reco::BasicCluster &cluster, double R0=6.6, bool logW=true, float w0=4.7)
Definition: DetId.h:18
float eseffsiyiy(const reco::SuperCluster &cluster)
std::vector< float > covariances(const reco::BasicCluster &cluster, float w0=4.7)
float eBottom(const reco::BasicCluster &cluster)
void getTopology(const edm::EventSetup &es)
EcalIntercalibConstantMap icalMap
std::vector< float > localCovariances(const reco::BasicCluster &cluster, float w0=4.7)
EcalClusterLazyToolsT(const edm::Event &ev, const edm::EventSetup &es, edm::EDGetTokenT< EcalRecHitCollection > token1, edm::EDGetTokenT< EcalRecHitCollection > token2, edm::EDGetTokenT< EcalRecHitCollection > token3)
void getEBRecHits(const edm::Event &ev)
edm::EDGetTokenT< EcalRecHitCollection > ebRHToken_
std::vector< float > lat(const reco::BasicCluster &cluster, bool logW=true, float w0=4.7)
float eMax(const reco::BasicCluster &cluster)
double zernike20(const reco::BasicCluster &cluster, double R0=6.6, bool logW=true, float w0=4.7)
std::vector< float > scLocalCovariances(const reco::SuperCluster &cluster, float w0=4.7)
ESHandle< TrackerGeometry > geometry
float e1x5(const reco::BasicCluster &cluster)
void getLaserDbService(const edm::EventSetup &es)
float e2x5Top(const reco::BasicCluster &cluster)
const EcalRecHitCollection * eeRecHits_
void getGeometry(const edm::EventSetup &es)
int n5x5(const reco::BasicCluster &cluster)
std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster)
void getEERecHits(const edm::Event &ev)
std::map< DetId, EcalRecHit > rechits_map_
edm::ESHandle< EcalLaserDbService > laser
float BasicClusterSeedTime(const reco::BasicCluster &cluster)
std::vector< DetId > matrixDetId(DetId id, int ixMin, int ixMax, int iyMin, int iyMax)
const CaloTopology * topology_
float eRight(const reco::BasicCluster &cluster)
EcalClusterLazyToolsT(const edm::Event &ev, const edm::EventSetup &es, edm::EDGetTokenT< EcalRecHitCollection > token1, edm::EDGetTokenT< EcalRecHitCollection > token2)
float eTop(const reco::BasicCluster &cluster)
float eseffsirir(const reco::SuperCluster &cluster)