ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4InnerHcalSubsystem.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4InnerHcalSubsystem.cc
2 
3 #include "PHG4HcalDefs.h"
7 
8 #include <phparameter/PHParameters.h>
9 
10 #include <g4main/PHG4DisplayAction.h> // for PHG4DisplayAction
12 #include <g4main/PHG4SteppingAction.h> // for PHG4SteppingAction
13 
14 #include <phool/PHCompositeNode.h>
15 #include <phool/PHIODataNode.h> // for PHIODataNode
16 #include <phool/PHNode.h> // for PHNode
17 #include <phool/PHNodeIterator.h> // for PHNodeIterator
18 #include <phool/PHObject.h> // for PHObject
19 #include <phool/getClass.h>
20 
21 #include <boost/foreach.hpp>
22 
23 #include <cmath> // for NAN
24 #include <iostream> // for operator<<, basic_ostream
25 #include <set>
26 #include <sstream>
27 
28 class PHG4Detector;
29 
30 using namespace std;
31 
32 //_______________________________________________________________________
33 PHG4InnerHcalSubsystem::PHG4InnerHcalSubsystem(const std::string &name, const int lyr)
34  : PHG4DetectorSubsystem(name, lyr)
35  , m_Detector(nullptr)
36  , m_SteppingAction(nullptr)
37  , m_DisplayAction(nullptr)
38 {
40 }
41 
42 //_______________________________________________________________________
44 {
45  delete m_DisplayAction;
46 }
47 
48 //_______________________________________________________________________
50 {
51  PHNodeIterator iter(topNode);
52  PHCompositeNode *dstNode = dynamic_cast<PHCompositeNode *>(iter.findFirst("PHCompositeNode", "DST"));
53 
54  // create display settings before detector
56 
57  // create detector
58  m_Detector = new PHG4InnerHcalDetector(this, topNode, GetParams(), Name());
61  set<string> nodes;
62  if (GetParams()->get_int_param("active"))
63  {
64  PHNodeIterator dstIter(dstNode);
65  PHCompositeNode *DetNode = dynamic_cast<PHCompositeNode *>(dstIter.findFirst("PHCompositeNode", SuperDetector()));
66  if (!DetNode)
67  {
68  DetNode = new PHCompositeNode(SuperDetector());
69  dstNode->addNode(DetNode);
70  }
71 
72  ostringstream nodename;
73  if (SuperDetector() != "NONE")
74  {
75  nodename << "G4HIT_" << SuperDetector();
76  }
77  else
78  {
79  nodename << "G4HIT_" << Name();
80  }
81  nodes.insert(nodename.str());
82  if (GetParams()->get_int_param("absorberactive"))
83  {
84  nodename.str("");
85  if (SuperDetector() != "NONE")
86  {
87  nodename << "G4HIT_ABSORBER_" << SuperDetector();
88  }
89  else
90  {
91  nodename << "G4HIT_ABSORBER_" << Name();
92  }
93  nodes.insert(nodename.str());
94  }
95  BOOST_FOREACH (string node, nodes)
96  {
97  PHG4HitContainer *g4_hits = findNode::getClass<PHG4HitContainer>(topNode, node.c_str());
98  if (!g4_hits)
99  {
100  g4_hits = new PHG4HitContainer(node);
101  DetNode->addNode(new PHIODataNode<PHObject>(g4_hits, node.c_str(), "PHObject"));
102  }
103  }
104 
105  // create stepping action
107  }
108  else
109  {
110  // if this is a black hole it does not have to be active
111  if (GetParams()->get_int_param("blackhole"))
112  {
114  }
115  }
116  return 0;
117 }
118 
119 //_______________________________________________________________________
121 {
122  // pass top node to stepping action so that it gets
123  // relevant nodes needed internally
124  if (m_SteppingAction)
125  {
127  }
128  return 0;
129 }
130 
131 void PHG4InnerHcalSubsystem::Print(const string &what) const
132 {
133  cout << Name() << " Parameters: " << endl;
134  GetParams()->Print();
135  if (m_Detector)
136  {
137  m_Detector->Print(what);
138  }
139  if (m_SteppingAction)
140  {
141  m_SteppingAction->Print(what);
142  }
143 
144  return;
145 }
146 
147 //_______________________________________________________________________
149 {
150  return m_Detector;
151 }
152 
154 {
156  set_default_double_param("light_balance_inner_corr", NAN);
157  set_default_double_param("light_balance_inner_radius", NAN);
158  set_default_double_param("light_balance_outer_corr", NAN);
159  set_default_double_param("light_balance_outer_radius", NAN);
161  set_default_double_param("place_x", 0.);
162  set_default_double_param("place_y", 0.);
163  set_default_double_param("place_z", 0.);
164  set_default_double_param("rot_x", 0.);
165  set_default_double_param("rot_y", 0.);
166  set_default_double_param("rot_z", 0.);
167  set_default_double_param("scinti_eta_coverage", 1.1);
168  set_default_double_param("scinti_eta_coverage_pos", 1.1);
169  set_default_double_param("scinti_eta_coverage_neg", 1.1);
170  set_default_double_param("scinti_gap_neighbor", 0.1);
171  set_default_double_param("scinti_inner_gap", 0.85);
172  set_default_double_param("scinti_outer_gap", 1.22 * (5.0 / 4.0));
173  // some math issue in the code subtracts 0.4mm so the scintillator
174  // does not end at 133.09 as per drawing but at 133.05
175  // adding 0.4mm compensates for this (so 133.13 gives the desired 133.09
176  set_default_double_param("scinti_outer_radius", 133.13);
177  set_default_double_param("scinti_tile_thickness", 0.7);
178  set_default_double_param("size_z", 175.94 * 2);
179  set_default_double_param("steplimits", NAN);
180  set_default_double_param("tilt_angle", 36.15); // engineering drawing
181  // corresponds very closely to 4 crossinge (35.5497 deg)
182 
183  set_default_int_param("light_scint_model", 1);
184  // if ncross is set (and tilt_angle is NAN) tilt_angle is calculated
185  // from number of crossings
186  set_default_int_param("ncross", 0);
192 
193  set_default_string_param("material", "G4_Al");
194 }
195 
196 void PHG4InnerHcalSubsystem::SetLightCorrection(const double inner_radius, const double inner_corr, const double outer_radius, const double outer_corr)
197 {
198  set_double_param("light_balance_inner_corr", inner_corr);
199  set_double_param("light_balance_inner_radius", inner_radius);
200  set_double_param("light_balance_outer_corr", outer_corr);
201  set_double_param("light_balance_outer_radius", outer_radius);
202  return;
203 }