ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4BackwardHcalSubsystem.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4BackwardHcalSubsystem.cc
2 
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 //_______________________________________________________________________
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
51  m_Detector = new PHG4BackwardHcalDetector(this, topNode, GetParams(), Name());
55 
56  std::set<std::string> nodes;
57  if (GetParams()->get_int_param("active"))
58  {
59  PHNodeIterator dstIter(dstNode);
60  PHCompositeNode* DetNode = dstNode;
61  if (SuperDetector() != "NONE")
62  {
63  DetNode = dynamic_cast<PHCompositeNode*>(dstIter.findFirst("PHCompositeNode", SuperDetector()));
64  if (!DetNode)
65  {
66  DetNode = new PHCompositeNode(SuperDetector());
67  dstNode->addNode(DetNode);
68  }
69  }
70  // create hit output node
71  std::string nodename;
72  if (SuperDetector() != "NONE")
73  {
74  nodename = "G4HIT_" + SuperDetector();
75  }
76  else
77  {
78  nodename = "G4HIT_" + Name();
79  }
80  nodes.insert(nodename);
81  if (GetParams()->get_int_param("absorberactive"))
82  {
83  if (SuperDetector() != "NONE")
84  {
85  nodename = "G4HIT_ABSORBER_" + SuperDetector();
86  }
87  else
88  {
89  nodename = "G4HIT_ABSORBER_" + Name();
90  }
91  nodes.insert(nodename);
92  }
93  for (auto thisnode : nodes)
94  {
95  PHG4HitContainer* g4_hits = findNode::getClass<PHG4HitContainer>(topNode, thisnode);
96  if (!g4_hits)
97  {
98  g4_hits = new PHG4HitContainer(thisnode);
99  DetNode->addNode(new PHIODataNode<PHObject>(g4_hits, thisnode, "PHObject"));
100  }
101  }
102  // create stepping action
104  }
105 
106  return 0;
107 }
108 
109 //_______________________________________________________________________
111 {
112  // pass top node to stepping action so that it gets
113  // relevant nodes needed internally
114  if (m_SteppingAction)
115  {
117  }
118  return 0;
119 }
120 
121 //_______________________________________________________________________
123 {
124  return m_Detector;
125 }
126 
128 {
129  set_default_double_param("place_x", 0.);
130  set_default_double_param("place_y", 0.);
131  set_default_double_param("place_z", 400.);
132  set_default_double_param("tower_dx", 10.);
133  set_default_double_param("tower_dy", 10.);
134  set_default_double_param("tower_dz", 100.);
135  set_default_double_param("dz", 100.);
136  set_default_double_param("rMin1", 5.);
137  set_default_double_param("rMax1", 262.);
138  set_default_double_param("rMin2", 5.);
139  set_default_double_param("rMax2", 336.9);
140  set_default_double_param("wls_dw", 0.3);
141  set_default_double_param("support_dw", 0.2);
142  set_default_double_param("rot_x", 0.);
143  set_default_double_param("rot_y", 0.);
144  set_default_double_param("rot_z", 0.);
145  set_default_double_param("thickness_absorber", 2.);
146  set_default_double_param("thickness_scintillator", 0.231);
147 
148  std::ostringstream mappingfilename;
149  const char* calibroot = getenv("CALIBRATIONROOT");
150  if (calibroot)
151  {
152  mappingfilename << calibroot;
153  }
154  else
155  {
156  std::cout << "no CALIBRATIONROOT environment variable" << std::endl;
157  gSystem->Exit(1);
158  }
159 
160  mappingfilename << "/BackwardHcal/mapping/towerMap_EHCAL_default.txt";
161  set_default_string_param("mapping_file", mappingfilename.str());
162  set_default_string_param("mapping_file_md5", PHG4Utils::md5sum(mappingfilename.str()));
163  set_default_string_param("scintillator", "G4_POLYSTYRENE");
164  set_default_string_param("absorber", "G4_Fe");
165  set_default_string_param("support", "G4_Fe");
166 
167  return;
168 }
169 
171 {
172  set_string_param("mapping_file", filename);
173  set_string_param("mapping_file_md5", PHG4Utils::md5sum(get_string_param("mapping_file")));
174 }