Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4OHCalSubsystem.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4OHCalSubsystem.cc
1 #include "PHG4OHCalSubsystem.h"
2 
3 #include "PHG4OHCalDetector.h"
6 
7 #include <g4detectors/PHG4DetectorSubsystem.h> // for PHG4DetectorSubsystem
9 
10 #include <phparameter/PHParameters.h>
11 
12 #include <g4main/PHG4DisplayAction.h> // for PHG4DisplayAction
14 #include <g4main/PHG4SteppingAction.h> // for PHG4SteppingAction
15 
16 #include <phool/PHCompositeNode.h>
17 #include <phool/PHIODataNode.h> // for PHIODataNode
18 #include <phool/PHNode.h> // for PHNode
19 #include <phool/PHNodeIterator.h> // for PHNodeIterator
20 #include <phool/PHObject.h> // for PHObject
21 #include <phool/getClass.h>
22 
23 #include <cmath> // for NAN
24 #include <cstdlib> // for getenv
25 #include <iostream> // for operator<<, basic_ostream
26 #include <set> // for set
27 class PHG4Detector;
28 
29 //_______________________________________________________________________
31  : PHG4DetectorSubsystem(name, lyr)
32 {
34 }
35 
36 //_______________________________________________________________________
38 {
39  delete m_DisplayAction;
40 }
41 
42 //_______________________________________________________________________
44 {
45  PHNodeIterator iter(topNode);
46  PHCompositeNode *dstNode = dynamic_cast<PHCompositeNode *>(iter.findFirst("PHCompositeNode", "DST"));
47 
48  // create display settings before detector
50 
51  if (get_string_param("IronFieldMapPath") == "DefaultParameters-InvadPath")
52  {
53  std::cout << __PRETTY_FUNCTION__ << ": invalid string parameter IronFieldMapPath, where we expect a 3D field map" << std::endl;
54  exit(1);
55  }
56 
57  // create detector
58  m_Detector = new PHG4OHCalDetector(this, topNode, GetParams(), Name());
61  std::set<std::string> nodes;
62  if (GetParams()->get_int_param("active"))
63  {
64  PHNodeIterator dstIter(dstNode);
65  PHCompositeNode *DetNode = dstNode;
66  if (SuperDetector() != "NONE" && !SuperDetector().empty())
67  {
68  PHNodeIterator iter_dst(dstNode);
69  DetNode = dynamic_cast<PHCompositeNode *>(iter_dst.findFirst("PHCompositeNode", SuperDetector()));
70 
71  if (!DetNode)
72  {
73  DetNode = new PHCompositeNode(SuperDetector());
74  dstNode->addNode(DetNode);
75  }
76  }
77  std::string detector_suffix = SuperDetector();
78  if (detector_suffix == "NONE" || detector_suffix.empty())
79  {
80  detector_suffix = Name();
81  }
82 
83  m_HitNodeName = "G4HIT_" + detector_suffix;
84  nodes.insert(m_HitNodeName);
85  m_AbsorberNodeName = "G4HIT_ABSORBER_" + detector_suffix;
86  if (GetParams()->get_int_param("absorberactive"))
87  {
88  nodes.insert(m_AbsorberNodeName);
89  }
90  for (const auto &nodename : nodes)
91  {
92  PHG4HitContainer *g4_hits = findNode::getClass<PHG4HitContainer>(topNode, nodename);
93  if (!g4_hits)
94  {
95  g4_hits = new PHG4HitContainer(nodename);
96  DetNode->addNode(new PHIODataNode<PHObject>(g4_hits, nodename, "PHObject"));
97  }
98  }
99  // create stepping action
101  m_SteppingAction->InitWithNode(topNode);
104  }
105  else
106  {
107  if (GetParams()->get_int_param("blackhole"))
108  {
110  m_SteppingAction->InitWithNode(topNode);
111  }
112  }
113 
114  return 0;
115 }
116 
117 //_______________________________________________________________________
119 {
120  // pass top node to stepping action so that it gets
121  // relevant nodes needed internally
122  if (m_SteppingAction)
123  {
125  }
126  return 0;
127 }
128 
129 void PHG4OHCalSubsystem::Print(const std::string &what) const
130 {
131  std::cout << "Outer Hcal Parameters: " << std::endl;
132  GetParams()->Print();
133  if (m_Detector)
134  {
135  m_Detector->Print(what);
136  }
137  return;
138 }
139 
140 //_______________________________________________________________________
142 {
143  return m_Detector;
144 }
145 
146 void PHG4OHCalSubsystem::SetLightCorrection(const double inner_radius, const double inner_corr, const double outer_radius, const double outer_corr)
147 {
148  set_double_param("light_balance_inner_corr", inner_corr);
149  set_double_param("light_balance_inner_radius", inner_radius);
150  set_double_param("light_balance_outer_corr", outer_corr);
151  set_double_param("light_balance_outer_radius", outer_radius);
152  return;
153 }
154 
156 {
157  set_default_double_param("inner_radius", 182.423 - 5);
158  set_default_double_param("light_balance_inner_corr", NAN);
159  set_default_double_param("light_balance_inner_radius", NAN);
160  set_default_double_param("light_balance_outer_corr", NAN);
161  set_default_double_param("light_balance_outer_radius", NAN);
162  set_default_double_param("phistart", NAN);
163  set_default_double_param("scinti_eta_coverage_neg", 1.1);
164  set_default_double_param("scinti_eta_coverage_pos", 1.1);
165  set_default_double_param("outer_radius", 269.317 + 5);
166  set_default_double_param("place_x", 0.);
167  set_default_double_param("place_y", 0.);
168  set_default_double_param("place_z", 0.);
169  set_default_double_param("rot_x", 0.);
170  set_default_double_param("rot_y", 180.);
171  set_default_double_param("rot_z", 0.);
172  set_default_double_param("size_z", 639.240 + 10);
173  set_default_double_param("Birk_const", 0.07943);
174  set_default_double_param("tmin", -20.);
175  set_default_double_param("tmax", 60.);
176  set_default_double_param("dt", 100.);
177  set_default_int_param("field_check", 0);
178  set_default_int_param("light_scint_model", 1);
179 
180  set_default_int_param("n_towers", 64);
182  set_default_int_param("n_scinti_tiles", 12);
183  set_default_int_param("etabins", 24);
184  set_default_int_param("saveg4hit", 1);
185 
186  set_default_string_param("GDMPath", "DefaultParameters-InvadPath");
187  std::string defaultmapfilename;
188  const char *Calibroot = getenv("CALIBRATIONROOT");
189  if (Calibroot)
190  {
191  defaultmapfilename = Calibroot;
192  defaultmapfilename += "/HCALOUT/tilemap/ohcalgdmlmapfiles102022.root";
193  }
194  set_default_string_param("MapFileName", defaultmapfilename);
195  set_default_string_param("MapHistoName", "ohcal_mephi_map_towerid_");
196 
197  if (!Calibroot)
198  {
199  std::cout << __PRETTY_FUNCTION__ << ": no CALIBRATIONROOT environment variable" << std::endl;
200  exit(1);
201  }
202  set_default_string_param("IronFieldMapPath", std::string(Calibroot) + "/Field/Map/sphenix3dbigmapxyz_steel_rebuild.root");
203  set_default_double_param("IronFieldMapScale", 1.);
204 }