Analysis Software
Documentation for sPHENIX simulation 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 //_______________________________________________________________________
28  : PHG4DetectorSubsystem(name, lyr)
29 {
31 }
32 
33 //_______________________________________________________________________
35 {
36  delete m_DisplayAction;
37 }
38 
39 //_______________________________________________________________________
41 {
42  PHNodeIterator iter(topNode);
43  PHCompositeNode* dstNode = dynamic_cast<PHCompositeNode*>(iter.findFirst("PHCompositeNode", "DST"));
44 
45  // create display settings before detector
47  // create detector
48  m_Detector = new PHG4ZDCDetector(this, topNode, GetParams(), Name(), GetLayer());
49 
53 
54  if (GetParams()->get_int_param("active"))
55  {
56  std::set<std::string> nodes;
57  PHNodeIterator dstIter(dstNode);
58  PHCompositeNode* DetNode = dstNode;
59  if (SuperDetector() != "NONE" && !SuperDetector().empty())
60  {
61  PHNodeIterator iter_dst(dstNode);
62  DetNode = dynamic_cast<PHCompositeNode*>(iter_dst.findFirst("PHCompositeNode", SuperDetector()));
63 
64  if (!DetNode)
65  {
66  DetNode = new PHCompositeNode(SuperDetector());
67  dstNode->addNode(DetNode);
68  }
69  }
70  // create hit output nodes
71  std::string detector_suffix = SuperDetector();
72  if (detector_suffix == "NONE" || detector_suffix.empty())
73  {
74  detector_suffix = Name();
75  }
76 
77  m_HitNodeName = "G4HIT_" + detector_suffix;
78  nodes.insert(m_HitNodeName);
79  m_AbsorberNodeName = "G4HIT_ABSORBER_" + detector_suffix;
80  if (GetParams()->get_int_param("absorberactive"))
81  {
82  nodes.insert(m_AbsorberNodeName);
83  }
84  m_SupportNodeName = "G4HIT_SUPPORT_" + detector_suffix;
85  if (GetParams()->get_int_param("supportactive"))
86  {
87  nodes.insert(m_SupportNodeName);
88  }
89 
90  for (const auto& nodename : nodes)
91  {
92  PHG4HitContainer* g4_hits = findNode::getClass<PHG4HitContainer>(topNode, nodename);
93  if (!g4_hits)
94  {
95  g4_hits = new PHG4HitContainer(nodename);
96  DetNode->addNode(new PHIODataNode<PHObject>(g4_hits, nodename, "PHObject"));
97  }
98  }
99  // create stepping action
104  }
105  else if (GetParams()->get_int_param("blackhole"))
106  {
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", 1843.0);
135  set_default_double_param("rot_x", 0.);
136  set_default_double_param("rot_y", 0.);
137  set_default_double_param("rot_z", 0.);
138  return;
139 }