Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:25:56

0001 #ifndef RecoLocalTracker_FTLClusterizer_MTDArrayBuffer_H
0002 #define RecoLocalTracker_FTLClusterizer_MTDArrayBuffer_H
0003 
0004 //----------------------------------------------------------------------------
0005 //! \class MTDArrayBuffer
0006 //! \brief Class to store ADC counts and times during clustering.
0007 //!
0008 //----------------------------------------------------------------------------
0009 
0010 // We use FTLHitPos which is an inner class of FTLCluster:
0011 #include "DataFormats/FTLRecHit/interface/FTLCluster.h"
0012 
0013 #include "DataFormats/GeometrySurface/interface/LocalError.h"
0014 #include "DataFormats/GeometryVector/interface/LocalPoint.h"
0015 #include "Geometry/CommonDetUnit/interface/GeomDetEnumerators.h"
0016 
0017 #include <vector>
0018 #include <iostream>
0019 
0020 class MTDArrayBuffer {
0021 public:
0022   typedef unsigned int uint;
0023 
0024   inline MTDArrayBuffer(uint rows, uint cols);
0025   inline MTDArrayBuffer() {}
0026 
0027   inline void setSize(uint rows, uint cols);
0028 
0029   /// Use subDet to identify whether the Hit is in BTL or ETL
0030   inline GeomDetEnumerators::Location subDet(uint row, uint col) const;
0031   inline GeomDetEnumerators::Location subDet(const FTLCluster::FTLHitPos&) const;
0032   inline float energy(uint row, uint col) const;
0033   inline float energy(const FTLCluster::FTLHitPos&) const;
0034   inline float time(uint row, uint col) const;
0035   inline float time(const FTLCluster::FTLHitPos&) const;
0036   inline float time_error(uint row, uint col) const;
0037   inline float time_error(const FTLCluster::FTLHitPos&) const;
0038 
0039   inline LocalError local_error(uint row, uint col) const;
0040   inline LocalError local_error(const FTLCluster::FTLHitPos&) const;
0041   inline LocalPoint local_point(uint row, uint col) const;
0042   inline LocalPoint local_point(const FTLCluster::FTLHitPos&) const;
0043 
0044   inline float xpos(uint row, uint col) const;
0045   inline float xpos(const FTLCluster::FTLHitPos&) const;
0046 
0047   inline uint rows() const { return nrows; }
0048   inline uint columns() const { return ncols; }
0049 
0050   inline bool inside(uint row, uint col) const;
0051 
0052   inline void clear(uint row, uint col) {
0053     LocalError le_n(0, 0, 0);
0054     LocalPoint lp_n(0, 0, 0);
0055     set_subDet(row, col, GeomDetEnumerators::invalidLoc);
0056     set_energy(row, col, 0.);
0057     set_time(row, col, 0.);
0058     set_time_error(row, col, 0.);
0059     set_local_error(row, col, le_n);
0060     set_local_point(row, col, lp_n);
0061     set_xpos(row, col, 0.);
0062   }
0063   inline void clear(const FTLCluster::FTLHitPos& pos) { clear(pos.row(), pos.col()); }
0064 
0065   inline void set(uint row,
0066                   uint col,
0067                   GeomDetEnumerators::Location subDet,
0068                   float energy,
0069                   float time,
0070                   float time_error,
0071                   const LocalError& local_error,
0072                   const LocalPoint& local_point,
0073                   float xpos);
0074   inline void set(const FTLCluster::FTLHitPos&,
0075                   GeomDetEnumerators::Location subDet,
0076                   float energy,
0077                   float time,
0078                   float time_error,
0079                   const LocalError& local_error,
0080                   const LocalPoint& local_point,
0081                   float xpos);
0082 
0083   inline void set_subDet(uint row, uint col, GeomDetEnumerators::Location subDet);
0084   inline void set_subDet(const FTLCluster::FTLHitPos&, GeomDetEnumerators::Location subDet);
0085 
0086   inline void set_energy(uint row, uint col, float energy);
0087   inline void set_energy(const FTLCluster::FTLHitPos&, float energy);
0088   inline void add_energy(uint row, uint col, float energy);
0089 
0090   inline void set_time(uint row, uint col, float time);
0091   inline void set_time(const FTLCluster::FTLHitPos&, float time);
0092 
0093   inline void set_time_error(uint row, uint col, float time_error);
0094   inline void set_time_error(const FTLCluster::FTLHitPos&, float time_error);
0095 
0096   inline void set_local_point(uint row, uint col, const LocalPoint& lp);
0097   inline void set_local_point(const FTLCluster::FTLHitPos&, const LocalPoint& lp);
0098 
0099   inline void set_local_error(uint row, uint col, const LocalError& le);
0100   inline void set_local_error(const FTLCluster::FTLHitPos&, const LocalError& le);
0101 
0102   inline void set_xpos(uint row, uint col, float xpos);
0103   inline void set_xpos(const FTLCluster::FTLHitPos&, float xpos);
0104 
0105   uint size() const { return hitEnergy_vec.size(); }
0106 
0107   /// Definition of indexing within the buffer.
0108   uint index(uint row, uint col) const { return col * nrows + row; }
0109   uint index(const FTLCluster::FTLHitPos& pix) const { return index(pix.row(), pix.col()); }
0110 
0111 private:
0112   std::vector<GeomDetEnumerators::Location> hitSubDet_vec;
0113   std::vector<float> hitEnergy_vec;
0114   std::vector<float> hitTime_vec;
0115   std::vector<float> hitTimeError_vec;
0116   std::vector<LocalPoint> hitGP_vec;
0117   std::vector<LocalError> hitLE_vec;
0118   std::vector<float> xpos_vec;
0119   uint nrows;
0120   uint ncols;
0121 };
0122 
0123 MTDArrayBuffer::MTDArrayBuffer(uint rows, uint cols)
0124     : hitSubDet_vec(rows * cols, GeomDetEnumerators::invalidLoc),
0125       hitEnergy_vec(rows * cols, 0),
0126       hitTime_vec(rows * cols, 0),
0127       hitTimeError_vec(rows * cols, 0),
0128       hitGP_vec(rows * cols),
0129       hitLE_vec(rows * cols),
0130       xpos_vec(rows * cols),
0131       nrows(rows),
0132       ncols(cols) {}
0133 
0134 void MTDArrayBuffer::setSize(uint rows, uint cols) {
0135   hitSubDet_vec.resize(rows * cols, GeomDetEnumerators::invalidLoc);
0136   hitEnergy_vec.resize(rows * cols, 0);
0137   hitTime_vec.resize(rows * cols, 0);
0138   hitTimeError_vec.resize(rows * cols, 0);
0139   hitGP_vec.resize(rows * cols);
0140   hitLE_vec.resize(rows * cols);
0141   xpos_vec.resize(rows * cols), nrows = rows;
0142   ncols = cols;
0143 }
0144 
0145 bool MTDArrayBuffer::inside(uint row, uint col) const { return (row < nrows && col < ncols); }
0146 
0147 GeomDetEnumerators::Location MTDArrayBuffer::subDet(uint row, uint col) const { return hitSubDet_vec[index(row, col)]; }
0148 GeomDetEnumerators::Location MTDArrayBuffer::subDet(const FTLCluster::FTLHitPos& pix) const {
0149   return hitSubDet_vec[index(pix)];
0150 }
0151 
0152 float MTDArrayBuffer::energy(uint row, uint col) const { return hitEnergy_vec[index(row, col)]; }
0153 float MTDArrayBuffer::energy(const FTLCluster::FTLHitPos& pix) const { return hitEnergy_vec[index(pix)]; }
0154 
0155 float MTDArrayBuffer::time(uint row, uint col) const { return hitTime_vec[index(row, col)]; }
0156 float MTDArrayBuffer::time(const FTLCluster::FTLHitPos& pix) const { return hitTime_vec[index(pix)]; }
0157 
0158 float MTDArrayBuffer::time_error(uint row, uint col) const { return hitTimeError_vec[index(row, col)]; }
0159 float MTDArrayBuffer::time_error(const FTLCluster::FTLHitPos& pix) const { return hitTimeError_vec[index(pix)]; }
0160 
0161 LocalError MTDArrayBuffer::local_error(uint row, uint col) const { return hitLE_vec[index(row, col)]; }
0162 LocalError MTDArrayBuffer::local_error(const FTLCluster::FTLHitPos& pix) const { return hitLE_vec[index(pix)]; }
0163 
0164 LocalPoint MTDArrayBuffer::local_point(uint row, uint col) const { return hitGP_vec[index(row, col)]; }
0165 LocalPoint MTDArrayBuffer::local_point(const FTLCluster::FTLHitPos& pix) const { return hitGP_vec[index(pix)]; }
0166 
0167 float MTDArrayBuffer::xpos(uint row, uint col) const { return xpos_vec[index(row, col)]; }
0168 float MTDArrayBuffer::xpos(const FTLCluster::FTLHitPos& pix) const { return xpos_vec[index(pix)]; }
0169 
0170 void MTDArrayBuffer::set(uint row,
0171                          uint col,
0172                          GeomDetEnumerators::Location subDet,
0173                          float energy,
0174                          float time,
0175                          float time_error,
0176                          const LocalError& local_error,
0177                          const LocalPoint& local_point,
0178                          float xpos) {
0179   hitSubDet_vec[index(row, col)] = subDet;
0180   hitEnergy_vec[index(row, col)] = energy;
0181   hitTime_vec[index(row, col)] = time;
0182   hitTimeError_vec[index(row, col)] = time_error;
0183   hitGP_vec[index(row, col)] = local_point;
0184   hitLE_vec[index(row, col)] = local_error;
0185   xpos_vec[index(row, col)] = xpos;
0186 }
0187 void MTDArrayBuffer::set(const FTLCluster::FTLHitPos& pix,
0188                          GeomDetEnumerators::Location subDet,
0189                          float energy,
0190                          float time,
0191                          float time_error,
0192                          const LocalError& local_error,
0193                          const LocalPoint& local_point,
0194                          float xpos) {
0195   set(pix.row(), pix.col(), subDet, energy, time, time_error, local_error, local_point, xpos);
0196 }
0197 
0198 void MTDArrayBuffer::set_subDet(uint row, uint col, GeomDetEnumerators::Location subDet) {
0199   hitSubDet_vec[index(row, col)] = subDet;
0200 }
0201 void MTDArrayBuffer::set_subDet(const FTLCluster::FTLHitPos& pix, GeomDetEnumerators::Location subDet) {
0202   hitSubDet_vec[index(pix)] = subDet;
0203 }
0204 
0205 void MTDArrayBuffer::set_energy(uint row, uint col, float energy) { hitEnergy_vec[index(row, col)] = energy; }
0206 void MTDArrayBuffer::set_energy(const FTLCluster::FTLHitPos& pix, float energy) { hitEnergy_vec[index(pix)] = energy; }
0207 void MTDArrayBuffer::add_energy(uint row, uint col, float energy) { hitEnergy_vec[index(row, col)] += energy; }
0208 
0209 void MTDArrayBuffer::set_time(uint row, uint col, float time) { hitTime_vec[index(row, col)] = time; }
0210 void MTDArrayBuffer::set_time(const FTLCluster::FTLHitPos& pix, float time) { hitTime_vec[index(pix)] = time; }
0211 
0212 void MTDArrayBuffer::set_time_error(uint row, uint col, float time_error) {
0213   hitTimeError_vec[index(row, col)] = time_error;
0214 }
0215 void MTDArrayBuffer::set_time_error(const FTLCluster::FTLHitPos& pix, float time_error) {
0216   hitTimeError_vec[index(pix)] = time_error;
0217 }
0218 
0219 void MTDArrayBuffer::set_local_point(uint row, uint col, const LocalPoint& lp) { hitGP_vec[index(row, col)] = lp; }
0220 void MTDArrayBuffer::set_local_point(const FTLCluster::FTLHitPos& pix, const LocalPoint& lp) {
0221   hitGP_vec[index(pix)] = lp;
0222 }
0223 
0224 void MTDArrayBuffer::set_local_error(uint row, uint col, const LocalError& le) { hitLE_vec[index(row, col)] = le; }
0225 void MTDArrayBuffer::set_local_error(const FTLCluster::FTLHitPos& pix, const LocalError& le) {
0226   hitLE_vec[index(pix)] = le;
0227 }
0228 
0229 void MTDArrayBuffer::set_xpos(uint row, uint col, float xpos) { xpos_vec[index(row, col)] = xpos; }
0230 void MTDArrayBuffer::set_xpos(const FTLCluster::FTLHitPos& pix, float xpos) { xpos_vec[index(pix)] = xpos; }
0231 
0232 #endif