Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-02-01 23:47:21

0001 #ifndef TkSeedingLayers_SeedingHitSet_H
0002 #define TkSeedingLayers_SeedingHitSet_H
0003 
0004 #include "DataFormats/TrackerRecHit2D/interface/BaseTrackerRecHit.h"
0005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0006 
0007 #include <vector>
0008 #include <algorithm>
0009 
0010 class SeedingHitSet {
0011 public:
0012   using RecHit = BaseTrackerRecHit;
0013   using RecHitPointer = BaseTrackerRecHit *;
0014   using ConstRecHitPointer = BaseTrackerRecHit const *;
0015 
0016   static ConstRecHitPointer nullPtr() { return nullptr; }
0017 
0018   SeedingHitSet() = default;
0019 
0020   SeedingHitSet(ConstRecHitPointer one, ConstRecHitPointer two) : SeedingHitSet({one, two}) {}
0021 
0022   SeedingHitSet(ConstRecHitPointer one, ConstRecHitPointer two, ConstRecHitPointer three)
0023       : SeedingHitSet({one, two, three}) {}
0024 
0025   SeedingHitSet(ConstRecHitPointer one, ConstRecHitPointer two, ConstRecHitPointer three, ConstRecHitPointer four)
0026       : SeedingHitSet({one, two, three, four}) {}
0027 
0028   SeedingHitSet(const std::vector<ConstRecHitPointer> &hits) {
0029     if (hits.size() >= 2) {
0030       auto end = std::find(hits.begin(), hits.end(), nullPtr());
0031       auto size = std::distance(hits.begin(), end);
0032       if (size >= 2) {
0033         theRecHits.reserve(size);
0034         std::copy(hits.begin(), end, std::back_inserter(theRecHits));
0035       }
0036     }
0037   }
0038 
0039   SeedingHitSet(const std::initializer_list<ConstRecHitPointer> &hits) {
0040     if (hits.size() >= 2) {
0041       auto end = std::find(hits.begin(), hits.end(), nullPtr());
0042       auto size = std::distance(hits.begin(), end);
0043       if (size >= 2) {
0044         theRecHits.reserve(size);
0045         std::copy(hits.begin(), end, std::back_inserter(theRecHits));
0046       }
0047     }
0048   }
0049 
0050   ConstRecHitPointer const *data() const { return theRecHits.data(); }
0051 
0052   unsigned int size() const { return theRecHits.size(); }
0053 
0054   ConstRecHitPointer get(unsigned int i) const { return theRecHits[i]; }
0055   ConstRecHitPointer operator[](unsigned int i) const { return theRecHits[i]; }
0056 
0057 protected:
0058   std::vector<ConstRecHitPointer> theRecHits;
0059 };
0060 
0061 #endif