Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JSummary.cc File Reference

Auxiliary program to blend and write summary data. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "JDAQ/JDAQSummaryslice.hh"
#include "JDAQ/JDAQChronometer.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JTrigger/JTriggerParameters.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JFileRecorder.hh"
#include "JSupport/JSummarysliceSupportkit.hh"
#include "JSupport/JTriggerParametersSupportkit.hh"
#include "JSupport/JSupport.hh"
#include "JSupport/JMeta.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Auxiliary program to blend and write summary data.

Author
mdejong

Definition in file JSummary.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 28 of file JSummary.cc.

29 {
30  using namespace std;
31  using namespace JPP;
32  using namespace KM3NETDAQ;
33 
34  JMultipleFileScanner<JDAQSummaryslice> inputFile;
35  JFileRecorder <JTYPELIST<JDAQSummaryslice, JTriggerParameters, JMeta>::typelist> outputFile;
36  int numberOfEvents;
37  string detectorFile;
38  JTriggerParameters parameters;
39  int run_number;
40  int debug;
41 
42  try {
43 
44  JParser<> zap("Auxiliary program to blend and write summary data.");
45 
46  zap['f'] = make_field(inputFile);
47  zap['n'] = make_field(numberOfEvents);
48  zap['o'] = make_field(outputFile);
49  zap['a'] = make_field(detectorFile);
50  zap['@'] = make_field(parameters) = JPARSER::initialised();
51  zap['R'] = make_field(run_number) = 1;
52  zap['d'] = make_field(debug) = 0;
53 
54  zap(argc, argv);
55  }
56  catch(const exception &error) {
57  FATAL(error.what() << endl);
58  }
59 
60 
61 
62  JDetector detector;
63 
64  try {
65  load(detectorFile, detector);
66  }
67  catch(const JException& error) {
68  FATAL(error);
69  }
70 
71 
72  // check availability of sufficient summary data
73 
74  unsigned int number_of_modules = 0;
75 
76  while (inputFile.hasNext() && number_of_modules < detector.size()) {
77  number_of_modules += inputFile.next()->size();
78  }
79 
80  if (number_of_modules < detector.size()) {
81  FATAL("Input summary data insufficient: " << number_of_modules << " < " << detector.size() << endl);
82  }
83 
84  inputFile.rewind();
85 
86 
87  outputFile.open();
88 
89  outputFile.put(JMeta(argc, argv));
90 
91  outputFile.put(parameters);
92 
93  for (int frame_index = 1; frame_index <= numberOfEvents; ) {
94 
95  NOTICE("event: " << setw(10) << frame_index << '\r'); DEBUG(endl);
96 
97  JSummaryslice summary(JDAQChronometer(detector.getID(),
98  run_number,
99  frame_index,
100  getTimeOfFrame(frame_index)),
101  inputFile,
102  detector);
103 
104  if (summary.size() == detector.size()) {
105 
106  outputFile.put(summary);
107 
108  ++frame_index;
109 
110  } else {
111 
112  inputFile.rewind();
113  }
114  }
115  NOTICE(endl);
116 
117  outputFile.close();
118 }
Auxiliary class for ROOT I/O of application specific meta data.
Definition: JMeta.hh:71
Utility class to parse command line options.
Definition: JParser.hh:1410
Data structure for all trigger parameters.
Empty structure for specification of parser element that is initialised (i.e.
Definition: JParser.hh:64
string outputFile
double getTimeOfFrame(const int frame_index)
Get start time of frame in ns since start of run for a given frame index.
Definition: JDAQClock.hh:185
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1836
#define NOTICE(A)
Definition: JMessage.hh:62
void load(const JString &file_name, JDetector &detector)
Load detector from input file.
int debug
debug level
Definition: JSirene.cc:59
#define FATAL(A)
Definition: JMessage.hh:65
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:60