Jpp  19.0.0
the software that should make you happy
 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 "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

int main ( int  argc,
char **  argv 
)

Definition at line 31 of file JPlotPDF.cc.

32 {
33  using namespace std;
34  using namespace JPP;
35 
36  typedef JAbstractHistogram<double> JHistogram_t;
37 
38  vector<string> inputFile;
39  string outputFile;
40  double E;
41  double R;
42  double z;
43  JAngle3D dir;
44  double TTS_ns;
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;
70  typedef JMAPLIST<JPolint1FunctionalMap,
71  JPolint1FunctionalGridMap,
72  JPolint1FunctionalGridMap>::maplist JMapList_t;
73  typedef JPDFTable<JFunction1D_t, JMapList_t> JPDF_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 }
Utility class to parse command line options.
Definition: JParser.hh:1711
static const double COS_THETA_C_WATER
Average cosine corresponding to the group velocity.
then usage $script< input file >[option[primary[working directory]]] nWhere option can be E
Definition: JMuonPostfit.sh:40
static const double MASS_MUON
muon mass [GeV]
static const JGeaneWater gWater
Function object for energy loss of muon in sea water.
Definition: JGeane.hh:381
static const JZero zero
Function object to assign zero value.
Definition: JZero.hh:105
then warning Cannot perform comparison test for histogram
then fatal Wrong number of arguments fi set_variable STRING $argv[1] set_variable DETECTORXY_TXT $WORKDIR $DETECTORXY_TXT tail read X Y CHI2 RMS printf optimum n $X $Y $CHI2 $RMS awk v Y
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
string outputFile
direct light from muon
Definition: JPDFTypes.hh:26
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_bremsstrahlung(const int pdf)
Test if given PDF type corresponds to Cherenkov light from Bremsstrahlung.
Definition: JPDFTypes.hh:137
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2158
#define NOTICE(A)
Definition: JMessage.hh:64
#define FATAL(A)
Definition: JMessage.hh:67
int getPDFType(const std::string &file_name)
Get PDF type.
Definition: JPDFTypes.hh:77
then JCookie sh JDataQuality D $DETECTOR_ID R
Definition: JDataQuality.sh:41
virtual double getE(const double E, const double dx) const override
Get energy of muon after specified distance.
Definition: JGeane.hh:257
then usage $script[energy[distance[z of PMT]]] fi case set_variable z
Definition: JDrawPDF.sh:45
then usage $script< input file >[option[primary[working directory]]] nWhere option can be N
Definition: JMuonPostfit.sh:40
JResultEvaluator< JResult_t >::result_type get_derivative(const JResult_t &value)
Helper method to convert function value to derivative value.
Definition: JResult.hh:1011
bool is_deltarays(const int pdf)
Test if given PDF type corresponds to Cherenkov light from delta-rays.
Definition: JPDFTypes.hh:151
double getTanThetaC()
Get average tangent of Cherenkov angle of water corresponding to group velocity.
then set_variable DETECTOR set_variable OUTPUT_FILE set_variable DAQ_FILE set_variable PMT_FILE else fatal Wrong number of arguments fi JPrintTree f $DAQ_FILE type
int j
Definition: JPolint.hh:792
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
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:486
JResultEvaluator< JResult_t >::result_type get_value(const JResult_t &value)
Helper method to recursively evaluate a to function value.
Definition: JResult.hh:998
int debug
debug level
JAbstractHistogram< double > JHistogram_t
Type definition for scan along axis.
Definition: JBillabong.cc:61