Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4Prototype3InnerHcalSubsystem.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4Prototype3InnerHcalSubsystem.cc
5 
6 #include <phparameter/PHParameters.h>
7 
8 #include <phparameter/PHParameters.h>
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 PHG4Prototype3InnerHcalDetector(this, topNode, GetParams(), Name());
50  set<string> nodes;
51  if (GetParams()->get_int_param("active") || GetParams()->get_int_param("absorberactive"))
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 (GetParams()->get_int_param("active"))
63  {
64  if (SuperDetector() != "NONE")
65  {
66  nodename << "G4HIT_" << SuperDetector();
67  }
68  else
69  {
70  nodename << "G4HIT_" << Name();
71  }
72  nodes.insert(nodename.str());
73  }
74  if (GetParams()->get_int_param("absorberactive"))
75  {
76  nodename.str("");
77  if (SuperDetector() != "NONE")
78  {
79  nodename << "G4HIT_ABSORBER_" << SuperDetector();
80  }
81  else
82  {
83  nodename << "G4HIT_ABSORBER_" << Name();
84  }
85  nodes.insert(nodename.str());
86  }
87  BOOST_FOREACH (string node, nodes)
88  {
89  PHG4HitContainer *g4_hits = findNode::getClass<PHG4HitContainer>(topNode, node.c_str());
90  if (!g4_hits)
91  {
92  g4_hits = new PHG4HitContainer(node);
93  DetNode->addNode(new PHIODataNode<PHObject>(g4_hits, node.c_str(), "PHObject"));
94  }
95  }
96 
97  // create stepping action
99  }
100  else
101  {
102  // if this is a black hole it does not have to be active
103  if (GetParams()->get_int_param("blackhole"))
104  {
106  }
107  }
108  return 0;
109 }
110 
111 //_______________________________________________________________________
113 {
114  // pass top node to stepping action so that it gets
115  // relevant nodes needed internally
116  if (m_SteppingAction)
117  {
119  }
120  return 0;
121 }
122 
123 void PHG4Prototype3InnerHcalSubsystem::Print(const string &what) const
124 {
125  cout << Name() << " Parameters: " << endl;
126  GetParams()->Print();
127  if (m_Detector)
128  {
129  m_Detector->Print(what);
130  }
131  if (m_SteppingAction)
132  {
133  m_SteppingAction->Print(what);
134  }
135  return;
136 }
137 
138 //_______________________________________________________________________
140 {
141  return m_Detector;
142 }
143 
145 {
146  // all in cm
147  set_default_double_param("light_balance_inner_corr", NAN);
148  set_default_double_param("light_balance_inner_radius", NAN);
149  set_default_double_param("light_balance_outer_corr", NAN);
150  set_default_double_param("light_balance_outer_radius", NAN);
151  set_default_double_param("place_x", 0.);
152  set_default_double_param("place_y", 0.);
153  set_default_double_param("place_z", 0.);
154  set_default_double_param("rot_x", 0.);
155  set_default_double_param("rot_y", 0.);
156  set_default_double_param("rot_z", 0.);
157  set_default_double_param("steplimits", NAN);
158 
159  set_default_int_param("hi_eta", 1);
160  set_default_int_param("light_scint_model", 1);
162  set_default_int_param("scintillators", 1);
163 
164  set_default_string_param("material", "Steel_A36");
165 }
166 
167 void PHG4Prototype3InnerHcalSubsystem::SetLightCorrection(const double inner_radius, const double inner_corr, const double outer_radius, const double outer_corr)
168 {
169  set_double_param("light_balance_inner_corr", inner_corr);
170  set_double_param("light_balance_inner_radius", inner_radius);
171  set_double_param("light_balance_outer_corr", outer_corr);
172  set_double_param("light_balance_outer_radius", outer_radius);
173  return;
174 }