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::Event &iEvent, const edm::EventSetup &evSetup, 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)
 
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 170 of file HBHEIsolatedNoiseAlgos.h.

Constructor & Destructor Documentation

PhysicsTowerOrganizer::PhysicsTowerOrganizer ( const edm::Event iEvent,
const edm::EventSetup evSetup,
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 
)

Definition at line 151 of file HBHEIsolatedNoiseAlgos.cc.

References edm::SortedCollection< T, SORT >::begin(), DetId::Ecal, EcalBarrel, EcalEndcap, edm::SortedCollection< T, SORT >::end(), edm::EventSetup::get(), CaloSubdetectorGeometry::getClosestCell(), CaloGeometry::getSubdetectorGeometry(), HBHERecHit::id(), EcalRecHit::id(), point, reco::TrackExtrapolation::positions(), edm::ESHandle< T >::product(), CaloTowerConstituentsMap::towerOf(), reco::TrackExtrapolation::track(), HLT_2018_cff::track, ObjectValidatorAbs::validHit(), and ObjectValidatorAbs::validTrack().

159  {
160  // get some geometries
162  evSetup.get<CaloGeometryRecord>().get(pG);
163  const CaloGeometry* geo = pG.product();
166 
167  // do the HCAL hits
168  for (HBHERecHitCollection::const_iterator it = hbhehitcoll_h->begin(); it != hbhehitcoll_h->end(); ++it) {
169  const HBHERecHit* hit = &(*it);
170 
171  // check that the hit is valid
172  if (!objectvalidator.validHit(*hit))
173  continue;
174 
175  // add the hit to the organizer
176  CaloTowerDetId tid = ctcm.towerOf(hit->id());
177  insert_(tid, hit);
178  }
179 
180  // do the EB hits
181  for (EcalRecHitCollection::const_iterator it = ebhitcoll_h->begin(); it != ebhitcoll_h->end(); ++it) {
182  const EcalRecHit* hit = &(*it);
183 
184  if (!objectvalidator.validHit(*hit))
185  continue;
186  CaloTowerDetId tid = ctcm.towerOf(hit->id());
187  insert_(tid, hit);
188  }
189 
190  // do the EE hits
191  for (EcalRecHitCollection::const_iterator it = eehitcoll_h->begin(); it != eehitcoll_h->end(); ++it) {
192  const EcalRecHit* hit = &(*it);
193 
194  if (!objectvalidator.validHit(*hit))
195  continue;
196  CaloTowerDetId tid = ctcm.towerOf(hit->id());
197  insert_(tid, hit);
198  }
199 
200  // do the tracks
201  for (std::vector<reco::TrackExtrapolation>::const_iterator it = trackextrapcoll_h->begin();
202  it != trackextrapcoll_h->end();
203  ++it) {
204  const reco::TrackExtrapolation* extrap = &(*it);
205  const reco::Track* track = &(*(extrap->track()));
206 
207  // validate track
208  if (!objectvalidator.validTrack(*track))
209  continue;
210 
211  // get the point
212  if (extrap->positions().empty())
213  continue;
214  const GlobalPoint point(
215  extrap->positions().front().x(), extrap->positions().front().y(), extrap->positions().front().z());
216 
217  if (std::fabs(point.eta()) < 1.479) {
218  EBDetId cell = gEB->getClosestCell(point);
219  CaloTowerDetId tid = ctcm.towerOf(cell);
220  insert_(tid, track);
221  } else {
222  EEDetId cell = gEE->getClosestCell(point);
223  CaloTowerDetId tid = ctcm.towerOf(cell);
224  insert_(tid, track);
225  }
226  }
227 
228  return;
229 }
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:34
HcalDetId id() const
get the id
Definition: HBHERecHit.h:39
std::vector< T >::const_iterator const_iterator
virtual bool validTrack(const reco::Track &) const =0
CaloTowerDetId towerOf(const DetId &id) const
Get the tower id for this det id (or null if not known)
virtual bool validHit(const HBHERecHit &) const =0
void insert_(CaloTowerDetId &id, const HBHERecHit *hit)
const_iterator end() const
virtual DetId getClosestCell(const GlobalPoint &r) const
DetId id() const
get the id
Definition: EcalRecHit.h:77
reco::TrackRef const & track() const
T get() const
Definition: EventSetup.h:73
std::vector< Point > const & positions() const
T const * product() const
Definition: ESHandle.h:86
*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
const_iterator begin() const
virtual PhysicsTowerOrganizer::~PhysicsTowerOrganizer ( )
inlinevirtual

