ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4CylinderGeom_Spacalv1.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4CylinderGeom_Spacalv1.cc
1 // $$Id: PHG4CylinderGeom_Spacalv1.cc,v 1.3 2014/08/12 03:49:11 jinhuang Exp $$
2 
12 
13 #include <phparameter/PHParameters.h>
14 
15 #include <Geant4/G4PhysicalConstants.hh>
16 
17 #include <CLHEP/Units/SystemOfUnits.h> // for twopi
18 
19 #include <cmath>
20 #include <sstream>
21 #include <utility> // for pair
22 
23 using namespace std;
24 
26 {
27  SetDefault();
28 }
29 
30 void PHG4CylinderGeom_Spacalv1::identify(std::ostream& os) const
31 {
32  os << "PHG4CylinderGeom_Spacalv1: layer: " << layer //
33  << ", radius: " << radius //
34  << ", thickness: " << thickness //
35  << ", zmin: " << zmin //
36  << ", zmax: " << zmax << //
37  ", num scint: " << nscint
38 
39  << endl;
40  return;
41 }
42 
43 void PHG4CylinderGeom_Spacalv1::Print(Option_t*) const
44 {
45  identify(cout);
46 
47  cout << "Configuration is #" << get_config() << ":" << endl;
48  switch (get_config())
49  {
50  case kNonProjective:
51  cout << "fiber always placed radially" << endl;
52  break;
53  case kFullProjective_2DTaper:
54  cout << "Fully projective spacal with 2D tapered modules" << endl;
55  break;
56  case kFullProjective_2DTaper_SameLengthFiberPerTower:
57  cout
58  << "Fully projective spacal with 2D tapered modules. To speed up construction, same-length fiber is used cross one tower"
59  << endl;
60  break;
61  case kFullProjective_2DTaper_Tilted:
62  cout << "Fully projective spacal with 2D tapered modules and allow azimuthal tilts" << endl;
63  break;
64  case kFullProjective_2DTaper_Tilted_SameLengthFiberPerTower:
65  cout
66  << "Fully projective spacal with 2D tapered modules and allow azimuthal tilts. To speed up construction, same-length fiber is used cross one tower"
67  << endl;
68  break;
69  default:
70  cout << "PHG4CylinderGeom_Spacalv1::Print - ERROR - unknown configuration #"
71  << get_config() << endl;
72  break;
73  }
74 
75  cout << "\t"
76  << "get_max_radius() = " << get_max_radius() << endl;
77  cout << "\t"
78  << "get_half_radius() = " << get_half_radius() << endl;
79  cout << "\t"
80  << "get_length() = " << get_length() << endl;
81  cout << "\t"
82  << "get_*pos() = " << get_xpos() << ", " << get_ypos() << ", "
83  << get_zpos() << endl;
84 
85  cout << "\t"
86  << "get_azimuthal_n_sec() = " << get_azimuthal_n_sec() << ", "
87  << sector_map.size() << "/" << get_azimuthal_n_sec()
88  << " azimuthal sectors would be filled with SPACAL." << endl;
89  cout << "\t"
90  << "get_azimuthal_distance() = " << get_azimuthal_distance()
91  << endl;
92  cout << "\t"
93  << "get_z_distance() = " << get_z_distance() << endl;
94  cout << "\t"
95  << "get_fiber_outer_r() = " << get_fiber_outer_r() << endl;
96  cout << "\t"
97  << "get_fiber_clading_thickness() = "
98  << get_fiber_clading_thickness() << endl;
99  cout << "\t"
100  << "get_fiber_core_diameter() = " << get_fiber_core_diameter()
101  << endl;
102  cout << "\t"
103  << "get_fiber_distance() = " << get_fiber_distance() << endl;
104 
105  cout << "\t"
106  << "get_absorber_mat() = " << get_absorber_mat() << endl;
107  cout << "\t"
108  << "get_fiber_clading_mat() = " << get_fiber_clading_mat()
109  << endl;
110  cout << "\t"
111  << "get_fiber_core_mat() = " << get_fiber_core_mat() << endl;
112  // cout << "\t" << "get_calo_step_size() = " << get_calo_step_size() << endl;
113  // cout << "\t" << "get_fiber_clading_step_size() = "
114  // << get_fiber_clading_step_size() << endl;
115  cout << "\t"
116  << "get_fiber_core_step_size() = " << get_fiber_core_step_size()
117  << endl;
118 
119  cout << "\t"
120  << "is_virualize_fiber() = " << is_virualize_fiber() << endl;
121  cout << "\t"
122  << "get_construction_verbose() = " << get_construction_verbose()
123  << endl;
124 
125  if (get_construction_verbose() >= 2)
126  {
127  cout << "\t"
128  << "Containing " << sector_map.size()
129  << " sector with rotation specified:" << endl;
130  for (sector_map_t::const_iterator it = sector_map.begin();
131  it != sector_map.end(); ++it)
132  {
133  cout << "\t"
134  << "\t"
135  << "sector_map[" << it->first << "] = " << it->second
136  << endl;
137  }
138  }
139 }
140 
142 {
143  config = kNonProjective;
144 
145  layer = 0;
146  radius = 95;
147  thickness = 16.6;
148  zmin = -143;
149  zmax = -zmin;
150  nscint = 0;
151 
152  absorber_mat = "Spacal_W_Epoxy";
153  fiber_clading_mat = "PMMA";
154  fiber_core_mat = "G4_POLYSTYRENE";
155 
156  xpos = 0;
157  ypos = 0;
158  zpos = 0;
159 
160  fiber_clading_thickness = 0.003 / 2;
161  fiber_core_diameter = 0.047 - fiber_clading_thickness * 2;
162  fiber_distance = 0.1;
163 
164  virualize_fiber = false;
165  construction_verbose = 0;
166 
167  // init_default_sector_map();
168 }
169 
171 {
173 
174  if (param.exist_string_param("absorber_mat"))
175  absorber_mat = param.get_string_param("absorber_mat");
176  if (param.exist_string_param("fiber_core_mat"))
177  fiber_core_mat = param.get_string_param("fiber_core_mat");
178  if (param.exist_string_param("fiber_clading_mat"))
179  fiber_clading_mat = param.get_string_param("fiber_clading_mat");
180  if (param.exist_double_param("xpos"))
181  xpos = param.get_double_param("xpos");
182  if (param.exist_double_param("ypos"))
183  ypos = param.get_double_param("ypos");
184  if (param.exist_double_param("zpos"))
185  zpos = param.get_double_param("zpos");
186  if (param.exist_double_param("fiber_core_diameter"))
187  fiber_core_diameter = param.get_double_param("fiber_core_diameter");
188  if (param.exist_double_param("fiber_clading_thickness"))
189  fiber_clading_thickness = param.get_double_param("fiber_clading_thickness");
190  if (param.exist_double_param("fiber_distance"))
191  fiber_distance = param.get_double_param("fiber_distance");
192  if (param.exist_int_param("config"))
193  config = static_cast<config_t>(param.get_int_param("config"));
194  if (param.exist_int_param("virualize_fiber"))
195  virualize_fiber = static_cast<bool>(param.get_int_param("virualize_fiber"));
196  if (param.exist_int_param("construction_verbose"))
197  construction_verbose = param.get_int_param("construction_verbose");
198 
199  //init_default_sector_map if instructed to do so
200  if (param.exist_int_param("init_default_sector_map"))
201  {
202  if (param.get_int_param("init_default_sector_map"))
203  {
204  init_default_sector_map();
205  }
206  }
207 
208  // load sector_map if specified. Over write init_default_sector_map if both presents
209  if (param.exist_int_param("sector_map_size"))
210  {
211  sector_map.clear();
212 
213  const int n = param.get_int_param("sector_map_size");
214 
215  for (int i = 0; i < n; i++)
216  {
217  stringstream prefix;
218  prefix << "sector_map";
219  prefix << "[" << i << "]"
220  << ".";
221 
222  const int id = param.get_int_param(prefix.str() + "id");
223  const double rotation = param.get_double_param(
224  prefix.str() + "rotation");
225 
226  sector_map[id] = rotation;
227  }
228  }
229 
230  return;
231 }
232 
234 {
235  return std::floor(
236  get_half_radius() * twopi / (get_fiber_distance() * sqrt(3.)));
237 }
238 
239 double
241 {
242  return get_half_radius() * twopi / (double) (get_azimuthal_n_sec());
243 }
244 
245 double
247 {
248  return get_fiber_distance() / 2.;
249 }
250 
253 {
254  sector_map.clear();
255 
256  for (int sec = 0; sec < get_azimuthal_n_sec(); ++sec)
257  {
258  const double rot = twopi / (double) (get_azimuthal_n_sec()) * ((double) (sec));
259 
260  sector_map[sec] = rot;
261  }
262 }