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  // energy in the 2x5 strip right of the max crystal (does not contain max crystal)
132  // 2 crystals wide in eta, 5 wide in phi.
133  float e2x5Right( const reco::BasicCluster &cluster );
134  // energy in the 2x5 strip left of the max crystal (does not contain max crystal)
135  float e2x5Left( const reco::BasicCluster &cluster );
136  // energy in the 5x2 strip above the max crystal (does not contain max crystal)
137  // 5 crystals wide in eta, 2 wide in phi.
138  float e2x5Top( const reco::BasicCluster &cluster );
139 
140  // energy in the 5x2 strip below the max crystal (does not contain max crystal)
141  float e2x5Bottom( const reco::BasicCluster &cluster );
142  // energy in a 2x5 strip containing the seed (max) crystal.
143  // 2 crystals wide in eta, 5 wide in phi.
144  // it is the maximum of either (1x5left + 1x5center) or (1x5right + 1x5center)
145  float e2x5Max( const reco::BasicCluster &cluster );
146  // energies in the crystal left, right, top, bottom w.r.t. to the most energetic crystal
147  float eLeft( const reco::BasicCluster &cluster );
148 
149  float eRight( const reco::BasicCluster &cluster );
150 
151  float eTop( const reco::BasicCluster &cluster );
152 
153  float eBottom( const reco::BasicCluster &cluster );
154  // the energy of the most energetic crystal in the cluster
155  float eMax( const reco::BasicCluster &cluster );
156  // the energy of the second most energetic crystal in the cluster
157  float e2nd( const reco::BasicCluster &cluster );
158 
159  // get the DetId and the energy of the maximum energy crystal of the input cluster
160  std::pair<DetId, float> getMaximum( const reco::BasicCluster &cluster );
161 
162  std::vector<float> energyBasketFractionEta( const reco::BasicCluster &cluster );
163 
164  std::vector<float> energyBasketFractionPhi( const reco::BasicCluster &cluster );
165 
166  // return a vector v with v[0] = etaLat, v[1] = phiLat, v[2] = lat
167  std::vector<float> lat( const reco::BasicCluster &cluster, bool logW = true, float w0 = 4.7 );
168 
169  // return a vector v with v[0] = covEtaEta, v[1] = covEtaPhi, v[2] = covPhiPhi
170  std::vector<float> covariances(const reco::BasicCluster &cluster, float w0 = 4.7 );
171 
172  // return a vector v with v[0] = covIEtaIEta, v[1] = covIEtaIPhi, v[2] = covIPhiIPhi
173  //this function calculates differences in eta/phi in units of crystals not global eta/phi
174  //this is gives better performance in the crack regions of the calorimeter but gives otherwise identical results to covariances function
175  //this is only defined for the barrel, it returns covariances when the cluster is in the endcap
176  //Warning: covIEtaIEta has been studied by egamma, but so far covIPhiIPhi hasnt been studied extensively so there could be a bug in
177  // the covIPhiIEta or covIPhiIPhi calculations. I dont think there is but as it hasnt been heavily used, there might be one
178  std::vector<float> localCovariances(const reco::BasicCluster &cluster, float w0 = 4.7);
179 
180  std::vector<float> scLocalCovariances(const reco::SuperCluster &cluster, float w0 = 4.7);
181 
182  double zernike20( const reco::BasicCluster &cluster, double R0 = 6.6, bool logW = true, float w0 = 4.7 );
183  double zernike42( const reco::BasicCluster &cluster, double R0 = 6.6, bool logW = true, float w0 = 4.7 );
184 
185  // get the detId's of a matrix centered in the maximum energy crystal = (0,0)
186  // the size is specified by ixMin, ixMax, iyMin, iyMax in unit of crystals
187  std::vector<DetId> matrixDetId( DetId id, int ixMin, int ixMax, int iyMin, int iyMax );
188  // get the energy deposited in a matrix centered in the maximum energy crystal = (0,0)
189  // the size is specified by ixMin, ixMax, iyMin, iyMax in unit of crystals
190  float matrixEnergy( const reco::BasicCluster &cluster, DetId id, int ixMin, int ixMax, int iyMin, int iyMax );
191 
192 }; // class EcalClusterLazyToolsT
193 
194 template<class EcalClusterToolsImpl>
196 {
197  return EcalClusterToolsImpl::e1x3( cluster, getEcalRecHitCollection(cluster), topology_ );
198 }
199 
200 
201 template<class EcalClusterToolsImpl>
203 {
204  return EcalClusterToolsImpl::e3x1( cluster, getEcalRecHitCollection(cluster), topology_ );
205 }
206 
207 template<class EcalClusterToolsImpl>
209 {
210  return EcalClusterToolsImpl::e1x5( cluster, getEcalRecHitCollection(cluster), topology_ );
211 }
212 
213 
214 template<class EcalClusterToolsImpl>
216 {
217  return EcalClusterToolsImpl::e5x1( cluster, getEcalRecHitCollection(cluster), topology_ );
218 }
219 
220 template<class EcalClusterToolsImpl>
222 {
223  return EcalClusterToolsImpl::e2x2( cluster, getEcalRecHitCollection(cluster), topology_ );
224 }
225 
226 template<class EcalClusterToolsImpl>
228 {
229  return EcalClusterToolsImpl::e3x2( cluster, getEcalRecHitCollection(cluster), topology_ );
230 }
231 
232 template<class EcalClusterToolsImpl>
234 {
235  return EcalClusterToolsImpl::e3x3( cluster, getEcalRecHitCollection(cluster), topology_ );
236 }
237 
238 template<class EcalClusterToolsImpl>
240 {
241  return EcalClusterToolsImpl::e4x4( cluster, getEcalRecHitCollection(cluster), topology_ );
242 }
243 
244 template<class EcalClusterToolsImpl>
246 {
247  return EcalClusterToolsImpl::e5x5( cluster, getEcalRecHitCollection(cluster), topology_ );
248 }
249 
250 template<class EcalClusterToolsImpl>
252 {
253  return EcalClusterToolsImpl::e2x5Right( cluster, getEcalRecHitCollection(cluster), topology_ );
254 }
255 
256 template<class EcalClusterToolsImpl>
258 {
259  return EcalClusterToolsImpl::e2x5Left( cluster, getEcalRecHitCollection(cluster), topology_ );
260 }
261 
262 template<class EcalClusterToolsImpl>
264 {
265  return EcalClusterToolsImpl::e2x5Top( cluster, getEcalRecHitCollection(cluster), topology_ );
266 }
267 
268 template<class EcalClusterToolsImpl>
270 {
271  return EcalClusterToolsImpl::e2x5Bottom( cluster, getEcalRecHitCollection(cluster), topology_ );
272 }
273 
274 template<class EcalClusterToolsImpl>
276 {
277  return EcalClusterToolsImpl::e2x5Max( cluster, getEcalRecHitCollection(cluster), topology_ );
278 }
279 
280 template<class EcalClusterToolsImpl>
282 {
283  return EcalClusterToolsImpl::eLeft( cluster, getEcalRecHitCollection(cluster), topology_ );
284 }
285 
286 template<class EcalClusterToolsImpl>
288 {
289  return EcalClusterToolsImpl::eRight( cluster, getEcalRecHitCollection(cluster), topology_ );
290 }
291 
292 template<class EcalClusterToolsImpl>
294 {
295  return EcalClusterToolsImpl::eTop( cluster, getEcalRecHitCollection(cluster), topology_ );
296 }
297 
298 template<class EcalClusterToolsImpl>
300 {
301  return EcalClusterToolsImpl::eBottom( cluster, getEcalRecHitCollection(cluster), topology_ );
302 }
303 
304 template<class EcalClusterToolsImpl>
306 {
307  return EcalClusterToolsImpl::eMax( cluster, getEcalRecHitCollection(cluster) );
308 }
309 
310 template<class EcalClusterToolsImpl>
312 {
313  return EcalClusterToolsImpl::e2nd( cluster, getEcalRecHitCollection(cluster) );
314 }
315 
316 template<class EcalClusterToolsImpl>
318 {
319  return EcalClusterToolsImpl::getMaximum( cluster, getEcalRecHitCollection(cluster) );
320 }
321 
322 template<class EcalClusterToolsImpl>
324 {
325  return EcalClusterToolsImpl::energyBasketFractionEta( cluster, getEcalRecHitCollection(cluster) );
326 }
327 
328 template<class EcalClusterToolsImpl>
330 {
331  return EcalClusterToolsImpl::energyBasketFractionPhi( cluster, getEcalRecHitCollection(cluster) );
332 }
333 
334 template<class EcalClusterToolsImpl>
335 std::vector<float> EcalClusterLazyToolsT<EcalClusterToolsImpl>::lat( const reco::BasicCluster &cluster, bool logW, float w0 )
336 {
337  return EcalClusterToolsImpl::lat( cluster, getEcalRecHitCollection(cluster), geometry_, logW, w0 );
338 }
339 
340 template<class EcalClusterToolsImpl>
342 {
343  return EcalClusterToolsImpl::covariances( cluster, getEcalRecHitCollection(cluster), topology_, geometry_, w0 );
344 }
345 
346 template<class EcalClusterToolsImpl>
348 {
349  return EcalClusterToolsImpl::localCovariances( cluster, getEcalRecHitCollection(cluster), topology_, w0 );
350 }
351 
352 template<class EcalClusterToolsImpl>
354 {
355  return EcalClusterToolsImpl::scLocalCovariances( cluster, getEcalRecHitCollection(cluster), topology_, w0 );
356 }
357 
358 template<class EcalClusterToolsImpl>
359 double EcalClusterLazyToolsT<EcalClusterToolsImpl>::zernike20( const reco::BasicCluster &cluster, double R0, bool logW, float w0 )
360 {
361  return EcalClusterToolsImpl::zernike20( cluster, getEcalRecHitCollection(cluster), geometry_, R0, logW, w0 );
362 }
363 
364 
365 template<class EcalClusterToolsImpl>
366 double EcalClusterLazyToolsT<EcalClusterToolsImpl>::zernike42( const reco::BasicCluster &cluster, double R0, bool logW, float w0 )
367 {
368  return EcalClusterToolsImpl::zernike42( cluster, getEcalRecHitCollection(cluster), geometry_, R0, logW, w0 );
369 }
370 
371 template<class EcalClusterToolsImpl>
372 std::vector<DetId> EcalClusterLazyToolsT<EcalClusterToolsImpl>::matrixDetId( DetId id, int ixMin, int ixMax, int iyMin, int iyMax )
373 {
374  return EcalClusterToolsImpl::matrixDetId( topology_, id, ixMin, ixMax, iyMin, iyMax );
375 }
376 
377 template<class EcalClusterToolsImpl>
378 float EcalClusterLazyToolsT<EcalClusterToolsImpl>::matrixEnergy( const reco::BasicCluster &cluster, DetId id, int ixMin, int ixMax, int iyMin, int iyMax )
379 {
380  return EcalClusterToolsImpl::matrixEnergy( cluster, getEcalRecHitCollection(cluster), topology_, id, ixMin, ixMax, iyMin, iyMax );
381 }
382 
383 namespace noZS {
385 }
387 
388 
389 
390 #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)
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)