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 167 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 136 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(), HiIsolationCommonParameters_cff::track, reco::TrackExtrapolation::track(), ObjectValidatorAbs::validHit(), and ObjectValidatorAbs::validTrack().

144 {
145  // get some geometries
147  evSetup.get<CaloGeometryRecord>().get(pG);
148  const CaloGeometry* geo = pG.product();
151 
152  // do the HCAL hits
153  for(HBHERecHitCollection::const_iterator it=hbhehitcoll_h->begin(); it!=hbhehitcoll_h->end(); ++it) {
154  const HBHERecHit* hit=&(*it);
155 
156  // check that the hit is valid
157  if(!objectvalidator.validHit(*hit)) continue;
158 
159  // add the hit to the organizer
160  CaloTowerDetId tid = ctcm.towerOf(hit->id());
161  insert_(tid, hit);
162  }
163 
164  // do the EB hits
165  for(EcalRecHitCollection::const_iterator it=ebhitcoll_h->begin(); it!=ebhitcoll_h->end(); ++it) {
166  const EcalRecHit* hit=&(*it);
167 
168  if(!objectvalidator.validHit(*hit)) continue;
169  CaloTowerDetId tid = ctcm.towerOf(hit->id());
170  insert_(tid, hit);
171  }
172 
173  // do the EE hits
174  for(EcalRecHitCollection::const_iterator it=eehitcoll_h->begin(); it!=eehitcoll_h->end(); ++it) {
175  const EcalRecHit* hit=&(*it);
176 
177  if(!objectvalidator.validHit(*hit)) continue;
178  CaloTowerDetId tid = ctcm.towerOf(hit->id());
179  insert_(tid, hit);
180  }
181 
182  // do the tracks
183  for(std::vector<reco::TrackExtrapolation>::const_iterator it=trackextrapcoll_h->begin(); it!=trackextrapcoll_h->end(); ++it) {
184  const reco::TrackExtrapolation* extrap=&(*it);
185  const reco::Track* track = &(*(extrap->track()));
186 
187  // validate track
188  if(!objectvalidator.validTrack(*track)) continue;
189 
190  // get the point
191  if ( extrap->positions().empty() ) continue;
192  const GlobalPoint point(extrap->positions().front().x(),
193  extrap->positions().front().y(),
194  extrap->positions().front().z());
195 
196 
197  if(std::fabs(point.eta())<1.479) {
198  EBDetId cell = gEB->getClosestCell(point);
199  CaloTowerDetId tid = ctcm.towerOf(cell);
200  insert_(tid, track);
201  } else {
202  EEDetId cell = gEE->getClosestCell(point);
203  CaloTowerDetId tid = ctcm.towerOf(cell);
204  insert_(tid, track);
205  }
206  }
207 
208  return;
209 }
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:49
HcalDetId id() const
get the id
Definition: HBHERecHit.h:42
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:71
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 184 of file HBHEIsolatedNoiseAlgos.h.

184 {}

Member Function Documentation

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

Definition at line 258 of file HBHEIsolatedNoiseAlgos.cc.

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

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

