Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4IHCalSubsystem.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4IHCalSubsystem.cc
1 #include "PHG4IHCalSubsystem.h"
2 
3 #include "PHG4IHCalDetector.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 
24 #include <cmath> // for NAN
25 #include <iostream> // for operator<<, basic_ostream
26 #include <set>
27 
28 class PHG4Detector;
29 
30 //_______________________________________________________________________
32  : PHG4DetectorSubsystem(name, lyr)
33 {
35 }
36 
37 //_______________________________________________________________________
39 {
40  delete m_DisplayAction;
41 }
42 
43 //_______________________________________________________________________
45 {
46  PHNodeIterator iter(topNode);
47  PHCompositeNode *dstNode = dynamic_cast<PHCompositeNode *>(iter.findFirst("PHCompositeNode", "DST"));
48 
49  // create display settings before detector
51 
52  // create detector
53  m_Detector = new PHG4IHCalDetector(this, topNode, GetParams(), Name());
56  std::set<std::string> nodes;
57  if (GetParams()->get_int_param("active"))
58  {
59  PHNodeIterator dstIter(dstNode);
60  PHCompositeNode *DetNode = dstNode;
61 
62  if (SuperDetector() != "NONE" && !SuperDetector().empty())
63  {
64  PHNodeIterator iter_dst(dstNode);
65  DetNode = dynamic_cast<PHCompositeNode *>(iter_dst.findFirst("PHCompositeNode", SuperDetector()));
66 
67  if (!DetNode)
68  {
69  DetNode = new PHCompositeNode(SuperDetector());
70  dstNode->addNode(DetNode);
71  }
72  }
73  std::string detector_suffix = SuperDetector();
74  if (detector_suffix == "NONE" || detector_suffix.empty())
75  {
76  detector_suffix = Name();
77  }
78 
79  m_HitNodeName = "G4HIT_" + detector_suffix;
80  nodes.insert(m_HitNodeName);
81  m_AbsorberNodeName = "G4HIT_ABSORBER_" + detector_suffix;
82  if (GetParams()->get_int_param("absorberactive"))
83  {
84  nodes.insert(m_AbsorberNodeName);
85  }
86  for (const auto &nodename : nodes)
87  {
88  PHG4HitContainer *g4_hits = findNode::getClass<PHG4HitContainer>(topNode, nodename);
89  if (!g4_hits)
90  {
91  g4_hits = new PHG4HitContainer(nodename);
92  DetNode->addNode(new PHIODataNode<PHObject>(g4_hits, nodename, "PHObject"));
93  }
94  }
95 
96  // create stepping action
101  }
102  else
103  {
104  // if this is a black hole it does not have to be active
105  if (GetParams()->get_int_param("blackhole"))
106  {
108  m_SteppingAction->InitWithNode(topNode);
109  }
110  }
111  return 0;
112 }
113 
114 //_______________________________________________________________________
116 {
117  // pass top node to stepping action so that it gets
118  // relevant nodes needed internally
119  if (m_SteppingAction)
120  {
122  }
123  return 0;
124 }
125 
126 void PHG4IHCalSubsystem::Print(const std::string &what) const
127 {
128  std::cout << Name() << " Parameters: " << std::endl;
129  GetParams()->Print();
130  if (m_Detector)
131  {
132  m_Detector->Print(what);
133  }
134  if (m_SteppingAction)
135  {
136  m_SteppingAction->Print(what);
137  }
138 
139  return;
140 }
141 
142 //_______________________________________________________________________
144 {
145  return m_Detector;
146 }
147 
149 {
151  set_default_double_param("light_balance_inner_corr", NAN);
152  set_default_double_param("light_balance_inner_radius", NAN);
153  set_default_double_param("light_balance_outer_corr", NAN);
154  set_default_double_param("light_balance_outer_radius", NAN);
155  set_default_double_param("phistart", NAN);
156  set_default_double_param("scinti_eta_coverage_neg", 1.1);
157  set_default_double_param("scinti_eta_coverage_pos", 1.1);
159  set_default_double_param("place_x", 0.);
160  set_default_double_param("place_y", 0.);
161  set_default_double_param("place_z", 0.);
162  set_default_double_param("rot_x", 0.);
163  set_default_double_param("rot_y", 180.);
164  set_default_double_param("rot_z", 0.);
165  set_default_double_param("size_z", 435.000 + 10 );
166  set_default_double_param("Birk_const", 0.07943);
167  set_default_double_param("tmin", -20.);
168  set_default_double_param("tmax", 60.);
169  set_default_double_param("dt", 100.);
170 
171 
172  set_default_int_param("light_scint_model", 1);
176  set_default_int_param("etabins", 24);
177  set_default_int_param("saveg4hit", 1);
178 
179 
180  set_default_string_param("GDMPath", "DefaultParameters-InvadPath");
181  const char* Calibroot = getenv("CALIBRATIONROOT");
182  std::string defaultmapfilename;
183  if (Calibroot)
184  {
185  defaultmapfilename = Calibroot;
186  defaultmapfilename += "/HCALIN/tilemap/ihcalgdmlmap09212022.root";
187  }
188  set_default_string_param("MapFileName", defaultmapfilename);
189  set_default_string_param("MapHistoName", "ihcalcombinedgdmlnormtbyt");
190 }
191 
192 void PHG4IHCalSubsystem::SetLightCorrection(const double inner_radius, const double inner_corr, const double outer_radius, const double outer_corr)
193 {
194  set_double_param("light_balance_inner_corr", inner_corr);
195  set_double_param("light_balance_inner_radius", inner_radius);
196  set_double_param("light_balance_outer_corr", outer_corr);
197  set_double_param("light_balance_outer_radius", outer_radius);
198  return;
199 }