ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4BlockSubsystem.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4BlockSubsystem.cc
1 #include "PHG4BlockSubsystem.h"
2 
3 #include "PHG4BlockDetector.h"
6 #include "PHG4BlockGeomv1.h"
8 
9 #include <phparameter/PHParameters.h>
10 
12 #include <g4main/PHG4DisplayAction.h> // for PHG4DisplayAction
13 #include <g4main/PHG4SteppingAction.h> // for PHG4SteppingAction
14 
15 #include <phool/PHIODataNode.h> // for PHIODataNode
16 #include <phool/PHNode.h> // for PHNode
17 #include <phool/PHNodeIterator.h> // for PHNodeIterator
18 #include <phool/PHObject.h> // for PHObject
19 #include <phool/getClass.h>
20 #include <phool/PHCompositeNode.h>
21 
22 #include <cmath> // for NAN
23 #include <sstream>
24 
25 class PHG4BlockGeom;
26 class PHG4Detector;
27 
28 using namespace std;
29 
30 //_______________________________________________________________________
31 PHG4BlockSubsystem::PHG4BlockSubsystem(const std::string &name, const int lyr)
32  : PHG4DetectorSubsystem(name, lyr)
33  , m_Detector(nullptr)
34  , m_SteppingAction(nullptr)
35  , m_DisplayAction(nullptr)
36 {
37  m_ColorArray.fill(NAN);
39 }
40 
41 //_______________________________________________________________________
43 {
44  delete m_DisplayAction;
45 }
46 
47 //_______________________________________________________________________
49 {
50  PHNodeIterator iter(topNode);
51  PHCompositeNode *dstNode = dynamic_cast<PHCompositeNode *>(iter.findFirst("PHCompositeNode", "DST"));
52 
53  // create display settings before detector (detector adds its volumes to it)
55  if (isfinite(m_ColorArray[0]) &&
56  isfinite(m_ColorArray[1]) &&
57  isfinite(m_ColorArray[2]) &&
59  {
60  disp_action->SetColor(m_ColorArray[0], m_ColorArray[1],m_ColorArray[2],m_ColorArray[3]);
61  }
62  m_DisplayAction = disp_action;
63  // create detector
64  m_Detector = new PHG4BlockDetector(this, topNode, GetParams(), Name(), GetLayer());
67  if (GetParams()->get_int_param("active"))
68  {
69  ostringstream nodename;
70  ostringstream geonode;
71  if (SuperDetector() != "NONE")
72  {
73  nodename << "G4HIT_" << SuperDetector();
74  geonode << "BLOCKGEOM_" << SuperDetector();
75  }
76  else
77  {
78  nodename << "G4HIT_" << Name();
79  geonode << "BLOCKGEOM_" << Name();
80  }
81 
82  // create hit list
83  PHG4HitContainer *block_hits = findNode::getClass<PHG4HitContainer>(topNode, nodename.str());
84  if (!block_hits)
85  {
86  dstNode->addNode(new PHIODataNode<PHObject>(block_hits = new PHG4HitContainer(nodename.str()), nodename.str(), "PHObject"));
87  }
88 
89  block_hits->AddLayer(GetLayer());
90  PHG4BlockGeomContainer *geocont = findNode::getClass<PHG4BlockGeomContainer>(topNode,
91  geonode.str());
92  if (!geocont)
93  {
94  geocont = new PHG4BlockGeomContainer();
95  PHCompositeNode *runNode = dynamic_cast<PHCompositeNode *>(iter.findFirst("PHCompositeNode", "RUN"));
96  PHIODataNode<PHObject> *newNode = new PHIODataNode<PHObject>(geocont, geonode.str(), "PHObject");
97  runNode->addNode(newNode);
98  }
99 
100  PHG4BlockGeom *geom = new PHG4BlockGeomv1(GetLayer(),
101  GetParams()->get_double_param("size_x"),
102  GetParams()->get_double_param("size_y"),
103  GetParams()->get_double_param("size_z"),
104  GetParams()->get_double_param("place_x"),
105  GetParams()->get_double_param("place_y"),
106  GetParams()->get_double_param("place_z"),
107  GetParams()->get_double_param("rot_z"));
108  geocont->AddLayerGeom(GetLayer(), geom);
109 
111  }
112  else if (GetParams()->get_int_param("blackhole"))
113  {
115  }
116 
117  return 0;
118 }
119 
120 //_______________________________________________________________________
122 {
123  // pass top node to stepping action so that it gets
124  // relevant nodes needed internally
125  if (m_SteppingAction)
126  {
128  }
129  return 0;
130 }
131 
132 //_______________________________________________________________________
133 PHG4Detector *
135 {
136  return m_Detector;
137 }
138 
140 {
141  set_default_double_param("place_x", 0.);
142  set_default_double_param("place_y", 0.);
143  set_default_double_param("place_z", 0.);
144  set_default_double_param("rot_x", 0.);
145  set_default_double_param("rot_y", 0.);
146  set_default_double_param("rot_z", 0.);
147  set_default_double_param("steplimits", NAN);
148  set_default_double_param("size_x", 10.);
149  set_default_double_param("size_y", 10.);
150  set_default_double_param("size_z", 10.);
151 
152  set_default_int_param("use_g4steps", 0);
153 
154  set_default_string_param("material", "G4_Galactic");
155 }