Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4OuterHcalSubsystem.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4OuterHcalSubsystem.cc
2 
3 #include "PHG4HcalDefs.h"
7 
8 #include <phparameter/PHParameters.h>
9 
10 #include <g4main/PHG4DisplayAction.h> // for PHG4DisplayAction
12 #include <g4main/PHG4SteppingAction.h> // for PHG4SteppingAction
13 
14 #include <phool/PHCompositeNode.h>
15 #include <phool/PHIODataNode.h> // for PHIODataNode
16 #include <phool/PHNode.h> // for PHNode
17 #include <phool/PHNodeIterator.h> // for PHNodeIterator
18 #include <phool/PHObject.h> // for PHObject
19 #include <phool/getClass.h>
20 
21 #include <cmath> // for NAN
22 #include <iostream> // for operator<<, basic_ostream
23 #include <set> // for set
24 #include <sstream>
25 
26 class PHG4Detector;
27 
28 //_______________________________________________________________________
30  : PHG4DetectorSubsystem(name, lyr)
31 {
33 }
34 
35 //_______________________________________________________________________
37 {
38  delete m_DisplayAction;
39 }
40 
41 //_______________________________________________________________________
43 {
44  PHNodeIterator iter(topNode);
45  PHCompositeNode *dstNode = dynamic_cast<PHCompositeNode *>(iter.findFirst("PHCompositeNode", "DST"));
46 
47  // create display settings before detector
49 
50  // create detector
51  m_Detector = new PHG4OuterHcalDetector(this, topNode, GetParams(), Name());
54 
55  if (GetParams()->get_int_param("active"))
56  {
57  std::set<std::string> nodes;
58  PHNodeIterator dstIter(dstNode);
59  PHCompositeNode *DetNode = dynamic_cast<PHCompositeNode *>(dstIter.findFirst("PHCompositeNode", SuperDetector()));
60  if (!DetNode)
61  {
62  DetNode = new PHCompositeNode(SuperDetector());
63  dstNode->addNode(DetNode);
64  }
65  std::ostringstream nodename;
66  if (SuperDetector() != "NONE")
67  {
68  nodename << "G4HIT_" << SuperDetector();
69  }
70  else
71  {
72  nodename << "G4HIT_" << Name();
73  }
74  nodes.insert(nodename.str());
75  if (GetParams()->get_int_param("absorberactive"))
76  {
77  nodename.str("");
78  if (SuperDetector() != "NONE")
79  {
80  nodename << "G4HIT_ABSORBER_" << SuperDetector();
81  }
82  else
83  {
84  nodename << "G4HIT_ABSORBER_" << Name();
85  }
86  nodes.insert(nodename.str());
87  }
88  for (auto &node : nodes)
89  {
90  PHG4HitContainer *g4_hits = findNode::getClass<PHG4HitContainer>(topNode, node);
91  if (!g4_hits)
92  {
93  g4_hits = new PHG4HitContainer(node);
94  DetNode->addNode(new PHIODataNode<PHObject>(g4_hits, node, "PHObject"));
95  }
96  }
97  // create stepping action
100  }
101  else
102  {
103  if (GetParams()->get_int_param("blackhole"))
104  {
106  m_SteppingAction->InitWithNode(topNode);
107  }
108  }
109 
110  return 0;
111 }
112 
113 //_______________________________________________________________________
115 {
116  // pass top node to stepping action so that it gets
117  // relevant nodes needed internally
118  if (m_SteppingAction)
119  {
121  }
122  return 0;
123 }
124 
126 {
127  std::cout << "Outer Hcal Parameters: " << std::endl;
128  GetParams()->Print();
129  if (m_Detector)
130  {
131  m_Detector->Print(what);
132  }
133  return;
134 }
135 
136 //_______________________________________________________________________
138 {
139  return m_Detector;
140 }
141 
142 void PHG4OuterHcalSubsystem::SetLightCorrection(const double inner_radius, const double inner_corr, const double outer_radius, const double outer_corr)
143 {
144  set_double_param("light_balance_inner_corr", inner_corr);
145  set_double_param("light_balance_inner_radius", inner_radius);
146  set_double_param("light_balance_outer_corr", outer_corr);
147  set_double_param("light_balance_outer_radius", outer_radius);
148  return;
149 }
150 
152 {
153  set_default_double_param("inner_radius", 183.3);
154  set_default_double_param("light_balance_inner_corr", NAN);
155  set_default_double_param("light_balance_inner_radius", NAN);
156  set_default_double_param("light_balance_outer_corr", NAN);
157  set_default_double_param("light_balance_outer_radius", NAN);
158  set_default_double_param("phistart", NAN);
159  set_default_double_param("scinti_eta_coverage_neg", 1.1);
160  set_default_double_param("scinti_eta_coverage_pos", 1.1);
161  // some math issue in the code does not subtract the magnet cutout correctly
162  // (maybe some factor of 2 in a G4 volume creation)
163  // The engineering drawing values are:
164  // set_default_double_param("magnet_cutout_radius", 195.31);
165  // set_default_double_param("magnet_cutout_scinti_radius", 195.96);
166  // seting this to these values results in the correct edges
167  // (verified by looking at the G4 hit coordinates of the inner edges)
168  set_default_double_param("magnet_cutout_radius", 195.72);
169  set_default_double_param("magnet_cutout_scinti_radius", 197.04);
170  set_default_double_param("outer_radius", 264.71);
171  set_default_double_param("place_x", 0.);
172  set_default_double_param("place_y", 0.);
173  set_default_double_param("place_z", 0.);
174  set_default_double_param("rot_x", 0.);
175  set_default_double_param("rot_y", 0.);
176  set_default_double_param("rot_z", 0.);
177  set_default_double_param("tmin", -20.);
178  set_default_double_param("tmax", 60.);
179  set_default_double_param("dt", 100.);
180  set_default_double_param("scinti_eta_coverage", 1.1);
181  set_default_double_param("scinti_gap", 0.85);
182  set_default_double_param("scinti_gap_neighbor", 0.1);
183  set_default_double_param("scinti_inner_radius", 183.89);
184  // some math issue in the code subtracts 0.1mm+ so the scintillator
185  // does not end at 263.27 as per drawing but at 263.26
186  // adding 0.125mm compensates for this (so 263.2825 gives the desired 263.27
187  set_default_double_param("scinti_outer_radius", 263.2825);
188  set_default_double_param("scinti_tile_thickness", 0.7);
189  set_default_double_param("size_z", 304.91 * 2);
190  set_default_double_param("steplimits", NAN);
191  set_default_double_param("tilt_angle", -11.23); // engineering drawing
192  // corresponds very closely to 4 crossinge (-11.7826 deg)
193 
194  set_default_int_param("field_check", 0);
195  set_default_int_param("light_scint_model", 1);
196  set_default_int_param("magnet_cutout_first_scinti", 8); // tile start at 0, drawing tile starts at 1
197  set_default_int_param("etabins", 24);
198  set_default_int_param("saveg4hit", 1);
199 
200  // if ncross is set (and tilt_angle is NAN) tilt_angle is calculated
201  // from number of crossings
202  set_default_int_param("ncross", 0);
203  set_default_int_param("n_towers", 64);
205  set_default_int_param("n_scinti_tiles", 12);
206 
207  set_default_string_param("material", "Steel_1006");
208  std::string defaultmapfilename;
209  const char *Calibroot = getenv("CALIBRATIONROOT");
210  if (Calibroot)
211  {
212  defaultmapfilename = Calibroot;
213  defaultmapfilename += "/HCALOUT/tilemap/oHCALMaps092021.root";
214  }
215  set_default_string_param("MapFileName", defaultmapfilename);
216  set_default_string_param("MapHistoName", "hCombinedMap");
217 }