CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
PhysicsTowerOrganizer Class Reference

#include <HBHEIsolatedNoiseAlgos.h>

Classes

struct  towercmp
 

Public Member Functions

void findNeighbors (const CaloTowerDetId &id, std::set< const PhysicsTower *> &neighbors) const
 
void findNeighbors (const PhysicsTower *twr, std::set< const PhysicsTower *> &neighbors) const
 
void findNeighbors (int ieta, int iphi, std::set< const PhysicsTower *> &neighbors) const
 
const PhysicsTowerfindTower (const CaloTowerDetId &id) const
 
const PhysicsTowerfindTower (int ieta, int iphi) const
 
 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)
 
virtual ~PhysicsTowerOrganizer ()
 

Private Member Functions

PhysicsTowerfindTower (const CaloTowerDetId &id)
 
PhysicsTowerfindTower (int ieta, int iphi)
 
void insert_ (CaloTowerDetId &id, const HBHERecHit *hit)
 
void insert_ (CaloTowerDetId &id, const EcalRecHit *hit)
 
void insert_ (CaloTowerDetId &id, const reco::Track *hit)
 

Private Attributes

std::set< PhysicsTower, towercmptowers_
 

Detailed Description

Definition at line 171 of file HBHEIsolatedNoiseAlgos.h.

Constructor & Destructor Documentation

◆ PhysicsTowerOrganizer()

PhysicsTowerOrganizer::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 
)

Definition at line 150 of file HBHEIsolatedNoiseAlgos.cc.

