Analysis Software
Documentation for sPHENIX simulation 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 #include <g4detectors/PHG4DetectorGroupSubsystem.h> // for PHG4DetectorGrou...
10 
11 #include <g4main/PHG4DisplayAction.h> // for PHG4DisplayAction
13 #include <g4main/PHG4SteppingAction.h> // for PHG4SteppingAction
14 
15 #include <phool/PHCompositeNode.h>
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 
22 #include <iostream> // for operator<<, basi...
23 #include <set> // for _Rb_tree_const_i...
24 #include <type_traits> // for __decay_and_stri...
25 
26 class PHG4Detector;
27 
28 //_______________________________________________________________________
29 PHG4InttSubsystem::PHG4InttSubsystem(const std::string &detectorname, const vpair &layerconfig)
30  : PHG4DetectorGroupSubsystem(detectorname)
31  , m_LayerConfigVector(layerconfig)
32  , m_DetectorType(detectorname)
33 {
34  for (std::vector<std::pair<int, int>>::const_iterator piter = layerconfig.begin(); piter != layerconfig.end(); ++piter)
35  {
36  AddDetId((*piter).second);
37  }
38 
40  // put the layer into the name so we get unique names
41  // for multiple layers
42  Name(detectorname);
43  SuperDetector(detectorname);
44 }
45 
47 {
48  delete m_DisplayAction;
49 }
50 
51 //_______________________________________________________________________
53 {
54  if (Verbosity() > 0)
55  {
56  std::cout << "PHG4InttSubsystem::Init started" << std::endl;
57  }
58 
59  PHNodeIterator iter(topNode);
60  PHCompositeNode *dstNode = dynamic_cast<PHCompositeNode *>(iter.findFirst("PHCompositeNode", "DST"));
61 
62  // create display settings before detector (detector adds its volumes to it)
64  // create detector
65  std::pair<std::vector<std::pair<int, int>>::const_iterator, std::vector<std::pair<int, int>>::const_iterator> layer_begin_end = std::make_pair(m_LayerConfigVector.begin(), m_LayerConfigVector.end());
66  m_Detector = new PHG4InttDetector(this, topNode, GetParamsContainer(), Name(), layer_begin_end);
67  m_Detector->Verbosity(Verbosity());
68  m_Detector->SuperDetector(SuperDetector());
69  m_Detector->Detector(m_DetectorType);
70  m_Detector->OverlapCheck(CheckOverlap());
71 
72  int active = 0;
73  // initialize with support active flag (if support is active we need the absorber hit node)
74  int absorberactive = GetParamsContainer()->GetParameters(PHG4InttDefs::SUPPORTPARAMS)->get_int_param("supportactive");
75  int blackhole = 0;
76  for (std::set<int>::const_iterator parcontaineriter = GetDetIds().first; parcontaineriter != GetDetIds().second; ++parcontaineriter)
77  {
78  if (active || GetParamsContainer()->GetParameters(*parcontaineriter)->get_int_param("active"))
79  {
80  active = 1;
81  }
82  if (absorberactive || GetParamsContainer()->GetParameters(*parcontaineriter)->get_int_param("absorberactive") || GetParamsContainer()->GetParameters(*parcontaineriter)->get_int_param("supportactive"))
83  {
84  absorberactive = 1;
85  }
86  if (blackhole || GetParamsContainer()->GetParameters(*parcontaineriter)->get_int_param("blackhole"))
87  {
88  blackhole = 1;
89  }
90  }
91  std::set<std::string> nodes;
92  if (active)
93  {
94  PHNodeIterator dstIter(dstNode);
95  PHCompositeNode *DetNode = dstNode;
96  if (SuperDetector() != "NONE" && !SuperDetector().empty())
97  {
98  PHNodeIterator iter_dst(dstNode);
99  DetNode = dynamic_cast<PHCompositeNode *>(iter_dst.findFirst("PHCompositeNode", SuperDetector()));
100  if (!DetNode)
101  {
102  DetNode = new PHCompositeNode(SuperDetector());
103  dstNode->addNode(DetNode);
104  }
105  }
106  // create hit output nodes
107  std::string detector_suffix = SuperDetector();
108  if (detector_suffix == "NONE" || detector_suffix.empty())
109  {
110  detector_suffix = Name();
111  }
112  m_HitNodeName = "G4HIT_" + detector_suffix;
113  nodes.insert(m_HitNodeName);
114  m_AbsorberNodeName = "G4HIT_ABSORBER_" + detector_suffix;
115  if (absorberactive)
116  {
117  nodes.insert(m_AbsorberNodeName);
118  }
119  for (auto nodename : nodes)
120  {
121  PHG4HitContainer *g4_hits = findNode::getClass<PHG4HitContainer>(topNode, nodename);
122  if (!g4_hits)
123  {
124  g4_hits = new PHG4HitContainer(nodename);
125  DetNode->addNode(new PHIODataNode<PHObject>(g4_hits, nodename, "PHObject"));
126  }
127  }
128  // create stepping action
129  m_SteppingAction = new PHG4InttSteppingAction(m_Detector, GetParamsContainer(), layer_begin_end);
133  }
134  else
135  {
136  if (blackhole)
137  {
138  m_SteppingAction = new PHG4InttSteppingAction(m_Detector, GetParamsContainer(), layer_begin_end);
139  }
140  }
141 
142  return 0;
143 }
144 
145 //_______________________________________________________________________
147 {
148  // pass top node to stepping action so that it gets
149  // relevant nodes needed internally
150  if (m_SteppingAction)
151  {
153  }
154 
155  return 0;
156 }
157 
158 //_______________________________________________________________________
160 {
161  return m_Detector;
162 }
163 
165 {
169  PHG4InttDefs::SEGMENTATION_PHI}; // default
170 
171  int nladder[4] = {12, 12, 16, 16};
172  double sensor_radius[4] = {7.188 - 36e-4, 7.732 - 36e-4, 9.680 - 36e-4, 10.262 - 36e-4};
173  double offsetphi[4] = {-0.5 * 360.0 / nladder[0], 0.0, -0.5 * 360.0 / nladder[2], 0.0};
174 
175  // This was the original code block; I am leaving it here as a comment in case any of the changes need to be reverted
176  // // We have only two types of ladders, one with vertical strips (SEGMENTATION_Z) and one with horizontal strips (SEGMENTATION_PHI)set
177  // // There are 4 sensors in each ladder
178  // // In ladder type 0 the sensor is special and inner and outer sensors are the same.
179  // // In ladder type 1 there are two different sensor types, inner and outer
180  // // We do not want to hard code the ladder types for the layers
181 
182  // // We define default ladder types for 8 layers, but these can be changed at the macro level
183 
184  // int laddertype[8] = {PHG4InttDefs::SEGMENTATION_Z,
185  // PHG4InttDefs::SEGMENTATION_Z,
186  // PHG4InttDefs::SEGMENTATION_PHI,
187  // PHG4InttDefs::SEGMENTATION_PHI,
188  // PHG4InttDefs::SEGMENTATION_PHI,
189  // PHG4InttDefs::SEGMENTATION_PHI,
190  // PHG4InttDefs::SEGMENTATION_PHI,
191  // PHG4InttDefs::SEGMENTATION_PHI}; // default
192 
193  // int nladder[8] = {17, 17, 12, 12, 16, 16, 21, 21}; // default, new 03/05/2020
194 
195  // double sensor_radius[8] = {6.876, 7.462,
196  // // 4 elements are those for PHG4InttDefs::SEGMENTATION_PHI, 36um subtracted to set si sensors at the place
197  // // these subtractions are due to different thickness of glue for the sensors (14um) and the FPHX chips (50um)
198  // 7.188 - 36e-4, 7.732 - 36e-4, 9.680 - 36e-4, 10.262 - 36e-4,
199  // 12.676, 13.179}; // radius of center of sensor for layer default, new 30/05/2020
200 
201  // double offsetphi[4] = {-0.5 * 360.0 / nladder[0+2], 0.0, -0.5 * 360.0 / nladder[2+2], 0.0 }; // the final configuration, July/09/202
202 
203  auto detid = GetDetIds(); // get pair of iterators to begin/end of set<int> of detids
204  for (auto detiter = detid.first; detiter != detid.second; ++detiter)
205  {
206  set_default_int_param(*detiter, "active", 1);
207 
208  // To reconfigure the layers, all you have to do is overide the defaults for these four arrays from the tracking macro
209  set_default_int_param(*detiter, "laddertype", laddertype[*detiter]);
210  set_default_int_param(*detiter, "nladder", nladder[*detiter]); // ladders per layer
211  set_default_double_param(*detiter, "sensor_radius", sensor_radius[*detiter]);
212  // These offsets should be kept at zero in the new design
213  // set_default_double_param(*detiter, "offsetphi", 0.);// obsolete
214  set_default_double_param(*detiter, "offsetphi", offsetphi[*detiter] );
215  set_default_double_param(*detiter, "offsetrot", 0.);
216 
217  // sitrack->set_int_param(i, "laddertype", laddertype[i]);
218  }
219 
220  // These are the parameters that describe the internal ladder geometry for the two ladder types
221  // SEGMENTATION_Z //////////////////////////////////////
222  // int param
223  set_default_int_param(PHG4InttDefs::SEGMENTATION_Z, "nstrips_phi_cell", 1);
224  set_default_int_param(PHG4InttDefs::SEGMENTATION_Z, "nstrips_phi_sensor", 1);
225  set_default_int_param(PHG4InttDefs::SEGMENTATION_Z, "nstrips_z_sensor_0", 128 * 5);
226  set_default_int_param(PHG4InttDefs::SEGMENTATION_Z, "nstrips_z_sensor_1", 128 * 5);
227 
228  // double param
235  set_default_double_param(PHG4InttDefs::SEGMENTATION_Z, "halfladder_inside_z", 23.9622);
241  set_default_double_param(PHG4InttDefs::SEGMENTATION_Z, "sensor_edge_phi", 0.13);
243  set_default_double_param(PHG4InttDefs::SEGMENTATION_Z, "sensor_offset_y", 0.304);
248  set_default_double_param(PHG4InttDefs::SEGMENTATION_Z, "stave_straight_cooler_x", 0.01905);
249  set_default_double_param(PHG4InttDefs::SEGMENTATION_Z, "stave_straight_cooler_y", 0.47);
250  set_default_double_param(PHG4InttDefs::SEGMENTATION_Z, "stave_slant_cooler_y", 1.4362);
251  set_default_double_param(PHG4InttDefs::SEGMENTATION_Z, "stave_straight_outer_y", 0.672);
252  set_default_double_param(PHG4InttDefs::SEGMENTATION_Z, "stave_straight_rohacell_y", 0.57181);
253 
254  // SEGMENTATION_PHI //////////////////////////////////////
255  // int param
256  set_default_int_param(PHG4InttDefs::SEGMENTATION_PHI, "nstrips_phi_cell", 256);
257  set_default_int_param(PHG4InttDefs::SEGMENTATION_PHI, "nstrips_phi_sensor", 256);
258  set_default_int_param(PHG4InttDefs::SEGMENTATION_PHI, "nstrips_z_sensor_0", 8);
259  set_default_int_param(PHG4InttDefs::SEGMENTATION_PHI, "nstrips_z_sensor_1", 5);
260 
261  // double param
267 
268  set_default_double_param(PHG4InttDefs::SEGMENTATION_PHI, "si_glue_x", 0.0014); // 14 um, don't forget to change double sensor_radius when it's changed
269  set_default_double_param(PHG4InttDefs::SEGMENTATION_PHI, "fphx_glue_x", 0.005); // 50 um
270 
272  set_default_double_param(PHG4InttDefs::SEGMENTATION_PHI, "halfladder_inside_z", 23.9622);
273 
278 
286 
287  set_default_double_param(PHG4InttDefs::SEGMENTATION_PHI, "stave_straight_cooler_x", 0.03);
288  set_default_double_param(PHG4InttDefs::SEGMENTATION_PHI, "stave_straight_cooler_y", 1.47684);
289 
290  set_default_double_param(PHG4InttDefs::SEGMENTATION_PHI, "stave_slant_cooler_y", 0.6322614829);
291 
292  set_default_double_param(PHG4InttDefs::SEGMENTATION_PHI, "stave_straight_outer_y", 0.33227);
293  set_default_double_param(PHG4InttDefs::SEGMENTATION_PHI, "stave_straight_rohacell_y", 0.58842);
294 
295  // SUPPORTPARAMS //////////////////////////////////////
296  // int param
298 
299  // double param
300  // set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "inner_skin_inner_radius", 6.2416);
301  // set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "inner_skin_length", 50.7 );
302  // set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "inner_skin_outer_radius", 6.2666);
303  set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "inner_skin_inner_radius", 12.9667 / 2);
304  set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "inner_skin_outer_radius", 13.0175 / 2);
305  set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "inner_skin_length", 49.7);
306 
307  // set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "outer_skin_cfcin_inner_radius", 12.0444);
308  // set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "outer_skin_cfcin_outer_radius", 12.0694);
309  // set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "outer_skin_cfcin_length", 50.7 );
310 
311  // set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "outer_skin_foam_inner_radius", 12.0694);
312  // set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "outer_skin_foam_outer_radius", 12.2194);
313  // set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "outer_skin_foam_length", 50.7 );
314 
315  // set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "outer_skin_cfcout_inner_radius", 12.2194);
316  // set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "outer_skin_cfcout_outer_radius", 12.2444);
317  // set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "outer_skin_cfcout_length", 50.7 );
318 
319  set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "outer_skin_inner_radius", 23.4950 / 2);
320  set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "outer_skin_outer_radius", 23.5458 / 2);
321  set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "outer_skin_length", 49.7);
322 
323  // Endcap ring flag
324  set_default_int_param(PHG4InttDefs::SUPPORTPARAMS, "endcap_ring_enabled", 1);
325  set_default_int_param(PHG4InttDefs::SUPPORTPARAMS, "endcap_ring_type", 2); // 0: Al+SS+WG, 1 : CarbonPEEK, 2(default) : new model Jan/2021
326 
327  // Aluminum endcap ring position
328  set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "endcap_ring_z", 24.35);
329 
330  // Aluminum endcap ring
331  set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "endcap_Alring_inner_radius", 6.267);
332  set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "endcap_Alring_outer_radius", 12.0444);
333  set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "endcap_Alring_length", 0.3645);
334 
335  // Stainless steel endcap ring
336  set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "endcap_SSring_inner_radius", 6.267);
337  set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "endcap_SSring_outer_radius", 12.0444);
338  set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "endcap_SSring_length", 0.0047);
339 
340  // Water Glycol endcap ring
341  set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "endcap_WGring_inner_radius", 6.267);
342  set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "endcap_WGring_outer_radius", 12.0444);
343  set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "endcap_WGring_length", 0.0186);
344 
345  // CarbonPEEK endcap ring position
346  set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "endcap_CPring_z", 24.4185);
347 
348  // CarbonPEEK endcap ring position
349  set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "endcap_CPring_inner_radius", 6.6675);
350  set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "endcap_CPring_outer_radius", 11.43);
351  set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "endcap_CPring_length", 0.6370);
352 
354  // the new endcap model
355  set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "endcap_AlPEEK_Alring_z", 24.4185);
356  set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "endcap_AlPEEK_Alring_1_outer_radius", 11.7475); // outer radius of the outermost part
357  set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "endcap_AlPEEK_Cring_1_outer_radius", 11.2020); // outer radius of the 2nd outermost part
358  set_default_double_param(PHG4InttDefs::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
359  set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "endcap_AlPEEK_Cring_2_outer_radius", 8.7095); // outer radius of the 4th outermost part
360  set_default_double_param(PHG4InttDefs::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
361  set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "endcap_AlPEEK_Alring_3_inner_radius", 6.5088); // inner radius of the 5th outermost (=the outer most) part
362 
363  set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "endcap_AlPEEK_Alring_length", 0.75);
364  set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "endcap_AlPEEK_Cring_length", 0.5);
365 
367  // Survice barrel, outer
368  set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "service_barrel_outer_inner_radius", 33.02 / 2);
369  set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "service_barrel_outer_outer_radius", 33.34 / 2);
370  set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "service_barrel_outer_length", 273.69);
371 
373  // Support tube
374  set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "support_tube_inner_radius", 37.47 / 2);
375  set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "support_tube_outer_radius", 38.10 / 2);
376  set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "support_tube_length", 273.69);
377 
378  // Cylinders for the bus extenders
379  set_default_int_param(PHG4InttDefs::SUPPORTPARAMS, "bus_extender", 1); // 0: OFF, 1: ON
380  set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "bus_extender_length", 111.0); // in cm
381  set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "bus_extender_ends_at", 328.5); // z-coordinate in cm where the bus extender ends at
382  set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "bus_extender_radius", 15.0); // radius of the innermost layer (copper for the inner barrel)
383  set_default_double_param(PHG4InttDefs::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
384  set_default_double_param(PHG4InttDefs::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
385 
386  set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "rail_dphi", 90.); // deg
387  set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "rail_inner_radius", 0.45);
388  set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "rail_length", 410); // tpc length
389  //set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "rail_length", 20 ); // tpc length
390  set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "rail_outer_radius", 0.6);
391  set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "rail_phi_start", 45.); // deg
392  //set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "rail_radius", 16.85 );
393  set_default_double_param(PHG4InttDefs::SUPPORTPARAMS, "rail_radius", (33.34 + 0.6 * 2) / 2); // tentativevalue
394 
395  return;
396 }
397 
398 void PHG4InttSubsystem::Print(const std::string & /*what*/) const
399 {
401  std::cout << std::endl
402  << "------" << std::endl;
404  std::cout << std::endl
405  << "------" << std::endl
406  << std::endl;
408 }