Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4Prototype2InnerHcalSubsystem.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4Prototype2InnerHcalSubsystem.cc
5 
6 #include <phparameter/PHParameters.h>
7 
8 #include <g4detectors/PHG4DetectorSubsystem.h> // for PHG4DetectorSubsy...
9 
11 #include <g4main/PHG4SteppingAction.h> // for PHG4SteppingAction
12 
13 #include <phool/PHCompositeNode.h>
14 #include <phool/PHIODataNode.h> // for PHIODataNode
15 #include <phool/PHNode.h> // for PHNode
16 #include <phool/PHNodeIterator.h> // for PHNodeIterator
17 #include <phool/PHObject.h> // for PHObject
18 #include <phool/getClass.h>
19 
20 #include <boost/foreach.hpp>
21 
22 #include <cmath> // for NAN
23 #include <iostream> // for operator<<, basic...
24 #include <set>
25 #include <sstream>
26 
27 class PHG4Detector;
28 
29 using namespace std;
30 
31 //_______________________________________________________________________
33  : PHG4DetectorSubsystem(name, lyr)
34  , m_Detector(nullptr)
35  , m_SteppingAction(nullptr)
36 {
38 }
39 
40 //_______________________________________________________________________
42 {
43  PHNodeIterator iter(topNode);
44  PHCompositeNode *dstNode = dynamic_cast<PHCompositeNode *>(iter.findFirst("PHCompositeNode", "DST"));
45 
46  // create detector
47  m_Detector = new PHG4Prototype2InnerHcalDetector(this, topNode, GetParams(), Name());
50  set<string> nodes;
51  if (GetParams()->get_int_param("active"))
52  {
53  PHNodeIterator dstiter(dstNode);
54  PHCompositeNode *DetNode = dynamic_cast<PHCompositeNode *>(dstiter.findFirst("PHCompositeNode", SuperDetector()));
55  if (!DetNode)
56  {
57  DetNode = new PHCompositeNode(SuperDetector());
58  dstNode->addNode(DetNode);
59  }
60 
61  ostringstream nodename;
62  if (SuperDetector() != "NONE")
63  {
64  nodename << "G4HIT_" << SuperDetector();
65  }
66  else
67  {
68  nodename << "G4HIT_" << Name();
69  }
70  nodes.insert(nodename.str());
71  if (GetParams()->get_int_param("absorberactive"))
72  {
73  nodename.str("");
74  if (SuperDetector() != "NONE")
75  {
76  nodename << "G4HIT_ABSORBER_" << SuperDetector();
77  }
78  else
79  {
80  nodename << "G4HIT_ABSORBER_" << Name();
81  }
82  nodes.insert(nodename.str());
83  }
84  BOOST_FOREACH (string node, nodes)
85  {
86  PHG4HitContainer *g4_hits = findNode::getClass<PHG4HitContainer>(topNode, node.c_str());
87  if (!g4_hits)
88  {
89  g4_hits = new PHG4HitContainer(node);
90  DetNode->addNode(new PHIODataNode<PHObject>(g4_hits, node.c_str(), "PHObject"));
91  }
92  }
93 
94  // create stepping action
96  }
97  else
98  {
99  // if this is a black hole it does not have to be active
100  if (GetParams()->get_int_param("blackhole"))
101  {
103  }
104  }
105  return 0;
106 }
107 
108 //_______________________________________________________________________
110 {
111  // pass top node to stepping action so that it gets
112  // relevant nodes needed internally
113  if (m_SteppingAction)
114  {
116  }
117  return 0;
118 }
119 
120 void PHG4Prototype2InnerHcalSubsystem::Print(const string &what) const
121 {
122  cout << Name() << " Parameters: " << endl;
123  GetParams()->Print();
124  if (m_Detector)
125  {
126  m_Detector->Print(what);
127  }
128  if (m_SteppingAction)
129  {
130  m_SteppingAction->Print(what);
131  }
132  return;
133 }
134 
135 //_______________________________________________________________________
137 {
138  return m_Detector;
139 }
140 
142 {
143  // all in cm
144  set_default_double_param("light_balance_inner_corr", NAN);
145  set_default_double_param("light_balance_inner_radius", NAN);
146  set_default_double_param("light_balance_outer_corr", NAN);
147  set_default_double_param("light_balance_outer_radius", NAN);
148  set_default_double_param("place_x", 0.);
149  set_default_double_param("place_y", 0.);
150  set_default_double_param("place_z", 0.);
151  set_default_double_param("rot_x", 0.);
152  set_default_double_param("rot_y", 0.);
153  set_default_double_param("rot_z", 0.);
154  set_default_double_param("steplimits", NAN);
155 
156  set_default_int_param("hi_eta", 0);
157  set_default_int_param("light_scint_model", 1);
159 }
160 
161 void PHG4Prototype2InnerHcalSubsystem::SetLightCorrection(const double inner_radius, const double inner_corr, const double outer_radius, const double outer_corr)
162 {
163  set_double_param("light_balance_inner_corr", inner_corr);
164  set_double_param("light_balance_inner_radius", inner_radius);
165  set_double_param("light_balance_outer_corr", outer_corr);
166  set_double_param("light_balance_outer_radius", outer_radius);
167  return;
168 }