Jpp  18.5.0
the software that should make you happy
 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 
7 #include "JDetector/JDetector.hh"
13 #include "JSupport/JSupport.hh"
14 #include "JSupport/JMeta.hh"
16 
17 #include "Jeep/JParser.hh"
18 #include "Jeep/JMessage.hh"
19 
20 
21 /**
22  * \file
23  *
24  * Auxiliary program to blend and write summary data.
25  *
26  * This application can be used to convert measured rates of any detector
27  * to a consistent set of rates for a simulated complete detector.\n
28  * The rates as well as the high-rate veto and FIFO (almost) full will then be included
29  * in the run-by-run simulations using JTriggerEfficiency.cc.
30  *
31  * The option <tt>-f <inputFile></tt> corresponds to a list of input files
32  * containing summary data (commonly referred to as "measured rates").\n
33  * These data can originate from any detector.
34  *
35  * The option <tt>-a <detectorFile></tt> corresponds to the detector to be used in simulations.\n
36  * This could be a complete detector.
37  *
38  * The option <tt>-@ <parameters></tt> corresponds to the trigger parameters.\n
39  * This is needed here because in the run-by-run simulations,
40  * the trigger parameters are taken from the input file.
41  *
42  * The application JSummaryWriter.cc can be used to write summary data according user defined input rates.
43  *
44  * \author mdejong
45  */
46 int main(int argc, char **argv)
47 {
48  using namespace std;
49  using namespace JPP;
50  using namespace KM3NETDAQ;
51 
54  int numberOfEvents;
55  string detectorFile;
57  int run_number;
58  int debug;
59 
60  try {
61 
62  JParser<> zap("Auxiliary program to blend and write summary data.");
63 
64  zap['f'] = make_field(inputFile);
65  zap['n'] = make_field(numberOfEvents);
66  zap['o'] = make_field(outputFile);
67  zap['a'] = make_field(detectorFile);
69  zap['R'] = make_field(run_number) = 1;
70  zap['d'] = make_field(debug) = 0;
71 
72  zap(argc, argv);
73  }
74  catch(const exception &error) {
75  FATAL(error.what() << endl);
76  }
77 
78 
80 
81  try {
82  load(detectorFile, detector);
83  }
84  catch(const JException& error) {
85  FATAL(error);
86  }
87 
88 
89  // check availability of sufficient summary data
90 
91  unsigned int number_of_modules = 0;
92 
93  while (inputFile.hasNext() && number_of_modules < detector.size()) {
94  number_of_modules += inputFile.next()->size();
95  }
96 
97  if (number_of_modules < detector.size()) {
98  FATAL("Input summary data insufficient: " << number_of_modules << " < " << detector.size() << endl);
99  }
100 
101  inputFile.rewind();
102 
103 
104  outputFile.open();
105 
106  outputFile.put(JMeta(argc, argv));
107 
108  outputFile.put(parameters);
109 
110  for (int frame_index = 1; frame_index <= numberOfEvents; ) {
111 
112  NOTICE("event: " << setw(10) << frame_index << '\r'); DEBUG(endl);
113 
114  JSummaryslice summary(JDAQChronometer(detector.getID(),
115  run_number,
116  frame_index,
117  getTimeOfFrame(frame_index)),
118  inputFile,
119  detector);
120 
121  if (summary.size() == detector.size()) {
122 
123  outputFile.put(summary);
124 
125  ++frame_index;
126 
127  } else {
128 
129  inputFile.rewind();
130  }
131  }
132  NOTICE(endl);
133 
134  outputFile.close();
135 }
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
int main(int argc, char *argv[])
Definition: Main.cc:15
ROOT TTree parameter settings of various packages.
Detector data structure.
Definition: JDetector.hh:89
Recording of objects on file according a format that follows from the file name extension.
*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
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:83
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
Detector file.
Definition: JHead.hh:226
Auxiliaries for creation of summary data.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
ROOT I/O of application specific meta data.
#define NOTICE(A)
Definition: JMessage.hh:64
Auxiliary class to create summary data.
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
Scanning of objects from multiple files according a format that follows from the extension of each fi...
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
Utility class to parse command line options.
do set_variable DETECTOR_TXT $WORKDIR detector
int debug
debug level
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62