Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:05:21

0001 #include "DataFormats/Common/interface/Ref.h"
0002 #include "DataFormats/Common/interface/TestHandle.h"
0003 #include "DataFormats/Provenance/interface/ProductID.h"
0004 #include "DataFormats/TrackerRecHit2D/interface/OmniClusterRef.h"
0005 #include <cassert>
0006 
0007 int strip() {
0008   typedef edm::Ref<edmNew::DetSetVector<SiPixelCluster>, SiPixelCluster> ClusterPixelRef;
0009   typedef edm::Ref<edmNew::DetSetVector<SiStripCluster>, SiStripCluster> ClusterStripRef;
0010 
0011   using Coll = edmNew::DetSetVector<SiStripCluster>;
0012 
0013   Coll coll;
0014   edm::TestHandle<Coll> collH(&coll, edm::ProductID(1, 1));
0015 
0016   typedef Coll::FastFiller FF;
0017 
0018   {
0019     FF ff(coll, 1);
0020     ff.push_back(SiStripCluster());
0021     ff.push_back(SiStripCluster());
0022     ff.push_back(SiStripCluster());
0023     ff.push_back(SiStripCluster());
0024   }
0025 
0026   ClusterStripRef sref = edmNew::makeRefTo(collH, &coll.data()[2]);
0027 
0028   OmniClusterRef oref(sref);
0029   assert(oref.isValid());
0030   assert(oref.index() == 2);
0031   assert(oref.isStrip());
0032   assert(!oref.isPixel());
0033   assert(oref.subCluster() == 0);
0034 
0035   OmniClusterRef oref2(sref, 3);
0036   OmniClusterRef oref3(sref, 3);
0037   assert(oref2.isValid());
0038   assert(oref2.index() == 2);
0039   assert(oref2.isStrip());
0040   assert(!oref2.isPixel());
0041   assert(oref2.subCluster() == 3);
0042   assert(!(oref2 == oref));
0043   assert((oref2 == oref3));
0044 
0045   return 0;
0046 }
0047 
0048 int pixel() {
0049   typedef edm::Ref<edmNew::DetSetVector<SiPixelCluster>, SiPixelCluster> ClusterPixelRef;
0050   typedef edm::Ref<edmNew::DetSetVector<SiStripCluster>, SiStripCluster> ClusterStripRef;
0051 
0052   using Coll = edmNew::DetSetVector<SiPixelCluster>;
0053 
0054   Coll coll;
0055   edm::TestHandle<Coll> collH(&coll, edm::ProductID(1, 1));
0056 
0057   typedef Coll::FastFiller FF;
0058 
0059   {
0060     FF ff(coll, 1);
0061     ff.push_back(SiPixelCluster());
0062     ff.push_back(SiPixelCluster());
0063     ff.push_back(SiPixelCluster());
0064     ff.push_back(SiPixelCluster());
0065   }
0066 
0067   ClusterPixelRef sref = edmNew::makeRefTo(collH, &coll.data()[2]);
0068 
0069   OmniClusterRef oref(sref);
0070   assert(oref.isValid());
0071   assert(oref.index() == 2);
0072   assert(!oref.isStrip());
0073   assert(oref.isPixel());
0074   assert(oref.subCluster() == 0);
0075 
0076   OmniClusterRef oref2(sref, 3);
0077   OmniClusterRef oref3(sref, 3);
0078   assert(oref2.isValid());
0079   assert(oref2.index() == 2);
0080   assert(!oref2.isStrip());
0081   assert(oref2.isPixel());
0082   assert(oref2.subCluster() == 3);
0083   assert(!(oref2 == oref));
0084   assert((oref2 == oref3));
0085 
0086   return 0;
0087 }
0088 
0089 int main() { return strip() + pixel(); }