Jpp  17.0.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JTimesliceReprocessor.cc
Go to the documentation of this file.
1 
2 #include <string>
3 #include <iostream>
4 #include <iomanip>
5 
9 
10 #include "JDAQ/JDAQTimesliceIO.hh"
11 #include "JDAQ/JDAQEventIO.hh"
13 
14 #include "JDetector/JDetector.hh"
17 
18 #include "JTrigger/JHit.hh"
19 #include "JTrigger/JHitToolkit.hh"
22 #include "JTrigger/JTimeslice.hh"
23 #include "JTrigger/JBuildL1.hh"
24 #include "JTrigger/JBuildL2.hh"
25 #include "JTrigger/JTimesliceL1.hh"
28 
31 
35 #include "JSupport/JSupport.hh"
36 #include "JSupport/JMeta.hh"
38 
39 #include "Jeep/JParser.hh"
40 #include "Jeep/JMessage.hh"
41 
42 
43 /**
44  * \file
45  * Auxiliary program to re-process KM3NETDAQ::JDAQTimeslice data.
46  * \author mdejong
47  */
48 int main(int argc, char **argv)
49 {
50  using namespace std;
51  using namespace JPP;
52  using namespace KM3NETDAQ;
53 
54  typedef JAllTypes_t typelist;
55 
58  JLimit_t& numberOfEvents = inputFile.getLimit();
59  string detectorFile;
61  bool reuse_parameters;
62  JROOTClassSelector selector;
63  int debug;
64 
65  try {
66 
67  JParser<> zap("Auxiliary program to re-process time slice data.");
68 
69  zap['f'] = make_field(inputFile);
70  zap['o'] = make_field(outputFile) = "timeslice.root";
71  zap['n'] = make_field(numberOfEvents) = JLimit::max();
72  zap['a'] = make_field(detectorFile);
74  zap['U'] = make_field(reuse_parameters);
75  zap['C'] = make_field(selector, "timeslice selector, e.g. JDAQTimesliceL1.") = getROOTClassSelection<JDAQTimesliceTypes_t>();
76  zap['d'] = make_field(debug) = 0;
77 
78  zap(argc, argv);
79  }
80  catch(const exception &error) {
81  FATAL(error.what() << endl);
82  }
83 
84 
85  cout.tie(&cerr);
86 
88 
89  DEBUG("Frame time [ms] " << getFrameTime() * 1e-6 << endl);
90  DEBUG("Reset time [ms] " << getRTS() * 1e-6 << endl);
91  DEBUG("Trigger" << endl << parameters << endl);
92 
94 
95  try {
96  load(detectorFile, detector);
97  }
98  catch(const JException& error) {
99  FATAL(error);
100  }
101 
102  if (reuse_parameters) {
103 
104  try {
105 
106  parameters = getTriggerParameters(inputFile);
107 
108  NOTICE("Set trigger parameters from input." << endl);
109  }
110  catch(const JException& error) {
111  FATAL("No trigger parameters from input." << endl);
112  }
113  }
114  // detector
115 
116  if (parameters.disableHighRateVeto) {
117 
118  NOTICE("Disabling high-rate veto of all PMTs." << endl);
119 
120  detector.setPMTStatus(HIGH_RATE_VETO_DISABLE);
121  }
122 
124 
125  const JModuleRouter moduleRouter(detector);
126 
127  if (parameters.writeSummary()) { WARNING("Discard writeSummary option during reprocesing of data." << endl); }
128 
129  //typedef JHit hit_type;
130  //typedef int hit_type;
131  typedef double hit_type;
132 
133  typedef JSuperFrame1D<hit_type> JSuperFrame1D_t;
134  typedef JSuperFrame2D<hit_type> JSuperFrame2D_t;
135  typedef JTimeslice <hit_type> JTimeslice_t;
136  typedef JBuildL1 <hit_type> JBuildL1_t;
137  typedef JBuildL2 <hit_type> JBuildL2_t;
138 
139  const JBuildL1_t buildL1(parameters);
140  const JBuildL2_t buildL2(parameters.L2);
141  const JBuildL2_t buildSN(parameters.SN);
142 
143  JTimesliceRouter timesliceRouter(parameters.numberOfBins);
144 
145  outputFile.open();
146 
147  if (!outputFile.is_open()) {
148  FATAL("Error opening file " << outputFile << endl);
149  }
150 
151  outputFile.put(JMeta(argc, argv));
152  outputFile.put(parameters);
153 
155 
156  counter_type counter = 0;
157 
158  for ( ; in.hasNext() && counter != inputFile.getLimit(); ++counter) {
159 
160  STATUS("event: " << setw(10) << counter << '\r'); DEBUG(endl);
161 
162  const JDAQTimeslice* timeslice = in.next();
163 
164  DEBUG(*timeslice << endl);
165 
166  timesliceRouter.configure(*timeslice);
167 
168  JTimeslice_t timesliceL0(timeslice->getDAQChronometer());
169  JTimeslice_t timesliceL1(timeslice->getDAQChronometer());
170  JTimeslice_t timesliceL2(timeslice->getDAQChronometer());
171  JTimeslice_t timesliceSN(timeslice->getDAQChronometer());
172 
173  for (JDAQTimeslice::const_iterator super_frame = timeslice->begin(); super_frame != timeslice->end(); ++super_frame) {
174 
175  if (moduleRouter.hasModule(super_frame->getModuleID())) {
176 
177  // calibration
178 
179  const JModule& module = moduleRouter.getModule(super_frame->getModuleID());
180  JSuperFrame2D_t& buffer = JSuperFrame2D_t::demultiplex(*super_frame, module);
181 
182  // Apply high-rate veto
183 
184  buffer.applyHighRateVeto(parameters.highRateVeto_Hz);
185 
186  // L0
187 
188  timesliceL0.push_back(JSuperFrame1D_t(buffer));
189 
190  // L1
191 
192  timesliceL1.push_back(JSuperFrame1D_t(super_frame->getDAQChronometer(),
193  super_frame->getModuleIdentifier(),
194  module.getPosition()));
195 
196  buildL1(*timesliceL0.rbegin(), back_inserter(*timesliceL1.rbegin()));
197 
198  // L2
199 
200  timesliceL2.push_back(JSuperFrame1D_t(super_frame->getDAQChronometer(),
201  super_frame->getModuleIdentifier(),
202  module.getPosition()));
203 
204  buildL2(buffer, *timesliceL1.rbegin(), back_inserter(*timesliceL2.rbegin()));
205 
206  // SN
207 
208  timesliceSN.push_back(JSuperFrame1D_t(super_frame->getDAQChronometer(),
209  super_frame->getModuleIdentifier(),
210  module.getPosition()));
211 
212  buildSN(buffer, *timesliceL1.rbegin(), back_inserter(*timesliceSN.rbegin()));
213  }
214  }
215 
216  if (parameters.writeL0()) {
217  outputFile.put(*timeslice);
218  }
219 
220  if (parameters.writeL1()) {
221  outputFile.put(JTimesliceL1<JDAQTimesliceL1>(timesliceL1, timesliceRouter, moduleRouter, parameters.TMaxLocal_ns));
222  }
223 
224  if (parameters.writeL2()) {
225  outputFile.put(JTimesliceL1<JDAQTimesliceL2>(timesliceL2, timesliceRouter, moduleRouter, parameters.L2.TMaxLocal_ns));
226  }
227 
228  if (parameters.writeSN()) {
229  outputFile.put(JTimesliceL1<JDAQTimesliceSN>(timesliceSN, timesliceRouter, moduleRouter, parameters.SN.TMaxLocal_ns));
230  }
231  }
232  STATUS(endl);
233 
235 
236  io >> outputFile;
237 
238  outputFile.close();
239 }
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:1500
General exception.
Definition: JException.hh:23
#define WARNING(A)
Definition: JMessage.hh:65
debug
Definition: JMessage.hh:29
int main(int argc, char *argv[])
Definition: Main.cc:15
ROOT TTree parameter settings of various packages.
const JModule & getModule(const JObjectID &id) const
Get module parameters.
Data structure for a composite optical module.
Definition: JModule.hh:68
Router for fast addressing of hits in KM3NETDAQ::JDAQTimeslice data structure as a function of the op...
#define STATUS(A)
Definition: JMessage.hh:63
Detector data structure.
Definition: JDetector.hh:89
void configure(const JDAQTimeslice &timeslice)
Configure.
Auxiliary class to select ROOT class based on class name.
Recording of objects on file according a format that follows from the file name extension.
Router for direct addressing of module data in detector data structure.
static const int HIGH_RATE_VETO_DISABLE
Enable (disable) use of high-rate veto test if this status bit is 0 (1);.
Definition: pmt_status.hh:13
*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:66
Long64_t counter_type
Type definition for counter.
Auxiliary class for multiplexing object iterators.
Basic data structure for time and time over threshold information of hit.
string outputFile
Data structure for detector geometry and calibration.
Tools for handling different hit types.
1-dimensional frame with time calibrated data from one optical module.
Type list.
Definition: JTypeList.hh:22
void setDAQLongprint(const bool option)
Set DAQ print option.
Definition: JDAQPrint.hh:28
Scanning of objects from a single file according a format that follows from the extension of each fil...
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
Template L2 builder.
Definition: JBuildL2.hh:45
double getMaximalDistance(const JDetector &detector)
Get maximal distance between modules in detector.
Detector file.
Definition: JHead.hh:224
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
double getFrameTime()
Get frame time duration.
Definition: JDAQClock.hh:162
ROOT I/O of application specific meta data.
#define NOTICE(A)
Definition: JMessage.hh:64
const JDAQChronometer & getDAQChronometer() const
Get DAQ chronometer.
Data time slice.
virtual const pointer_type & next() override
Get next element.
int debug
debug level
Definition: JSirene.cc:66
virtual bool hasNext() override
Check availability of next element.
const JPosition3D & getPosition() const
Get position.
Definition: JPosition3D.hh:130
General purpose messaging.
Template L1 hit builder.
Definition: JBuildL1.hh:85
#define FATAL(A)
Definition: JMessage.hh:67
Direct access to module in detector data structure.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
Auxiliary class to build JDAQTimeslice for L1 timeslice.
Definition: JTimesliceL1.hh:36
double getRTS()
Get TDC dynamic range.
Definition: JDAQClock.hh:173
Utility class to parse command line options.
bool hasModule(const JObjectID &id) const
Has module.
2-dimensional frame with time calibrated data from one optical module.
Object reading from a list of files.
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:73
do set_variable DETECTOR_TXT $WORKDIR detector
KM3NeT DAQ constants, bit handling, etc.
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
JTriggerParameters getTriggerParameters(const JMultipleFileScanner_t &file_list)
Get trigger parameters.
Time slice with calibrated data.
Definition: JTimeslice.hh:26
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62