Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHPy6ParticleTrigger.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHPy6ParticleTrigger.C
1 #include "PHPy6GenTrigger.h"
2 #include "PHPy6ParticleTrigger.h"
4 #include <phool/phool.h>
5 #include <phool/getClass.h>
6 
8 #include <HepMC/GenEvent.h>
9 
10 #include <cstdlib>
11 #include <iostream>
12 using namespace std;
13 
14 //___________________________________________________________________________
16  PHPy6GenTrigger(name),
17 
18  _theParticleType(0),
19  _Q2Min(0.0),
20 
21  _doTheParticleType(false),
22  _doQ2Min(false)
23 {}
24 
25 
26 bool PHPy6ParticleTrigger::Apply( const HepMC::GenEvent* evt )
27 {
28 
29  if(_doQ2Min && evt->pdf_info()->scalePDF() < _Q2Min) return false;
30  // cout<<"EVENT"<<endl;
31  /*
32  for ( HepMC::GenEvent::particle_const_iterator p
33  = evt->particles_begin(); p != evt->particles_end(); ++p ){
34  if((*p)->status()==1) cout<<(*p)->pdg_id()<<" "<<(*p)->momentum().eta()<<" "<<sqrt(pow((*p)->momentum().px(),2) + pow((*p)->momentum().py(),2))<<endl;
35 
36  }
37  */
38  if(!_doTheParticleType) return true;
39 
40  // Loop over all particles in the event
41  for ( HepMC::GenEvent::particle_const_iterator p
42  = evt->particles_begin(); p != evt->particles_end(); ++p ){
43 
44  int pi_num = 0;
45 
46  if((*p)->pdg_id() != _theParticleType) continue;
47 
48  //if((*p)->pdg_id() == _theParticleType) return true;
49 
50 
51  for ( HepMC::GenVertex::particle_iterator decay
52  = (*p)->end_vertex()->
53  particles_begin(HepMC::children);
54  decay != (*p)->end_vertex()->
55  particles_end(HepMC::children);
56  ++decay )
57  {
58  // check if particle decays further
59  if(!(*decay)->end_vertex()){
60  if(abs((*decay)->pdg_id()) == 211) pi_num++;
61  }
62 
63  // loop over decay if particle decays further
64  else if((*decay)->end_vertex()){
65 
66  //further decay loop /
67  for ( HepMC::GenVertex::particle_iterator second_decay
68  = (*decay)->end_vertex()->
69  particles_begin(HepMC::children);
70  second_decay != (*decay)->end_vertex()->
71  particles_end(HepMC::children);
72  ++second_decay )
73  {
74  if (abs((*second_decay)->pdg_id()) == 211) pi_num++;
75 
76  if ((*second_decay)->status() != 1){
77  for ( HepMC::GenVertex::particle_iterator third_decay
78  = (*second_decay)->end_vertex()->
79  particles_begin(HepMC::children);
80  third_decay != (*second_decay)->end_vertex()->
81  particles_end(HepMC::children);
82  ++third_decay )
83  {
84  if(abs((*third_decay)->pdg_id()) == 211) pi_num++;
85  }
86  }
87  }
88  }
89  }
90 
91  if (pi_num == 3) return true;
92 
93  }//pythia event for loop
94 
95 return false;
96 
97 }
98 
101  _doTheParticleType = true;
102 }
103 
105  _Q2Min = Q2;
106  _doQ2Min = true;
107 }