CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
CaloDualConeSelector.h
Go to the documentation of this file.
1 #ifndef RECOCALOTOOLS_SELECTORS_CALODUALCONESELECTOR_H
2 #define RECOCALOTOOLS_SELECTORS_CALODUALCONESELECTOR_H 1
3 
7 #include <memory>
8 
13 template <class T>
15 public:
16  CaloDualConeSelector(double dRmin, double dRmax, const CaloGeometry* geom)
17  : geom_(geom), deltaRmin_(dRmin), deltaRmax_(dRmax), detector_(DetId::Detector(0)), subdet_(0) {}
18 
19  CaloDualConeSelector(double dRmin, double dRmax, const CaloGeometry* geom, DetId::Detector detector, int subdet = 0)
20  : geom_(geom), deltaRmin_(dRmin), deltaRmax_(dRmax), detector_(detector), subdet_(subdet) {}
21 
22  void inline selectCallback(double eta,
23  double phi,
25  std::function<void(const T&)> callback) {
26  GlobalPoint p(GlobalPoint::Cylindrical(1, phi, tanh(eta)));
27  return selectCallback(p, inputCollection, callback);
28  }
29 
30  void inline selectCallback(const GlobalPoint& p,
31  const edm::SortedCollection<T>& inputCollection,
32  std::function<void(const T&)> callback) {
33  // TODO: handle default setting of detector_ (loops over subdet)
34  // TODO: heuristics of when it is better to loop over inputCollection instead (small # hits)
35  for (int subdet = subdet_; subdet <= 7 && (subdet_ == 0 || subdet_ == subdet); subdet++) {
37  if (sdg != nullptr) {
38  // get the list of detids within range (from geometry)
41  // use set operations to determine detids in annulus
44  dis_all.begin(), dis_all.end(), dis_excl.begin(), dis_excl.end(), std::inserter(dis, dis.begin()));
45 
46  // loop over detids...
47  typename edm::SortedCollection<T>::const_iterator j, je = inputCollection.end();
48 
49  for (CaloSubdetectorGeometry::DetIdSet::iterator i = dis.begin(); i != dis.end(); i++) {
50  if (i->subdetId() != subdet)
51  continue; // possible for HCAL where the same geometry object handles all the detectors
52  j = inputCollection.find(*i);
53  if (j != je)
54  callback(*j);
55  }
56  }
57  }
58  }
59 
60 private:
64  int subdet_;
65 };
66 
67 #endif
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:34
std::vector< T >::const_iterator const_iterator
CaloDualConeSelector(double dRmin, double dRmax, 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.
string function
Definition: callgraph.py:50
const CaloGeometry * geom_
CaloDualConeSelector(double dRmin, double dRmax, const CaloGeometry *geom, DetId::Detector detector, int subdet=0)
const_iterator end() const
Definition: DetId.h:17
Detector
Definition: DetId.h:24
void selectCallback(const GlobalPoint &p, const edm::SortedCollection< T > &inputCollection, std::function< void(const T &)> callback)
void selectCallback(double eta, double phi, const edm::SortedCollection< T > &inputCollection, std::function< void(const T &)> callback)
iterator find(key_type k)
tuple inputCollection
long double T
std::vector< std::string > set_difference(std::vector< std::string > const &v1, std::vector< std::string > const &v2)