Jpp  16.0.0-rc.1
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 "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 "TROOT.h"
#include "JROOT/JRootFileReader.hh"
#include "JROOT/JROOTClassSelector.hh"
#include "JROOT/JRootToolkit.hh"
#include "JROOT/JRootFileWriter.hh"
#include "JRunAnalyzer.hh"
#include "JRunHistograms.hh"
#include <TSystem.h>

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 51 of file JRunAnalyzer.cc.

51  {
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> ();
113  Analyzer.readTimesliceData<JDAQTimesliceL0>();
114  Analyzer.readTimesliceData<JDAQTimesliceL1>();
115  Analyzer.readTimesliceData<JDAQTimesliceL2>();
116  cout << "read timeslices!\n";
117  Analyzer.readTimesliceData<JDAQTimesliceSN>();
118 
119  cout << "before histos!\n";
120 
121  JRA_Histograms run_histograms = Analyzer.getHistograms();
122 
123  TFile out(outputFile.c_str(), "recreate");
124 
125  cout << "outputfile!\n";
126 
127  putObject(out, JMeta(argc, argv));
128 
129  JDAQHeader header;
130 
131  JTreeScanner <JDAQTimeslice> in(inputFile);
132 
133  while(in.hasNext()){
134 
135  const JDAQTimeslice* timeslice = in.next();
136 
137  if (header.getDetectorID() != timeslice->getDetectorID() ||
138  header.getRunNumber () != timeslice->getRunNumber ()) {
139 
140  header = timeslice->getDAQHeader();
141 
142  putObject(out, header);
143 
144  break;
145  }
146 
147  }
148 
149  JMeta::copy(inputFile.c_str(), out);
150 
151  run_histograms.Write_to_file(out);
152 
153  out.Close();
154  }
155 }
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.