Jpp  test_elongated_shower_pde
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"
19 
20 #include "Jeep/JParser.hh"
21 
24 
25 #include "JDAQ/JDAQTimesliceIO.hh"
27 
28 #include "JLang/JObjectReader.hh"
29 
30 #include "TROOT.h"
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 #include <TSystem.h>
41 
42 using namespace KM3NETDAQ;
43 using namespace JDETECTOR;
44 using namespace JLANG;
45 using namespace JPP;
46 
47 /**
48  * \author rgruiz, adomi
49  */
50 
51 int main(int argc, char **argv) {
52 
53  typedef JToken<';'> JToken_t;
54 
55  string inputFile;
56  string outputFile;
57  string detectorFile;
58  JLimit_t nTimeslices;
59  JLimit_t nSummaryslices;
60  JLimit_t nEvents;
62 
63  try {
64 
65  JParser<> zap;
66 
67  zap['f'] = make_field(inputFile , "Path to input file " );
68  zap['o'] = make_field(outputFile , "Path to output file" ) = "out.root";
69  zap['a'] = make_field(detectorFile , "path to detector file" );
70  zap['t'] = make_field(nTimeslices , "number of timeslices" ) = JLimit::max();
71  zap['s'] = make_field(nSummaryslices , "number of summaryslices") = JLimit::max();
72  zap['n'] = make_field(nEvents , "number of events" ) = JLimit::max();
73  zap['@'] = make_field(parameters, "parameter values, e.g: \"p0 = 1.0;\"");
74 
75  zap(argc,argv);
76  }
77  catch(const exception &error) {
78  ERROR(error.what() << endl);
79  }
80 
81  bool pmt_analysis = false;
82 
83  for (vector<JToken_t>::const_iterator i = parameters.begin(); i != parameters.end(); ++i) {
84 
85  if(getParameter(*i) == 0 && getValue(*i) > 0) pmt_analysis = true;
86 
87  }
88 
89  if(pmt_analysis == true){
90  cout << "JRUNANALYZER RUNNING WITH ALL AVAILABLE PLOTS. It may take a while!" << endl;
91  } else {
92  cout << "JRUNANALYZER RUNNING WITH A REDUCED NUMBER OF PLOTS." << endl;
93  }
94 
95  JTreeScanner <JDAQEvent> scanner(inputFile, 1);
96 
97  bool filecheck = false;
98  if(scanner.hasNext()) {
99  filecheck = true;
100  }
101 
102  if(filecheck){
103 
104  cout << "START\n";
105 
106  JRunAnalyzer Analyzer (inputFile, detectorFile, nTimeslices, nSummaryslices, nEvents, pmt_analysis);
107 
108  Analyzer.readEvents ();
109  cout << "read events!\n";
110  Analyzer.readSummaryData ();
111  cout << "read summarydata!\n";
112  Analyzer.readTimesliceData<JDAQTimeslice> ();
116  cout << "read timeslices!\n";
118 
119  cout << "before histos!\n";
120 
121  TFile out(outputFile.c_str(), "recreate");
122 
123  cout << "outputfile!\n";
124 
125  putObject(out, JMeta(argc, argv));
126 
127  JDAQHeader header;
128 
129  while(scanner.hasNext()){
130 
131  const JDAQEvent* event = scanner.next();
132 
133  if (header.getDetectorID() != event->getDetectorID() ||
134  header.getRunNumber () != event->getRunNumber ()) {
135 
136  header = event->getDAQHeader();
137 
138  putObject(out, header);
139 
140  break;
141  }
142 
143  }
144 
145  JMeta::copy(inputFile.c_str(), out);
146 
147  Analyzer.writeToFile(out);
148 
149  out.Close();
150  }
151 }
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:29
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 writeToFile(TFile &f)
void readTimesliceData()
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.
void readEvents()
Timeslice data structure for L0 data.