EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4CEmcTestBeamSubsystem.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4CEmcTestBeamSubsystem.cc
3 
6 
8 #include <g4main/PHG4Subsystem.h> // for PHG4Subsystem
9 
10 #include <phool/PHCompositeNode.h>
11 #include <phool/PHIODataNode.h> // for PHIODataNode
12 #include <phool/PHNode.h> // for PHNode
13 #include <phool/PHNodeIterator.h> // for PHNodeIterator
14 #include <phool/PHObject.h> // for PHObject
15 #include <phool/getClass.h>
16 
17 #include <Geant4/G4SystemOfUnits.hh>
18 #include <Geant4/G4Types.hh> // for G4double
19 
20 #include <sstream>
21 
22 class PHG4Detector;
23 class PHG4SteppingAction;
24 
25 using namespace std;
26 
27 //_______________________________________________________________________
29  : PHG4Subsystem(name)
30  , detector_(0)
31  , steppingAction_(nullptr)
32  , eventAction_(nullptr)
33  , place_in_x(0)
34  , place_in_y(0)
35  , place_in_z(0)
36  , rot_in_x(0)
37  , rot_in_y(0)
38  , rot_in_z(0)
39  , active(0)
40  , absorberactive(0)
41  , layer(lyr)
42  , blackhole(0)
43  , detector_type(name)
44  , superdetector("NONE")
45 {
46  // put the layer into the name so we get unique names
47  // for multiple layers
48  ostringstream nam;
49  nam << name << "_" << lyr;
50  Name(nam.str().c_str());
51  for (int i = 0; i < 3; i++)
52  {
53  dimension[i] = 100.0 * cm;
54  }
55 }
56 
57 //_______________________________________________________________________
59 {
60  PHNodeIterator iter(topNode);
61  PHCompositeNode* dstNode = dynamic_cast<PHCompositeNode*>(iter.findFirst("PHCompositeNode", "DST"));
62 
63  // create detector
64  detector_ = new PHG4CEmcTestBeamDetector(this, topNode, Name(), layer);
74  if (active)
75  {
76  ostringstream nodename;
77  if (superdetector != "NONE")
78  {
79  nodename << "G4HIT_" << superdetector;
80  }
81  else
82  {
83  nodename << "G4HIT_" << detector_type << "_" << layer;
84  }
85  // create hit list
86  PHG4HitContainer* block_hits = findNode::getClass<PHG4HitContainer>(topNode, nodename.str().c_str());
87  if (!block_hits)
88  {
89  dstNode->addNode(new PHIODataNode<PHObject>(block_hits = new PHG4HitContainer(nodename.str()), nodename.str().c_str(), "PHObject"));
90  }
91  if (absorberactive)
92  {
93  nodename.str("");
94  if (superdetector != "NONE")
95  {
96  nodename << "G4HIT_ABSORBER_" << superdetector;
97  }
98  else
99  {
100  nodename << "G4HIT_ABSORBER_" << detector_type << "_" << layer;
101  }
102  }
103  block_hits = findNode::getClass<PHG4HitContainer>(topNode, nodename.str().c_str());
104  if (!block_hits)
105  {
106  dstNode->addNode(new PHIODataNode<PHObject>(block_hits = new PHG4HitContainer(nodename.str()), nodename.str().c_str(), "PHObject"));
107  }
108  // create stepping action
110 
111  eventAction_ = new PHG4EventActionClearZeroEdep(topNode, nodename.str());
112  }
113  if (blackhole && !active)
114  {
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 (steppingAction_)
126  {
128  }
129  return 0;
130 }
131 
132 //_______________________________________________________________________
134 {
135  return detector_;
136 }
137 
138 //_______________________________________________________________________
140 {
141  return steppingAction_;
142 }
143 
144 void PHG4CEmcTestBeamSubsystem::SetPlace(const G4double place_x, const G4double place_y, const G4double place_z)
145 {
146  place_in_x = place_x * cm;
147  place_in_y = place_y * cm;
148  place_in_z = place_z * cm;
149 }
150 
151 void PHG4CEmcTestBeamSubsystem::SetPlaceZ(const G4double dbl)
152 {
153  place_in_z = dbl * cm;
154 }
155 
156 void PHG4CEmcTestBeamSubsystem::SetXRot(const G4double dbl)
157 {
158  rot_in_x = dbl * deg;
159 }
160 
161 void PHG4CEmcTestBeamSubsystem::SetYRot(const G4double dbl)
162 {
163  rot_in_y = dbl * deg;
164 }
165 
166 void PHG4CEmcTestBeamSubsystem::SetZRot(const G4double dbl)
167 {
168  rot_in_z = dbl * deg;
169 }