Jpp  16.0.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JPlotPD0.cc File Reference

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

#include <string>
#include <iostream>
#include <fstream>
#include <iomanip>
#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 "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 bright point using interpolation tables.

Author
mdejong

Definition in file JPlotPD0.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 28 of file JPlotPD0.cc.

29 {
30  using namespace std;
31  using namespace JPP;
32 
33  typedef JAbstractHistogram<double> JHistogram_t;
34 
35  vector<string> inputFile;
36  string outputFile;
37  double E;
38  double D;
39  double ct;
40  double TTS_ns;
41  JHistogram_t histogram;
42  int debug;
43 
44  try {
45 
46  JParser<> zap("Program to plot PDF of Cherenkov light from bright point using interpolation tables.");
47 
48  zap['f'] = make_field(inputFile);
49  zap['o'] = make_field(outputFile) = "";
50  zap['E'] = make_field(E, "shower energy [GeV]") = 1.0;
51  zap['R'] = make_field(D, "distance [m]");
52  zap['c'] = make_field(ct, "cosine PMT angle");
53  zap['T'] = make_field(TTS_ns, "PMT time smearing [ns]") = 0.0; // [ns]
54  zap['H'] = make_field(histogram, "histogram binning") = JHistogram_t();
55  zap['d'] = make_field(debug) = 0;
56 
57  zap(argc, argv);
58  }
59  catch(const exception &error) {
60  FATAL(error.what() << endl);
61  }
62 
63  JDistance<double>::precision = 1.0e-10;
64 
65  typedef JSplineFunction1S_t JFunction1D_t;
66  typedef JMAPLIST<JPolint1FunctionalMap,
67  JPolint1FunctionalGridMap>::maplist JMapList_t;
68  typedef JPDFTable<JFunction1D_t, JMapList_t> JPDF_t;
69 
70  const int N = inputFile.size();
71 
72  int type[N];
73  JPDF_t pdf [N];
74 
75  try {
76 
77  for (int i = 0; i != N; ++i) {
78 
79  NOTICE("loading input from file " << inputFile[i] << "... " << flush);
80 
81  type[i] = getPDFType(inputFile[i]);
82 
83  pdf [i].load(inputFile[i].c_str());
84 
85  pdf [i].setExceptionHandler(new JFunction1D_t::JDefaultResult(JMATH::zero));
86 
87  if (TTS_ns > 0.0) {
88  pdf[i].blur(TTS_ns);
89  }
90 
91  NOTICE("OK" << endl);
92  }
93  }
94  catch(const JException& error) {
95  FATAL(error.what() << endl);
96  }
97 
98 
99  if (outputFile == "") {
100 
101  for (double dt; cin >> dt; ) {
102 
103  for (int i = 0; i != N; ++i) {
104 
105  JFunction1D_t::result_type y = pdf[i](D, ct, dt);
106 
107  cout << setw(2) << type[i] << ' '
108  << SCIENTIFIC(7,1) << E << ' '
109  << FIXED(5,1) << D << ' '
110  << FIXED(5,2) << ct << ' '
111  << FIXED(5,1) << dt << ' '
112  << SCIENTIFIC(9,3) << get_value(y) << ' '
113  << SCIENTIFIC(9,3) << get_derivative(y) << ' '
114  << SCIENTIFIC(9,3) << get_integral(y) << ' '
115  << SCIENTIFIC(9,3) << get_total_integral(y) << endl;
116  }
117  }
118 
119  return 0;
120  }
121 
122 
123  TFile out(outputFile.c_str(), "recreate");
124 
125  int function = 0;
126 
127  if (inputFile.size() == 1 &&
128  inputFile.begin()->find(getLabel(SCATTERED_LIGHT_FROM_BRIGHT_POINT)) == string::npos) {
129  function = 1;
130  }
131 
132  //const double t0 = D * getIndexOfRefraction() / C; // time [ns]
133  const double t0 = 0.0; // time [ns]
134 
135  if (!histogram.is_valid()) {
136 
137  if (function == 1) {
138 
139  histogram = JHistogram_t(t0 - 20.0, t0 + 50.0);
140 
141  histogram.setBinWidth(0.1);
142 
143  } else {
144 
145  histogram = JHistogram_t(t0 - 20.0, t0 + 500.0);
146 
147  histogram.setBinWidth(0.5);
148  }
149  }
150 
151  TH1D h0("h0", NULL, histogram.getNumberOfBins(), histogram.getLowerLimit(), histogram.getUpperLimit());
152 
153  for (int i = 1; i <= h0.GetNbinsX(); ++i) {
154 
155  const double dt = h0.GetBinCenter(i) - t0;
156 
157  JFunction1D_t::result_type Y = JMATH::zero;
158 
159  for (int j = 0; j != N; ++j) {
160  Y += pdf[j](D, ct, dt) * E;
161  }
162 
163  h0.SetBinContent(i, get_value(Y));
164  }
165 
166  out.Write();
167  out.Close();
168 }
Utility class to parse command line options.
Definition: JParser.hh:1500
then usage E
Definition: JMuonPostfit.sh:35
std::string getLabel(const JLocation &location)
Get module label for monitoring and other applications.
Definition: JLocation.hh:246
then JShowerPostfit f $INPUT_FILE o $OUTPUT_FILE N
static const JZero zero
Function object to assign zero value.
Definition: JZero.hh:105
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
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
#define NOTICE(A)
Definition: JMessage.hh:64
JResultEvaluator< JResult_t >::result_type get_total_integral(const JResult_t &value)
Helper method to convert function value to total integral value.
Definition: JResult.hh:1037
int debug
debug level
Definition: JSirene.cc:63
scattered light from bright point
Definition: JPDFTypes.hh:46
#define FATAL(A)
Definition: JMessage.hh:67
int getPDFType(const std::string &file_name)
Get PDF type.
Definition: JPDFTypes.hh:81
JResultEvaluator< JResult_t >::result_type get_derivative(const JResult_t &value)
Helper method to convert function value to derivative value.
Definition: JResult.hh:1011
int j
Definition: JPolint.hh:682
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:484
do echo Generating $dir eval D
Definition: JDrawLED.sh:53
JResultEvaluator< JResult_t >::result_type get_value(const JResult_t &value)
Helper method to recursively evaluate a to function value.
Definition: JResult.hh:998