Jpp
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 }
JRootFileReader.hh
JMeta.hh
JDAQ.hh
JRunHistograms.hh
RunAnalyzer::read_daqevents_from_file
void read_daqevents_from_file()
Definition: RunAnalyzer.hh:518
KM3NETDAQ::JDAQTimesliceL2
Timeslice data structure for L2 data.
Definition: JDAQTimeslice.hh:325
RunAnalyzer::read_summaryslices_from_file
void read_summaryslices_from_file()
Definition: RunAnalyzer.hh:330
read_user_options
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
KM3NETDAQ::JDAQTimesliceSN
Timeslice data structure for SN data.
Definition: JDAQTimeslice.hh:331
KM3NETDAQ::JDAQTimeslice
Data time slice.
Definition: JDAQTimeslice.hh:36
JPARSER::JParser
Utility class to parse command line options.
Definition: JParser.hh:1493
RunAnalyzer
Class dedicated to the analysis of KM3NeT runs.
Definition: RunAnalyzer.hh:37
JDAQTimeslice.hh
JROOT::putObject
bool putObject(TDirectory *dir, const T &object)
Write object to ROOT directory.
Definition: JRootFileWriter.hh:38
IO
Structure to store the different command line arguments for JRunAnalyzer.
Definition: JRunAnalyzer.cc:40
JObjectReader.hh
JTreeScanner.hh
RunAnalyzer::getHistograms
JRA_Histograms getHistograms()
Definition: RunAnalyzer.hh:541
JDAQSummaryslice.hh
JSupport.hh
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
ERROR
#define ERROR(A)
Definition: JMessage.hh:66
JRA_Histograms
Definition: JRunHistograms.hh:1485
IO::ofname
string ofname
Definition: JRunAnalyzer.cc:44
KM3NETDAQ::JDAQTimesliceL0
Timeslice data structure for L0 data.
Definition: JDAQTimeslice.hh:313
main
int main(int argc, char **argv)
Definition: JRunAnalyzer.cc:92
JModuleRouter.hh
IO::ifname
string ifname
Definition: JRunAnalyzer.cc:42
JMultipleFileScanner.hh
JParser.hh
JDetectorToolkit.hh
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
RunAnalyzer::read_timeslices_from_file
void read_timeslices_from_file()
Definition: RunAnalyzer.hh:491
RunAnalyzer.hh
JSUPPORT::JMeta
Auxiliary class for ROOT I/O of application specific meta data.
Definition: JMeta.hh:71
IO::detector_file
string detector_file
Definition: JRunAnalyzer.cc:46
KM3NETDAQ
KM3NeT DAQ data structures and auxiliaries.
Definition: DataQueue.cc:39
JDetector.hh
JLANG
Auxiliary classes and methods for language specific functionality.
Definition: JAbstractClass.hh:10
KM3NETDAQ::JDAQTimesliceL1
Timeslice data structure for L1 data.
Definition: JDAQTimeslice.hh:319
JDETECTOR
Auxiliary classes and methods for detector calibration.
Definition: JAnchor.hh:12
JPARSER::JParser::read
int read(const int argc, const char *const argv[])
Parse the program's command line options.
Definition: JParser.hh:1791
JSUPPORT::JMeta::copy
static void copy(const char *const file_name, TFile &out)
Copy meta data.
Definition: JMeta.hh:396