Definition at line 185 of file HBHEIsolatedNoiseAlgos.h.

References LEDCalibrationChannels::ieta, and LEDCalibrationChannels::iphi.

185 {}

Member Function Documentation

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

Definition at line 280 of file HBHEIsolatedNoiseAlgos.cc.

References triggerObjects_cff::id, photons_cff::ids, LEDCalibrationChannels::ieta, CaloTowerDetId::ietaAbs(), CaloTowerDetId::iphi(), LEDCalibrationChannels::iphi, CaloTowerDetId::zside(), and ecaldqm::zside().

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

281  {
282  // correct for the merging of the |ieta|=28-29 towers
283  CaloTowerDetId id(tempid);
284  if (tempid.ietaAbs() == 29)
285  id = CaloTowerDetId((tempid.ietaAbs() - 1) * tempid.zside(), tempid.iphi());
286 
287  std::vector<CaloTowerDetId> ids;
288  // get the neighbor with higher iphi
289  if (id.ietaAbs() <= 20) {
290  if (id.iphi() == 72)
291  ids.push_back(CaloTowerDetId(id.ieta(), 1));
292  else
293  ids.push_back(CaloTowerDetId(id.ieta(), id.iphi() + 1));
294  } else {
295  if (id.iphi() == 71)
296  ids.push_back(CaloTowerDetId(id.ieta(), 1));
297  else
298  ids.push_back(CaloTowerDetId(id.ieta(), id.iphi() + 2));
299  }
300 
301  // get the neighbor with the lower iphi
302  if (id.ietaAbs() <= 20) {
303  if (id.iphi() == 1)
304  ids.push_back(CaloTowerDetId(id.ieta(), 72));
305  else
306  ids.push_back(CaloTowerDetId(id.ieta(), id.iphi() - 1));
307  } else {
308  if (id.iphi() == 1)
309  ids.push_back(CaloTowerDetId(id.ieta(), 71));
310  else
311  ids.push_back(CaloTowerDetId(id.ieta(), id.iphi() - 2));
312  }
313 
314  // get the neighbor with the higher ietaAbs
315  if (id.ietaAbs() == 20 && (id.iphi() % 2) == 0)
316  ids.push_back(CaloTowerDetId((id.ietaAbs() + 1) * id.zside(), id.iphi() - 1));
317  else
318  ids.push_back(CaloTowerDetId((id.ietaAbs() + 1) * id.zside(), id.iphi()));
319 
320  // get the neighbor(s) with the lower ietaAbs
321  if (id.ietaAbs() == 21) {
322  ids.push_back(CaloTowerDetId((id.ietaAbs() - 1) * id.zside(), id.iphi()));
323  ids.push_back(CaloTowerDetId((id.ietaAbs() - 1) * id.zside(), id.iphi() + 1));
324  } else if (id.ietaAbs() == 1) {
325  ids.push_back(CaloTowerDetId(-id.ieta(), id.iphi()));
326  } else {
327  ids.push_back(CaloTowerDetId((id.ietaAbs() - 1) * id.zside(), id.iphi()));
328  }
329 
330  // get the neighbor with higher ieta and higher iphi
331  if (id.ietaAbs() <= 19 || (id.ietaAbs() == 20 && (id.iphi() % 2) == 0)) {
332  if (id.iphi() == 72)
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() + 1));
336  } else if (id.ietaAbs() >= 21) {
337  if (id.iphi() == 71)
338  ids.push_back(CaloTowerDetId((id.ietaAbs() + 1) * id.zside(), 1));
339  else
340  ids.push_back(CaloTowerDetId((id.ietaAbs() + 1) * id.zside(), id.iphi() + 2));
341  }
342 
343  // get the neighbor with higher ieta and lower iphi
344  if (id.ietaAbs() <= 19) {
345  if (id.iphi() == 1)
346  ids.push_back(CaloTowerDetId((id.ietaAbs() + 1) * id.zside(), 72));
347  else
348  ids.push_back(CaloTowerDetId((id.ietaAbs() + 1) * id.zside(), id.iphi() - 1));
349  } else if (id.ietaAbs() >= 21 || (id.ietaAbs() == 20 && (id.iphi() % 2) == 1)) {
350  if (id.iphi() == 1)
351  ids.push_back(CaloTowerDetId((id.ietaAbs() + 1) * id.zside(), 71));
352  else
353  ids.push_back(CaloTowerDetId((id.ietaAbs() + 1) * id.zside(), id.iphi() - 2));
354  }
355 
356  // get the neighbor with lower ieta and higher iphi
357  if (id.ietaAbs() == 1) {
358  if (id.iphi() == 72)
359  ids.push_back(CaloTowerDetId(-id.ieta(), 1));
360  else
361  ids.push_back(CaloTowerDetId(-id.ieta(), id.iphi() + 1));
362  } else if (id.ietaAbs() <= 20) {
363  if (id.iphi() == 72)
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() + 1));
367  } else if (id.ietaAbs() >= 21) {
368  if (id.iphi() == 71)
369  ids.push_back(CaloTowerDetId((id.ietaAbs() - 1) * id.zside(), 1));
370  else
371  ids.push_back(CaloTowerDetId((id.ietaAbs() - 1) * id.zside(), id.iphi() + 2));
372  }
373 
374  // get the neighbor with lower ieta and lower iphi
375  if (id.ietaAbs() == 1) {
376  if (id.iphi() == 1)
377  ids.push_back(CaloTowerDetId(-id.ieta(), 72));
378  else
379  ids.push_back(CaloTowerDetId(-id.ieta(), id.iphi() - 1));
380  } else if (id.ietaAbs() <= 20) {
381  if (id.iphi() == 1)
382  ids.push_back(CaloTowerDetId((id.ietaAbs() - 1) * id.zside(), 72));
383  else
384  ids.push_back(CaloTowerDetId((id.ietaAbs() - 1) * id.zside(), id.iphi() - 1));
385  } else if (id.ietaAbs() >= 22) {
386  if (id.iphi() == 1)
387  ids.push_back(CaloTowerDetId((id.ietaAbs() - 1) * id.zside(), 71));
388  else
389  ids.push_back(CaloTowerDetId((id.ietaAbs() - 1) * id.zside(), id.iphi() - 2));
390  } else if (id.ietaAbs() == 21) {
391  if (id.iphi() == 1)
392  ids.push_back(CaloTowerDetId((id.ietaAbs() - 1) * id.zside(), 72));
393  else
394  ids.push_back(CaloTowerDetId((id.ietaAbs() - 1) * id.zside(), id.iphi() - 1));
395  }
396 
397  // clear neighbors
398  neighbors.clear();
399 
400  // find the neighbors and add them to the eponymous set
401  for (std::vector<CaloTowerDetId>::const_iterator it = ids.begin(); it != ids.end(); ++it) {
402  const PhysicsTower* twr = findTower(*it);
403  if (twr)
404  neighbors.insert(twr);
405  }
406 
407  return;
408 }
int zside(DetId const &)
const PhysicsTower * findTower(const CaloTowerDetId &id) const
void PhysicsTowerOrganizer::findNeighbors ( const PhysicsTower twr,
std::set< const PhysicsTower * > &  neighbors 
) const

