File indexing completed on 2025-08-06 08:18:57
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include "PHG4CylinderGeom_Spacalv1.h"
0012
0013 #include <phparameter/PHParameters.h>
0014
0015 #include <Geant4/G4PhysicalConstants.hh>
0016
0017 #include <cmath>
0018 #include <sstream>
0019 #include <utility> // for pair
0020
0021 PHG4CylinderGeom_Spacalv1::PHG4CylinderGeom_Spacalv1()
0022 {
0023 SetDefault();
0024 }
0025
0026 void PHG4CylinderGeom_Spacalv1::identify(std::ostream& os) const
0027 {
0028 os << "PHG4CylinderGeom_Spacalv1: layer: " << layer
0029 << ", radius: " << radius
0030 << ", thickness: " << thickness
0031 << ", zmin: " << zmin
0032 << ", zmax: " << zmax <<
0033 ", num scint: " << nscint
0034
0035 << std::endl;
0036 return;
0037 }
0038
0039 void PHG4CylinderGeom_Spacalv1::Print(Option_t* ) const
0040 {
0041 identify(std::cout);
0042
0043 std::cout << "Configuration is #" << get_config() << ":" << std::endl;
0044 switch (get_config())
0045 {
0046 case kNonProjective:
0047 std::cout << "fiber always placed radially" << std::endl;
0048 break;
0049 case kFullProjective_2DTaper:
0050 std::cout << "Fully projective spacal with 2D tapered modules" << std::endl;
0051 break;
0052 case kFullProjective_2DTaper_SameLengthFiberPerTower:
0053 std::cout
0054 << "Fully projective spacal with 2D tapered modules. To speed up construction, same-length fiber is used cross one tower"
0055 << std::endl;
0056 break;
0057 case kFullProjective_2DTaper_Tilted:
0058 std::cout << "Fully projective spacal with 2D tapered modules and allow azimuthal tilts" << std::endl;
0059 break;
0060 case kFullProjective_2DTaper_Tilted_SameLengthFiberPerTower:
0061 std::cout
0062 << "Fully projective spacal with 2D tapered modules and allow azimuthal tilts. To speed up construction, same-length fiber is used cross one tower"
0063 << std::endl;
0064 break;
0065 default:
0066 std::cout << "PHG4CylinderGeom_Spacalv1::Print - ERROR - unknown configuration #"
0067 << get_config() << std::endl;
0068 break;
0069 }
0070
0071 std::cout << "\t"
0072 << "get_max_radius() = " << get_max_radius() << std::endl;
0073 std::cout << "\t"
0074 << "get_half_radius() = " << get_half_radius() << std::endl;
0075 std::cout << "\t"
0076 << "get_length() = " << get_length() << std::endl;
0077 std::cout << "\t"
0078 << "get_*pos() = " << get_xpos() << ", " << get_ypos() << ", "
0079 << get_zpos() << std::endl;
0080
0081 std::cout << "\t"
0082 << "get_azimuthal_n_sec() = " << get_azimuthal_n_sec() << ", "
0083 << sector_map.size() << "/" << get_azimuthal_n_sec()
0084 << " azimuthal sectors would be filled with SPACAL." << std::endl;
0085 std::cout << "\t"
0086 << "get_azimuthal_distance() = " << get_azimuthal_distance()
0087 << std::endl;
0088 std::cout << "\t"
0089 << "get_z_distance() = " << get_z_distance() << std::endl;
0090 std::cout << "\t"
0091 << "get_fiber_outer_r() = " << get_fiber_outer_r() << std::endl;
0092 std::cout << "\t"
0093 << "get_fiber_clading_thickness() = "
0094 << get_fiber_clading_thickness() << std::endl;
0095 std::cout << "\t"
0096 << "get_fiber_core_diameter() = " << get_fiber_core_diameter()
0097 << std::endl;
0098 std::cout << "\t"
0099 << "get_fiber_distance() = " << get_fiber_distance() << std::endl;
0100
0101 std::cout << "\t"
0102 << "get_absorber_mat() = " << get_absorber_mat() << std::endl;
0103 std::cout << "\t"
0104 << "get_fiber_clading_mat() = " << get_fiber_clading_mat()
0105 << std::endl;
0106 std::cout << "\t"
0107 << "get_fiber_core_mat() = " << get_fiber_core_mat() << std::endl;
0108
0109
0110
0111 std::cout << "\t"
0112 << "get_fiber_core_step_size() = " << get_fiber_core_step_size()
0113 << std::endl;
0114
0115 std::cout << "\t"
0116 << "is_virualize_fiber() = " << is_virualize_fiber() << std::endl;
0117 std::cout << "\t"
0118 << "get_construction_verbose() = " << get_construction_verbose()
0119 << std::endl;
0120
0121 if (get_construction_verbose() >= 2)
0122 {
0123 std::cout << "\t"
0124 << "Containing " << sector_map.size()
0125 << " sector with rotation specified:" << std::endl;
0126 for (auto it : sector_map)
0127 {
0128 std::cout << "\t"
0129 << "\t"
0130 << "sector_map[" << it.first << "] = " << it.second
0131 << std::endl;
0132 }
0133 }
0134 }
0135
0136 void PHG4CylinderGeom_Spacalv1::SetDefault()
0137 {
0138 config = kNonProjective;
0139
0140 layer = 0;
0141 radius = 95;
0142 thickness = 16.6;
0143 zmin = -143;
0144 zmax = -zmin;
0145 nscint = 0;
0146
0147 absorber_mat = "Spacal_W_Epoxy";
0148 fiber_clading_mat = "PMMA";
0149 fiber_core_mat = "G4_POLYSTYRENE";
0150
0151 xpos = 0;
0152 ypos = 0;
0153 zpos = 0;
0154
0155 fiber_clading_thickness = 0.003 / 2;
0156 fiber_core_diameter = 0.047 - fiber_clading_thickness * 2;
0157 fiber_distance = 0.1;
0158
0159 virualize_fiber = false;
0160 construction_verbose = 0;
0161
0162
0163 }
0164
0165 void PHG4CylinderGeom_Spacalv1::ImportParameters(const PHParameters& param)
0166 {
0167 PHG4CylinderGeomv2::ImportParameters(param);
0168
0169 if (param.exist_string_param("absorber_mat"))
0170 {
0171 absorber_mat = param.get_string_param("absorber_mat");
0172 }
0173 if (param.exist_string_param("fiber_core_mat"))
0174 {
0175 fiber_core_mat = param.get_string_param("fiber_core_mat");
0176 }
0177 if (param.exist_string_param("fiber_clading_mat"))
0178 {
0179 fiber_clading_mat = param.get_string_param("fiber_clading_mat");
0180 }
0181 if (param.exist_double_param("xpos"))
0182 {
0183 xpos = param.get_double_param("xpos");
0184 }
0185 if (param.exist_double_param("ypos"))
0186 {
0187 ypos = param.get_double_param("ypos");
0188 }
0189 if (param.exist_double_param("zpos"))
0190 {
0191 zpos = param.get_double_param("zpos");
0192 }
0193 if (param.exist_double_param("fiber_core_diameter"))
0194 {
0195 fiber_core_diameter = param.get_double_param("fiber_core_diameter");
0196 }
0197 if (param.exist_double_param("fiber_clading_thickness"))
0198 {
0199 fiber_clading_thickness = param.get_double_param("fiber_clading_thickness");
0200 }
0201 if (param.exist_double_param("fiber_distance"))
0202 {
0203 fiber_distance = param.get_double_param("fiber_distance");
0204 }
0205 if (param.exist_int_param("config"))
0206 {
0207 config = static_cast<config_t>(param.get_int_param("config"));
0208 }
0209 if (param.exist_int_param("virualize_fiber"))
0210 {
0211 virualize_fiber = static_cast<bool>(param.get_int_param("virualize_fiber"));
0212 }
0213 if (param.exist_int_param("construction_verbose"))
0214 {
0215 construction_verbose = param.get_int_param("construction_verbose");
0216 }
0217
0218
0219 if (param.exist_int_param("init_default_sector_map"))
0220 {
0221 if (param.get_int_param("init_default_sector_map"))
0222 {
0223 init_default_sector_map();
0224 }
0225 }
0226
0227
0228 if (param.exist_int_param("sector_map_size"))
0229 {
0230 sector_map.clear();
0231
0232 const int n = param.get_int_param("sector_map_size");
0233
0234 for (int i = 0; i < n; i++)
0235 {
0236 std::stringstream prefix;
0237 prefix << "sector_map";
0238 prefix << "[" << i << "]"
0239 << ".";
0240
0241 const int id = param.get_int_param(prefix.str() + "id");
0242 const double rotation = param.get_double_param(
0243 prefix.str() + "rotation");
0244
0245 sector_map[id] = rotation;
0246 }
0247 }
0248
0249 return;
0250 }
0251
0252 int PHG4CylinderGeom_Spacalv1::get_azimuthal_n_sec() const
0253 {
0254 return std::floor(
0255 get_half_radius() * 2 * M_PI / (get_fiber_distance() * sqrt(3.)));
0256 }
0257
0258 double
0259 PHG4CylinderGeom_Spacalv1::get_azimuthal_distance() const
0260 {
0261 return get_half_radius() * 2 * M_PI / (double) (get_azimuthal_n_sec());
0262 }
0263
0264 double
0265 PHG4CylinderGeom_Spacalv1::get_z_distance() const
0266 {
0267 return get_fiber_distance() / 2.;
0268 }
0269
0270
0271 void PHG4CylinderGeom_Spacalv1::init_default_sector_map()
0272 {
0273 sector_map.clear();
0274
0275 for (int sec = 0; sec < get_azimuthal_n_sec(); ++sec)
0276 {
0277 const double rot = 2 * M_PI / (double) (get_azimuthal_n_sec()) * ((double) (sec));
0278
0279 sector_map[sec] = rot;
0280 }
0281 }