Jpp  15.0.4
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JPlotPDG.cc File Reference

Program to plot PDF of Cherenkov light from EM-shower or scattered light from muon 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 "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 EM-shower or scattered light from muon using interpolation tables.

Author
mdejong

Definition in file JPlotPDG.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 29 of file JPlotPDG.cc.

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