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;
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
class-composition.H
H
Definition: class-composition.py:31
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
Range
PixelRecoRange< float > Range
Definition: PixelTripletHLTGenerator.cc:31
edmNew::detsetRangeFromPair
DSTV::Range detsetRangeFromPair(DSTV const &v, std::pair< A, B > const &p)
Definition: DetSetAlgorithm.h:13
fwrapper::cs
unique_ptr< ClusterSequence > cs
Definition: fastjetfortran_madfks.cc:47
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
h
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
Definition: L1TUtmAlgorithmRcd.h:4
findQualityFiles.v
v
Definition: findQualityFiles.py:179
edmNew
Definition: DetSet2RangeMap.h:11
F
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:163
HcalDetIdTransform::transform
unsigned transform(const HcalDetId &id, unsigned transformCode)
Definition: HcalDetIdTransform.cc:7
h
edmNew::copyDetSetRange
void copyDetSetRange(DSTV const &dstv, std::vector< T const * > &v, std::pair< A, B > const &sel)
Definition: DetSetAlgorithm.h:42
edmNew::dstvdetails::Pointer
Definition: DetSetAlgorithm.h:29
edmNew::dstvdetails::Pointer::operator()
const H * operator()(H const &h) const
Definition: DetSetAlgorithm.h:31
ecal::multifit::data_type
::ecal::reco::ComputationScalarType data_type
Definition: EigenMatrixTypes_gpu.h:18
EgammaValidation_Wenu_cff.sel
sel
Definition: EgammaValidation_Wenu_cff.py:33
edmNew::foreachDetSetObject
void foreachDetSetObject(DSTV const &v, std::pair< A, B > const &sel, F &f)
Definition: DetSetAlgorithm.h:20
DetSetVectorNew.h