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