Jpp  18.2.1-ARCA-DF-PATCH
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JCDFTable2D.cc
Go to the documentation of this file.
1 
2 #include <string>
3 #include <iostream>
4 #include <fstream>
5 #include <iomanip>
6 #include <vector>
7 
8 #include "TROOT.h"
9 #include "TFile.h"
10 #include "TH2D.h"
11 
12 #include "JTools/JFunction1D_t.hh"
14 #include "JPhysics/JCDFTable.hh"
15 #include "JPhysics/JPDFTypes.hh"
16 #include "JPhysics/JPDFToolkit.hh"
17 #include "JSirene/JCDFTable2D.hh"
18 #include "Jeep/JProperties.hh"
19 #include "Jeep/JPrint.hh"
20 #include "Jeep/JParser.hh"
21 #include "Jeep/JMessage.hh"
22 
23 
24 /**
25  * \file
26  *
27  * Program to plot CDF of Cherenkov light from shower using interpolation tables.
28  * \author mdejong
29  */
30 int main(int argc, char **argv)
31 {
32  using namespace std;
33  using namespace JPP;
34 
35  string inputFile;
36  string outputFile;
37  int numberOfBins = 200; //!< number of bins for average CDF integral of optical module
38  double safetyFactor = 1.7; //!< safety factor for average CDF integral of optical module
39  int debug;
40 
41  try {
42 
43  JProperties properties;
44 
45  properties.insert(gmake_property(numberOfBins));
46  properties.insert(gmake_property(safetyFactor));
47 
48  JParser<> zap("Program to plot PDF of Cherenkov light from shower using interpolation tables.");
49 
50  zap['@'] = make_field(properties) = JPARSER::initialised();
51  zap['f'] = make_field(inputFile);
52  zap['o'] = make_field(outputFile) = "cdf.root";
53  zap['d'] = make_field(debug) = 0;
54 
55  zap(argc, argv);
56  }
57  catch(const exception &error) {
58  FATAL(error.what() << endl);
59  }
60 
61 
62  typedef JHermiteSplineFunction1D_t JFunction1D_t;
63  typedef JMAPLIST<JPolint1FunctionalMap,
64  JPolint1FunctionalMap,
65  JPolint1FunctionalGridMap,
66  JPolint1FunctionalGridMap>::maplist JMapList_t;
67  typedef JCDFTable<JFunction1D_t, JMapList_t> JCDF_t;
68 
69  typedef JCDFTable2D<JFunction1D_t::argument_type, JFunction1D_t::result_type> JCDF2D_t;
70 
71  JCDF_t function;
72 
73  try {
74 
75  NOTICE("loading input from file " << inputFile << "... " << flush);
76 
77  function.load(inputFile.c_str());
78 
79  NOTICE("OK" << endl);
80  }
81  catch(const JException& error) {
82  FATAL(error.what() << endl);
83  }
84 
85  JCDF2D_t integral(function, numberOfBins, safetyFactor);
86 
87 
88  TFile out(outputFile.c_str(), "recreate");
89 
90  TH2D h0("h0", NULL,
91  200, function.intensity.getXmin(), function.intensity.getXmax(),
92  200, -1.0, +1.0);
93 
94  for (int ix = 1; ix <= h0.GetXaxis()->GetNbins(); ++ix) {
95  for (int iy = 1; iy <= h0.GetYaxis()->GetNbins(); ++iy) {
96 
97  const double R = h0.GetXaxis()->GetBinCenter(ix);
98  const double cd = h0.GetYaxis()->GetBinCenter(iy);
99  const double y = integral.getNPE(R, cd);
100 
101  h0.SetBinContent(ix, iy, y);
102  }
103  }
104 
105  out.Write();
106  out.Close();
107 }
Utility class to parse command line options.
Definition: JParser.hh:1514
int main(int argc, char *argv[])
Definition: Main.cc:15
Auxiliary methods for PDF calculations.
#define gmake_property(A)
macros to convert (template) parameter to JPropertiesElement object
double safetyFactor
safety factor for average CDF integral of optical module
Definition: JSirene.cc:70
Utility class to parse parameter values.
Definition: JProperties.hh:497
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:83
string outputFile
Utility class to parse parameter values.
Various implementations of functional maps.
Numbering scheme for PDF types.
I/O formatting auxiliaries.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
#define NOTICE(A)
Definition: JMessage.hh:64
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
then JCookie sh JDataQuality D $DETECTOR_ID R
Definition: JDataQuality.sh:41
Utility class to parse command line options.
int numberOfBins
number of bins for average CDF integral of optical module
Definition: JSirene.cc:69
int debug
debug level