Jpp  master_rocky-40-g5f0272dcd
the software that should make you happy
Functions
JCLB.cc File Reference

Auxiliary program to convert raw CLB data to KM3NETDAQ::JDAQTimeslice data. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <algorithm>
#include "DataQueue/DataFormats/clb_common_header.hh"
#include "km3net-dataformat/online/JDAQHit.hh"
#include "km3net-dataformat/online/JDAQSuperFrame.hh"
#include "km3net-dataformat/online/JDAQTimeslice.hh"
#include "JDAQ/JDAQTimesliceIO.hh"
#include "JSupport/JFileRecorder.hh"
#include "JSupport/JSupport.hh"
#include "JSupport/JMeta.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 convert raw CLB data to KM3NETDAQ::JDAQTimeslice data.

Author
mdejong

Definition in file JCLB.cc.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 137 of file JCLB.cc.

138 {
139  using namespace std;
140  using namespace JPP;
141  using namespace KM3NETDAQ;
142 
143 
144  string inputFile;
145  int numberOfEvents;
147  int detector;
148  size_t queue;
149  int debug;
150 
151  try {
152 
153  JParser<> zap("Auxiliary program to convert raw CLB data to KM3NETDAQ::JDAQTimeslice data.");
154 
155  zap['f'] = make_field(inputFile, "input file).");
156  zap['o'] = make_field(outputFile, "output file.") = "clb.root";
157  zap['n'] = make_field(numberOfEvents) = numeric_limits<int>::max();
158  zap['Q'] = make_field(queue, "queue depth") = 1000;
159  zap['D'] = make_field(detector, "detector identifier") = 1;
160  zap['d'] = make_field(debug, "debug.") = 1;
161 
162  zap(argc, argv);
163  }
164  catch(const exception& error) {
165  FATAL(error.what() << endl);
166  }
167 
168 
169  outputFile.open();
170 
171  if (!outputFile.is_open()) {
172  FATAL("Error opening file " << outputFile << endl);
173  }
174 
175  outputFile.put(JMeta(argc, argv));
176 
178 
179  uint32_t run = numeric_limits<uint32_t>::max();
180  uint32_t size;
181 
182  ifstream in(inputFile.c_str(), ios::binary);
183 
184  for (int count = 0; count != numberOfEvents && in.read((char*) &size, sizeof(uint32_t)); ++count) {
185 
186  STATUS(setw(8) << count << '\r'); DEBUG(endl);
187 
188  buffer_type buffer(size);
189 
190  if (in.read(buffer.data(), size)) {
191 
192  if (size >= sizeof(CLBCommonHeader)) {
193 
194  const CLBCommonHeader* header = (const CLBCommonHeader*) buffer.data();
195 
196  if (run == numeric_limits<uint32_t>::max()) {
197  run = header->runNumber();
198  }
199 
200  DEBUG("data: "
201  << setw(8) << header->runNumber() << ' '
202  << setw(9) << header->domIdentifier() << ' '
203  << setw(2) << header->udpSequenceNumber() << endl);
204 
205  if (header->dataType() == TDC) {
206 
207  if (header->runNumber() == run) {
208 
209  data[header->timeStamp().inMilliSeconds()][header->domIdentifier()].push_back(buffer);
210 
211  while (data.size() > queue) {
212  outputFile.put(data.pop());
213  }
214 
215  } else {
216 
217  WARNING("Run numbers differ " << run << ' ' << header->runNumber() << " -> skip data." << endl);
218  }
219  }
220  }
221  }
222  }
223  STATUS(endl);
224 
225  in.close();
226 
227  while (!data.empty()) {
228  outputFile.put(data.pop());
229  }
230 
231  outputFile.close();
232 }
string outputFile
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
#define STATUS(A)
Definition: JMessage.hh:63
#define FATAL(A)
Definition: JMessage.hh:67
int debug
debug level
Definition: JSirene.cc:69
#define WARNING(A)
Definition: JMessage.hh:65
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2142
Utility class to parse command line options.
Definition: JParser.hh:1698
Object writing to file.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
KM3NeT DAQ data structures and auxiliaries.
Definition: DataQueue.cc:39
std::map< int, range_type > map_type
Definition: JSTDTypes.hh:14
uint32_t dataType() const
uint32_t udpSequenceNumber() const
UTCTime timeStamp() const
uint32_t runNumber() const
uint32_t domIdentifier() const
Detector file.
Definition: JHead.hh:227
Auxiliary class for ROOT I/O of application specific meta data.
Definition: JMeta.hh:72
uint64_t inMilliSeconds() const
Definition: utctime.hh:27