Jpp  19.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
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/JPDFToolkit.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

int main ( int  argc,
char **  argv 
)

Definition at line 194 of file JDeltaRays.cc.

195 {
196  using namespace std;
197  using namespace JPP;
198 
199  typedef JRange<double> JRange_t;
200 
201  string outputFile;
202  JRange_t T_GeV;
203  int numberOfPoints;
204  bool use_numerical;
205  string lepton;
206  double A;
207  double Z;
208  string option;
209  double precision;
210  int debug;
211 
212  try {
213 
214  JParser<> zap("Program to determine the energy loss due to visible delta-rays.");
215 
216  zap['o'] = make_field(outputFile) = "delta-rays.root";
217  zap['n'] = make_field(numberOfPoints, "points for integration") = 1000000;
218  zap['N'] = make_field(use_numerical, "perform numeric integration");
219  zap['T'] = make_field(T_GeV, "kinetic energy range of electron [GeV]") = JRange_t();
220  zap['L'] = make_field(lepton) = muon, tau, positron, electron;
221  zap['A'] = make_field(A, "atomic mass") = 18.0;
222  zap['Z'] = make_field(Z, "atomic number") = 10.0;
223  zap['O'] = make_field(option) = "";
224  zap['e'] = make_field(precision) = 1.0e-6;
225  zap['d'] = make_field(debug) = 1;
226 
227  zap(argc, argv);
228  }
229  catch(const exception &error) {
230  FATAL(error.what() << endl);
231  }
232 
233  if (option.find('R') == string::npos) { option += 'R'; }
234  if (option.find('S') == string::npos) { option += 'S'; }
235  if (option.find('Q') == string::npos && debug < JEEP::debug_t) { option += 'Q'; }
236 
237  double MASS_LEPTON;
238 
239  if (lepton == muon)
240  MASS_LEPTON = MASS_MUON;
241  else if (lepton == tau)
242  MASS_LEPTON = MASS_TAU;
243  else if (lepton == positron)
244  MASS_LEPTON = MASS_ELECTRON;
245  else if (lepton == electron)
246  MASS_LEPTON = MASS_ELECTRON;
247  else
248  FATAL("Invalid lepton " << lepton << endl);
249 
250  const double Tmin = (T_GeV.is_valid() ?
251  T_GeV.constrain(getDeltaRayTmin()) : getDeltaRayTmin());
252 
253  TFile out(outputFile.c_str(), "recreate");
254 
255  const double error = 1.0e-12;
256 
257  const double xmin = log10(MASS_LEPTON);
258  const double xmax = 9.25;
259 
260  TH1D h0("h0", NULL, 320, xmin, xmax);
261  TH1D h1("h1", NULL, 320, xmin, xmax);
262 
263  for (int i = 1; i <= h0.GetNbinsX(); ++i) {
264 
265  const double x = h0.GetBinCenter(i);
266  const double E = pow(10.0,x); // particle energy [GeV]
267 
268  double Tmax = (lepton != electron ?
269  getDeltaRayTmax (E, MASS_LEPTON) :
270  0.5 * getKineticEnergy(E, MASS_ELECTRON));
271 
272  if (T_GeV.is_valid()) { Tmax = T_GeV.constrain(Tmax); }
273 
274  double dEdx = 0.0;
275  double dNdx = 0.0;
276 
277  if (use_numerical) {
278 
279  const double gamma = E / MASS_LEPTON;
280  const double beta = sqrt((1.0 + 1.0/gamma) * (1 - 1.0/gamma));
281 
282  const JFormFactor F(0.5/(E*E), -beta*beta/Tmax, 1.0);
283 
284  dEdx = getDeltaRays(E, MASS_LEPTON, Tmin, Tmax, Z, A, F, numberOfPoints) / DENSITY_SEA_WATER * 1e1; // [MeV g^-1 cm^2]
285  dNdx = getCount (E, MASS_LEPTON, Tmin, Tmax, Z, A, F, numberOfPoints) / DENSITY_SEA_WATER * 1e-2; // [g^-1 cm^2]
286 
287  } else {
288 
289  dEdx = getDeltaRays(E, MASS_LEPTON, Tmin, Tmax, Z, A) / DENSITY_SEA_WATER * 1e1; // [MeV g^-1 cm^2]
290  dNdx = getCount (E, MASS_LEPTON, Tmin, Tmax, Z, A) / DENSITY_SEA_WATER * 1e-2; // [g^-1 cm^2]
291  }
292 
293  DEBUG("E [GeV] " << SCIENTIFIC(8,2) << E << endl);
294  DEBUG("Tmin [GeV] " << SCIENTIFIC(8,2) << Tmin << endl);
295  DEBUG("Tmax [GeV] " << SCIENTIFIC(8,2) << Tmax << endl);
296  DEBUG("dE/dx [MeV g^-1 cm^2] " << FIXED(5,4) << dEdx << endl);
297  DEBUG("dE/dx [g^-1 cm^2] " << FIXED(5,2) << dNdx << endl);
298 
299  h0.SetBinContent(i, dEdx);
300  h0.SetBinError (i, error);
301  h1.SetBinContent(i, dNdx);
302  }
303 
304  if (use_numerical) {
305 
306  TF1 f1("f1", "[0] + [1]*x + [2]*x*x + [3]*x*x*x");
307 
308  if (option.find('W') == string::npos) {
309  option += "W";
310  }
311 
312  f1.SetParameter(0, h0.GetMinimum());
313  f1.SetParameter(1, (h0.GetMaximum() - h0.GetMinimum()) / (h0.GetXaxis()->GetXmax() - h0.GetXaxis()->GetXmin()));
314  f1.SetParameter(2, 0.0);
315  f1.SetParameter(3, 0.0);
316 
317  f1.SetLineColor(kRed);
318 
319  // fit
320 
321  const TFitResultPtr result = h0.Fit(&f1, option.c_str(), "same", xmin, xmax);
322 
323  cout << "chi2/NDF " << result->Chi2() << '/' << result->Ndf() << endl;
324 
325  cout << "\t// " << lepton << endl;
326  cout << "\t// dE/dX = a + bx + cx^2 + dx^3; // [MeV g^-1 cm^2]; x = log10(E/GeV);" << endl;
327 
328  for (int i = 0; i != 4; ++i) {
329  cout << "\tstatic const double " << (char) ('a' + i) << " = " << SCIENTIFIC(10,3) << f1.GetParameter(i) << ";" << endl;
330  }
331 
332  double Emin = 1 * MASS_LEPTON;
333  double Emax = 5 * MASS_LEPTON;
334 
335  for (double E = 0.5 * (Emin + Emax); ; E = 0.5 * (Emin + Emax)) {
336 
337  const double Tmax = getDeltaRayTmax(E, MASS_LEPTON);
338 
339  if (fabs(Tmax - Tmin) < precision) {
340  cout << "\tstatic const double Emin = " << FIXED(7,5) << E << "; // [GeV]" << endl;
341  break;
342  }
343 
344  if (Tmax > Tmin)
345  Emax = E;
346  else
347  Emin = E;
348  }
349  }
350 
351  out.Write();
352  out.Close();
353 }
const double xmax
Definition: JQuadrature.cc:24
Utility class to parse command line options.
Definition: JParser.hh:1711
debug
Definition: JMessage.hh:29
then usage $script< input file >[option[primary[working directory]]] nWhere option can be E
Definition: JMuonPostfit.sh:40
size_t getCount(const array_type< T > &buffer, const JCompare_t &compare)
Count number of unique values.
Definition: JVectorize.hh:261
double getDeltaRayTmax(const double E, const double M)
Get maximum delta-ray kinetic energy for given lepton energy and mass.
Definition: JPDFToolkit.hh:93
double getDeltaRayTmin()
Get minimum delta-ray kinetic energy.
Definition: JPDFToolkit.hh:73
static const double MASS_MUON
muon mass [GeV]
static const double DENSITY_SEA_WATER
Fixed environment values.
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
string outputFile
const JPolynome f1(1.0, 2.0, 3.0)
Function.
Type definition of range.
Definition: JHead.hh:41
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2158
set_variable E_E log10(E_{fit}/E_{#mu})"
static const double MASS_TAU
tau mass [GeV]
T pow(const T &x, const double y)
Power .
Definition: JMath.hh:97
double getDeltaRays(const double E, const double M, const double Tmin, const double Tmax, const double Z, const double A)
Get equivalent EM-shower energy due to delta-rays per unit track length for an ionising particle with...
Definition: JPDFToolkit.hh:124
then awk F
static const double MASS_ELECTRON
electron mass [GeV]
double getKineticEnergy(const Trk &trk)
Get track kinetic energy.
#define FATAL(A)
Definition: JMessage.hh:67
const double xmin
Definition: JQuadrature.cc:23
int numberOfPoints
Definition: JResultPDF.cc:22
do set_variable MODULE getModule a $WORKDIR detector_a datx L $STRING JEditDetector a $WORKDIR detector_a datx M $MODULE setz o $WORKDIR detector_a datx JEditDetector a $WORKDIR detector_b datx M $MODULE setz o $WORKDIR detector_b datx done echo Output stored at $WORKDIR detector_a datx and $WORKDIR tripod_a txt JDrawDetector2D a $WORKDIR detector_a datx a $WORKDIR detector_b datx L BL o detector $FORMAT $BATCH JDrawDetector2D T $WORKDIR tripod_a txt T $WORKDIR tripod_b txt L BL o tripod $FORMAT $BATCH JCompareDetector a $WORKDIR detector_a datx b $WORKDIR detector_b datx o $WORKDIR abc root &dev null for KEY in X Y Z
source $JPP_DIR setenv csh $JPP_DIR &dev null eval JShellParser o a A
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:486
then for LEPTON in muon tau positron electron
Definition: JDeltaRays.sh:44
int debug
debug level
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62