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