Analysis Software
Documentation for sPHENIX simulation 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 #pragma GCC diagnostic push
5 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
6 #include <HepMC/GenEvent.h>
7 #pragma GCC diagnostic pop
8 
9 #include <HepMC/GenParticle.h> // for GenParticle
10 #include <HepMC/SimpleVector.h> // for FourVector
11 
12 #include <cmath> // for sqrt
13 #include <cstdlib>
14 #include <iostream>
15 
16 using namespace std;
17 
18 //___________________________________________________________________________
20  : PHPy6GenTrigger(name)
21 {
22  ntriggered_forward_electron = 0;
23  nconsidered_forward_electron = 0;
24 
25  n_em_required = 1;
26  n_ep_required = 1;
27  n_comb_required = 1;
28  pt_required = 0.5;
29  eta_low = 1.0;
30  eta_high = 5.0;
31 
32  RequireElectron = false;
33  RequirePositron = false;
34  RequireOR = false;
35  RequireAND = false;
36  RequireCOMBO = true;
37 }
38 
40 {
41  cout << endl;
42  cout << "PHPy6ForwardElectronTrig Configuration: " << endl;
43  cout << " >=" << n_ep_required << " e+ required" << endl;
44  cout << " >=" << n_em_required << " e- required" << endl;
45  cout << " >=" << n_comb_required << " combined required" << endl;
46  cout << " Electron transverse momentum > " << pt_required << " GeV required" << endl;
47  cout << " " << eta_low << " < eta < " << eta_high << endl;
48 
49  if (RequireElectron) cout << " RequireElectron is set" << endl;
50  if (RequirePositron) cout << " RequirePositron is set" << endl;
51  if (RequireOR) cout << " RequireOR is set" << endl;
52  if (RequireAND) cout << " RequireAND is set" << endl;
53  if (RequireCOMBO) cout << " RequireCOMBINED is set" << endl;
54 
55  cout << endl;
56 }
57 
58 bool PHPy6ForwardElectronTrig::Apply(const HepMC::GenEvent* evt)
59 {
60  // increment counter
62 
63  // Print Out Trigger Information Once, for Posterity
64  static int trig_info_printed = 0;
65  if (trig_info_printed == 0)
66  {
67  PrintConfig();
68  trig_info_printed = 1;
69  }
70 
71  // Check the HepMC particle list -
72 
73  unsigned int n_em_found = 0;
74  unsigned int n_ep_found = 0;
75 
76  for (HepMC::GenEvent::particle_const_iterator p = evt->particles_begin(); p != evt->particles_end(); ++p)
77  {
78  if ((abs((*p)->pdg_id()) == 11) && ((*p)->status() == 1) &&
79  ((*p)->momentum().pseudoRapidity() > eta_low) && ((*p)->momentum().pseudoRapidity() < eta_high) &&
80  (sqrt(pow((*p)->momentum().px(), 2) + pow((*p)->momentum().py(), 2)) > pt_required))
81  {
82  if (((*p)->pdg_id()) == 11) n_em_found++;
83  if (((*p)->pdg_id()) == -11) n_ep_found++;
84  }
85  }
86 
87  if ((RequireOR && ((n_em_found >= n_em_required) || (n_ep_found >= n_ep_required))) ||
88  (RequireElectron && (n_em_found >= n_em_required)) ||
89  (RequirePositron && (n_ep_found >= n_ep_required)) ||
90  (RequireAND && (n_em_found >= n_em_required) && (n_ep_found >= n_ep_required)) ||
91  (RequireCOMBO && (n_em_found + n_ep_found) >= n_comb_required))
92  {
94  return true;
95  }
96 
97  return false;
98 }