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