Jpp  18.2.1-ARCA-DF-PATCH
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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

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 }
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:1514
#define WARNING(A)
Definition: JMessage.hh:65
std::map< int, buffer_type > map_type
string -&gt; hits
Definition: JPerth.cc:68
uint32_t domIdentifier() const
#define STATUS(A)
Definition: JMessage.hh:63
uint32_t runNumber() const
UTCTime timeStamp() const
string outputFile
Detector file.
Definition: JHead.hh:226
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
uint32_t udpSequenceNumber() const
#define FATAL(A)
Definition: JMessage.hh:67
uint32_t dataType() const
then echo Submitting reweighting and histogram comparison jobs to nikhef stbc batch queue
set_variable TDC
Definition: JPrintTDC.sh:20
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 JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:46
uint64_t inMilliSeconds() const
Definition: utctime.hh:27
int debug
debug level
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62