CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_9_patch3/src/DataFormats/Common/interface/DetSet2RangeMap.h

Go to the documentation of this file.
00001 #ifndef DataFormats_Common_DetSet2RangeMap_h
00002 #define DataFormats_Common_DetSet2RangeMap_h
00003 
00004 #include "DataFormats/Common/interface/DetSetVectorNew.h"
00005 #include "DataFormats/Common/interface/RangeMap.h"
00006 // #include "DataFormats/Common/interface/DetSetAlgorithm.h"
00007 
00008 #include <algorithm>
00009 
00010 //FIXME remove New when ready
00011 namespace edmNew {
00012 
00013   namespace dstvdetails {
00014     // copy from DS to RM
00015     template<typename B>
00016     struct ToRM {
00017       ToRM(edm::RangeMap<det_id_type, edm::OwnVector<B> > & irm) : rm(&irm){}
00018       edm::RangeMap<det_id_type, edm::OwnVector<B> > * rm;
00019       template<typename T>
00020       void operator()(edmNew::DetSet<T> const&  ds) {
00021         // make it easy
00022         // std::vector<T const *> v(ds.size());
00023         //std::transform(ds.begin(),ds.end(),v.begin(),dstvdetails::Pointer());
00024         if (!ds.empty()) rm->put(ds.id(), ds.begin(), ds.end());
00025       }
00026     };
00027   }
00028 
00029   // copy from DSTV to RangeMap
00030   template<typename T, typename B>
00031   void copy(DetSetVector<T> const&  dstv,
00032        edm::RangeMap<det_id_type, edm::OwnVector<B> > & rm) {
00033     dstvdetails::ToRM<B> torm(rm);
00034     std::for_each(dstv.begin(), dstv.end(), torm);
00035   }
00036 
00037 }
00038  
00039 #endif // DataFormats_Common_DetSet2RangeMap_h