ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4CylinderStripSubsystem.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4CylinderStripSubsystem.cc
4 
5 #include <phparameter/PHParameters.h>
6 
7 #include <g4main/PHG4DisplayAction.h> // for PHG4DisplayAction
9 #include <g4main/PHG4SteppingAction.h> // for PHG4SteppingAction
10 #include <g4main/PHG4Utils.h>
11 
12 #include <phool/PHCompositeNode.h>
13 #include <phool/PHIODataNode.h> // for PHIODataNode
14 #include <phool/PHNode.h> // for PHNode
15 #include <phool/PHNodeIterator.h> // for PHNodeIterator
16 #include <phool/PHObject.h> // for PHObject
17 #include <phool/getClass.h>
18 
19 #include <Geant4/G4Types.hh> // for G4double
20 
21 #include <cmath> // for NAN
22 #include <iostream> // for operator<<, basic_ostream, endl
23 #include <sstream>
24 
25 class PHG4Detector;
26 
27 using namespace std;
28 
29 //_______________________________________________________________________
30 PHG4CylinderStripSubsystem::PHG4CylinderStripSubsystem(const std::string &na, const int lyr)
31  : PHG4DetectorSubsystem(na, lyr)
32  , m_Detector(nullptr)
33  , m_SteppingAction(nullptr)
34 {
36 }
37 
39 {
40 }
41 
42 //_______________________________________________________________________
44 {
45  // create detector
46  m_Detector = new PHG4CylinderStripDetector(this, topNode, GetParams(), Name(), GetLayer());
47  //G4double detlength = GetParams()->get_double_param("length");
50  if (GetParams()->get_int_param("active"))
51  {
52  PHNodeIterator iter(topNode);
53  PHCompositeNode *dstNode = dynamic_cast<PHCompositeNode *>(iter.findFirst("PHCompositeNode", "DST"));
54  PHCompositeNode *runNode = dynamic_cast<PHCompositeNode *>(iter.findFirst("PHCompositeNode", "RUN"));
55 
56  ostringstream nodename;
57  ostringstream geonode;
58  if (SuperDetector() != "NONE")
59  {
60  // create super detector subnodes
61  PHNodeIterator iter_dst(dstNode);
62  PHCompositeNode *superSubNode = dynamic_cast<PHCompositeNode *>(iter_dst.findFirst("PHCompositeNode", SuperDetector()));
63  if (!superSubNode)
64  {
65  superSubNode = new PHCompositeNode(SuperDetector());
66  dstNode->addNode(superSubNode);
67  }
68  dstNode = superSubNode;
69  PHNodeIterator iter_run(runNode);
70  superSubNode = dynamic_cast<PHCompositeNode *>(iter_run.findFirst("PHCompositeNode", SuperDetector()));
71  if (!superSubNode)
72  {
73  superSubNode = new PHCompositeNode(SuperDetector());
74  runNode->addNode(superSubNode);
75  }
76  runNode = superSubNode;
77 
78  nodename << "G4HIT_" << SuperDetector();
79  geonode << "CYLINDERStripGEOM_" << SuperDetector();
80  }
81 
82  else
83  {
84  nodename << "G4HIT_" << Name();
85  geonode << "CYLINDERStripGEOM_" << Name();
86  }
87  PHG4HitContainer *cylinder_hits = findNode::getClass<PHG4HitContainer>(topNode, nodename.str());
88  if (!cylinder_hits)
89  {
90  dstNode->addNode(new PHIODataNode<PHObject>(cylinder_hits = new PHG4HitContainer(nodename.str()), nodename.str(), "PHObject"));
91  }
92  cylinder_hits->AddLayer(GetLayer());
93  //PHG4CylinderStripGeomContainer *geo = findNode::getClass<PHG4CylinderStripGeomContainer>(topNode, geonode.str());
94  //if (!geo)
95  //{
96  // geo = new PHG4CylinderStripGeomContainer();
97  // PHIODataNode<PHObject> *newNode = new PHIODataNode<PHObject>(geo, geonode.str(), "PHObject");
98  // runNode->addNode(newNode);
99  //}
100  //PHG4CylinderStripGeom *mygeom = new PHG4CylinderStripGeomv1(GetParams()->get_double_param("radius"), GetParams()->get_double_param("place_z") - detlength / 2., GetParams()->get_double_param("place_z") + detlength / 2., GetParams()->get_double_param("thickness"));
101  //geo->AddLayerGeom(GetLayer(), mygeom);
103  }
104  else if (GetParams()->get_int_param("blackhole"))
105  {
107  }
108  return 0;
109 }
110 
111 //_______________________________________________________________________
113 {
114  // pass top node to stepping action so that it gets
115  // relevant nodes needed internally
116  if (m_SteppingAction)
117  {
119  }
120  return 0;
121 }
122 
124 {
125  set_default_double_param("length", 100);
126  set_default_double_param("place_x", 0.);
127  set_default_double_param("place_y", 0.);
128  set_default_double_param("place_z", 0.);
129  set_default_double_param("radius", 100);
130  set_default_double_param("steplimits", NAN);
131  set_default_double_param("gap", 20);
132  set_default_double_param("gas1thickness", 0.0020000);
133  set_default_double_param("gas2thickness", 0.3000000);
134  set_default_double_param("phi0", 0.);
135  set_default_double_param("tmin", NAN);
136  set_default_double_param("tmax", NAN);
137  set_default_double_param("deadzone", 0);
138 
139  set_default_int_param("lengthviarapidity", 0);
140  set_default_int_param("lightyield", 0);
141  set_default_int_param("use_g4steps", 0);
142  set_default_int_param("use_2Dreadout", 0);
143  set_default_int_param("nhit", 1);
144 
145  set_default_string_param("gas", "G4_Ar");
146 }
147 
148 PHG4Detector *
150 {
151  return m_Detector;
152 }
153 
154 void PHG4CylinderStripSubsystem::Print(const string &what) const
155 {
156  cout << Name() << " Parameters: " << endl;
157  if (!BeginRunExecuted())
158  {
159  cout << "Need to execute BeginRun() before parameter printout is meaningful" << endl;
160  cout << "To do so either run one or more events or on the command line execute: " << endl;
161  cout << "Fun4AllServer *se = Fun4AllServer::instance();" << endl;
162  cout << "PHG4Reco *g4 = (PHG4Reco *) se->getSubsysReco(\"PHG4RECO\");" << endl;
163  cout << "g4->InitRun(se->topNode());" << endl;
164  cout << "PHG4CylinderStripSubsystem *cyl = (PHG4CylinderStripSubsystem *) g4->getSubsystem(\"" << Name() << "\");" << endl;
165  cout << "cyl->Print()" << endl;
166  return;
167  }
168  GetParams()->Print();
169  if (m_SteppingAction)
170  {
171  m_SteppingAction->Print(what);
172  }
173  return;
174 }