Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4InnerHcalSubsystem.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4InnerHcalSubsystem.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>
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 PHG4InnerHcalDetector(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 
66  std::ostringstream nodename;
67  if (SuperDetector() != "NONE")
68  {
69  nodename << "G4HIT_" << SuperDetector();
70  }
71  else
72  {
73  nodename << "G4HIT_" << Name();
74  }
75  nodes.insert(nodename.str());
76  if (GetParams()->get_int_param("absorberactive"))
77  {
78  nodename.str("");
79  if (SuperDetector() != "NONE")
80  {
81  nodename << "G4HIT_ABSORBER_" << SuperDetector();
82  }
83  else
84  {
85  nodename << "G4HIT_ABSORBER_" << Name();
86  }
87  nodes.insert(nodename.str());
88  }
89  for (auto &node : nodes)
90  {
91  PHG4HitContainer *g4_hits = findNode::getClass<PHG4HitContainer>(topNode, node);
92  if (!g4_hits)
93  {
94  g4_hits = new PHG4HitContainer(node);
95  DetNode->addNode(new PHIODataNode<PHObject>(g4_hits, node, "PHObject"));
96  }
97  }
98 
99  // create stepping action
101  m_SteppingAction->InitWithNode(topNode);
102  }
103  else
104  {
105  // if this is a black hole it does not have to be active
106  if (GetParams()->get_int_param("blackhole"))
107  {
109  m_SteppingAction->InitWithNode(topNode);
110  }
111  }
112  return 0;
113 }
114 
115 //_______________________________________________________________________
117 {
118  // pass top node to stepping action so that it gets
119  // relevant nodes needed internally
120  if (m_SteppingAction)
121  {
123  }
124  return 0;
125 }
126 
128 {
129  std::cout << Name() << " Parameters: " << std::endl;
130  GetParams()->Print();
131  if (m_Detector)
132  {
133  m_Detector->Print(what);
134  }
135  if (m_SteppingAction)
136  {
137  m_SteppingAction->Print(what);
138  }
139 
140  return;
141 }
142 
143 //_______________________________________________________________________
145 {
146  return m_Detector;
147 }
148 
150 {
152  set_default_double_param("light_balance_inner_corr", NAN);
153  set_default_double_param("light_balance_inner_radius", NAN);
154  set_default_double_param("light_balance_outer_corr", NAN);
155  set_default_double_param("light_balance_outer_radius", NAN);
156  set_default_double_param("phistart", NAN);
158  set_default_double_param("place_x", 0.);
159  set_default_double_param("place_y", 0.);
160  set_default_double_param("place_z", 0.);
161  set_default_double_param("rot_x", 0.);
162  set_default_double_param("rot_y", 0.);
163  set_default_double_param("rot_z", 0.);
164  set_default_double_param("scinti_eta_coverage", 1.1);
165  set_default_double_param("scinti_eta_coverage_pos", 1.1);
166  set_default_double_param("scinti_eta_coverage_neg", 1.1);
167  set_default_double_param("scinti_gap_neighbor", 0.1);
168  set_default_double_param("scinti_inner_gap", 0.85);
169  set_default_double_param("scinti_outer_gap", 1.22 * (5.0 / 4.0));
170  set_default_double_param("tmin", -20.);
171  set_default_double_param("tmax", 60.);
172  set_default_double_param("dt", 100.);
173  // some math issue in the code subtracts 0.4mm so the scintillator
174  // does not end at 133.09 as per drawing but at 133.05
175  // adding 0.4mm compensates for this (so 133.13 gives the desired 133.09
176  set_default_double_param("scinti_outer_radius", 133.13);
177  set_default_double_param("scinti_tile_thickness", 0.7);
178  set_default_double_param("size_z", 175.94 * 2);
179  set_default_double_param("steplimits", NAN);
180  set_default_double_param("tilt_angle", 36.15); // engineering drawing
181  // corresponds very closely to 4 crossinge (35.5497 deg)
182 
183  set_default_int_param("light_scint_model", 1);
184  // if ncross is set (and tilt_angle is NAN) tilt_angle is calculated
185  // from number of crossings
186  set_default_int_param("ncross", 0);
192  set_default_int_param("etabins", 24);
193  set_default_int_param("saveg4hit", 1);
194 
195  set_default_string_param("material", "G4_Al");
196  std::string defaultmapfilename;
197  const char *Calibroot = getenv("CALIBRATIONROOT");
198  if (Calibroot)
199  {
200  defaultmapfilename = Calibroot;
201  defaultmapfilename += "/HCALIN/tilemap/iHCALMapsNorm020922.root";
202  }
203  set_default_string_param("MapFileName", defaultmapfilename);
204  set_default_string_param("MapHistoName", "ihcalmapcombined");
205 }
206 
207 void PHG4InnerHcalSubsystem::SetLightCorrection(const double inner_radius, const double inner_corr, const double outer_radius, const double outer_corr)
208 {
209  set_double_param("light_balance_inner_corr", inner_corr);
210  set_double_param("light_balance_inner_radius", inner_radius);
211  set_double_param("light_balance_outer_corr", outer_corr);
212  set_double_param("light_balance_outer_radius", outer_radius);
213  return;
214 }