Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4MicromegasSubsystem.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4MicromegasSubsystem.cc
1 
7 
11 
12 #include <phparameter/PHParameters.h>
13 
16 
17 #include <phool/PHCompositeNode.h>
18 #include <phool/PHIODataNode.h>
19 #include <phool/PHNode.h>
20 #include <phool/PHNodeIterator.h>
21 #include <phool/PHObject.h>
22 #include <phool/getClass.h>
23 
24 //_______________________________________________________________________
26  : PHG4DetectorSubsystem(name, layerno)
27 {
28  // call base class method which will set up parameter infrastructure
29  // and call our SetDefaultParameters() method
31 
32  SuperDetector(name);
33 }
34 
35 //_______________________________________________________________________
37 {
38  delete m_DisplayAction;
39 }
40 
41 //_______________________________________________________________________
43 {
44  PHNodeIterator iter(topNode);
45  auto dstNode = dynamic_cast<PHCompositeNode *>(iter.findFirst("PHCompositeNode", "DST"));
46  PHNodeIterator dstIter(dstNode);
47  if (GetParams()->get_int_param("active"))
48  {
49  std::set<std::string> nodes;
50  auto detNode = dynamic_cast<PHCompositeNode *>(dstIter.findFirst("PHCompositeNode", SuperDetector()));
51  if (!detNode)
52  {
53  detNode = new PHCompositeNode(SuperDetector());
54  dstNode->addNode(detNode);
55  }
56 
57  // create hit output nodes
58  std::string detector_suffix = SuperDetector();
59  if (detector_suffix == "NONE" || detector_suffix.empty())
60  {
61  detector_suffix = Name();
62  }
63 
64  m_HitNodeName = "G4HIT_" + detector_suffix;
65  nodes.insert(m_HitNodeName);
66  m_SupportNodeName = "G4HIT_SUPPORT_" + detector_suffix;
67  if (GetParams()->get_int_param("supportactive"))
68  {
69  nodes.insert(m_SupportNodeName);
70  }
71 
72  for (const auto &g4hitnodename : nodes)
73  {
74  auto g4_hits = findNode::getClass<PHG4HitContainer>(detNode, g4hitnodename);
75  if (!g4_hits)
76  {
77  g4_hits = new PHG4HitContainer(g4hitnodename);
78  detNode->addNode(new PHIODataNode<PHObject>(g4_hits, g4hitnodename, "PHObject"));
79  }
80  }
81  }
82 
83  // create detector
85  m_Detector = new PHG4MicromegasDetector(this, topNode, GetParams(), Name());
87 
91 
92  // create stepping action if detector is active
93  if (GetParams()->get_int_param("active"))
94  {
98  }
99  return 0;
100 }
101 
102 //_______________________________________________________________________
104 {
105  // pass top node to stepping action so that it gets
106  // relevant nodes needed internally
107  if (m_SteppingAction)
108  {
110  }
111  return 0;
112 }
113 
114 //_______________________________________________________________________
116 {
117  if (m_Detector)
118  {
119  m_Detector->Print(what);
120  }
121 }
122 
123 //_______________________________________________________________________
125 {
126  return m_Detector;
127 }