Jpp  master_rocky-43-ge265d140c
the software that should make you happy
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 "JPhysics/JPDFToolkit.hh"
#include "JGeometry3D/JAngle3D.hh"
#include "Jeep/JPrint.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"
#include "JPhysics/JGeane.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, bofearraigh

Definition in file JPlotPDF.cc.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 31 of file JPlotPDF.cc.

32 {
33  using namespace std;
34  using namespace JPP;
35 
37 
38  vector<string> inputFile;
39  string outputFile;
40  double E;
41  double R;
42  double z;
43  JAngle3D dir;
44  double TTS_ns;
45  JHistogram_t histogram;
46  int debug;
47 
48  try {
49 
50  JParser<> zap("Program to plot PDF of Cherenkov light from muon using interpolation tables.");
51 
52  zap['f'] = make_field(inputFile);
53  zap['o'] = make_field(outputFile) = "";
54  zap['E'] = make_field(E, "muon energy at vertex [GeV]") = 1.0;
55  zap['R'] = make_field(R, "distance of approach [m]");
56  zap['z'] = make_field(z, "PMT z-position [m]");
57  zap['D'] = make_field(dir, "(theta, phi) of PMT [rad]");
58  zap['T'] = make_field(TTS_ns, "PMT time smearing [ns]") = 0.0;
59  zap['H'] = make_field(histogram, "histogram binning") = JHistogram_t();
60  zap['d'] = make_field(debug) = 0;
61 
62  zap(argc, argv);
63  }
64  catch(const exception &error) {
65  FATAL(error.what() << endl);
66  }
67 
68 
69  typedef JSplineFunction1S_t JFunction1D_t;
72  JPolint1FunctionalGridMap>::maplist JMapList_t;
74 
75  const int N = inputFile.size();
76 
77  int type[N];
78  JPDF_t pdf [N];
79 
80  try {
81 
82  for (int i = 0; i != N; ++i) {
83 
84  NOTICE("loading input from file " << inputFile[i] << "... " << flush);
85 
86  type[i] = getPDFType(inputFile[i]);
87 
88  pdf [i].load(inputFile[i].c_str());
89 
90  pdf [i].setExceptionHandler(new JFunction1D_t::JDefaultResult(JMATH::zero));
91 
92  if (TTS_ns > 0.0) {
93  pdf[i].blur(TTS_ns);
94  }
95 
96  NOTICE("OK" << endl);
97  }
98  }
99  catch(const JException& error) {
100  FATAL(error.what() << endl);
101  }
102 
103  const double z_emission = z - R/getTanThetaC(); // emission point z-position
104  const double E_emission = gWater.getE(E, z_emission ); // Get energy of muon at emission point
105 
106  if (outputFile == "") {
107 
108  for (double dt; cin >> dt; ) {
109 
110  for (int i = 0; i != N; ++i) {
111 
112  JFunction1D_t::result_type y = pdf[i](R, dir.getTheta(), dir.getPhi(), dt);
113 
114  if (is_bremsstrahlung(type[i])) {
115  y *= E_emission;
116  } else if (is_deltarays(type[i])) {
117  y *= getDeltaRaysFromMuon(E_emission);
118  }
119 
120  cout << setw(2) << type[i] << ' '
121  << SCIENTIFIC(7,1) << E << ' '
122  << FIXED(5,1) << R << ' '
123  << FIXED(5,1) << z << ' '
124  << FIXED(5,2) << dir.getTheta() << ' '
125  << FIXED(5,2) << dir.getPhi() << ' '
126  << FIXED(5,1) << dt << ' '
127  << SCIENTIFIC(9,3) << get_value(y) << endl;
128  }
129  }
130 
131  return 0;
132  }
133 
134  TFile out(outputFile.c_str(), "recreate");
135 
136  int function = 0;
137 
138  if (inputFile.size() == 1 && getPDFType(inputFile[0]) == DIRECT_LIGHT_FROM_MUON) {
139  function = 1;
140  }
141 
142  const double t0 = 0.0; // time [ns]
143 
144  if (!histogram.is_valid()) {
145 
146  if (function == 1) {
147 
148  histogram = JHistogram_t(t0 - 20.0, t0 + 50.0);
149 
150  histogram.setBinWidth(0.1);
151 
152  } else {
153 
154  histogram = JHistogram_t(t0 - 20.0, t0 + 500.0);
155 
156  histogram.setBinWidth(0.5);
157  }
158  }
159 
160  TH1D h0("h0", NULL, histogram.getNumberOfBins(), histogram.getLowerLimit(), histogram.getUpperLimit());
161  TH1D h1("h1", NULL, histogram.getNumberOfBins(), histogram.getLowerLimit(), histogram.getUpperLimit());
162  TH1D h2("h2", NULL, histogram.getNumberOfBins(), histogram.getLowerLimit(), histogram.getUpperLimit());
163 
164  for (int i = 1; i <= h0.GetNbinsX(); ++i) {
165 
166  const double dt = h0.GetBinCenter(i) - t0;
167 
168  JFunction1D_t::result_type Y = JMATH::zero;
169 
170  for (int j = 0; j != N; ++j) {
171 
172  if ( E_emission > MASS_MUON* (1/COS_THETA_C_WATER) ) { // muon emission energy has to be above Cherenkov threshold
173 
174  if (z_emission >= 0 && z_emission <= gWater(E)) { // emission point is between start and end point of muon
175 
176  JFunction1D_t::result_type y = pdf[j](R, dir.getTheta(), dir.getPhi(), dt);
177 
178  if (is_bremsstrahlung(type[j])) {
179  y *= E_emission;
180  } else if (is_deltarays(type[j])) {
181  y *= getDeltaRaysFromMuon(E_emission);
182  }
183  Y += y;
184  }
185  }
186  }
187 
188 
189  h0.SetBinContent(i, get_value (Y));
190  h1.SetBinContent(i, get_derivative(Y));
191  h2.SetBinContent(i, get_integral (Y));
192  }
193 
194  out.Write();
195  out.Close();
196 }
string outputFile
#define NOTICE(A)
Definition: JMessage.hh:64
#define FATAL(A)
Definition: JMessage.hh:67
int debug
debug level
Definition: JSirene.cc:69
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2142
Data structure for angles in three dimensions.
Definition: JAngle3D.hh:35
double getTheta() const
Get theta angle.
Definition: JAngle3D.hh:86
double getPhi() const
Get phi angle.
Definition: JAngle3D.hh:97
General exception.
Definition: JException.hh:24
virtual const char * what() const override
Get error message.
Definition: JException.hh:64
Utility class to parse command line options.
Definition: JParser.hh:1698
virtual double getE(const double E, const double dx) const override
Get energy of muon after specified distance.
Definition: JGeane.hh:257
Multi-dimensional PDF table for arrival time of Cherenkov light.
Definition: JPDFTable.hh:44
T getLowerLimit() const
Get lower limit.
Definition: JRange.hh:202
T getUpperLimit() const
Get upper limit.
Definition: JRange.hh:213
JAbstractHistogram< double > JHistogram_t
Type definition for scan along axis.
Definition: JBillabong.cc:61
static const JZero zero
Function object to assign zero value.
Definition: JZero.hh:105
double getDeltaRaysFromMuon(const double E, const JRange< double > T_GeV=JRange< double >(DELTARAY_TMIN, DELTARAY_TMAX))
Equivalent EM-shower energy due to delta-rays per unit muon track length.
Definition: JPDFToolkit.hh:260
bool is_deltarays(const int pdf)
Test if given PDF type corresponds to Cherenkov light from delta-rays.
Definition: JPDFTypes.hh:151
static const double MASS_MUON
muon mass [GeV]
bool is_bremsstrahlung(const int pdf)
Test if given PDF type corresponds to Cherenkov light from Bremsstrahlung.
Definition: JPDFTypes.hh:137
static const JGeaneWater gWater
Function object for energy loss of muon in sea water.
Definition: JGeane.hh:381
double getTanThetaC()
Get average tangent of Cherenkov angle of water corresponding to group velocity.
@ DIRECT_LIGHT_FROM_MUON
direct light from muon
Definition: JPDFTypes.hh:26
static const double COS_THETA_C_WATER
Average cosine corresponding to the group velocity.
int getPDFType(const std::string &file_name)
Get PDF type.
Definition: JPDFTypes.hh:77
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
JResultEvaluator< JResult_t >::result_type get_value(const JResult_t &value)
Helper method to recursively evaluate a to function value.
Definition: JResult.hh:998
JResultEvaluator< JResult_t >::result_type get_integral(const JResult_t &value)
Helper method to convert function value to partial integral value.
Definition: JResult.hh:1024
int j
Definition: JPolint.hh:792
JResultEvaluator< JResult_t >::result_type get_derivative(const JResult_t &value)
Helper method to convert function value to derivative value.
Definition: JResult.hh:1011
Definition: JSTDTypes.hh:14
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:448
Simple data structure for histogram binning.
void setBinWidth(const abscissa_type dx, int option=0)
Set bin width.
bool is_valid() const
Check validity of histogram binning.
int getNumberOfBins() const
Get number of bins.
Auxiliary class for recursive map list generation.
Definition: JMapList.hh:109
Type definition of a 1st degree polynomial interpolation based on a JGridMap implementation.
Type definition of a 1st degree polynomial interpolation based on a JMap implementation.
Type definition of a spline interpolation method based on a JCollection with JResultPDF result type.
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:488