Definition at line 410 of file HBHEIsolatedNoiseAlgos.cc.

References PhysicsTower::id.

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

Definition at line 415 of file HBHEIsolatedNoiseAlgos.cc.

415  {
416  findNeighbors(CaloTowerDetId(ieta, iphi), neighbors);
417  return;
418 }
void findNeighbors(const CaloTowerDetId &id, std::set< const PhysicsTower * > &neighbors) const
const PhysicsTower * PhysicsTowerOrganizer::findTower ( const CaloTowerDetId id) const
inline

Definition at line 252 of file HBHEIsolatedNoiseAlgos.cc.

References triggerObjects_cff::id, PhysicsTower::id, LEDCalibrationChannels::iphi, and ecaldqm::zside().

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

252  {
253  // create dummy PhysicsTower
255 
256  // correct for the merging of the |ieta|=28-29 towers
257  if (id.ietaAbs() == 29)
258  dummy.id = CaloTowerDetId((id.ietaAbs() - 1) * id.zside(), id.iphi());
259  else
260  dummy.id = id;
261 
262  // search on the dummy
263  std::set<PhysicsTower, towercmp>::iterator it = towers_.find(dummy);
264 
265  if (it == towers_.end())
266  return nullptr;
267  return &(*it);
268 }
int zside(DetId const &)
std::set< PhysicsTower, towercmp > towers_
const PhysicsTower * PhysicsTowerOrganizer::findTower ( int  ieta,
int  iphi 
) const
inline

Definition at line 270 of file HBHEIsolatedNoiseAlgos.cc.

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

Definition at line 231 of file HBHEIsolatedNoiseAlgos.cc.

