Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4Example01Subsystem.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4Example01Subsystem.cc
1 #include "G4Example01Subsystem.h"
2 #include "G4Example01Detector.h"
4 
6 #include <g4main/PHG4SteppingAction.h> // for PHG4SteppingAction
7 
9 #include <phool/PHIODataNode.h> // for PHIODataNode
10 #include <phool/PHNode.h> // for PHNode
11 #include <phool/PHNodeIterator.h> // for PHNodeIterator
12 #include <phool/PHObject.h> // for PHObject
13 #include <phool/getClass.h>
14 
15 using namespace std;
16 
17 //_______________________________________________________________________
19  : PHG4Subsystem(name)
20  , m_Detector(nullptr)
21  , m_SteppingAction(nullptr)
22 {
23 }
24 
25 //_______________________________________________________________________
27 {
28  PHNodeIterator iter(topNode);
29  PHCompositeNode *dstNode = dynamic_cast<PHCompositeNode *>(iter.findFirst("PHCompositeNode", "DST"));
30  PHNodeIterator dstIter(dstNode);
31  PHCompositeNode *DetNode = dynamic_cast<PHCompositeNode *>(dstIter.findFirst("PHCompositeNode", Name()));
32  if (!DetNode)
33  {
34  DetNode = new PHCompositeNode(Name());
35  dstNode->addNode(DetNode);
36  }
37  string g4hitnodename = "G4HIT_" + Name();
38  PHG4HitContainer *g4_hits = findNode::getClass<PHG4HitContainer>(DetNode, g4hitnodename);
39  if (!g4_hits)
40  {
41  g4_hits = new PHG4HitContainer(g4hitnodename);
42  DetNode->addNode(new PHIODataNode<PHObject>(g4_hits, g4hitnodename, "PHObject"));
43  }
44 
45  // create detector
46  m_Detector = new G4Example01Detector(this, topNode, Name());
48 
49  // create stepping action
51 
52  return 0;
53 }
54 
55 //_______________________________________________________________________
57 {
58  // pass top node to stepping action so that it gets
59  // relevant nodes needed internally
60  if (m_SteppingAction)
61  {
63  }
64  return 0;
65 }
66 
67 void G4Example01Subsystem::Print(const string &what) const
68 {
69  //cout << "PSTOF Parameters: " << endl;
70  if (m_Detector)
71  {
72  m_Detector->Print(what);
73  }
74  return;
75 }
76 
77 //_______________________________________________________________________
79 {
80  return m_Detector;
81 }