259 {
260  // correct for the merging of the |ieta|=28-29 towers
261  CaloTowerDetId id(tempid);
262  if(tempid.ietaAbs()==29) id = CaloTowerDetId((tempid.ietaAbs()-1)*tempid.zside(), tempid.iphi());
263 
264  std::vector<CaloTowerDetId> ids;
265  // get the neighbor with higher iphi
266  if(id.ietaAbs()<=20) {
267  if(id.iphi()==72) ids.push_back(CaloTowerDetId(id.ieta(), 1));
268  else ids.push_back(CaloTowerDetId(id.ieta(), id.iphi()+1));
269  } else {
270  if(id.iphi()==71) ids.push_back(CaloTowerDetId(id.ieta(), 1));
271  else ids.push_back(CaloTowerDetId(id.ieta(), id.iphi()+2));
272  }
273 
274  // get the neighbor with the lower iphi
275  if(id.ietaAbs()<=20) {
276  if(id.iphi()==1) ids.push_back(CaloTowerDetId(id.ieta(), 72));
277  else ids.push_back(CaloTowerDetId(id.ieta(), id.iphi()-1));
278  } else {
279  if(id.iphi()==1) ids.push_back(CaloTowerDetId(id.ieta(), 71));
280  else ids.push_back(CaloTowerDetId(id.ieta(), id.iphi()-2));
281  }
282 
283  // get the neighbor with the higher ietaAbs
284  if(id.ietaAbs()==20 && (id.iphi()%2)==0)
285  ids.push_back(CaloTowerDetId((id.ietaAbs()+1)*id.zside(), id.iphi()-1));
286  else
287  ids.push_back(CaloTowerDetId((id.ietaAbs()+1)*id.zside(), id.iphi()));
288 
289  // get the neighbor(s) with the lower ietaAbs
290  if(id.ietaAbs()==21) {
291  ids.push_back(CaloTowerDetId((id.ietaAbs()-1)*id.zside(), id.iphi()));
292  ids.push_back(CaloTowerDetId((id.ietaAbs()-1)*id.zside(), id.iphi()+1));
293  } else if(id.ietaAbs()==1) {
294  ids.push_back(CaloTowerDetId(-id.ieta(), id.iphi()));
295  } else {
296  ids.push_back(CaloTowerDetId((id.ietaAbs()-1)*id.zside(), id.iphi()));
297  }
298 
299  // get the neighbor with higher ieta and higher iphi
300  if(id.ietaAbs()<=19 || (id.ietaAbs()==20 && (id.iphi()%2)==0)) {
301  if(id.iphi()==72) ids.push_back(CaloTowerDetId((id.ietaAbs()+1)*id.zside(), 1));
302  else ids.push_back(CaloTowerDetId((id.ietaAbs()+1)*id.zside(), id.iphi()+1));
303  } else if(id.ietaAbs()>=21) {
304  if(id.iphi()==71) ids.push_back(CaloTowerDetId((id.ietaAbs()+1)*id.zside(), 1));
305  else ids.push_back(CaloTowerDetId((id.ietaAbs()+1)*id.zside(), id.iphi()+2));
306  }
307 
308  // get the neighbor with higher ieta and lower iphi
309  if(id.ietaAbs()<=19) {
310  if(id.iphi()==1) ids.push_back(CaloTowerDetId((id.ietaAbs()+1)*id.zside(), 72));
311  else ids.push_back(CaloTowerDetId((id.ietaAbs()+1)*id.zside(), id.iphi()-1));
312  } else if(id.ietaAbs()>=21 || (id.ietaAbs()==20 && (id.iphi()%2)==1)) {
313  if(id.iphi()==1) ids.push_back(CaloTowerDetId((id.ietaAbs()+1)*id.zside(), 71));
314  else ids.push_back(CaloTowerDetId((id.ietaAbs()+1)*id.zside(), id.iphi()-2));
315  }
316 
317  // get the neighbor with lower ieta and higher iphi
318  if(id.ietaAbs()==1) {
319  if(id.iphi()==72) ids.push_back(CaloTowerDetId(-id.ieta(), 1));
320  else ids.push_back(CaloTowerDetId(-id.ieta(), id.iphi()+1));
321  } else if(id.ietaAbs()<=20) {
322  if(id.iphi()==72) ids.push_back(CaloTowerDetId((id.ietaAbs()-1)*id.zside(), 1));
323  else ids.push_back(CaloTowerDetId((id.ietaAbs()-1)*id.zside(), id.iphi()+1));
324  } else if(id.ietaAbs()>=21) {
325  if(id.iphi()==71) ids.push_back(CaloTowerDetId((id.ietaAbs()-1)*id.zside(), 1));
326  else ids.push_back(CaloTowerDetId((id.ietaAbs()-1)*id.zside(), id.iphi()+2));
327  }
328 
329  // get the neighbor with lower ieta and lower iphi
330  if(id.ietaAbs()==1) {
331  if(id.iphi()==1) ids.push_back(CaloTowerDetId(-id.ieta(), 72));
332  else ids.push_back(CaloTowerDetId(-id.ieta(), id.iphi()-1));
333  } else if(id.ietaAbs()<=20) {
334  if(id.iphi()==1) ids.push_back(CaloTowerDetId((id.ietaAbs()-1)*id.zside(), 72));
335  else ids.push_back(CaloTowerDetId((id.ietaAbs()-1)*id.zside(), id.iphi()-1));
336  } else if(id.ietaAbs()>=22) {
337  if(id.iphi()==1) ids.push_back(CaloTowerDetId((id.ietaAbs()-1)*id.zside(), 71));
338  else ids.push_back(CaloTowerDetId((id.ietaAbs()-1)*id.zside(), id.iphi()-2));
339  } else if(id.ietaAbs()==21) {
340  if(id.iphi()==1) ids.push_back(CaloTowerDetId((id.ietaAbs()-1)*id.zside(), 72));
341  else ids.push_back(CaloTowerDetId((id.ietaAbs()-1)*id.zside(), id.iphi()-1));
342  }
343 
344  // clear neighbors
345  neighbors.clear();
346 
347  // find the neighbors and add them to the eponymous set
348  for(std::vector<CaloTowerDetId>::const_iterator it=ids.begin(); it!=ids.end(); ++it) {
349  const PhysicsTower* twr=findTower(*it);
350  if(twr) neighbors.insert(twr);
351  }
352 
353  return;
354 }
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 356 of file HBHEIsolatedNoiseAlgos.cc.

