Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JRunAnalyzer.cc
Go to the documentation of this file.
1 // c++ standard library
2 #include <iostream>
3 #include <iomanip>
4 // Jpp
5 
6 #include "JDetector/JDetector.hh"
9 
10 #include "JSupport/JSupport.hh"
11 #include "JSupport/JMeta.hh"
13 #include "JSupport/JTreeScanner.hh"
14 
15 #include "TROOT.h"
16 
17 #include "Jeep/JParser.hh"
18 #include "JDAQ/JDAQ.hh"
19 #include "JDAQ/JDAQTimeslice.hh"
20 #include "JDAQ/JDAQSummaryslice.hh"
21 
22 #include "JLang/JObjectReader.hh"
23 
24 #include "JROOT/JRootFileReader.hh"
25 
26 //JRunAnalyzer
27 #include "RunAnalyzer.hh"
28 #include "JRunHistograms.hh"
29 
30 using namespace KM3NETDAQ ;
31 using namespace JDETECTOR ;
32 using namespace JLANG ;
33 using namespace JPP ;
34 
35 
36 
37 /**
38  * Structure to store the different command line arguments for JRunAnalyzer.
39  */
40 struct IO{
41 
42  string ifname ;
43 
44  string ofname ;
45 
46  string detector_file ;
47 
48 };
49 
50 /**
51  * Parses the command line options and fills an IO structure with them.
52  *
53  * \param options an option structure
54  * \param argc the number of command line arguments
55  * \param argv the command line arguments
56  *
57  * \return 1 if works 2 if it doesn't work
58  */
59 inline int read_user_options(IO &options, int argc, char **argv){
60 
61  int a = 0;
62 
63  try {
64 
65  JParser<string> zap;
66 
67  zap["o"] = make_field(options.ofname) = "out.root" ;
68 
69  zap["f"] = make_field(options.ifname) ;
70 
71  zap["a"] = make_field(options.detector_file) ;
72 
73  if (zap.read(argc, argv) != 0)
74 
75  a = 1;
76 
77  }
78 
79  catch(const exception &error) {
80 
81  ERROR(error.what() << endl);
82 
83  a = 2;
84 
85  }
86 
87  return a;
88 
89 }
90 
91 
92 int main(int argc, char **argv) {
93 
94  IO options ;
95 
96  read_user_options(options, argc , argv) ;
97 
98  RunAnalyzer Analyzer ( options.ifname , options.detector_file) ;
99 
100  Analyzer.read_daqevents_from_file() ;
101 
102  Analyzer.read_summaryslices_from_file () ;
103 
105 
107 
109 
111 
113 
114  JRA_Histograms run_histograms = Analyzer.getHistograms();
115 
116  TFile outfile(options.ofname.c_str() , "recreate") ;
117 
118  putObject(&outfile , JMeta(argc, argv));
119 
120  JMeta::copy(options.ifname.c_str(), outfile);
121 
122  run_histograms.Write_to_file (outfile) ;
123 
124  outfile.Close() ;
125 
126  cout << "Done! " << endl ;
127 
128 }
Auxiliary class for ROOT I/O of application specific meta data.
Definition: JMeta.hh:71
Utility class to parse command line options.
Definition: JParser.hh:1410
void read_daqevents_from_file()
Definition: RunAnalyzer.hh:506
void read_summaryslices_from_file()
Definition: RunAnalyzer.hh:318
static void copy(const char *const file_name, TFile &out)
Copy meta data.
Definition: JMeta.hh:400
Structure to store the different command line arguments for JRunAnalyzer.
Definition: JRunAnalyzer.cc:40
string ofname
Definition: JRunAnalyzer.cc:44
void read_timeslices_from_file()
Definition: RunAnalyzer.hh:479
Data structure for detector geometry and calibration.
Timeslice data structure for L1 data.
Class dedicated to the analysis of KM3NeT runs.
Definition: RunAnalyzer.hh:37
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1836
JRA_Histograms getHistograms()
Definition: RunAnalyzer.hh:529
Timeslice data structure for L2 data.
ROOT I/O of application specific meta data.
#define ERROR(A)
Definition: JMessage.hh:64
Data time slice.
string ifname
Definition: JRunAnalyzer.cc:42
Timeslice data structure for SN data.
Scanning of objects from multiple files according a format that follows from the extension of each fi...
Direct access to module in detector data structure.
int read(const int argc, const char *const argv[])
Parse the program&#39;s command line options.
Definition: JParser.hh:1673
Utility class to parse command line options.
ROOT TTree parameter settings.
string detector_file
Definition: JRunAnalyzer.cc:46
KM3NeT DAQ constants, bit handling, etc.
int read_user_options(IO &options, int argc, char **argv)
Parses the command line options and fills an IO structure with them.
Definition: JRunAnalyzer.cc:59
Timeslice data structure for L0 data.
bool putObject(TDirectory *dir, const T &object)
Write object to ROOT directory.
int main(int argc, char *argv[])
Definition: Main.cpp:15