Jpp
 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 "JTools/JConstants.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.

Author
mdejong

Definition in file JDeltaRays.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 39 of file JDeltaRays.cc.

40 {
41  using namespace std;
42 
44 
45  string outputFile;
46  JRange_t T_GeV;
47  int numberOfPoints;
48  string lepton;
49  string option;
50  double precision;
51  int debug;
52 
53  try {
54 
55  JParser<> zap("Program to determine the energy loss due to visible delta-rays.");
56 
57  zap['o'] = make_field(outputFile) = "delta-rays.root";
58  zap['T'] = make_field(T_GeV, "kinetic energy range of electron [GeV]") = JRange_t();
59  zap['n'] = make_field(numberOfPoints, "points for integration") = 1000000;
60  zap['L'] = make_field(lepton) = muon, tau, positron, electron;
61  zap['O'] = make_field(option) = "";
62  zap['e'] = make_field(precision) = 1.0e-6;
63  zap['d'] = make_field(debug) = 1;
64 
65  zap(argc, argv);
66  }
67  catch(const exception &error) {
68  FATAL(error.what() << endl);
69  }
70 
71  using namespace JPP;
72 
73  double MASS_LEPTON;
74 
75  if (lepton == muon)
76  MASS_LEPTON = MASS_MUON;
77  else if (lepton == tau)
78  MASS_LEPTON = MASS_TAU;
79  else if (lepton == positron)
80  MASS_LEPTON = MASS_ELECTRON;
81  else if (lepton == electron)
82  MASS_LEPTON = MASS_ELECTRON;
83  else
84  FATAL("Invalid lepton " << lepton << endl);
85 
86 
87  const double RATIO = MASS_ELECTRON / MASS_LEPTON;
88 
89 
90  // Minimal energy of electron for Cherenkov threshold [GeV]
91 
93 
94  // Minimal kinetic energy of electron [GeV]
95 
96  double Tmin = sqrt(EMIN*EMIN - MASS_ELECTRON*MASS_ELECTRON);
97 
98  NOTICE("Tmin [GeV] " << FIXED(8,6) << Tmin << ' ' << FIXED(8,6) << T_GeV.getLowerLimit() << endl);
99 
100  if (T_GeV.is_valid()) {
101  if (Tmin < T_GeV.getLowerLimit()) {
102  Tmin = T_GeV.getLowerLimit();
103  }
104  }
105 
106 
107  TFile out(outputFile.c_str(), "recreate");
108 
109  TH1D h0("h0", NULL, 80, log10(MASS_LEPTON), +9.25);
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); // muon energy [GeV]
115 
116  const double gamma = E / MASS_LEPTON;
117  const double beta = sqrt(1.0 - 1.0/(gamma*gamma));
118 
119 
120  // Maximal kinetic energy of electron [GeV]
121 
122  double Tmax = (lepton == electron ?
123  (0.5*sqrt(E*E - MASS_ELECTRON*MASS_ELECTRON)) :
124  (2.0*MASS_ELECTRON*beta*beta*gamma*gamma) / (1.0 + 2.0*gamma*RATIO + RATIO*RATIO));
125 
126  if (T_GeV.is_valid()) {
127  if (Tmax > T_GeV.getUpperLimit()) {
128  Tmax = T_GeV.getUpperLimit();
129  }
130  }
131 
132 
133  double value = 0.0; // energy of delta-rays
134 
135  if (Tmax > Tmin) {
136 
137  const double a = 1.0; // Form factor formula
138  const double b = -beta*beta/Tmax; //
139  const double c = 0.5/(E*E); // F(T) = a + b*T + c*T^2
140 
141  const double xmin = log(Tmin); // T * 1/T^2 * dT = d log(T)
142  const double xmax = log(Tmax);
143  const double dx = (xmax - xmin) / numberOfPoints;
144 
145  const double W = dx * 0.5 * K * (Z/A) * (1.0/(beta*beta));
146 
147  for (double x = xmin; x <= xmax; x += dx) {
148 
149  const double T = exp(x);
150 
151  const double F = a + T*(b + T*(c)); // Form factor formula
152  const double y = W * F;
153 
154  value += y;
155  }
156  }
157 
158  DEBUG("E [GeV] " << SCIENTIFIC(8,2) << E << endl);
159  DEBUG("Tmin [GeV] " << SCIENTIFIC(8,2) << Tmin << endl);
160  DEBUG("Tmax [GeV] " << SCIENTIFIC(8,2) << Tmax << endl);
161  DEBUG("dE/dx [MeV g^-1 cm^2] " << FIXED(5,4) << value << endl);
162 
163  h0.SetBinContent(i, value);
164  }
165 
166 
167  TF1 f1("f1", "[0] + [1]*x + [2]*x*x + [3]*x*x*x");
168 
169  if (option.find('W') == string::npos) {
170  option += "W";
171  }
172 
173  f1.SetParameter(0, h0.GetMinimum());
174  f1.SetParameter(1, (h0.GetMaximum() - h0.GetMinimum()) / (h0.GetXaxis()->GetXmax() - h0.GetXaxis()->GetXmin()));
175  f1.SetParameter(2, 0.0);
176  f1.SetParameter(3, 0.0);
177 
178  f1.SetLineColor(kRed);
179 
180  // fit
181 
182  h0.Fit(&f1, option.c_str(), "same");
183 
184 
185  cout << "\t// " << lepton << endl;
186  cout << "\t// dE/dX = a + bx + cx^2 + dx^3; // [MeV g^-1 cm^2]; x = log10(E/GeV);" << endl;
187 
188  for (int i = 0; i != 4; ++i) {
189  cout << "\tstatic const double " << (char) ('a' + i) << " = " << SCIENTIFIC(10,3) << f1.GetParameter(i) << ";" << endl;
190  }
191 
192  {
193  double Tmin = sqrt(EMIN*EMIN - MASS_ELECTRON*MASS_ELECTRON);
194 
195  double Emin = 1 * MASS_LEPTON;
196  double Emax = 5 * MASS_LEPTON;
197 
198  for (double E = 0.5 * (Emin + Emax); ; E = 0.5 * (Emin + Emax)) {
199 
200  const double gamma = E / MASS_LEPTON;
201  const double beta = sqrt(1.0 - 1.0/(gamma*gamma));
202 
203  const double Tmax = (lepton == electron ?
204  (0.5*sqrt(E*E - MASS_ELECTRON*MASS_ELECTRON)) :
205  (2.0*MASS_ELECTRON*beta*beta*gamma*gamma) / (1.0 + 2.0*gamma*RATIO + RATIO*RATIO));
206 
207  if (fabs(Tmax - Tmin) < precision) {
208  cout << "\tstatic const double Emin = " << FIXED(7,5) << E << "; // [GeV]" << endl;
209  break;
210  }
211 
212  if (Tmax > Tmin)
213  Emax = E;
214  else
215  Emin = E;
216  }
217  }
218 
219  out.Write();
220  out.Close();
221 }
Utility class to parse command line options.
Definition: JParser.hh:1493
static const uint32_t K[64]
Definition: crypt.cc:77
static const double MASS_MUON
muon mass [GeV]
Definition: JConstants.hh:59
then check_input_file $DETECTOR $INPUT_FILE for OPTION in A B C D E F
Definition: JFilter.sh:47
static const double MASS_TAU
tau mass [GeV]
Definition: JConstants.hh:60
Auxiliary data structure for floating point format specification.
Definition: JPrint.hh:481
fi JEventTimesliceWriter a
string outputFile
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
do set_variable OUTPUT_DIRECTORY $WORKDIR T
#define NOTICE(A)
Definition: JMessage.hh:64
int debug
debug level
Definition: JSirene.cc:61
#define FATAL(A)
Definition: JMessage.hh:67
JRange< Double_t > JRange_t
Definition: JFitToT.hh:34
int numberOfPoints
Definition: JResultPDF.cc:22
static const double INDEX_OF_REFRACTION_WATER
average index of refraction of water
Definition: JConstants.hh:37
Auxiliary data structure for floating point format specification.
Definition: JPrint.hh:518
static const double MASS_ELECTRON
electron mass [GeV]
Definition: JConstants.hh:58
then for LEPTON in muon tau positron electron
Definition: JDeltaRays.sh:39
source $JPP_DIR setenv csh $JPP_DIR eval JShellParser o a A
then usage $script[input file[working directory[option]]] nWhere option can be E
Definition: JMuonPostfit.sh:37
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
then set_variable FORMULA *[0] exp(-0.5 *(x-[1])*(x-[1])/([2]*[2]))" set_variable OUTPUT_FILE histogram.root JHistogram1D -o $WORKDIR/$OUTPUT_FILE -F "$FORMULA" -