ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4LBLVtxSubsystem.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4LBLVtxSubsystem.cc
1 #include "G4LBLVtxSubsystem.h"
2 
3 #include "G4LBLVtxDetector.h"
6 
7 #include <phparameter/PHParameters.h>
8 
9 #include <g4detectors/PHG4DetectorSubsystem.h> // for PHG4DetectorSubsystem
10 
11 #include <g4main/PHG4DisplayAction.h> // for PHG4DisplayAction
13 #include <g4main/PHG4SteppingAction.h> // for PHG4SteppingAction
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 <boost/foreach.hpp>
23 
24 #include <iostream> // for operator<<, basic_ostream, endl
25 #include <set> // for set
26 
27 using namespace std;
28 
30  : PHG4DetectorSubsystem(name, 0)
31  , m_Detector(nullptr)
32  , m_SteppingAction(nullptr)
33  , m_DisplayAction(nullptr)
34 {
36 }
37 
39 {
40  delete m_DisplayAction;
41 }
42 
43 //_______________________________________________________________________
45 {
46  PHNodeIterator iter(topNode);
47  PHCompositeNode *dstNode = dynamic_cast<PHCompositeNode *>(iter.findFirst("PHCompositeNode", "DST"));
48 
49  // create display settings before detector
51 
52  // create detector
53  m_Detector = new G4LBLVtxDetector(this, topNode, Name(), GetParams());
56 
57  set<string> nodes;
58  if (GetParams()->get_int_param("active"))
59  {
60  PHNodeIterator dstIter(dstNode);
61  PHCompositeNode *DetNode = dynamic_cast<PHCompositeNode *>(dstIter.findFirst("PHCompositeNode", SuperDetector()));
62  if (!DetNode)
63  {
64  DetNode = new PHCompositeNode(SuperDetector());
65  dstNode->addNode(DetNode);
66  }
67 
68  ostringstream nodename;
69  if (SuperDetector() != "NONE")
70  {
71  nodename << "G4HIT_" << SuperDetector();
72  }
73  else
74  {
75  nodename << "G4HIT_" << Name();
76  }
77  nodes.insert(nodename.str());
78  if (GetParams()->get_int_param("absorberactive"))
79  {
80  nodename.str("");
81  if (SuperDetector() != "NONE")
82  {
83  nodename << "G4HIT_ABSORBER_" << SuperDetector();
84  }
85  else
86  {
87  nodename << "G4HIT_ABSORBER_" << Name();
88  }
89  nodes.insert(nodename.str());
90  }
91  BOOST_FOREACH (string node, nodes)
92  {
93  PHG4HitContainer *g4_hits = findNode::getClass<PHG4HitContainer>(topNode, node);
94  if (!g4_hits)
95  {
96  g4_hits = new PHG4HitContainer(node);
97  DetNode->addNode(new PHIODataNode<PHObject>(g4_hits, node, "PHObject"));
98  }
99  }
100 
101  // create stepping action
103  }
104  else
105  {
106  // if this is a black hole it does not have to be active
107  if (GetParams()->get_int_param("blackhole"))
108  {
110  }
111  }
112  return 0;
113 }
114 
115 //_______________________________________________________________________
117 {
118  // pass top node to stepping action so that it gets
119  // relevant nodes needed internally
120  if (m_SteppingAction)
121  {
123  }
124  return 0;
125 }
126 
127 void G4LBLVtxSubsystem::Print(const string &what) const
128 {
129  cout << Name() << " Parameters: " << endl;
130  GetParams()->Print();
131  if (m_Detector)
132  {
133  m_Detector->Print(what);
134  }
135 
136  return;
137 }
138 
139 //_______________________________________________________________________
141 {
142  return m_Detector;
143 }
144 
146 {
147  set_default_double_param("place_x", 0.);
148  set_default_double_param("place_y", 0.);
149  set_default_double_param("place_z", 0.);
150  set_default_double_param("rot_x", 0.);
151  set_default_double_param("rot_y", 0.);
152  set_default_double_param("rot_z", 0.);
153 
154  set_default_string_param("GDMPath", "DefaultParameters-InvalidPath");
155  set_default_string_param("TopVolName", "DefaultParameters-InvalidVol");
156 }