Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHSartreParticleTrigger.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHSartreParticleTrigger.cc
2 
3 #include <sartre/Event.h>
4 
5 #include <TLorentzVector.h> // for TLorentzVector
6 
7 #include <cmath> // for abs
8 #include <iostream> // for operator<<, endl, basic_ostream, basic_o...
9 
10 //__________________________________________________________
12  : PHSartreGenTrigger(name)
13  , _theEtaHigh(-999.9)
14  , _theEtaLow(-999.9)
15  , _thePtHigh(999.9)
16  , _thePtLow(-999.9)
17  , _thePHigh(999.9)
18  , _thePLow(-999.9)
19  , _thePzHigh(999.9)
20  , _thePzLow(-999.9)
21  ,
22 
23  _doEtaHighCut(false)
24  , _doEtaLowCut(false)
25  , _doBothEtaCut(false)
26  ,
27 
28  _doAbsEtaHighCut(false)
29  , _doAbsEtaLowCut(false)
30  , _doBothAbsEtaCut(false)
31  ,
32 
33  _doPtHighCut(false)
34  , _doPtLowCut(false)
35  , _doBothPtCut(false)
36  ,
37 
38  _doPHighCut(false)
39  , _doPLowCut(false)
40  , _doBothPCut(false)
41  ,
42 
43  _doPzHighCut(false)
44  , _doPzLowCut(false)
45  , _doBothPzCut(false)
46 {
47 }
48 
50 {
51  if (Verbosity() > 0) PrintConfig();
52 }
53 
55 {
56  if (Verbosity() > 2)
57  {
58  cout << "PHSartreParticleTrigger::Apply - event size: "
59  << event->particles.size() << endl;
60  }
61 
62  // Loop over all particles in the event
63  for (unsigned int i = 0; i < event->particles.size(); ++i)
64  {
65  //cout << i << " " << event->particles[i].pdgId << endl;
66 
67  if ((i < 7) && (i != 4)) continue; // only the VM, daughters OR the nuclear remnants
68 
69  const Particle &particle = event->particles[i];
70 
71  // loop over all the trigger particle criteria
72  for (int j = 0; j < int(_theParticles.size()); j++)
73  {
74  if ((particle.pdgId == _theParticles[j]) &&
75  ((particle.status == 1) || (i == 4)))
76  { //only stable particles OR the vector meson
77 
78  if (_doBothEtaCut && (particle.p.Eta() < _theEtaLow ||
79  particle.p.Eta() > _theEtaHigh)) continue;
80  if (_doEtaLowCut && particle.p.Eta() < _theEtaLow) continue;
81  if (_doEtaHighCut && particle.p.Eta() > _theEtaHigh) continue;
82 
83  if (_doBothAbsEtaCut && (abs(particle.p.Eta()) < _theEtaLow ||
84  abs(particle.p.Eta()) > _theEtaHigh)) continue;
85  if (_doAbsEtaLowCut && abs(particle.p.Eta()) < _theEtaLow) continue;
86  if (_doAbsEtaHighCut && abs(particle.p.Eta()) > _theEtaHigh) continue;
87 
88  if (_doBothPtCut && (particle.p.Pt() < _thePtLow ||
89  particle.p.Pt() > _thePtHigh)) continue;
90  if (_doPtHighCut && particle.p.Pt() > _thePtHigh) continue;
91  if (_doPtLowCut && particle.p.Pt() < _thePtLow) continue;
92 
93  if (_doBothPCut && (particle.p.P() < _thePLow ||
94  particle.p.P() > _thePHigh)) continue;
95  if (_doPHighCut && particle.p.P() > _thePHigh) continue;
96  if (_doPLowCut && particle.p.P() < _thePLow) continue;
97 
98  if (_doBothPzCut && (particle.p.Pz() < _thePzLow ||
99  particle.p.Pz() > _thePzHigh)) continue;
100  if (_doPzHighCut && particle.p.Pz() > _thePzHigh) continue;
101  if (_doPzLowCut && particle.p.Pz() < _thePzLow) continue;
102 
103  //If we made it here, success!
104  return true;
105 
106  } //if _theParticles
107  } //_theParticles for loop
108  }
109 
110  return false;
111 }
112 
114 {
115  std::vector<int> addedParts = convertToInts(particles);
116  _theParticles.insert(_theParticles.end(), addedParts.begin(), addedParts.end());
117 }
118 
120 {
121  _theParticles.push_back(particle);
122 }
123 
125 {
126  _theParticles.insert(_theParticles.end(), particles.begin(), particles.end());
127 }
128 
130 {
131  _thePtHigh = pt;
132  if (_doPtLowCut)
133  _doBothPtCut = true;
134  else
135  _doPtHighCut = true;
136 }
137 
139 {
140  _thePtLow = pt;
141  if (_doPtHighCut)
142  _doBothPtCut = true;
143  else
144  _doPtLowCut = true;
145 }
146 
147 void PHSartreParticleTrigger::SetPtHighLow(double ptHigh, double ptLow)
148 {
149  if (ptHigh < ptLow)
150  {
151  _thePtHigh = ptLow;
152  _thePtLow = ptHigh;
153  }
154  else
155  {
156  _thePtHigh = ptHigh;
157  _thePtLow = ptLow;
158  }
159  _doBothPtCut = true;
160  _doPtLowCut = false;
161  _doPtHighCut = false;
162 }
163 
165 {
166  _thePHigh = p;
167  if (_doPLowCut)
168  {
169  _doBothPCut = true;
170  _doPLowCut = false;
171  }
172  else
173  {
174  _doPHighCut = true;
175  }
176 }
177 
179 {
180  _thePLow = p;
181  if (_doPHighCut)
182  {
183  _doBothPCut = true;
184  _doPHighCut = false;
185  }
186  else
187  {
188  _doPLowCut = true;
189  }
190 }
191 
192 void PHSartreParticleTrigger::SetPHighLow(double pHigh, double pLow)
193 {
194  if (pHigh < pLow)
195  {
196  _thePHigh = pLow;
197  _thePLow = pHigh;
198  }
199  else
200  {
201  _thePHigh = pHigh;
202  _thePLow = pLow;
203  }
204  _doBothPCut = true;
205  _doPLowCut = false;
206  _doPHighCut = false;
207 }
208 
210 {
211  _theEtaHigh = eta;
212  if (_doEtaLowCut)
213  {
214  _doBothEtaCut = true;
215  _doEtaLowCut = false;
216  }
217  else
218  {
219  _doEtaHighCut = true;
220  }
221 }
222 
224 {
225  _theEtaLow = eta;
226  if (_doEtaHighCut)
227  {
228  _doBothEtaCut = true;
229  _doEtaHighCut = false;
230  }
231  else
232  {
233  _doEtaLowCut = true;
234  }
235 }
236 
237 void PHSartreParticleTrigger::SetEtaHighLow(double etaHigh, double etaLow)
238 {
239  _theEtaHigh = etaHigh;
240  _theEtaLow = etaLow;
241  _doBothEtaCut = true;
242  _doEtaHighCut = false;
243  _doEtaLowCut = false;
244 }
245 
247 {
248  _theEtaHigh = eta;
249  if (_doAbsEtaLowCut)
250  {
251  _doBothAbsEtaCut = true;
252  _doAbsEtaLowCut = false;
253  }
254  else
255  {
256  _doAbsEtaHighCut = true;
257  }
258 }
259 
261 {
262  _theEtaLow = eta;
263  if (_doAbsEtaHighCut)
264  {
265  _doBothAbsEtaCut = true;
266  _doAbsEtaHighCut = false;
267  }
268  else
269  {
270  _doAbsEtaLowCut = true;
271  }
272 }
273 
274 void PHSartreParticleTrigger::SetAbsEtaHighLow(double etaHigh, double etaLow)
275 {
276  _theEtaHigh = etaHigh;
277  _theEtaLow = etaLow;
278  _doBothAbsEtaCut = true;
279  _doAbsEtaLowCut = false;
280  _doAbsEtaHighCut = false;
281 }
282 
284 {
285  _thePzHigh = pz;
286  if (_doPzLowCut)
287  {
288  _doBothPzCut = true;
289  _doPzLowCut = false;
290  }
291  else
292  {
293  _doPzHighCut = true;
294  }
295 }
296 
298 {
299  _thePzLow = pz;
300  if (_doPzHighCut)
301  {
302  _doBothPzCut = true;
303  _doPzHighCut = false;
304  }
305  else
306  {
307  _doPzLowCut = true;
308  }
309 }
310 
311 void PHSartreParticleTrigger::SetPzHighLow(double pzHigh, double pzLow)
312 {
313  if (pzHigh < pzLow)
314  {
315  _thePzHigh = pzLow;
316  _thePzLow = pzHigh;
317  }
318  else
319  {
320  _thePzHigh = pzHigh;
321  _thePzLow = pzLow;
322  }
323  _doBothPzCut = true;
324  _doPzLowCut = false;
325  _doPzHighCut = false;
326 }
327 
329 {
330  cout << "---------------- PHSartreParticleTrigger::PrintConfig --------------------" << endl;
331  cout << " Particles: ";
332  for (int i = 0; i < int(_theParticles.size()); i++) cout << _theParticles[i] << " ";
333  cout << endl;
334 
336  cout << " doEtaCut: " << _theEtaLow << " < eta < " << _theEtaHigh << endl;
338  cout << " doAbsEtaCut: " << _theEtaLow << " < |eta| < " << _theEtaHigh << endl;
340  cout << " doPtCut: " << _thePtLow << " < pT < " << _thePtHigh << endl;
342  cout << " doPCut: " << _thePLow << " < p < " << _thePHigh << endl;
344  cout << " doPzCut: " << _thePzLow << " < pz < " << _thePzHigh << endl;
345  cout << "-----------------------------------------------------------------------" << endl;
346 }