ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4ZDCSubsystem.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4ZDCSubsystem.cc
1 #include "PHG4ZDCSubsystem.h"
2 
3 #include "PHG4ZDCDetector.h"
4 #include "PHG4ZDCDisplayAction.h"
6 
7 #include <phparameter/PHParameters.h>
8 
9 #include <g4main/PHG4DisplayAction.h> // for PHG4DisplayAction
11 #include <g4main/PHG4SteppingAction.h> // for PHG4SteppingAction
12 
13 #include <phool/PHCompositeNode.h>
14 #include <phool/PHIODataNode.h> // for PHIODataNode
15 #include <phool/PHNode.h> // for PHNode
16 #include <phool/PHNodeIterator.h> // for PHNodeIterator
17 #include <phool/PHObject.h> // for PHObject
18 #include <phool/getClass.h>
19 
20 #include <fstream>
21 #include <set> // for set
22 #include <sstream>
23 
24 class PHG4Detector;
25 
26 using namespace std;
27 
28 //_______________________________________________________________________
29 PHG4ZDCSubsystem::PHG4ZDCSubsystem(const std::string& name, const int lyr)
30  : PHG4DetectorSubsystem(name, lyr)
31 {
33 }
34 
35 //_______________________________________________________________________
37 {
38  delete m_DisplayAction;
39 }
40 
41 //_______________________________________________________________________
43 {
44  PHNodeIterator iter(topNode);
45  PHCompositeNode* dstNode = dynamic_cast<PHCompositeNode*>(iter.findFirst("PHCompositeNode", "DST"));
46 
47  // create display settings before detector
49  // create detector
50  m_Detector = new PHG4ZDCDetector(this, topNode, GetParams(), Name(), GetLayer());
51 
55  set<string> nodes;
56 
57  if (GetParams()->get_int_param("active"))
58  {
59  PHNodeIterator dstIter(dstNode);
60  PHCompositeNode* DetNode = dstNode;
61  if (SuperDetector() != "NONE" && !SuperDetector().empty())
62  {
63  PHNodeIterator iter_dst(dstNode);
64  DetNode = dynamic_cast<PHCompositeNode*>(iter_dst.findFirst("PHCompositeNode", SuperDetector()));
65 
66  if (!DetNode)
67  {
68  DetNode = new PHCompositeNode(SuperDetector());
69  dstNode->addNode(DetNode);
70  }
71  }
72  // create hit output nodes
73  std::string detector_suffix = SuperDetector();
74  if (detector_suffix == "NONE" || detector_suffix.empty())
75  {
76  detector_suffix = Name();
77  }
78 
79  m_HitNodeName = "G4HIT_" + detector_suffix;
80  nodes.insert(m_HitNodeName);
81  m_AbsorberNodeName = "G4HIT_ABSORBER_" + detector_suffix;
82  if (GetParams()->get_int_param("absorberactive"))
83  {
84  nodes.insert(m_AbsorberNodeName);
85  }
86  m_SupportNodeName = "G4HIT_SUPPORT_" + detector_suffix;
87  if (GetParams()->get_int_param("supportactive"))
88  {
89  nodes.insert(m_SupportNodeName);
90  }
91 
92  for (auto nodename : nodes)
93  {
94  PHG4HitContainer* g4_hits = findNode::getClass<PHG4HitContainer>(topNode, nodename);
95  if (!g4_hits)
96  {
97  g4_hits = new PHG4HitContainer(nodename);
98  DetNode->addNode(new PHIODataNode<PHObject>(g4_hits, nodename, "PHObject"));
99  }
100  }
101  // create stepping action
106  }
107  else if (GetParams()->get_int_param("blackhole"))
108  {
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_double_param("place_x", 0.);
135  set_default_double_param("place_y", 0.);
136  set_default_double_param("place_z", 1843.0);
137  set_default_double_param("rot_x", 0.);
138  set_default_double_param("rot_y", 0.);
139  set_default_double_param("rot_z", 0.);
140  return;
141 }