EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4LmonSubsystem.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4LmonSubsystem.cc
1 #include "G4LmonSubsystem.h"
2 #include "G4LmonDetector.h"
3 #include "G4LmonEventAction.h"
4 #include "G4LmonSteppingAction.h"
5 #include "RootOut.h"
6 
7 #include <phparameter/PHParameters.h>
8 
10 #include <g4main/PHG4SteppingAction.h> // for PHG4SteppingAction
11 
12 #include <phool/PHCompositeNode.h>
13 #include <phool/PHIODataNode.h> // for PHIODataNode
14 #include <phool/PHNode.h> // for PHNode
15 #include <phool/PHNodeIterator.h> // for PHNodeIterator
16 #include <phool/PHObject.h> // for PHObject
17 #include <phool/getClass.h>
18 
19 #include <boost/foreach.hpp>
20 
21 #include <set> // for set
22 #include <sstream>
23 
24 using namespace std;
25 
26 //_______________________________________________________________________
28  : PHG4Subsystem(name)
29  , m_Detector(nullptr)
30  , m_SteppingAction(nullptr)
31  , m_rootname("lmon.root")
32 {
33  Name(name);
34 }
35 
36 //_______________________________________________________________________
38 {
39  PHNodeIterator iter(topNode);
40  PHCompositeNode *dstNode = dynamic_cast<PHCompositeNode *>(iter.findFirst("PHCompositeNode", "DST"));
41  PHNodeIterator dstIter(dstNode);
42  PHCompositeNode *DetNode = dynamic_cast<PHCompositeNode *>(dstIter.findFirst("PHCompositeNode", Name()));
43  if (!DetNode)
44  {
45  DetNode = new PHCompositeNode(Name());
46  dstNode->addNode(DetNode);
47  }
48  string g4hitnodename = "G4HIT_" + Name();
49  PHG4HitContainer *g4_hits = findNode::getClass<PHG4HitContainer>(DetNode, g4hitnodename);
50  if (!g4_hits)
51  {
52  g4_hits = new PHG4HitContainer(g4hitnodename);
53  DetNode->addNode(new PHIODataNode<PHObject>(g4_hits, g4hitnodename, "PHObject"));
54  }
55 
56  // create detector
57  m_Detector = new G4LmonDetector(this, topNode, Name());
59 
60  rootoutput = new RootOut();
62  rootoutput->Open();
64  // create stepping action
67 
68  return 0;
69 }
70 
71 
72 //_______________________________________________________________________
74 {
75  // pass top node to stepping action so that it gets
76  // relevant nodes needed internally
77  if (m_SteppingAction)
78  {
80  }
81  return 0;
82 }
83 
84 void G4LmonSubsystem::Print(const string &what) const
85 {
86  //cout << "PSTOF Parameters: " << endl;
87  if (m_Detector)
88  {
89  m_Detector->Print(what);
90  }
91  return;
92 }
93 
94 //_______________________________________________________________________
96 {
97  return m_Detector;
98 }