ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4InttSubsystem.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4InttSubsystem.cc
1 #include "PHG4InttSubsystem.h"
2 #include "PHG4InttDefs.h"
3 #include "PHG4InttDetector.h"
6 
7 #include <phparameter/PHParameters.h>
8 #include <phparameter/PHParametersContainer.h>
9 
10 #include <g4detectors/PHG4DetectorGroupSubsystem.h> // for PHG4DetectorGrou...
11 
12 #include <g4main/PHG4DisplayAction.h> // for PHG4DisplayAction
14 #include <g4main/PHG4SteppingAction.h> // for PHG4SteppingAction
15 
16 #include <phool/PHIODataNode.h> // for PHIODataNode
17 #include <phool/PHNode.h> // for PHNode
18 #include <phool/PHNodeIterator.h> // for PHNodeIterator
19 #include <phool/PHObject.h> // for PHObject
20 #include <phool/getClass.h>
21 #include <phool/PHCompositeNode.h>
22 
23 #include <boost/format.hpp>
24 
25 #include <iostream> // for operator<<, basi...
26 #include <set> // for _Rb_tree_const_i...
27 #include <type_traits> // for __decay_and_stri...
28 
29 class PHG4Detector;
30 
31 using namespace std;
32 
33 //_______________________________________________________________________
34 PHG4InttSubsystem::PHG4InttSubsystem(const std::string &detectorname, const vpair &layerconfig)
35  : PHG4DetectorGroupSubsystem(detectorname)
36  , m_Detector(nullptr)
37  , m_SteppingAction(nullptr)
38  , m_DisplayAction(nullptr)
39  , m_LayerConfigVector(layerconfig)
40  , m_DetectorType(detectorname)
41 {
42  for (vector<pair<int, int>>::const_iterator piter = layerconfig.begin(); piter != layerconfig.end(); ++piter)
43  {
44  AddDetId((*piter).second);
45  }
46 
48  // put the layer into the name so we get unique names
49  // for multiple layers
50  Name(detectorname);
51  SuperDetector(detectorname);
52 }
53 
55 {
56  delete m_DisplayAction;
57 }
58 
59 //_______________________________________________________________________
61 {
62  if (Verbosity() > 0)
63  {
64  std::cout << "PHG4InttSubsystem::Init started" << std::endl;
65  }
66 
67  PHNodeIterator iter(topNode);
68  PHCompositeNode *dstNode = dynamic_cast<PHCompositeNode *>(iter.findFirst("PHCompositeNode", "DST"));
69 
70  // create display settings before detector (detector adds its volumes to it)
72  // create detector
73  pair<vector<pair<int, int>>::const_iterator, vector<pair<int, int>>::const_iterator> layer_begin_end = make_pair(m_LayerConfigVector.begin(), m_LayerConfigVector.end());
74  m_Detector = new PHG4InttDetector(this, topNode, GetParamsContainer(), Name(), layer_begin_end);
75  m_Detector->Verbosity(Verbosity());
76  m_Detector->SuperDetector(SuperDetector());
77  m_Detector->Detector(m_DetectorType);
78  m_Detector->OverlapCheck(CheckOverlap());
79 
80  int active = 0;
81  // initialize with support active flag (if support is active we need the absorber hit node)
82  int absorberactive = GetParamsContainer()->GetParameters(PHG4InttDefs::SUPPORTPARAMS)->get_int_param("supportactive");
83  int blackhole = 0;
84  for (set<int>::const_iterator parcontaineriter = GetDetIds().first; parcontaineriter != GetDetIds().second; ++parcontaineriter)
85  {
86  if (active || GetParamsContainer()->GetParameters(*parcontaineriter)->get_int_param("active"))
87  {
88  active = 1;
89  }
90  if (absorberactive || GetParamsContainer()->GetParameters(*parcontaineriter)->get_int_param("absorberactive"))
91  {
92  absorberactive = 1;
93  }
94  if (blackhole || GetParamsContainer()->GetParameters(*parcontaineriter)->get_int_param("blackhole"))
95  {
96  blackhole = 1;
97  }
98  }
99  if (active)
100  {
101  PHNodeIterator dstIter(dstNode);
102  PHCompositeNode *DetNode = dynamic_cast<PHCompositeNode *>(dstIter.findFirst("PHCompositeNode", SuperDetector()));
103  if (!DetNode)
104  {
105  DetNode = new PHCompositeNode(SuperDetector());
106  dstNode->addNode(DetNode);
107  }
108  std::string nodename = (SuperDetector() != "NONE") ? boost::str(boost::format("G4HIT_%s") % SuperDetector()) : boost::str(boost::format("G4HIT_%s") % m_DetectorType);
109 
110  // create hit list
111  PHG4HitContainer *hitcontainer = findNode::getClass<PHG4HitContainer>(topNode, nodename.c_str());
112  if (!hitcontainer)
113  DetNode->addNode(new PHIODataNode<PHObject>(hitcontainer = new PHG4HitContainer(nodename), nodename.c_str(), "PHObject"));
114 
115  if (absorberactive)
116  {
117  nodename = (SuperDetector() != "NONE") ? boost::str(boost::format("G4HIT_ABSORBER_%s") % SuperDetector()) : boost::str(boost::format("G4HIT_ABSORBER_%s") % m_DetectorType);
118 
119  hitcontainer = findNode::getClass<PHG4HitContainer>(topNode, nodename.c_str());
120  if (!hitcontainer)
121  {
122  DetNode->addNode(new PHIODataNode<PHObject>(hitcontainer = new PHG4HitContainer(nodename), nodename.c_str(), "PHObject"));
123  }
124  }
125 
126  // create stepping action
127  m_SteppingAction = new PHG4InttSteppingAction(m_Detector, GetParamsContainer(), layer_begin_end);
129  }
130  else
131  {
132  if (blackhole)
133  {
134  m_SteppingAction = new PHG4InttSteppingAction(m_Detector, GetParamsContainer(), layer_begin_end);
135  }
136  }
137 
138  return 0;
139 }
140 
141 //_______________________________________________________________________
143 {
144  // pass top node to stepping action so that it gets
145  // relevant nodes needed internally
146  if (m_SteppingAction)
147  {
149  }
150 
151  return 0;
152 }
153 
154 //_______________________________________________________________________
156 {
157  return m_Detector;
158 }
159 
161 {
162  // We have only two types of ladders, one with vertical strips (SEGMENTATION_Z) and one with horizontal strips (SEGMENTATION_PHI)set
163  // There are 4 sensors in each ladder
164  // In ladder type 0 the sensor is special and inner and outer sensors are the same.
165  // In ladder type 1 there are two different sensor types, inner and outer
166  // We do not want to hard code the ladder types for the layers
167 
168  // We define default ladder types for 8 layers, but these can be changed at the macro level
169 
170  int laddertype[8] = {PHG4InttDefs::SEGMENTATION_Z,
177  PHG4InttDefs::SEGMENTATION_PHI}; // default
178 
179  int nladder[8] = {17, 17, 12, 12, 16, 16, 21, 21}; // default, new 03/05/2020
180 
181  double sensor_radius[8] = {6.876, 7.462,
182  // 4 elements are those for PHG4InttDefs::SEGMENTATION_PHI, 36um subtracted to set si sensors at the place
183  // these subtractions are due to different thickness of glue for the sensors (14um) and the FPHX chips (50um)
184  7.188 - 36e-4, 7.732 - 36e-4, 9.680 - 36e-4, 10.262 - 36e-4,
185  12.676, 13.179}; // radius of center of sensor for layer default, new 30/05/2020
186 
187  auto detid = GetDetIds(); // get pair of iterators to begin/end of set<int> of detids
188  for (auto detiter = detid.first; detiter != detid.second; ++detiter)
189  {
190  set_default_int_param(*detiter, "active", 1);
191 
192  // To reconfigure the layers, all you have to do is overide the defaults for these four arrays from the tracking macro
193  set_default_int_param(*detiter, "laddertype", laddertype[*detiter]);
194  set_default_int_param(*detiter, "nladder", nladder[*detiter]); // ladders per layer
195  set_default_double_param(*detiter, "sensor_radius", sensor_radius[*detiter]);
196  // These offsets should be kept at zero in the new design
197  set_default_double_param(*detiter, "offsetphi", 0.);
198  set_default_double_param(*detiter, "offsetrot", 0.);
199 
200 
201  // sitrack->set_int_param(i, "laddertype", laddertype[i]);
202  }
203 
204  // These are the parameters that describe the internal ladder geometry for the two ladder types
205  { // just being lazy, using namespace in this scope for less clutter
206  using namespace PHG4InttDefs;
207  // SEGMENTATION_Z //////////////////////////////////////
208  // int param
209  set_default_int_param(SEGMENTATION_Z, "nstrips_phi_cell", 1);
210  set_default_int_param(SEGMENTATION_Z, "nstrips_phi_sensor", 1);
211  set_default_int_param(SEGMENTATION_Z, "nstrips_z_sensor_0", 128 * 5);
212  set_default_int_param(SEGMENTATION_Z, "nstrips_z_sensor_1", 128 * 5);
213 
214  // double param
215  set_default_double_param(SEGMENTATION_Z, "fphx_x", 0.032);
216  set_default_double_param(SEGMENTATION_Z, "fphx_y", 0.27);
217  set_default_double_param(SEGMENTATION_Z, "fphx_z", 0.91);
218  set_default_double_param(SEGMENTATION_Z, "fphx_offset_z", 0.005);
219  set_default_double_param(SEGMENTATION_Z, "gap_sensor_fphx", 0.1);
220  set_default_double_param(SEGMENTATION_Z, "halfladder_z", 40.00);
221  set_default_double_param(SEGMENTATION_Z, "halfladder_inside_z", 23.9622);
222  set_default_double_param(SEGMENTATION_Z, "hdi_copper_x", 0.0052);
223  set_default_double_param(SEGMENTATION_Z, "hdi_edge_z", 0.);
224  set_default_double_param(SEGMENTATION_Z, "hdi_kapton_x", 0.038);
227  set_default_double_param(SEGMENTATION_Z, "sensor_edge_phi", 0.13);
228  set_default_double_param(SEGMENTATION_Z, "sensor_edge_z", 0.1);
229  set_default_double_param(SEGMENTATION_Z, "sensor_offset_y", 0.304);
230  set_default_double_param(SEGMENTATION_Z, "strip_x", 0.032);
231  set_default_double_param(SEGMENTATION_Z, "strip_y", 1.6);
232  set_default_double_param(SEGMENTATION_Z, "strip_z_0", 0.01406);
233  set_default_double_param(SEGMENTATION_Z, "strip_z_1", 0.01406);
234  set_default_double_param(SEGMENTATION_Z, "stave_straight_cooler_x", 0.01905);
235  set_default_double_param(SEGMENTATION_Z, "stave_straight_cooler_y", 0.47);
236  set_default_double_param(SEGMENTATION_Z, "stave_slant_cooler_y", 1.4362);
237  set_default_double_param(SEGMENTATION_Z, "stave_straight_outer_y", 0.672);
238  set_default_double_param(SEGMENTATION_Z, "stave_straight_rohacell_y", 0.57181);
239 
240  // SEGMENTATION_PHI //////////////////////////////////////
241  // int param
242  set_default_int_param(SEGMENTATION_PHI, "nstrips_phi_cell", 256);
243  set_default_int_param(SEGMENTATION_PHI, "nstrips_phi_sensor", 256);
244  set_default_int_param(SEGMENTATION_PHI, "nstrips_z_sensor_0", 8);
245  set_default_int_param(SEGMENTATION_PHI, "nstrips_z_sensor_1", 5);
246 
247  // double param
248  set_default_double_param(SEGMENTATION_PHI, "fphx_x", 0.032);
249  set_default_double_param(SEGMENTATION_PHI, "fphx_y", 0.27 );
250  set_default_double_param(SEGMENTATION_PHI, "fphx_z", 0.91 );
251  set_default_double_param(SEGMENTATION_PHI, "fphx_offset_z", 0.005);
252  set_default_double_param(SEGMENTATION_PHI, "gap_sensor_fphx", 0.1 );
253 
254  set_default_double_param(SEGMENTATION_PHI, "si_glue_x", 0.0014 ); // 14 um, don't forget to change double sensor_radius when it's changed
255  set_default_double_param(SEGMENTATION_PHI, "fphx_glue_x", 0.005 ); // 50 um
256 
257  set_default_double_param(SEGMENTATION_PHI, "halfladder_z", 40.00 );
258  set_default_double_param(SEGMENTATION_PHI, "halfladder_inside_z", 23.9622);
259 
260  set_default_double_param(SEGMENTATION_PHI, "hdi_copper_x", 0.00376);
261  set_default_double_param(SEGMENTATION_PHI, "hdi_edge_z", 0. );
262  set_default_double_param(SEGMENTATION_PHI, "hdi_kapton_x", 0.038 );
264 
265  set_default_double_param(SEGMENTATION_PHI, "sensor_edge_phi", 0.13 );
266  set_default_double_param(SEGMENTATION_PHI, "sensor_edge_z", 0.1 );
267  set_default_double_param(SEGMENTATION_PHI, "sensor_offset_y", 0. );
268  set_default_double_param(SEGMENTATION_PHI, "strip_x", 0.032 );
269  set_default_double_param(SEGMENTATION_PHI, "strip_y", 0.0078);
270  set_default_double_param(SEGMENTATION_PHI, "strip_z_0", 1.6 );
271  set_default_double_param(SEGMENTATION_PHI, "strip_z_1", 2. );
272 
273  set_default_double_param(SEGMENTATION_PHI, "stave_straight_cooler_x", 0.03 );
274  set_default_double_param(SEGMENTATION_PHI, "stave_straight_cooler_y", 1.47684);
275 
276  set_default_double_param(SEGMENTATION_PHI, "stave_slant_cooler_y", 0.6322614829);
277 
278  set_default_double_param(SEGMENTATION_PHI, "stave_straight_outer_y", 0.33227);
279  set_default_double_param(SEGMENTATION_PHI, "stave_straight_rohacell_y", 0.58842);
280 
281  // SUPPORTPARAMS //////////////////////////////////////
282  // int param
283  set_default_int_param(SUPPORTPARAMS, "supportactive", 1);
284 
285  // double param
286  // set_default_double_param(SUPPORTPARAMS, "inner_skin_inner_radius", 6.2416);
287  // set_default_double_param(SUPPORTPARAMS, "inner_skin_length", 50.7 );
288  // set_default_double_param(SUPPORTPARAMS, "inner_skin_outer_radius", 6.2666);
289  set_default_double_param(SUPPORTPARAMS, "inner_skin_inner_radius", 12.9667 / 2 );
290  set_default_double_param(SUPPORTPARAMS, "inner_skin_outer_radius", 13.0175 / 2 );
291  set_default_double_param(SUPPORTPARAMS, "inner_skin_length", 49.7 );
292 
293  // set_default_double_param(SUPPORTPARAMS, "outer_skin_cfcin_inner_radius", 12.0444);
294  // set_default_double_param(SUPPORTPARAMS, "outer_skin_cfcin_outer_radius", 12.0694);
295  // set_default_double_param(SUPPORTPARAMS, "outer_skin_cfcin_length", 50.7 );
296 
297  // set_default_double_param(SUPPORTPARAMS, "outer_skin_foam_inner_radius", 12.0694);
298  // set_default_double_param(SUPPORTPARAMS, "outer_skin_foam_outer_radius", 12.2194);
299  // set_default_double_param(SUPPORTPARAMS, "outer_skin_foam_length", 50.7 );
300 
301  // set_default_double_param(SUPPORTPARAMS, "outer_skin_cfcout_inner_radius", 12.2194);
302  // set_default_double_param(SUPPORTPARAMS, "outer_skin_cfcout_outer_radius", 12.2444);
303  // set_default_double_param(SUPPORTPARAMS, "outer_skin_cfcout_length", 50.7 );
304 
305  set_default_double_param(SUPPORTPARAMS, "outer_skin_inner_radius", 23.4950 / 2 );
306  set_default_double_param(SUPPORTPARAMS, "outer_skin_outer_radius", 23.5458 / 2);
307  set_default_double_param(SUPPORTPARAMS, "outer_skin_length", 49.7 );
308 
309  // Endcap ring flag
310  set_default_int_param(SUPPORTPARAMS, "endcap_ring_enabled", 1);
311  set_default_int_param(SUPPORTPARAMS, "endcap_ring_type", 2); // 0: Al+SS+WG, 1 : CarbonPEEK, 2(default) : new model Jan/2021
312 
313  // Aluminum endcap ring position
314  set_default_double_param(SUPPORTPARAMS, "endcap_ring_z", 24.35);
315 
316  // Aluminum endcap ring
317  set_default_double_param(SUPPORTPARAMS, "endcap_Alring_inner_radius", 6.267 );
318  set_default_double_param(SUPPORTPARAMS, "endcap_Alring_outer_radius", 12.0444);
319  set_default_double_param(SUPPORTPARAMS, "endcap_Alring_length", 0.3645);
320 
321  // Stainless steel endcap ring
322  set_default_double_param(SUPPORTPARAMS, "endcap_SSring_inner_radius", 6.267 );
323  set_default_double_param(SUPPORTPARAMS, "endcap_SSring_outer_radius", 12.0444);
324  set_default_double_param(SUPPORTPARAMS, "endcap_SSring_length", 0.0047);
325 
326  // Water Glycol endcap ring
327  set_default_double_param(SUPPORTPARAMS, "endcap_WGring_inner_radius", 6.267 );
328  set_default_double_param(SUPPORTPARAMS, "endcap_WGring_outer_radius", 12.0444);
329  set_default_double_param(SUPPORTPARAMS, "endcap_WGring_length", 0.0186);
330 
331  // CarbonPEEK endcap ring position
332  set_default_double_param(SUPPORTPARAMS, "endcap_CPring_z", 24.4185);
333 
334  // CarbonPEEK endcap ring position
335  set_default_double_param(SUPPORTPARAMS, "endcap_CPring_inner_radius", 6.6675);
336  set_default_double_param(SUPPORTPARAMS, "endcap_CPring_outer_radius", 11.43 );
337  set_default_double_param(SUPPORTPARAMS, "endcap_CPring_length", 0.6370);
338 
340  // the new endcap model
341  set_default_double_param(SUPPORTPARAMS, "endcap_AlPEEK_Alring_z", 24.4185);
342  set_default_double_param(SUPPORTPARAMS, "endcap_AlPEEK_Alring_1_outer_radius", 11.7475 ); // outer radius of the outermost part
343  set_default_double_param(SUPPORTPARAMS, "endcap_AlPEEK_Cring_1_outer_radius", 11.2020 ); // outer radius of the 2nd outermost part
344  set_default_double_param(SUPPORTPARAMS, "endcap_AlPEEK_Alring_2_outer_radius", 9.65 ); // outer radius of the 3rd outermost part, slightly shrinked from the reeeal drawing of 9.6971 cm to avoid overwlapping
345  set_default_double_param(SUPPORTPARAMS, "endcap_AlPEEK_Cring_2_outer_radius", 8.7095 ); // outer radius of the 4th outermost part
346  set_default_double_param(SUPPORTPARAMS, "endcap_AlPEEK_Alring_3_outer_radius", 7.15 ); // outer radius of the 5th outermost part, slightly shrinked from the real drawing of 7.2045 cm to avoid overlapping
347  set_default_double_param(SUPPORTPARAMS, "endcap_AlPEEK_Alring_3_inner_radius", 6.5088 ); // inner radius of the 5th outermost (=the outer most) part
348 
349  set_default_double_param(SUPPORTPARAMS, "endcap_AlPEEK_Alring_length", 0.75 );
350  set_default_double_param(SUPPORTPARAMS, "endcap_AlPEEK_Cring_length", 0.5 );
351 
353  // Survice barrel, outer
354  set_default_double_param(SUPPORTPARAMS, "service_barrel_outer_inner_radius", 33.02 / 2 );
355  set_default_double_param(SUPPORTPARAMS, "service_barrel_outer_outer_radius", 33.34 / 2 );
356  set_default_double_param(SUPPORTPARAMS, "service_barrel_outer_length", 273.69 );
357 
359  // Support tube
360  set_default_double_param(SUPPORTPARAMS, "support_tube_inner_radius", 37.47 / 2 );
361  set_default_double_param(SUPPORTPARAMS, "support_tube_outer_radius", 38.10 / 2 );
362  set_default_double_param(SUPPORTPARAMS, "support_tube_length", 273.69 );
363 
364 
365  // Cylinders for the bus extenders
366  set_default_int_param(SUPPORTPARAMS, "bus_extender", 1); // 0: OFF, 1: ON
367  set_default_double_param(SUPPORTPARAMS, "bus_extender_length", 111.0 ); // in cm
368  set_default_double_param(SUPPORTPARAMS, "bus_extender_ends_at", 328.5 ); // z-coordinate in cm where the bus extender ends at
369  set_default_double_param(SUPPORTPARAMS, "bus_extender_radius", 15.0 ); // radius of the innermost layer (copper for the inner barrel)
370  set_default_double_param(SUPPORTPARAMS, "bus_extender_copper_x", 48.0e-4 * 1.5 ); // thickness of the copper layer of the bus extenders in cm, it's 48 um
371  set_default_double_param(SUPPORTPARAMS, "bus_extender_kapton_x", 300.0e-4 * 1.5 ); // thickness of the kapton layer of the bus extenders in cm, it's 300 um
372 
373  set_default_double_param(SUPPORTPARAMS, "rail_dphi", 90. ); // deg
374  set_default_double_param(SUPPORTPARAMS, "rail_inner_radius", 0.45);
375  set_default_double_param(SUPPORTPARAMS, "rail_length", 410 ); // tpc length
376  //set_default_double_param(SUPPORTPARAMS, "rail_length", 20 ); // tpc length
377  set_default_double_param(SUPPORTPARAMS, "rail_outer_radius", 0.6 );
378  set_default_double_param(SUPPORTPARAMS, "rail_phi_start", 45. ); // deg
379  //set_default_double_param(SUPPORTPARAMS, "rail_radius", 16.85 );
380  set_default_double_param(SUPPORTPARAMS, "rail_radius", (33.34 + 0.6 * 2 ) /2 ); // tentativevalue
381  }
382 
383  return;
384 }
385 
386 void PHG4InttSubsystem::Print(const string &/*what*/) const
387 {
389  cout << endl
390  << "------" << endl;
392  cout << endl
393  << "------" << endl
394  << endl;
396 }