CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalClusterLazyTools.cc
Go to the documentation of this file.
2 
5 
8 
16 
20 
24 
25 //EcalClusterLazyTools::EcalClusterLazyTools( const edm::Event &ev, const edm::EventSetup &es, const edm::InputTag& redEBRecHits, const edm::InputTag& redEERecHits,const edm::ParameterSet& config )
26 EcalClusterLazyTools::EcalClusterLazyTools( const edm::Event &ev, const edm::EventSetup &es, const edm::InputTag& redEBRecHits, const edm::InputTag& redEERecHits)
27 {
28  getGeometry( es );
29  getTopology( es );
30  getEBRecHits( ev, redEBRecHits );
31  getEERecHits( ev, redEERecHits );
33  getADCToGeV ( es );
34  getLaserDbService ( es );
35 
36  //AA
37  //Flags and Severities to be excluded from photon calculations
38 /*
39  const std::vector<std::string> flagnames =
40  config.getParameter<std::vector<std::string> >("RecHitFlagToBeExcluded");
41 
42  flagsexcl_=
43  StringToEnumValue<EcalRecHit::Flags>(flagnames);
44 
45  const std::vector<std::string> severitynames =
46  config.getParameter<std::vector<std::string> >("RecHitSeverityToBeExcluded");
47 
48  severitiesexcl_=
49  StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynames);
50  //AA
51 
52  //AA
53 */
54  //Get the severity level object
55 // edm::ESHandle<EcalSeverityLevelAlgo> sevLv;
56 // es.get<EcalSeverityLevelAlgoRcd>().get(sevLv);
57  //
58 
59 }
60 
61 EcalClusterLazyTools::EcalClusterLazyTools( const edm::Event &ev, const edm::EventSetup &es, const edm::InputTag& redEBRecHits, const edm::InputTag& redEERecHits,const edm::ParameterSet& config)
62 {
63  getGeometry( es );
64  getTopology( es );
65  getEBRecHits( ev, redEBRecHits );
66  getEERecHits( ev, redEERecHits );
68  getADCToGeV ( es );
69  getLaserDbService ( es );
70 
71 // edm::ESHandle<EcalSeverityLevelAlgo> sevLv;
72 // es.get<EcalSeverityLevelAlgoRcd>().get(sevLv);
73 
74 }
75 
76 EcalClusterLazyTools::EcalClusterLazyTools( const edm::Event &ev, const edm::EventSetup &es, const edm::InputTag& redEBRecHits, const edm::InputTag& redEERecHits, const edm::InputTag& redESRecHits)
77 {
78  getGeometry( es );
79  getTopology( es );
80  getEBRecHits( ev, redEBRecHits );
81  getEERecHits( ev, redEERecHits );
82  getESRecHits( ev, redESRecHits );
84  getADCToGeV ( es );
85  getLaserDbService ( es );
86 
87 }
88 
90 {
91 }
92 
93 
94 
96 {
98  es.get<CaloGeometryRecord>().get(pGeometry);
99  geometry_ = pGeometry.product();
100 }
101 
102 
103 
105 {
106  edm::ESHandle<CaloTopology> pTopology;
107  es.get<CaloTopologyRecord>().get(pTopology);
108  topology_ = pTopology.product();
109 }
110 
111 
112 
113 void EcalClusterLazyTools::getEBRecHits( const edm::Event &ev, const edm::InputTag& redEBRecHits )
114 {
116  ev.getByLabel( redEBRecHits, pEBRecHits );
117  ebRecHits_ = pEBRecHits.product();
118 }
119 
120 
121 
122 void EcalClusterLazyTools::getEERecHits( const edm::Event &ev, const edm::InputTag& redEERecHits )
123 {
125  ev.getByLabel( redEERecHits, pEERecHits );
126  eeRecHits_ = pEERecHits.product();
127 }
128 
129 
130 
131 void EcalClusterLazyTools::getESRecHits( const edm::Event &ev, const edm::InputTag& redESRecHits )
132 {
134  ev.getByLabel( redESRecHits, pESRecHits );
135  esRecHits_ = pESRecHits.product();
136 
137  // make the map of rechits
138  rechits_map_.clear();
139  if (pESRecHits.isValid()) {
141  for (it = pESRecHits->begin(); it != pESRecHits->end(); ++it) {
142  // remove bad ES rechits
143  if (it->recoFlag()==1 || it->recoFlag()==14 || (it->recoFlag()<=10 && it->recoFlag()>=5)) continue;
144  //Make the map of DetID, EcalRecHit pairs
145  rechits_map_.insert(std::make_pair(it->id(), *it));
146  }
147  }
148 
149 }
150 
151 
152 
154 {
155  // get IC's
157  icalMap = ical->getMap();
158 }
159 
160 
161 
163 {
164  // get ADCtoGeV
165  es.get<EcalADCToGeVConstantRcd>().get(agc);
166 }
167 
168 
169 
171  // transp corrections
172  es.get<EcalLaserDbRecord>().get(laser);
173 }
174 
175 
177 {
178  if ( cluster.size() == 0 ) {
179  throw cms::Exception("InvalidCluster") << "The cluster has no crystals!";
180  }
181  DetId id = (cluster.hitsAndFractions()[0]).first; // size is by definition > 0 -- FIXME??
182  const EcalRecHitCollection *recHits = 0;
183  if ( id.subdetId() == EcalBarrel ) {
184  recHits = ebRecHits_;
185  } else if ( id.subdetId() == EcalEndcap ) {
186  recHits = eeRecHits_;
187  } else {
188  throw cms::Exception("InvalidSubdetector") << "The subdetId() " << id.subdetId() << " does not correspond to EcalBarrel neither EcalEndcap";
189  }
190  return recHits;
191 }
192 
193 
194 
196 {
197  return EcalClusterTools::e1x3( cluster, getEcalRecHitCollection(cluster), topology_ );
198 }
199 
200 
201 float EcalClusterLazyTools::e1x3( const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
202 {
203  return EcalClusterTools::e1x3( cluster, getEcalRecHitCollection(cluster), topology_, flagsexcl, severitiesexcl, sevLv );
204 }
205 
206 
207 
209 {
210  return EcalClusterTools::e3x1( cluster, getEcalRecHitCollection(cluster), topology_ );
211 }
212 
213 float EcalClusterLazyTools::e3x1( const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
214 {
215  return EcalClusterTools::e3x1( cluster, getEcalRecHitCollection(cluster), topology_, flagsexcl, severitiesexcl, sevLv );
216 }
217 
218 
220 {
221  return EcalClusterTools::e1x5( cluster, getEcalRecHitCollection(cluster), topology_ );
222 }
223 
224 float EcalClusterLazyTools::e1x5( const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
225 {
226  return EcalClusterTools::e1x5( cluster, getEcalRecHitCollection(cluster), topology_, flagsexcl, severitiesexcl, sevLv );
227 }
228 
229 
230 
232 {
233  return EcalClusterTools::e5x1( cluster, getEcalRecHitCollection(cluster), topology_ );
234  }
235 
236 float EcalClusterLazyTools::e5x1( const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
237 {
238  return EcalClusterTools::e5x1( cluster, getEcalRecHitCollection(cluster), topology_, flagsexcl, severitiesexcl, sevLv );
239  }
240 
241 
243 {
244  return EcalClusterTools::e2x2( cluster, getEcalRecHitCollection(cluster), topology_ );
245 }
246 
247 float EcalClusterLazyTools::e2x2( const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
248 {
249  return EcalClusterTools::e2x2( cluster, getEcalRecHitCollection(cluster), topology_, flagsexcl, severitiesexcl, sevLv );
250 }
251 
252 
254 {
255  return EcalClusterTools::e3x2( cluster, getEcalRecHitCollection(cluster), topology_ );
256 }
257 
258 float EcalClusterLazyTools::e3x2( const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
259 {
260  return EcalClusterTools::e3x2( cluster, getEcalRecHitCollection(cluster), topology_, flagsexcl, severitiesexcl, sevLv );
261 }
262 
263 
265 {
266  return EcalClusterTools::e3x3( cluster, getEcalRecHitCollection(cluster), topology_ );
267 }
268 
269 float EcalClusterLazyTools::e3x3( const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
270 {
271  return EcalClusterTools::e3x3( cluster, getEcalRecHitCollection(cluster), topology_, flagsexcl, severitiesexcl, sevLv );
272 }
273 
274 
276 {
277  return EcalClusterTools::e4x4( cluster, getEcalRecHitCollection(cluster), topology_ );
278 }
279 
280 float EcalClusterLazyTools::e4x4( const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
281 {
282  return EcalClusterTools::e4x4( cluster, getEcalRecHitCollection(cluster), topology_, flagsexcl, severitiesexcl, sevLv );
283 }
284 
285 
287 {
288  return EcalClusterTools::e5x5( cluster, getEcalRecHitCollection(cluster), topology_ );
289 }
290 
291 float EcalClusterLazyTools::e5x5( const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
292 {
293  return EcalClusterTools::e5x5( cluster, getEcalRecHitCollection(cluster), topology_, flagsexcl, severitiesexcl, sevLv );
294 }
295 
296 
298 {
300 }
301 
302 float EcalClusterLazyTools::e2x5Right( const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
303 {
304  return EcalClusterTools::e2x5Right( cluster, getEcalRecHitCollection(cluster), topology_, flagsexcl, severitiesexcl, sevLv );
305 }
306 
307 
309 {
310  return EcalClusterTools::e2x5Left( cluster, getEcalRecHitCollection(cluster), topology_ );
311 }
312 
313 float EcalClusterLazyTools::e2x5Left( const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
314 {
315  return EcalClusterTools::e2x5Left( cluster, getEcalRecHitCollection(cluster), topology_, flagsexcl, severitiesexcl, sevLv );
316 }
317 
318 
320 {
321  return EcalClusterTools::e2x5Top( cluster, getEcalRecHitCollection(cluster), topology_ );
322 }
323 
324 float EcalClusterLazyTools::e2x5Top( const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
325 {
326  return EcalClusterTools::e2x5Top( cluster, getEcalRecHitCollection(cluster), topology_, flagsexcl, severitiesexcl, sevLv );
327 }
328 
329 
331 {
333 }
334 
335 float EcalClusterLazyTools::e2x5Bottom( const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
336 {
337  return EcalClusterTools::e2x5Bottom( cluster, getEcalRecHitCollection(cluster), topology_, flagsexcl, severitiesexcl, sevLv );
338 }
339 
340 // Energy in 2x5 strip containing the max crystal.
342 {
343  return EcalClusterTools::e2x5Max( cluster, getEcalRecHitCollection(cluster), topology_ );
344 }
345 
346 float EcalClusterLazyTools::e2x5Max( const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
347 {
348  return EcalClusterTools::e2x5Max( cluster, getEcalRecHitCollection(cluster), topology_, flagsexcl, severitiesexcl, sevLv );
349 }
350 
351 
353 {
354  return EcalClusterTools::eLeft( cluster, getEcalRecHitCollection(cluster), topology_ );
355 }
356 
357 float EcalClusterLazyTools::eLeft( const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
358 {
359  return EcalClusterTools::eLeft( cluster, getEcalRecHitCollection(cluster), topology_, flagsexcl, severitiesexcl, sevLv );
360 }
361 
362 
364 {
365  return EcalClusterTools::eRight( cluster, getEcalRecHitCollection(cluster), topology_ );
366 }
367 
368 float EcalClusterLazyTools::eRight( const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
369 {
370  return EcalClusterTools::eRight( cluster, getEcalRecHitCollection(cluster), topology_, flagsexcl, severitiesexcl, sevLv );
371 }
372 
373 
375 {
376  return EcalClusterTools::eTop( cluster, getEcalRecHitCollection(cluster), topology_ );
377 }
378 
379 float EcalClusterLazyTools::eTop( const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
380 {
381  return EcalClusterTools::eTop( cluster, getEcalRecHitCollection(cluster), topology_, flagsexcl, severitiesexcl, sevLv );
382 }
383 
384 
386 {
387  return EcalClusterTools::eBottom( cluster, getEcalRecHitCollection(cluster), topology_ );
388 }
389 
390 float EcalClusterLazyTools::eBottom( const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
391 {
392  return EcalClusterTools::eBottom( cluster, getEcalRecHitCollection(cluster), topology_, flagsexcl, severitiesexcl, sevLv );
393 }
394 
395 
397 {
398  return EcalClusterTools::eMax( cluster, getEcalRecHitCollection(cluster) );
399 }
400 
401 float EcalClusterLazyTools::eMax( const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
402 {
403  return EcalClusterTools::eMax( cluster, getEcalRecHitCollection(cluster), flagsexcl, severitiesexcl, sevLv );
404 }
405 
406 
408 {
409  return EcalClusterTools::e2nd( cluster, getEcalRecHitCollection(cluster) );
410 }
411 
412 float EcalClusterLazyTools::e2nd( const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
413 {
414  return EcalClusterTools::e2nd( cluster, getEcalRecHitCollection(cluster), flagsexcl, severitiesexcl, sevLv );
415 }
416 
417 std::pair<DetId, float> EcalClusterLazyTools::getMaximum( const reco::BasicCluster &cluster )
418 {
419  return EcalClusterTools::getMaximum( cluster, getEcalRecHitCollection(cluster) );
420 }
421 
422 std::pair<DetId, float> EcalClusterLazyTools::getMaximum( const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
423 {
424  return EcalClusterTools::getMaximum( cluster, getEcalRecHitCollection(cluster), flagsexcl, severitiesexcl, sevLv );
425 }
426 
427 
429 {
431 }
432 
433 std::vector<float> EcalClusterLazyTools::energyBasketFractionEta( const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
434 {
435  return EcalClusterTools::energyBasketFractionEta( cluster, getEcalRecHitCollection(cluster), flagsexcl, severitiesexcl, sevLv );
436 }
437 
438 
440 {
442 }
443 
444 std::vector<float> EcalClusterLazyTools::energyBasketFractionPhi( const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
445 {
446  return EcalClusterTools::energyBasketFractionPhi( cluster, getEcalRecHitCollection(cluster), flagsexcl, severitiesexcl, sevLv );
447 }
448 
449 
450 std::vector<float> EcalClusterLazyTools::lat( const reco::BasicCluster &cluster, bool logW, float w0 )
451 {
452  return EcalClusterTools::lat( cluster, getEcalRecHitCollection(cluster), geometry_, logW, w0 );
453 }
454 
455 //std::vector<float> EcalClusterLazyTools::lat( const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv, bool logW, float w0 )
456 //{
457 // return EcalClusterTools::lat( cluster, getEcalRecHitCollection(cluster), geometry_,flagsexcl, severitiesexcl, sevLv, logW, w0 );
458 //}
459 
460 
461 std::vector<float> EcalClusterLazyTools::covariances(const reco::BasicCluster &cluster, float w0 )
462 {
464 }
465 
466 std::vector<float> EcalClusterLazyTools::covariances(const reco::BasicCluster &cluster,const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv, float w0 )
467 {
468  return EcalClusterTools::covariances( cluster, getEcalRecHitCollection(cluster), topology_, geometry_, flagsexcl, severitiesexcl, sevLv, w0 );
469 }
470 
471 std::vector<float> EcalClusterLazyTools::localCovariances(const reco::BasicCluster &cluster, float w0 )
472 {
474 }
475 
476 std::vector<float> EcalClusterLazyTools::localCovariances(const reco::BasicCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv, float w0 )
477 {
478  return EcalClusterTools::localCovariances( cluster, getEcalRecHitCollection(cluster), topology_, flagsexcl, severitiesexcl, sevLv, w0 );
479 }
480 
481 std::vector<float> EcalClusterLazyTools::scLocalCovariances(const reco::SuperCluster &cluster, float w0 )
482 {
484 }
485 
486 std::vector<float> EcalClusterLazyTools::scLocalCovariances(const reco::SuperCluster &cluster, const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv, float w0 )
487 {
488  return EcalClusterTools::scLocalCovariances( cluster, getEcalRecHitCollection(cluster), topology_, flagsexcl, severitiesexcl, sevLv, w0 );
489 }
490 
491 double EcalClusterLazyTools::zernike20( const reco::BasicCluster &cluster, double R0, bool logW, float w0 )
492 {
493  return EcalClusterTools::zernike20( cluster, getEcalRecHitCollection(cluster), geometry_, R0, logW, w0 );
494 }
495 
496 
497 double EcalClusterLazyTools::zernike42( const reco::BasicCluster &cluster, double R0, bool logW, float w0 )
498 {
499  return EcalClusterTools::zernike42( cluster, getEcalRecHitCollection(cluster), geometry_, R0, logW, w0 );
500 }
501 
502 std::vector<DetId> EcalClusterLazyTools::matrixDetId( DetId id, int ixMin, int ixMax, int iyMin, int iyMax )
503 {
504  return EcalClusterTools::matrixDetId( topology_, id, ixMin, ixMax, iyMin, iyMax );
505 }
506 
507 float EcalClusterLazyTools::matrixEnergy( const reco::BasicCluster &cluster, DetId id, int ixMin, int ixMax, int iyMin, int iyMax )
508 {
509  return EcalClusterTools::matrixEnergy( cluster, getEcalRecHitCollection(cluster), topology_, id, ixMin, ixMax, iyMin, iyMax );
510 }
511 
512 float EcalClusterLazyTools::matrixEnergy( const reco::BasicCluster &cluster, DetId id, int ixMin, int ixMax, int iyMin, int iyMax,const std::vector<int>& flagsexcl, const std::vector<int>& severitiesexcl, const EcalSeverityLevelAlgo *sevLv )
513 {
514  return EcalClusterTools::matrixEnergy( cluster, getEcalRecHitCollection(cluster), topology_, id, ixMin, ixMax, iyMin, iyMax, flagsexcl, severitiesexcl, sevLv );
515 }
516 
517 
518 // get time of basic cluster seed crystal
520 {
521 
522  const EcalRecHitCollection *recHits = getEcalRecHitCollection( cluster );
523 
524  DetId id = cluster.seed();
525  EcalRecHitCollection::const_iterator theSeedHit = recHits->find (id);
526  // std::cout << "the seed of the BC has time: "
527  //<< (*theSeedHit).time()
528  //<< "and energy: " << (*theSeedHit).energy() << " collection size: " << recHits->size()
529  //<< "\n" <<std::endl; // GF debug
530 
531  return (*theSeedHit).time();
532 }
533 
534 
535 // error-weighted average of time from constituents of basic cluster
537 {
538 
539  std::vector<std::pair<DetId, float> > clusterComponents = (cluster).hitsAndFractions() ;
540  //std::cout << "BC has this many components: " << clusterComponents.size() << std::endl; // GF debug
541 
542  const EcalRecHitCollection *recHits = getEcalRecHitCollection( cluster );
543  //std::cout << "BasicClusterClusterTime - rechits are this many: " << recHits->size() << std::endl; // GF debug
544 
545 
546  float weightedTsum = 0;
547  float sumOfWeights = 0;
548 
549  for (std::vector<std::pair<DetId, float> >::const_iterator detitr = clusterComponents.begin(); detitr != clusterComponents.end(); detitr++ )
550  {
551  // EcalRecHitCollection::const_iterator theSeedHit = recHits->find (id); // trash this
552  EcalRecHitCollection::const_iterator oneHit = recHits->find( (detitr -> first) ) ;
553 
554  // in order to get back the ADC counts from the recHit energy, three ingredients are necessary:
555  // 1) get laser correction coefficient
556  float lasercalib = 1.;
557  lasercalib = laser->getLaserCorrection( detitr->first, ev.time());
558  // 2) get intercalibration
560  EcalIntercalibConstant icalconst = 1.;
561  if( icalit!=icalMap.end() ) {
562  icalconst = (*icalit);
563  // std::cout << "icalconst set to: " << icalconst << std::endl;
564  } else {
565  edm::LogError("EcalClusterLazyTools") << "No intercalib const found for xtal " << (detitr->first).rawId() << "bailing out";
566  assert(0);
567  }
568  // 3) get adc2GeV
569  float adcToGeV = 1.;
570  if ( (detitr -> first).subdetId() == EcalBarrel ) adcToGeV = float(agc->getEBValue());
571  else if ( (detitr -> first).subdetId() == EcalEndcap ) adcToGeV = float(agc->getEEValue());
572  float adc = 2.;
573  if (icalconst>0 && lasercalib>0 && adcToGeV>0) adc= (*oneHit).energy()/(icalconst*lasercalib*adcToGeV);
574 
575  // don't consider recHits with too little amplitude; take sigma_noise_total into account
576  if( (detitr -> first).subdetId() == EcalBarrel && adc< (1.1*20) ) continue;
577  if( (detitr -> first).subdetId() == EcalEndcap && adc< (2.2*20) ) continue;
578 
579  // count only on rechits whose error is trusted by the method (ratio)
580  if(! (*oneHit).isTimeErrorValid()) continue;
581 
582  float timeError = (*oneHit).timeError();
583  // the constant used to build timeError is largely over-estimated ; remove in quadrature 0.6 and add 0.15 back.
584  // could be prettier if value of constant term was changed at recHit production level
585  if (timeError>0.6) timeError = sqrt( timeError*timeError - 0.6*0.6 + 0.15*0.15);
586  else timeError = sqrt( timeError*timeError + 0.15*0.15);
587 
588  // do the error weighting
589  weightedTsum += (*oneHit).time() / (timeError*timeError);
590  sumOfWeights += 1. / (timeError*timeError);
591 
592  }
593 
594  // what if no crytal is available for weighted average?
595  if ( sumOfWeights ==0 ) return -999;
596  else return ( weightedTsum / sumOfWeights);
597 
598 }
599 
600 
601 // get BasicClusterSeedTime of the seed basic cluser of the supercluster
603 
604  return BasicClusterSeedTime ( (*cluster.seed()) );
605 
606 }
607 
608 
609 // get BasicClusterTime of the seed basic cluser of the supercluster
611 
612  return BasicClusterTime ( (*cluster.seed()) , ev);
613 
614 }
615 
616 
617 // get Preshower effective sigmaIRIR
619 {
620  if (!(fabs(cluster.eta()) > 1.6 && fabs(cluster.eta()) < 3.)) return 0.;
621 
623  CaloSubdetectorTopology *topology_p = 0;
624  if (geometryES) topology_p = new EcalPreshowerTopology(geometry_);
625 
626  std::vector<float> phoESHitsIXIX = getESHits(cluster.x(), cluster.y(), cluster.z(), rechits_map_, geometry_, topology_p, 0, 1);
627  std::vector<float> phoESHitsIYIY = getESHits(cluster.x(), cluster.y(), cluster.z(), rechits_map_, geometry_, topology_p, 0, 2);
628  float phoESShapeIXIX = getESShape(phoESHitsIXIX);
629  float phoESShapeIYIY = getESShape(phoESHitsIYIY);
630 
631  return sqrt(phoESShapeIXIX*phoESShapeIXIX + phoESShapeIYIY*phoESShapeIYIY);
632 }
633 
634 // get Preshower effective sigmaIXIX
636 {
637  if (!(fabs(cluster.eta()) > 1.6 && fabs(cluster.eta()) < 3.)) return 0.;
638 
640  CaloSubdetectorTopology *topology_p = 0;
641  if (geometryES) topology_p = new EcalPreshowerTopology(geometry_);
642 
643  std::vector<float> phoESHitsIXIX = getESHits(cluster.x(), cluster.y(), cluster.z(), rechits_map_, geometry_, topology_p, 0, 1);
644  float phoESShapeIXIX = getESShape(phoESHitsIXIX);
645 
646  return phoESShapeIXIX;
647 }
648 
649 // get Preshower effective sigmaIYIY
651 {
652  if (!(fabs(cluster.eta()) > 1.6 && fabs(cluster.eta()) < 3.)) return 0.;
653 
655  CaloSubdetectorTopology *topology_p = 0;
656  if (geometryES) topology_p = new EcalPreshowerTopology(geometry_);
657 
658  std::vector<float> phoESHitsIYIY = getESHits(cluster.x(), cluster.y(), cluster.z(), rechits_map_, geometry_, topology_p, 0, 2);
659  float phoESShapeIYIY = getESShape(phoESHitsIYIY);
660 
661  return phoESShapeIYIY;
662 }
663 
664 // get Preshower Rechits
665 std::vector<float> EcalClusterLazyTools::getESHits(double X, double Y, double Z, std::map<DetId, EcalRecHit> rechits_map, const CaloGeometry* geometry, CaloSubdetectorTopology *topology_p, int row, int plane)
666 {
667  std::vector<float> esHits;
668 
669  const GlobalPoint point(X,Y,Z);
670 
671  const CaloSubdetectorGeometry *geometry_p ;
672  geometry_p = geometry->getSubdetectorGeometry (DetId::Ecal,EcalPreshower) ;
673 
674  DetId esId = (dynamic_cast<const EcalPreshowerGeometry*>(geometry_p))->getClosestCellInPlane(point, plane);
675  ESDetId esDetId = (esId == DetId(0)) ? ESDetId(0) : ESDetId(esId);
676 
677  std::map<DetId, EcalRecHit>::iterator it;
678  ESDetId next;
679  ESDetId strip;
680  strip = esDetId;
681 
682  EcalPreshowerNavigator theESNav(strip, topology_p);
683  theESNav.setHome(strip);
684 
685  if (row == 1) {
686  if (plane==1 && strip != ESDetId(0)) strip = theESNav.north();
687  if (plane==2 && strip != ESDetId(0)) strip = theESNav.east();
688  } else if (row == -1) {
689  if (plane==1 && strip != ESDetId(0)) strip = theESNav.south();
690  if (plane==2 && strip != ESDetId(0)) strip = theESNav.west();
691  }
692 
693 
694  if (strip == ESDetId(0)) {
695  for (int i=0; i<31; ++i) esHits.push_back(0);
696  } else {
697  it = rechits_map.find(strip);
698  if (it->second.energy() > 1.0e-10 && it != rechits_map.end()) esHits.push_back(it->second.energy());
699  else esHits.push_back(0);
700  //cout<<"center : "<<strip<<" "<<it->second.energy()<<endl;
701 
702  // Front Plane
703  if (plane==1) {
704  // east road
705  for (int i=0; i<15; ++i) {
706  next = theESNav.east();
707  if (next != ESDetId(0)) {
708  it = rechits_map.find(next);
709  if (it->second.energy() > 1.0e-10 && it != rechits_map.end()) esHits.push_back(it->second.energy());
710  else esHits.push_back(0);
711  //cout<<"east "<<i<<" : "<<next<<" "<<it->second.energy()<<endl;
712  } else {
713  for (int j=i; j<15; j++) esHits.push_back(0);
714  break;
715  //cout<<"east "<<i<<" : "<<next<<" "<<0<<endl;
716  }
717  }
718 
719  // west road
720  theESNav.setHome(strip);
721  theESNav.home();
722  for (int i=0; i<15; ++i) {
723  next = theESNav.west();
724  if (next != ESDetId(0)) {
725  it = rechits_map.find(next);
726  if (it->second.energy() > 1.0e-10 && it != rechits_map.end()) esHits.push_back(it->second.energy());
727  else esHits.push_back(0);
728  //cout<<"west "<<i<<" : "<<next<<" "<<it->second.energy()<<endl;
729  } else {
730  for (int j=i; j<15; j++) esHits.push_back(0);
731  break;
732  //cout<<"west "<<i<<" : "<<next<<" "<<0<<endl;
733  }
734  }
735  } // End of Front Plane
736 
737  // Rear Plane
738  if (plane==2) {
739  // north road
740  for (int i=0; i<15; ++i) {
741  next = theESNav.north();
742  if (next != ESDetId(0)) {
743  it = rechits_map.find(next);
744  if (it->second.energy() > 1.0e-10 && it != rechits_map.end()) esHits.push_back(it->second.energy());
745  else esHits.push_back(0);
746  //cout<<"north "<<i<<" : "<<next<<" "<<it->second.energy()<<endl;
747  } else {
748  for (int j=i; j<15; j++) esHits.push_back(0);
749  break;
750  //cout<<"north "<<i<<" : "<<next<<" "<<0<<endl;
751  }
752  }
753 
754  // south road
755  theESNav.setHome(strip);
756  theESNav.home();
757  for (int i=0; i<15; ++i) {
758  next = theESNav.south();
759  if (next != ESDetId(0)) {
760  it = rechits_map.find(next);
761  if (it->second.energy() > 1.0e-10 && it != rechits_map.end()) esHits.push_back(it->second.energy());
762  else esHits.push_back(0);
763  //cout<<"south "<<i<<" : "<<next<<" "<<it->second.energy()<<endl;
764  } else {
765  for (int j=i; j<15; j++) esHits.push_back(0);
766  break;
767  //cout<<"south "<<i<<" : "<<next<<" "<<0<<endl;
768  }
769  }
770  } // End of Rear Plane
771  } // Fill ES RecHits
772 
773  return esHits;
774 }
775 
776 
777 // get Preshower hit shape
778 float EcalClusterLazyTools::getESShape(const std::vector<float>& ESHits0)
779 {
780  const int nBIN = 21;
781  float esRH[nBIN];
782  for (int idx=0; idx<nBIN; idx++) {
783  esRH[idx] = 0.;
784  }
785 
786  for(int ibin=0; ibin<((nBIN+1)/2); ibin++) {
787  if (ibin==0) {
788  esRH[(nBIN-1)/2] = ESHits0[ibin];
789  } else {
790  esRH[(nBIN-1)/2+ibin] = ESHits0[ibin];
791  esRH[(nBIN-1)/2-ibin] = ESHits0[ibin+15];
792  }
793  }
794 
795  // ---- Effective Energy Deposit Width ---- //
796  double EffWidthSigmaISIS = 0.;
797  double totalEnergyISIS = 0.;
798  double EffStatsISIS = 0.;
799  for (int id_X=0; id_X<21; id_X++) {
800  totalEnergyISIS += esRH[id_X];
801  EffStatsISIS += esRH[id_X]*(id_X-10)*(id_X-10);
802  }
803  EffWidthSigmaISIS = (totalEnergyISIS>0.) ? sqrt(fabs(EffStatsISIS / totalEnergyISIS)) : 0.;
804 
805  return EffWidthSigmaISIS;
806 }
int adc(sample_type sample)
get the ADC sample (12 bits)
const double Z[kNumberCalorimeter]
std::vector< float > localCovariances(const reco::BasicCluster &cluster, float w0=4.7)
CaloNavigator< ESDetId > EcalPreshowerNavigator
static float eBottom(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:43
int i
Definition: DBlmapReader.cc:9
static double zernike42(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloGeometry *geometry, double R0=6.6, bool logW=true, float w0=4.7)
float e2x2(const reco::BasicCluster &cluster)
float e4x4(const reco::BasicCluster &cluster)
std::vector< float > energyBasketFractionPhi(const reco::BasicCluster &cluster)
float eBottom(const reco::BasicCluster &cluster)
static float e5x1(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
float e2nd(const reco::BasicCluster &cluster)
const EcalRecHitCollection * esRecHits_
std::map< DetId, EcalRecHit > rechits_map_
float eseffsiyiy(const reco::SuperCluster &cluster)
static std::vector< float > energyBasketFractionEta(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
void getEBRecHits(const edm::Event &ev, const edm::InputTag &redEBRecHits)
edm::ESHandle< EcalADCToGeVConstant > agc
static float e3x1(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
static float matrixEnergy(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, DetId id, int ixMin, int ixMax, int iyMin, int iyMax)
float eRight(const reco::BasicCluster &cluster)
float e1x5(const reco::BasicCluster &cluster)
static std::vector< DetId > matrixDetId(const CaloTopology *topology, DetId id, int ixMin, int ixMax, int iyMin, int iyMax)
void getEERecHits(const edm::Event &ev, const edm::InputTag &redEERecHits)
float SuperClusterTime(const reco::SuperCluster &cluster, const edm::Event &ev)
std::vector< EcalRecHit >::const_iterator const_iterator
#define X(str)
Definition: MuonsGrabber.cc:49
float e3x3(const reco::BasicCluster &cluster)
float eMax(const reco::BasicCluster &cluster)
const CaloGeometry * geometry_
float getESShape(const std::vector< float > &ESHits0)
static float e2nd(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
double z() const
z coordinate of cluster centroid
Definition: CaloCluster.h:157
double eta() const
pseudorapidity of cluster centroid
Definition: CaloCluster.h:160
float SuperClusterSeedTime(const reco::SuperCluster &cluster)
static float e3x2(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
static std::vector< float > covariances(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, const CaloGeometry *geometry, float w0=4.7)
void getLaserDbService(const edm::EventSetup &es)
edm::ESHandle< EcalLaserDbService > laser
const EcalRecHitCollection * ebRecHits_
float eseffsirir(const reco::SuperCluster &cluster)
float matrixEnergy(const reco::BasicCluster &cluster, DetId id, int ixMin, int ixMax, int iyMin, int iyMax)
static float e2x5Left(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
static std::vector< float > localCovariances(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, float w0=4.7)
void getIntercalibConstants(const edm::EventSetup &es)
static double zernike20(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloGeometry *geometry, double R0=6.6, bool logW=true, float w0=4.7)
static std::vector< float > energyBasketFractionPhi(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
float e2x5Max(const reco::BasicCluster &cluster)
T sqrt(T t)
Definition: SSEVec.h:48
float e5x1(const reco::BasicCluster &cluster)
float e2x5Right(const reco::BasicCluster &cluster)
static float e3x3(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
double zernike20(const reco::BasicCluster &cluster, double R0=6.6, bool logW=true, float w0=4.7)
void getADCToGeV(const edm::EventSetup &es)
double zernike42(const reco::BasicCluster &cluster, double R0=6.6, bool logW=true, float w0=4.7)
int j
Definition: DBlmapReader.cc:9
const EcalRecHitCollection * eeRecHits_
double x() const
x coordinate of cluster centroid
Definition: CaloCluster.h:151
float BasicClusterSeedTime(const reco::BasicCluster &cluster)
static float e4x4(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
std::vector< float > getESHits(double X, double Y, double Z, std::map< DetId, EcalRecHit > rechits_map, const CaloGeometry *geometry, CaloSubdetectorTopology *topology_p, int row=0, int plane=1)
bool first
Definition: L1TdeRCT.cc:94
bool isValid() const
Definition: HandleBase.h:76
std::vector< float > scLocalCovariances(const reco::SuperCluster &cluster, float w0=4.7)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
float eseffsixix(const reco::SuperCluster &cluster)
float e3x2(const reco::BasicCluster &cluster)
std::vector< float > covariances(const reco::BasicCluster &cluster, float w0=4.7)
float eTop(const reco::BasicCluster &cluster)
float e2x5Bottom(const reco::BasicCluster &cluster)
std::vector< float > lat(const reco::BasicCluster &cluster, bool logW=true, float w0=4.7)
Definition: DetId.h:20
float e2x5Left(const reco::BasicCluster &cluster)
float e5x5(const reco::BasicCluster &cluster)
static float eRight(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
static float eTop(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
float eLeft(const reco::BasicCluster &cluster)
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
static float eMax(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
const T & get() const
Definition: EventSetup.h:55
std::vector< Item >::const_iterator const_iterator
edm::ESHandle< EcalIntercalibConstants > ical
T const * product() const
Definition: ESHandle.h:62
static std::vector< float > lat(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloGeometry *geometry, bool logW=true, float w0=4.7)
std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster)
T const * product() const
Definition: Handle.h:74
static float e2x5Bottom(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
static std::vector< float > scLocalCovariances(const reco::SuperCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, float w0=4.7)
EcalClusterLazyTools(const edm::Event &ev, const edm::EventSetup &es, const edm::InputTag &redEBRecHits, const edm::InputTag &redEERecHits, const edm::ParameterSet &config)
ESHandle< TrackerGeometry > geometry
iterator find(key_type k)
EcalIntercalibConstantMap icalMap
static std::pair< DetId, float > getMaximum(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
static float e2x5Max(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
float e2x5Top(const reco::BasicCluster &cluster)
static float e1x3(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
static float e5x5(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
const_iterator find(uint32_t rawId) const
static float e1x5(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
void getGeometry(const edm::EventSetup &es)
float BasicClusterTime(const reco::BasicCluster &cluster, const edm::Event &ev)
float e3x1(const reco::BasicCluster &cluster)
const_iterator end() const
std::vector< DetId > matrixDetId(DetId id, int ixMin, int ixMax, int iyMin, int iyMax)
const CaloClusterPtr & seed() const
seed BasicCluster
Definition: SuperCluster.h:68
double y() const
y coordinate of cluster centroid
Definition: CaloCluster.h:154
const CaloTopology * topology_
static float eLeft(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
void getESRecHits(const edm::Event &ev, const edm::InputTag &redESRecHits)
const EcalRecHitCollection * getEcalRecHitCollection(const reco::BasicCluster &cluster)
static float e2x5Right(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
void getTopology(const edm::EventSetup &es)
edm::Timestamp time() const
Definition: EventBase.h:57
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
std::vector< float > energyBasketFractionEta(const reco::BasicCluster &cluster)
float EcalIntercalibConstant
static float e2x2(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
float e1x3(const reco::BasicCluster &cluster)
static float e2x5Top(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)