References edm::SortedCollection< T, SORT >::begin(), DetId::Ecal, EcalBarrel, EcalEndcap, edm::SortedCollection< T, SORT >::end(), CaloSubdetectorGeometry::getClosestCell(), CaloGeometry::getSubdetectorGeometry(), hit::id, insert_(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, point, reco::TrackExtrapolation::positions(), CaloTowerConstituentsMap::towerOf(), reco::TrackExtrapolation::track(), HLT_2024v10_cff::track, ObjectValidatorAbs::validHit(), and ObjectValidatorAbs::validTrack().

157  {
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 }
CaloTowerDetId towerOf(const DetId &id) const
Get the tower id for this det id (or null if not known)
std::vector< T >::const_iterator const_iterator
virtual bool validTrack(const reco::Track &) const =0
reco::TrackRef const & track() const
void insert_(CaloTowerDetId &id, const HBHERecHit *hit)
const_iterator begin() const
virtual DetId getClosestCell(const GlobalPoint &r) const
unsigned int id
const_iterator end() const
virtual bool validHit(const HBHERecHit &) const =0
std::vector< Point > const & positions() const
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:34
*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

◆ ~PhysicsTowerOrganizer()

virtual PhysicsTowerOrganizer::~PhysicsTowerOrganizer ( )
inlinevirtual

Definition at line 185 of file HBHEIsolatedNoiseAlgos.h.

185 {}

Member Function Documentation

◆ findNeighbors() [1/3]

void PhysicsTowerOrganizer::findNeighbors ( const CaloTowerDetId id,
std::set< const PhysicsTower *> &  neighbors 
) const

Definition at line 275 of file HBHEIsolatedNoiseAlgos.cc.

References findTower(), l1ctLayer2EG_cff::id, hcalRecHitTable_cff::ieta, ALPAKA_ACCELERATOR_NAMESPACE::ecal::reconstruction::internal::barrel::ietaAbs(), CaloTowerDetId::ietaAbs(), hcalRecHitTable_cff::iphi, CaloTowerDetId::iphi(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, CaloTowerDetId::zside(), and ecaldqm::zside().

Referenced by findNeighbors(), HBHEHitMapOrganizer::getHPDNeighbors(), and HBHEHitMapOrganizer::HBHEHitMapOrganizer().

276  {
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 }
int zside(DetId const &)
ALPAKA_FN_ACC ALPAKA_FN_INLINE uint32_t ietaAbs(uint32_t id)
const PhysicsTower * findTower(const CaloTowerDetId &id) const

◆ findNeighbors() [2/3]

void PhysicsTowerOrganizer::findNeighbors ( const PhysicsTower twr,
std::set< const PhysicsTower *> &  neighbors 
) const

Definition at line 405 of file HBHEIsolatedNoiseAlgos.cc.

References findNeighbors(), and PhysicsTower::id.

405  {
406  findNeighbors(twr->id, neighbors);
407  return;
408 }
void findNeighbors(const CaloTowerDetId &id, std::set< const PhysicsTower *> &neighbors) const

◆ findNeighbors() [3/3]

void PhysicsTowerOrganizer::findNeighbors ( int  ieta,
int  iphi,
std::set< const PhysicsTower *> &  neighbors 
) const

Definition at line 410 of file HBHEIsolatedNoiseAlgos.cc.

References findNeighbors(), hcalRecHitTable_cff::ieta, and hcalRecHitTable_cff::iphi.

410  {
411  findNeighbors(CaloTowerDetId(ieta, iphi), neighbors);
412  return;
413 }
void findNeighbors(const CaloTowerDetId &id, std::set< const PhysicsTower *> &neighbors) const

◆ findTower() [1/4]

const PhysicsTower * PhysicsTowerOrganizer::findTower ( const CaloTowerDetId id) const
inline

Definition at line 247 of file HBHEIsolatedNoiseAlgos.cc.

References l1ctLayer2EG_cff::id, ALPAKA_ACCELERATOR_NAMESPACE::ecal::reconstruction::internal::barrel::ietaAbs(), hcalRecHitTable_cff::iphi, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, towers_, and ecaldqm::zside().

Referenced by findNeighbors(), findTower(), HBHEHitMapOrganizer::getHPDNeighbors(), HBHEHitMapOrganizer::HBHEHitMapOrganizer(), and insert_().

247  {
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 }
int zside(DetId const &)
ALPAKA_FN_ACC ALPAKA_FN_INLINE uint32_t ietaAbs(uint32_t id)
std::set< PhysicsTower, towercmp > towers_

◆ findTower() [2/4]

const PhysicsTower * PhysicsTowerOrganizer::findTower ( int  ieta,
int  iphi 
) const
inline

Definition at line 265 of file HBHEIsolatedNoiseAlgos.cc.

References findTower(), hcalRecHitTable_cff::ieta, and hcalRecHitTable_cff::iphi.

265  {
266  CaloTowerDetId tid(ieta, iphi);
267  return findTower(tid);
268 }
const PhysicsTower * findTower(const CaloTowerDetId &id) const

◆ findTower() [3/4]

PhysicsTower * PhysicsTowerOrganizer::findTower ( const CaloTowerDetId id)
private

Definition at line 226 of file HBHEIsolatedNoiseAlgos.cc.

References l1ctLayer2EG_cff::id, ALPAKA_ACCELERATOR_NAMESPACE::ecal::reconstruction::internal::barrel::ietaAbs(), hcalRecHitTable_cff::iphi, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, towers_, and ecaldqm::zside().

226  {
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 }
int zside(DetId const &)
ALPAKA_FN_ACC ALPAKA_FN_INLINE uint32_t ietaAbs(uint32_t id)
std::set< PhysicsTower, towercmp > towers_

◆ findTower() [4/4]

PhysicsTower * PhysicsTowerOrganizer::findTower ( int  ieta,
int  iphi 
)
private

Definition at line 270 of file HBHEIsolatedNoiseAlgos.cc.

References findTower(), hcalRecHitTable_cff::ieta, and hcalRecHitTable_cff::iphi.

270  {
271  CaloTowerDetId tid(ieta, iphi);
272  return findTower(tid);
273 }
const PhysicsTower * findTower(const CaloTowerDetId &id) const

◆ insert_() [1/3]

void PhysicsTowerOrganizer::insert_ ( CaloTowerDetId id,
const HBHERecHit hit 
)
private

Definition at line 415 of file HBHEIsolatedNoiseAlgos.cc.

References findTower(), PhysicsTower::hcalhits, l1ctLayer2EG_cff::id, ALPAKA_ACCELERATOR_NAMESPACE::ecal::reconstruction::internal::barrel::ietaAbs(), hcalRecHitTable_cff::iphi, towers_, and ecaldqm::zside().

Referenced by PhysicsTowerOrganizer().

415  {
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 }
std::set< const HBHERecHit * > hcalhits
int zside(DetId const &)
ALPAKA_FN_ACC ALPAKA_FN_INLINE uint32_t ietaAbs(uint32_t id)
std::set< PhysicsTower, towercmp > towers_
const PhysicsTower * findTower(const CaloTowerDetId &id) const

◆ insert_() [2/3]

void PhysicsTowerOrganizer::insert_ ( CaloTowerDetId id,
const EcalRecHit hit 
)
private

Definition at line 431 of file HBHEIsolatedNoiseAlgos.cc.

References PhysicsTower::ecalhits, findTower(), l1ctLayer2EG_cff::id, ALPAKA_ACCELERATOR_NAMESPACE::ecal::reconstruction::internal::barrel::ietaAbs(), hcalRecHitTable_cff::iphi, towers_, and ecaldqm::zside().

431  {
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 }
int zside(DetId const &)
ALPAKA_FN_ACC ALPAKA_FN_INLINE uint32_t ietaAbs(uint32_t id)
std::set< PhysicsTower, towercmp > towers_
const PhysicsTower * findTower(const CaloTowerDetId &id) const
std::set< const EcalRecHit * > ecalhits

◆ insert_() [3/3]

void PhysicsTowerOrganizer::insert_ ( CaloTowerDetId id,
const reco::Track hit 
)
private

Definition at line 447 of file HBHEIsolatedNoiseAlgos.cc.

References findTower(), l1ctLayer2EG_cff::id, ALPAKA_ACCELERATOR_NAMESPACE::ecal::reconstruction::internal::barrel::ietaAbs(), hcalRecHitTable_cff::iphi, towers_, HLT_2024v10_cff::track, PhysicsTower::tracks, and ecaldqm::zside().

447  {
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 }
int zside(DetId const &)
ALPAKA_FN_ACC ALPAKA_FN_INLINE uint32_t ietaAbs(uint32_t id)
std::set< PhysicsTower, towercmp > towers_
const PhysicsTower * findTower(const CaloTowerDetId &id) const
std::set< const reco::Track * > tracks

Member Data Documentation

◆ towers_

std::set<PhysicsTower, towercmp> PhysicsTowerOrganizer::towers_
private

Definition at line 206 of file HBHEIsolatedNoiseAlgos.h.

Referenced by findTower(), and insert_().