Jpp  15.0.1-rc.1-highqe
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JTimesliceReprocessor.cc File Reference

Auxiliary program to re-process KM3NETDAQ::JDAQTimeslice data. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "km3net-dataformat/offline/Head.hh"
#include "km3net-dataformat/online/JDAQ.hh"
#include "km3net-dataformat/online/JDAQClock.hh"
#include "JDAQ/JDAQTimesliceIO.hh"
#include "JDAQ/JDAQEventIO.hh"
#include "JDAQ/JDAQSummarysliceIO.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JModuleRouter.hh"
#include "JTrigger/JHit.hh"
#include "JTrigger/JHitToolkit.hh"
#include "JTrigger/JSuperFrame1D.hh"
#include "JTrigger/JSuperFrame2D.hh"
#include "JTrigger/JTimeslice.hh"
#include "JTrigger/JBuildL1.hh"
#include "JTrigger/JBuildL2.hh"
#include "JTrigger/JTimesliceL1.hh"
#include "JTrigger/JTriggerParameters.hh"
#include "JTrigger/JTriggerToolkit.hh"
#include "JLang/JObjectMultiplexer.hh"
#include "JROOT/JROOTClassSelector.hh"
#include "JSupport/JMonteCarloFileSupportkit.hh"
#include "JSupport/JSingleFileScanner.hh"
#include "JSupport/JFileRecorder.hh"
#include "JSupport/JSupport.hh"
#include "JSupport/JMeta.hh"
#include "JSupport/JTriggerParametersSupportkit.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 re-process KM3NETDAQ::JDAQTimeslice data.

Author
mdejong

Definition in file JTimesliceReprocessor.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 48 of file JTimesliceReprocessor.cc.

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 
116 
117  const JModuleRouter moduleRouter(detector);
118 
119  if (parameters.writeSummary()) { WARNING("Discard writeSummary option during reprocesing of data." << endl); }
120 
121  //typedef JHit hit_type;
122  //typedef int hit_type;
123  typedef double hit_type;
124 
125  typedef JSuperFrame1D<hit_type> JSuperFrame1D_t;
126  typedef JSuperFrame2D<hit_type> JSuperFrame2D_t;
127  typedef JTimeslice <hit_type> JTimeslice_t;
128  typedef JBuildL1 <hit_type> JBuildL1_t;
129  typedef JBuildL2 <hit_type> JBuildL2_t;
130 
131  const JBuildL1_t buildL1(parameters);
132  const JBuildL2_t buildL2(parameters.L2);
133  const JBuildL2_t buildSN(parameters.SN);
134 
135  JTimesliceRouter timesliceRouter(parameters.numberOfBins);
136 
137  outputFile.open();
138 
139  if (!outputFile.is_open()) {
140  FATAL("Error opening file " << outputFile << endl);
141  }
142 
143  outputFile.put(JMeta(argc, argv));
144  outputFile.put(parameters);
145 
147 
148  counter_type counter = 0;
149 
150  for ( ; in.hasNext() && counter != inputFile.getLimit(); ++counter) {
151 
152  STATUS("event: " << setw(10) << counter << '\r'); DEBUG(endl);
153 
154  const JDAQTimeslice* timeslice = in.next();
155 
156  DEBUG(*timeslice << endl);
157 
158  timesliceRouter.configure(*timeslice);
159 
160  JTimeslice_t timesliceL0(timeslice->getDAQChronometer());
161  JTimeslice_t timesliceL1(timeslice->getDAQChronometer());
162  JTimeslice_t timesliceL2(timeslice->getDAQChronometer());
163  JTimeslice_t timesliceSN(timeslice->getDAQChronometer());
164 
165  for (JDAQTimeslice::const_iterator super_frame = timeslice->begin(); super_frame != timeslice->end(); ++super_frame) {
166 
167  if (moduleRouter.hasModule(super_frame->getModuleID())) {
168 
169  // calibration
170 
171  const JModule& module = moduleRouter.getModule(super_frame->getModuleID());
172  JSuperFrame2D_t& buffer = JSuperFrame2D_t::demultiplex(*super_frame, module);
173 
174  // Apply high-rate veto
175 
176  buffer.applyHighRateVeto(parameters.highRateVeto_Hz);
177 
178  // L0
179 
180  timesliceL0.push_back(JSuperFrame1D_t(buffer));
181 
182  // L1
183 
184  timesliceL1.push_back(JSuperFrame1D_t(super_frame->getDAQChronometer(),
185  super_frame->getModuleIdentifier(),
186  module.getPosition()));
187 
188  buildL1(*timesliceL0.rbegin(), back_inserter(*timesliceL1.rbegin()));
189 
190  // L2
191 
192  timesliceL2.push_back(JSuperFrame1D_t(super_frame->getDAQChronometer(),
193  super_frame->getModuleIdentifier(),
194  module.getPosition()));
195 
196  buildL2(buffer, *timesliceL1.rbegin(), back_inserter(*timesliceL2.rbegin()));
197 
198  // SN
199 
200  timesliceSN.push_back(JSuperFrame1D_t(super_frame->getDAQChronometer(),
201  super_frame->getModuleIdentifier(),
202  module.getPosition()));
203 
204  buildSN(buffer, *timesliceL1.rbegin(), back_inserter(*timesliceSN.rbegin()));
205  }
206  }
207 
208  if (parameters.writeL0()) {
209  outputFile.put(*timeslice);
210  }
211 
212  if (parameters.writeL1()) {
213  outputFile.put(JTimesliceL1<JDAQTimesliceL1>(timesliceL1, timesliceRouter, moduleRouter, parameters.TMaxLocal_ns));
214  }
215 
216  if (parameters.writeL2()) {
217  outputFile.put(JTimesliceL1<JDAQTimesliceL2>(timesliceL2, timesliceRouter, moduleRouter, parameters.L2.TMaxLocal_ns));
218  }
219 
220  if (parameters.writeSN()) {
221  outputFile.put(JTimesliceL1<JDAQTimesliceSN>(timesliceSN, timesliceRouter, moduleRouter, parameters.SN.TMaxLocal_ns));
222  }
223  }
224  STATUS(endl);
225 
227 
228  io >> outputFile;
229 
230  outputFile.close();
231 }
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
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
Auxiliary class to select ROOT class based on class name.
Router for direct addressing of module data in detector data structure.
*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.
string outputFile
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
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:196
#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
#define NOTICE(A)
Definition: JMessage.hh:64
const JDAQChronometer & getDAQChronometer() const
Get DAQ chronometer.
Data time slice.
int debug
debug level
Definition: JSirene.cc:63
const JPosition3D & getPosition() const
Get position.
Definition: JPosition3D.hh:130
Template L1 hit builder.
Definition: JBuildL1.hh:85
#define FATAL(A)
Definition: JMessage.hh:67
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
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
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
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 source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:41
JTriggerParameters getTriggerParameters(const JMultipleFileScanner_t &file_list)
Get trigger parameters.
Time slice with calibrated data.
Definition: JTimeslice.hh:26