Jpp  17.1.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 "km3net-dataformat/offline/Head.hh"
#include "JAAnet/JAAnetDictionary.hh"
#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 "JDAQ/JDAQEventIO.hh"
#include "JSupport/JSupport.hh"
#include "JSupport/JMeta.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JTreeScanner.hh"
#include "JSupport/JMonteCarloFileSupportkit.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 "JSupport/JSupportToolkit.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 60 of file JRunAnalyzer.cc.

60  {
61 
62  typedef JToken<';'> JToken_t;
63 
64  JMultipleFileScanner<> inputFile;
65  string outputFile;
66  string detectorFile;
67  JLimit_t nTimeslices;
68  JLimit_t nSummaryslices;
69  JLimit_t nEvents;
71 
72  try {
73 
74  JParser<> zap;
75 
76  zap['f'] = make_field(inputFile , "Path to input file " );
77  zap['o'] = make_field(outputFile , "Path to output file" ) = "out.root";
78  zap['a'] = make_field(detectorFile , "path to detector file" );
79  zap['t'] = make_field(nTimeslices , "number of timeslices" ) = JLimit::max();
80  zap['s'] = make_field(nSummaryslices , "number of summaryslices") = JLimit::max();
81  zap['n'] = make_field(nEvents , "number of events" ) = JLimit::max();
82  zap['@'] = make_field(parameters, "parameter values, e.g: \"p0 = 1.0;\"");
83 
84 
85  zap(argc,argv);
86  }
87  catch(const exception &error) {
88  ERROR(error.what() << endl);
89  }
90 
92 
93  try {
94  load (detectorFile, detector);
95  }
96  catch(const JException & error) {
97  FATAL( "FATAL ERROR. Could not open detector file '" << detectorFile << "'." << endl);
98  }
99 
100  bool pmt_analysis = false;
101 
102  for (vector<JToken_t>::const_iterator i = parameters.begin(); i != parameters.end(); ++i) {
103 
104  if(getParameter(*i) == 0 && getValue(*i) > 0) pmt_analysis = true;
105 
106  }
107 
108  if(pmt_analysis == true){
109  cout << "JRUNANALYZER RUNNING WITH ALL AVAILABLE PLOTS. It may take a while!" << endl;
110  } else {
111  cout << "JRUNANALYZER RUNNING WITH A REDUCED NUMBER OF PLOTS." << endl;
112  }
113 
115 
116  Head head;
117 
118  try{
119  head = getHeader(in);
120  }catch(const exception&){}
121 
122  JHead buffer(head);
123 
124  buffer.DAQ.livetime_s = getLivetime(inputFile.begin(), inputFile.end());
125 
126  buffer.push(& JAANET::JHead::DAQ);
127 
128  copy(buffer, head);
129 
130  cout << "START\n";
131 
132  JRunAnalyzer Analyzer (inputFile, detector, nTimeslices, nSummaryslices, nEvents, pmt_analysis);
133 
134  Analyzer.readEvents ();
135  cout << "read events!\n";
136  Analyzer.readSummaryData ();
137  cout << "read summarydata!\n";
138  Analyzer.readTimesliceData<JDAQTimeslice> ();
139  Analyzer.readTimesliceData<JDAQTimesliceL0>();
140  Analyzer.readTimesliceData<JDAQTimesliceL1>();
141  Analyzer.readTimesliceData<JDAQTimesliceL2>();
142  cout << "read timeslices!\n";
143  Analyzer.readTimesliceData<JDAQTimesliceSN>();
144 
145  cout << "before histos!\n";
146 
147  TFile out(outputFile.c_str(), "recreate");
148 
149  cout << "outputfile!\n";
150 
151  putObject(out, JMeta(argc, argv));
152  putObject(out, head);
153 
154  JDAQHeader header;
155 
156  for(const auto& i: inputFile){
157 
158 
159  for(JMultipleFileScanner<JDAQEvent> in(i); in.hasNext();){
160 
161  const JDAQEvent* event = in.next();
162 
163  if (header.getDetectorID() != event->getDetectorID() ||
164  header.getRunNumber () != event->getRunNumber ()) {
165 
166  header = event->getDAQHeader();
167 
168  putObject(out, header);
169 
170  break;
171  }
172  }
173  }
174 
175  for(const auto& i: inputFile){
176 
177  JMeta::copy(i.c_str(), out);
178  }
179 
180  Analyzer.writeToFile(out);
181 
182  out.Close();
183 
184 }
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:1517
General exception.
Definition: JException.hh:23
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.
Detector data structure.
Definition: JDetector.hh:89
*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:28
int getRunNumber() const
Get run number.
Timeslice data structure for L1 data.
Head getHeader(const JMultipleFileScanner_t &file_list)
Get Monte Carlo header.
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:1993
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.
Monte Carlo run header.
Definition: JHead.hh:1167
The Head class reflects the header of Monte-Carlo event files, which consists of keys (also referred ...
Definition: Head.hh:65
#define FATAL(A)
Definition: JMessage.hh:67
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
double getLivetime(const std::string &file_name)
Get data taking live time.
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:161
do set_variable DETECTOR_TXT $WORKDIR detector
JAANET::DAQ DAQ
Definition: JHead.hh:1532
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 JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:46
Timeslice data structure for L0 data.