Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:24:35

0001 #ifndef RecoLocalTracker_MTDClusterizer_MTDClusterizerBase_H
0002 #define RecoLocalTracker_MTDClusterizer_MTDClusterizerBase_H
0003 
0004 #include "DataFormats/Common/interface/DetSetVector.h"
0005 #include "DataFormats/Common/interface/DetSetVectorNew.h"
0006 
0007 #include "DataFormats/FTLRecHit/interface/FTLRecHitCollections.h"
0008 #include "DataFormats/FTLRecHit/interface/FTLClusterCollections.h"
0009 
0010 #include "Geometry/MTDGeometryBuilder/interface/MTDGeometry.h"
0011 #include "Geometry/MTDNumberingBuilder/interface/MTDTopology.h"
0012 
0013 #include <vector>
0014 #include <array>
0015 
0016 /**
0017  * Abstract interface for MTD Clusterizers
0018  */
0019 class MTDClusterizerBase {
0020 public:
0021   typedef FTLRecHitCollection::const_iterator RecHitIterator;
0022   typedef FTLClusterCollection::const_iterator ClusterIterator;
0023 
0024   // Virtual destructor, this is a base class.
0025   virtual ~MTDClusterizerBase() {}
0026 
0027   // Build clusters
0028   virtual void clusterize(const FTLRecHitCollection& input,
0029                           const MTDGeometry* geom,
0030                           const MTDTopology* topo,
0031                           FTLClusterCollection& output) = 0;
0032 
0033 protected:
0034   struct AccretionCluster {
0035     typedef unsigned short UShort;
0036     static constexpr UShort MAXSIZE = 256;
0037 
0038     std::array<float, MAXSIZE> energy;
0039     std::array<float, MAXSIZE> time;
0040     std::array<float, MAXSIZE> timeError;
0041     std::array<UShort, MAXSIZE> x;
0042     std::array<UShort, MAXSIZE> y;
0043 
0044     UShort xmin = 16000;
0045     UShort ymin = 16000;
0046     unsigned int isize = 0;
0047     unsigned int curr = 0;
0048 
0049     // stack interface (unsafe ok for use below)
0050     UShort top() const { return curr; }
0051     void pop() { ++curr; }
0052     bool empty() { return curr == isize; }
0053 
0054     bool add(FTLCluster::FTLHitPos const& p, float const ienergy, float const itime, float const itimeError) {
0055       if (isize == MAXSIZE)
0056         return false;
0057       xmin = std::min(xmin, (unsigned short)(p.row()));
0058       ymin = std::min(ymin, (unsigned short)(p.col()));
0059       energy[isize] = ienergy;
0060       time[isize] = itime;
0061       timeError[isize] = itimeError;
0062       x[isize] = p.row();
0063       y[isize] = p.col();
0064       isize++;
0065       return true;
0066     }
0067   };
0068 };
0069 
0070 #endif