Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:25:10

0001 #ifndef RecoLocalTracker_StripClusterizerAlgorithm_h
0002 #define RecoLocalTracker_StripClusterizerAlgorithm_h
0003 
0004 namespace edm {
0005   class EventSetup;
0006 }
0007 class SiStripDigi;
0008 #include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
0009 #include "DataFormats/Common/interface/DetSetVector.h"
0010 #include "DataFormats/Common/interface/DetSetVectorNew.h"
0011 #include <limits>
0012 
0013 #include "RecoLocalTracker/Records/interface/SiStripClusterizerConditionsRcd.h"
0014 #include "CalibFormats/SiStripObjects/interface/SiStripClusterizerConditions.h"
0015 
0016 class StripClusterizerAlgorithm {
0017 public:
0018   using Det = SiStripClusterizerConditions::Det;
0019 
0020   //state of the candidate cluster
0021   struct State {
0022     State(Det const& idet) : m_det(idet) { ADCs.reserve(8); }
0023     Det const& det() const { return m_det; }
0024     std::vector<uint8_t> ADCs;
0025     uint16_t lastStrip = 0;
0026     float noiseSquared = 0;
0027     bool candidateLacksSeed = true;
0028 
0029   private:
0030     Det const& m_det;
0031   };
0032 
0033   virtual ~StripClusterizerAlgorithm() {}
0034 
0035   void initialize(const edm::EventSetup& es) { m_conditions = &es.getData(m_conditionsToken); }
0036   const SiStripClusterizerConditions& conditions() const { return *m_conditions; }
0037 
0038   //Offline DetSet interface
0039   typedef edmNew::DetSetVector<SiStripCluster> output_t;
0040   void clusterize(const edm::DetSetVector<SiStripDigi>&, output_t&) const;
0041   void clusterize(const edmNew::DetSetVector<SiStripDigi>&, output_t&) const;
0042   virtual void clusterizeDetUnit(const edm::DetSet<SiStripDigi>&, output_t::TSFastFiller&) const {}
0043   virtual void clusterizeDetUnit(const edmNew::DetSet<SiStripDigi>&, output_t::TSFastFiller&) const {}
0044 
0045   //HLT stripByStrip interface
0046   Det const& stripByStripBegin(uint32_t id) const { return m_conditions->findDetId(id); }
0047 
0048   virtual void stripByStripAdd(State& state, uint16_t strip, uint8_t adc, std::vector<SiStripCluster>& out) const {}
0049   virtual void stripByStripEnd(State& state, std::vector<SiStripCluster>& out) const {}
0050 
0051   virtual void stripByStripAdd(State& state, uint16_t strip, uint8_t adc, output_t::TSFastFiller& out) const {}
0052   virtual void stripByStripEnd(State& state, output_t::TSFastFiller& out) const {}
0053 
0054   struct InvalidChargeException : public cms::Exception {
0055   public:
0056     InvalidChargeException(const SiStripDigi&);
0057   };
0058 
0059 protected:
0060   explicit StripClusterizerAlgorithm(
0061       const edm::ESGetToken<SiStripClusterizerConditions, SiStripClusterizerConditionsRcd>& conditionsToken)
0062       : m_conditionsToken(conditionsToken) {}
0063 
0064 private:
0065   template <class T>
0066   void clusterize_(const T& input, output_t& output) const {
0067     for (typename T::const_iterator it = input.begin(); it != input.end(); it++) {
0068       output_t::TSFastFiller ff(output, it->detId());
0069       clusterizeDetUnit(*it, ff);
0070       if (ff.empty())
0071         ff.abort();
0072     }
0073   }
0074 
0075   edm::ESGetToken<SiStripClusterizerConditions, SiStripClusterizerConditionsRcd> m_conditionsToken;
0076   const SiStripClusterizerConditions* m_conditions;
0077 };
0078 #endif