ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4BbcSubsystem.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4BbcSubsystem.cc
1 #include "PHG4BbcSubsystem.h"
2 
3 #include "PHG4BbcDetector.h"
4 #include "PHG4BbcDisplayAction.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 #include <phool/phool.h>
20 
21 #include <iostream> // for operator<<, basic_ostream, endl
22 #include <set> // for set
23 #include <sstream>
24 
25 //_______________________________________________________________________
27  : PHG4DetectorSubsystem(name)
28 {
30 }
31 
32 //_______________________________________________________________________
34 {
35  delete m_DisplayAction;
36 }
37 
38 //_______________________________________________________________________
40 {
41  if (Verbosity() > 1)
42  {
43  std::cout << PHWHERE << " Initializing BBC Subsystem" << std::endl;
44  }
45 
46  PHNodeIterator iter(topNode);
47  PHCompositeNode *dstNode = dynamic_cast<PHCompositeNode *>(iter.findFirst("PHCompositeNode", "DST"));
48 
49  // create display settings before detector
51  // create detector
52  m_Detector = new PHG4BbcDetector(this, topNode, GetParams(), Name());
55 
56  std::set<std::string> nodes;
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")
75  {
76  detector_suffix = Name();
77  }
78 
79  m_HitNodeName = "G4HIT_" + detector_suffix;
80  nodes.insert(m_HitNodeName);
81  m_SupportNodeName = "G4HIT_SUPPORT_" + detector_suffix;
82  if (GetParams()->get_int_param("supportactive"))
83  {
84  nodes.insert(m_SupportNodeName);
85  }
86  for (auto nodename : nodes)
87  {
88  PHG4HitContainer *g4_hits = findNode::getClass<PHG4HitContainer>(topNode, nodename);
89  if (!g4_hits)
90  {
91  g4_hits = new PHG4HitContainer(nodename);
92  DetNode->addNode(new PHIODataNode<PHObject>(g4_hits, nodename, "PHObject"));
93  }
94  }
95  // create stepping action
99  }
100  else if (GetParams()->get_int_param("blackhole"))
101  {
103  }
104 
105  return 0;
106 }
107 
108 //_______________________________________________________________________
110 {
111  // pass top node to stepping action so that it gets
112  // relevant nodes needed internally
113  if (m_SteppingAction)
114  {
116  }
117  return 0;
118 }
119 
120 void PHG4BbcSubsystem::Print(const std::string &what) const
121 {
122  std::cout << Name() << " Parameters: " << std::endl;
123  GetParams()->Print();
124  if (m_Detector)
125  {
126  m_Detector->Print(what);
127  }
128  if (m_SteppingAction)
129  {
130  m_SteppingAction->Print(what);
131  }
132  return;
133 }
134 
135 //_______________________________________________________________________
137 {
138  return m_Detector;
139 }
140 
142 {
143  // geometry version number
144  // we use negative numbers until the "official" version
145  // when we build the detector
146  // set_default_int_param("geometry_version",-1);
147 }