/
PHG4BarrelEcalSubsystem.cc
183 lines (165 loc) · 5.97 KB
/
PHG4BarrelEcalSubsystem.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
171
172
173
174
175
176
177
178
179
180
181
182
183
#include "PHG4BarrelEcalSubsystem.h"
#include "PHG4BarrelEcalDetector.h"
#include "PHG4BarrelEcalDisplayAction.h"
#include "PHG4BarrelEcalSteppingAction.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;
//_______________________________________________________________________
PHG4BarrelEcalSubsystem::PHG4BarrelEcalSubsystem(const std::string& name, const int lyr)
: PHG4DetectorSubsystem(name, lyr)
{
InitializeParameters();
}
//_______________________________________________________________________
PHG4BarrelEcalSubsystem::~PHG4BarrelEcalSubsystem()
{
delete m_DisplayAction;
}
//_______________________________________________________________________
int PHG4BarrelEcalSubsystem::InitRunSubsystem(PHCompositeNode* topNode)
{
PHNodeIterator iter(topNode);
PHCompositeNode* dstNode = dynamic_cast<PHCompositeNode*>(iter.findFirst("PHCompositeNode", "DST"));
// create display settings before detector
m_DisplayAction = new PHG4BarrelEcalDisplayAction(Name());
// create detector
m_Detector = new PHG4BarrelEcalDetector(this, topNode, GetParams(), Name());
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 = dstNode;
if (SuperDetector() != "NONE")
{
DetNode = dynamic_cast<PHCompositeNode*>(dstIter.findFirst("PHCompositeNode", SuperDetector()));
if (!DetNode)
{
DetNode = new PHCompositeNode(SuperDetector());
dstNode->addNode(DetNode);
}
}
// create hit output nodes
std::string detector_suffix = SuperDetector();
if (detector_suffix == "NONE")
{
detector_suffix = Name();
}
m_HitNodeName = "G4HIT_" + detector_suffix;
nodes.insert(m_HitNodeName);
m_AbsorberNodeName = "G4HIT_ABSORBER_" + detector_suffix;
if (GetParams()->get_int_param("absorberactive"))
{
nodes.insert(m_AbsorberNodeName);
}
m_SupportNodeName = "G4HIT_SUPPORT_" + detector_suffix;
if (GetParams()->get_int_param("supportactive"))
{
nodes.insert(m_SupportNodeName);
}
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
PHG4BarrelEcalSteppingAction* tmp = new PHG4BarrelEcalSteppingAction(m_Detector, GetParams());
tmp->SetHitNodeName(m_HitNodeName);
tmp->SetAbsorberNodeName(m_AbsorberNodeName);
tmp->SetSupportNodeName(m_SupportNodeName);
m_SteppingAction = tmp;
}
return 0;
}
//_______________________________________________________________________
int PHG4BarrelEcalSubsystem::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* PHG4BarrelEcalSubsystem::GetDetector(void) const
{
return m_Detector;
}
void PHG4BarrelEcalSubsystem::SetDefaultParameters()
{
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 << "BarrelEcal/mapping/towerMap_BEMC_v001.txt";
set_default_string_param("mapping_file", mappingfilename.str());
set_default_double_param("radius", 85.);
set_default_double_param("max_radius", 138.);
set_default_double_param("CenterZ_Shift", -41.);
set_default_double_param("tower_length", 45.5);
set_default_double_param("cone1_h", 30.);
set_default_double_param("cone1_dz", 24.);
set_default_double_param("cone2_h", 20.5);
set_default_double_param("cone2_dz", 25.5);
set_default_double_param("thickness_wall", 0.1);
set_default_double_param("silicon_width_half", 0.05);
set_default_double_param("kapton_width_half", 0.05);
set_default_double_param("SIO2_width_half", 0.05);
set_default_double_param("Carbon_width_half", 1.);
set_default_double_param("support_length", 1.5);
return;
}
void PHG4BarrelEcalSubsystem::SetTowerMappingFile(const std::string& filename)
{
set_string_param("mapping_file", filename);
}
void PHG4BarrelEcalSubsystem::Print(const std::string& what) const
{
std::cout << Name() << " Parameters: " << std::endl;
if (!BeginRunExecuted())
{
std::cout << "Need to execute BeginRun() before parameter printout is meaningful" << std::endl;
std::cout << "To do so either run one or more events or on the command line execute: " << std::endl;
std::cout << "Fun4AllServer *se = Fun4AllServer::instance();" << std::endl;
std::cout << "PHG4Reco *g4 = (PHG4Reco *) se->getSubsysReco(\"PHG4RECO\");" << std::endl;
std::cout << "g4->InitRun(se->topNode());" << std::endl;
std::cout << "PHG4BarrelEcalSubsystem *fhcal = (PHG4BarrelEcalSubsystem *) g4->getSubsystem(\"" << Name() << "\");" << std::endl;
std::cout << "fhcal->Print()" << std::endl;
return;
}
GetParams()->Print();
if (m_SteppingAction)
{
m_SteppingAction->Print(what);
}
return;
}