Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TruthJetInput.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TruthJetInput.cc
1 
2 #include "TruthJetInput.h"
3 
4 
5 #include <g4main/PHG4Particle.h>
7 #include <jetbase/Jet.h>
8 #include <jetbase/Jetv2.h>
9 #include <phool/getClass.h>
10 #include <phool/phool.h> // for PHWHERE
11 
12 // standard includes
13 #include <algorithm> // std::find
14 #include <cmath> // for asinh, sqrt
15 #include <cstdlib>
16 #include <iostream>
17 #include <map> // for _Rb_tree_const_iterator
18 #include <utility> // for pair
19 #include <vector>
20 
22  : m_Input(input)
23 {
24 }
25 
26 void TruthJetInput::identify(std::ostream &os)
27 {
28  os << " TruthJetInput: G4TruthInfo to Jet::PARTICLE";
29  if (use_embed_stream())
30  {
31  os << ". Processing embedded streams: ";
32  for (int it : m_EmbedID)
33  {
34  os << it << ", ";
35  }
36  }
37  os << std::endl;
38 }
39 
40 std::vector<Jet *> TruthJetInput::get_input(PHCompositeNode *topNode)
41 {
42  if (Verbosity() > 0) std::cout << "TruthJetInput::process_event -- entered" << std::endl;
43 
44  // Pull the reconstructed track information off the node tree...
45  PHG4TruthInfoContainer *truthinfo = findNode::getClass<PHG4TruthInfoContainer>(topNode, "G4TruthInfo");
46  if (!truthinfo)
47  {
48  std::cout << PHWHERE << " ERROR: Can't find G4TruthInfo" << std::endl;
49  return std::vector<Jet *>();
50  }
51 
52  std::vector<Jet *> pseudojets;
54  for (PHG4TruthInfoContainer::ConstIterator iter = range.first;
55  iter != range.second;
56  ++iter)
57  {
58  PHG4Particle *part = iter->second;
59 
60  if (use_embed_stream())
61  {
62  const int this_embed_id = truthinfo->isEmbeded(part->get_track_id());
63 
64  if (std::find(m_EmbedID.begin(), m_EmbedID.end(), this_embed_id) == m_EmbedID.end())
65  {
66  continue; // reject particle as it is not in the interested embedding stream.
67  }
68  }
69 
70  // remove some particles (muons, taus, neutrinos)...
71  // 12 == nu_e
72  // 13 == muons
73  // 14 == nu_mu
74  // 15 == taus
75  // 16 == nu_tau
76  if ((abs(part->get_pid()) >= 12) && (abs(part->get_pid()) <= 16)) continue;
77 
78  // remove acceptance... _etamin,_etamax
79  if ((part->get_px() == 0.0) && (part->get_py() == 0.0)) continue; // avoid pt=0
80  float eta = asinh(part->get_pz() / sqrt(pow(part->get_px(), 2) + pow(part->get_py(), 2)));
81  if (eta < m_EtaMin) continue;
82  if (eta > m_EtaMax) continue;
83 
84  Jet *jet = new Jetv2();
85  jet->set_px(part->get_px());
86  jet->set_py(part->get_py());
87  jet->set_pz(part->get_pz());
88  jet->set_e(part->get_e());
89  jet->insert_comp(Jet::PARTICLE, part->get_track_id());
90  pseudojets.push_back(jet);
91  }
92 
93  if (Verbosity() > 0) std::cout << "TruthJetInput::process_event -- exited" << std::endl;
94 
95  return pseudojets;
96 }