Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4InputFilter.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4InputFilter.cc
1 #include "PHG4InputFilter.h"
2 #include "PHG4InEvent.h"
3 #include "PHG4Particle.h"
4 
6 #include <phool/getClass.h>
7 #include <phool/phool.h> // for PHWHERE
8 
9 #include <cmath>
10 #include <iostream> // for operator<<, endl, basic_ostream
11 #include <map> // for multimap<>::iterator, _Rb_tr...
12 #include <utility> // for pair
13 
14 using namespace std;
15 
17  SubsysReco(name),
18  etamin(NAN),
19  etamax(NAN),
20  ptmin(NAN),
21  ptmax(NAN)
22 {}
23 
24 int
26 {
27  PHG4InEvent *ineve = findNode::getClass<PHG4InEvent>(topNode, "PHG4INEVENT");
28  if (!ineve)
29  {
30  cout << PHWHERE << "no PHG4INEVENT node" << endl;
32  }
33  pair<multimap<int, PHG4Particle *>::iterator, multimap<int, PHG4Particle *>::iterator > beginend = ineve->GetParticles_Modify();
34  multimap<int, PHG4Particle *>::iterator particleiter;
35  if (Verbosity() > 0)
36  {
37  cout << "PHG4InputFilter before filter" << endl;
38  ineve->identify();
39  }
40  particleiter = beginend.first;
41  while (particleiter != beginend.second)
42  {
43  if (isfinite(etamin))
44  {
45  double eta = get_eta((particleiter->second)->get_px(), (particleiter->second)->get_py(), (particleiter->second)->get_pz());
46  if (eta < etamin)
47  {
48  multimap<int, PHG4Particle *>::iterator particleiter_cache = particleiter ;
49  ++particleiter_cache;
50  ineve->DeleteParticle(particleiter);
51  particleiter = particleiter_cache;
52  continue;
53  }
54  }
55  if (isfinite(etamax))
56  {
57  double eta = get_eta((particleiter->second)->get_px(), (particleiter->second)->get_py(), (particleiter->second)->get_pz());
58  if (eta > etamax)
59  {
60  multimap<int, PHG4Particle *>::iterator particleiter_cache = particleiter ;
61  ++particleiter_cache;
62  ineve->DeleteParticle(particleiter);
63  particleiter = particleiter_cache;
64  continue;
65  }
66  }
67  if (isfinite(ptmin))
68  {
69  double pt = sqrt((particleiter->second)->get_px()*(particleiter->second)->get_px()+ (particleiter->second)->get_py()*(particleiter->second)->get_py());
70  if (pt < ptmin)
71  {
72  multimap<int, PHG4Particle *>::iterator particleiter_cache = particleiter ;
73  ++particleiter_cache;
74  ineve->DeleteParticle(particleiter);
75  particleiter = particleiter_cache;
76  continue;
77  }
78  }
79  if (isfinite(ptmax))
80  {
81  double pt = sqrt((particleiter->second)->get_px()*(particleiter->second)->get_px()+ (particleiter->second)->get_py()*(particleiter->second)->get_py());
82  if (pt > ptmax)
83  {
84  multimap<int, PHG4Particle *>::iterator particleiter_cache = particleiter ;
85  ++particleiter_cache;
86  ineve->DeleteParticle(particleiter);
87  particleiter = particleiter_cache;
88  continue;
89  }
90  }
91  ++particleiter;
92  }
93  if (Verbosity() > 0)
94  {
95  cout << "PHG4InputFilter: after filter" << endl;
96  ineve->identify();
97  }
99 }
100 
101 double
102 PHG4InputFilter::get_eta(const double x, const double y, const double z)
103 {
104  double eta;
105  double radius;
106  double theta;
107  radius = sqrt(x * x + y * y);
108  theta = atan2(radius, z);
109  eta = -log(tan(theta / 2.));
110  return eta;
111 }