Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JCLB.cc File Reference

Auxiliary program to convert 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 CLB data to KM3NETDAQ::JDAQTimeslice data.

Author
mdejong

Definition in file JCLB.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 136 of file JCLB.cc.

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