EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ClusterJetInput.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ClusterJetInput.cc
1 
2 #include "ClusterJetInput.h"
3 
4 #include "Jet.h"
5 #include "Jetv1.h"
6 
7 #include <phool/getClass.h>
8 
9 #include <calobase/RawCluster.h>
10 #include <calobase/RawClusterContainer.h>
11 #include <calobase/RawClusterUtility.h>
12 #include <calobase/RawTowerGeomContainer.h>
13 
14 #include <g4vertex/GlobalVertex.h>
16 
17 #include <CLHEP/Vector/ThreeVector.h> // for Hep3Vector
18 
19 // standard includes
20 #include <cassert>
21 #include <iostream>
22 #include <map> // for _Rb_tree_const_iterator
23 #include <utility> // for pair
24 #include <vector>
25 
26 using namespace std;
27 
29  : _verbosity(0)
30  , _input(input)
31 {
32 }
33 
34 void ClusterJetInput::identify(std::ostream &os)
35 {
36  os << " ClusterJetInput: ";
38  os << "CLUSTER_CEMC to Jet::CEMC_CLUSTER";
40  os << "CLUSTER_EEMC to Jet::EEMC_CLUSTER";
41  else if (_input == Jet::HCALIN_CLUSTER)
42  os << "CLUSTER_HCALIN to Jet::HCALIN_CLUSTER";
43  else if (_input == Jet::HCALOUT_CLUSTER)
44  os << "CLUSTER_HCALOUT to Jet::HCALOUT_CLUSTER";
45  os << endl;
46 }
47 
48 std::vector<Jet *> ClusterJetInput::get_input(PHCompositeNode *topNode)
49 {
50  if (_verbosity > 0) cout << "ClusterJetInput::process_event -- entered" << endl;
51  GlobalVertexMap *vertexmap = findNode::getClass<GlobalVertexMap>(topNode, "GlobalVertexMap");
52  if (!vertexmap)
53  {
54  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;
55  assert(vertexmap); // force quit
56 
57  return std::vector<Jet *>();
58  }
59 
60  if (vertexmap->empty())
61  {
62  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;
63  return std::vector<Jet *>();
64  }
65 
66  RawClusterContainer *clusters = nullptr;
68  {
69  clusters = findNode::getClass<RawClusterContainer>(topNode, "CLUSTER_CEMC");
70  if (!clusters)
71  {
72  return std::vector<Jet *>();
73  }
74  }
75  else if (_input == Jet::EEMC_CLUSTER)
76  {
77  clusters = findNode::getClass<RawClusterContainer>(topNode, "CLUSTER_EEMC");
78  if (!clusters)
79  {
80  return std::vector<Jet *>();
81  }
82  }
83  else if (_input == Jet::HCALIN_CLUSTER)
84  {
85  clusters = findNode::getClass<RawClusterContainer>(topNode, "CLUSTER_HCALIN");
86  if (!clusters)
87  {
88  return std::vector<Jet *>();
89  }
90  }
91  else if (_input == Jet::HCALOUT_CLUSTER)
92  {
93  clusters = findNode::getClass<RawClusterContainer>(topNode, "CLUSTER_HCALOUT");
94  if (!clusters)
95  {
96  return std::vector<Jet *>();
97  }
98  }
99  else if (_input == Jet::HCAL_TOPO_CLUSTER)
100  {
101  clusters = findNode::getClass<RawClusterContainer>(topNode, "TOPOCLUSTER_HCAL");
102  if (!clusters)
103  {
104  return std::vector<Jet *>();
105  }
106  }
107  else if (_input == Jet::ECAL_TOPO_CLUSTER)
108  {
109  clusters = findNode::getClass<RawClusterContainer>(topNode, "TOPOCLUSTER_EMCAL");
110  if (!clusters)
111  {
112  return std::vector<Jet *>();
113  }
114  }
115  else if (_input == Jet::FEMC_CLUSTER)
116  {
117  clusters = findNode::getClass<RawClusterContainer>(topNode, "CLUSTER_FEMC");
118  if (!clusters)
119  {
120  return std::vector<Jet *>();
121  }
122  }
123  else if (_input == Jet::FHCAL_CLUSTER)
124  {
125  clusters = findNode::getClass<RawClusterContainer>(topNode, "CLUSTER_FHCAL");
126  if (!clusters)
127  {
128  return std::vector<Jet *>();
129  }
130  }
131  else
132  {
133  return std::vector<Jet *>();
134  }
135 
136  // first grab the event vertex or bail
137  GlobalVertex *vtx = vertexmap->begin()->second;
138  CLHEP::Hep3Vector vertex;
139  if (vtx)
140  vertex.set(vtx->get_x(), vtx->get_y(), vtx->get_z());
141  else
142  return std::vector<Jet *>();
143 
144  std::vector<Jet *> pseudojets;
145  RawClusterContainer::ConstRange begin_end = clusters->getClusters();
147  for (rtiter = begin_end.first; rtiter != begin_end.second; ++rtiter)
148  {
149  RawCluster *cluster = rtiter->second;
150 
151  CLHEP::Hep3Vector E_vec_cluster = RawClusterUtility::GetEVec(*cluster, vertex);
152 
153  Jet *jet = new Jetv1();
154  jet->set_px(E_vec_cluster.x());
155  jet->set_py(E_vec_cluster.y());
156  jet->set_pz(E_vec_cluster.z());
157  jet->set_e(cluster->get_energy());
158  jet->insert_comp(_input, cluster->get_id());
159  pseudojets.push_back(jet);
160  }
161 
162  if (_verbosity > 0) cout << "ClusterJetInput::process_event -- exited" << endl;
163 
164  return pseudojets;
165 }