References PhysicsTower::id.

357 {
358  findNeighbors(twr->id, neighbors);
359  return;
360 }
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 362 of file HBHEIsolatedNoiseAlgos.cc.

363 {
364  findNeighbors(CaloTowerDetId(ieta, iphi), neighbors);
365  return;
366 }
void findNeighbors(const CaloTowerDetId &id, std::set< const PhysicsTower * > &neighbors) const
const PhysicsTower * PhysicsTowerOrganizer::findTower ( const CaloTowerDetId id) const
inline

Definition at line 230 of file HBHEIsolatedNoiseAlgos.cc.

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

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

231 {
232  // create dummy PhysicsTower
234 
235  // correct for the merging of the |ieta|=28-29 towers
236  if(id.ietaAbs()==29) dummy.id = CaloTowerDetId((id.ietaAbs()-1)*id.zside(), id.iphi());
237  else dummy.id=id;
238 
239  // search on the dummy
240  std::set<PhysicsTower, towercmp>::iterator it=towers_.find(dummy);
241 
242  if(it==towers_.end()) return nullptr;
243  return &(*it);
244 }
int zside(DetId const &)
std::set< PhysicsTower, towercmp > towers_
const PhysicsTower * PhysicsTowerOrganizer::findTower ( int  ieta,
int  iphi 
) const
inline

Definition at line 246 of file HBHEIsolatedNoiseAlgos.cc.

247 {
248  CaloTowerDetId tid(ieta, iphi);
249  return findTower(tid);
250 }
const PhysicsTower * findTower(const CaloTowerDetId &id) const
PhysicsTower * PhysicsTowerOrganizer::findTower ( const CaloTowerDetId id)
private

Definition at line 211 of file HBHEIsolatedNoiseAlgos.cc.

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

212 {
213  // create dummy PhysicsTower
215 
216  // correct for the merging of the |ieta|=28-29 towers
217  if(id.ietaAbs()==29) dummy.id = CaloTowerDetId((id.ietaAbs()-1)*id.zside(), id.iphi());
218  else dummy.id=id;
219 
220  // search on the dummy
221  std::set<PhysicsTower, towercmp>::iterator it=towers_.find(dummy);
222 
223  if(it==towers_.end()) return nullptr;
224 
225  // for whatever reason, I can't get a non-const out of the find method
226  PhysicsTower &twr = const_cast<PhysicsTower&>(*it);
227  return &twr;
228 }
int zside(DetId const &)
std::set< PhysicsTower, towercmp > towers_
PhysicsTower * PhysicsTowerOrganizer::findTower ( int  ieta,
int  iphi 
)
private

Definition at line 252 of file HBHEIsolatedNoiseAlgos.cc.

253 {
254  CaloTowerDetId tid(ieta, iphi);
255  return findTower(tid);
256 }
const PhysicsTower * findTower(const CaloTowerDetId &id) const
void PhysicsTowerOrganizer::insert_ ( CaloTowerDetId id,
const HBHERecHit hit 
)
private

Definition at line 368 of file HBHEIsolatedNoiseAlgos.cc.

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

369 {
370  PhysicsTower* twr=findTower(id);
371  if(twr==nullptr) {
373  if(id.ietaAbs()==29)
374  dummy.id = CaloTowerDetId((id.ietaAbs()-1)*id.zside(), id.iphi());
375  else
376  dummy.id = id;
377  dummy.hcalhits.insert(hit);
378  towers_.insert(dummy);
379  } else {
380  twr->hcalhits.insert(hit);
381  }
382  return;
383 }
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 385 of file HBHEIsolatedNoiseAlgos.cc.

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

386 {
387  PhysicsTower* twr=findTower(id);
388  if(twr==nullptr) {
390  if(id.ietaAbs()==29)
391  dummy.id = CaloTowerDetId((id.ietaAbs()-1)*id.zside(), id.iphi());
392  else
393  dummy.id = id;
394  dummy.ecalhits.insert(hit);
395  towers_.insert(dummy);
396  } else {
397  twr->ecalhits.insert(hit);
398  }
399  return;
400 }
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 402 of file HBHEIsolatedNoiseAlgos.cc.

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

403 {
404  PhysicsTower* twr=findTower(id);
405  if(twr==nullptr) {
407  if(id.ietaAbs()==29)
408  dummy.id = CaloTowerDetId((id.ietaAbs()-1)*id.zside(), id.iphi());
409  else
410  dummy.id = id;
411  dummy.tracks.insert(track);
412  towers_.insert(dummy);
413  } else {
414  twr->tracks.insert(track);
415  }
416  return;
417 }
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 205 of file HBHEIsolatedNoiseAlgos.h.