forked from sPHENIX-Collaboration/coresoftware
/
PHG4CEmcTestBeamSubsystem.cc
169 lines (150 loc) · 4.63 KB
/
PHG4CEmcTestBeamSubsystem.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#include "PHG4CEmcTestBeamSubsystem.h"
#include "PHG4CEmcTestBeamDetector.h"
#include "PHG4CEmcTestBeamSteppingAction.h"
#include "PHG4EventActionClearZeroEdep.h"
#include <g4main/PHG4HitContainer.h>
#include <g4main/PHG4Subsystem.h> // for PHG4Subsystem
#include <phool/PHCompositeNode.h>
#include <phool/PHIODataNode.h> // for PHIODataNode
#include <phool/PHNode.h> // for PHNode
#include <phool/PHNodeIterator.h> // for PHNodeIterator
#include <phool/PHObject.h> // for PHObject
#include <phool/getClass.h>
#include <Geant4/G4SystemOfUnits.hh>
#include <Geant4/G4Types.hh> // for G4double
#include <sstream>
class PHG4Detector;
class PHG4SteppingAction;
using namespace std;
//_______________________________________________________________________
PHG4CEmcTestBeamSubsystem::PHG4CEmcTestBeamSubsystem(const std::string& name, const int lyr)
: PHG4Subsystem(name)
, detector_(0)
, steppingAction_(nullptr)
, eventAction_(nullptr)
, place_in_x(0)
, place_in_y(0)
, place_in_z(0)
, rot_in_x(0)
, rot_in_y(0)
, rot_in_z(0)
, active(0)
, absorberactive(0)
, layer(lyr)
, blackhole(0)
, detector_type(name)
, superdetector("NONE")
{
// put the layer into the name so we get unique names
// for multiple layers
ostringstream nam;
nam << name << "_" << lyr;
Name(nam.str().c_str());
for (int i = 0; i < 3; i++)
{
dimension[i] = 100.0 * cm;
}
}
//_______________________________________________________________________
int PHG4CEmcTestBeamSubsystem::Init(PHCompositeNode* topNode)
{
PHNodeIterator iter(topNode);
PHCompositeNode* dstNode = dynamic_cast<PHCompositeNode*>(iter.findFirst("PHCompositeNode", "DST"));
// create detector
detector_ = new PHG4CEmcTestBeamDetector(this, topNode, Name(), layer);
detector_->SetPlace(place_in_x, place_in_y, place_in_z);
detector_->SetXRot(rot_in_x);
detector_->SetYRot(rot_in_y);
detector_->SetZRot(rot_in_z);
detector_->SetActive(active);
detector_->SetAbsorberActive(absorberactive);
detector_->BlackHole(blackhole);
detector_->SuperDetector(superdetector);
detector_->OverlapCheck(CheckOverlap());
if (active)
{
ostringstream nodename;
if (superdetector != "NONE")
{
nodename << "G4HIT_" << superdetector;
}
else
{
nodename << "G4HIT_" << detector_type << "_" << layer;
}
// create hit list
PHG4HitContainer* block_hits = findNode::getClass<PHG4HitContainer>(topNode, nodename.str().c_str());
if (!block_hits)
{
dstNode->addNode(new PHIODataNode<PHObject>(block_hits = new PHG4HitContainer(nodename.str()), nodename.str().c_str(), "PHObject"));
}
if (absorberactive)
{
nodename.str("");
if (superdetector != "NONE")
{
nodename << "G4HIT_ABSORBER_" << superdetector;
}
else
{
nodename << "G4HIT_ABSORBER_" << detector_type << "_" << layer;
}
}
block_hits = findNode::getClass<PHG4HitContainer>(topNode, nodename.str().c_str());
if (!block_hits)
{
dstNode->addNode(new PHIODataNode<PHObject>(block_hits = new PHG4HitContainer(nodename.str()), nodename.str().c_str(), "PHObject"));
}
// create stepping action
steppingAction_ = new PHG4CEmcTestBeamSteppingAction(detector_);
eventAction_ = new PHG4EventActionClearZeroEdep(topNode, nodename.str());
}
if (blackhole && !active)
{
steppingAction_ = new PHG4CEmcTestBeamSteppingAction(detector_);
}
return 0;
}
//_______________________________________________________________________
int PHG4CEmcTestBeamSubsystem::process_event(PHCompositeNode* topNode)
{
// pass top node to stepping action so that it gets
// relevant nodes needed internally
if (steppingAction_)
{
steppingAction_->SetInterfacePointers(topNode);
}
return 0;
}
//_______________________________________________________________________
PHG4Detector* PHG4CEmcTestBeamSubsystem::GetDetector(void) const
{
return detector_;
}
//_______________________________________________________________________
PHG4SteppingAction* PHG4CEmcTestBeamSubsystem::GetSteppingAction(void) const
{
return steppingAction_;
}
void PHG4CEmcTestBeamSubsystem::SetPlace(const G4double place_x, const G4double place_y, const G4double place_z)
{
place_in_x = place_x * cm;
place_in_y = place_y * cm;
place_in_z = place_z * cm;
}
void PHG4CEmcTestBeamSubsystem::SetPlaceZ(const G4double dbl)
{
place_in_z = dbl * cm;
}
void PHG4CEmcTestBeamSubsystem::SetXRot(const G4double dbl)
{
rot_in_x = dbl * deg;
}
void PHG4CEmcTestBeamSubsystem::SetYRot(const G4double dbl)
{
rot_in_y = dbl * deg;
}
void PHG4CEmcTestBeamSubsystem::SetZRot(const G4double dbl)
{
rot_in_z = dbl * deg;
}