Jpp  15.0.3
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JRunAnalyzer.cc File Reference
#include <iostream>
#include <iomanip>
#include "JDetector/JDetector.hh"
#include "JDetector/JModuleRouter.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JTools/JRange.hh"
#include "JLang/JToken.hh"
#include "JGizmo/JGizmoToolkit.hh"
#include "JSupport/JSupport.hh"
#include "JSupport/JMeta.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JTreeScanner.hh"
#include "TROOT.h"
#include "Jeep/JParser.hh"
#include "km3net-dataformat/online/JDAQ.hh"
#include "km3net-dataformat/online/JDAQHeader.hh"
#include "JDAQ/JDAQTimesliceIO.hh"
#include "JDAQ/JDAQSummarysliceIO.hh"
#include "JLang/JObjectReader.hh"
#include "JROOT/JRootFileReader.hh"
#include "JROOT/JROOTClassSelector.hh"
#include "JROOT/JRootToolkit.hh"
#include "JROOT/JRootFileWriter.hh"
#include "JRunAnalyzer.hh"
#include "JRunHistograms.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

int main ( int  argc,
char **  argv 
)
Author
rgruiz, adomi

Definition at line 49 of file JRunAnalyzer.cc.

49  {
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> ();
102  Analyzer.readTimesliceData<JDAQTimesliceL0>();
103  Analyzer.readTimesliceData<JDAQTimesliceL1>();
104  Analyzer.readTimesliceData<JDAQTimesliceL2>();
105  cout << "read timeslices!\n";
106  Analyzer.readTimesliceData<JDAQTimesliceSN>();
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 getParameter(const std::string &text)
Get parameter number from text string.
int getDetectorID() const
Get detector identifier.
*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
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
Timeslice data structure for L1 data.
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.
#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.
const JDAQHeader & getDAQHeader() const
Get DAQ header.
Definition: JDAQHeader.hh:49
Wrapper class around string.
Definition: JToken.hh:23
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:139
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
Timeslice data structure for L0 data.