test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
18  // invoke f for each object in the range of DataSets selected by sel
19  // to ease use, f is passed by reference
20  template <typename DSTV, typename A, typename B, typename F>
21  void foreachDetSetObject(DSTV const & v, std::pair<A,B> const & sel, F & f) {
22  typedef typename DSTV::data_type data_type;
23  typename DSTV::Range range = detsetRangeFromPair(v,sel);
24  for(typename DSTV::const_iterator id=range.first; id!=range.second; id++)
25  std::for_each((*id).begin(), (*id).end(),
26  std::function<void(const data_type &)>(std::ref(f)));
27  }
28 
29  namespace dstvdetails {
30 
31  struct Pointer {
32  template<typename H>
33  H const * operator()(H const& h) const { return &h;}
34  };
35 
36  }
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,
43  std::vector<T const *> & v,
44  std::pair<A,B> const & sel) {
45  typename DSTV::Range range = dstv.equal_range(sel.first,sel.second);
46  for(typename DSTV::const_iterator id=range.first; id!=range.second; id++){
47  size_t cs = v.size();
48  v.resize(cs+(*id).size());
49  std::transform((*id).begin(), (*id).end(),v.begin()+cs,dstvdetails::Pointer());
50  }
51  }
52 }
53 
54 
55 #endif // DataFormats_Common_DetSetAlgorithm_h
void copyDetSetRange(DSTV const &dstv, std::vector< T const * > &v, std::pair< A, B > const &sel)
auto_ptr< ClusterSequence > cs
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
PixelRecoRange< float > Range
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:281