/
PHG4ForwardEcalSubsystem.cc
170 lines (152 loc) · 5.16 KB
/
PHG4ForwardEcalSubsystem.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
170
#include "PHG4ForwardEcalSubsystem.h"
#include "PHG4EICForwardEcalDetector.h"
#include "PHG4ForwardEcalDetector.h"
#include "PHG4ForwardEcalDisplayAction.h"
#include "PHG4ForwardEcalSteppingAction.h"
#include <phparameter/PHParameters.h>
#include <g4main/PHG4DisplayAction.h> // for PHG4DisplayAction
#include <g4main/PHG4HitContainer.h>
#include <g4main/PHG4SteppingAction.h> // for PHG4SteppingAction
#include <g4main/PHG4Utils.h>
#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 <TSystem.h>
#include <cstdlib> // for getenv
#include <set> // for set
#include <sstream>
class PHG4Detector;
//_______________________________________________________________________
PHG4ForwardEcalSubsystem::PHG4ForwardEcalSubsystem(const std::string& name, const int lyr)
: PHG4DetectorSubsystem(name, lyr)
{
InitializeParameters();
}
//_______________________________________________________________________
PHG4ForwardEcalSubsystem::~PHG4ForwardEcalSubsystem()
{
delete m_DisplayAction;
}
//_______________________________________________________________________
int PHG4ForwardEcalSubsystem::InitRunSubsystem(PHCompositeNode* topNode)
{
PHNodeIterator iter(topNode);
PHCompositeNode* dstNode = dynamic_cast<PHCompositeNode*>(iter.findFirst("PHCompositeNode", "DST"));
// create display settings before detector
m_DisplayAction = new PHG4ForwardEcalDisplayAction(Name(), showdetailed);
// create detector
if (m_EICDetectorFlag)
{
m_Detector = new PHG4EICForwardEcalDetector(this, topNode, GetParams(), Name());
}
else
{
m_Detector = new PHG4ForwardEcalDetector(this, topNode, GetParams(), Name());
}
m_Detector->DoFullLightProp(_do_lightpropagation);
m_Detector->SuperDetector(SuperDetector());
m_Detector->OverlapCheck(CheckOverlap());
m_Detector->Verbosity(Verbosity());
std::set<std::string> nodes;
if (GetParams()->get_int_param("active"))
{
PHNodeIterator dstIter(dstNode);
PHCompositeNode* DetNode = dynamic_cast<PHCompositeNode*>(dstIter.findFirst("PHCompositeNode", SuperDetector()));
if (!DetNode)
{
DetNode = new PHCompositeNode(SuperDetector());
dstNode->addNode(DetNode);
}
std::string nodename;
if (SuperDetector() != "NONE")
{
nodename = "G4HIT_" + SuperDetector();
}
else
{
nodename = "G4HIT_" + Name();
}
nodes.insert(nodename);
if (GetParams()->get_int_param("absorberactive"))
{
if (SuperDetector() != "NONE")
{
nodename = "G4HIT_ABSORBER_" + SuperDetector();
}
else
{
nodename = "G4HIT_ABSORBER_" + Name();
}
nodes.insert(nodename);
}
for (auto thisnode : nodes)
{
PHG4HitContainer* g4_hits = findNode::getClass<PHG4HitContainer>(topNode, thisnode);
if (!g4_hits)
{
g4_hits = new PHG4HitContainer(thisnode);
DetNode->addNode(new PHIODataNode<PHObject>(g4_hits, thisnode, "PHObject"));
}
}
// create stepping action
m_SteppingAction = new PHG4ForwardEcalSteppingAction(m_Detector, GetParams());
}
return 0;
}
//_______________________________________________________________________
int PHG4ForwardEcalSubsystem::process_event(PHCompositeNode* topNode)
{
// pass top node to stepping action so that it gets
// relevant nodes needed internally
if (m_SteppingAction)
{
m_SteppingAction->SetInterfacePointers(topNode);
}
return 0;
}
//_______________________________________________________________________
PHG4Detector* PHG4ForwardEcalSubsystem::GetDetector(void) const
{
return m_Detector;
}
void PHG4ForwardEcalSubsystem::SetDefaultParameters()
{
set_default_int_param("nFibers", 0);
set_default_double_param("fiber_diam", 0.);
set_default_double_param("width_coating", 0.);
set_default_double_param("tower_readout_dz", 4.0);
set_default_double_param("clamp_plate_width", 0.0);
set_default_double_param("place_x", 0.);
set_default_double_param("place_y", 0.);
set_default_double_param("place_z", -108.);
set_default_double_param("rMin1", 2.2);
set_default_double_param("rMax1", 65.6);
set_default_double_param("rMin2", 2.6);
set_default_double_param("rMax2", 77.5);
set_default_double_param("rot_x", 0.);
set_default_double_param("rot_y", 180.);
set_default_double_param("rot_z", 0.);
std::ostringstream mappingfilename;
const char* calibroot = getenv("CALIBRATIONROOT");
if (calibroot)
{
mappingfilename << calibroot;
}
else
{
std::cout << "no CALIBRATIONROOT environment variable" << std::endl;
gSystem->Exit(1);
}
mappingfilename << "/ForwardEcal/mapping/towerMap_FEMC_fsPHENIX_v004.txt";
set_default_string_param("mapping_file", mappingfilename.str());
set_default_string_param("mapping_file_md5", PHG4Utils::md5sum(mappingfilename.str()));
return;
}
void PHG4ForwardEcalSubsystem::SetTowerMappingFile(const std::string& filename)
{
set_string_param("mapping_file", filename);
set_string_param("mapping_file_md5", PHG4Utils::md5sum(get_string_param("mapping_file")));
}