File indexing completed on 2025-08-03 08:12:34
0001 #include "PHPy6GenTrigger.h"
0002 #include "PHPy6ParticleTrigger.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 PHPy6ParticleTrigger::PHPy6ParticleTrigger(const std::string &name):
0016 PHPy6GenTrigger(name),
0017
0018 _theParticleType(0),
0019 _Q2Min(0.0),
0020
0021 _doTheParticleType(false),
0022 _doQ2Min(false)
0023 {}
0024
0025
0026 bool PHPy6ParticleTrigger::Apply( const HepMC::GenEvent* evt )
0027 {
0028
0029 if(_doQ2Min && evt->pdf_info()->scalePDF() < _Q2Min) return false;
0030
0031
0032
0033
0034
0035
0036
0037
0038 if(!_doTheParticleType) return true;
0039
0040
0041 for ( HepMC::GenEvent::particle_const_iterator p
0042 = evt->particles_begin(); p != evt->particles_end(); ++p ){
0043
0044 int pi_num = 0;
0045
0046 if((*p)->pdg_id() != _theParticleType) continue;
0047
0048
0049
0050
0051 for ( HepMC::GenVertex::particle_iterator decay
0052 = (*p)->end_vertex()->
0053 particles_begin(HepMC::children);
0054 decay != (*p)->end_vertex()->
0055 particles_end(HepMC::children);
0056 ++decay )
0057 {
0058
0059 if(!(*decay)->end_vertex()){
0060 if(abs((*decay)->pdg_id()) == 211) pi_num++;
0061 }
0062
0063
0064 else if((*decay)->end_vertex()){
0065
0066
0067 for ( HepMC::GenVertex::particle_iterator second_decay
0068 = (*decay)->end_vertex()->
0069 particles_begin(HepMC::children);
0070 second_decay != (*decay)->end_vertex()->
0071 particles_end(HepMC::children);
0072 ++second_decay )
0073 {
0074 if (abs((*second_decay)->pdg_id()) == 211) pi_num++;
0075
0076 if ((*second_decay)->status() != 1){
0077 for ( HepMC::GenVertex::particle_iterator third_decay
0078 = (*second_decay)->end_vertex()->
0079 particles_begin(HepMC::children);
0080 third_decay != (*second_decay)->end_vertex()->
0081 particles_end(HepMC::children);
0082 ++third_decay )
0083 {
0084 if(abs((*third_decay)->pdg_id()) == 211) pi_num++;
0085 }
0086 }
0087 }
0088 }
0089 }
0090
0091 if (pi_num == 3) return true;
0092
0093 }
0094
0095 return false;
0096
0097 }
0098
0099 void PHPy6ParticleTrigger::SetParticleType(int pid) {
0100 _theParticleType = pid;
0101 _doTheParticleType = true;
0102 }
0103
0104 void PHPy6ParticleTrigger::SetQ2Min(double Q2) {
0105 _Q2Min = Q2;
0106 _doQ2Min = true;
0107 }