CMS 3D CMS Logo

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 "DataFormats/DetId/interface/DetId.h"
00009 
00010 #include <boost/ref.hpp>
00011 // #include <boost/bind.hpp>
00012 // #include <boost/function.hpp>
00013 #include <algorithm>
00014 
00015 //FIXME remove New when ready
00016 namespace edmNew {
00017 
00018   namespace dstvdetails {
00019     // copy from DS to RM
00020     template<typename B>
00021     struct ToRM {
00022       ToRM(edm::RangeMap<DetId, edm::OwnVector<B> > & irm) : rm(&irm){}
00023       edm::RangeMap<DetId, edm::OwnVector<B> > * rm;
00024       template<typename T>
00025       void operator()(edmNew::DetSet<T> const&  ds) {
00026         // make it easy
00027         // std::vector<T const *> v(ds.size());
00028         //std::transform(ds.begin(),ds.end(),v.begin(),dstvdetails::Pointer());
00029         if (!ds.empty()) rm->put(ds.id(), ds.begin(), ds.end());
00030       }
00031     };
00032   }
00033 
00034   // copy from DSTV to RangeMap
00035   template<typename T, typename B>
00036   void copy(DetSetVector<T> const&  dstv,
00037        edm::RangeMap<DetId, edm::OwnVector<B> > & rm) {
00038     dstvdetails::ToRM<B> torm(rm);
00039     std::for_each(dstv.begin(), dstv.end(), torm);
00040   }
00041 
00042 }
00043  
00044 #endif // DataFormats_Common_DetSet2RangeMap_h

Generated on Tue Jun 9 17:28:42 2009 for CMSSW by  doxygen 1.5.4