EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4OuterHcalSubsystem.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4OuterHcalSubsystem.cc
2 
6 #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> // for set
26 #include <sstream>
27 
28 class PHG4Detector;
29 
30 using namespace std;
31 
32 //_______________________________________________________________________
33 PHG4OuterHcalSubsystem::PHG4OuterHcalSubsystem( 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 //_______________________________________________________________________
49 int
51 {
52  PHNodeIterator iter( topNode );
53  PHCompositeNode *dstNode = dynamic_cast<PHCompositeNode*>(iter.findFirst("PHCompositeNode", "DST" ));
54 
55  // create display settings before detector
57 
58  // create detector
59  m_Detector = new PHG4OuterHcalDetector(this, topNode, GetParams(), Name());
62  set<string> nodes;
63  if (GetParams()->get_int_param("active"))
64  {
65  PHNodeIterator dstIter( dstNode );
66  PHCompositeNode *DetNode = dynamic_cast<PHCompositeNode*>(dstIter.findFirst("PHCompositeNode",SuperDetector()));
67  if (! DetNode)
68  {
69  DetNode = new PHCompositeNode(SuperDetector());
70  dstNode->addNode(DetNode);
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  // create stepping action
107  }
108  else
109  {
110  if (GetParams()->get_int_param("blackhole"))
111  {
114  }
115  }
116 
117  return 0;
118 }
119 
120 //_______________________________________________________________________
121 int
123 {
124  // pass top node to stepping action so that it gets
125  // relevant nodes needed internally
126  if (m_SteppingAction)
127  {
129  }
130  return 0;
131 }
132 
133 void
134 PHG4OuterHcalSubsystem::Print(const string &what) const
135 {
136  cout << "Outer Hcal Parameters: " << endl;
137  GetParams()->Print();
138  if (m_Detector)
139  {
140  m_Detector->Print(what);
141  }
142  return;
143 }
144 
145 
146 //_______________________________________________________________________
148 {
149  return m_Detector;
150 }
151 
152 void
153 PHG4OuterHcalSubsystem::SetLightCorrection(const double inner_radius, const double inner_corr,const double outer_radius, const double outer_corr)
154 {
155  set_double_param("light_balance_inner_corr", inner_corr);
156  set_double_param("light_balance_inner_radius", inner_radius);
157  set_double_param("light_balance_outer_corr", outer_corr);
158  set_double_param("light_balance_outer_radius", outer_radius);
159  return;
160 }
161 
162 void
164 {
165  set_default_double_param("inner_radius", 183.3);
166  set_default_double_param("light_balance_inner_corr", NAN);
167  set_default_double_param("light_balance_inner_radius", NAN);
168  set_default_double_param("light_balance_outer_corr", NAN);
169  set_default_double_param("light_balance_outer_radius", NAN);
170 // some math issue in the code does not subtract the magnet cutout correctly
171 // (maybe some factor of 2 in a G4 volume creation)
172 // The engineering drawing values are:
173 // set_default_double_param("magnet_cutout_radius", 195.31);
174 // set_default_double_param("magnet_cutout_scinti_radius", 195.96);
175 // seting this to these values results in the correct edges
176 // (verified by looking at the G4 hit coordinates of the inner edges)
177  set_default_double_param("magnet_cutout_radius", 195.72);
178  set_default_double_param("magnet_cutout_scinti_radius", 197.04);
179  set_default_double_param("outer_radius", 264.71);
180  set_default_double_param("place_x", 0.);
181  set_default_double_param("place_y", 0.);
182  set_default_double_param("place_z", 0.);
183  set_default_double_param("rot_x", 0.);
184  set_default_double_param("rot_y", 0.);
185  set_default_double_param("rot_z", 0.);
186  set_default_double_param("scinti_eta_coverage", 1.1);
187  set_default_double_param("scinti_gap", 0.85);
188  set_default_double_param("scinti_gap_neighbor", 0.1);
189  set_default_double_param("scinti_inner_radius",183.89);
190 // some math issue in the code subtracts 0.1mm+ so the scintillator
191 // does not end at 263.27 as per drawing but at 263.26
192 // adding 0.125mm compensates for this (so 263.2825 gives the desired 263.27
193  set_default_double_param("scinti_outer_radius",263.2825);
194  set_default_double_param("scinti_tile_thickness", 0.7);
195  set_default_double_param("size_z", 304.91 * 2);
196  set_default_double_param("steplimits", NAN);
197  set_default_double_param("tilt_angle", -11.23); // engineering drawing
198 // corresponds very closely to 4 crossinge (-11.7826 deg)
199 
200  set_default_int_param("field_check", 0);
201  set_default_int_param("light_scint_model", 1);
202  set_default_int_param("magnet_cutout_first_scinti", 8); // tile start at 0, drawing tile starts at 1
203 
204 // if ncross is set (and tilt_angle is NAN) tilt_angle is calculated
205 // from number of crossings
206  set_default_int_param("ncross", 0);
207  set_default_int_param("n_towers", 64);
209  set_default_int_param("n_scinti_tiles", 12);
210 
211  set_default_string_param("material", "Steel_1006");
212 }