ECCE @ EIC 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 #include "Jet.h"
5 #include "Jetv1.h"
6 
7 #include <g4main/PHG4Particle.h>
9 
10 #include <phool/getClass.h>
11 #include <phool/phool.h> // for PHWHERE
12 
13 // standard includes
14 #include <algorithm> // std::find
15 #include <cmath> // for asinh, sqrt
16 #include <cstdlib>
17 #include <iostream>
18 #include <map> // for _Rb_tree_const_iterator
19 #include <utility> // for pair
20 #include <vector>
21 
22 using namespace std;
23 
25  : _input(input)
26  , _eta_min(-4.0)
27  , _eta_max(+4.0)
28 {
29 }
30 
31 void TruthJetInput::identify(std::ostream &os)
32 {
33  os << " TruthJetInput: G4TruthInfo to Jet::PARTICLE";
34  if (use_embed_stream())
35  {
36  os << ". Processing embedded streams: ";
37  for (std::vector<int>::const_iterator it = _embed_id.begin(); it != _embed_id.end(); ++it)
38  {
39  os << (*it) << ", ";
40  }
41  }
42  os << endl;
43 }
44 
45 std::vector<Jet *> TruthJetInput::get_input(PHCompositeNode *topNode)
46 {
47  if (Verbosity() > 0) cout << "TruthJetInput::process_event -- entered" << endl;
48 
49  // Pull the reconstructed track information off the node tree...
50  PHG4TruthInfoContainer *truthinfo = findNode::getClass<PHG4TruthInfoContainer>(topNode, "G4TruthInfo");
51  if (!truthinfo)
52  {
53  cerr << PHWHERE << " ERROR: Can't find G4TruthInfo" << endl;
54  return std::vector<Jet *>();
55  }
56 
57  std::vector<Jet *> pseudojets;
59  for (PHG4TruthInfoContainer::ConstIterator iter = range.first;
60  iter != range.second;
61  ++iter)
62  {
63  PHG4Particle *part = iter->second;
64 
65  if (use_embed_stream())
66  {
67  const int this_embed_id = truthinfo->isEmbeded(part->get_track_id());
68 
69  if (std::find(_embed_id.begin(), _embed_id.end(), this_embed_id) == _embed_id.end())
70  {
71  continue; // reject particle as it is not in the interested embedding stream.
72  }
73  }
74 
75  // remove some particles (muons, taus, neutrinos)...
76  // 12 == nu_e
77  // 13 == muons
78  // 14 == nu_mu
79  // 15 == taus
80  // 16 == nu_tau
81  if ((abs(part->get_pid()) >= 12) && (abs(part->get_pid()) <= 16)) continue;
82 
83  // remove acceptance... _etamin,_etamax
84  if ((part->get_px() == 0.0) && (part->get_py() == 0.0)) continue; // avoid pt=0
85  float eta = asinh(part->get_pz() / sqrt(pow(part->get_px(), 2) + pow(part->get_py(), 2)));
86  if (eta < _eta_min) continue;
87  if (eta > _eta_max) continue;
88 
89  Jet *jet = new Jetv1();
90  jet->set_px(part->get_px());
91  jet->set_py(part->get_py());
92  jet->set_pz(part->get_pz());
93  jet->set_e(part->get_e());
94  jet->insert_comp(Jet::PARTICLE, part->get_track_id());
95  pseudojets.push_back(jet);
96  }
97 
98  if (Verbosity() > 0) cout << "TruthJetInput::process_event -- exited" << endl;
99 
100  return pseudojets;
101 }