CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CaloDualConeSelector.cc
Go to the documentation of this file.
4 
5 #include <algorithm>
6 
7 CaloDualConeSelector::CaloDualConeSelector(double dRmin, double dRmax, const CaloGeometry* geom) :
8  geom_(geom),deltaRmin_(dRmin),deltaRmax_(dRmax),detector_(DetId::Detector(0)),subdet_(0) {
9 }
10 
11 CaloDualConeSelector::CaloDualConeSelector(double dRmin, double dRmax, const CaloGeometry* geom, DetId::Detector detector, int subdet) :
12  geom_(geom),deltaRmin_(dRmin),deltaRmax_(dRmax),detector_(detector),subdet_(subdet) {
13 }
14 
15 std::auto_ptr<CaloRecHitMetaCollectionV> CaloDualConeSelector::select(double eta, double phi, const CaloRecHitMetaCollectionV& inputCollection) {
16  GlobalPoint p(GlobalPoint::Cylindrical(1,phi,tanh(eta)));
17  return select(p,inputCollection);
18 }
19 
20 std::auto_ptr<CaloRecHitMetaCollectionV> CaloDualConeSelector::select(const GlobalPoint& p, const CaloRecHitMetaCollectionV& inputCollection) {
22 
23  // TODO: handle default setting of detector_ (loops over subdet)
24  // TODO: heuristics of when it is better to loop over inputCollection instead (small # hits)
25  for (int subdet=subdet_; subdet<=7 && (subdet_==0 || subdet_==subdet); subdet++) {
27  if (sdg!=0) {
28  // get the list of detids within range (from geometry)
31  // use set operations to determine detids in annulus
33  std::set_difference(dis_all.begin(),dis_all.end(),
34  dis_excl.begin(),dis_excl.end(),
35  std::inserter(dis,dis.begin()));
36  // loop over detids...
37  CaloRecHitMetaCollectionV::const_iterator j,je=inputCollection.end();
38 
39  for (CaloSubdetectorGeometry::DetIdSet::iterator i=dis.begin(); i!=dis.end(); i++) {
40  if (i->subdetId()!=subdet) continue; // possible for HCAL where the same geometry object handles all the detectors
41  j=inputCollection.find(*i);
42  if (j!=je) c->add(&(*j));
43  }
44  }
45  }
46 
47  return std::auto_ptr<CaloRecHitMetaCollectionV>(c);
48 }
virtual const_iterator find(const DetId &id) const
find by id (default version is very slow unsorted find)
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:43
int i
Definition: DBlmapReader.cc:9
T eta() const
void add(const CaloRecHit *hit)
add an item to the collection
const_iterator end() const
get the ending iterator
virtual DetIdSet getCells(const GlobalPoint &r, double dR) const
Get a list of all cells within a dR of the given cell.
std::auto_ptr< CaloRecHitMetaCollectionV > select(double eta, double phi, const CaloRecHitMetaCollectionV &inputCollection)
int j
Definition: DBlmapReader.cc:9
Definition: DetId.h:18
Detector
Definition: DetId.h:24
CaloDualConeSelector(double dRmin, double dRmax, const CaloGeometry *geom)
Definition: DDAxes.h:10
const CaloGeometry * geom_