Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:18:06

0001 #ifndef TPCCALIB_TpcSpaceChargeMatrixContainerv2_H
0002 #define TPCCALIB_TpcSpaceChargeMatrixContainerv2_H
0003 
0004 /**
0005  * @file tpccalib/TpcSpaceChargeMatrixContainer.h
0006  * @author Hugo Pereira Da Costa
0007  * @date June 2018
0008  * @brief Contains matrices needed for space charge trackbase reconstruction
0009  */
0010 
0011 #include "TpcSpaceChargeMatrixContainer.h"
0012 
0013 #include <array>
0014 
0015 /**
0016  * @brief Cluster container object
0017  */
0018 class TpcSpaceChargeMatrixContainerv2 : public TpcSpaceChargeMatrixContainer
0019 {
0020  public:
0021   /// constructor
0022   TpcSpaceChargeMatrixContainerv2();
0023 
0024   /// destructor
0025   ~TpcSpaceChargeMatrixContainerv2() override = default;
0026 
0027   ///@name accessors
0028   //@{
0029 
0030   /// identify object
0031   void identify(std::ostream& os = std::cout) const override;
0032 
0033   /// get grid dimensions
0034   void get_grid_dimensions(int& phibins, int& rbins, int& zbins) const override;
0035 
0036   /// get grid size
0037   int get_grid_size() const override;
0038 
0039   /// get grid index for given sub-indexes
0040   int get_cell_index(int iphibin, int irbin, int izbin) const override;
0041 
0042   /// get entries for a given cell
0043   int get_entries(int cell_index) const override;
0044 
0045   /// get left hand side
0046   float get_lhs(int cell_index, int i, int j) const override;
0047 
0048   /// get right hand side
0049   float get_rhs(int cell_index, int i) const override;
0050 
0051   /// get reduced rphi left hand side
0052   float get_lhs_rphi(int cell_index, int i, int j) const override;
0053 
0054   /// get reduced rphi right hand side
0055   float get_rhs_rphi(int cell_index, int i) const override;
0056 
0057   /// get reduced z left hand side
0058   float get_lhs_z(int cell_index, int i, int j) const override;
0059 
0060   /// get reduced z right hand side
0061   float get_rhs_z(int cell_index, int i) const override;
0062 
0063   //@}
0064 
0065   ///@name modifiers
0066   //@{
0067 
0068   /// reset method
0069   void Reset() override;
0070 
0071   /// set grid dimensions
0072   /**
0073   \param phibins the number of bins in the azimuth direction
0074   \param zbins the number of bins along z
0075   */
0076   void set_grid_dimensions(int phibins, int rbins, int zbins) override;
0077 
0078   /// increment cell entries
0079   void add_to_entries(int cell_index) override
0080   {
0081     add_to_entries(cell_index, 1);
0082   }
0083 
0084   /// increment cell entries
0085   void add_to_entries(int cell_index, int value) override;
0086 
0087   /// increment left hand side matrix
0088   void add_to_lhs(int cell_index, int i, int j, float value) override;
0089 
0090   /// increment right hand side column
0091   void add_to_rhs(int cell_index, int i, float value) override;
0092 
0093   /// increment left hand side reduced rphi matrix
0094   void add_to_lhs_rphi(int cell_index, int i, int j, float value) override;
0095 
0096   /// increment right hand side reduced rphi column
0097   void add_to_rhs_rphi(int cell_index, int i, float value) override;
0098 
0099   /// increment left hand side reduced rphi matrix
0100   void add_to_lhs_z(int cell_index, int i, int j, float value) override;
0101 
0102   /// increment right hand side reduced rphi column
0103   void add_to_rhs_z(int cell_index, int i, float value) override;
0104 
0105   /// add content from other container
0106   bool add(const TpcSpaceChargeMatrixContainer& other) override;
0107 
0108   //@}
0109 
0110  private:
0111   /// boundary check
0112   bool bound_check(int cell_index) const;
0113 
0114   /// boundary check
0115   bool bound_check(int cell_index, int i) const;
0116 
0117   /// boundary check
0118   bool bound_check(int cell_index, int i, int j) const;
0119 
0120   /// map matrix index to flat array
0121   int get_flat_index(int i, int j) const;
0122 
0123   /// boundary check
0124   bool bound_check_reduced(int cell_index, int i) const;
0125 
0126   /// boundary check
0127   bool bound_check_reduced(int cell_index, int i, int j) const;
0128 
0129   /// map matrix index to flat array
0130   int get_flat_index_reduced(int i, int j) const;
0131 
0132   ///@name grid size
0133   //@{
0134   int m_phibins = 36;
0135   int m_rbins = 16;
0136   int m_zbins = 80;
0137   //@}
0138 
0139   //@name full 3D matrices (drphi, dz and dr)
0140   //@{
0141   //! number of coordinates for full matrix (drphi, dz and dr)
0142   static constexpr int m_ncoord = 3;
0143 
0144   /// internal matrix representation
0145   using matrix_t = std::array<float, m_ncoord * m_ncoord>;
0146   using column_t = std::array<float, m_ncoord>;
0147 
0148   /// left hand side matrices for distortion inversions
0149   std::vector<matrix_t> m_lhs;
0150 
0151   /// right hand side matrices for distortion inversions
0152   std::vector<column_t> m_rhs;
0153   //@}
0154 
0155 
0156   //@name reduced 2D matrices (drphi, dr) and (dz and dr)
0157   //@{
0158   //! number of coordinates for reduce matrix (drphi, dr) and (dz and dr)
0159   static constexpr int m_ncoord_reduced = 2;
0160 
0161   /// internal matrix representation
0162   using reduced_matrix_t = std::array<float, m_ncoord_reduced * m_ncoord_reduced>;
0163   using reduced_column_t = std::array<float, m_ncoord_reduced>;
0164 
0165   /// left hand side matrices for reduced rphi distortion inversions
0166   std::vector<reduced_matrix_t> m_lhs_rphi;
0167 
0168   /// right hand side matrices for distortion rphi inversions
0169   std::vector<reduced_column_t> m_rhs_rphi;
0170 
0171   /// left hand side matrices for reduced z distortion inversions
0172   std::vector<reduced_matrix_t> m_lhs_z;
0173 
0174   /// right hand side matrices for reduced z distortion inversions
0175   std::vector<reduced_column_t> m_rhs_z;
0176   //@}
0177 
0178   /// keep track of how many entries are used per cells
0179   std::vector<int> m_entries;
0180 
0181   ClassDefOverride(TpcSpaceChargeMatrixContainerv2, 1)
0182 };
0183 
0184 #endif