Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4SpacalPrototype4Subsystem.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4SpacalPrototype4Subsystem.cc
2 
5 
6 #include <phparameter/PHParameters.h>
7 
9 #include <g4main/PHG4SteppingAction.h> // for PHG4SteppingAction
10 
11 #include <phool/PHCompositeNode.h>
12 #include <phool/PHIODataNode.h> // for PHIODataNode
13 #include <phool/PHNode.h> // for PHNode
14 #include <phool/PHNodeIterator.h> // for PHNodeIterator
15 #include <phool/PHObject.h> // for PHObject
16 #include <phool/getClass.h>
17 
18 #include <iostream> // for operator<<, basic_ost...
19 #include <sstream>
20 
21 class PHG4Detector;
22 
23 using namespace std;
24 
25 //_______________________________________________________________________
27  : PHG4DetectorSubsystem(na, 0)
28  , detector_(nullptr)
29  , steppingAction_(nullptr)
30 {
32 }
33 
34 //_______________________________________________________________________
36 {
37  PHNodeIterator iter(topNode);
38  PHCompositeNode* dstNode = dynamic_cast<PHCompositeNode*>(iter.findFirst("PHCompositeNode", "DST"));
39 
40  if (Verbosity() > 0)
41  cout
42  << "PHG4SpacalPrototype4Subsystem::InitRun - use PHG4SpacalPrototype4Detector"
43  << endl;
44  detector_ = new PHG4SpacalPrototype4Detector(this, topNode, GetParams(), Name());
45 
47  detector_->SetAbsorberActive(GetParams()->get_int_param("absorberactive"));
50 
51  if (GetParams()->get_int_param("active"))
52  {
53  ostringstream nodename;
54  if (SuperDetector() != "NONE")
55  {
56  nodename << "G4HIT_" << SuperDetector();
57  }
58  else
59  {
60  nodename << "G4HIT_" << Name();
61  }
62  PHG4HitContainer* cylinder_hits = findNode::getClass<PHG4HitContainer>(
63  topNode, nodename.str());
64  if (!cylinder_hits)
65  {
66  dstNode->addNode(
68  cylinder_hits = new PHG4HitContainer(nodename.str()),
69  nodename.str(), "PHObject"));
70  }
71  cylinder_hits->AddLayer(0);
72  if (GetParams()->get_int_param("absorberactive"))
73  {
74  nodename.str("");
75  if (SuperDetector() != "NONE")
76  {
77  nodename << "G4HIT_ABSORBER_" << SuperDetector();
78  }
79  else
80  {
81  nodename << "G4HIT_ABSORBER_" << Name();
82  }
83  PHG4HitContainer* cylinder_hits =
84  findNode::getClass<PHG4HitContainer>(topNode, nodename.str());
85  if (!cylinder_hits)
86  {
87  cylinder_hits = new PHG4HitContainer(nodename.str());
88  dstNode->addNode(new PHIODataNode<PHObject>(cylinder_hits, nodename.str(), "PHObject"));
89  }
90  cylinder_hits->AddLayer(0);
91  }
94  }
95 
96  return 0;
97 }
98 
99 //_______________________________________________________________________
101 {
102  // pass top node to stepping action so that it gets
103  // relevant nodes needed internally
104  if (steppingAction_)
105  {
107  }
108  return 0;
109 }
110 
111 //_______________________________________________________________________
114 {
115  return detector_;
116 }
117 
119 {
120  detector_->Print(what);
121  cout << Name() << " Parameters: " << endl;
122  if (!BeginRunExecuted())
123  {
124  cout << "Need to execute BeginRun() before parameter printout is meaningful" << endl;
125  cout << "To do so either run one or more events or on the command line execute: " << endl;
126  cout << "Fun4AllServer *se = Fun4AllServer::instance();" << endl;
127  cout << "PHG4Reco *g4 = (PHG4Reco *) se->getSubsysReco(\"PHG4RECO\");" << endl;
128  cout << "g4->InitRun(se->topNode());" << endl;
129  cout << "PHG4SpacalPrototype4Subsystem *sys = (PHG4SpacalPrototype4Subsystem *) g4->getSubsystem(\"" << Name() << "\");" << endl;
130  cout << "sys->Print()" << endl;
131  return;
132  }
133  GetParams()->Print();
134  return;
135 }
136 
138 {
139  set_default_double_param("xpos", 0.); // translation in 3D
140  set_default_double_param("ypos", 0.); // translation in 3D
141  set_default_double_param("zpos", 0.); // translation in 3D
142  set_default_double_param("z_rotation_degree", 0.); // roation in the vertical plane
143  set_default_int_param("construction_verbose", 0.); // roation in the vertical plane
144  return;
145 }