Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHPy6JetTrigger.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHPy6JetTrigger.C
1 
2 #include "PHPy6GenTrigger.h"
3 #include "PHPy6JetTrigger.h"
5 #include <phool/phool.h>
6 #include <phool/getClass.h>
7 
9 #include <HepMC/GenEvent.h>
10 
11 // fastjet includes
12 #include <fastjet/JetDefinition.hh>
13 #include <fastjet/PseudoJet.hh>
14 #include <fastjet/ClusterSequence.hh>
15 #include <fastjet/SISConePlugin.hh>
16 #include <cassert>
17 
18 using namespace std;
19 
20 //__________________________________________________________
22  PHPy6GenTrigger(name),
23  _theEtaHigh(4.0),
24  _theEtaLow(1.0),
25  _minPt(10.0),
26  _R(1.0)
27  {}
28 
30  if (_verbosity > 0) PrintConfig();
31 }
32 
33 bool PHPy6JetTrigger::Apply(const HepMC::GenEvent* evt) {
34 
35 
36  // Loop over all particles in the event
37  int idx = 0;
38  std::vector<fastjet::PseudoJet> pseudojets;
39  for ( HepMC::GenEvent::particle_const_iterator p
40  = evt->particles_begin(); p != evt->particles_end(); ++p ){
41 
42  idx++;
43  if ( ((*p)->status()!=1) != 0) continue;
44 
45  // remove some particles (muons, taus, neutrinos)...
46  // 12 == nu_e
47  // 13 == muons
48  // 14 == nu_mu
49  // 15 == taus
50  // 16 == nu_tau
51  if ((abs(((*p)->pdg_id())) >= 12) && (abs(((*p)->pdg_id())) <= 16)) continue;
52 
53  // acceptance... _etamin,_etamax
54  if (((*p)->momentum().px() == 0.0) && ((*p)->momentum().py() == 0.0)) continue; // avoid pt=0
55  if ( (((*p)->momentum().pseudoRapidity()) < _theEtaLow) ||
56  (((*p)->momentum().pseudoRapidity()) > _theEtaHigh)) continue;
57 
58 
59  fastjet::PseudoJet pseudojet ((*p)->momentum().px(),
60  (*p)->momentum().py(),
61  (*p)->momentum().pz(),
62  (*p)->momentum().e());
63  pseudojet.set_user_index(idx);
64  pseudojets.push_back(pseudojet);
65 
66  }
67 
68  // Call FastJet
69 
70  fastjet::JetDefinition *jetdef = new fastjet::JetDefinition(fastjet::antikt_algorithm,_R, fastjet::E_scheme,fastjet::Best);
71  fastjet::ClusterSequence jetFinder(pseudojets,*jetdef);
72  std::vector<fastjet::PseudoJet> fastjets = jetFinder.inclusive_jets();
73  delete jetdef;
74 
75  bool jetFound = false;
76  double max_pt = -1;
77  for (unsigned int ijet = 0; ijet < fastjets.size(); ++ijet) {
78 
79  const double pt = sqrt(pow(fastjets[ijet].px(),2) + pow(fastjets[ijet].py(),2));
80 
81  if (pt > max_pt) max_pt = pt;
82 
83  if(pt > _minPt){
84  jetFound = true;
85  break;
86  }
87  }
88 
89  if (_verbosity > 2) {
90  cout << "PHPy6JetTrigger::Apply - max_pt = "<<max_pt<<", and jetFound = "<<jetFound<<endl;
91  }
92 
93  return jetFound;
94 }
95 
96 void PHPy6JetTrigger::SetEtaHighLow(double etaHigh, double etaLow) {
97 
98  _theEtaHigh = etaHigh;
99  _theEtaLow = etaLow;
100 
102  {
104  }
105 
106 }
107 
109  _minPt = minPt;
110 }
111 
113  _R = R;
114 }
115 
117  cout << "---------------- PHPy6JetTrigger::PrintConfig --------------------" << endl;
118 
119  cout << " Particles EtaCut: " << _theEtaLow << " < eta < " << _theEtaHigh << endl;
120  cout << " Minimum Jet pT: " << _minPt << " GeV/c" << endl;
121  cout << " Anti-kT Radius: " << _R << endl;
122  cout << "-----------------------------------------------------------------------" << endl;
123 }