Jpp  15.0.1-rc.1-highQE
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JDAQSplit.cc File Reference

Auxiliary program to split data. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "JDAQ/JDAQTimesliceIO.hh"
#include "JDAQ/JDAQEventIO.hh"
#include "JDAQ/JDAQSummarysliceIO.hh"
#include "JDAQ/JDAQEvaluator.hh"
#include "JTrigger/JTriggerParameters.hh"
#include "JSupport/JSingleFileScanner.hh"
#include "JSupport/JTreeScanner.hh"
#include "JSupport/JFileRecorder.hh"
#include "JSupport/JTriggerParametersSupportkit.hh"
#include "JSupport/JMeta.hh"
#include "JSupport/JSupport.hh"
#include "JSupport/JSupportToolkit.hh"
#include "JROOT/JROOTClassSelector.hh"
#include "JLang/JSinglePointer.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 split data.

Author
mdejong

Definition in file JDAQSplit.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 203 of file JDAQSplit.cc.

204 {
205  using namespace std;
206  using namespace JPP;
207 
208  typedef vector<JDAQUTCTimeRange> ranges_type;
209 
210  std::string inputFile;
211  std::string outputFile;
212  size_t numberOfFiles;
213  ranges_type ranges;
214  JROOTClassSelection selection = getROOTClassSelection<JDAQTypes_t>();
215  int debug;
216 
217  try {
218 
219  JParser<> zap("Auxiliary program to split data.");
220 
221  zap['f'] = make_field(inputFile);
222  zap['o'] = make_field(outputFile);
223  zap['N'] = make_field(numberOfFiles) = 0;
224  zap['r'] = make_field(ranges,
225  "UTC time range(s)") = JPARSER::initialised();
226  zap['C'] = make_field(selection,
227  "Precede name of data structure by a '+' or '-' "
228  "to add or remove data types in the output, respectively."
229  "\nROOT wildcards are accepted.") = JPARSER::initialised();
230  zap['d'] = make_field(debug) = 1;
231 
232  zap(argc, argv);
233  }
234  catch(const exception& error) {
235  FATAL(error.what() << endl);
236  }
237 
238 
239  if (numberOfFiles == 0 && ranges.empty()) {
240  FATAL("Invalid splitting " << numberOfFiles << '/' << ranges.size() << endl);
241  }
242 
243  const size_t pos = outputFile.find(WILDCARD);
244 
245  if (pos == string::npos) {
246  FATAL("Output file name " << outputFile << " does not contain wild card '" << WILDCARD << "'" << endl);
247  }
248 
249  const JDAQUTCTimeRange total = getUTCTimeRange<JDAQSummaryslice>(inputFile);
250 
251  if (!total.is_valid()) {
252  FATAL("No (valid) summary data in input file " << inputFile << ' ' << total << endl);
253  }
254 
255  NOTICE("Total time range " << total << endl);
256 
257  if (ranges.empty()) {
258 
259  const double T_ns = (total.getUpperLimit().getTimeNanoSecond() -
260  total.getLowerLimit().getTimeNanoSecond()) / numberOfFiles;
261 
262  for (double t1 = total.getLowerLimit().getTimeNanoSecond(); t1 < total.getUpperLimit().getTimeNanoSecond(); t1 += T_ns) {
263  ranges.push_back(JDAQUTCTimeRange(JDAQUTCExtended(t1), JDAQUTCExtended(t1 + T_ns)));
264  }
265  }
266 
267 
269 
270  JCopyMaster<JDAQTypes_t> master(inputFile, selection);
271 
272  const int width = (int) (log10(ranges.size() + 1) + 1);
273 
274  for (size_t i = 0; i != ranges.size(); ++i) {
275 
276  const string file_name = MAKE_STRING(outputFile.substr(0,pos) << FILL(width,'0') << i << FILL() << outputFile.substr(pos+1));
277 
278  STATUS("Writing " << file_name << endl);
279 
280  master.open(file_name.c_str());
281 
282  master.put(getTriggerParameters(inputFile));
283 
284  master.copy(ranges[i]);
285 
286  master.close();
287  }
288 }
Utility class to parse command line options.
Definition: JParser.hh:1500
then echo Test string reversed by master(hit< return > to continue)." $DIR/JProcess -c "$DIR/JEcho" -rC fi if (( 1 ))
#define STATUS(A)
Definition: JMessage.hh:63
Auxiliary class for ROOT class selection.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:66
string outputFile
Data structure for UTC time.
#define MAKE_STRING(A)
Make string.
Definition: JPrint.hh:142
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
#define NOTICE(A)
Definition: JMessage.hh:64
int debug
debug level
Definition: JSirene.cc:63
Range of values.
Definition: JRange.hh:38
JTOOLS::JRange< JDAQUTCExtended > JDAQUTCTimeRange
Type definition for DAQ UTC time range.
Auxiliary data structure for sequence of same character.
Definition: JManip.hh:328
#define FATAL(A)
Definition: JMessage.hh:67
JTriggerParameters getTriggerParameters(const JMultipleFileScanner_t &file_list)
Get trigger parameters.