Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:53:06

0001 #include "DataFormats/Common/interface/DetSetVectorNew.h"
0002 #include "FWCore/Utilities/interface/Exception.h"
0003 #include <iostream>
0004 #include <functional>
0005 
0006 struct T {
0007   float v;
0008 };
0009 
0010 typedef edmNew::DetSetVector<T> DSTV;
0011 typedef edmNew::DetSet<T> DST;
0012 typedef DSTV::FastFiller FF;
0013 
0014 void print0(DST const& d) { std::cout << d[0].v << std::endl; }
0015 
0016 int main() try {
0017   DSTV dstv;
0018 
0019   {
0020     FF ff(dstv, 1);
0021     ff.push_back(T());
0022     ff[0].v = 2.1;
0023   }
0024   {
0025     FF ff(dstv, 2);
0026     ff.push_back(T());
0027     ff.push_back(T());
0028   }
0029   std::cout << dstv.size() << std::endl;
0030   std::cout << dstv.dataSize() << std::endl;
0031   std::cout << dstv.detsetSize(0) << std::endl;
0032 
0033   DST d1 = *dstv.find(2);
0034   d1[0].v = 3.14;
0035   DST d2 = dstv.insert(4, 3);
0036   d2[0].v = 4.15;
0037 
0038   std::for_each(dstv.begin(), dstv.end(), std::function<void(DST const&)>(print0));
0039 
0040   return 0;
0041 } catch (cms::Exception const& e) {
0042   std::cerr << e.explainSelf() << std::endl;
0043 } catch (std::exception const& e) {
0044   std::cerr << e.what() << std::endl;
0045 }