Jpp
 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 "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 190 of file JDAQSplit.cc.

191 {
192  using namespace std;
193  using namespace JPP;
194 
195  typedef vector<JFrameIndexRange> ranges_type;
196 
197  std::string inputFile;
198  std::string outputFile;
199  size_t numberOfFiles;
200  ranges_type ranges;
201  int debug;
202 
203  try {
204 
205  JParser<> zap("Auxiliary program to split data.");
206 
207  zap['f'] = make_field(inputFile);
208  zap['o'] = make_field(outputFile);
209  zap['N'] = make_field(numberOfFiles) = 0;
210  zap['r'] = make_field(ranges) = JPARSER::initialised();
211  zap['d'] = make_field(debug) = 1;
212 
213  zap(argc, argv);
214  }
215  catch(const exception& error) {
216  FATAL(error.what() << endl);
217  }
218 
219 
220  if (numberOfFiles == 0 && ranges.empty()) {
221  FATAL("Invalid splitting " << numberOfFiles << '/' << ranges.size() << endl);
222  }
223 
224  const size_t pos = outputFile.find(WILDCARD);
225 
226  if (pos == string::npos) {
227  FATAL("Output file name " << outputFile << " does not contain wild card '" << WILDCARD << "'" << endl);
228  }
229 
230  const JFrameIndexRange total = getFrameIndexRange<JDAQSummaryslice>(inputFile);
231 
232  DEBUG("Total frame index range " << total << endl);
233 
234  if (total.getLength() == 0) {
235  FATAL("No summary data in input file " << inputFile << endl);
236  }
237 
238 
239  if (ranges.empty()) {
240 
241  int length = total.getLength() / numberOfFiles;
242 
243  if (length == 0) {
244  length = 1;
245  }
246 
247  for (JFrameIndexRange range(total.getLowerLimit(),
248  total.getLowerLimit() + length);
249  range.getLowerLimit() <= total.getUpperLimit();
250  range.add(length + 1)) {
251  ranges.push_back(range);
252  }
253  }
254 
255 
257 
258  JCopyMaster<JDAQTypes_t> master(inputFile);
259 
260  for (ranges_type::const_iterator range = ranges.begin(); range != ranges.end(); ++range) {
261 
262  const string file_name = MAKE_STRING(outputFile.substr(0,pos) << "_"
263  << range->getLowerLimit() << "-"
264  << range->getUpperLimit() << "_"
265  << outputFile.substr(pos+1));
266 
267  STATUS("Writing " << file_name << endl);
268 
269  master.open(file_name.c_str());
270 
271  master.put(getTriggerParameters(inputFile));
272 
273  master.copy(*range);
274 
275  master.close();
276  }
277 }
Utility class to parse command line options.
Definition: JParser.hh:1493
T getLowerLimit() const
Get lower limit.
Definition: JRange.hh:215
#define STATUS(A)
Definition: JMessage.hh:63
then echo Test string reversed by master(hit< return > to continue)." JProcess -c "JEcho" -rC fi if (( 1 ))
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:63
string outputFile
#define MAKE_STRING(A)
Make string.
Definition: JPrint.hh:699
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
int debug
debug level
Definition: JSirene.cc:61
#define FATAL(A)
Definition: JMessage.hh:67
JTriggerParameters getTriggerParameters(const JMultipleFileScanner_t &file_list)
Get trigger parameters.
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62