Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 // $$Id: PHG4CylinderGeom_Spacalv2.cc,v 1.3 2014/08/28 22:18:35 jinhuang Exp $$
0002 
0003 /*!
0004  * \file ${file_name}
0005  * \brief
0006  * \author Jin Huang <jhuang@bnl.gov>
0007  * \version $$Revision: 1.3 $$
0008  * \date $$Date: 2014/08/28 22:18:35 $$
0009  */
0010 
0011 #include "PHG4CylinderGeom_Spacalv2.h"
0012 
0013 #include <phparameter/PHParameters.h>
0014 
0015 #include <Geant4/G4PhysicalConstants.hh>
0016 
0017 #include <CLHEP/Units/SystemOfUnits.h>  // for twopi, halfpi, pi
0018 
0019 #include <cmath>
0020 #include <cstdlib>  // for exit
0021 #include <iostream>
0022 
0023 PHG4CylinderGeom_Spacalv2::PHG4CylinderGeom_Spacalv2()
0024 {
0025   SetDefault();
0026 }
0027 
0028 void PHG4CylinderGeom_Spacalv2::identify(std::ostream& os) const
0029 {
0030   os << "PHG4CylinderGeom_Spacalv2: layer: " << layer  //
0031      << ", radius: " << radius                         //
0032      << ", thickness: " << thickness                   //
0033      << ", zmin: " << zmin                             //
0034      << ", zmax: " << zmax <<                          //
0035       ", num scint: " << nscint
0036 
0037      << std::endl;
0038   return;
0039 }
0040 
0041 void PHG4CylinderGeom_Spacalv2::Print(Option_t* opt) const
0042 {
0043   PHG4CylinderGeom_Spacalv1::Print(opt);
0044 
0045   std::cout << "\t"
0046             << "is_azimuthal_seg_visible() = " << is_azimuthal_seg_visible()
0047             << std::endl;
0048   std::cout << "\t"
0049             << "azimuthal_tilt() = " << get_azimuthal_tilt() << std::endl;
0050   std::cout << "\t"
0051             << "get_polar_taper_ratio() = " << get_polar_taper_ratio()
0052             << std::endl;
0053   std::cout << "\t"
0054             << "get_sec_azimuthal_width() = " << get_sec_azimuthal_width()
0055             << std::endl;
0056   std::cout << "\t"
0057             << "get_sec_depth() = " << get_sec_depth() << std::endl;
0058   std::cout << "\t"
0059             << "get_block_width() = " << get_block_width() << std::endl;
0060   std::cout << "\t"
0061             << "get_block_depth() = " << get_block_depth() << std::endl;
0062   std::cout << "\t"
0063             << "get_assembly_spacing() = " << get_assembly_spacing() << std::endl;
0064   std::cout << "\t"
0065             << "get_reg_fiber_grid_distance_taper() = "
0066             << get_reg_fiber_grid_distance_taper() << " = sqrt(3)*"
0067             << get_reg_fiber_grid_distance_taper() / sqrt(3.) << std::endl;
0068   std::cout << "\t"
0069             << "get_reg_fiber_grid_distance_nontaper() = "
0070             << get_reg_fiber_grid_distance_nontaper() << std::endl;
0071 }
0072 
0073 void PHG4CylinderGeom_Spacalv2::SetDefault()
0074 {
0075   PHG4CylinderGeom_Spacalv1::SetDefault();
0076 
0077   azimuthal_n_sec = 256;
0078   azimuthal_tilt = 0;
0079   azimuthal_seg_visible = false;
0080   polar_taper_ratio = 1 + 1.1 / 42.;
0081   assembly_spacing = 0.0001;  // order ~1um clearance around all structures
0082 
0083   //  init_default_sector_map();
0084 }
0085 
0086 void PHG4CylinderGeom_Spacalv2::ImportParameters(const PHParameters& param)
0087 {
0088   PHG4CylinderGeom_Spacalv1::ImportParameters(param);
0089 
0090   if (param.exist_int_param("azimuthal_n_sec"))
0091   {
0092     azimuthal_n_sec = param.get_int_param("azimuthal_n_sec");
0093   }
0094   if (param.exist_double_param("azimuthal_tilt"))
0095   {
0096     azimuthal_tilt = param.get_double_param("azimuthal_tilt");
0097   }
0098   if (param.exist_int_param("azimuthal_seg_visible"))
0099   {
0100     azimuthal_seg_visible = static_cast<bool>(param.get_int_param(
0101         "azimuthal_seg_visible"));
0102   }
0103   if (param.exist_double_param("polar_taper_ratio"))
0104   {
0105     polar_taper_ratio = param.get_double_param("polar_taper_ratio");
0106   }
0107   if (param.exist_double_param("assembly_spacing"))
0108   {
0109     assembly_spacing = param.get_double_param("assembly_spacing");
0110   }
0111 
0112   return;
0113 }
0114 
0115 double
0116 PHG4CylinderGeom_Spacalv2::get_sec_azimuthal_width() const
0117 {
0118   const double azimuthal_width_base = get_radius() * twopi / (double) (get_azimuthal_n_sec()) - get_assembly_spacing();
0119 
0120   // triggernometry stuff to make a tight connection after tilting
0121 
0122   const double theta1 = get_azimuthal_tilt();
0123   const double theta2 = pi + (twopi / get_azimuthal_n_sec()) - halfpi - get_azimuthal_tilt();
0124 
0125   return azimuthal_width_base * sin(theta2) / sin(theta1 + theta2);
0126 }
0127 
0128 double
0129 PHG4CylinderGeom_Spacalv2::get_half_polar_taper_angle() const
0130 {
0131   return atan2(get_block_width() * 0.5 * (get_polar_taper_ratio() - 1),
0132                get_block_depth());
0133 }
0134 
0135 int PHG4CylinderGeom_Spacalv2::get_azimuthal_n_sec() const
0136 {
0137   //  if (config == kNonProjective)
0138   //    //For kNonProjective geometry, azimuthal_n_sec is calculated, and can not be set externally
0139   //    return PHG4CylinderGeom_Spacalv1::get_azimuthal_n_sec();
0140   //  else
0141   return azimuthal_n_sec;
0142 }
0143 
0144 void PHG4CylinderGeom_Spacalv2::set_azimuthal_n_sec(int azimuthalNSec)
0145 {
0146   if (config == kNonProjective)
0147   {
0148     std::cout
0149         << "PHG4CylinderGeom_Spacalv2::set_azimuthal_n_sec - Fatal Error - "
0150            "Spacal is configured as NonProjective geometry. In this case azimuthal_n_sec is calculated, and can not be set externally."
0151         << std::endl;
0152     exit(10);
0153   }
0154 
0155   azimuthal_n_sec = azimuthalNSec;
0156   //  init_default_sector_map();
0157 }
0158 
0159 bool PHG4CylinderGeom_Spacalv2::is_azimuthal_seg_visible() const
0160 {
0161   return azimuthal_seg_visible;
0162 }
0163 
0164 void PHG4CylinderGeom_Spacalv2::set_azimuthal_seg_visible(bool b)
0165 {
0166   if (config == kNonProjective)
0167   {
0168     std::cout
0169         << "PHG4CylinderGeom_Spacalv2::set_azimuthal_seg_visible - Fatal Error - "
0170            "Spacal is configured as NonProjective geometry. In this case azimuthal_seg_visible is false, and can not be set externally."
0171         << std::endl;
0172     exit(10);
0173   }
0174 
0175   azimuthal_seg_visible = b;
0176   ;
0177 }
0178 
0179 //! regulated fiber distance in the tapering direction
0180 double
0181 PHG4CylinderGeom_Spacalv2::get_reg_fiber_grid_distance_taper() const
0182 {
0183   const double mid_plane_width = get_block_width() * ((get_polar_taper_ratio() - 1) * 0.5 + 1) - get_assembly_spacing();
0184 
0185   const int n_grid = floor(mid_plane_width / (get_fiber_distance() * sqrt(3.)));
0186 
0187   return mid_plane_width / n_grid;
0188 }
0189 
0190 //! regulated fiber distance in the non-tapering direction
0191 double
0192 PHG4CylinderGeom_Spacalv2::get_reg_fiber_grid_distance_nontaper() const
0193 {
0194   const double mid_plane_width = get_block_width() - get_assembly_spacing();
0195   const int n_grid = floor(mid_plane_width / (get_fiber_distance()));
0196   return mid_plane_width / n_grid;
0197 }