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  public:
99 
100 }; // class EcalClusterLazyToolsBase
101 
102 template<class EcalClusterToolsImpl>
104  public:
105 
107  EcalClusterLazyToolsBase(ev,es,token1,token2) {}
108 
110  EcalClusterLazyToolsBase(ev,es,token1,token2,token3) {}
112 
113  // various energies in the matrix nxn surrounding the maximum energy crystal of the input cluster
114  //NOTE (29/10/08): we now use an eta/phi coordinate system rather than phi/eta
115  //to minmise possible screwups, for now e5x1 isnt defined all the majority of people who call it actually want e1x5 and
116  //it is thought it is better that their code doesnt compile rather than pick up the wrong function
117  //therefore in this version and later e1x5 = e5x1 in the old version
118  //so 1x5 is 1 crystal in eta and 5 crystals in phi
119  //note e3x2 does not have a definate eta/phi geometry, it takes the maximum 3x2 block containing the
120  //seed regardless of whether that 3 in eta or phi
121  float e1x3( const reco::BasicCluster &cluster );
122 
123  float e3x1( const reco::BasicCluster &cluster );
124 
125  float e1x5( const reco::BasicCluster &cluster );
126 
127  float e5x1( const reco::BasicCluster &cluster );
128 
129  float e2x2( const reco::BasicCluster &cluster );
130 
131  float e3x2( const reco::BasicCluster &cluster );
132 
133  float e3x3( const reco::BasicCluster &cluster );
134 
135  float e4x4( const reco::BasicCluster &cluster );
136 
137  float e5x5( const reco::BasicCluster &cluster );
138  int n5x5( const reco::BasicCluster &cluster );
139  // energy in the 2x5 strip right of the max crystal (does not contain max crystal)
140  // 2 crystals wide in eta, 5 wide in phi.
141  float e2x5Right( const reco::BasicCluster &cluster );
142  // energy in the 2x5 strip left of the max crystal (does not contain max crystal)
143  float e2x5Left( const reco::BasicCluster &cluster );
144  // energy in the 5x2 strip above the max crystal (does not contain max crystal)
145  // 5 crystals wide in eta, 2 wide in phi.
146  float e2x5Top( const reco::BasicCluster &cluster );
147 
148  // energy in the 5x2 strip below the max crystal (does not contain max crystal)
149  float e2x5Bottom( const reco::BasicCluster &cluster );
150  // energy in a 2x5 strip containing the seed (max) crystal.
151  // 2 crystals wide in eta, 5 wide in phi.
152  // it is the maximum of either (1x5left + 1x5center) or (1x5right + 1x5center)
153  float e2x5Max( const reco::BasicCluster &cluster );
154  // energies in the crystal left, right, top, bottom w.r.t. to the most energetic crystal
155  float eLeft( const reco::BasicCluster &cluster );
156 
157  float eRight( const reco::BasicCluster &cluster );
158 
159  float eTop( const reco::BasicCluster &cluster );
160 
161  float eBottom( const reco::BasicCluster &cluster );
162  // the energy of the most energetic crystal in the cluster
163  float eMax( const reco::BasicCluster &cluster );
164  // the energy of the second most energetic crystal in the cluster
165  float e2nd( const reco::BasicCluster &cluster );
166 
167  // get the DetId and the energy of the maximum energy crystal of the input cluster
168  std::pair<DetId, float> getMaximum( const reco::BasicCluster &cluster );
169 
170  std::vector<float> energyBasketFractionEta( const reco::BasicCluster &cluster );
171 
172  std::vector<float> energyBasketFractionPhi( const reco::BasicCluster &cluster );
173 
174  // return a vector v with v[0] = etaLat, v[1] = phiLat, v[2] = lat
175  std::vector<float> lat( const reco::BasicCluster &cluster, bool logW = true, float w0 = 4.7 );
176 
177  // return a vector v with v[0] = covEtaEta, v[1] = covEtaPhi, v[2] = covPhiPhi
178  std::vector<float> covariances(const reco::BasicCluster &cluster, float w0 = 4.7 );
179 
180  // return a vector v with v[0] = covIEtaIEta, v[1] = covIEtaIPhi, v[2] = covIPhiIPhi
181  //this function calculates differences in eta/phi in units of crystals not global eta/phi
182  //this is gives better performance in the crack regions of the calorimeter but gives otherwise identical results to covariances function
183  //this is only defined for the barrel, it returns covariances when the cluster is in the endcap
184  //Warning: covIEtaIEta has been studied by egamma, but so far covIPhiIPhi hasnt been studied extensively so there could be a bug in
185  // the covIPhiIEta or covIPhiIPhi calculations. I dont think there is but as it hasnt been heavily used, there might be one
186  std::vector<float> localCovariances(const reco::BasicCluster &cluster, float w0 = 4.7);
187 
188  std::vector<float> scLocalCovariances(const reco::SuperCluster &cluster, float w0 = 4.7);
189 
190  double zernike20( const reco::BasicCluster &cluster, double R0 = 6.6, bool logW = true, float w0 = 4.7 );
191  double zernike42( const reco::BasicCluster &cluster, double R0 = 6.6, bool logW = true, float w0 = 4.7 );
192 
193  // get the detId's of a matrix centered in the maximum energy crystal = (0,0)
194  // the size is specified by ixMin, ixMax, iyMin, iyMax in unit of crystals
195  std::vector<DetId> matrixDetId( DetId id, int ixMin, int ixMax, int iyMin, int iyMax );
196  // get the energy deposited in a matrix centered in the maximum energy crystal = (0,0)
197  // the size is specified by ixMin, ixMax, iyMin, iyMax in unit of crystals
198  float matrixEnergy( const reco::BasicCluster &cluster, DetId id, int ixMin, int ixMax, int iyMin, int iyMax );
199 
200 }; // class EcalClusterLazyToolsT
201 
202 template<class EcalClusterToolsImpl>
204 {
205  return EcalClusterToolsImpl::e1x3( cluster, getEcalRecHitCollection(cluster), topology_ );
206 }
207 
208 
209 template<class EcalClusterToolsImpl>
211 {
212  return EcalClusterToolsImpl::e3x1( cluster, getEcalRecHitCollection(cluster), topology_ );
213 }
214 
215 template<class EcalClusterToolsImpl>
217 {
218  return EcalClusterToolsImpl::e1x5( cluster, getEcalRecHitCollection(cluster), topology_ );
219 }
220 
221 
222 template<class EcalClusterToolsImpl>
224 {
225  return EcalClusterToolsImpl::e5x1( cluster, getEcalRecHitCollection(cluster), topology_ );
226 }
227 
228 template<class EcalClusterToolsImpl>
230 {
231  return EcalClusterToolsImpl::e2x2( cluster, getEcalRecHitCollection(cluster), topology_ );
232 }
233 
234 template<class EcalClusterToolsImpl>
236 {
237  return EcalClusterToolsImpl::e3x2( cluster, getEcalRecHitCollection(cluster), topology_ );
238 }
239 
240 template<class EcalClusterToolsImpl>
242 {
243  return EcalClusterToolsImpl::e3x3( cluster, getEcalRecHitCollection(cluster), topology_ );
244 }
245 
246 template<class EcalClusterToolsImpl>
248 {
249  return EcalClusterToolsImpl::e4x4( cluster, getEcalRecHitCollection(cluster), topology_ );
250 }
251 
252 template<class EcalClusterToolsImpl>
254 {
255  return EcalClusterToolsImpl::e5x5( cluster, getEcalRecHitCollection(cluster), topology_ );
256 }
257 
258 template<class EcalClusterToolsImpl>
260 {
261  return EcalClusterToolsImpl::n5x5( cluster, getEcalRecHitCollection(cluster), topology_ );
262 }
263 
264 template<class EcalClusterToolsImpl>
266 {
267  return EcalClusterToolsImpl::e2x5Right( cluster, getEcalRecHitCollection(cluster), topology_ );
268 }
269 
270 template<class EcalClusterToolsImpl>
272 {
273  return EcalClusterToolsImpl::e2x5Left( cluster, getEcalRecHitCollection(cluster), topology_ );
274 }
275 
276 template<class EcalClusterToolsImpl>
278 {
279  return EcalClusterToolsImpl::e2x5Top( cluster, getEcalRecHitCollection(cluster), topology_ );
280 }
281 
282 template<class EcalClusterToolsImpl>
284 {
285  return EcalClusterToolsImpl::e2x5Bottom( cluster, getEcalRecHitCollection(cluster), topology_ );
286 }
287 
288 template<class EcalClusterToolsImpl>
290 {
291  return EcalClusterToolsImpl::e2x5Max( cluster, getEcalRecHitCollection(cluster), topology_ );
292 }
293 
294 template<class EcalClusterToolsImpl>
296 {
297  return EcalClusterToolsImpl::eLeft( cluster, getEcalRecHitCollection(cluster), topology_ );
298 }
299 
300 template<class EcalClusterToolsImpl>
302 {
303  return EcalClusterToolsImpl::eRight( cluster, getEcalRecHitCollection(cluster), topology_ );
304 }
305 
306 template<class EcalClusterToolsImpl>
308 {
309  return EcalClusterToolsImpl::eTop( cluster, getEcalRecHitCollection(cluster), topology_ );
310 }
311 
312 template<class EcalClusterToolsImpl>
314 {
315  return EcalClusterToolsImpl::eBottom( cluster, getEcalRecHitCollection(cluster), topology_ );
316 }
317 
318 template<class EcalClusterToolsImpl>
320 {
321  return EcalClusterToolsImpl::eMax( cluster, getEcalRecHitCollection(cluster) );
322 }
323 
324 template<class EcalClusterToolsImpl>
326 {
327  return EcalClusterToolsImpl::e2nd( cluster, getEcalRecHitCollection(cluster) );
328 }
329 
330 template<class EcalClusterToolsImpl>
332 {
333  return EcalClusterToolsImpl::getMaximum( cluster, getEcalRecHitCollection(cluster) );
334 }
335 
336 template<class EcalClusterToolsImpl>
338 {
339  return EcalClusterToolsImpl::energyBasketFractionEta( cluster, getEcalRecHitCollection(cluster) );
340 }
341 
342 template<class EcalClusterToolsImpl>
344 {
345  return EcalClusterToolsImpl::energyBasketFractionPhi( cluster, getEcalRecHitCollection(cluster) );
346 }
347 
348 template<class EcalClusterToolsImpl>
349 std::vector<float> EcalClusterLazyToolsT<EcalClusterToolsImpl>::lat( const reco::BasicCluster &cluster, bool logW, float w0 )
350 {
351  return EcalClusterToolsImpl::lat( cluster, getEcalRecHitCollection(cluster), geometry_, logW, w0 );
352 }
353 
354 template<class EcalClusterToolsImpl>
356 {
357  return EcalClusterToolsImpl::covariances( cluster, getEcalRecHitCollection(cluster), topology_, geometry_, w0 );
358 }
359 
360 template<class EcalClusterToolsImpl>
362 {
363  return EcalClusterToolsImpl::localCovariances( cluster, getEcalRecHitCollection(cluster), topology_, w0 );
364 }
365 
366 template<class EcalClusterToolsImpl>
368 {
369  return EcalClusterToolsImpl::scLocalCovariances( cluster, getEcalRecHitCollection(cluster), topology_, w0 );
370 }
371 
372 template<class EcalClusterToolsImpl>
373 double EcalClusterLazyToolsT<EcalClusterToolsImpl>::zernike20( const reco::BasicCluster &cluster, double R0, bool logW, float w0 )
374 {
375  return EcalClusterToolsImpl::zernike20( cluster, getEcalRecHitCollection(cluster), geometry_, R0, logW, w0 );
376 }
377 
378 
379 template<class EcalClusterToolsImpl>
380 double EcalClusterLazyToolsT<EcalClusterToolsImpl>::zernike42( const reco::BasicCluster &cluster, double R0, bool logW, float w0 )
381 {
382  return EcalClusterToolsImpl::zernike42( cluster, getEcalRecHitCollection(cluster), geometry_, R0, logW, w0 );
383 }
384 
385 template<class EcalClusterToolsImpl>
386 std::vector<DetId> EcalClusterLazyToolsT<EcalClusterToolsImpl>::matrixDetId( DetId id, int ixMin, int ixMax, int iyMin, int iyMax )
387 {
388  return EcalClusterToolsImpl::matrixDetId( topology_, id, ixMin, ixMax, iyMin, iyMax );
389 }
390 
391 template<class EcalClusterToolsImpl>
392 float EcalClusterLazyToolsT<EcalClusterToolsImpl>::matrixEnergy( const reco::BasicCluster &cluster, DetId id, int ixMin, int ixMax, int iyMin, int iyMax )
393 {
394  return EcalClusterToolsImpl::matrixEnergy( cluster, getEcalRecHitCollection(cluster), topology_, id, ixMin, ixMax, iyMin, iyMax );
395 }
396 
397 namespace noZS {
399 }
401 
402 
403 
404 #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)
const edm::ESHandle< EcalLaserDbService > & getLaserHandle(void)
EcalClusterLazyToolsT<::EcalClusterTools > EcalClusterLazyTools
const EcalRecHitCollection * getEcalESRecHitCollection(void)
float SuperClusterSeedTime(const reco::SuperCluster &cluster)
const EcalRecHitCollection * getEcalEERecHitCollection(void)
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)
const EcalIntercalibConstantMap * icalMap
#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_
const EcalRecHitCollection * getEcalEBRecHitCollection(void)
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)
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)
const EcalIntercalibConstants & getEcalIntercalibConstants(void)
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)