Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 // Tell emacs that this is a C++ source
0002 //  -*- C++ -*-.
0003 // $$Id: PHG4CylinderGeom_Spacalv3.h,v 1.3 2014/08/28 22:18:35 jinhuang Exp $$
0004 
0005 /*!
0006  * \file ${file_name}
0007  * \brief
0008  * \author Jin Huang <jhuang@bnl.gov>
0009  * \version $$Revision: 1.3 $$
0010  * \date $$Date: 2014/08/28 22:18:35 $$
0011  */
0012 #ifndef G4DETECTORS_PHG4CYLINDERGEOMSPACALV3_H
0013 #define G4DETECTORS_PHG4CYLINDERGEOMSPACALV3_H
0014 
0015 #include "PHG4CylinderGeom_Spacalv2.h"
0016 
0017 #include <iostream>  // for operator<<, basic_ostream::op...
0018 #include <map>
0019 #include <string>
0020 #include <utility>  // std::pair, std::make_pair
0021 
0022 class PHParameters;
0023 
0024 class PHG4CylinderGeom_Spacalv3 : public PHG4CylinderGeom_Spacalv2
0025 {
0026  public:
0027   PHG4CylinderGeom_Spacalv3();
0028 
0029   ~PHG4CylinderGeom_Spacalv3() override;
0030 
0031   // from PHObject
0032   void identify(std::ostream& os = std::cout) const override;
0033 
0034   // from TObject
0035   void Print(Option_t* option = "") const override;
0036 
0037   // cppcheck-suppress virtualCallInConstructor
0038   void SetDefault() override;
0039 
0040   //! load parameters from PHParameters, which interface to Database/XML/ROOT files
0041   void ImportParameters(const PHParameters& param) override;
0042 
0043   double
0044   get_sidewall_outer_torr() const
0045   {
0046     return sidewall_outer_torr;
0047   }
0048 
0049   void
0050   set_sidewall_outer_torr(double sidewallOuterTorr)
0051   {
0052     sidewall_outer_torr = sidewallOuterTorr;
0053   }
0054 
0055   double
0056   get_sidewall_thickness() const
0057   {
0058     return sidewall_thickness;
0059   }
0060 
0061   void
0062   set_sidewall_thickness(double sidewallThickness)
0063   {
0064     sidewall_thickness = sidewallThickness;
0065   }
0066 
0067   const std::string
0068   &get_sidewall_mat() const
0069   {
0070     return sidewall_mat;
0071   }
0072 
0073   void
0074   set_sidewall_mat(const std::string& absorberMat)
0075   {
0076     sidewall_mat = absorberMat;
0077   }
0078 
0079   int get_max_phi_bin_in_sec() const
0080   {
0081     return max_phi_bin_in_sec;
0082   }
0083 
0084   void
0085   set_max_phi_bin_in_sec(int maxPhiBinInSec)
0086   {
0087     max_phi_bin_in_sec = maxPhiBinInSec;
0088   }
0089 
0090   const std::string& get_divider_mat() const
0091   {
0092     return divider_mat;
0093   }
0094 
0095   void set_divider_mat(const std::string& dividerMat)
0096   {
0097     divider_mat = dividerMat;
0098   }
0099 
0100   double get_divider_width() const
0101   {
0102     return divider_width;
0103   }
0104 
0105   void set_divider_width(double dividerWidth)
0106   {
0107     divider_width = dividerWidth;
0108   }
0109 
0110   class geom_tower
0111   {
0112    public:
0113     geom_tower();
0114     virtual ~geom_tower()
0115     {
0116     }
0117 
0118     int id;
0119     double pDz;
0120 
0121     double pDy1;
0122     double pDx1;
0123     double pDx2;
0124     double pDy2;
0125     double pDx3;
0126     double pDx4;
0127 
0128     double pTheta;
0129     double pPhi;
0130     double pAlp1;
0131     double pAlp2;
0132 
0133     double pRotationAngleX;
0134     double centralX;
0135     double centralY;
0136     double centralZ;
0137 
0138     double ModuleSkinThickness;
0139 
0140     //! number of fiber along final azimuthal direction
0141     int NFiberX;
0142     //! number of fiber along final polar direction
0143     int NFiberY;
0144 
0145     //! number of fiber along final azimuthal direction
0146     int NSubtowerX;
0147     //! number of fiber along final polar direction
0148     int NSubtowerY;
0149 
0150     //! fiber layout (2D index of 0...NFiberX/NFiberY) -> fiber_id
0151     int
0152     compose_fiber_id(int index_x, int index_y) const;
0153     //! fiber_id -> sub tower ID x/azimuthal direction: 0 ... NSubtowerX -1
0154     int
0155     get_sub_tower_ID_x(int fiber_id) const;
0156     //! fiber_id -> sub tower ID y/polar direction: 0 ... NSubtowerY -1
0157     int
0158     get_sub_tower_ID_y(int fiber_id) const;
0159     //! fiber_id -> fraction position in sub tower ID in the x/azimuthal direction, [0-1]
0160     double
0161     get_position_fraction_x_in_sub_tower(int fiber_id) const;
0162     //! fiber_id -> fraction position in sub tower ID in the y/polar direction, [0-1]
0163     double
0164     get_position_fraction_y_in_sub_tower(int fiber_id) const;
0165 
0166     //! height of light guide
0167     double LightguideHeight;
0168     //! edge length ratio, narrow / wide
0169     double LightguideTaperRatio;
0170     //! edge length ratio, narrow / wide
0171     std::string LightguideMaterial;
0172 
0173     virtual void
0174     identify(std::ostream& os = std::cout) const;
0175 
0176     //! read via PHParameters
0177     void
0178     ImportParameters(const PHParameters& param,
0179                      const std::string& param_prefix);
0180 
0181     ClassDef(PHG4CylinderGeom_Spacalv3::geom_tower, 3)
0182   };
0183   typedef std::map<int, geom_tower> tower_map_t;
0184 
0185   void
0186   load_demo_sector_tower_map1();
0187   void
0188   load_demo_sector_tower_map2();
0189   void
0190   load_demo_sector_tower_map4();
0191 
0192   const tower_map_t&
0193   get_sector_tower_map() const
0194   {
0195     return sector_tower_map;
0196   }
0197 
0198   //! get approximate radial position of tower
0199   double
0200   get_tower_radial_position(const geom_tower& tower) const;
0201 
0202   //! check that all towers has consistent sub-tower divider
0203   void
0204   subtower_consistency_check() const;
0205   //! sub-tower divider along the polar direction
0206   int get_n_subtower_eta() const;
0207   //! sub-tower divider along the azimuthal direction
0208   int get_n_subtower_phi() const;
0209   //! max tolerance needed for the light guide
0210   double
0211   get_max_lightguide_height() const;
0212 
0213   //
0214   //  void
0215   //  set_geom_super_tower_map(geom_super_tower_map_t geomSuperTowerMap)
0216   //  {
0217   //    geom_super_tower_map = geomSuperTowerMap;
0218   //  }
0219 
0220   //! compact ID of each fiber in 32bit PHG4Hit::set_scint_id(). Buffer the result for repeated use.
0221   class scint_id_coder
0222   {
0223    public:
0224     explicit scint_id_coder(int scint_id);
0225     scint_id_coder(int sector_id, int tower_id, int fiber_id);
0226     virtual ~scint_id_coder()
0227     {
0228     }
0229 
0230     virtual void
0231     identify(std::ostream& os = std::cout) const
0232     {
0233       os << "scint_id_coder with "
0234          << "scint_ID(" << scint_ID << ") = "
0235          << "sector_ID(" << sector_ID << "), "
0236          << "tower_ID(" << tower_ID
0237          << "), "
0238          << "fiber_ID(" << fiber_ID << ")" << std::endl;
0239     }
0240 
0241     int scint_ID;
0242     int sector_ID;
0243     int tower_ID;
0244     int fiber_ID;
0245 
0246     static const int kfiber_bit = 13;  // max 8192 fiber per tower
0247     static const int ktower_bit = 11;  // max 2048 towers per sector
0248     static const int ksector_bit = 8;  // max 256 sectors
0249 
0250     ClassDef(PHG4CylinderGeom_Spacalv3::scint_id_coder, 1)
0251   };
0252 
0253   //! convert tower_ID + sector ID to eta and z bins as in other cylindrical calorimeters
0254   //! @return: a std::pair of zbin and phibin number
0255   virtual std::pair<int, int>
0256   get_tower_z_phi_ID(const int tower_ID, const int sector_ID) const;
0257 
0258  protected:
0259   double sidewall_thickness{std::numeric_limits<double>::quiet_NaN()};
0260   double sidewall_outer_torr{std::numeric_limits<double>::quiet_NaN()};
0261   std::string sidewall_mat;
0262   int max_phi_bin_in_sec{std::numeric_limits<int>::min()};
0263 
0264   tower_map_t sector_tower_map;
0265 
0266   //! wdith along the approximate radial direction
0267   double divider_width{std::numeric_limits<double>::quiet_NaN()};
0268   //! material for divider
0269   std::string divider_mat;
0270 
0271   ClassDefOverride(PHG4CylinderGeom_Spacalv3, 4)
0272 };
0273 
0274 #endif