stablejet is hosted by Hepforge, IPPP Durham
StableJet
PythiaJetGun.hh
1 // Convenient wrapper for two simple PYTHIA jet production mechanisms
2 
3 #ifndef PYTHIAJETGUN_HH_
4 #define PYTHIAJETGUN_HH_
5 
6 #include <vector>
7 
8 #include "rk/rk.hh"
9 #include "geners/ClassId.hh"
10 
11 namespace PythiaJetGun
12 {
13  // A simple particle class which carries the 4-momentum
14  // of the particle and its PYTHIA particle code.
15  // Jets will be made of collections of such particles.
16  class Particle
17  {
18  public:
19  inline Particle() : p4_(), code_(0) {}
20  inline Particle(const Particle &part) : p4_(part.p4_), code_(part.code_) {}
21  inline Particle(int code, const rk::P4& p4) : p4_(p4), code_(code) {}
22 
23  inline const rk::P4& p4() const {return p4_;}
24  inline int code() const {return code_;}
25  double charge() const;
26 
27  inline void setCode(int code) { code_ = code; }
28  inline void setP4(const rk::P4& p4) { p4_ = p4; }
29 
30  // The gyration radius is returned in meters for magnetic field B
31  // in Tesla and particle momentum in GeV/c. The radius is positive
32  // if signs of B and particle charge are the same, and negative
33  // otherwise. DBL_MAX is returned for neutral particles or in case
34  // B is 0.
35  double gyrationRadius(double B) const;
36 
37  bool operator==(const Particle& r) const;
38  inline bool operator!=(const Particle& r) const
39  {return !(*this == r);}
40 
41  inline gs::ClassId classId() const {return gs::ClassId(*this);}
42  bool write(std::ostream& of) const;
43 
44  static inline const char* classname()
45  {return "PythiaJetGun::Particle";}
46  static inline unsigned version() {return 1;}
47  static void restore(const gs::ClassId& id, std::istream& in,
48  Particle* ptr);
49 
50  private:
51  rk::P4 p4_;
52  int code_;
53  };
54 
55  // The following function uses the original Pythia single jet gun
56  // function PY1ENT. Such a jet is not required to conserve
57  // energy, momentum, or flavour.
58  void shoot1(int partonCode, double pt, double eta, double phi,
59  Particle* parton, std::vector<Particle>* jetParticles);
60 
61  // The following creates a q qbar pair and takes a jet from the
62  // hemisphere of q or qbar (choice of q or qbar is random).
63  // Chosen parton and jet particles are returned.
64  void shoot2(int partonCode, double pt, double eta, double phi,
65  Particle* parton, std::vector<Particle>* jetParticles,
66  bool runPyexec = true);
67 
68  // Random number generators based on Pythia "pyr" function
69  double pyrandom();
70  double gaussRandom(double mean, double sigma);
71 
72  // Wrapper for "pygive"
73  void pythiacmd(const char* cmd);
74 }
75 
76 #endif // PYTHIAJETGUN_HH_