Jpp 21.0.0-rc.1-88-g0130508c4
the software that should make you happy
Loading...
Searching...
No Matches
JTimesliceReprocessor.cc
Go to the documentation of this file.
1
2#include <string>
3#include <iostream>
4#include <iomanip>
5
10
12#include "JDAQ/JDAQEventIO.hh"
14
18
19#include "JTrigger/JHit.hh"
24#include "JTrigger/JBuildL1.hh"
25#include "JTrigger/JBuildL2.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 */
49int 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
153 struct counts_type {
154
155 void add(const size_t value)
156 {
157 this->value += value;
158 this->count += 1;
159 }
160
161 size_t value = 0; // number of entries
162 size_t count = 0; // number of optical modules
163 };
164
166
168
169 counter_type counter = 0;
170
171 for ( ; in.hasNext() && counter != inputFile.getLimit(); ++counter) {
172
173 STATUS("event: " << setw(10) << counter << '\r'); DEBUG(endl);
174
175 const JDAQTimeslice* timeslice = in.next();
176
177 DEBUG(*timeslice << endl);
178
179 timesliceRouter.configure(*timeslice);
180
181 JTimeslice_t timesliceL0(timeslice->getDAQChronometer());
182 JTimeslice_t timesliceL1(timeslice->getDAQChronometer());
183 JTimeslice_t timesliceL2(timeslice->getDAQChronometer());
184 JTimeslice_t timesliceSN(timeslice->getDAQChronometer());
185
186 for (JDAQTimeslice::const_iterator super_frame = timeslice->begin(); super_frame != timeslice->end(); ++super_frame) {
187
188 if (moduleRouter.hasModule(super_frame->getModuleID())) {
189
190 // calibration
191
192 const JModule& module = moduleRouter.getModule(super_frame->getModuleID());
193 JSuperFrame2D_t& buffer = JSuperFrame2D_t::demultiplex(*super_frame, module);
194
195 // Apply high-rate veto
196
197 buffer.applyHighRateVeto(parameters.highRateVeto_Hz);
198
199 // L0
200
201 timesliceL0.push_back(JSuperFrame1D_t(buffer));
202
203 // L1
204
205 timesliceL1.push_back(JSuperFrame1D_t(super_frame->getDAQChronometer(),
206 super_frame->getModuleIdentifier(),
207 module.getPosition()));
208
209 buildL1(*timesliceL0.rbegin(), back_inserter(*timesliceL1.rbegin()));
210
211 // L2
212
213 timesliceL2.push_back(JSuperFrame1D_t(super_frame->getDAQChronometer(),
214 super_frame->getModuleIdentifier(),
215 module.getPosition()));
216
217 buildL2(buffer, *timesliceL1.rbegin(), back_inserter(*timesliceL2.rbegin()));
218
219 // SN
220 {
221 JTimeslice_t::value_type tv(super_frame->getDAQChronometer(),
222 super_frame->getModuleIdentifier(),
223 module.getPosition());
224
225 buildSN(buffer, *timesliceL1.rbegin(), back_inserter(tv));
226
227 if (!tv.empty()) {
228 timesliceSN.push_back(tv);
229 }
230 }
231 }
232 }
233
234 for (const auto& i : timesliceL1) { ls["L1"].add(i.size()); }
235 for (const auto& i : timesliceL2) { ls["L2"].add(i.size()); }
236 for (const auto& i : timesliceSN) { ls["SN"].add(i.size()); }
237
238 if (parameters.writeL0()) {
239 outputFile.put(*timeslice);
240 }
241
242 if (parameters.writeL1()) {
243 outputFile.put(JTimesliceL1<JDAQTimesliceL1>(timesliceL1, timesliceRouter, moduleRouter, parameters.TMaxLocal_ns));
244 }
245
246 if (parameters.writeL2()) {
247 outputFile.put(JTimesliceL1<JDAQTimesliceL2>(timesliceL2, timesliceRouter, moduleRouter, parameters.L2.TMaxLocal_ns));
248 }
249
250 if (parameters.writeSN()) {
251 outputFile.put(JTimesliceL1<JDAQTimesliceSN>(timesliceSN, timesliceRouter, moduleRouter, parameters.SN.TMaxLocal_ns));
252 }
253 }
254 STATUS(endl);
255
256 for (const auto& i : ls) {
257 NOTICE(left << setw(4) << i.first << right << FIXED(7,2) << (i.second.count != 0 ? (double) i.second.value / ((double) i.second.count * 1.0e-9 * getFrameTime()) : 0.0) << " Hz" << endl);
258 }
259
261
262 io >> outputFile;
263
264 outputFile.close();
265}
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:74
#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:2140
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.
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.
bool hasModule(const JModuleIdentifier &id) const
Has module.
const JModule & getModule(const JModuleIdentifier &id) const
Get module parameters.
Data structure for a composite optical module.
Definition JModule.hh:76
const JPosition3D & getPosition() const
Get position.
General exception.
Definition JException.hh:25
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:1697
Object writing to file.
Object reading from a list of files.
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.
const JDAQChronometer & getDAQChronometer() const
Get DAQ chronometer.
int main()
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).
std::set< JROOTClassSelector > getROOTClassSelection(const bool option=false)
Get ROOT class selection.
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
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:14
Auxiliary data structure for floating point format specification.
Definition JManip.hh:448
Detector file.
Definition JHead.hh:227
Transmission with position.
Definition JBillabong.cc:70
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:67
Auxiliary class to select ROOT class based on class name.
Auxiliary class for defining the range of iterations of objects.
Definition JLimit.hh:45
static counter_type max()
Get maximum counter value.
Definition JLimit.hh:128
Auxiliary class for ROOT I/O of application specific meta data.
Definition JMeta.hh:72
Auxiliary data structure to list files in directory.
Router for fast addressing of hits in KM3NETDAQ::JDAQTimeslice data structure as a function of the op...
void configure(const JDAQTimeslice &timeslice)
Configure.