/home/docs/checkouts/readthedocs.org/user_builds/ratpac/checkouts/latest/src/gen/include/RAT/BetaFunction.hh Source File

Ratpac-two: /home/docs/checkouts/readthedocs.org/user_builds/ratpac/checkouts/latest/src/gen/include/RAT/BetaFunction.hh Source File
Ratpac-two
BetaFunction.hh
1 #ifndef __RAT_BetaFunction__
2 #define __RAT_BetaFunction__
3 
4 // 04-Jan-2006 WGS: Drag this code into the 21st century: use CLHEP,
5 // use strings, use STL.
6 
7 #include <cmath>
8 #include <cstdlib>
9 #include <cstring>
10 #include <iostream>
11 #include <map>
12 
13 namespace RAT {
14 
15 enum EReactions {
16  iBAD = -9999,
17  NullParticle = -2, // for stable particles
18  DecayBeta = +1,
19  DecayEC = -1,
20  DecayGamma = 0,
21  DecayAlpha = +2
22 };
23 
24 class BetaFunction {
25  enum EBetaFunctionConsts { PartMax = 1000, BrMax = 1000 };
26 
27  public:
28  BetaFunction();
29  BetaFunction(const std::string Name);
30  BetaFunction(const std::string Name, double Z, double A = 0., int reaction = DecayBeta, double tau = 0.);
31  ~BetaFunction();
32 
33  void Reset();
34  void Show();
35 
36  void SetTarget(const std::string Name, double Z, double A = 0., int reaction = DecayBeta, double tau = 0.);
37  void SetBranches(double Branch, int Spin, double EndPoint);
38  void RemoveBranch(int iBranch);
39  void SetGammas(int iBranch, int pid, double energy);
40  void SetGammas(double energy);
41  void SetParticleID(int iBranch, int n, int pid);
42  void SetTargetMass(double A);
43  void SetNorm(int iBranch);
44 
45  int GetNParticles(int iBranch);
46  int GetParticleID(int iBranch, int n);
47  int GetSpin(int iBranch);
48 
49  double GetBranch(int iBranch);
50  double GetEndPoint(int iBranch);
51  double GetEnergy(int iBranch, int n);
52  double GetValue(double energy, int iBranch);
53 
54  void GenerateEvent();
55  void SetEventTime();
56 
57  int GetEventID(int n);
58  double GetEventEnergy(int n);
59  double GetEventTotE();
60 
61  double GetRandomNumber(double rmin = 0., double rmax = 1.);
62 
63  bool ReadInputFile(const std::string dName);
64  bool ReadInputFile(const std::string dName, int iType);
65  bool ReadInputFile(const std::string dName, int iZ, int iA, int iType = DecayBeta);
66 
67  void ErrorLog(int iFlag = -1);
68 
69  inline void SetFileName(const std::string Name) { inputFileName = Name; }
70  inline void SetVerbose(bool iSet = true) { isVerbose = iSet; }
71  inline void SetProbabilityCulmulative(bool iSel = true) { isCulmulative = iSel; }
72 
73  inline void SetName(const std::string Name) { TargetName = Name; }
74  inline void SetCharge(double Z) { TargetCharge = Z; }
75  inline void SetDecayType(int iType) { TargetDecayType = iType; }
76  inline void SetNeutrinoMass(double Mass) { MassNu = Mass; }
77  inline void SetLifeTime(double Tau) { TargetDecayTime = Tau; }
78 
79  inline int GetDecayType() { return TargetDecayType; }
80  inline int GetNBranches() { return NumberOfBranches; }
81  inline int GetNGenerated() { return nGenerated; }
82 
83  inline const std::string GetName() { return TargetName; }
84  inline const std::string GetFileName() { return inputFileName; }
85 
86  inline double GetLifeTime() { return TargetDecayTime; }
87  inline double GetTargetMass() { return TargetMass; }
88  inline double GetCharge() { return TargetCharge; }
89  inline double GetNeutrinoMass() { return MassNu; }
90  inline double GetEventTime() { return nTime; }
91  // WGS: Initialize DecayNorm if it hasn't been set before.
92  inline double GetNorm(int iBranch) {
93  std::map<size_t, double>::iterator i = DecayNorm.find(iBranch);
94  if (i == DecayNorm.end()) {
95  DecayNorm[iBranch] = 1.;
96  return 1.; // We could return DecayNorm[iBranch], but that takes longer.
97  }
98  // Otherwise return DecayNorm[iBranch]... which we already point
99  // to with i.
100  return (*i).second;
101  }
102 
103  private:
104  static void ThrowParsingException(std::string filename, std::string decayName);
105 
106  bool isVerbose;
107  bool isCulmulative;
108 
109  std::string TargetName;
110  std::string inputFileName;
111 
112  int NumberOfBranches;
113  std::map<size_t, int> ParticleSpin;
114  std::map<size_t, double> ParticleEndPoint;
115  std::map<size_t, double> ParticleBranch;
116 
117  std::map<size_t, double> DecayNorm;
118  std::map<size_t, int> NumberOfParticles;
119  std::map<size_t, std::map<size_t, int>> ParticleID;
120  std::map<size_t, std::map<size_t, double>> ParticleEnergy;
121 
122  double TargetMass;
123  double TargetCharge;
124  double MassNu;
125  double TargetDecayTime;
126  int TargetDecayType;
127 
128  int nGenerated;
129  std::map<size_t, int> IDn;
130  std::map<size_t, double> En;
131  double nTime;
132 };
133 
134 } // namespace RAT
135 
136 #endif // __RAT_BetaFunction__
Definition: BetaFunction.hh:24
Definition: CCCrossSecMessenger.hh:29