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 <boost/ref.hpp>
6 #include <boost/function.hpp>
7 #include <algorithm>
8 
9 //FIXME remove New when ready
10 namespace edmNew {
11 
12  // adapt the RecHit accessors to DSTV
13  template <typename DSTV, typename A, typename B>
14  typename DSTV::Range detsetRangeFromPair(DSTV const & v, std::pair<A,B> const & p) {
15  return v.equal_range(p.first,p.second);
16  }
17 
18 
19  // invoke f for each object in the range of DataSets selected by sel
20  // to ease use, f is passed by reference
21  template <typename DSTV, typename A, typename B, typename F>
22  void foreachDetSetObject(DSTV const & v, std::pair<A,B> const & sel, F & f) {
23  typedef typename DSTV::data_type data_type;
24  typename DSTV::Range range = detsetRangeFromPair(v,sel);
25  for(typename DSTV::const_iterator id=range.first; id!=range.second; id++)
26  std::for_each((*id).begin(), (*id).end(),
27  boost::function<void(const data_type &)>(boost::ref(f)));
28  }
29 
30  namespace dstvdetails {
31 
32  struct Pointer {
33  template<typename H>
34  H const * operator()(H const& h) const { return &h;}
35  };
36 
37  }
38 
39  // to write an easy iterator on objects in a range of DataSets selected by sel
40  // is left as exercise to the reader
41  // here we provide this not optimal solution...
42  template <typename DSTV, typename A, typename B, typename T>
43  void copyDetSetRange(DSTV const & dstv,
44  std::vector<T const *> & v,
45  std::pair<A,B> const & sel) {
46  typename DSTV::Range range = dstv.equal_range(sel.first,sel.second);
47  for(typename DSTV::const_iterator id=range.first; id!=range.second; id++){
48  size_t cs = v.size();
49  v.resize(cs+(*id).size());
50  std::transform((*id).begin(), (*id).end(),v.begin()+cs,dstvdetails::Pointer());
51  }
52  }
53 }
54 
55 
56 #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
double f[11][100]
PixelRecoRange< float > Range
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
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
mathSSE::Vec4< T > v