Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JPlotPDF.cc File Reference

Program to plot PDF of Cherenkov light from muon using interpolation tables. More...

#include <string>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <vector>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "JTools/JFunction1D_t.hh"
#include "JTools/JFunctionalMap_t.hh"
#include "JTools/JAbstractHistogram.hh"
#include "JPhysics/JPDFTransformer.hh"
#include "JPhysics/JPDFTable.hh"
#include "JPhysics/JPDFTypes.hh"
#include "JGeometry3D/JAngle3D.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 plot PDF of Cherenkov light from muon using interpolation tables.

Author
mdejong

Definition in file JPlotPDF.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 30 of file JPlotPDF.cc.

31 {
32  using namespace std;
33  using namespace JPP;
34 
35  typedef JAbstractHistogram<double> JHistogram_t;
36 
37  vector<string> inputFile;
38  string outputFile;
39  double E;
40  double R;
41  JAngle3D dir;
42  double TTS_ns;
43  JHistogram_t histogram;
44  int debug;
45 
46  try {
47 
48  JParser<> zap("Program to plot PDF of Cherenkov light from muon using interpolation tables.");
49 
50  zap['f'] = make_field(inputFile);
51  zap['o'] = make_field(outputFile) = "";
52  zap['E'] = make_field(E, "muon energy [GeV]") = 1.0;
53  zap['R'] = make_field(R, "distance of approach [m]");
54  zap['D'] = make_field(dir, "(theta, phi) of PMT [rad]");
55  zap['T'] = make_field(TTS_ns, "PMT time smearing [ns]") = 0.0; // [ns]
56  zap['H'] = make_field(histogram, "histogram binning") = JHistogram_t();
57  zap['d'] = make_field(debug) = 0;
58 
59  zap(argc, argv);
60  }
61  catch(const exception &error) {
62  FATAL(error.what() << endl);
63  }
64 
65 
66  typedef JSplineFunction1S_t JFunction1D_t;
67  //typedef JPolint1Function1D_t JFunction1D_t;
68  typedef JMAPLIST<JPolint1FunctionalMap,
69  JPolint1FunctionalGridMap,
70  JPolint1FunctionalGridMap>::maplist JMapList_t;
71  typedef JPDFTable<JFunction1D_t, JMapList_t> JPDF_t;
72 
73  const int N = inputFile.size();
74 
75  int type[N];
76  JPDF_t pdf [N];
77 
78  try {
79 
80  for (int i = 0; i != N; ++i) {
81 
82  NOTICE("loading input from file " << inputFile[i] << "... " << flush);
83 
84  type[i] = getPDFType(inputFile[i]);
85 
86  pdf [i].load(inputFile[i].c_str());
87 
88  pdf [i].setExceptionHandler(new JFunction1D_t::JDefaultResult(JMATH::zero));
89 
90  if (TTS_ns > 0.0) {
91  pdf[i].blur(TTS_ns);
92  }
93 
94  NOTICE("OK" << endl);
95  }
96  }
97  catch(const JException& error) {
98  FATAL(error.what() << endl);
99  }
100 
101 
102  if (outputFile == "") {
103 
104  for (double dt; cin >> dt; ) {
105 
106  for (int i = 0; i != N; ++i) {
107 
108  JFunction1D_t::result_type y = pdf[i](R, dir.getTheta(), dir.getPhi(), dt);
109 
110  if (is_bremsstrahlung(type[i])) {
111  y *= E;
112  } else if (is_deltarays(type[i])) {
113  y *= getDeltaRaysFromMuon(E);
114  }
115 
116  cout << setw(2) << type[i] << ' '
117  << SCIENTIFIC(7,1) << E << ' '
118  << FIXED(5,1) << R << ' '
119  << FIXED(5,2) << dir.getTheta() << ' '
120  << FIXED(5,2) << dir.getPhi() << ' '
121  << FIXED(5,1) << dt << ' '
122  << SCIENTIFIC(9,3) << get_value(y) << endl;
123  }
124  }
125 
126  return 0;
127  }
128 
129 
130  TFile out(outputFile.c_str(), "recreate");
131 
132  int function = 0;
133 
134  if (inputFile.size() == 1 && getPDFType(inputFile[0]) == DIRECT_LIGHT_FROM_MUON) {
135  function = 1;
136  }
137 
138  //const double z0 = -100.0; // [m]
139  //const double t0 = (-z0 + R * getTanThetaC()) / C; // time [ns]
140  const double t0 = 0.0; // time [ns]
141 
142  if (!histogram.is_valid()) {
143 
144  if (function == 1) {
145 
146  histogram = JHistogram_t(t0 - 20.0, t0 + 50.0);
147 
148  histogram.setBinWidth(0.1);
149 
150  } else {
151 
152  histogram = JHistogram_t(t0 - 20.0, t0 + 500.0);
153 
154  histogram.setBinWidth(0.5);
155  }
156  }
157 
158  TH1D h0("h0", NULL, histogram.getNumberOfBins(), histogram.getLowerLimit(), histogram.getUpperLimit());
159  TH1D h1("h1", NULL, histogram.getNumberOfBins(), histogram.getLowerLimit(), histogram.getUpperLimit());
160  TH1D h2("h2", NULL, histogram.getNumberOfBins(), histogram.getLowerLimit(), histogram.getUpperLimit());
161 
162  for (int i = 1; i <= h0.GetNbinsX(); ++i) {
163 
164  const double dt = h0.GetBinCenter(i) - t0;
165 
166  JFunction1D_t::result_type Y = JMATH::zero;
167 
168  for (int j = 0; j != N; ++j) {
169 
170  JFunction1D_t::result_type y = pdf[j](R, dir.getTheta(), dir.getPhi(), dt);
171 
172  if (is_bremsstrahlung(type[j])) {
173  y *= E;
174  } else if (is_deltarays(type[j])) {
175  y *= getDeltaRaysFromMuon(E);
176  }
177 
178  Y += y;
179  }
180 
181  h0.SetBinContent(i, get_value (Y));
182  h1.SetBinContent(i, get_derivative(Y));
183  h2.SetBinContent(i, get_integral (Y));
184  }
185 
186  out.Write();
187  out.Close();
188 }
Utility class to parse command line options.
Definition: JParser.hh:1410
static const JZero zero
Function object to assign zero value.
Definition: JZero.hh:94
Auxiliary data structure for floating point format specification.
Definition: JPrint.hh:461
string outputFile
direct light from muon
Definition: JPDFTypes.hh:29
bool is_bremsstrahlung(const int pdf)
Test if given PDF type corresponds to Cherenkov light from Bremsstrahlung.
Definition: JPDFTypes.hh:157
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1836
#define NOTICE(A)
Definition: JMessage.hh:62
int debug
debug level
Definition: JSirene.cc:59
#define FATAL(A)
Definition: JMessage.hh:65
int getPDFType(const std::string &file_name)
Get PDF type.
Definition: JPDFTypes.hh:75
JResultEvaluator< JResult_t >::result_type get_derivative(const JResult_t &value)
Helper method to convert function value to derivative value.
Definition: JResult.hh:761
bool is_deltarays(const int pdf)
Test if given PDF type corresponds to Cherenkov light from delta-rays.
Definition: JPDFTypes.hh:171
double getDeltaRaysFromMuon(const double E)
Equivalent EM-shower energy due to delta-rays per unit muon track length.
Definition: JPDFToolkit.hh:81
JResultEvaluator< JResult_t >::result_type get_integral(const JResult_t &value)
Helper method to convert function value to partial integral value.
Definition: JResult.hh:774
Auxiliary data structure for floating point format specification.
Definition: JPrint.hh:498
JResultEvaluator< JResult_t >::result_type get_value(const JResult_t &value)
Helper method to recursively evaluate a to function value.
Definition: JResult.hh:748