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