CMS 3D CMS Logo

HBHEIsolatedNoiseAlgos.cc
Go to the documentation of this file.
1 /*
2 Description: Isolation algorithms used to identify anomalous noise in the HB/HE.
3  These algorithms will be used to reflag HB/HE rechits as noise.
4 
5  There are 4 objects implemented here:
6  1) ObjectValidator
7  2) PhysicsTowerOrganizer
8  3) HBHEHitMap
9  4) HBHEHitMapOrganizer
10  See comments below for details.
11 
12 Original Author: John Paul Chou (Brown University)
13  Thursday, September 2, 2010
14 */
15 
17 
19 
28 
35 
37 //
38 // ObjectValidator
39 //
41 
43  HBThreshold_ = iConfig.getParameter<double>("HBThreshold");
44  HESThreshold_ = iConfig.getParameter<double>("HESThreshold");
45  HEDThreshold_ = iConfig.getParameter<double>("HEDThreshold");
46  EBThreshold_ = iConfig.getParameter<double>("EBThreshold");
47  EEThreshold_ = iConfig.getParameter<double>("EEThreshold");
48 
49  HcalAcceptSeverityLevel_ = iConfig.getParameter<uint32_t>("HcalAcceptSeverityLevel");
50  EcalAcceptSeverityLevel_ = iConfig.getParameter<uint32_t>("EcalAcceptSeverityLevel");
51  UseHcalRecoveredHits_ = iConfig.getParameter<bool>("UseHcalRecoveredHits");
52  UseEcalRecoveredHits_ = iConfig.getParameter<bool>("UseEcalRecoveredHits");
53  UseAllCombinedRechits_ = iConfig.getParameter<bool>("UseAllCombinedRechits");
54 
55  MinValidTrackPt_ = iConfig.getParameter<double>("MinValidTrackPt");
56  MinValidTrackPtBarrel_ = iConfig.getParameter<double>("MinValidTrackPtBarrel");
57  MinValidTrackNHits_ = iConfig.getParameter<int>("MinValidTrackNHits");
58 
59  theHcalChStatus_ = nullptr;
60  theEcalChStatus_ = nullptr;
61  theHcalSevLvlComputer_ = nullptr;
62  theEcalSevLvlAlgo_ = nullptr;
63  theEBRecHitCollection_ = nullptr;
64  theEERecHitCollection_ = nullptr;
65 
66  return;
67 }
68 
70 
72  assert(theHcalSevLvlComputer_ != nullptr && theHcalChStatus_ != nullptr);
73 
76  return true;
77 
78  // require the hit to pass a certain energy threshold
79  if (hit.id().subdet() == HcalBarrel && hit.energy() < HBThreshold_)
80  return false;
81  else if (hit.id().subdet() == HcalEndcap && hit.id().ietaAbs() <= 20 && hit.energy() < HESThreshold_)
82  return false;
83  else if (hit.id().subdet() == HcalEndcap && hit.id().ietaAbs() > 20 && hit.energy() < HEDThreshold_)
84  return false;
85 
86  // determine if the hit is good, bad, or recovered
87  const DetId id = hit.detid();
88  const uint32_t recHitFlag = hit.flags();
89  const uint32_t dbStatusFlag = theHcalChStatus_->getValues(id)->getValue();
90  int severityLevel = theHcalSevLvlComputer_->getSeverityLevel(id, recHitFlag, dbStatusFlag);
91  bool isRecovered = theHcalSevLvlComputer_->recoveredRecHit(id, recHitFlag);
92 
93  if (severityLevel == 0)
94  return true;
95  if (isRecovered)
96  return UseHcalRecoveredHits_;
97  if (severityLevel > static_cast<int>(HcalAcceptSeverityLevel_))
98  return false;
99  else
100  return true;
101 }
102 
104  assert(theEcalSevLvlAlgo_ != nullptr && theEcalChStatus_ != nullptr);
105 
106  // require the hit to pass a certain energy threshold
107  const DetId id = hit.detid();
108  if (id.subdetId() == EcalBarrel && hit.energy() < EBThreshold_)
109  return false;
110  else if (id.subdetId() == EcalEndcap && hit.energy() < EEThreshold_)
111  return false;
112 
113  // determine if the hit is good, bad, or recovered
114  int severityLevel = 999;
115  if (id.subdetId() == EcalBarrel && theEBRecHitCollection_ != nullptr)
117  hit); //id, *theEBRecHitCollection_, *theEcalChStatus_, 5., EcalSeverityLevelAlgo::kSwissCross, 0.95, 2., 15., 0.999);
118  else if (id.subdetId() == EcalEndcap && theEERecHitCollection_ != nullptr)
120  hit); //id, *theEERecHitCollection_, *theEcalChStatus_, 5., EcalSeverityLevelAlgo::kSwissCross, 0.95, 2., 15., 0.999);
121  else
122  return false;
123 
125  return true;
127  return UseEcalRecoveredHits_;
128  if (severityLevel > static_cast<int>(EcalAcceptSeverityLevel_))
129  return false;
130  else
131  return true;
132 }
133 
134 bool ObjectValidator::validTrack(const reco::Track& trk) const {
135  if (trk.pt() < MinValidTrackPt_)
136  return false;
137  if (trk.pt() < MinValidTrackPtBarrel_ && std::fabs(trk.momentum().eta()) < 1.479)
138  return false;
140  return false;
141  return true;
142 }
143 
145 //
146 // PhysicsTowerOrganizer
147 //
149 
151  const edm::Handle<HBHERecHitCollection>& hbhehitcoll_h,
152  const edm::Handle<EcalRecHitCollection>& ebhitcoll_h,
153  const edm::Handle<EcalRecHitCollection>& eehitcoll_h,
154  const edm::Handle<std::vector<reco::TrackExtrapolation> >& trackextrapcoll_h,
155  const ObjectValidatorAbs& objectvalidator,
156  const CaloTowerConstituentsMap& ctcm,
157  const CaloGeometry& geo) {
158  // get some geometries
161 
162  // do the HCAL hits
163  for (HBHERecHitCollection::const_iterator it = hbhehitcoll_h->begin(); it != hbhehitcoll_h->end(); ++it) {
164  const HBHERecHit* hit = &(*it);
165 
166  // check that the hit is valid
167  if (!objectvalidator.validHit(*hit))
168  continue;
169 
170  // add the hit to the organizer
171  CaloTowerDetId tid = ctcm.towerOf(hit->id());
172  insert_(tid, hit);
173  }
174 
175  // do the EB hits
176  for (EcalRecHitCollection::const_iterator it = ebhitcoll_h->begin(); it != ebhitcoll_h->end(); ++it) {
177  const EcalRecHit* hit = &(*it);
178 
179  if (!objectvalidator.validHit(*hit))
180  continue;
181  CaloTowerDetId tid = ctcm.towerOf(hit->id());
182  insert_(tid, hit);
183  }
184 
185  // do the EE hits
186  for (EcalRecHitCollection::const_iterator it = eehitcoll_h->begin(); it != eehitcoll_h->end(); ++it) {
187  const EcalRecHit* hit = &(*it);
188 
189  if (!objectvalidator.validHit(*hit))
190  continue;
191  CaloTowerDetId tid = ctcm.towerOf(hit->id());
192  insert_(tid, hit);
193  }
194 
195  // do the tracks
196  for (std::vector<reco::TrackExtrapolation>::const_iterator it = trackextrapcoll_h->begin();
197  it != trackextrapcoll_h->end();
198  ++it) {
199  const reco::TrackExtrapolation* extrap = &(*it);
200  const reco::Track* track = &(*(extrap->track()));
201 
202  // validate track
203  if (!objectvalidator.validTrack(*track))
204  continue;
205 
206  // get the point
207  if (extrap->positions().empty())
208  continue;
209  const GlobalPoint point(
210  extrap->positions().front().x(), extrap->positions().front().y(), extrap->positions().front().z());
211 
212  if (std::fabs(point.eta()) < 1.479) {
213  EBDetId cell = gEB->getClosestCell(point);
214  CaloTowerDetId tid = ctcm.towerOf(cell);
215  insert_(tid, track);
216  } else {
217  EEDetId cell = gEE->getClosestCell(point);
218  CaloTowerDetId tid = ctcm.towerOf(cell);
219  insert_(tid, track);
220  }
221  }
222 
223  return;
224 }
225 
227  // create dummy PhysicsTower
229 
230  // correct for the merging of the |ieta|=28-29 towers
231  if (id.ietaAbs() == 29)
232  dummy.id = CaloTowerDetId((id.ietaAbs() - 1) * id.zside(), id.iphi());
233  else
234  dummy.id = id;
235 
236  // search on the dummy
237  std::set<PhysicsTower, towercmp>::iterator it = towers_.find(dummy);
238 
239  if (it == towers_.end())
240  return nullptr;
241 
242  // for whatever reason, I can't get a non-const out of the find method
243  PhysicsTower& twr = const_cast<PhysicsTower&>(*it);
244  return &twr;
245 }
246 
248  // create dummy PhysicsTower
250 
251  // correct for the merging of the |ieta|=28-29 towers
252  if (id.ietaAbs() == 29)
253  dummy.id = CaloTowerDetId((id.ietaAbs() - 1) * id.zside(), id.iphi());
254  else
255  dummy.id = id;
256 
257  // search on the dummy
258  std::set<PhysicsTower, towercmp>::iterator it = towers_.find(dummy);
259 
260  if (it == towers_.end())
261  return nullptr;
262  return &(*it);
263 }
264 
266  CaloTowerDetId tid(ieta, iphi);
267  return findTower(tid);
268 }
269 
271  CaloTowerDetId tid(ieta, iphi);
272  return findTower(tid);
273 }
274 
276  std::set<const PhysicsTower*>& neighbors) const {
277  // correct for the merging of the |ieta|=28-29 towers
278  CaloTowerDetId id(tempid);
279  if (tempid.ietaAbs() == 29)
280  id = CaloTowerDetId((tempid.ietaAbs() - 1) * tempid.zside(), tempid.iphi());
281 
282  std::vector<CaloTowerDetId> ids;
283  // get the neighbor with higher iphi
284  if (id.ietaAbs() <= 20) {
285  if (id.iphi() == 72)
286  ids.push_back(CaloTowerDetId(id.ieta(), 1));
287  else
288  ids.push_back(CaloTowerDetId(id.ieta(), id.iphi() + 1));
289  } else {
290  if (id.iphi() == 71)
291  ids.push_back(CaloTowerDetId(id.ieta(), 1));
292  else
293  ids.push_back(CaloTowerDetId(id.ieta(), id.iphi() + 2));
294  }
295 
296  // get the neighbor with the lower iphi
297  if (id.ietaAbs() <= 20) {
298  if (id.iphi() == 1)
299  ids.push_back(CaloTowerDetId(id.ieta(), 72));
300  else
301  ids.push_back(CaloTowerDetId(id.ieta(), id.iphi() - 1));
302  } else {
303  if (id.iphi() == 1)
304  ids.push_back(CaloTowerDetId(id.ieta(), 71));
305  else
306  ids.push_back(CaloTowerDetId(id.ieta(), id.iphi() - 2));
307  }
308 
309  // get the neighbor with the higher ietaAbs
310  if (id.ietaAbs() == 20 && (id.iphi() % 2) == 0)
311  ids.push_back(CaloTowerDetId((id.ietaAbs() + 1) * id.zside(), id.iphi() - 1));
312  else
313  ids.push_back(CaloTowerDetId((id.ietaAbs() + 1) * id.zside(), id.iphi()));
314 
315  // get the neighbor(s) with the lower ietaAbs
316  if (id.ietaAbs() == 21) {
317  ids.push_back(CaloTowerDetId((id.ietaAbs() - 1) * id.zside(), id.iphi()));
318  ids.push_back(CaloTowerDetId((id.ietaAbs() - 1) * id.zside(), id.iphi() + 1));
319  } else if (id.ietaAbs() == 1) {
320  ids.push_back(CaloTowerDetId(-id.ieta(), id.iphi()));
321  } else {
322  ids.push_back(CaloTowerDetId((id.ietaAbs() - 1) * id.zside(), id.iphi()));
323  }
324 
325  // get the neighbor with higher ieta and higher iphi
326  if (id.ietaAbs() <= 19 || (id.ietaAbs() == 20 && (id.iphi() % 2) == 0)) {
327  if (id.iphi() == 72)
328  ids.push_back(CaloTowerDetId((id.ietaAbs() + 1) * id.zside(), 1));
329  else
330  ids.push_back(CaloTowerDetId((id.ietaAbs() + 1) * id.zside(), id.iphi() + 1));
331  } else if (id.ietaAbs() >= 21) {
332  if (id.iphi() == 71)
333  ids.push_back(CaloTowerDetId((id.ietaAbs() + 1) * id.zside(), 1));
334  else
335  ids.push_back(CaloTowerDetId((id.ietaAbs() + 1) * id.zside(), id.iphi() + 2));
336  }
337 
338  // get the neighbor with higher ieta and lower iphi
339  if (id.ietaAbs() <= 19) {
340  if (id.iphi() == 1)
341  ids.push_back(CaloTowerDetId((id.ietaAbs() + 1) * id.zside(), 72));
342  else
343  ids.push_back(CaloTowerDetId((id.ietaAbs() + 1) * id.zside(), id.iphi() - 1));
344  } else if (id.ietaAbs() >= 21 || (id.ietaAbs() == 20 && (id.iphi() % 2) == 1)) {
345  if (id.iphi() == 1)
346  ids.push_back(CaloTowerDetId((id.ietaAbs() + 1) * id.zside(), 71));
347  else
348  ids.push_back(CaloTowerDetId((id.ietaAbs() + 1) * id.zside(), id.iphi() - 2));
349  }
350 
351  // get the neighbor with lower ieta and higher iphi
352  if (id.ietaAbs() == 1) {
353  if (id.iphi() == 72)
354  ids.push_back(CaloTowerDetId(-id.ieta(), 1));
355  else
356  ids.push_back(CaloTowerDetId(-id.ieta(), id.iphi() + 1));
357  } else if (id.ietaAbs() <= 20) {
358  if (id.iphi() == 72)
359  ids.push_back(CaloTowerDetId((id.ietaAbs() - 1) * id.zside(), 1));
360  else
361  ids.push_back(CaloTowerDetId((id.ietaAbs() - 1) * id.zside(), id.iphi() + 1));
362  } else if (id.ietaAbs() >= 21) {
363  if (id.iphi() == 71)
364  ids.push_back(CaloTowerDetId((id.ietaAbs() - 1) * id.zside(), 1));
365  else
366  ids.push_back(CaloTowerDetId((id.ietaAbs() - 1) * id.zside(), id.iphi() + 2));
367  }
368 
369  // get the neighbor with lower ieta and lower iphi
370  if (id.ietaAbs() == 1) {
371  if (id.iphi() == 1)
372  ids.push_back(CaloTowerDetId(-id.ieta(), 72));
373  else
374  ids.push_back(CaloTowerDetId(-id.ieta(), id.iphi() - 1));
375  } else if (id.ietaAbs() <= 20) {
376  if (id.iphi() == 1)
377  ids.push_back(CaloTowerDetId((id.ietaAbs() - 1) * id.zside(), 72));
378  else
379  ids.push_back(CaloTowerDetId((id.ietaAbs() - 1) * id.zside(), id.iphi() - 1));
380  } else if (id.ietaAbs() >= 22) {
381  if (id.iphi() == 1)
382  ids.push_back(CaloTowerDetId((id.ietaAbs() - 1) * id.zside(), 71));
383  else
384  ids.push_back(CaloTowerDetId((id.ietaAbs() - 1) * id.zside(), id.iphi() - 2));
385  } else if (id.ietaAbs() == 21) {
386  if (id.iphi() == 1)
387  ids.push_back(CaloTowerDetId((id.ietaAbs() - 1) * id.zside(), 72));
388  else
389  ids.push_back(CaloTowerDetId((id.ietaAbs() - 1) * id.zside(), id.iphi() - 1));
390  }
391 
392  // clear neighbors
393  neighbors.clear();
394 
395  // find the neighbors and add them to the eponymous set
396  for (std::vector<CaloTowerDetId>::const_iterator it = ids.begin(); it != ids.end(); ++it) {
397  const PhysicsTower* twr = findTower(*it);
398  if (twr)
399  neighbors.insert(twr);
400  }
401 
402  return;
403 }
404 
405 void PhysicsTowerOrganizer::findNeighbors(const PhysicsTower* twr, std::set<const PhysicsTower*>& neighbors) const {
406  findNeighbors(twr->id, neighbors);
407  return;
408 }
409 
410 void PhysicsTowerOrganizer::findNeighbors(int ieta, int iphi, std::set<const PhysicsTower*>& neighbors) const {
411  findNeighbors(CaloTowerDetId(ieta, iphi), neighbors);
412  return;
413 }
414 
416  PhysicsTower* twr = findTower(id);
417  if (twr == nullptr) {
419  if (id.ietaAbs() == 29)
420  dummy.id = CaloTowerDetId((id.ietaAbs() - 1) * id.zside(), id.iphi());
421  else
422  dummy.id = id;
423  dummy.hcalhits.insert(hit);
424  towers_.insert(dummy);
425  } else {
426  twr->hcalhits.insert(hit);
427  }
428  return;
429 }
430 
432  PhysicsTower* twr = findTower(id);
433  if (twr == nullptr) {
435  if (id.ietaAbs() == 29)
436  dummy.id = CaloTowerDetId((id.ietaAbs() - 1) * id.zside(), id.iphi());
437  else
438  dummy.id = id;
439  dummy.ecalhits.insert(hit);
440  towers_.insert(dummy);
441  } else {
442  twr->ecalhits.insert(hit);
443  }
444  return;
445 }
446 
448  PhysicsTower* twr = findTower(id);
449  if (twr == nullptr) {
451  if (id.ietaAbs() == 29)
452  dummy.id = CaloTowerDetId((id.ietaAbs() - 1) * id.zside(), id.iphi());
453  else
454  dummy.id = id;
455  dummy.tracks.insert(track);
456  towers_.insert(dummy);
457  } else {
458  twr->tracks.insert(track);
459  }
460  return;
461 }
462 
464 //
465 // HBHEHitMap
466 //
468 
470  hitEnergy_ = hitEnergyTrkFid_ = -999.;
471  nHits_ = -999;
476 }
477 
478 double HBHEHitMap::hitEnergy(void) const {
479  if (hitEnergy_ < -900)
480  calcHits_();
481  return hitEnergy_;
482 }
483 
484 int HBHEHitMap::nHits(void) const {
485  if (nHits_ < -900)
486  calcHits_();
487  return nHits_;
488 }
489 
491  if (hitEnergyTrkFid_ < -900)
492  calcHits_();
493  return hitEnergyTrkFid_;
494 }
495 
497  if (hcalEnergySameTowers_ < -900)
499  return hcalEnergySameTowers_;
500 }
501 
503  if (nHcalHitsSameTowers_ < -900)
505  return nHcalHitsSameTowers_;
506 }
507 
509  if (ecalEnergySameTowers_ < -900)
511  return ecalEnergySameTowers_;
512 }
513 
515  if (nEcalHitsSameTowers_ < -900)
517  return nEcalHitsSameTowers_;
518 }
519 
521  if (trackEnergySameTowers_ < -900)
523  return trackEnergySameTowers_;
524 }
525 
527  if (nTracksSameTowers_ < -900)
529  return nTracksSameTowers_;
530 }
531 
532 void HBHEHitMap::hcalHitsSameTowers(std::set<const HBHERecHit*>& v) const {
533  v.clear();
534  for (hitmap_const_iterator it1 = beginHits(); it1 != endHits(); ++it1) {
535  for (std::set<const HBHERecHit*>::const_iterator it2 = it1->second->hcalhits.begin();
536  it2 != it1->second->hcalhits.end();
537  ++it2) {
538  const HBHERecHit* hit = (*it2);
539  // if the hit in the tower is already in the hitmap, don't include it
540  if (findHit(hit) == endHits())
541  v.insert(hit);
542  }
543  }
544  return;
545 }
546 
547 void HBHEHitMap::ecalHitsSameTowers(std::set<const EcalRecHit*>& v) const {
548  v.clear();
549  for (hitmap_const_iterator it1 = beginHits(); it1 != endHits(); ++it1) {
550  v.insert(it1->second->ecalhits.begin(), it1->second->ecalhits.end());
551  }
552  return;
553 }
554 
555 void HBHEHitMap::tracksSameTowers(std::set<const reco::Track*>& v) const {
556  v.clear();
557  for (hitmap_const_iterator it1 = beginHits(); it1 != endHits(); ++it1) {
558  v.insert(it1->second->tracks.begin(), it1->second->tracks.end());
559  }
560  return;
561 }
562 
564  if (hcalEnergyNeighborTowers_ < -900)
567 }
568 
570  if (nHcalHitsNeighborTowers_ < -900)
573 }
574 
576  if (ecalEnergyNeighborTowers_ < -900)
579 }
580 
582  if (nEcalHitsNeighborTowers_ < -900)
585 }
586 
588  if (trackEnergyNeighborTowers_ < -900)
591 }
592 
594  if (nTracksNeighborTowers_ < -900)
596  return nTracksNeighborTowers_;
597 }
598 
599 void HBHEHitMap::hcalHitsNeighborTowers(std::set<const HBHERecHit*>& v) const {
600  v.clear();
601  for (neighbor_const_iterator it1 = beginNeighbors(); it1 != endNeighbors(); ++it1) {
602  const PhysicsTower* twr = (*it1);
603  v.insert(twr->hcalhits.begin(), twr->hcalhits.end());
604  }
605  return;
606 }
607 
608 void HBHEHitMap::ecalHitsNeighborTowers(std::set<const EcalRecHit*>& v) const {
609  v.clear();
610  for (neighbor_const_iterator it1 = beginNeighbors(); it1 != endNeighbors(); ++it1) {
611  const PhysicsTower* twr = (*it1);
612  v.insert(twr->ecalhits.begin(), twr->ecalhits.end());
613  }
614 
615  return;
616 }
617 
618 void HBHEHitMap::tracksNeighborTowers(std::set<const reco::Track*>& v) const {
619  v.clear();
620  for (neighbor_const_iterator it1 = beginNeighbors(); it1 != endNeighbors(); ++it1) {
621  const PhysicsTower* twr = (*it1);
622  v.insert(twr->tracks.begin(), twr->tracks.end());
623  }
624  return;
625 }
626 
627 void HBHEHitMap::byTowers(std::vector<twrinfo>& v) const { assert(false); }
628 
629 void HBHEHitMap::insert(const HBHERecHit* hit, const PhysicsTower* twr, std::set<const PhysicsTower*>& neighbors) {
630  hits_[hit] = twr;
631  neighbors_.insert(neighbors.begin(), neighbors.end());
632 
633  // make sure none of the neighbors are also are part of the hitmap
634  for (hitmap_const_iterator it = beginHits(); it != endHits(); ++it) {
635  const PhysicsTower* t = it->second;
637 
638  // if a hit is also a neighbor, remove the neighbor
639  if (find != endNeighbors())
640  neighbors_.erase(find);
641  }
642  return;
643 }
644 
645 void HBHEHitMap::calcHits_(void) const {
646  hitEnergy_ = 0;
647  nHits_ = 0;
648  hitEnergyTrkFid_ = 0;
649  for (hitmap_const_iterator it = hits_.begin(); it != hits_.end(); ++it) {
650  const HBHERecHit* hit = it->first;
651  if (hit->id().ietaAbs() <= 26)
652  hitEnergyTrkFid_ += hit->energy();
653  hitEnergy_ += hit->energy();
654  ++nHits_;
655  }
656  return;
657 }
658 
662  std::set<const HBHERecHit*> v;
664  for (std::set<const HBHERecHit*>::const_iterator it = v.begin(); it != v.end(); ++it) {
665  const HBHERecHit* hit = (*it);
666  hcalEnergySameTowers_ += hit->energy();
668  }
669  return;
670 }
671 
675  std::set<const EcalRecHit*> v;
677  for (std::set<const EcalRecHit*>::const_iterator it = v.begin(); it != v.end(); ++it) {
678  const EcalRecHit* hit = (*it);
679  ecalEnergySameTowers_ += hit->energy();
681  }
682  return;
683 }
684 
687  nTracksSameTowers_ = 0;
688  std::set<const reco::Track*> v;
690  for (std::set<const reco::Track*>::const_iterator it = v.begin(); it != v.end(); ++it) {
691  const reco::Track* trk = (*it);
692  trackEnergySameTowers_ += trk->p();
694  }
695  return;
696 }
697 
701  std::set<const HBHERecHit*> v;
703  for (std::set<const HBHERecHit*>::const_iterator it = v.begin(); it != v.end(); ++it) {
704  const HBHERecHit* hit = (*it);
705  hcalEnergyNeighborTowers_ += hit->energy();
707  }
708  return;
709 }
710 
714  std::set<const EcalRecHit*> v;
716  for (std::set<const EcalRecHit*>::const_iterator it = v.begin(); it != v.end(); ++it) {
717  const EcalRecHit* hit = (*it);
718  ecalEnergyNeighborTowers_ += hit->energy();
720  }
721  return;
722 }
723 
727  std::set<const reco::Track*> v;
729  for (std::set<const reco::Track*>::const_iterator it = v.begin(); it != v.end(); ++it) {
730  const reco::Track* trk = (*it);
731  trackEnergyNeighborTowers_ += trk->p();
733  }
734  return;
735 }
736 
738 //
739 // HBHEHitMapOrganizer
740 //
742 
744  const ObjectValidatorAbs& objvalidator,
745  const PhysicsTowerOrganizer& pto,
746  const HcalFrontEndMap* hfemap)
747  : hfemap_(hfemap) {
748  // loop over the hits
749  for (HBHERecHitCollection::const_iterator it = hbhehitcoll_h->begin(); it != hbhehitcoll_h->end(); ++it) {
750  const HBHERecHit* hit = &(*it);
751  if (!objvalidator.validHit(*hit))
752  continue;
753 
754  // get the Physics Tower and the neighbors
755  const PhysicsTower* tower = pto.findTower(hit->id().ieta(), hit->id().iphi());
756 
757  std::set<const PhysicsTower*> neighbors;
758  pto.findNeighbors(hit->id().ieta(), hit->id().iphi(), neighbors);
759 
760  // organize the RBXs
761  int rbxidnum = hfemap_->lookupRBXIndex(hit->id());
762  rbxs_[rbxidnum].insert(hit, tower, neighbors);
763 
764  // organize the HPDs
765  int hpdidnum = hfemap_->lookupRMIndex(hit->id());
766  hpds_[hpdidnum].insert(hit, tower, neighbors);
767 
768  // organize the dihits
769  std::vector<const HBHERecHit*> hpdneighbors;
770  getHPDNeighbors(hit, hpdneighbors, pto);
771 
772  if (hpdneighbors.size() == 1) {
773  std::vector<const HBHERecHit*> hpdneighborsneighbors;
774  getHPDNeighbors(hpdneighbors[0], hpdneighborsneighbors, pto);
775 
776  if (hpdneighborsneighbors.size() == 1 && hpdneighborsneighbors[0] == hit &&
777  hit->energy() > hpdneighbors[0]->energy()) {
778  // we've found two hits who are neighbors in the same HPD, but who have no other
779  // neighbors (in the same HPD) in common. In order not to double-count, we
780  // require that the first hit has more energy
781 
782  const PhysicsTower* tower2 = pto.findTower(hpdneighbors[0]->id().ieta(), hpdneighbors[0]->id().iphi());
783  std::set<const PhysicsTower*> neighbors2;
784  pto.findNeighbors(hpdneighbors[0]->id().ieta(), hpdneighbors[0]->id().iphi(), neighbors2);
785 
786  HBHEHitMap dihit;
787  dihit.insert(hit, tower, neighbors);
788  dihit.insert(hpdneighbors[0], tower2, neighbors2);
789  dihits_.push_back(dihit);
790  }
791  } else if (hpdneighbors.empty()) {
792  // organize the monohits
793  HBHEHitMap monohit;
794  monohit.insert(hit, tower, neighbors);
795  monohits_.push_back(monohit);
796  }
797 
798  } // finished looping over HBHERecHits
799  return;
800 }
801 
802 void HBHEHitMapOrganizer::getRBXs(std::vector<HBHEHitMap>& v, double energy) const {
803  for (std::map<int, HBHEHitMap>::const_iterator it = rbxs_.begin(); it != rbxs_.end(); ++it) {
804  const HBHEHitMap& map = it->second;
805  if (map.hitEnergy() > energy)
806  v.push_back(map);
807  }
808  return;
809 }
810 
811 void HBHEHitMapOrganizer::getHPDs(std::vector<HBHEHitMap>& v, double energy) const {
812  for (std::map<int, HBHEHitMap>::const_iterator it = hpds_.begin(); it != hpds_.end(); ++it) {
813  const HBHEHitMap& map = it->second;
814  if (map.hitEnergy() > energy)
815  v.push_back(map);
816  }
817  return;
818 }
819 
820 void HBHEHitMapOrganizer::getDiHits(std::vector<HBHEHitMap>& v, double energy) const {
821  for (std::vector<HBHEHitMap>::const_iterator it = dihits_.begin(); it != dihits_.end(); ++it) {
822  if (it->hitEnergy() > energy)
823  v.push_back(*it);
824  }
825  return;
826 }
827 
828 void HBHEHitMapOrganizer::getMonoHits(std::vector<HBHEHitMap>& v, double energy) const {
829  for (std::vector<HBHEHitMap>::const_iterator it = monohits_.begin(); it != monohits_.end(); ++it) {
830  if (it->hitEnergy() > energy)
831  v.push_back(*it);
832  }
833  return;
834 }
835 
837  std::vector<const HBHERecHit*>& neighbors,
838  const PhysicsTowerOrganizer& pto) {
839  std::set<const PhysicsTower*> temp;
840  pto.findNeighbors(hit->id().ieta(), hit->id().iphi(), temp);
841 
842  // make sure to include the same tower that the hit is in
843  temp.insert(pto.findTower(hit->id().ieta(), hit->id().iphi()));
844 
845  // loop over the rechits in the temp neighbors
846  for (std::set<const PhysicsTower*>::const_iterator it1 = temp.begin(); it1 != temp.end(); ++it1) {
847  for (std::set<const HBHERecHit*>::const_iterator it2 = (*it1)->hcalhits.begin(); it2 != (*it1)->hcalhits.end();
848  ++it2) {
849  const HBHERecHit* hit2(*it2);
850  if (hit != hit2 && hfemap_->lookupRMIndex(hit->id()) == hfemap_->lookupRMIndex(hit2->id())) {
851  neighbors.push_back(hit2);
852  }
853  }
854  }
855  return;
856 }
int nEcalHitsNeighborTowers(void) const
int nHcalHitsNeighborTowers(void) const
std::set< const HBHERecHit * > hcalhits
const int lookupRBXIndex(DetId fId) const
void calcHcalNeighborTowers_(void) const
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void insert(const HBHERecHit *hit, const PhysicsTower *twr, std::set< const PhysicsTower *> &neighbors)
hitmap_const_iterator endHits(void) const
void getDiHits(std::vector< HBHEHitMap > &v, double energy) const
int ietaAbs() const
get the absolute value of the tower ieta
void calcHits_(void) const
unsigned short numberOfValidHits() const
number of valid hits found
Definition: TrackBase.h:799
std::map< const HBHERecHit *, const PhysicsTower * >::const_iterator hitmap_const_iterator
std::vector< HBHEHitMap > dihits_
PhysicsTowerOrganizer(const edm::Handle< HBHERecHitCollection > &hbhehitcoll_h, const edm::Handle< EcalRecHitCollection > &ebhitcoll_h, const edm::Handle< EcalRecHitCollection > &eehitcoll_h, const edm::Handle< std::vector< reco::TrackExtrapolation > > &trackextrapcoll_h, const ObjectValidatorAbs &objectvalidator, const CaloTowerConstituentsMap &ctcm, const CaloGeometry &geo)
double p() const
momentum vector magnitude
Definition: TrackBase.h:632
bool recoveredRecHit(const DetId &myid, const uint32_t &myflag) const
HBHEHitMapOrganizer(const edm::Handle< HBHERecHitCollection > &hbhehitcoll_h, const ObjectValidatorAbs &objvalidator, const PhysicsTowerOrganizer &pto, const HcalFrontEndMap *hfemap)
CaloTowerDetId towerOf(const DetId &id) const
Get the tower id for this det id (or null if not known)
double hitEnergyTrackFiducial(void) const
int nTracksSameTowers(void) const
std::vector< T >::const_iterator const_iterator
void hcalHitsSameTowers(std::set< const HBHERecHit *> &v) const
void calcHcalSameTowers_(void) const
virtual bool validTrack(const reco::Track &) const =0
void byTowers(std::vector< twrinfo > &v) const
int zside(DetId const &)
void tracksSameTowers(std::set< const reco::Track *> &v) const
double hcalEnergyNeighborTowers_
double hcalEnergySameTowers(void) const
hitmap_const_iterator findHit(const HBHERecHit *hit) const
ObjectValidator(const edm::ParameterSet &)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
assert(be >=bs)
bool validHit(const HBHERecHit &) const override
std::map< const HBHERecHit *, const PhysicsTower * > hits_
const Item * getValues(DetId fId, bool throwOnFail=true) const
EcalSeverityLevel::SeverityLevel severityLevel(const DetId &id) const
Evaluate status from id use channelStatus from DB.
double trackEnergyNeighborTowers_
void hcalHitsNeighborTowers(std::set< const HBHERecHit *> &v) const
double hcalEnergyNeighborTowers(void) const
reco::TrackRef const & track() const
double pt() const
track transverse momentum
Definition: TrackBase.h:638
double hitEnergy(void) const
const int lookupRMIndex(DetId fId) const
std::set< const PhysicsTower * > neighbors_
void calcEcalSameTowers_(void) const
void ecalHitsNeighborTowers(std::set< const EcalRecHit *> &v) const
std::map< int, HBHEHitMap > rbxs_
int nHcalHitsSameTowers(void) const
const EcalChannelStatus * theEcalChStatus_
void ecalHitsSameTowers(std::set< const EcalRecHit *> &v) const
const EcalRecHitCollection * theEERecHitCollection_
void insert_(CaloTowerDetId &id, const HBHERecHit *hit)
neighbor_const_iterator findNeighbor(const PhysicsTower *twr) const
void calcTracksSameTowers_(void) const
neighbor_const_iterator endNeighbors(void) const
const_iterator begin() const
void getHPDNeighbors(const HBHERecHit *hit, std::vector< const HBHERecHit *> &neighbors, const PhysicsTowerOrganizer &pto)
const EcalRecHitCollection * theEBRecHitCollection_
uint32_t getValue() const
std::set< const PhysicsTower * >::const_iterator neighbor_const_iterator
virtual DetId getClosestCell(const GlobalPoint &r) const
constexpr bool getBit(const uint32_t u, const unsigned bitnum)
std::map< int, HBHEHitMap > hpds_
unsigned int id
const_iterator end() const
std::set< PhysicsTower, towercmp > towers_
Definition: DetId.h:17
neighbor_const_iterator beginNeighbors(void) const
const PhysicsTower * findTower(const CaloTowerDetId &id) const
void calcEcalNeighborTowers_(void) const
virtual bool validHit(const HBHERecHit &) const =0
constexpr HcalDetId id() const
get the id
Definition: HBHERecHit.h:41
double ecalEnergyNeighborTowers_
double ecalEnergySameTowers(void) const
int iphi() const
get the tower iphi
int nTracksNeighborTowers(void) const
const EcalSeverityLevelAlgo * theEcalSevLvlAlgo_
void findNeighbors(const CaloTowerDetId &id, std::set< const PhysicsTower *> &neighbors) const
double trackEnergySameTowers(void) const
std::set< const EcalRecHit * > ecalhits
int nHits(void) const
const Vector & momentum() const
track momentum vector
Definition: TrackBase.h:665
void getMonoHits(std::vector< HBHEHitMap > &v, double energy) const
bool validTrack(const reco::Track &) const override
double ecalEnergyNeighborTowers(void) const
double trackEnergyNeighborTowers(void) const
void getRBXs(std::vector< HBHEHitMap > &v, double energy) const
void calcTracksNeighborTowers_(void) const
void getHPDs(std::vector< HBHEHitMap > &v, double energy) const
int zside() const
get the z-side of the tower (1/-1)
void tracksNeighborTowers(std::set< const reco::Track *> &v) const
std::set< const reco::Track * > tracks
static const unsigned OFF_COMBINED
std::vector< HBHEHitMap > monohits_
int getSeverityLevel(const DetId &myid, const uint32_t &myflag, const uint32_t &mystatus) const
const HcalChannelQuality * theHcalChStatus_
std::vector< Point > const & positions() const
const HcalFrontEndMap * hfemap_
const HcalSeverityLevelComputer * theHcalSevLvlComputer_
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:34
hitmap_const_iterator beginHits(void) const
*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
int nEcalHitsSameTowers(void) const