EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4ForwardEcalSubsystem.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4ForwardEcalSubsystem.cc
6 
7 #include <phparameter/PHParameters.h>
8 
9 #include <g4main/PHG4DisplayAction.h> // for PHG4DisplayAction
11 #include <g4main/PHG4SteppingAction.h> // for PHG4SteppingAction
12 #include <g4main/PHG4Utils.h>
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 <TSystem.h>
22 
23 #include <cstdlib> // for getenv
24 #include <set> // for set
25 #include <sstream>
26 
27 class PHG4Detector;
28 
29 //_______________________________________________________________________
30 PHG4ForwardEcalSubsystem::PHG4ForwardEcalSubsystem(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  // create detector
52  {
53  m_Detector = new PHG4EICForwardEcalDetector(this, topNode, GetParams(), Name());
54  }
55  else
56  {
57  m_Detector = new PHG4ForwardEcalDetector(this, topNode, GetParams(), Name());
58  }
60 
64  std::set<std::string> nodes;
65  if (GetParams()->get_int_param("active"))
66  {
67  PHNodeIterator dstIter(dstNode);
68  PHCompositeNode* DetNode = dynamic_cast<PHCompositeNode*>(dstIter.findFirst("PHCompositeNode", SuperDetector()));
69  if (!DetNode)
70  {
71  DetNode = new PHCompositeNode(SuperDetector());
72  dstNode->addNode(DetNode);
73  }
74  std::string nodename;
75  if (SuperDetector() != "NONE")
76  {
77  nodename = "G4HIT_" + SuperDetector();
78  }
79  else
80  {
81  nodename = "G4HIT_" + Name();
82  }
83  nodes.insert(nodename);
84 
85  if (GetParams()->get_int_param("absorberactive"))
86  {
87  if (SuperDetector() != "NONE")
88  {
89  nodename = "G4HIT_ABSORBER_" + SuperDetector();
90  }
91  else
92  {
93  nodename = "G4HIT_ABSORBER_" + Name();
94  }
95  nodes.insert(nodename);
96  }
97 
98  for (auto thisnode : nodes)
99  {
100  PHG4HitContainer* g4_hits = findNode::getClass<PHG4HitContainer>(topNode, thisnode);
101  if (!g4_hits)
102  {
103  g4_hits = new PHG4HitContainer(thisnode);
104  DetNode->addNode(new PHIODataNode<PHObject>(g4_hits, thisnode, "PHObject"));
105  }
106  }
107  // create stepping action
109  }
110 
111  return 0;
112 }
113 
114 //_______________________________________________________________________
116 {
117  // pass top node to stepping action so that it gets
118  // relevant nodes needed internally
119  if (m_SteppingAction)
120  {
122  }
123  return 0;
124 }
125 
126 //_______________________________________________________________________
128 {
129  return m_Detector;
130 }
131 
133 {
134  set_default_int_param("nFibers", 0);
135  set_default_double_param("fiber_diam", 0.);
136  set_default_double_param("width_coating", 0.);
137  set_default_double_param("tower_readout_dz", 4.0);
138  set_default_double_param("clamp_plate_width", 0.0);
139  set_default_double_param("place_x", 0.);
140  set_default_double_param("place_y", 0.);
141  set_default_double_param("place_z", -108.);
142  set_default_double_param("rMin1", 2.2);
143  set_default_double_param("rMax1", 65.6);
144  set_default_double_param("rMin2", 2.6);
145  set_default_double_param("rMax2", 77.5);
146  set_default_double_param("rot_x", 0.);
147  set_default_double_param("rot_y", 180.);
148  set_default_double_param("rot_z", 0.);
149  std::ostringstream mappingfilename;
150  const char* calibroot = getenv("CALIBRATIONROOT");
151  if (calibroot)
152  {
153  mappingfilename << calibroot;
154  }
155  else
156  {
157  std::cout << "no CALIBRATIONROOT environment variable" << std::endl;
158  gSystem->Exit(1);
159  }
160  mappingfilename << "/ForwardEcal/mapping/towerMap_FEMC_fsPHENIX_v004.txt";
161  set_default_string_param("mapping_file", mappingfilename.str());
162  set_default_string_param("mapping_file_md5", PHG4Utils::md5sum(mappingfilename.str()));
163  return;
164 }
165 
167 {
168  set_string_param("mapping_file", filename);
169  set_string_param("mapping_file_md5", PHG4Utils::md5sum(get_string_param("mapping_file")));
170 }