ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4LFHcalSubsystem.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4LFHcalSubsystem.cc
1 #include "PHG4LFHcalSubsystem.h"
2 
3 #include "PHG4LFHcalDetector.h"
6 
7 #include <phparameter/PHParameters.h>
8 
9 #include <g4main/PHG4DisplayAction.h> // for PHG4DisplayAction
11 #include <g4main/PHG4SteppingAction.h> // for PHG4SteppingAction
12 #include <g4main/PHG4Subsystem.h> // for PHG4Subsystem
13 #include <g4main/PHG4Utils.h>
14 
15 #include <phool/PHCompositeNode.h>
16 #include <phool/PHIODataNode.h> // for PHIODataNode
17 #include <phool/PHNode.h> // for PHNode
18 #include <phool/PHNodeIterator.h> // for PHNodeIterator
19 #include <phool/PHObject.h> // for PHObject
20 #include <phool/getClass.h>
21 
22 #include <TSystem.h>
23 
24 #include <set> // for set
25 #include <sstream>
26 
27 class PHG4Detector;
28 
29 //_______________________________________________________________________
30 PHG4LFHcalSubsystem::PHG4LFHcalSubsystem(const std::string& name, const int lyr)
31  : PHG4DetectorSubsystem(name, lyr)
32 {
34 }
35 
36 //_______________________________________________________________________
38 {
39  delete m_DisplayAction;
40 }
41 
42 //_______________________________________________________________________
44 {
45  PHNodeIterator iter(topNode);
46  PHCompositeNode* dstNode = dynamic_cast<PHCompositeNode*>(iter.findFirst("PHCompositeNode", "DST"));
47 
48  // create display settings before detector
50 
51  // create detector
52  m_Detector = new PHG4LFHcalDetector(this, topNode, GetParams(), Name());
57 
58  std::set<std::string> nodes;
59  if (GetParams()->get_int_param("active"))
60  {
61  PHNodeIterator dstIter(dstNode);
62  PHCompositeNode* DetNode = dstNode;
63  if (SuperDetector() != "NONE")
64  {
65  DetNode = dynamic_cast<PHCompositeNode*>(dstIter.findFirst("PHCompositeNode", SuperDetector()));
66  if (!DetNode)
67  {
68  DetNode = new PHCompositeNode(SuperDetector());
69  dstNode->addNode(DetNode);
70  }
71  }
72  // create hit output node
73  std::string nodename;
74  if (SuperDetector() != "NONE")
75  {
76  nodename = "G4HIT_" + SuperDetector();
77  }
78  else
79  {
80  nodename = "G4HIT_" + Name();
81  }
82  nodes.insert(nodename);
83  if (GetParams()->get_int_param("absorberactive"))
84  {
85  if (SuperDetector() != "NONE")
86  {
87  nodename = "G4HIT_ABSORBER_" + SuperDetector();
88  }
89  else
90  {
91  nodename = "G4HIT_ABSORBER_" + Name();
92  }
93  nodes.insert(nodename);
94  }
95  for (auto thisnode : nodes)
96  {
97  PHG4HitContainer* g4_hits = findNode::getClass<PHG4HitContainer>(topNode, thisnode);
98  if (!g4_hits)
99  {
100  g4_hits = new PHG4HitContainer(thisnode);
101  DetNode->addNode(new PHIODataNode<PHObject>(g4_hits, thisnode, "PHObject"));
102  }
103  }
104  // create stepping action
106  // m_SteppingAction = new PHG4LFHcalSteppingAction(m_Detector, m_Detector->getParamsDet());
107  }
108 
109  return 0;
110 }
111 
112 //_______________________________________________________________________
114 {
115  // pass top node to stepping action so that it gets
116  // relevant nodes needed internally
117  if (m_SteppingAction)
118  {
120  }
121  return 0;
122 }
123 
124 //_______________________________________________________________________
126 {
127  return m_Detector;
128 }
129 
131 {
132  set_default_double_param("place_x", 0.);
133  set_default_double_param("place_y", 0.);
134  set_default_double_param("place_z", 400.);
135  set_default_double_param("tower_dx", 5.);
136  set_default_double_param("tower_dy", 5.);
137  set_default_double_param("tower_dz", 100.);
138  set_default_double_param("dz", 100.);
139  set_default_double_param("rMin1", 5.);
140  set_default_double_param("rMax1", 262.);
141  set_default_double_param("rMin2", 5.);
142  set_default_double_param("rMax2", 336.9);
143  set_default_double_param("wls_dw", 0.125);
144  set_default_double_param("rot_x", 0.);
145  set_default_double_param("rot_y", 0.);
146  set_default_double_param("rot_z", 0.);
147  set_default_double_param("xoffset", 0.);
148  set_default_double_param("yoffset", 0.);
149  set_default_double_param("thickness_absorber", 1.6);
150  set_default_double_param("thickness_scintillator", 0.4);
151  set_default_int_param("nlayerspertowerseg", 10);
152  set_default_int_param("usetailcatcher", 0);
153  set_default_double_param("frame_width", 0.);
154  set_default_double_param("width_coating", 0.);
155  set_default_double_param("zdepthcatcheroffset", 1000000.);
156  set_default_int_param("nLayerOffsetTailcatcher", 0);
157  set_default_int_param("embed_fiber", 0);
158 
159  std::ostringstream mappingfilename;
160  const char* calibroot = getenv("CALIBRATIONROOT");
161  if (calibroot)
162  {
163  mappingfilename << calibroot;
164  }
165  else
166  {
167  std::cout << "no CALIBRATIONROOT environment variable" << std::endl;
168  gSystem->Exit(1);
169  }
170 
171  mappingfilename << "/LFHcal/mapping/towerMap_LFHCAL_2x.txt";
172  set_default_string_param("mapping_file", mappingfilename.str());
173  set_default_string_param("mapping_file_md5", PHG4Utils::md5sum(mappingfilename.str()));
174  set_default_string_param("scintillator", "G4_POLYSTYRENE");
175  set_default_string_param("absorber", "G4_Fe");
176  set_default_string_param("absorber_W", "G4_W");
177 
178  return;
179 }
180 
182 {
183  set_string_param("mapping_file", filename);
184  set_string_param("mapping_file_md5", PHG4Utils::md5sum(get_string_param("mapping_file")));
185 }