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