Jpp  15.0.3
the software that should make you happy
 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 
5 // Jpp
6 #include "JDetector/JDetector.hh"
9 
10 #include "JTools/JRange.hh"
11 #include "JLang/JToken.hh"
12 #include "JGizmo/JGizmoToolkit.hh"
13 
14 #include "JSupport/JSupport.hh"
15 #include "JSupport/JMeta.hh"
17 #include "JSupport/JTreeScanner.hh"
18 
19 #include "TROOT.h"
20 
21 #include "Jeep/JParser.hh"
22 
25 
26 #include "JDAQ/JDAQTimesliceIO.hh"
28 
29 #include "JLang/JObjectReader.hh"
30 
31 #include "JROOT/JRootFileReader.hh"
33 #include "JROOT/JRootToolkit.hh"
34 #include "JROOT/JRootFileWriter.hh"
35 
36 //JRunAnalyzer
37 #include "JRunAnalyzer.hh"
38 #include "JRunHistograms.hh"
39 
40 using namespace KM3NETDAQ;
41 using namespace JDETECTOR;
42 using namespace JLANG;
43 using namespace JPP;
44 
45 /**
46  * \author rgruiz, adomi
47  */
48 
49 int main(int argc, char **argv) {
50 
51  typedef JToken<';'> JToken_t;
52 
53  string inputFile;
54  string outputFile;
55  string detectorFile;
56  JLimit_t nTimeslices;
57  JLimit_t nSummaryslices;
58  JLimit_t nEvents;
60 
61  try {
62 
63  JParser<> zap;
64 
65  zap['f'] = make_field(inputFile , "Path to input file " );
66  zap['o'] = make_field(outputFile , "Path to output file" ) = "out.root";
67  zap['a'] = make_field(detectorFile , "path to detector file" );
68  zap['t'] = make_field(nTimeslices , "number of timeslices" ) = JLimit::max();
69  zap['s'] = make_field(nSummaryslices , "number of summaryslices") = JLimit::max();
70  zap['n'] = make_field(nEvents , "number of events" ) = JLimit::max();
71  zap['@'] = make_field(parameters, "parameter values, e.g: \"p0 = 1.0;\"");
72 
73  zap(argc,argv);
74  }
75  catch(const exception &error) {
76  ERROR(error.what() << endl);
77  }
78 
79  bool pmt_analysis = false;
80 
81  for (vector<JToken_t>::const_iterator i = parameters.begin(); i != parameters.end(); ++i) {
82 
83  if(getParameter(*i) == 0 && getValue(*i) > 0) pmt_analysis = true;
84 
85  }
86 
87  if(pmt_analysis == true){
88  cout << "JRUNANALYZER RUNNING WITH ALL AVAILABLE PLOTS. It may take a while!" << endl;
89  } else {
90  cout << "JRUNANALYZER RUNNING WITH A REDUCED NUMBER OF PLOTS." << endl;
91  }
92 
93  cout << "START\n";
94 
95  JRunAnalyzer Analyzer (inputFile, detectorFile, nTimeslices, nSummaryslices, nEvents, pmt_analysis);
96 
97  Analyzer.readEvents ();
98  cout << "read events!\n";
99  Analyzer.readSummaryData ();
100  cout << "read summarydata!\n";
101  Analyzer.readTimesliceData<JDAQTimeslice> ();
105  cout << "read timeslices!\n";
107 
108  cout << "before histos!\n";
109 
110  JRA_Histograms run_histograms = Analyzer.getHistograms();
111 
112  TFile out(outputFile.c_str(), "recreate");
113 
114  cout << "outputfile!\n";
115 
116  putObject(out, JMeta(argc, argv));
117 
118  JDAQHeader header;
119 
120  JTreeScanner <JDAQTimeslice> in(inputFile);
121 
122  while(in.hasNext()){
123 
124  const JDAQTimeslice* timeslice = in.next();
125 
126  if (header.getDetectorID() != timeslice->getDetectorID() ||
127  header.getRunNumber () != timeslice->getRunNumber ()) {
128 
129  header = timeslice->getDAQHeader();
130 
131  putObject(out, header);
132 
133  break;
134  }
135 
136  }
137 
138  JMeta::copy(inputFile.c_str(), out);
139 
140  run_histograms.Write_to_file(out);
141 
142  out.Close();
143 }
Auxiliary class for ROOT I/O of application specific meta data.
Definition: JMeta.hh:70
Utility class to parse command line options.
Definition: JParser.hh:1500
double getValue(const JScale_t scale)
Get numerical value corresponding to scale.
Definition: JScale.hh:47
int main(int argc, char *argv[])
Definition: Main.cc:15
int getParameter(const std::string &text)
Get parameter number from text string.
ROOT TTree parameter settings of various packages.
int getDetectorID() const
Get detector identifier.
static void copy(const char *const file_name, TFile &out)
Copy meta data.
Definition: JMeta.hh:421
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
Definition: diff-Tuna.sh:38
static counter_type max()
Get maximum counter value.
Definition: JLimit.hh:117
string outputFile
Class dedicated to the analysis of KM3NeT runs.
Definition: JRunAnalyzer.hh:27
int getRunNumber() const
Get run number.
Template definition for direct access of elements in ROOT TChain.
Definition: JTreeScanner.hh:91
Data structure for detector geometry and calibration.
Timeslice data structure for L1 data.
void readTimesliceData()
void Write_to_file(TFile &f)
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
Timeslice data structure for L2 data.
ROOT I/O of application specific meta data.
#define ERROR(A)
Definition: JMessage.hh:66
Data time slice.
Timeslice data structure for SN data.
bool putObject(TDirectory &dir, const TObject &object)
Write object to ROOT directory.
void readSummaryData()
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.
Auxiliary class to define a range between two values.
Utility class to parse command line options.
const JDAQHeader & getDAQHeader() const
Get DAQ header.
Definition: JDAQHeader.hh:49
Wrapper class around string.
Definition: JToken.hh:23
KM3NeT DAQ constants, bit handling, etc.
JRA_Histograms getHistograms()
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:42
void readEvents()
Timeslice data structure for L0 data.