CMS 3D CMS Logo

DetSetAlgorithm.h
Go to the documentation of this file.
1 #ifndef DataFormats_Common_DetSetAlgorithm_h
2 #define DataFormats_Common_DetSetAlgorithm_h
3 
5 #include <algorithm>
6 #include <functional>
7 
8 //FIXME remove New when ready
9 namespace edmNew {
10 
11  // adapt the RecHit accessors to DSTV
12  template <typename DSTV, typename A, typename B>
13  typename DSTV::Range detsetRangeFromPair(DSTV const &v, std::pair<A, B> const &p) {
14  return v.equal_range(p.first, p.second);
15  }
16 
17  // invoke f for each object in the range of DataSets selected by sel
18  // to ease use, f is passed by reference
19  template <typename DSTV, typename A, typename B, typename F>
20  void foreachDetSetObject(DSTV const &v, std::pair<A, B> const &sel, F &f) {
21  typedef typename DSTV::data_type data_type;
22  typename DSTV::Range range = detsetRangeFromPair(v, sel);
23  for (typename DSTV::const_iterator id = range.first; id != range.second; id++)
24  std::for_each((*id).begin(), (*id).end(), std::function<void(const data_type &)>(std::ref(f)));
25  }
26 
27  namespace dstvdetails {
28 
29  struct Pointer {
30  template <typename H>
31  H const *operator()(H const &h) const {
32  return &h;
33  }
34  };
35 
36  } // namespace dstvdetails
37 
38  // to write an easy iterator on objects in a range of DataSets selected by sel
39  // is left as exercise to the reader
40  // here we provide this not optimal solution...
41  template <typename DSTV, typename A, typename B, typename T>
42  void copyDetSetRange(DSTV const &dstv, std::vector<T const *> &v, std::pair<A, B> const &sel) {
43  typename DSTV::Range range = dstv.equal_range(sel.first, sel.second);
44  for (typename DSTV::const_iterator id = range.first; id != range.second; id++) {
45  size_t cs = v.size();
46  v.resize(cs + (*id).size());
47  std::transform((*id).begin(), (*id).end(), v.begin() + cs, dstvdetails::Pointer());
48  }
49  }
50 } // namespace edmNew
51 
52 #endif // DataFormats_Common_DetSetAlgorithm_h
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
void copyDetSetRange(DSTV const &dstv, std::vector< T const * > &v, std::pair< A, B > const &sel)
PixelRecoRange< float > Range
unique_ptr< ClusterSequence > cs
double f[11][100]
void foreachDetSetObject(DSTV const &v, std::pair< A, B > const &sel, F &f)
H const * operator()(H const &h) const
DSTV::Range detsetRangeFromPair(DSTV const &v, std::pair< A, B > const &p)
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:163
unsigned transform(const HcalDetId &id, unsigned transformCode)