File indexing completed on 2025-08-03 08:12:33
0001 #include "PHPy6GenTrigger.h"
0002 #include "PHPy6ForwardElectronTrig.h"
0003 #include <phool/PHCompositeNode.h>
0004 #include <phool/phool.h>
0005 #include <phool/getClass.h>
0006
0007 #include <phhepmc/PHHepMCGenEvent.h>
0008 #include <HepMC/GenEvent.h>
0009
0010 #include <cstdlib>
0011 #include <iostream>
0012 using namespace std;
0013
0014
0015 PHPy6ForwardElectronTrig::PHPy6ForwardElectronTrig(const std::string &name): PHPy6GenTrigger(name)
0016 {
0017 ntriggered_forward_electron = 0;
0018 nconsidered_forward_electron = 0;
0019
0020 n_em_required = 1;
0021 n_ep_required = 1;
0022 n_comb_required = 1;
0023 pt_required = 0.5;
0024 eta_low = 1.0;
0025 eta_high = 5.0;
0026
0027 RequireElectron = false;
0028 RequirePositron = false;
0029 RequireOR = false;
0030 RequireAND = false;
0031 RequireCOMBO = true;
0032
0033 }
0034
0035 void PHPy6ForwardElectronTrig::PrintConfig()
0036 {
0037 cout << endl;
0038 cout << "PHPy6ForwardElectronTrig Configuration: " << endl;
0039 cout << " >=" << n_ep_required << " e+ required" << endl;
0040 cout << " >=" << n_em_required << " e- required" << endl;
0041 cout << " >=" << n_comb_required << " combined required" << endl;
0042 cout << " Electron transverse momentum > " << pt_required << " GeV required" << endl;
0043 cout << " " << eta_low << " < eta < " << eta_high << endl;
0044
0045 if(RequireElectron) cout << " RequireElectron is set" << endl;
0046 if(RequirePositron) cout << " RequirePositron is set" << endl;
0047 if(RequireOR) cout << " RequireOR is set" << endl;
0048 if(RequireAND) cout << " RequireAND is set" << endl;
0049 if(RequireCOMBO) cout << " RequireCOMBINED is set" << endl;
0050
0051 cout << endl;
0052 }
0053
0054 bool PHPy6ForwardElectronTrig::Apply( const HepMC::GenEvent* evt )
0055 {
0056
0057
0058 ++nconsidered_forward_electron;
0059
0060
0061 static int trig_info_printed = 0;
0062 if ( trig_info_printed==0 )
0063 {
0064 PrintConfig();
0065 trig_info_printed = 1;
0066 }
0067
0068
0069
0070 unsigned int n_em_found = 0;
0071 unsigned int n_ep_found = 0;
0072
0073 for ( HepMC::GenEvent::particle_const_iterator p
0074 = evt->particles_begin(); p != evt->particles_end(); ++p ){
0075 if ( (abs((*p)->pdg_id()) == 11) && ((*p)->status()==1) &&
0076 ((*p)->momentum().pseudoRapidity() > eta_low) && ((*p)->momentum().pseudoRapidity() < eta_high) &&
0077 (sqrt(pow((*p)->momentum().px(),2) + pow((*p)->momentum().py(),2))>pt_required) ) {
0078 if(((*p)->pdg_id()) == 11) n_em_found++;
0079 if(((*p)->pdg_id()) == -11) n_ep_found++;
0080 }
0081 }
0082
0083 if( (RequireOR && ((n_em_found>=n_em_required)||(n_ep_found>=n_ep_required)) ) ||
0084 (RequireElectron && (n_em_found>=n_em_required)) ||
0085 (RequirePositron && (n_ep_found>=n_ep_required)) ||
0086 (RequireAND && (n_em_found>=n_em_required) && (n_ep_found>=n_ep_required)) ||
0087 (RequireCOMBO && (n_em_found+n_ep_found)>=n_comb_required) )
0088 {
0089 ++ntriggered_forward_electron;
0090 return true;
0091 }
0092
0093 return false;
0094
0095 }