Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2026-08-31 08:21:20

0001 // Tell emacs that this is a C++ source
0002 //  -*- C++ -*-.
0003 #ifndef TPCTRACKRECO_IDEALPADMAP_H
0004 #define TPCTRACKRECO_IDEALPADMAP_H
0005 
0006 #include <array>
0007 #include <string>
0008 #include <vector>
0009 
0010 class CDBTTree;
0011 
0012 class IdealPadMap
0013 {
0014  public:
0015   IdealPadMap();
0016   ~IdealPadMap();
0017 
0018   int load_from_cdb(int verbosity = 0);
0019   bool is_loaded() const { return m_is_loaded; }
0020 
0021   // TPC layers are real layer numbers: 7..54.
0022   // region is 0,1,2 for inner/mid/outer.
0023   int get_region(unsigned int layer) const;
0024   unsigned int get_pads_per_sector(unsigned int region) const;
0025   unsigned int get_pads_per_sector_for_layer(unsigned int layer) const;
0026   unsigned int get_total_phibins(unsigned int layer) const;
0027 
0028   // Radius from CDB, averaged over all pads in that layer. Returned in cm.
0029   double get_radius(unsigned int layer) const;
0030   double get_local_radius(unsigned int layer) const { return get_radius(layer); }
0031   double get_layer_thickness(unsigned int layer) const;
0032 
0033   // Raw local CDB phi for one pad inside one sector.
0034   // local_phibin is 0..pads_per_sector(layer)-1.
0035   double get_cdb_local_phi(unsigned int layer, unsigned int local_phibin) const;
0036 
0037   // Convert a full-circle PHG4TpcGeom phibin back to global phi.
0038   // phibin is the integer returned by layergeom->get_phibin(phi, side).
0039   double get_phi(unsigned int side, unsigned int layer, unsigned int phibin) const;
0040 
0041   // Same conversion, but with sector already known and local bin inside sector.
0042   double get_phi(unsigned int side,
0043                  unsigned int sector,
0044                  unsigned int layer,
0045                  unsigned int local_phibin) const;
0046 
0047   // Optional helper if you still need direct FEE/channel lookup.
0048   int get_layer_from_fee_channel(unsigned int fee, unsigned int channel) const;
0049 
0050  private:
0051   static constexpr unsigned int N_SIDES = 2;
0052   static constexpr unsigned int N_SECTORS = 12;
0053   static constexpr unsigned int N_REGIONS = 3;
0054   static constexpr unsigned int N_LAYERS = 48;
0055   static constexpr unsigned int FIRST_LAYER = 7;
0056   static constexpr unsigned int LAST_LAYER = 54;
0057   static constexpr unsigned int N_FEE = 26;
0058   static constexpr unsigned int N_CH = 256;
0059 
0060   int layer_index(unsigned int layer) const;
0061   double wrap_phi(double phi) const;
0062 
0063   bool m_is_loaded = false;
0064 
0065   // Indexed by layer-7.  Each layer vector is one sector worth of CDB pads.
0066   std::array<std::vector<double>, N_LAYERS> m_cdb_phi_by_layer;
0067   std::array<double, N_LAYERS> m_radius_cm_by_layer{};
0068 
0069   // Indexed by 256*fee + channel. -1 means no valid TPC layer.
0070   std::array<int, N_FEE * N_CH> m_layer_by_key{};
0071 };
0072 
0073 #endif