CMS 3D CMS Logo

CaloConeSelector.h
Go to the documentation of this file.
1 #ifndef RECOCALOTOOLS_SELECTORS_CALOCONESELECTOR_H
2 #define RECOCALOTOOLS_SELECTORS_CALOCONESELECTOR_H 1
3 
7 #include <memory>
8 
14 template <class T>
16 public:
18  geom_(geom),deltaR_(dR),detector_(DetId::Detector(0)),subdet_(0) {}
19 
20  CaloConeSelector(double dR, const CaloGeometry* geom, DetId::Detector detector, int subdet=0) :
21  geom_(geom),deltaR_(dR),detector_(detector),subdet_(subdet) {}
22 
23  void inline selectCallback(double eta, double phi, const edm::SortedCollection<T>& inputCollection, std::function<void(const T&)> callback) {
24  GlobalPoint p(GlobalPoint::Cylindrical(1,phi,tanh(eta)));
25  return selectCallback(p, inputCollection, callback);
26  }
27 
28  void inline selectCallback(const GlobalPoint& p, const edm::SortedCollection<T>& inputCollection, std::function<void(const T&)> callback) {
29  // TODO: handle default setting of detector_ (loops over subdet)
30  // TODO: heuristics of when it is better to loop over inputCollection instead (small # hits)
31  for (int subdet=subdet_; subdet<=7 && (subdet_==0 || subdet_==subdet); subdet++) {
33  if (sdg!=nullptr) {
34  // get the list of detids within range (from geometry)
36  // loop over detids...
37  typename edm::SortedCollection<T>::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)
43  callback(*j);
44  }
45  }
46  }
47  }
48 
49 private:
51  double deltaR_;
53  int subdet_;
54 };
55 
56 #endif
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:44
CaloConeSelector(double dR, const CaloGeometry *geom, DetId::Detector detector, int subdet=0)
std::vector< T >::const_iterator const_iterator
void selectCallback(const GlobalPoint &p, const edm::SortedCollection< T > &inputCollection, std::function< void(const T &)> callback)
const CaloGeometry * geom_
virtual DetIdSet getCells(const GlobalPoint &r, double dR) const
Get a list of all cells within a dR of the given cell.
CaloConeSelector(double dR, const CaloGeometry *geom)
const_iterator end() const
Definition: DetId.h:18
Detector
Definition: DetId.h:24
void selectCallback(double eta, double phi, const edm::SortedCollection< T > &inputCollection, std::function< void(const T &)> callback)
iterator find(key_type k)
DetId::Detector detector_
long double T