forked from sPHENIX-Collaboration/coresoftware
/
TowerJetInput.cc
249 lines (222 loc) · 7.33 KB
/
TowerJetInput.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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
#include "TowerJetInput.h"
#include "Jet.h"
#include "Jetv1.h"
#include <calobase/RawTower.h>
#include <calobase/RawTowerContainer.h>
#include <calobase/RawTowerGeom.h>
#include <calobase/RawTowerGeomContainer.h>
#include <g4vertex/GlobalVertex.h>
#include <g4vertex/GlobalVertexMap.h>
#include <phool/getClass.h>
#include <cassert>
#include <cmath> // for asinh, atan2, cos, cosh
#include <iostream>
#include <map> // for _Rb_tree_const_iterator
#include <utility> // for pair
#include <vector>
using namespace std;
TowerJetInput::TowerJetInput(Jet::SRC input)
: _input(input)
{
}
void TowerJetInput::identify(std::ostream &os)
{
os << " TowerJetInput: ";
if (_input == Jet::CEMC_TOWER)
os << "TOWER_CEMC to Jet::CEMC_TOWER";
if (_input == Jet::EEMC_TOWER)
os << "TOWER_EEMC to Jet::EEMC_TOWER";
else if (_input == Jet::HCALIN_TOWER)
os << "TOWER_HCALIN to Jet::HCALIN_TOWER";
else if (_input == Jet::HCALOUT_TOWER)
os << "TOWER_HCALOUT to Jet::HCALOUT_TOWER";
else if (_input == Jet::FEMC_TOWER)
os << "TOWER_FEMC to Jet::FEMC_TOWER";
else if (_input == Jet::FHCAL_TOWER)
os << "TOWER_FHCAL to Jet::FHCAL_TOWER";
os << endl;
}
std::vector<Jet *> TowerJetInput::get_input(PHCompositeNode *topNode)
{
if (Verbosity() > 0) cout << "TowerJetInput::process_event -- entered" << endl;
GlobalVertexMap *vertexmap = findNode::getClass<GlobalVertexMap>(topNode, "GlobalVertexMap");
if (!vertexmap)
{
cout << "TowerJetInput::get_input - Fatal Error - GlobalVertexMap node is missing. Please turn on the do_global flag in the main macro in order to reconstruct the global vertex." << endl;
assert(vertexmap); // force quit
return std::vector<Jet *>();
}
if (vertexmap->empty())
{
cout << "TowerJetInput::get_input - Fatal Error - GlobalVertexMap node is empty. Please turn on the do_bbc or tracking reco flags in the main macro in order to reconstruct the global vertex." << endl;
return std::vector<Jet *>();
}
RawTowerContainer *towers = nullptr;
RawTowerGeomContainer *geom = nullptr;
if (_input == Jet::CEMC_TOWER)
{
towers = findNode::getClass<RawTowerContainer>(topNode, "TOWER_CALIB_CEMC");
geom = findNode::getClass<RawTowerGeomContainer>(topNode, "TOWERGEOM_CEMC");
if (!towers || !geom)
{
return std::vector<Jet *>();
}
}
else if (_input == Jet::EEMC_TOWER)
{
towers = findNode::getClass<RawTowerContainer>(topNode, "TOWER_CALIB_EEMC");
geom = findNode::getClass<RawTowerGeomContainer>(topNode, "TOWERGEOM_EEMC");
if (!towers || !geom)
{
return std::vector<Jet *>();
}
}
else if (_input == Jet::HCALIN_TOWER)
{
towers = findNode::getClass<RawTowerContainer>(topNode, "TOWER_CALIB_HCALIN");
geom = findNode::getClass<RawTowerGeomContainer>(topNode, "TOWERGEOM_HCALIN");
if (!towers || !geom)
{
return std::vector<Jet *>();
}
}
else if (_input == Jet::HCALOUT_TOWER)
{
towers = findNode::getClass<RawTowerContainer>(topNode, "TOWER_CALIB_HCALOUT");
geom = findNode::getClass<RawTowerGeomContainer>(topNode, "TOWERGEOM_HCALOUT");
if (!towers || !geom)
{
return std::vector<Jet *>();
}
}
else if (_input == Jet::FEMC_TOWER)
{
towers = findNode::getClass<RawTowerContainer>(topNode, "TOWER_CALIB_FEMC");
geom = findNode::getClass<RawTowerGeomContainer>(topNode, "TOWERGEOM_FEMC");
if (!towers || !geom)
{
return std::vector<Jet *>();
}
}
else if (_input == Jet::FHCAL_TOWER)
{
towers = findNode::getClass<RawTowerContainer>(topNode, "TOWER_CALIB_FHCAL");
geom = findNode::getClass<RawTowerGeomContainer>(topNode, "TOWERGEOM_FHCAL");
if (!towers || !geom)
{
return std::vector<Jet *>();
}
}
else if (_input == Jet::CEMC_TOWER_RETOWER)
{
towers = findNode::getClass<RawTowerContainer>(topNode, "TOWER_CALIB_CEMC_RETOWER");
geom = findNode::getClass<RawTowerGeomContainer>(topNode, "TOWERGEOM_HCALIN");
if (!towers || !geom)
{
return std::vector<Jet *>();
}
}
else if (_input == Jet::CEMC_TOWER_SUB1)
{
towers = findNode::getClass<RawTowerContainer>(topNode, "TOWER_CALIB_CEMC_RETOWER_SUB1");
geom = findNode::getClass<RawTowerGeomContainer>(topNode, "TOWERGEOM_HCALIN");
if (!towers || !geom)
{
return std::vector<Jet *>();
}
}
else if (_input == Jet::HCALIN_TOWER_SUB1)
{
towers = findNode::getClass<RawTowerContainer>(topNode, "TOWER_CALIB_HCALIN_SUB1");
geom = findNode::getClass<RawTowerGeomContainer>(topNode, "TOWERGEOM_HCALIN");
if (!towers || !geom)
{
return std::vector<Jet *>();
}
}
else if (_input == Jet::HCALOUT_TOWER_SUB1)
{
towers = findNode::getClass<RawTowerContainer>(topNode, "TOWER_CALIB_HCALOUT_SUB1");
geom = findNode::getClass<RawTowerGeomContainer>(topNode, "TOWERGEOM_HCALOUT");
if (!towers || !geom)
{
return std::vector<Jet *>();
}
}
else if (_input == Jet::CEMC_TOWER_SUB1CS)
{
towers = findNode::getClass<RawTowerContainer>(topNode, "TOWER_CALIB_CEMC_RETOWER_SUB1CS");
geom = findNode::getClass<RawTowerGeomContainer>(topNode, "TOWERGEOM_HCALIN");
if (!towers || !geom)
{
return std::vector<Jet *>();
}
}
else if (_input == Jet::HCALIN_TOWER_SUB1CS)
{
towers = findNode::getClass<RawTowerContainer>(topNode, "TOWER_CALIB_HCALIN_SUB1CS");
geom = findNode::getClass<RawTowerGeomContainer>(topNode, "TOWERGEOM_HCALIN");
if (!towers || !geom)
{
return std::vector<Jet *>();
}
}
else if (_input == Jet::HCALOUT_TOWER_SUB1CS)
{
towers = findNode::getClass<RawTowerContainer>(topNode, "TOWER_CALIB_HCALOUT_SUB1CS");
geom = findNode::getClass<RawTowerGeomContainer>(topNode, "TOWERGEOM_HCALOUT");
if (!towers || !geom)
{
return std::vector<Jet *>();
}
}
else
{
return std::vector<Jet *>();
}
// first grab the event vertex or bail
GlobalVertex *vtx = vertexmap->begin()->second;
float vtxz = NAN;
if (vtx)
vtxz = vtx->get_z();
else
return std::vector<Jet *>();
if (isnan(vtxz))
{
static bool once = true;
if (once)
{
once = false;
cout << "TowerJetInput::get_input - WARNING - vertex is NAN. Drop all tower inputs (further NAN-vertex warning will be suppressed)." << endl;
}
return std::vector<Jet *>();
}
std::vector<Jet *> pseudojets;
RawTowerContainer::ConstRange begin_end = towers->getTowers();
RawTowerContainer::ConstIterator rtiter;
for (rtiter = begin_end.first; rtiter != begin_end.second; ++rtiter)
{
RawTower *tower = rtiter->second;
RawTowerGeom *tower_geom =
geom->get_tower_geometry(tower->get_key());
assert(tower_geom);
double r = tower_geom->get_center_radius();
double phi = atan2(tower_geom->get_center_y(), tower_geom->get_center_x());
double z0 = tower_geom->get_center_z();
double z = z0 - vtxz;
double eta = asinh(z / r); // eta after shift from vertex
double pt = tower->get_energy() / cosh(eta);
double px = pt * cos(phi);
double py = pt * sin(phi);
double pz = pt * sinh(eta);
Jet *jet = new Jetv1();
jet->set_px(px);
jet->set_py(py);
jet->set_pz(pz);
jet->set_e(tower->get_energy());
jet->insert_comp(_input, tower->get_id());
pseudojets.push_back(jet);
}
if (Verbosity() > 0) cout << "TowerJetInput::process_event -- exited" << endl;
return pseudojets;
}