forked from sPHENIX-Collaboration/coresoftware
/
ClusterJetInput.cc
165 lines (145 loc) · 4.46 KB
/
ClusterJetInput.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
#include "ClusterJetInput.h"
#include "Jet.h"
#include "Jetv1.h"
#include <phool/getClass.h>
#include <calobase/RawCluster.h>
#include <calobase/RawClusterContainer.h>
#include <calobase/RawClusterUtility.h>
#include <calobase/RawTowerGeomContainer.h>
#include <g4vertex/GlobalVertex.h>
#include <g4vertex/GlobalVertexMap.h>
#include <CLHEP/Vector/ThreeVector.h> // for Hep3Vector
// standard includes
#include <cassert>
#include <iostream>
#include <map> // for _Rb_tree_const_iterator
#include <utility> // for pair
#include <vector>
using namespace std;
ClusterJetInput::ClusterJetInput(Jet::SRC input)
: _verbosity(0)
, _input(input)
{
}
void ClusterJetInput::identify(std::ostream &os)
{
os << " ClusterJetInput: ";
if (_input == Jet::CEMC_CLUSTER)
os << "CLUSTER_CEMC to Jet::CEMC_CLUSTER";
if (_input == Jet::EEMC_CLUSTER)
os << "CLUSTER_EEMC to Jet::EEMC_CLUSTER";
else if (_input == Jet::HCALIN_CLUSTER)
os << "CLUSTER_HCALIN to Jet::HCALIN_CLUSTER";
else if (_input == Jet::HCALOUT_CLUSTER)
os << "CLUSTER_HCALOUT to Jet::HCALOUT_CLUSTER";
os << endl;
}
std::vector<Jet *> ClusterJetInput::get_input(PHCompositeNode *topNode)
{
if (_verbosity > 0) cout << "ClusterJetInput::process_event -- entered" << endl;
GlobalVertexMap *vertexmap = findNode::getClass<GlobalVertexMap>(topNode, "GlobalVertexMap");
if (!vertexmap)
{
cout << "ClusterJetInput::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 << "ClusterJetInput::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 *>();
}
RawClusterContainer *clusters = nullptr;
if (_input == Jet::CEMC_CLUSTER)
{
clusters = findNode::getClass<RawClusterContainer>(topNode, "CLUSTER_CEMC");
if (!clusters)
{
return std::vector<Jet *>();
}
}
else if (_input == Jet::EEMC_CLUSTER)
{
clusters = findNode::getClass<RawClusterContainer>(topNode, "CLUSTER_EEMC");
if (!clusters)
{
return std::vector<Jet *>();
}
}
else if (_input == Jet::HCALIN_CLUSTER)
{
clusters = findNode::getClass<RawClusterContainer>(topNode, "CLUSTER_HCALIN");
if (!clusters)
{
return std::vector<Jet *>();
}
}
else if (_input == Jet::HCALOUT_CLUSTER)
{
clusters = findNode::getClass<RawClusterContainer>(topNode, "CLUSTER_HCALOUT");
if (!clusters)
{
return std::vector<Jet *>();
}
}
else if (_input == Jet::HCAL_TOPO_CLUSTER)
{
clusters = findNode::getClass<RawClusterContainer>(topNode, "TOPOCLUSTER_HCAL");
if (!clusters)
{
return std::vector<Jet *>();
}
}
else if (_input == Jet::ECAL_TOPO_CLUSTER)
{
clusters = findNode::getClass<RawClusterContainer>(topNode, "TOPOCLUSTER_EMCAL");
if (!clusters)
{
return std::vector<Jet *>();
}
}
else if (_input == Jet::FEMC_CLUSTER)
{
clusters = findNode::getClass<RawClusterContainer>(topNode, "CLUSTER_FEMC");
if (!clusters)
{
return std::vector<Jet *>();
}
}
else if (_input == Jet::FHCAL_CLUSTER)
{
clusters = findNode::getClass<RawClusterContainer>(topNode, "CLUSTER_FHCAL");
if (!clusters)
{
return std::vector<Jet *>();
}
}
else
{
return std::vector<Jet *>();
}
// first grab the event vertex or bail
GlobalVertex *vtx = vertexmap->begin()->second;
CLHEP::Hep3Vector vertex;
if (vtx)
vertex.set(vtx->get_x(), vtx->get_y(), vtx->get_z());
else
return std::vector<Jet *>();
std::vector<Jet *> pseudojets;
RawClusterContainer::ConstRange begin_end = clusters->getClusters();
RawClusterContainer::ConstIterator rtiter;
for (rtiter = begin_end.first; rtiter != begin_end.second; ++rtiter)
{
RawCluster *cluster = rtiter->second;
CLHEP::Hep3Vector E_vec_cluster = RawClusterUtility::GetEVec(*cluster, vertex);
Jet *jet = new Jetv1();
jet->set_px(E_vec_cluster.x());
jet->set_py(E_vec_cluster.y());
jet->set_pz(E_vec_cluster.z());
jet->set_e(cluster->get_energy());
jet->insert_comp(_input, cluster->get_id());
pseudojets.push_back(jet);
}
if (_verbosity > 0) cout << "ClusterJetInput::process_event -- exited" << endl;
return pseudojets;
}