Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4ConeSubsystem.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4ConeSubsystem.cc
1 #include "PHG4ConeSubsystem.h"
2 
3 #include "PHG4ConeDetector.h"
6 
7 #include <phparameter/PHParameters.h>
8 
9 #include <g4main/PHG4DisplayAction.h> // for PHG4DisplayAction
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 <cmath> // for tan, atan, exp, M_PI
21 #include <sstream>
22 
23 class PHG4Detector;
24 
25 //_______________________________________________________________________
27  : PHG4DetectorSubsystem(name, lyr)
28 {
29  m_ColorArray.fill(NAN);
31 }
32 
33 //_______________________________________________________________________
35 {
36  delete m_DisplayAction;
37 }
38 
39 //_______________________________________________________________________
41 {
42  // create display settings before detector
44  if (std::isfinite(m_ColorArray[0]) &&
45  std::isfinite(m_ColorArray[1]) &&
46  std::isfinite(m_ColorArray[2]) &&
47  std::isfinite(m_ColorArray[3]))
48  {
49  disp_action->SetColor(m_ColorArray[0], m_ColorArray[1], m_ColorArray[2], m_ColorArray[3]);
50  }
51  m_DisplayAction = disp_action;
52 
53  // create detector
54  m_Detector = new PHG4ConeDetector(this, topNode, GetParams(), Name(), GetLayer());
57  if (GetParams()->get_int_param("active"))
58  {
59  PHNodeIterator iter(topNode);
60  PHCompositeNode *dstNode = dynamic_cast<PHCompositeNode *>(iter.findFirst("PHCompositeNode", "DST"));
61  PHCompositeNode *runNode = dynamic_cast<PHCompositeNode *>(iter.findFirst("PHCompositeNode", "RUN"));
62 
63  std::string nodename;
64  if (SuperDetector() != "NONE")
65  {
66  PHNodeIterator iter_dst(dstNode);
67  PHCompositeNode *superSubNode = dynamic_cast<PHCompositeNode *>(iter_dst.findFirst("PHCompositeNode", SuperDetector()));
68  if (!superSubNode)
69  {
70  superSubNode = new PHCompositeNode(SuperDetector());
71  dstNode->addNode(superSubNode);
72  }
73  dstNode = superSubNode;
74  PHNodeIterator iter_run(runNode);
75  superSubNode = dynamic_cast<PHCompositeNode *>(iter_run.findFirst("PHCompositeNode", SuperDetector()));
76  if (!superSubNode)
77  {
78  superSubNode = new PHCompositeNode(SuperDetector());
79  runNode->addNode(superSubNode);
80  }
81  nodename = "G4HIT_" + SuperDetector();
82  }
83  else
84  {
85  nodename = "G4HIT_" + Name();
86  }
87  // create hit list
88  PHG4HitContainer *cone_hits = findNode::getClass<PHG4HitContainer>(topNode, nodename);
89  if (!cone_hits)
90  {
91  dstNode->addNode(new PHIODataNode<PHObject>(cone_hits = new PHG4HitContainer(nodename), nodename, "PHObject"));
92  }
93  // create stepping action
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 (m_SteppingAction)
105  {
107  }
108  return 0;
109 }
110 
111 //_______________________________________________________________________
113 {
114  return m_Detector;
115 }
116 
117 //_______________________________________________________________________
118 void PHG4ConeSubsystem::Set_eta_range(const double etaMin, const double etaMax)
119 {
120  double thetaMin = 2 * atan(exp(-etaMax));
121  double thetaMax = 2 * atan(exp(-etaMin));
122 
123  double z1 = get_double_param("place_z") - get_double_param("length");
124  double z2 = get_double_param("place_z") + get_double_param("length");
125 
126  set_double_param("rmin1", z1 * tan(thetaMin));
127  set_double_param("rmax1", z1 * tan(thetaMax));
128 
129  set_double_param("rmin2", z2 * tan(thetaMin));
130  set_double_param("rmax2", z2 * tan(thetaMax));
131 }
132 
134 {
135  set_default_double_param("place_x", 0.);
136  set_default_double_param("place_y", 0.);
137  set_default_double_param("place_z", 0.);
138 
139  set_default_double_param("length", NAN);
140  set_default_double_param("rmin1", NAN);
141  set_default_double_param("rmax1", NAN);
142  set_default_double_param("rmin2", NAN);
143  set_default_double_param("rmax2", NAN);
144  set_default_double_param("sphi", 0.);
145  set_default_double_param("dphi", 360.); // degrees
146  set_default_double_param("rot_x", 0);
147  set_default_double_param("rot_y", 0);
148  set_default_double_param("rot_z", 0);
149 
150  set_default_string_param("material", "WorldMaterial");
151 }
152 
153 void PHG4ConeSubsystem::SetR1(const double min, const double max)
154 {
155  set_double_param("rmin1", min);
156  set_double_param("rmax1", max);
157 }
158 
159 void PHG4ConeSubsystem::SetR2(const double min, const double max)
160 {
161  set_double_param("rmin2", min);
162  set_double_param("rmax2", max);
163 }
164 
166 {
167  set_double_param("length", a);
168 }
169 
170 void PHG4ConeSubsystem::SetPhi(const double a, const double b)
171 {
172  set_double_param("sphi", a);
173  set_double_param("dphi", b);
174 }
175 
176 void PHG4ConeSubsystem::SetPlaceZ(const double dbl)
177 {
178  set_double_param("place_z", dbl);
179 }
180 
181 void PHG4ConeSubsystem::SetPlace(const double place_x, const double place_y, const double place_z)
182 {
183  set_double_param("place_x", place_x);
184  set_double_param("place_y", place_y);
185  set_double_param("place_z", place_z);
186 }
187 
188 void PHG4ConeSubsystem::SetZRot(const double dbl)
189 {
190  set_double_param("rot_z", dbl);
191 }
192 
194 {
195  set_string_param("material", mat);
196 }