ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHPy6ForwardElectronTrig.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHPy6ForwardElectronTrig.cc
2 #include "PHPy6GenTrigger.h"
3 
4 #include <HepMC/GenEvent.h>
5 #include <HepMC/GenParticle.h> // for GenParticle
6 #include <HepMC/SimpleVector.h> // for FourVector
7 
8 #include <cmath> // for sqrt
9 #include <cstdlib>
10 #include <iostream>
11 
12 using namespace std;
13 
14 //___________________________________________________________________________
16  : PHPy6GenTrigger(name)
17 {
20 
21  n_em_required = 1;
22  n_ep_required = 1;
23  n_comb_required = 1;
24  pt_required = 0.5;
25  eta_low = 1.0;
26  eta_high = 5.0;
27 
28  RequireElectron = false;
29  RequirePositron = false;
30  RequireOR = false;
31  RequireAND = false;
32  RequireCOMBO = true;
33 }
34 
36 {
37  cout << endl;
38  cout << "PHPy6ForwardElectronTrig Configuration: " << endl;
39  cout << " >=" << n_ep_required << " e+ required" << endl;
40  cout << " >=" << n_em_required << " e- required" << endl;
41  cout << " >=" << n_comb_required << " combined required" << endl;
42  cout << " Electron transverse momentum > " << pt_required << " GeV required" << endl;
43  cout << " " << eta_low << " < eta < " << eta_high << endl;
44 
45  if (RequireElectron) cout << " RequireElectron is set" << endl;
46  if (RequirePositron) cout << " RequirePositron is set" << endl;
47  if (RequireOR) cout << " RequireOR is set" << endl;
48  if (RequireAND) cout << " RequireAND is set" << endl;
49  if (RequireCOMBO) cout << " RequireCOMBINED is set" << endl;
50 
51  cout << endl;
52 }
53 
54 bool PHPy6ForwardElectronTrig::Apply(const HepMC::GenEvent* evt)
55 {
56  // increment counter
58 
59  // Print Out Trigger Information Once, for Posterity
60  static int trig_info_printed = 0;
61  if (trig_info_printed == 0)
62  {
63  PrintConfig();
64  trig_info_printed = 1;
65  }
66 
67  // Check the HepMC particle list -
68 
69  unsigned int n_em_found = 0;
70  unsigned int n_ep_found = 0;
71 
72  for (HepMC::GenEvent::particle_const_iterator p = evt->particles_begin(); p != evt->particles_end(); ++p)
73  {
74  if ((abs((*p)->pdg_id()) == 11) && ((*p)->status() == 1) &&
75  ((*p)->momentum().pseudoRapidity() > eta_low) && ((*p)->momentum().pseudoRapidity() < eta_high) &&
76  (sqrt(pow((*p)->momentum().px(), 2) + pow((*p)->momentum().py(), 2)) > pt_required))
77  {
78  if (((*p)->pdg_id()) == 11) n_em_found++;
79  if (((*p)->pdg_id()) == -11) n_ep_found++;
80  }
81  }
82 
83  if ((RequireOR && ((n_em_found >= n_em_required) || (n_ep_found >= n_ep_required))) ||
84  (RequireElectron && (n_em_found >= n_em_required)) ||
85  (RequirePositron && (n_ep_found >= n_ep_required)) ||
86  (RequireAND && (n_em_found >= n_em_required) && (n_ep_found >= n_ep_required)) ||
87  (RequireCOMBO && (n_em_found + n_ep_found) >= n_comb_required))
88  {
90  return true;
91  }
92 
93  return false;
94 }