CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CaloTowersCreationAlgo.cc
Go to the documentation of this file.
8 #include "Math/Interpolator.h"
9 
11  : theEBthreshold(-1000.),
12  theEEthreshold(-1000.),
13 
14  theUseEtEBTresholdFlag(false),
15  theUseEtEETresholdFlag(false),
16  theUseSymEBTresholdFlag(false),
17  theUseSymEETresholdFlag(false),
18 
19 
20  theHcalThreshold(-1000.),
21  theHBthreshold(-1000.),
22  theHESthreshold(-1000.),
23  theHEDthreshold(-1000.),
24  theHOthreshold0(-1000.),
25  theHOthresholdPlus1(-1000.),
26  theHOthresholdMinus1(-1000.),
27  theHOthresholdPlus2(-1000.),
28  theHOthresholdMinus2(-1000.),
29  theHF1threshold(-1000.),
30  theHF2threshold(-1000.),
31  theEBGrid(std::vector<double>(5,10.)),
32  theEBWeights(std::vector<double>(5,1.)),
33  theEEGrid(std::vector<double>(5,10.)),
34  theEEWeights(std::vector<double>(5,1.)),
35  theHBGrid(std::vector<double>(5,10.)),
36  theHBWeights(std::vector<double>(5,1.)),
37  theHESGrid(std::vector<double>(5,10.)),
38  theHESWeights(std::vector<double>(5,1.)),
39  theHEDGrid(std::vector<double>(5,10.)),
40  theHEDWeights(std::vector<double>(5,1.)),
41  theHOGrid(std::vector<double>(5,10.)),
42  theHOWeights(std::vector<double>(5,1.)),
43  theHF1Grid(std::vector<double>(5,10.)),
44  theHF1Weights(std::vector<double>(5,1.)),
45  theHF2Grid(std::vector<double>(5,10.)),
46  theHF2Weights(std::vector<double>(5,1.)),
47  theEBweight(1.),
48  theEEweight(1.),
49  theHBweight(1.),
50  theHESweight(1.),
51  theHEDweight(1.),
52  theHOweight(1.),
53  theHF1weight(1.),
54  theHF2weight(1.),
55  theEcutTower(-1000.),
56  theEBSumThreshold(-1000.),
57  theEESumThreshold(-1000.),
58  theHcalTopology(0),
59  theGeometry(0),
60  theTowerConstituentsMap(0),
61  theHOIsUsed(true),
62  // (for momentum reconstruction algorithm)
63  theMomConstrMethod(0),
64  theMomHBDepth(0.),
65  theMomHEDepth(0.),
66  theMomEBDepth(0.),
67  theMomEEDepth(0.)
68 {
69 }
70 
71 CaloTowersCreationAlgo::CaloTowersCreationAlgo(double EBthreshold, double EEthreshold,
72 
73  bool useEtEBTreshold,
74  bool useEtEETreshold,
75  bool useSymEBTreshold,
76  bool useSymEETreshold,
77 
78  double HcalThreshold,
79  double HBthreshold, double HESthreshold, double HEDthreshold,
80  double HOthreshold0, double HOthresholdPlus1, double HOthresholdMinus1,
81  double HOthresholdPlus2, double HOthresholdMinus2,
82  double HF1threshold, double HF2threshold,
83  double EBweight, double EEweight,
84  double HBweight, double HESweight, double HEDweight,
85  double HOweight, double HF1weight, double HF2weight,
86  double EcutTower, double EBSumThreshold, double EESumThreshold,
87  bool useHO,
88  // (momentum reconstruction algorithm)
89  int momConstrMethod,
90  double momHBDepth,
91  double momHEDepth,
92  double momEBDepth,
93  double momEEDepth)
94 
95  : theEBthreshold(EBthreshold),
96  theEEthreshold(EEthreshold),
97 
98  theUseEtEBTresholdFlag(useEtEBTreshold),
99  theUseEtEETresholdFlag(useEtEETreshold),
100  theUseSymEBTresholdFlag(useSymEBTreshold),
101  theUseSymEETresholdFlag(useSymEETreshold),
102 
103  theHcalThreshold(HcalThreshold),
104  theHBthreshold(HBthreshold),
105  theHESthreshold(HESthreshold),
106  theHEDthreshold(HEDthreshold),
107  theHOthreshold0(HOthreshold0),
108  theHOthresholdPlus1(HOthresholdPlus1),
109  theHOthresholdMinus1(HOthresholdMinus1),
110  theHOthresholdPlus2(HOthresholdPlus2),
111  theHOthresholdMinus2(HOthresholdMinus2),
112  theHF1threshold(HF1threshold),
113  theHF2threshold(HF2threshold),
114  theEBGrid(std::vector<double>(5,10.)),
115  theEBWeights(std::vector<double>(5,1.)),
116  theEEGrid(std::vector<double>(5,10.)),
117  theEEWeights(std::vector<double>(5,1.)),
118  theHBGrid(std::vector<double>(5,10.)),
119  theHBWeights(std::vector<double>(5,1.)),
120  theHESGrid(std::vector<double>(5,10.)),
121  theHESWeights(std::vector<double>(5,1.)),
122  theHEDGrid(std::vector<double>(5,10.)),
123  theHEDWeights(std::vector<double>(5,1.)),
124  theHOGrid(std::vector<double>(5,10.)),
125  theHOWeights(std::vector<double>(5,1.)),
126  theHF1Grid(std::vector<double>(5,10.)),
127  theHF1Weights(std::vector<double>(5,1.)),
128  theHF2Grid(std::vector<double>(5,10.)),
129  theHF2Weights(std::vector<double>(5,1.)),
130  theEBweight(EBweight),
131  theEEweight(EEweight),
132  theHBweight(HBweight),
133  theHESweight(HESweight),
134  theHEDweight(HEDweight),
135  theHOweight(HOweight),
136  theHF1weight(HF1weight),
137  theHF2weight(HF2weight),
138  theEcutTower(EcutTower),
139  theEBSumThreshold(EBSumThreshold),
140  theEESumThreshold(EESumThreshold),
141  theHOIsUsed(useHO),
142  // (momentum reconstruction algorithm)
143  theMomConstrMethod(momConstrMethod),
144  theMomHBDepth(momHBDepth),
145  theMomHEDepth(momHEDepth),
146  theMomEBDepth(momEBDepth),
147  theMomEEDepth(momEEDepth)
148 
149 {
150 }
151 
152 CaloTowersCreationAlgo::CaloTowersCreationAlgo(double EBthreshold, double EEthreshold,
153  bool useEtEBTreshold,
154  bool useEtEETreshold,
155  bool useSymEBTreshold,
156  bool useSymEETreshold,
157 
158  double HcalThreshold,
159  double HBthreshold, double HESthreshold, double HEDthreshold,
160  double HOthreshold0, double HOthresholdPlus1, double HOthresholdMinus1,
161  double HOthresholdPlus2, double HOthresholdMinus2,
162  double HF1threshold, double HF2threshold,
163  const std::vector<double> & EBGrid, const std::vector<double> & EBWeights,
164  const std::vector<double> & EEGrid, const std::vector<double> & EEWeights,
165  const std::vector<double> & HBGrid, const std::vector<double> & HBWeights,
166  const std::vector<double> & HESGrid, const std::vector<double> & HESWeights,
167  const std::vector<double> & HEDGrid, const std::vector<double> & HEDWeights,
168  const std::vector<double> & HOGrid, const std::vector<double> & HOWeights,
169  const std::vector<double> & HF1Grid, const std::vector<double> & HF1Weights,
170  const std::vector<double> & HF2Grid, const std::vector<double> & HF2Weights,
171  double EBweight, double EEweight,
172  double HBweight, double HESweight, double HEDweight,
173  double HOweight, double HF1weight, double HF2weight,
174  double EcutTower, double EBSumThreshold, double EESumThreshold,
175  bool useHO,
176  // (for the momentum construction algorithm)
177  int momConstrMethod,
178  double momHBDepth,
179  double momHEDepth,
180  double momEBDepth,
181  double momEEDepth)
182 
183  : theEBthreshold(EBthreshold),
184  theEEthreshold(EEthreshold),
185 
186  theUseEtEBTresholdFlag(useEtEBTreshold),
187  theUseEtEETresholdFlag(useEtEETreshold),
188  theUseSymEBTresholdFlag(useSymEBTreshold),
189  theUseSymEETresholdFlag(useSymEETreshold),
190 
191  theHcalThreshold(HcalThreshold),
192  theHBthreshold(HBthreshold),
193  theHESthreshold(HESthreshold),
194  theHEDthreshold(HEDthreshold),
195  theHOthreshold0(HOthreshold0),
196  theHOthresholdPlus1(HOthresholdPlus1),
197  theHOthresholdMinus1(HOthresholdMinus1),
198  theHOthresholdPlus2(HOthresholdPlus2),
199  theHOthresholdMinus2(HOthresholdMinus2),
200  theHF1threshold(HF1threshold),
201  theHF2threshold(HF2threshold),
202  theEBGrid(EBGrid),
203  theEBWeights(EBWeights),
204  theEEGrid(EEGrid),
205  theEEWeights(EEWeights),
206  theHBGrid(HBGrid),
207  theHBWeights(HBWeights),
208  theHESGrid(HESGrid),
209  theHESWeights(HESWeights),
210  theHEDGrid(HEDGrid),
211  theHEDWeights(HEDWeights),
212  theHOGrid(HOGrid),
213  theHOWeights(HOWeights),
214  theHF1Grid(HF1Grid),
215  theHF1Weights(HF1Weights),
216  theHF2Grid(HF2Grid),
217  theHF2Weights(HF2Weights),
218  theEBweight(EBweight),
219  theEEweight(EEweight),
220  theHBweight(HBweight),
221  theHESweight(HESweight),
222  theHEDweight(HEDweight),
223  theHOweight(HOweight),
224  theHF1weight(HF1weight),
225  theHF2weight(HF2weight),
226  theEcutTower(EcutTower),
227  theEBSumThreshold(EBSumThreshold),
228  theEESumThreshold(EESumThreshold),
229  theHOIsUsed(useHO),
230  // (momentum reconstruction algorithm)
231  theMomConstrMethod(momConstrMethod),
232  theMomHBDepth(momHBDepth),
233  theMomHEDepth(momHEDepth),
234  theMomEBDepth(momEBDepth),
235  theMomEEDepth(momEEDepth)
236 
237 {
238  // static int N = 0;
239  // std::cout << "VI Algo " << ++N << std::endl;
240  // nalgo=N;
241 }
242 
243 
246  theHcalTopology = topo;
247  theGeometry = geo;
249 }
250 
252  theTowerMap.clear();
253  theTowerMapSize=0;
254  //hcalDropChMap.clear();
255 }
256 
258  for(HBHERecHitCollection::const_iterator hbheItr = hbhe.begin();
259  hbheItr != hbhe.end(); ++hbheItr)
260  assignHitHcal(&(*hbheItr));
261 }
262 
264  for(HORecHitCollection::const_iterator hoItr = ho.begin();
265  hoItr != ho.end(); ++hoItr)
266  assignHitHcal(&(*hoItr));
267 }
268 
270  for(HFRecHitCollection::const_iterator hfItr = hf.begin();
271  hfItr != hf.end(); ++hfItr)
272  assignHitHcal(&(*hfItr));
273 }
274 
277  ecItr != ec.end(); ++ecItr)
278  assignHitEcal(&(*ecItr));
279 }
280 
281 // this method should not be used any more as the towers in the changed format
282 // can not be properly rescaled with the "rescale" method.
283 // "rescale was replaced by "rescaleTowers"
284 //
286  for(CaloTowerCollection::const_iterator ctcItr = ctc.begin();
287  ctcItr != ctc.end(); ++ctcItr) {
288  rescale(&(*ctcItr));
289  }
290 }
291 
292 
293 
295  // now copy this map into the final collection
296  result.reserve(theTowerMapSize);
297  // auto k=0U;
298  // if (!theEbHandle.isValid()) std::cout << "VI ebHandle not valid" << std::endl;
299  // if (!theEeHandle.isValid()) std::cout << "VI eeHandle not valid" << std::endl;
300 
301  for(auto const & mt : theTowerMap ) {
302  // Convert only if there is at least one constituent in the metatower.
303  // The check of constituents size in the coverted tower is still needed!
304  if (!mt.empty() ) { convert(mt.id, mt, result); } // ++k;}
305  }
306 
307  // assert(k==theTowerMapSize);
308  // std::cout << "VI TowerMap " << theTowerMapSize << " " << k << std::endl;
309 
310  theTowerMap.clear(); // save the memory
311  theTowerMapSize=0;
312 }
313 
314 
316 
317  for (CaloTowerCollection::const_iterator ctcItr = ctc.begin();
318  ctcItr != ctc.end(); ++ctcItr) {
319 
320  CaloTowerDetId twrId = ctcItr->id();
321  double newE_em = ctcItr->emEnergy();
322  double newE_had = ctcItr->hadEnergy();
323  double newE_outer = ctcItr->outerEnergy();
324 
325  double threshold = 0.0; // not used: we do not change thresholds
326  double weight = 1.0;
327 
328  // HF
329  if (ctcItr->ietaAbs()>=30) {
330  double E_short = 0.5 * newE_had; // from the definitions for HF
331  double E_long = newE_em + 0.5 * newE_had; //
332  // scale
333  E_long *= theHF1weight;
334  E_short *= theHF2weight;
335  // convert
336  newE_em = E_long - E_short;
337  newE_had = 2.0 * E_short;
338  }
339 
340  else { // barrel/endcap
341 
342  // find if its in EB, or EE; determine from first ecal constituent found
343  for (unsigned int iConst = 0; iConst < ctcItr->constituentsSize(); ++iConst) {
344  DetId constId = ctcItr->constituent(iConst);
345  if (constId.det()!=DetId::Ecal) continue;
346  getThresholdAndWeight(constId, threshold, weight);
347  newE_em *= weight;
348  break;
349  }
350  // HO
351  for (unsigned int iConst = 0; iConst < ctcItr->constituentsSize(); ++iConst) {
352  DetId constId = ctcItr->constituent(iConst);
353  if (constId.det()!=DetId::Hcal) continue;
354  if (HcalDetId(constId).subdet()!=HcalOuter) continue;
355  getThresholdAndWeight(constId, threshold, weight);
356  newE_outer *= weight;
357  break;
358  }
359  // HB/HE
360  for (unsigned int iConst = 0; iConst < ctcItr->constituentsSize(); ++iConst) {
361  DetId constId = ctcItr->constituent(iConst);
362  if (constId.det()!=DetId::Hcal) continue;
363  if (HcalDetId(constId).subdet()==HcalOuter) continue;
364  getThresholdAndWeight(constId, threshold, weight);
365  newE_had *= weight;
366  if (ctcItr->ietaAbs()>16) newE_outer *= weight;
367  break;
368  }
369 
370  } // barrel/endcap region
371 
372  // now make the new tower
373 
374  double newE_hadTot = (theHOIsUsed && twrId.ietaAbs()<16)? newE_had+newE_outer : newE_had;
375 
376  GlobalPoint emPoint = ctcItr->emPosition();
377  GlobalPoint hadPoint = ctcItr->emPosition();
378 
379  double f_em = 1.0/cosh(emPoint.eta());
380  double f_had = 1.0/cosh(hadPoint.eta());
381 
383 
384  if (ctcItr->ietaAbs()<30) {
385  if (newE_em>0) towerP4 += CaloTower::PolarLorentzVector(newE_em*f_em, emPoint.eta(), emPoint.phi(), 0);
386  if (newE_hadTot>0) towerP4 += CaloTower::PolarLorentzVector(newE_hadTot*f_had, hadPoint.eta(), hadPoint.phi(), 0);
387  }
388  else {
389  double newE_tot = newE_em + newE_had;
390  // for HF we use common point for ecal, hcal shower positions regardless of the method
391  if (newE_tot>0) towerP4 += CaloTower::PolarLorentzVector(newE_tot*f_had, hadPoint.eta(), hadPoint.phi(), 0);
392  }
393 
394 
395 
396  CaloTower rescaledTower(twrId, newE_em, newE_had, newE_outer, -1, -1, towerP4, emPoint, hadPoint);
397  // copy the timings, have to convert back to int, 1 unit = 0.01 ns
398  rescaledTower.setEcalTime( int(ctcItr->ecalTime()*100.0 + 0.5) );
399  rescaledTower.setHcalTime( int(ctcItr->hcalTime()*100.0 + 0.5) );
400 
401  std::vector<DetId> contains;
402  for (unsigned int iConst = 0; iConst < ctcItr->constituentsSize(); ++iConst) {
403  contains.push_back(ctcItr->constituent(iConst));
404  }
405  rescaledTower.addConstituents(contains);
406 
407  rescaledTower.setCaloTowerStatus(ctcItr->towerStatusWord());
408 
409  ctcResult.push_back(rescaledTower);
410 
411  } // end of loop over towers
412 
413 
414 }
415 
416 
418  DetId detId = recHit->detid();
419 
420  unsigned int chStatusForCT = hcalChanStatusForCaloTower(recHit);
421 
422  // this is for skipping channls: mostly needed for the creation of
423  // bad towers from hits i the bad channel collections.
424  if (chStatusForCT==CaloTowersCreationAlgo::IgnoredChan) return;
425 
426  double threshold, weight;
427  getThresholdAndWeight(detId, threshold, weight);
428 
429  double energy = recHit->energy(); // original RecHit energy is used to apply thresholds
430  double e = energy * weight; // energies scaled by user weight: used in energy assignments
431 
432  // SPECIAL handling of tower 28/depth 3 --> half into tower 28 and half into tower 29
433  if (detId.det()==DetId::Hcal &&
434  HcalDetId(detId).subdet()==HcalEndcap &&
435  HcalDetId(detId).depth()==3 &&
436  HcalDetId(detId).ietaAbs()==28) {
437 
439 
440  // bad channels are counted regardless of energy threshold
441 
442  if (chStatusForCT == CaloTowersCreationAlgo::BadChan) {
443  CaloTowerDetId towerDetId = theTowerConstituentsMap->towerOf(detId);
444  if (towerDetId.null()) return;
445  MetaTower & tower28 = find(towerDetId);
446  CaloTowerDetId towerDetId29(towerDetId.ieta()+towerDetId.zside(),
447  towerDetId.iphi());
448  MetaTower & tower29 = find(towerDetId29);
449  tower28.numBadHcalCells += 1;
450  tower29.numBadHcalCells += 1;
451  }
452 
453  else if (0.5*energy >= threshold) { // not bad channel: use energy if above threshold
454 
455  CaloTowerDetId towerDetId = theTowerConstituentsMap->towerOf(detId);
456  if (towerDetId.null()) return;
457  MetaTower & tower28 = find(towerDetId);
458  CaloTowerDetId towerDetId29(towerDetId.ieta()+towerDetId.zside(),
459  towerDetId.iphi());
460  MetaTower & tower29 = find(towerDetId29);
461 
462  if (chStatusForCT == CaloTowersCreationAlgo::RecoveredChan) {
463  tower28.numRecHcalCells += 1;
464  tower29.numRecHcalCells += 1;
465  }
466  else if (chStatusForCT == CaloTowersCreationAlgo::ProblematicChan) {
467  tower28.numProbHcalCells += 1;
468  tower29.numProbHcalCells += 1;
469  }
470 
471  // NOTE DIVIDE BY 2!!!
472  double e28 = 0.5 * e;
473  double e29 = 0.5 * e;
474 
475  tower28.E_had += e28;
476  tower28.E += e28;
477  std::pair<DetId,float> mc(detId,e28);
478  tower28.metaConstituents.push_back(mc);
479 
480  tower29.E_had += e29;
481  tower29.E += e29;
482  tower29.metaConstituents.push_back(mc);
483 
484  // time info: do not use in averaging if timing error is found: need
485  // full set of status info to implement: use only "good" channels for now
486 
487  if (chStatusForCT == CaloTowersCreationAlgo::GoodChan) {
488  tower28.hadSumTimeTimesE += ( e28 * recHit->time() );
489  tower28.hadSumEForTime += e28;
490  tower29.hadSumTimeTimesE += ( e29 * recHit->time() );
491  tower29.hadSumEForTime += e29;
492  }
493 
494  // store the energy in layer 3 also in E_outer
495  tower28.E_outer += e28;
496  tower29.E_outer += e29;
497  } // not a "bad" hit
498 
499  } // end of special case
500 
501  else {
502  HcalDetId hcalDetId(detId);
503 
505 
506  if(hcalDetId.subdet() == HcalOuter) {
507 
508  CaloTowerDetId towerDetId = theTowerConstituentsMap->towerOf(detId);
509  if (towerDetId.null()) return;
510  MetaTower & tower = find(towerDetId);
511 
512  if (chStatusForCT == CaloTowersCreationAlgo::BadChan) {
513  if (theHOIsUsed) tower.numBadHcalCells += 1;
514  }
515 
516  else if (energy >= threshold) {
517  tower.E_outer += e; // store HO energy even if HO is not used
518  // add energy of the tower and/or flag if theHOIsUsed
519  if(theHOIsUsed) {
520  tower.E += e;
521 
522  if (chStatusForCT == CaloTowersCreationAlgo::RecoveredChan) {
523  tower.numRecHcalCells += 1;
524  }
525  else if (chStatusForCT == CaloTowersCreationAlgo::ProblematicChan) {
526  tower.numProbHcalCells += 1;
527  }
528  } // HO is used
529 
530 
531  // add HO to constituents even if it is not used: JetMET wants to keep these towers
532  std::pair<DetId,float> mc(detId,e);
533  tower.metaConstituents.push_back(mc);
534 
535  } // not a bad channel, energy above threshold
536 
537  } // HO hit
538 
539  // HF calculates EM fraction differently
540  else if(hcalDetId.subdet() == HcalForward) {
541 
542  if (chStatusForCT == CaloTowersCreationAlgo::BadChan) {
543  CaloTowerDetId towerDetId = theTowerConstituentsMap->towerOf(detId);
544  if (towerDetId.null()) return;
545  MetaTower & tower = find(towerDetId);
546  tower.numBadHcalCells += 1;
547  }
548 
549  else if (energy >= threshold) {
550  CaloTowerDetId towerDetId = theTowerConstituentsMap->towerOf(detId);
551  if (towerDetId.null()) return;
552  MetaTower & tower = find(towerDetId);
553 
554  if (hcalDetId.depth() == 1) {
555  // long fiber, so E_EM = E(Long) - E(Short)
556  tower.E_em += e;
557  }
558  else {
559  // short fiber, EHAD = 2 * E(Short)
560  tower.E_em -= e;
561  tower.E_had += 2. * e;
562  }
563  tower.E += e;
564  if (chStatusForCT == CaloTowersCreationAlgo::RecoveredChan) {
565  tower.numRecHcalCells += 1;
566  }
567  else if (chStatusForCT == CaloTowersCreationAlgo::ProblematicChan) {
568  tower.numProbHcalCells += 1;
569  }
570 
571  // put the timing in HCAL -> have to check timing errors when available
572  // for now use only good channels
573  if (chStatusForCT == CaloTowersCreationAlgo::GoodChan) {
574  tower.hadSumTimeTimesE += ( e * recHit->time() );
575  tower.hadSumEForTime += e;
576  }
577 
578  std::pair<DetId,float> mc(detId,e);
579  tower.metaConstituents.push_back(mc);
580 
581  } // not a bad HF channel, energy above threshold
582 
583  } // HF hit
584 
585  else {
586  // HCAL situation normal in HB/HE
587  if (chStatusForCT == CaloTowersCreationAlgo::BadChan) {
588  CaloTowerDetId towerDetId = theTowerConstituentsMap->towerOf(detId);
589  if (towerDetId.null()) return;
590  MetaTower & tower = find(towerDetId);
591  tower.numBadHcalCells += 1;
592  }
593  else if (energy >= threshold) {
594  CaloTowerDetId towerDetId = theTowerConstituentsMap->towerOf(detId);
595  if (towerDetId.null()) return;
596  MetaTower & tower = find(towerDetId);
597  tower.E_had += e;
598  tower.E += e;
599  if (chStatusForCT == CaloTowersCreationAlgo::RecoveredChan) {
600  tower.numRecHcalCells += 1;
601  }
602  else if (chStatusForCT == CaloTowersCreationAlgo::ProblematicChan) {
603  tower.numProbHcalCells += 1;
604  }
605 
606  // Timing information: need specific accessors
607  // for now use only good channels
608  if (chStatusForCT == CaloTowersCreationAlgo::GoodChan) {
609  tower.hadSumTimeTimesE += ( e * recHit->time() );
610  tower.hadSumEForTime += e;
611  }
612  // store energy in highest depth for towers 18-27 (for electron,photon ID in endcap)
613  // also, store energy in HE part of tower 16 (for JetMET cleanup)
614  HcalDetId hcalDetId(detId);
615  if (hcalDetId.subdet()==HcalEndcap) {
616  if ( (hcalDetId.depth()==2 && hcalDetId.ietaAbs()>=18 && hcalDetId.ietaAbs()<27) ||
617  (hcalDetId.depth()==3 && hcalDetId.ietaAbs()==27) ||
618  (hcalDetId.depth()==3 && hcalDetId.ietaAbs()==16) ) {
619  tower.E_outer += e;
620  }
621  }
622 
623  std::pair<DetId,float> mc(detId,e);
624  tower.metaConstituents.push_back(mc);
625 
626  } // not a "bad" channel, energy above threshold
627 
628  } // channel in HBHE (excluding twrs 28,29)
629 
630  } // recHit normal case (not in HE towers 28,29)
631 
632 } // end of assignHitHcal method
633 
635  DetId detId = recHit->detid();
636 
637  unsigned int chStatusForCT;
638  bool ecalIsBad=false;
639  std::tie(chStatusForCT,ecalIsBad) = ecalChanStatusForCaloTower(recHit);
640 
641  // this is for skipping channls: mostly needed for the creation of
642  // bad towers from hits i the bad channel collections.
643  if (chStatusForCT==CaloTowersCreationAlgo::IgnoredChan) return;
644 
645  double threshold, weight;
646  getThresholdAndWeight(detId, threshold, weight);
647 
648  double energy = recHit->energy(); // original RecHit energy is used to apply thresholds
649  double e = energy * weight; // energies scaled by user weight: used in energy assignments
650 
652 
653  // For ECAL we count all bad channels after the metatower is complete
654 
655  // Include options for symmetric thresholds and cut on Et
656  // for ECAL RecHits
657 
658  bool passEmThreshold = false;
659 
660  if (detId.subdetId() == EcalBarrel) {
661  if (theUseEtEBTresholdFlag) energy /= cosh( (theGeometry->getGeometry(detId)->getPosition()).eta() ) ;
662  if (theUseSymEBTresholdFlag) passEmThreshold = (fabs(energy) >= threshold);
663  else passEmThreshold = (energy >= threshold);
664 
665  }
666  else if (detId.subdetId() == EcalEndcap) {
667  if (theUseEtEETresholdFlag) energy /= cosh( (theGeometry->getGeometry(detId)->getPosition()).eta() ) ;
668  if (theUseSymEETresholdFlag) passEmThreshold = (fabs(energy) >= threshold);
669  else passEmThreshold = (energy >= threshold);
670  }
671 
672  CaloTowerDetId towerDetId = theTowerConstituentsMap->towerOf(detId);
673  if (towerDetId.null()) return;
674  MetaTower & tower = find(towerDetId);
675 
676 
677  // count bad cells and avoid double counting with those from DB (Recovered are counted bad)
678 
679  // somehow misses some
680  // if ( (chStatusForCT == CaloTowersCreationAlgo::BadChan) & (!ecalIsBad) ) ++tower.numBadEcalCells;
681 
682  // a bit slower...
683  if ( chStatusForCT == CaloTowersCreationAlgo::BadChan ) {
684  auto thisEcalSevLvl = theEcalSevLvlAlgo->severityLevel(detId);
685  // check if the Ecal severity is ok to keep
686  auto sevit = std::find(theEcalSeveritiesToBeExcluded.begin(),
688  thisEcalSevLvl);
689  if (sevit==theEcalSeveritiesToBeExcluded.end()) ++tower.numBadEcalCells; // notinDB
690  }
691 
692 
693  // if (chStatusForCT != CaloTowersCreationAlgo::BadChan && energy >= threshold) {
694  if (chStatusForCT != CaloTowersCreationAlgo::BadChan && passEmThreshold) {
695 
696  tower.E_em += e;
697  tower.E += e;
698 
699  if (chStatusForCT == CaloTowersCreationAlgo::RecoveredChan) {
700  tower.numRecEcalCells += 1;
701  }
702  else if (chStatusForCT == CaloTowersCreationAlgo::ProblematicChan) {
703  tower.numProbEcalCells += 1;
704  }
705 
706  // change when full status info is available
707  // for now use only good channels
708 
709  // add e>0 check (new options allow e<0)
710  if (chStatusForCT == CaloTowersCreationAlgo::GoodChan && e>0 ) {
711  tower.emSumTimeTimesE += ( e * recHit->time() );
712  tower.emSumEForTime += e; // see above
713  }
714 
715  std::pair<DetId,float> mc(detId,e);
716  tower.metaConstituents.push_back(mc);
717  }
718 } // end of assignHitEcal method
719 
720 
721 
722 
723 // This method is not flexible enough for the new CaloTower format.
724 // For now make a quick compatibility "fix" : WILL NOT WORK CORRECTLY with anything
725 // except the default simple p4 assignment!!!
726 // Must be rewritten for full functionality.
728  double threshold, weight;
729  CaloTowerDetId towerDetId = theTowerConstituentsMap->towerOf(ct->id());
730  if (towerDetId.null()) return;
731  MetaTower & tower = find(towerDetId);
732 
733  tower.E_em = 0.;
734  tower.E_had = 0.;
735  tower.E_outer = 0.;
736  for (unsigned int i=0; i<ct->constituentsSize(); i++) {
737  DetId detId = ct->constituent(i);
738  getThresholdAndWeight(detId, threshold, weight);
739  DetId::Detector det = detId.det();
740  if(det == DetId::Ecal) {
741  tower.E_em = ct->emEnergy()*weight;
742  }
743  else {
744  HcalDetId hcalDetId(detId);
745  if(hcalDetId.subdet() == HcalForward) {
746  if (hcalDetId.depth()==1) tower.E_em = ct->emEnergy()*weight;
747  if (hcalDetId.depth()==2) tower.E_had = ct->hadEnergy()*weight;
748  }
749  else if(hcalDetId.subdet() == HcalOuter) {
750  tower.E_outer = ct->outerEnergy()*weight;
751  }
752  else {
753  tower.E_had = ct->hadEnergy()*weight;
754  }
755  }
756  tower.E = tower.E_had+tower.E_em+tower.E_outer;
757 
758  // this is to be compliant with the new MetaTower setup
759  // used only for the default simple vector assignment
760  std::pair<DetId, float> mc(detId, 0);
761  tower.metaConstituents.push_back(mc);
762  }
763 
764  // preserve time inforamtion
765  tower.emSumTimeTimesE = ct->ecalTime();
766  tower.hadSumTimeTimesE = ct->hcalTime();
767  tower.emSumEForTime = 1.0;
768  tower.hadSumEForTime = 1.0;
769 }
770 
771 
773  if (theTowerMap.empty()) {
775  }
776 
777  auto & mt = theTowerMap[detId.denseIndex()];
778 
779  if (mt.empty()) {
780  mt.id=detId;
781  mt.metaConstituents.reserve(detId.ietaAbs()<30 ? 12 : 2);
782  ++theTowerMapSize;
783  }
784 
785  return mt;
786 }
787 
788 
791 {
792  assert(id.rawId()!=0);
793 
794  double ecalThres=(id.ietaAbs()<=17)?(theEBSumThreshold):(theEESumThreshold);
795  double E=mt.E;
796  double E_em=mt.E_em;
797  double E_had=mt.E_had;
798  double E_outer=mt.E_outer;
799 
800  // Note: E_outer is used to save HO energy OR energy in the outermost depths in endcap region
801  // In the methods with separate treatment of EM and HAD components:
802  // - HO is not used to determine direction, however HO energy is added to get "total had energy"
803  // => Check if the tower is within HO coverage before adding E_outer to the "total had" energy
804  // else the energy will be double counted
805  // When summing up the energy of the tower these checks are performed in the loops over RecHits
806 
807  std::vector<std::pair<DetId,float> > metaContains=mt.metaConstituents;
808  if (id.ietaAbs()<=29 && E_em<ecalThres) { // ignore EM threshold in HF
809  E-=E_em;
810  E_em=0;
811  std::vector<std::pair<DetId,float> > metaContains_noecal;
812 
813  for (std::vector<std::pair<DetId,float> >::iterator i=metaContains.begin(); i!=metaContains.end(); ++i)
814  if (i->first.det()!=DetId::Ecal) metaContains_noecal.push_back(*i);
815  metaContains.swap(metaContains_noecal);
816  }
817  if (id.ietaAbs()<=29 && E_had<theHcalThreshold) {
818  E-=E_had;
819 
820  if (theHOIsUsed && id.ietaAbs()<16) E-=E_outer; // not subtracted before, think it should be done
821 
822  E_had=0;
823  E_outer=0;
824  std::vector<std::pair<DetId,float> > metaContains_nohcal;
825 
826  for (std::vector<std::pair<DetId,float> >::iterator i=metaContains.begin(); i!=metaContains.end(); ++i)
827  if (i->first.det()!=DetId::Hcal) metaContains_nohcal.push_back(*i);
828  metaContains.swap(metaContains_nohcal);
829  }
830 
831  if(metaContains.empty()) return;
832 
833  double E_had_tot = (theHOIsUsed && id.ietaAbs()<16)? E_had+E_outer : E_had;
834 
835 
836  // create CaloTower using the selected algorithm
837 
838  GlobalPoint emPoint, hadPoint;
839 
840  // this is actually a 4D vector
841  Basic3DVectorF towerP4;
842  bool massless=true;
843  // float mass1=0;
844  float mass2=0;
845 
846  // conditional assignment of depths for barrel/endcap
847  // Some additional tuning may be required in the transitional region
848  // 14<|iEta|<19
849  double momEmDepth = 0.;
850  double momHadDepth = 0.;
851  if (id.ietaAbs()<=17) {
852  momHadDepth = theMomHBDepth;
853  momEmDepth = theMomEBDepth;
854  }
855  else {
856  momHadDepth = theMomHEDepth;
857  momEmDepth = theMomEEDepth;
858  }
859 
860 
861 
862  switch (theMomConstrMethod) {
863 
864  // FIXME : move to simple cartesian algebra
865  case 0 :
866  { // Simple 4-momentum assignment
868  towerP4 = p.basicVector().unit();
869  towerP4[3] = 1.f; // energy
870  towerP4 *=E;
871 
872  // double pf=1.0/cosh(p.eta());
873  // if (E>0) towerP4 = CaloTower::PolarLorentzVector(E*pf, p.eta(), p.phi(), 0);
874 
875  emPoint = p;
876  hadPoint = p;
877  } // end case 0
878  break;
879 
880  case 1 :
881  { // separate 4-vectors for ECAL, HCAL, add to get the 4-vector of the tower (=>tower has mass!)
882  if (id.ietaAbs()<=29) {
883  Basic3DVectorF emP4;
884  if (E_em>0) {
885  emPoint = emShwrPos(metaContains, momEmDepth, E_em);
886  emP4 = emPoint.basicVector().unit();
887  emP4[3] = 1.f; // energy
888  towerP4 = emP4*E_em;
889 
890  // double emPf = 1.0/cosh(emPoint.eta());
891  // towerP4 += CaloTower::PolarLorentzVector(E_em*emPf, emPoint.eta(), emPoint.phi(), 0);
892  }
893  if ( (E_had + E_outer) >0) {
894  massless = (E_em<=0);
895  hadPoint = hadShwrPos(id, momHadDepth);
896  auto lP4 = hadPoint.basicVector().unit();
897  lP4[3] = 1.f; // energy
898  if (!massless) {
899  auto diff = lP4-emP4; mass2 = std::sqrt(E_em*E_had_tot*diff.mag2());
900  }
901  lP4 *=E_had_tot;
902  towerP4 +=lP4;
903  /*
904  if (!massless) {
905  auto p = towerP4;
906  double m2 = double(p[3]*p[3]) - double(p[0]*p[0])+double(p[1]*p[1])+double(p[2]*p[2]); mass1 = m2>0 ? std::sqrt(m2) : 0;
907  }
908  */
909  // double hadPf = 1.0/cosh(hadPoint.eta());
910  // if (E_had_tot>0) {
911  // towerP4 += CaloTower::PolarLorentzVector(E_had_tot*hadPf, hadPoint.eta(), hadPoint.phi(), 0);
912  // }
913  }
914  }
915  else { // forward detector: use the CaloTower position
917  towerP4 = p.basicVector().unit();
918  towerP4[3] = 1.f; // energy
919  towerP4 *=E;
920  // double pf=1.0/cosh(p.eta());
921  // if (E>0) towerP4 = CaloTower::PolarLorentzVector(E*pf, p.eta(), p.phi(), 0); // simple momentum assignment, same position
922  emPoint = p;
923  hadPoint = p;
924  }
925  } // end case 1
926  break;
927 
928  case 2:
929  { // use ECAL position for the tower (when E_cal>0), else default CaloTower position (massless tower)
930  if (id.ietaAbs()<=29) {
931  if (E_em>0) emPoint = emShwrLogWeightPos(metaContains, momEmDepth, E_em);
932  else emPoint = theTowerGeometry->getGeometry(id)->getPosition();
933  towerP4 = emPoint.basicVector().unit();
934  towerP4[3] = 1.f; // energy
935  towerP4 *=E;
936 
937  // double sumPf = 1.0/cosh(emPoint.eta());
939 
940  hadPoint = emPoint;
941  }
942  else { // forward detector: use the CaloTower position
944  towerP4 = p.basicVector().unit();
945  towerP4[3] = 1.f; // energy
946  towerP4 *=E;
947 
948  // double pf=1.0/cosh(p.eta());
949  // if (E>0) towerP4 = CaloTower::PolarLorentzVector(E*pf, p.eta(), p.phi(), 0); // simple momentum assignment, same position
950  emPoint = p;
951  hadPoint = p;
952  }
953  } // end case 2
954  break;
955 
956  } // end of decision on p4 reconstruction method
957 
958 
959  // insert in collection (remove and return if below threshold)
960  if unlikely ( (towerP4[3]==0) & (E_outer>0) ) {
961  collection.emplace_back(id, E_em, E_had, E_outer, -1, -1, CaloTower::PolarLorentzVector(0,hadPoint.eta(), hadPoint.phi(),0), emPoint, hadPoint);
962  } else {
963  collection.emplace_back(id, E_em, E_had, E_outer, -1, -1, GlobalVector(towerP4), towerP4[3], mass2, emPoint, hadPoint);
964  }
965  auto & caloTower = collection.back();
966 
967  // if (!massless) std::cout << "massive " << id <<' ' << mass1 <<' ' << mass2 <<' ' << caloTower.mass() << std::endl;
968  // std::cout << "CaloTowerVI " <<theMomConstrMethod <<' ' << id <<' '<< E_em <<' '<< E_had <<' '<< E_outer <<' '<< GlobalVector(towerP4) <<' '<< towerP4[3] <<' '<< emPoint <<' '<< hadPoint << std::endl;
969  //if (towerP4[3]==0) std::cout << "CaloTowerVIzero " << theEcutTower << ' ' << collection.back().eta() <<' '<< collection.back().phi() << std::endl;
970 
971  if(caloTower.energy() < theEcutTower) { collection.pop_back(); return;}
972 
973  // set the timings
974  float ecalTime = (mt.emSumEForTime>0)? mt.emSumTimeTimesE/mt.emSumEForTime : -9999;
975  float hcalTime = (mt.hadSumEForTime>0)? mt.hadSumTimeTimesE/mt.hadSumEForTime : -9999;
976  caloTower.setEcalTime(compactTime(ecalTime));
977  caloTower.setHcalTime(compactTime(hcalTime));
978 
979  // set the CaloTower status word =====================================
980  // Channels must be counter exclusively in the defined cathegories
981  // "Bad" channels (not used in energy assignment) can be flagged during
982  // CaloTower creation only if specified in the configuration file
983 
984  unsigned int numBadHcalChan = mt.numBadHcalCells;
985  // unsigned int numBadEcalChan = mt.numBadEcalCells;
986  unsigned int numBadEcalChan = 0; //
987 
988  unsigned int numRecHcalChan = mt.numRecHcalCells;
989  unsigned int numRecEcalChan = mt.numRecEcalCells;
990  unsigned int numProbHcalChan = mt.numProbHcalCells;
991  unsigned int numProbEcalChan = mt.numProbEcalCells;
992 
993  // now add dead/off/... channels not used in RecHit reconstruction for HCAL
994  HcalDropChMap::iterator dropChItr = hcalDropChMap.find(id);
995  if (dropChItr != hcalDropChMap.end()) numBadHcalChan += dropChItr->second;
996 
997 
998  // for ECAL the number of all bad channels is obtained here -----------------------
999 
1000  /*
1001  // old hyper slow algorithm
1002  // get all possible constituents of the tower
1003  std::vector<DetId> allConstituents = theTowerConstituentsMap->constituentsOf(id);
1004 
1005  for (std::vector<DetId>::iterator ac_it=allConstituents.begin();
1006  ac_it!=allConstituents.end(); ++ac_it) {
1007 
1008  if (ac_it->det()!=DetId::Ecal) continue;
1009 
1010  int thisEcalSevLvl = -999;
1011 
1012  if (ac_it->subdetId() == EcalBarrel && theEbHandle.isValid()) {
1013  thisEcalSevLvl = theEcalSevLvlAlgo->severityLevel( *ac_it, *theEbHandle);//, *theEcalChStatus);
1014  }
1015  else if (ac_it->subdetId() == EcalEndcap && theEeHandle.isValid()) {
1016  thisEcalSevLvl = theEcalSevLvlAlgo->severityLevel( *ac_it, *theEeHandle);//, *theEcalChStatus);
1017  }
1018 
1019  // check if the Ecal severity is ok to keep
1020  std::vector<int>::const_iterator sevit = std::find(theEcalSeveritiesToBeExcluded.begin(),
1021  theEcalSeveritiesToBeExcluded.end(),
1022  thisEcalSevLvl);
1023  if (sevit!=theEcalSeveritiesToBeExcluded.end()) {
1024  ++numBadEcalChan;
1025  }
1026 
1027  }
1028 
1029  // compare with fast version
1030 
1031  // hcal:
1032  int inEcals[2] = {0,0};
1033  for (std::vector<std::pair<DetId,float> >::iterator i=metaContains.begin(); i!=metaContains.end(); ++i) {
1034  DetId detId = i->first;
1035  if(detId.det() == DetId::Ecal){
1036  if( detId.subdetId()==EcalBarrel ) inEcals[0] =1;
1037  else if( detId.subdetId()==EcalEndcap ) inEcals[1] =1;
1038  }
1039  }
1040 
1041  auto numBadEcalChanNew = ecalBadChs[id.denseIndex()]+mt.numBadEcalCells; // - mt.numRecEcalCells
1042  if (int(numBadEcalChanNew)!=int(numBadEcalChan)) {
1043  std::cout << "VI wrong " << ((inEcals[1]==1) ? "EE" : "" ) << id << " " << numBadEcalChanNew << " " << numBadEcalChan
1044  << " " << mt.numBadEcalCells << " " << mt.numRecEcalCells << std::endl;
1045  }
1046  */
1047 
1048  numBadEcalChan = ecalBadChs[id.denseIndex()]+mt.numBadEcalCells; // - mt.numRecEcalCells
1049 
1050  //--------------------------------------------------------------------------------------
1051 
1052  caloTower.setCaloTowerStatus(numBadHcalChan, numBadEcalChan,
1053  numRecHcalChan, numRecEcalChan,
1054  numProbHcalChan, numProbEcalChan);
1055 
1056  double maxCellE = -999.0; // for storing the hottest cell E in the calotower
1057 
1058  std::vector<DetId> contains;
1059  contains.reserve(metaContains.size());
1060  for (std::vector<std::pair<DetId,float> >::iterator i=metaContains.begin(); i!=metaContains.end(); ++i) {
1061 
1062  contains.push_back(i->first);
1063 
1064  if (maxCellE < i->second) {
1065  // need an extra check because of the funny towers that are empty except for the presence of an HO
1066  // hit in the constituents (JetMET wanted them saved)
1067  // This constituent is only used for storing the tower, but should not be concidered as a hot cell canditate for
1068  // configurations with useHO = false
1069 
1070 
1071  if (i->first.det()==DetId::Ecal) { // ECAL
1072  maxCellE = i->second;
1073  }
1074  else { // HCAL
1075  if (HcalDetId(i->first).subdet() != HcalOuter)
1076  maxCellE = i->second;
1077  else if (theHOIsUsed) maxCellE = i->second;
1078  }
1079 
1080  } // found higher E cell
1081 
1082  } // loop over matacontains
1083 
1084  caloTower.setConstituents(std::move(contains));
1085  caloTower.setHottestCellE(maxCellE);
1086 
1087  // std::cout << "CaloTowerVI " << nalgo << ' ' << caloTower.id() << ((inEcals[1]==1) ? "EE " : " " ) << caloTower.pt() << ' ' << caloTower.et() << ' ' << caloTower.mass() << ' '
1088  // << caloTower.constituentsSize() <<' '<< caloTower.towerStatusWord() << std::endl;
1089 
1090 }
1091 
1092 
1093 
1094 void CaloTowersCreationAlgo::getThresholdAndWeight(const DetId & detId, double & threshold, double & weight) const {
1095  DetId::Detector det = detId.det();
1096  weight=0; // in case the hit is not identified
1097 
1098  if(det == DetId::Ecal) {
1099  // may or may not be EB. We'll find out.
1100 
1101  EcalSubdetector subdet = (EcalSubdetector)(detId.subdetId());
1102  if(subdet == EcalBarrel) {
1103  threshold = theEBthreshold;
1104  weight = theEBweight;
1105  if (weight <= 0.) {
1106  ROOT::Math::Interpolator my(theEBGrid,theEBWeights,ROOT::Math::Interpolation::kAKIMA);
1107  weight = my.Eval(theEBEScale);
1108  }
1109  }
1110  else if(subdet == EcalEndcap) {
1111  threshold = theEEthreshold;
1112  weight = theEEweight;
1113  if (weight <= 0.) {
1114  ROOT::Math::Interpolator my(theEEGrid,theEEWeights,ROOT::Math::Interpolation::kAKIMA);
1115  weight = my.Eval(theEEEScale);
1116  }
1117  }
1118  }
1119  else if(det == DetId::Hcal) {
1120  HcalDetId hcalDetId(detId);
1121  HcalSubdetector subdet = hcalDetId.subdet();
1122 
1123  if(subdet == HcalBarrel) {
1124  threshold = theHBthreshold;
1125  weight = theHBweight;
1126  if (weight <= 0.) {
1127  ROOT::Math::Interpolator my(theHBGrid,theHBWeights,ROOT::Math::Interpolation::kAKIMA);
1128  weight = my.Eval(theHBEScale);
1129  }
1130  }
1131 
1132  else if(subdet == HcalEndcap) {
1133  // check if it's single or double tower
1134  if(hcalDetId.ietaAbs() < theHcalTopology->firstHEDoublePhiRing()) {
1135  threshold = theHESthreshold;
1136  weight = theHESweight;
1137  if (weight <= 0.) {
1138  ROOT::Math::Interpolator my(theHESGrid,theHESWeights,ROOT::Math::Interpolation::kAKIMA);
1139  weight = my.Eval(theHESEScale);
1140  }
1141  }
1142  else {
1143  threshold = theHEDthreshold;
1144  weight = theHEDweight;
1145  if (weight <= 0.) {
1146  ROOT::Math::Interpolator my(theHEDGrid,theHEDWeights,ROOT::Math::Interpolation::kAKIMA);
1147  weight = my.Eval(theHEDEScale);
1148  }
1149  }
1150  }
1151 
1152  else if(subdet == HcalOuter) {
1153  //check if it's ring 0 or +1 or +2 or -1 or -2
1154  if(hcalDetId.ietaAbs() <= 4) threshold = theHOthreshold0;
1155  else if(hcalDetId.ieta() < 0) {
1156  // set threshold for ring -1 or -2
1157  threshold = (hcalDetId.ietaAbs() <= 10) ? theHOthresholdMinus1 : theHOthresholdMinus2;
1158  } else {
1159  // set threshold for ring +1 or +2
1160  threshold = (hcalDetId.ietaAbs() <= 10) ? theHOthresholdPlus1 : theHOthresholdPlus2;
1161  }
1162  weight = theHOweight;
1163  if (weight <= 0.) {
1164  ROOT::Math::Interpolator my(theHOGrid,theHOWeights,ROOT::Math::Interpolation::kAKIMA);
1165  weight = my.Eval(theHOEScale);
1166  }
1167  }
1168 
1169  else if(subdet == HcalForward) {
1170  if(hcalDetId.depth() == 1) {
1171  threshold = theHF1threshold;
1172  weight = theHF1weight;
1173  if (weight <= 0.) {
1174  ROOT::Math::Interpolator my(theHF1Grid,theHF1Weights,ROOT::Math::Interpolation::kAKIMA);
1175  weight = my.Eval(theHF1EScale);
1176  }
1177  } else {
1178  threshold = theHF2threshold;
1179  weight = theHF2weight;
1180  if (weight <= 0.) {
1181  ROOT::Math::Interpolator my(theHF2Grid,theHF2Weights,ROOT::Math::Interpolation::kAKIMA);
1182  weight = my.Eval(theHF2EScale);
1183  }
1184  }
1185  }
1186  }
1187  else {
1188  edm::LogError("CaloTowersCreationAlgo") << "Bad cell: " << det << std::endl;
1189  }
1190 }
1191 
1193  if (scale>0.00001) *&theEBEScale = scale;
1194  else *&theEBEScale = 50.;
1195 }
1196 
1198  if (scale>0.00001) *&theEEEScale = scale;
1199  else *&theEEEScale = 50.;
1200 }
1201 
1203  if (scale>0.00001) *&theHBEScale = scale;
1204  else *&theHBEScale = 50.;
1205 }
1206 
1208  if (scale>0.00001) *&theHESEScale = scale;
1209  else *&theHESEScale = 50.;
1210 }
1211 
1213  if (scale>0.00001) *&theHEDEScale = scale;
1214  else *&theHEDEScale = 50.;
1215 }
1216 
1218  if (scale>0.00001) *&theHOEScale = scale;
1219  else *&theHOEScale = 50.;
1220 }
1221 
1223  if (scale>0.00001) *&theHF1EScale = scale;
1224  else *&theHF1EScale = 50.;
1225 }
1226 
1228  if (scale>0.00001) *&theHF2EScale = scale;
1229  else *&theHF2EScale = 50.;
1230 }
1231 
1232 
1234  const CaloCellGeometry* cellGeometry = theGeometry->getGeometry(detId);
1235  GlobalPoint point = cellGeometry->getPosition(); // face of the cell
1236 
1237  if (fracDepth<=0) return point;
1238  if (fracDepth>1) fracDepth=1;
1239 
1240  GlobalPoint backPoint = cellGeometry->getBackPoint();
1241  point += fracDepth * (backPoint-point);
1242 
1243  return point;
1244 }
1245 
1247  // same code as above
1248  return emCrystalShwrPos(detId, fracDepth);
1249 }
1250 
1251 
1252 GlobalPoint CaloTowersCreationAlgo::hadShwrPos(const std::vector<std::pair<DetId,float> >& metaContains,
1253  float fracDepth, double hadE) {
1254 
1255  // this is based on available RecHits, can lead to different actual depths if
1256  // hits in multi-depth towers are not all there
1257  if (hadE<=0) return GlobalPoint(0,0,0);
1258 
1259  double hadX = 0.0;
1260  double hadY = 0.0;
1261  double hadZ = 0.0;
1262 
1263  int nConst = 0;
1264 
1265  std::vector<std::pair<DetId,float> >::const_iterator mc_it = metaContains.begin();
1266  for (; mc_it!=metaContains.end(); ++mc_it) {
1267  if (mc_it->first.det() != DetId::Hcal) continue;
1268  // do not use HO for deirection calculations for now
1269  if (HcalDetId(mc_it->first).subdet() == HcalOuter) continue;
1270  ++nConst;
1271 
1272  GlobalPoint p = hadSegmentShwrPos(mc_it->first, fracDepth);
1273 
1274  // longitudinal segmentation: do not weight by energy,
1275  // get the geometrical position
1276  hadX += p.x();
1277  hadY += p.y();
1278  hadZ += p.z();
1279  }
1280 
1281  return GlobalPoint(hadX/nConst, hadY/nConst, hadZ/nConst);
1282 }
1283 
1284 
1286 
1287  // set depth using geometry of cells that are associated with the
1288  // tower (regardless if they have non-zero energies)
1289 
1290 // if (hadE <= 0) return GlobalPoint(0, 0, 0);
1291 
1292  if (fracDepth < 0) fracDepth = 0;
1293  else if (fracDepth > 1) fracDepth = 1;
1294 
1295  GlobalPoint point(0,0,0);
1296 
1297  int iEta = towerId.ieta();
1298  int iPhi = towerId.iphi();
1299 
1300  HcalDetId frontCellId, backCellId;
1301 
1302  if (towerId.ietaAbs() <= 14) {
1303  // barrel, one depth only
1304  frontCellId = HcalDetId(HcalBarrel, iEta, iPhi, 1);
1305  backCellId = HcalDetId(HcalBarrel, iEta, iPhi, 1);
1306  }
1307  else if (towerId.ietaAbs() == 15) {
1308  // barrel, two depths
1309  frontCellId = HcalDetId(HcalBarrel, iEta, iPhi, 1);
1310  backCellId = HcalDetId(HcalBarrel, iEta, iPhi, 2);
1311  }
1312  else if (towerId.ietaAbs() == 16) {
1313  // barrel and endcap: two depths HB, one depth HE
1314  frontCellId = HcalDetId(HcalBarrel, iEta, iPhi, 1);
1315  backCellId = HcalDetId(HcalEndcap, iEta, iPhi, 3); // this cell is in endcap!
1316  }
1317  else if (towerId.ietaAbs() == 17) {
1318  // endcap, one depth only
1319  frontCellId = HcalDetId(HcalEndcap, iEta, iPhi, 1);
1320  backCellId = HcalDetId(HcalEndcap, iEta, iPhi, 1);
1321  }
1322  else if (towerId.ietaAbs() >= 18 && towerId.ietaAbs() <= 26) {
1323  // endcap: two depths
1324  frontCellId = HcalDetId(HcalEndcap, iEta, iPhi, 1);
1325  backCellId = HcalDetId(HcalEndcap, iEta, iPhi, 2);
1326  }
1327  else if (towerId.ietaAbs() <= 29) {
1328  // endcap: three depths
1329  frontCellId = HcalDetId(HcalEndcap, iEta, iPhi, 1);
1330  // there is no iEta=29 for depth 3
1331  if (iEta == 29) iEta = 28;
1332  if (iEta == -29) iEta = -28;
1333  backCellId = HcalDetId(HcalEndcap, iEta, iPhi, 3);
1334  }
1335  else if (towerId.ietaAbs() >= 30) {
1336  // forward, take the goemetry for long fibers
1337  frontCellId = HcalDetId(HcalForward, iEta, iPhi, 1);
1338  backCellId = HcalDetId(HcalForward, iEta, iPhi, 1);
1339  }
1340  else {
1341  // should not get here
1342  return point;
1343  }
1344 
1345  point = hadShwPosFromCells(DetId(frontCellId), DetId(backCellId), fracDepth);
1346 
1347  return point;
1348 }
1349 
1350 GlobalPoint CaloTowersCreationAlgo::hadShwPosFromCells(DetId frontCellId, DetId backCellId, float fracDepth) {
1351 
1352  // uses the "front" and "back" cells
1353  // to determine the axis. point set by the predefined depth.
1354 
1355  const CaloCellGeometry* frontCellGeometry = theGeometry->getGeometry(DetId(frontCellId));
1356  const CaloCellGeometry* backCellGeometry = theGeometry->getGeometry(DetId(backCellId));
1357 
1358  GlobalPoint point = frontCellGeometry->getPosition();
1359  GlobalPoint backPoint = backCellGeometry->getBackPoint();
1360 
1361  point += fracDepth * (backPoint - point);
1362 
1363  return point;
1364 }
1365 
1366 
1367 GlobalPoint CaloTowersCreationAlgo::emShwrPos(const std::vector<std::pair<DetId,float> >& metaContains,
1368  float fracDepth, double emE) {
1369 
1370  if (emE<=0) return GlobalPoint(0,0,0);
1371 
1372  double emX = 0.0;
1373  double emY = 0.0;
1374  double emZ = 0.0;
1375 
1376  double eSum = 0;
1377 
1378  std::vector<std::pair<DetId,float> >::const_iterator mc_it = metaContains.begin();
1379  for (; mc_it!=metaContains.end(); ++mc_it) {
1380  if (mc_it->first.det() != DetId::Ecal) continue;
1381  GlobalPoint p = emCrystalShwrPos(mc_it->first, fracDepth);
1382  double e = mc_it->second;
1383 
1384  if (e>0) {
1385  emX += p.x() * e;
1386  emY += p.y() * e;
1387  emZ += p.z() * e;
1388  eSum += e;
1389  }
1390 
1391  }
1392 
1393  return GlobalPoint(emX/eSum, emY/eSum, emZ/eSum);
1394 }
1395 
1396 
1397 GlobalPoint CaloTowersCreationAlgo::emShwrLogWeightPos(const std::vector<std::pair<DetId,float> >& metaContains,
1398  float fracDepth, double emE) {
1399 
1400  double emX = 0.0;
1401  double emY = 0.0;
1402  double emZ = 0.0;
1403 
1404  double weight = 0;
1405  double sumWeights = 0;
1406  double sumEmE = 0; // add crystals with E/E_EM > 1.5%
1407  double crystalThresh = 0.015 * emE;
1408 
1409  std::vector<std::pair<DetId,float> >::const_iterator mc_it = metaContains.begin();
1410  for (; mc_it!=metaContains.end(); ++mc_it) {
1411  if (mc_it->second < 0) continue;
1412  if (mc_it->first.det() == DetId::Ecal && mc_it->second > crystalThresh) sumEmE += mc_it->second;
1413  }
1414 
1415  for (mc_it = metaContains.begin(); mc_it!=metaContains.end(); ++mc_it) {
1416 
1417  if (mc_it->first.det() != DetId::Ecal || mc_it->second < crystalThresh) continue;
1418 
1419  GlobalPoint p = emCrystalShwrPos(mc_it->first, fracDepth);
1420 
1421  weight = 4.2 + log(mc_it->second/sumEmE);
1422  sumWeights += weight;
1423 
1424  emX += p.x() * weight;
1425  emY += p.y() * weight;
1426  emZ += p.z() * weight;
1427  }
1428 
1429  return GlobalPoint(emX/sumWeights, emY/sumWeights, emZ/sumWeights);
1430 }
1431 
1432 
1433 
1434 
1435 
1437 
1438  const float timeUnit = 0.01; // discretization (ns)
1439 
1440  if (time> 300.0) return 30000;
1441  if (time< -300.0) return -30000;
1442 
1443  return int(time/timeUnit + 0.5);
1444 
1445 }
1446 
1447 
1448 
1449 //========================================================
1450 //
1451 // Bad/anomolous cell handling
1452 
1453 
1454 
1455 
1457 
1458  // This method fills the map of number of dead channels for the calotower,
1459  // The key of the map is CaloTowerDetId.
1460  // By definition these channels are not going to be in the RecHit collections.
1461  hcalDropChMap.clear();
1462  std::vector<DetId> allChanInStatusCont = theHcalChStatus->getAllChannels();
1463 
1464  for (std::vector<DetId>::iterator it = allChanInStatusCont.begin(); it!=allChanInStatusCont.end(); ++it) {
1465 
1466  const uint32_t dbStatusFlag = theHcalChStatus->getValues(*it)->getValue();
1467 
1468  if (theHcalSevLvlComputer->dropChannel(dbStatusFlag)) {
1469 
1471 
1472  hcalDropChMap[twrId] +=1;
1473 
1474  // special case for tower 29: if HCAL hit is in depth 3 add to twr 29 as well
1475  if (HcalDetId(*it).subdet()==HcalEndcap &&
1476  HcalDetId(*it).depth()==3 &&
1477  HcalDetId(*it).ietaAbs()==28) {
1478 
1479  CaloTowerDetId twrId29(twrId.ieta()+twrId.zside(), twrId.iphi());
1480  hcalDropChMap[twrId29] +=1;
1481  }
1482 
1483  }
1484 
1485  }
1486 
1487 }
1488 
1489 
1491 
1492  // std::cout << "VI making EcalBadChs ";
1493 
1494  // for ECAL the number of all bad channels is obtained here -----------------------
1495 
1496  for (auto ind=0U; ind<CaloTowerDetId::kSizeForDenseIndexing; ++ind) {
1497 
1498  auto & numBadEcalChan = ecalBadChs[ind];
1499  numBadEcalChan=0;
1500  auto id = CaloTowerDetId::detIdFromDenseIndex(ind);
1501 
1502  // this is utterly slow... (can be optmized if really needed)
1503 
1504  // get all possible constituents of the tower
1505  std::vector<DetId> allConstituents = theTowerConstituentsMap->constituentsOf(id);
1506 
1507  for (std::vector<DetId>::iterator ac_it=allConstituents.begin();
1508  ac_it!=allConstituents.end(); ++ac_it) {
1509 
1510  if (ac_it->det()!=DetId::Ecal) continue;
1511 
1512  auto thisEcalSevLvl = theEcalSevLvlAlgo->severityLevel( *ac_it);
1513 
1514  // check if the Ecal severity is ok to keep
1515  std::vector<int>::const_iterator sevit = std::find(theEcalSeveritiesToBeExcluded.begin(),
1517  thisEcalSevLvl);
1518  if (sevit!=theEcalSeveritiesToBeExcluded.end()) {
1519  ++numBadEcalChan;
1520  }
1521  }
1522 
1523  // if (0!=numBadEcalChan) std::cout << id << ":" << numBadEcalChan << ", ";
1524  }
1525 
1526  /*
1527  int tot=0;
1528  for (auto ind=0U; ind<CaloTowerDetId::kSizeForDenseIndexing; ++ind) {
1529  if (ecalBadChs[ind]!=0) ++tot;
1530  }
1531  std::cout << " | " << tot << std::endl;
1532  */
1533 
1534 }
1535 
1536 
1538 
1540 
1541  const DetId id = hit->detid();
1542 
1543  const uint32_t recHitFlag = hit->flags();
1544  const uint32_t dbStatusFlag = theHcalChStatus->getValues(id)->getValue();
1545 
1546  int severityLevel = theHcalSevLvlComputer->getSeverityLevel(id, recHitFlag, dbStatusFlag);
1547  bool isRecovered = theHcalSevLvlComputer->recoveredRecHit(id, recHitFlag);
1548 
1549 
1550  // For use with hits rejected in the default reconstruction
1551  if (useRejectedHitsOnly) {
1552 
1553  if (!isRecovered) {
1554 
1555  if (severityLevel <= int(theHcalAcceptSeverityLevel) ||
1557  // this hit was either already accepted or is worse than
1558  }
1559  else {
1560 
1562  // skip recovered hits either because they were already used or because there was an explicit instruction
1564  }
1565  else if (useRejectedRecoveredHcalHits) {
1567  }
1568 
1569  } // recovered channels
1570 
1571  // clasify channels as problematic: no good hits are supposed to be present in the
1572  // extra rechit collections
1574 
1575  } // treatment of rejected hits
1576 
1577 
1578 
1579 
1580  // this is for the regular reconstruction sequence
1581 
1582  if (severityLevel == 0) return CaloTowersCreationAlgo::GoodChan;
1583 
1584  if (isRecovered) {
1585  return (theRecoveredHcalHitsAreUsed) ?
1587  }
1588  else {
1589  if (severityLevel > int(theHcalAcceptSeverityLevel)) {
1591  }
1592  else {
1594  }
1595  }
1596 
1597 }
1598 
1599 
1600 
1602 
1603  // const DetId id = hit->detid();
1604 
1605  // uint16_t dbStatus = theEcalChStatus->find(id)->getStatusCode();
1606  // uint32_t rhFlags = hit->flags();
1607  // int severityLevel = theEcalSevLvlAlgo->severityLevel(rhFlags, dbStatus);
1608  // The methods above will become private and cannot be usef for flagging ecal spikes.
1609  // Use the recommended interface - we leave the parameters for spilke removal to be specified by ECAL.
1610 
1611 
1612  // int severityLevel = 999;
1613 
1614  EcalRecHit const & rh = *reinterpret_cast<EcalRecHit const *>(hit);
1615  int severityLevel = theEcalSevLvlAlgo->severityLevel(rh);
1616 
1617 // if (id.subdetId() == EcalBarrel) severityLevel = theEcalSevLvlAlgo->severityLevel( id, *theEbHandle);//, *theEcalChStatus);
1618 // else if (id.subdetId() == EcalEndcap) severityLevel = theEcalSevLvlAlgo->severityLevel( id, *theEeHandle);//, *theEcalChStatus);
1619 
1620  // there should be no other ECAL types used in this reconstruction
1621 
1622  // The definition of ECAL severity levels uses categories that
1623  // are similar to the defined for CaloTower. (However, the categorization
1624  // for CaloTowers depends on the specified maximum acceptabel severity and therefore cannnot
1625  // be exact correspondence between the two. ECAL has additional categories describing modes of failure.)
1626  // This approach is different from the initial idea and from
1627  // the implementation for HCAL. Still make the logic similar to HCAL so that one has the ability to
1628  // exclude problematic channels as defined by ECAL.
1629  // For definitions of ECAL severity levels see RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgo.h
1630 
1631  bool isBad = (severityLevel == EcalSeverityLevel::kBad);
1632 
1633  bool isRecovered = (severityLevel == EcalSeverityLevel::kRecovered);
1634 
1635  // check if the severity is compatible with our configuration
1636  // This applies to the "default" tower cleaning
1637  std::vector<int>::const_iterator sevit = std::find(theEcalSeveritiesToBeExcluded.begin(),
1639  severityLevel);
1640  bool accepted = (sevit==theEcalSeveritiesToBeExcluded.end()) ;
1641 
1642  // For use with hits that were rejected in the regular reconstruction:
1643  // This is for creating calotowers with lower level of cleaning by merging
1644  // the information from the default towers and a collection of towers created from
1645  // bad rechits
1646 
1647 
1648  if (useRejectedHitsOnly) {
1649 
1650  if (!isRecovered) {
1651 
1652  if (accepted ||
1655  return std::make_tuple(CaloTowersCreationAlgo::IgnoredChan,isBad);
1656  // this hit was either already accepted, or is not eligible for inclusion
1657  }
1658  else {
1659 
1661  // skip recovered hits either because they were already used or because there was an explicit instruction
1662  return std::make_tuple(CaloTowersCreationAlgo::IgnoredChan,isBad);;
1663  }
1664  else if (useRejectedRecoveredEcalHits) {
1665  return std::make_tuple(CaloTowersCreationAlgo::RecoveredChan,isBad);
1666  }
1667 
1668  } // recovered channels
1669 
1670  // clasify channels as problematic
1671  return std::make_tuple(CaloTowersCreationAlgo::ProblematicChan,isBad);
1672 
1673  } // treatment of rejected hits
1674 
1675 
1676 
1677  // for normal reconstruction
1678  if (severityLevel == EcalSeverityLevel::kGood) return std::make_tuple(CaloTowersCreationAlgo::GoodChan,false);
1679 
1680  if (isRecovered) {
1681  return std::make_tuple( (theRecoveredEcalHitsAreUsed) ?
1683  }
1684  else {
1685  return std::make_tuple(accepted ? CaloTowersCreationAlgo::ProblematicChan : CaloTowersCreationAlgo::BadChan,isBad);
1686 
1687  }
1688 
1689 
1690 }
1691 
std::vector< double > theHBGrid
unsigned short ecalBadChs[CaloTowerDetId::kSizeForDenseIndexing]
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
const HcalChannelQuality * theHcalChStatus
size_t constituentsSize() const
Definition: CaloTower.h:89
const GlobalPoint & getBackPoint() const
bool contains(EventRange const &lh, EventID const &rh)
Definition: EventRange.cc:38
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:30
std::vector< std::pair< DetId, float > > metaConstituents
EcalSeverityLevel::SeverityLevel severityLevel(const DetId &id) const
Evaluate status from id use channelStatus from DB.
int ietaAbs() const
get the absolute value of the tower ieta
const DetId & detid() const
Definition: CaloRecHit.h:20
DetId constituent(size_t i) const
Definition: CaloTower.h:90
uint32_t denseIndex() const
void setCaloTowerStatus(unsigned int numBadHcalChan, unsigned int numBadEcalChan, unsigned int numRecHcalChan, unsigned int numRecEcalChan, unsigned int numProbHcalChan, unsigned int numProbEcalChan)
Definition: CaloTower.cc:199
std::vector< double > theHESGrid
std::vector< double > theHEDGrid
GlobalPoint emCrystalShwrPos(DetId detId, float fracDepth)
float ecalTime() const
Definition: CaloTower.h:165
void assignHitHcal(const CaloRecHit *recHit)
std::vector< int > theEcalSeveritiesToBeUsedInBadTowers
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: LeafCandidate.h:30
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
Basic3DVector unit() const
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
const DetId & detid() const
Definition: EcalRecHit.h:71
std::vector< HBHERecHit >::const_iterator const_iterator
T y() const
Definition: PV3DBase.h:63
GlobalPoint emShwrPos(const std::vector< std::pair< DetId, float > > &metaContains, float fracDepth, double totEmE)
void push_back(T const &t)
void finish(CaloTowerCollection &destCollection)
float time() const
Definition: EcalRecHit.h:70
const Item * getValues(DetId fId, bool throwOnFail=true) const
std::vector< double > theHOWeights
MetaTower & find(const CaloTowerDetId &id)
looks for a given tower in the internal cache. If it can&#39;t find it, it makes it.
T eta() const
std::vector< double > theEEGrid
void rescale(const CaloTower *ct)
float time() const
Definition: CaloRecHit.h:19
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
std::vector< DetId > constituentsOf(const CaloTowerDetId &id) const
Get the constituent detids for this tower id ( not yet implemented )
static CaloTowerDetId detIdFromDenseIndex(uint32_t din)
std::vector< double > theEEWeights
std::vector< double > theHESWeights
U second(std::pair< T, U > const &p)
GlobalPoint hadShwrPos(const std::vector< std::pair< DetId, float > > &metaContains, float fracDepth, double hadE)
#define unlikely(x)
Definition: Likely.h:21
const CaloSubdetectorGeometry * theTowerGeometry
int depth() const
get the tower depth
Definition: HcalDetId.h:40
void addConstituents(const std::vector< DetId > &ids)
Definition: CaloTower.cc:177
unsigned int hcalChanStatusForCaloTower(const CaloRecHit *hit)
CaloTowerDetId towerOf(const DetId &id) const
Get the tower id for this det id (or null if not known)
double emEnergy() const
Definition: CaloTower.h:94
std::vector< double > theHF2Grid
std::vector< double > theHEDWeights
void rescaleTowers(const CaloTowerCollection &ctInput, CaloTowerCollection &ctResult)
static const int SubdetId
float energy() const
Definition: CaloRecHit.h:17
std::vector< DetId > getAllChannels() const
T sqrt(T t)
Definition: SSEVec.h:48
T z() const
Definition: PV3DBase.h:64
bool recoveredRecHit(const DetId &myid, const uint32_t &myflag) const
tuple result
Definition: query.py:137
const CaloGeometry * theGeometry
uint32_t flags() const
Definition: CaloRecHit.h:21
int ieta() const
get the cell ieta
Definition: HcalDetId.h:36
GlobalPoint emShwrLogWeightPos(const std::vector< std::pair< DetId, float > > &metaContains, float fracDepth, double totEmE)
int iphi() const
get the tower iphi
HcalSubdetector
Definition: HcalAssistant.h:31
std::vector< double > theHOGrid
float energy() const
Definition: EcalRecHit.h:68
void assignHitEcal(const EcalRecHit *recHit)
adds a single hit to the tower
bool dropChannel(const uint32_t &mystatus) const
const CaloTowerConstituentsMap * theTowerConstituentsMap
void convert(const CaloTowerDetId &id, const MetaTower &mt, CaloTowerCollection &collection)
std::vector< double > theHF1Weights
int firstHEDoublePhiRing() const
Definition: HcalTopology.h:88
GlobalPoint hadSegmentShwrPos(DetId detId, float fracDepth)
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
unsigned towerId(DetId const &)
bool theHOIsUsed
only affects energy and ET calculation. HO is still recorded in the tower
void process(const HBHERecHitCollection &hbhe)
int ietaAbs() const
get the absolute value of the cell ieta
Definition: HcalDetId.h:34
double hadEnergy() const
Definition: CaloTower.h:95
const_iterator end() const
std::vector< double > theHBWeights
const HcalSeverityLevelComputer * theHcalSevLvlComputer
Definition: DetId.h:18
CaloTowerDetId id() const
Definition: CaloTower.h:87
float hcalTime() const
Definition: CaloTower.h:166
Detector
Definition: DetId.h:24
GlobalPoint hadShwPosFromCells(DetId frontCell, DetId backCell, float fracDepth)
bool null() const
is this a null id ?
Definition: DetId.h:45
int zside() const
get the z-side of the tower (1/-1)
void getThresholdAndWeight(const DetId &detId, double &threshold, double &weight) const
helper method to look up the appropriate threshold &amp; weight
int getSeverityLevel(const DetId &myid, const uint32_t &myflag, const uint32_t &mystatus) const
const HcalTopology * theHcalTopology
std::vector< int > theEcalSeveritiesToBeExcluded
T eta() const
Definition: PV3DBase.h:76
void setEcalTime(int t)
Definition: CaloTower.h:68
if(dp >Float(M_PI)) dp-
const EcalSeverityLevelAlgo * theEcalSevLvlAlgo
const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id.
Definition: CaloGeometry.cc:76
std::vector< double > theHF1Grid
void reserve(size_type n)
std::vector< double > theEBGrid
std::vector< double > theHF2Weights
volatile std::atomic< bool > shutdown_flag false
int ieta() const
get the tower ieta
int weight
Definition: histoStyle.py:50
uint32_t getValue() const
unsigned int theHcalAcceptSeverityLevelForRejectedHit
std::tuple< unsigned int, bool > ecalChanStatusForCaloTower(const EcalRecHit *hit)
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
void setHcalTime(int t)
Definition: CaloTower.h:69
void setGeometry(const CaloTowerConstituentsMap *cttopo, const HcalTopology *htopo, const CaloGeometry *geo)
EcalSubdetector
const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
T x() const
Definition: PV3DBase.h:62
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:56
std::vector< double > theEBWeights
*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
double outerEnergy() const
Definition: CaloTower.h:96
const_iterator begin() const
const_reference back() const
Global3DVector GlobalVector
Definition: GlobalVector.h:10
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Candidate.h:43