Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
JetScapeParticles.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file JetScapeParticles.h
1 /*******************************************************************************
2  * Copyright (c) The JETSCAPE Collaboration, 2018
3  *
4  * Modular, task-based framework for simulating all aspects of heavy-ion collisions
5  *
6  * For the list of contributors see AUTHORS.
7  *
8  * Report issues at https://github.com/JETSCAPE/JETSCAPE/issues
9  *
10  * or via email to bugs.jetscape@gmail.com
11  *
12  * Distributed under the GNU General Public License 3.0 (GPLv3 or later).
13  * See COPYING for details.
14  ******************************************************************************/
15 
56 #ifndef JETSCAPEPARTICLES_H
57 #define JETSCAPEPARTICLES_H
58 
59 #include <stdio.h>
60 #include <math.h>
61 #include "GTL/graph.h"
62 #include "JetScapeConstants.h"
63 #include "FourVector.h"
64 #include "fjcore.hh"
65 #include "JetScapeLogger.h"
66 #include "PartonShower.h"
67 
68 #include "Pythia8/Pythia.h"
69 
70 #include <vector>
71 #include <memory>
72 #include <iostream>
73 #include <sstream>
74 #include <iomanip>
75 
76 using std::ostream;
77 using std::weak_ptr;
78 
79 namespace Jetscape {
80 
81 class PartonShower;
82 
83 /**************************************************************************************************/
84 // BASE CLASS
85 /*************************************************************************************************/
86 
87 class JetScapeParticleBase : protected fjcore::PseudoJet {
88  friend class fjcore::PseudoJet;
89 
90  // unsafe
91  // using fjcore::PseudoJet::PseudoJet;
92  // using fjcore::PseudoJet::operator() (int i) const ;
93  // inline double operator [] (int i) const { return (*this)(i); }; // this too
94 
95 public:
96  // Disallow reset, it assumes different logic
97  // using fjcore::PseudoJet::reset(double px, double py, double pz, double E);
98  // using fjcore::PseudoJet::reset(const PseudoJet & psjet) {
99  // inline void reset_momentum(double px, double py, double pz, double E);
100  // inline void reset_momentum(const PseudoJet & pj);
101 
102  inline void reset_momentum(const double px, const double py, const double pz,
103  const double e) {
104  fjcore::PseudoJet::reset_momentum(px, py, pz, e);
105  }
106 
107  inline void reset_momentum(const FourVector &p) {
108  fjcore::PseudoJet::reset_momentum(p.x(), p.y(), p.z(), p.t());
109  }
110 
111  // Disallow the valarray return.
112  // Can replace/and or provide a double[4] version with the right assumptions
113  // std::valarray<double> four_mom() const;
114  // enum { X=0, Y=1, Z=2, T=3, NUM_COORDINATES=4, SIZE=NUM_COORDINATES };
115 
116  // This _should_ work, but not taking chances for now
117  // PseudoJet & boost(const PseudoJet & prest);
118  // PseudoJet & unboost(const PseudoJet & prest);
119 
120  // Replace with appropriate functions. m is a tricky one.
121  // inline double m2() const {return (_E+_pz)*(_E-_pz)-_kt2;}
122  // inline double m() const;
123  // inline double mperp2() const {return (_E+_pz)*(_E-_pz);}
124  // inline double mperp() const {return sqrt(std::abs(mperp2()));}
125  // inline double mt2() const {return (_E+_pz)*(_E-_pz);}
126  // inline double mt() const {return sqrt(std::abs(mperp2()));}
127 
128  // Disallow functions containing M
129  // inline void reset_PtYPhiM(...);
130  // void reset_momentum_PtYPhiM(double pt, double y, double phi, double m=0.0);
131 
132  // // void set_cached_rap_phi(double rap, double phi);
133 
135  fjcore::PseudoJet GetPseudoJet() const { return PseudoJet(*this); }
136 
137  // import safe functions
138  using fjcore::PseudoJet::px;
139  using fjcore::PseudoJet::py;
140  using fjcore::PseudoJet::pz;
141  using fjcore::PseudoJet::e;
142  using fjcore::PseudoJet::E;
143 
145  using fjcore::PseudoJet::phi_std;
146  using fjcore::PseudoJet::phi_02pi;
147  using fjcore::PseudoJet::rap;
148  using fjcore::PseudoJet::rapidity;
149  using fjcore::PseudoJet::pseudorapidity;
151  using fjcore::PseudoJet::pt2;
152  using fjcore::PseudoJet::pt;
153  using fjcore::PseudoJet::perp2;
155  using fjcore::PseudoJet::kt2;
156 
157  using fjcore::PseudoJet::modp2;
158  using fjcore::PseudoJet::modp;
159  using fjcore::PseudoJet::Et;
160  using fjcore::PseudoJet::Et2;
161 
162  using fjcore::PseudoJet::kt_distance;
163  using fjcore::PseudoJet::plain_distance;
164  using fjcore::PseudoJet::squared_distance;
165  using fjcore::PseudoJet::delta_R;
166  using fjcore::PseudoJet::delta_phi_to;
167  using fjcore::PseudoJet::beam_distance;
168 
169  using fjcore::PseudoJet::operator*=;
170  using fjcore::PseudoJet::operator/=;
171  using fjcore::PseudoJet::operator+=;
172  using fjcore::PseudoJet::operator-=;
173 
174  using fjcore::PseudoJet::user_index;
175  using fjcore::PseudoJet::set_user_index;
176  using fjcore::PseudoJet::UserInfoBase;
177  using fjcore::PseudoJet::InexistentUserInfo;
178 
179  using fjcore::PseudoJet::user_info;
180  using fjcore::PseudoJet::set_user_info;
181  using fjcore::PseudoJet::has_user_info;
182  using fjcore::PseudoJet::user_info_ptr;
183  using fjcore::PseudoJet::user_info_shared_ptr;
184 
186  // In principle, these might be okay, but ClusterSequences should
187  // be made after explicitly transforming to a proper PseudoJet
188  // using fjcore::PseudoJet::has_associated_cluster_sequence;
189  // using fjcore::PseudoJet::has_associated_cs;
190  // using fjcore::PseudoJet::has_valid_cluster_sequence;
191  // using fjcore::PseudoJet::has_valid_cs;
192  // using fjcore::PseudoJet::associated_cluster_sequence;
193  // using fjcore::PseudoJet::associated_cs;
194  // using fjcore::PseudoJet::validated_cluster_sequence;
195  // using fjcore::PseudoJet::validated_cs;
196  // using fjcore::PseudoJet::set_structure_shared_ptr;
197  // using fjcore::PseudoJet::has_structure;
198  // using fjcore::PseudoJet::structure_ptr;
199  // using fjcore::PseudoJet::structure_non_const_ptr;
200  // using fjcore::PseudoJet::validated_structure_ptr;
201  // using fjcore::PseudoJet::structure_shared_ptr;
202  // ... more
203 
204 public:
205  JetScapeParticleBase() : PseudoJet(){};
206  JetScapeParticleBase(int label, int id, int stat, const FourVector &p,
207  const FourVector &x);
208  JetScapeParticleBase(int label, int id, int stat, double pt, double eta,
209  double phi, double e, double *x = 0);
210  JetScapeParticleBase(int label, int id, int stat, const FourVector &p,
211  const FourVector &x, double mass);
213 
214  virtual ~JetScapeParticleBase();
215 
216  void clear();
217 
218  // Setters
219  void set_label(int label);
220  void set_id(int id);
221  void set_stat(int stat);
222  void set_x(double x[4]);
223 
224  void init_jet_v();
225  void set_jet_v(double v[4]);
226  void set_jet_v(FourVector j);
227 
230  bool SetController(string controller = "") {
231  bool wascontrolled = controlled_;
232  controlled_ = true;
233  controller_ = controller;
234  return wascontrolled;
235  };
238  controller_ = "";
239  controlled_ = false;
240  };
241 
242  // Getters
243 
244  const int pid() const;
245  const int pstat() const;
246  const int plabel() const;
247  // const double e();
248  // const double pt();
249  const double time() const;
250 
251  std::vector<JetScapeParticleBase> parents();
252 
253  const FourVector p_in() const;
254  const FourVector &x_in() const;
255  const FourVector &jet_v() const;
256 
257  const double restmass();
258  const double p(int i);
259  double pl();
260  const double nu();
261  const double t_max();
262 
265 
267  string GetController() const { return controller_; };
269  bool GetControlled() const { return controlled_; };
270 
271  // give it a static pythia to look up particle properties
272  // Be a bit careful with it!
273  // Init is never called, and this object is not configured. All it can do is look up
274  // in its original Data table
275  static Pythia8::Pythia InternalHelperPythia;
276 
277 protected:
278  void set_restmass(
279  double
280  mass_input);
281 
282  int pid_;
283  int pstat_;
284  int plabel_;
285  double
287 
289  FourVector
291 
292  // give it a static pythia to look up particle properties
293  // Be a bit careful with it!
294  // Init is never called, and this object is not configured. All it can do is look up
295  // in its original Data table
296  //static Pythia8::Pythia InternalHelperPythia;
297 
299  bool controlled_ = false;
300  string controller_ = "";
301 };
302 // END BASE CLASS
303 
304 // Declared outside the class
305 ostream &operator<<(ostream &output, JetScapeParticleBase &p);
306 
307 /**************************************************************************************************/
308 // PARTON CLASS
309 /*************************************************************************************************/
310 class Parton : public JetScapeParticleBase {
311 
312 public:
313  virtual void set_mean_form_time();
314  virtual void set_form_time(double form_time);
315 
316  virtual double form_time();
317  virtual const double mean_form_time();
318  virtual void reset_p(double px, double py, double pz);
319  virtual void set_color(unsigned int col);
320  virtual void
321  set_anti_color(unsigned int acol);
322  virtual void
323  set_max_color(unsigned int col);
324  virtual void
325  set_min_color(unsigned int col);
326  virtual void
327  set_min_anti_color(unsigned int acol);
328  bool isPhoton(
329  int pid); // Checks to see if the particle is a photon, separate derived class for photons
330 
331  Parton(int label, int id, int stat, const FourVector &p, const FourVector &x);
332  Parton(int label, int id, int stat, double pt, double eta, double phi,
333  double e, double *x = 0);
334  Parton(const Parton &srp);
335 
337  Parton &operator=(const Parton &c);
338 
339  const double t();
340  void set_t(
341  double
342  t);
343  unsigned int color();
344  unsigned int anti_color();
345  unsigned int max_color();
346  unsigned int min_color();
347  unsigned int min_anti_color();
348 
349  const int edgeid() const;
350  void set_edgeid(const int id);
351 
352  void set_shower(const shared_ptr<PartonShower> pShower);
353  void set_shower(const weak_ptr<PartonShower> pShower);
354  const weak_ptr<PartonShower> shower() const;
355 
356  std::vector<Parton> parents();
357 
358 protected:
360  double form_time_;
361  unsigned int Color_;
362  unsigned int antiColor_;
363  unsigned int MaxColor_;
364  unsigned int MinColor_;
365  unsigned int MinAntiColor_;
366 
367  weak_ptr<PartonShower> pShower_;
368  int edgeid_;
369 
370  // helpers
371  void initialize_form_time();
372  void CheckAcceptability(int id);
373 };
374 
375 class Hadron : public JetScapeParticleBase {
376 public:
377  Hadron(int label, int id, int stat, const FourVector &p, const FourVector &x);
378  Hadron(int label, int id, int stat, double pt, double eta, double phi,
379  double e, double *x = 0);
380  Hadron(int label, int id, int stat, const FourVector &p, const FourVector &x,
381  double mass);
382  Hadron(const Hadron &srh);
383 
385  Hadron &operator=(const Hadron &c);
386 
387  void set_decay_width(double width) { width_ = width; }
388 
389  double decay_width() { return (width_); }
390 
394  bool CheckOrForceHadron(const int id, const double mass = 0);
395 
397  bool has_no_position();
398 
399 protected:
400  double width_;
401 };
402 
403 class Photon : public Parton {
404 public:
405  Photon(int label, int id, int stat, const FourVector &p, const FourVector &x);
406  Photon(int label, int id, int stat, double pt, double eta, double phi,
407  double e, double *x = 0);
408  Photon(const Photon &srh);
409 
410  Photon &operator=(Photon &ph);
411  Photon &operator=(const Photon &ph);
412 };
413 
414 }; // namespace Jetscape
415 
416 #endif // JETSCAPEPARTICLES_H