Jpp test-rotations-old-533-g2bdbdb559
the software that should make you happy
Loading...
Searching...
No Matches
JDeltaRays.cc File Reference

Program to determine the energy loss due to visible delta-rays. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "TF1.h"
#include "TFitResult.h"
#include "JROOT/JMinimizer.hh"
#include "JPhysics/JConstants.hh"
#include "JPhysics/JDeltaRays.hh"
#include "JAAnet/JAAnetToolkit.hh"
#include "JTools/JRange.hh"
#include "Jeep/JPrint.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Program to determine the energy loss due to visible delta-rays.


Energy loss due to delta-rays and maximal kinetic energy (Tmax) are taken from reference https://pdg.lbl.gov/2020/reviews/rpp2020-rev-passage-particles-matter.pdf

Author
mdejong, bjung

Definition in file JDeltaRays.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 42 of file JDeltaRays.cc.

43{
44 using namespace std;
45 using namespace JPP;
46
47 typedef JRange<double> JRange_t;
48
49 string outputFile;
50 JRange_t T_GeV;
52 bool use_numerical;
53 string lepton;
54 double A;
55 double Z;
56 string option;
57 double precision;
58 int debug;
59
60 try {
61
62 JParser<> zap("Program to determine the energy loss due to visible delta-rays.");
63
64 zap['o'] = make_field(outputFile) = "delta-rays.root";
65 zap['n'] = make_field(numberOfPoints, "points for integration") = 1000000;
66 zap['N'] = make_field(use_numerical, "perform numeric integration");
67 zap['T'] = make_field(T_GeV, "kinetic energy range of electron [GeV]") = JRange_t();
68 zap['L'] = make_field(lepton) = muon, tau, positron, electron;
69 zap['A'] = make_field(A, "atomic mass") = 18.0;
70 zap['Z'] = make_field(Z, "atomic number") = 10.0;
71 zap['O'] = make_field(option) = "";
72 zap['e'] = make_field(precision) = 1.0e-6;
73 zap['d'] = make_field(debug) = 1;
74
75 zap(argc, argv);
76 }
77 catch(const exception &error) {
78 FATAL(error.what() << endl);
79 }
80
81 if (option.find('R') == string::npos) { option += 'R'; }
82 if (option.find('S') == string::npos) { option += 'S'; }
83 if (option.find('Q') == string::npos && debug < JEEP::debug_t) { option += 'Q'; }
84
85 double MASS_LEPTON;
86
87 if (lepton == muon)
88 MASS_LEPTON = MASS_MUON;
89 else if (lepton == tau)
90 MASS_LEPTON = MASS_TAU;
91 else if (lepton == positron)
92 MASS_LEPTON = MASS_ELECTRON;
93 else if (lepton == electron)
94 MASS_LEPTON = MASS_ELECTRON;
95 else
96 FATAL("Invalid lepton " << lepton << endl);
97
98 const double Tmin = (T_GeV.is_valid() ?
99 T_GeV.constrain(JDeltaRays::getTmin()) : JDeltaRays::getTmin());
100
101 TFile out(outputFile.c_str(), "recreate");
102
103 const double error = 1.0e-12;
104
105 const double xmin = log10(MASS_LEPTON);
106 const double xmax = 9.25;
107
108 TH1D h0("h0", NULL, 320, xmin, xmax);
109 TH1D h1("h1", NULL, 320, xmin, xmax);
110
111 for (int i = 1; i <= h0.GetNbinsX(); ++i) {
112
113 const double x = h0.GetBinCenter(i);
114 const double E = pow(10.0,x); // particle energy [GeV]
115
116 double Tmax = (lepton != electron ?
117 JDeltaRays::getTmax (E, MASS_LEPTON) :
118 0.5 * getKineticEnergy(E, MASS_ELECTRON));
119
120 if (T_GeV.is_valid()) { Tmax = T_GeV.constrain(Tmax); }
121
122 double dEdx = 0.0;
123 double dNdx = 0.0;
124
125 if (use_numerical) {
126
127 const double gamma = E / MASS_LEPTON;
128 const double beta = sqrt((1.0 + 1.0/gamma) * (1 - 1.0/gamma));
129
130 const JDeltaRays::JFormFactor F(0.5/(E*E), -beta*beta/Tmax, 1.0);
131
132 dEdx = JDeltaRays::getEnergyLoss(E, MASS_LEPTON, Tmin, Tmax, Z, A, F, numberOfPoints) * 1.0e3; // [MeV g^-1 cm^2]
133 dNdx = JDeltaRays::getCount (E, MASS_LEPTON, Tmin, Tmax, Z, A, F, numberOfPoints); // [g^-1 cm^2]
134
135 } else {
136
137 dEdx = JDeltaRays::getEnergyLoss(E, MASS_LEPTON, Tmin, Tmax, Z, A) * 1.0e3; // [MeV g^-1 cm^2]
138 dNdx = JDeltaRays::getCount (E, MASS_LEPTON, Tmin, Tmax, Z, A); // [g^-1 cm^2]
139 }
140
141 DEBUG("E [GeV] " << SCIENTIFIC(8,2) << E << endl);
142 DEBUG("Tmin [GeV] " << SCIENTIFIC(8,2) << Tmin << endl);
143 DEBUG("Tmax [GeV] " << SCIENTIFIC(8,2) << Tmax << endl);
144 DEBUG("dE/dx [MeV g^-1 cm^2] " << FIXED(5,4) << dEdx << endl);
145 DEBUG("dE/dx [g^-1 cm^2] " << FIXED(5,2) << dNdx << endl);
146
147 h0.SetBinContent(i, dEdx);
148 h0.SetBinError (i, error);
149 h1.SetBinContent(i, dNdx);
150 }
151
152 if (use_numerical) {
153
154 TF1 f1("f1", "[0] + [1]*x + [2]*x*x + [3]*x*x*x");
155
156 if (option.find('W') == string::npos) {
157 option += "W";
158 }
159
160 f1.SetParameter(0, h0.GetMinimum());
161 f1.SetParameter(1, (h0.GetMaximum() - h0.GetMinimum()) / (h0.GetXaxis()->GetXmax() - h0.GetXaxis()->GetXmin()));
162 f1.SetParameter(2, 0.0);
163 f1.SetParameter(3, 0.0);
164
165 f1.SetLineColor(kRed);
166
167 // fit
168
169 const TFitResultPtr result = h0.Fit(&f1, option.c_str(), "same", xmin, xmax);
170
171 cout << "chi2/NDF " << result->Chi2() << '/' << result->Ndf() << endl;
172
173 cout << "\t// " << lepton << endl;
174 cout << "\t// dE/dX = a + bx + cx^2 + dx^3; // [MeV g^-1 cm^2]; x = log10(E/GeV);" << endl;
175
176 for (int i = 0; i != 4; ++i) {
177 cout << "\tstatic const double " << (char) ('a' + i) << " = " << SCIENTIFIC(10,3) << f1.GetParameter(i) << ";" << endl;
178 }
179
180 double Emin = 1 * MASS_LEPTON;
181 double Emax = 5 * MASS_LEPTON;
182
183 for (double E = 0.5 * (Emin + Emax); ; E = 0.5 * (Emin + Emax)) {
184
185 const double Tmax = JDeltaRays::getTmax(E, MASS_LEPTON);
186
187 if (fabs(Tmax - Tmin) < precision) {
188 cout << "\tstatic const double Emin = " << FIXED(7,5) << E << "; // [GeV]" << endl;
189 break;
190 }
191
192 if (Tmax > Tmin)
193 Emax = E;
194 else
195 Emin = E;
196 }
197 }
198
199 out.Write();
200 out.Close();
201}
string outputFile
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
int numberOfPoints
Definition JResultPDF.cc:22
Utility class to parse command line options.
Definition JParser.hh:1698
Range of values.
Definition JRange.hh:42
@ debug_t
debug
Definition JMessage.hh:29
T pow(const T &x, const double y)
Power .
Definition JMath.hh:97
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
if((p==this->begin() &&this->getDistance(x,(p++) ->getX()) > distance_type::precision)||(p==this->end() &&this->getDistance((--p) ->getX(), x) > distance_type::precision))
Template base class for polynomial interpolations with polynomial result.
Definition JPolint.hh:775
Auxiliary data structure for floating point format specification.
Definition JManip.hh:448
Auxiliary class for 2nd order polynomial form factor.
Definition JDeltaRays.hh:96
Auxiliary data structure for floating point format specification.
Definition JManip.hh:488