Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4Prototype2OuterHcalSubsystem.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4Prototype2OuterHcalSubsystem.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 PHG4Prototype2OuterHcalDetector(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 PHG4Prototype2OuterHcalSubsystem::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  return;
129 }
130 
131 //_______________________________________________________________________
133 {
134  return m_Detector;
135 }
136 
138 {
139  // all in cm
140  set_default_double_param("light_balance_inner_corr", NAN);
141  set_default_double_param("light_balance_inner_radius", NAN);
142  set_default_double_param("light_balance_outer_corr", NAN);
143  set_default_double_param("light_balance_outer_radius", NAN);
144  set_default_double_param("place_x", 0.);
145  set_default_double_param("place_y", 0.);
146  set_default_double_param("place_z", 0.);
147  set_default_double_param("rot_x", 0.);
148  set_default_double_param("rot_y", 0.);
149  set_default_double_param("rot_z", 0.);
150  set_default_double_param("steplimits", NAN);
151 
152  set_default_int_param("hi_eta", 0);
153  set_default_int_param("light_scint_model", 1);
155 
156  set_default_string_param("material", "SS310");
157 }
158 
159 void PHG4Prototype2OuterHcalSubsystem::SetLightCorrection(const double inner_radius, const double inner_corr, const double outer_radius, const double outer_corr)
160 {
161  set_double_param("light_balance_inner_corr", inner_corr);
162  set_double_param("light_balance_inner_radius", inner_radius);
163  set_double_param("light_balance_outer_corr", outer_corr);
164  set_double_param("light_balance_outer_radius", outer_radius);
165  return;
166 }