References triggerObjects_cff::id, PhysicsTower::id, LEDCalibrationChannels::iphi, and ecaldqm::zside().

231  {
232  // create dummy PhysicsTower
234 
235  // correct for the merging of the |ieta|=28-29 towers
236  if (id.ietaAbs() == 29)
237  dummy.id = CaloTowerDetId((id.ietaAbs() - 1) * id.zside(), id.iphi());
238  else
239  dummy.id = id;
240 
241  // search on the dummy
242  std::set<PhysicsTower, towercmp>::iterator it = towers_.find(dummy);
243 
244  if (it == towers_.end())
245  return nullptr;
246 
247  // for whatever reason, I can't get a non-const out of the find method
248  PhysicsTower& twr = const_cast<PhysicsTower&>(*it);
249  return &twr;
250 }
int zside(DetId const &)
std::set< PhysicsTower, towercmp > towers_
PhysicsTower * PhysicsTowerOrganizer::findTower ( int  ieta,
int  iphi 
)
private

Definition at line 275 of file HBHEIsolatedNoiseAlgos.cc.

275  {
276  CaloTowerDetId tid(ieta, iphi);
277  return findTower(tid);
278 }
const PhysicsTower * findTower(const CaloTowerDetId &id) const
void PhysicsTowerOrganizer::insert_ ( CaloTowerDetId id,
const HBHERecHit hit 
)
private

Definition at line 420 of file HBHEIsolatedNoiseAlgos.cc.

References PhysicsTower::hcalhits, triggerObjects_cff::id, PhysicsTower::id, LEDCalibrationChannels::iphi, and ecaldqm::zside().

420  {
421  PhysicsTower* twr = findTower(id);
422  if (twr == nullptr) {
424  if (id.ietaAbs() == 29)
425  dummy.id = CaloTowerDetId((id.ietaAbs() - 1) * id.zside(), id.iphi());
426  else
427  dummy.id = id;
428  dummy.hcalhits.insert(hit);
429  towers_.insert(dummy);
430  } else {
431  twr->hcalhits.insert(hit);
432  }
433  return;
434 }
std::set< const HBHERecHit * > hcalhits
int zside(DetId const &)
const PhysicsTower * findTower(const CaloTowerDetId &id) const
std::set< PhysicsTower, towercmp > towers_
void PhysicsTowerOrganizer::insert_ ( CaloTowerDetId id,
const EcalRecHit hit 
)
private

Definition at line 436 of file HBHEIsolatedNoiseAlgos.cc.

References PhysicsTower::ecalhits, triggerObjects_cff::id, PhysicsTower::id, LEDCalibrationChannels::iphi, and ecaldqm::zside().

436  {
437  PhysicsTower* twr = findTower(id);
438  if (twr == nullptr) {
440  if (id.ietaAbs() == 29)
441  dummy.id = CaloTowerDetId((id.ietaAbs() - 1) * id.zside(), id.iphi());
442  else
443  dummy.id = id;
444  dummy.ecalhits.insert(hit);
445  towers_.insert(dummy);
446  } else {
447  twr->ecalhits.insert(hit);
448  }
449  return;
450 }
int zside(DetId const &)
const PhysicsTower * findTower(const CaloTowerDetId &id) const
std::set< PhysicsTower, towercmp > towers_
std::set< const EcalRecHit * > ecalhits
void PhysicsTowerOrganizer::insert_ ( CaloTowerDetId id,
const reco::Track hit 
)
private

Definition at line 452 of file HBHEIsolatedNoiseAlgos.cc.

References triggerObjects_cff::id, PhysicsTower::id, LEDCalibrationChannels::iphi, PhysicsTower::tracks, and ecaldqm::zside().

452  {
453  PhysicsTower* twr = findTower(id);
454  if (twr == nullptr) {
456  if (id.ietaAbs() == 29)
457  dummy.id = CaloTowerDetId((id.ietaAbs() - 1) * id.zside(), id.iphi());
458  else
459  dummy.id = id;
460  dummy.tracks.insert(track);
461  towers_.insert(dummy);
462  } else {
463  twr->tracks.insert(track);
464  }
465  return;
466 }
int zside(DetId const &)
const PhysicsTower * findTower(const CaloTowerDetId &id) const
std::set< PhysicsTower, towercmp > towers_
std::set< const reco::Track * > tracks

Member Data Documentation

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

Definition at line 206 of file HBHEIsolatedNoiseAlgos.h.