CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 165 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 130 of file HBHEIsolatedNoiseAlgos.cc.

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

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

Definition at line 182 of file HBHEIsolatedNoiseAlgos.h.

182 {}

Member Function Documentation

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

Definition at line 252 of file HBHEIsolatedNoiseAlgos.cc.

References findTower(), CaloTowerDetId::ietaAbs(), CaloTowerDetId::iphi(), and CaloTowerDetId::zside().

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

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

Definition at line 350 of file HBHEIsolatedNoiseAlgos.cc.

References findNeighbors(), and PhysicsTower::id.

351 {
352  findNeighbors(twr->id, neighbors);
353  return;
354 }
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 356 of file HBHEIsolatedNoiseAlgos.cc.

References findNeighbors().

357 {
358  findNeighbors(CaloTowerDetId(ieta, iphi), neighbors);
359  return;
360 }
void findNeighbors(const CaloTowerDetId &id, std::set< const PhysicsTower * > &neighbors) const
const PhysicsTower * PhysicsTowerOrganizer::findTower ( const CaloTowerDetId id) const
inline

Definition at line 224 of file HBHEIsolatedNoiseAlgos.cc.

References PhysicsTower::id, and towers_.

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

225 {
226  // create dummy PhysicsTower
227  PhysicsTower dummy;
228 
229  // correct for the merging of the |ieta|=28-29 towers
230  if(id.ietaAbs()==29) dummy.id = CaloTowerDetId((id.ietaAbs()-1)*id.zside(), id.iphi());
231  else dummy.id=id;
232 
233  // search on the dummy
234  std::set<PhysicsTower, towercmp>::iterator it=towers_.find(dummy);
235 
236  if(it==towers_.end()) return 0;
237  return &(*it);
238 }
std::set< PhysicsTower, towercmp > towers_
const PhysicsTower * PhysicsTowerOrganizer::findTower ( int  ieta,
int  iphi 
) const
inline

Definition at line 240 of file HBHEIsolatedNoiseAlgos.cc.

References findTower().

241 {
242  CaloTowerDetId tid(ieta, iphi);
243  return findTower(tid);
244 }
const PhysicsTower * findTower(const CaloTowerDetId &id) const
PhysicsTower * PhysicsTowerOrganizer::findTower ( const CaloTowerDetId id)
private

Definition at line 205 of file HBHEIsolatedNoiseAlgos.cc.

References PhysicsTower::id, and towers_.

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

Definition at line 246 of file HBHEIsolatedNoiseAlgos.cc.

References findTower().

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

Definition at line 362 of file HBHEIsolatedNoiseAlgos.cc.

References findTower(), PhysicsTower::hcalhits, PhysicsTower::id, and towers_.

Referenced by PhysicsTowerOrganizer().

363 {
364  PhysicsTower* twr=findTower(id);
365  if(twr==0) {
366  PhysicsTower dummy;
367  if(id.ietaAbs()==29)
368  dummy.id = CaloTowerDetId((id.ietaAbs()-1)*id.zside(), id.iphi());
369  else
370  dummy.id = id;
371  dummy.hcalhits.insert(hit);
372  towers_.insert(dummy);
373  } else {
374  twr->hcalhits.insert(hit);
375  }
376  return;
377 }
std::set< const HBHERecHit * > hcalhits
const PhysicsTower * findTower(const CaloTowerDetId &id) const
std::set< PhysicsTower, towercmp > towers_
void PhysicsTowerOrganizer::insert_ ( CaloTowerDetId id,
const EcalRecHit hit 
)
private

Definition at line 379 of file HBHEIsolatedNoiseAlgos.cc.

References PhysicsTower::ecalhits, findTower(), PhysicsTower::id, and towers_.

380 {
381  PhysicsTower* twr=findTower(id);
382  if(twr==0) {
383  PhysicsTower dummy;
384  if(id.ietaAbs()==29)
385  dummy.id = CaloTowerDetId((id.ietaAbs()-1)*id.zside(), id.iphi());
386  else
387  dummy.id = id;
388  dummy.ecalhits.insert(hit);
389  towers_.insert(dummy);
390  } else {
391  twr->ecalhits.insert(hit);
392  }
393  return;
394 }
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 396 of file HBHEIsolatedNoiseAlgos.cc.

References findTower(), PhysicsTower::id, towers_, and PhysicsTower::tracks.

397 {
398  PhysicsTower* twr=findTower(id);
399  if(twr==0) {
400  PhysicsTower dummy;
401  if(id.ietaAbs()==29)
402  dummy.id = CaloTowerDetId((id.ietaAbs()-1)*id.zside(), id.iphi());
403  else
404  dummy.id = id;
405  dummy.tracks.insert(track);
406  towers_.insert(dummy);
407  } else {
408  twr->tracks.insert(track);
409  }
410  return;
411 }
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 203 of file HBHEIsolatedNoiseAlgos.h.

Referenced by findTower(), and insert_().