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

Auxiliary program to add PDF tables of the arrival time of the Cherenkov light from a muon. More...

#include <string>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <vector>
#include "JTools/JFunction1D_t.hh"
#include "JTools/JFunctionalMap_t.hh"
#include "JPhysics/JPDFTable.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

Auxiliary program to add PDF tables of the arrival time of the Cherenkov light from a muon.

Author
mdejong

Definition in file JAddPDF.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 22 of file JAddPDF.cc.

23 {
24  using namespace std;
25 
26  vector<string> inputFile;
27  string outputFile;
28  int debug;
29 
30  try {
31 
32  JParser<> zap("Auxiliary program to add PDF tables of the arrival time of the Cherenkov light from a muon.");
33 
34  zap['f'] = make_field(inputFile);
35  zap['o'] = make_field(outputFile);
36  zap['d'] = make_field(debug) = 2;
37 
38  zap(argc, argv);
39  }
40  catch(const exception &error) {
41  FATAL(error.what() << endl);
42  }
43 
44 
45  if (inputFile.empty()) {
46  FATAL("No input file(s)." << endl);
47  }
48 
49  using namespace JPP;
50 
51  typedef JSplineFunction1D_t JFunction1D_t;
52  typedef JMAPLIST<JPolint1FunctionalMap,
53  JPolint1FunctionalGridMap,
54  JPolint1FunctionalGridMap>::maplist JMapList_t;
55  typedef JPDFTable<JFunction1D_t, JMapList_t> JPDF_t;
56 
57  const JFunction1D_t::JSupervisor supervisor(new JFunction1D_t::JDefaultResult(0.0));
58 
59  JPDF_t pdf;
60 
61  for (vector<string>::const_iterator i = inputFile.begin(); i != inputFile.end(); ++i) {
62 
63  try {
64 
65  NOTICE("loading input from file " << *i << "... " << flush);
66 
67  JPDF_t buffer;
68 
69  buffer.load(i->c_str());
70  buffer.compile();
71  buffer.setExceptionHandler(supervisor);
72 
73  NOTICE("OK" << endl);
74 
75  if (pdf.empty())
76  pdf = buffer;
77  else
78  pdf.add(buffer);
79  }
80  catch(const JException& error) {
81  FATAL(error.what() << endl);
82  }
83  }
84 
85  try {
86 
87  NOTICE("storing output to file " << outputFile << "... " << flush);
88 
89  pdf.store(outputFile.c_str());
90 
91  NOTICE("OK" << endl);
92  }
93  catch(const JException& error) {
94  FATAL(error << endl);
95  }
96 }
Utility class to parse command line options.
Definition: JParser.hh:1514
string outputFile
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
#define NOTICE(A)
Definition: JMessage.hh:64
#define FATAL(A)
Definition: JMessage.hh:67
int debug
debug level