Jpp test-rotations-new
the software that should make you happy
Loading...
Searching...
No Matches
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

◆ main()

int main ( int argc,
char ** argv )

Definition at line 28 of file JPlotPD0.cc.

29{
30 using namespace std;
31 using namespace JPP;
32
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
64
65 typedef JSplineFunction1S_t JFunction1D_t;
67 JPolint1FunctionalGridMap>::maplist JMapList_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}
string outputFile
#define NOTICE(A)
Definition JMessage.hh:64
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
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
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
std::string getLabel(const JLocation &location)
Get module label for monitoring and other applications.
Definition JLocation.hh:247
static const JZero zero
Function object to assign zero value.
Definition JZero.hh:105
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_derivative(const JResult_t &value)
Helper method to convert function value to derivative value.
Definition JResult.hh:1011
int j
Definition JPolint.hh:801
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
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: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.
Template class for distance evaluation.
Definition JDistance.hh:24
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