Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JSummary.cc
Go to the documentation of this file.
1 
2 #include <string>
3 #include <iostream>
4 #include <iomanip>
5 
8 #include "JDetector/JDetector.hh"
15 #include "JSupport/JSupport.hh"
16 #include "JSupport/JMeta.hh"
17 
18 #include "Jeep/JParser.hh"
19 #include "Jeep/JMessage.hh"
20 
21 
22 /**
23  * \file
24  *
25  * Auxiliary program to blend and write summary data.
26  * \author mdejong
27  */
28 int main(int argc, char **argv)
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.
Recording of objects on file according a format that follows from the file name extension.
Empty structure for specification of parser element that is initialised (i.e.
Definition: JParser.hh:64
string outputFile
Data structure for detector geometry and calibration.
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
ROOT I/O of application specific meta data.
#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
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:65
Scanning of objects from multiple files according a format that follows from the extension of each fi...
Auxiliaries for creation of summary data.
Utility class to parse command line options.
ROOT TTree parameter settings.
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:60
int main(int argc, char *argv[])
Definition: Main.cpp:15