Jpp  16.0.1
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 = combine(getUTCTimeRange<JDAQSummaryslice>(inputFile),
250  getUTCTimeRange<JDAQEvent> (inputFile));
251 
252  if (!total.is_valid()) {
253  FATAL("No (valid) summary data in input file " << inputFile << ' ' << total << endl);
254  }
255 
256  NOTICE("Total time range " << total << endl);
257 
258  if (ranges.empty()) {
259 
260  const double T_ns = (total.getUpperLimit().getTimeNanoSecond() -
261  total.getLowerLimit().getTimeNanoSecond()) / numberOfFiles;
262 
263  for (double t1 = total.getLowerLimit().getTimeNanoSecond(); t1 < total.getUpperLimit().getTimeNanoSecond(); t1 += T_ns) {
264  ranges.push_back(JDAQUTCTimeRange(JDAQUTCExtended(t1), JDAQUTCExtended(t1 + T_ns)));
265  }
266  }
267 
268 
270 
271  JCopyMaster<JDAQTypes_t> master(inputFile, selection);
272 
273  const int width = (int) (log10(ranges.size() + 1) + 1);
274 
275  for (size_t i = 0; i != ranges.size(); ++i) {
276 
277  const string file_name = MAKE_STRING(outputFile.substr(0,pos) << FILL(width,'0') << i << FILL() << outputFile.substr(pos+1));
278 
279  STATUS("Writing " << file_name << endl);
280 
281  master.open(file_name.c_str());
282 
283  master.put(getTriggerParameters(inputFile));
284 
285  master.copy(ranges[i]);
286 
287  master.close();
288  }
289 }
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
set_variable E_E log10(E_{fit}/E_{#mu})"
#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
JRange< T, JComparator_t > combine(const JRange< T, JComparator_t > &first, const JRange< T, JComparator_t > &second)
Combine ranges.
Definition: JRange.hh:685
#define FATAL(A)
Definition: JMessage.hh:67
JTriggerParameters getTriggerParameters(const JMultipleFileScanner_t &file_list)
Get trigger parameters.