Jpp  18.3.0
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 "JSupport/JSupport.hh"
#include "JSupport/JMeta.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JTreeScanner.hh"
#include "JSupport/JMonteCarloFileSupportkit.hh"
#include "JSupport/JFileRecorder.hh"
#include "JReconstruction/JEvt.hh"
#include "JReconstruction/JEvtToolkit.hh"
#include "Jeep/JParser.hh"
#include "km3net-dataformat/online/JDAQ.hh"
#include "km3net-dataformat/online/JDAQHeader.hh"
#include "JDAQ/JDAQEventIO.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 "JROOT/JTreeParameters.hh"
#include "JSupport/JSupportToolkit.hh"
#include "JRunAnalyzer/JRunInfo.hh"
#include "JRunAnalyzer.hh"
#include "JRunHistograms.hh"
#include <TSystem.h>
#include "TTree.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 62 of file JRunAnalyzer.cc.

62  {
63 
64  using namespace KM3NETDAQ;
65  using namespace JPP;
66 
67  typedef JToken<';'> JToken_t;
68 
69  JSingleFileScanner<> inputFile;
71  string detectorFile;
72  JLimit_t nTimeslices;
73  JLimit_t nSummaryslices;
74  JLimit_t nEvents;
76 
77  try {
78 
79  JParser<> zap;
80  zap['f'] = make_field(inputFile , "input file " );
81  zap['o'] = make_field(outputFile , "output file" ) = "out.root";
82  zap['a'] = make_field(detectorFile , "detector file" );
83  zap['t'] = make_field(nTimeslices , "number of timeslices" ) = JLimit::max();
84  zap['s'] = make_field(nSummaryslices , "number of summaryslices") = JLimit::max();
85  zap['n'] = make_field(nEvents , "number of events" ) = JLimit::max();
86  zap['@'] = make_field(parameters, "parameter values, e.g: \"p0 = 1.0;\"");
87 
88  zap(argc,argv);
89  }
90  catch(const exception &error) {
91  ERROR(error.what() << endl);
92  }
93 
95 
96  try {
97  load (detectorFile, detector);
98  }
99  catch(const JException & error) {
100  FATAL( "FATAL ERROR. Could not open detector file '" << detectorFile << "'." << endl);
101  }
102 
103  int analysis_level = 0;
104 
105  for (vector<JToken_t>::const_iterator i = parameters.begin(); i != parameters.end(); ++i) {
106 
107  if(getParameter(*i) == 0 && getValue(*i) == 1) analysis_level = 1;
108  if(getParameter(*i) == 0 && getValue(*i) == 2) analysis_level = 2;
109 
110  }
111 
112  if(analysis_level == 1){
113  cout << "ANALYSIS OF ALL AVAILABLE PMTs INFORMATION. It may take a while!" << endl;
114  } else if (analysis_level == 2){
115  cout << "BASIC ANALYSIS AT TRIGGER AND RECONSTRUCTION LEVEL." << endl;
116  } else {
117  cout << "JRUNANALYZER RUNNING WITH A REDUCED NUMBER OF PLOTS." << endl;
118  }
119 
121 
122  Head head;
123 
124  try{
125  head = getHeader(in);
126  }catch(const exception&){}
127 
128  JHead buffer(head);
129 
130  buffer.DAQ.livetime_s = getLivetime(inputFile);
131 
132  buffer.push(& JAANET::JHead::DAQ);
133 
134  copy(buffer, head);
135 
136  cout << "START\n";
137 
138  outputFile.open();
139 
140  JRootFile* p = dynamic_cast<JRootFile*>(outputFile.get());
141 
142  if (p == NULL) {
143  FATAL("WRONG FILE TYPE");
144  }
145 
146  TFile* out = p->getFile();
147 
148  cout << out->GetName() << endl;
149 
150  outputFile.put(JMeta(argc, argv));
151 
152  JDAQHeader header;
153 
154  for(JTreeScanner<JDAQEvent> in(inputFile); in.hasNext();){
155 
156  const JDAQEvent* event = in.next();
157 
158  if (header.getDetectorID() != event->getDetectorID() ||
159  header.getRunNumber () != event->getRunNumber ()) {
160 
161  header = event->getDAQHeader();
162 
163  putObject(out, header);
164 
165  break;
166  }
167  }
168 
169  const run_info runinfo(header.getDetectorID(),
170  header.getRunNumber(),
171  buffer.DAQ.livetime_s,
172  buffer.livetime.numberOfSeconds);
173 
174  outputFile.put(runinfo);
175 
176  JRunAnalyzer Analyzer (inputFile, detector, out, nTimeslices, nSummaryslices, nEvents, analysis_level);
177 
178  cout << "read events\n";
179  Analyzer.readEvents ();
180  cout << "read summarydata\n";
181  Analyzer.readSummaryData ();
182  cout << "read timeslices\n";
183  Analyzer.readTimesliceData<JDAQTimeslice> ();
184  Analyzer.readTimesliceData<JDAQTimesliceL0>();
185  Analyzer.readTimesliceData<JDAQTimesliceL1>();
186  Analyzer.readTimesliceData<JDAQTimesliceL2>();
187  Analyzer.readTimesliceData<JDAQTimesliceSN>();
188 
189  if(analysis_level == 2){
190  cout << "read reconstructed events\n";
191  Analyzer.readRecoEvents ();
192  }
193 
194  Analyzer.writeToFile(out, analysis_level);
195 
196  outputFile.close();
197 }
Auxiliary class for ROOT I/O of application specific meta data.
Definition: JMeta.hh:70
Object writing to file.
Utility class to parse command line options.
Definition: JParser.hh:1514
General exception.
Definition: JException.hh:24
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.
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
static counter_type max()
Get maximum counter value.
Definition: JLimit.hh:128
string outputFile
Class dedicated to the analysis of KM3NeT runs.
Definition: JRunAnalyzer.hh:32
Template definition for direct access of elements in ROOT TChain.
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
Detector file.
Definition: JHead.hh:226
Monte Carlo run header.
Definition: JHead.hh:1234
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
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.
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.
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:48
Wrapper class around string.
Definition: JToken.hh:23
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:162
do set_variable DETECTOR_TXT $WORKDIR detector
JAANET::DAQ DAQ
Definition: JHead.hh:1604
Timeslice data structure for L0 data.
ROOT file.
Definition: JRootFile.hh:45