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

Auxiliary program to merge detector files. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JLocation.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 merge detector files.

If the option

    -N [i] 

is used with a positive number the strings are renumbered starting from i. Each string gets a unique number based on the order of the detector files and its original index in its own detector file.

Author
mdejong

Definition in file JMergeDetector.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 28 of file JMergeDetector.cc.

29 {
30  using namespace std;
31  using namespace JPP;
32 
33  vector<string> detectorFile;
34  string outputFile;
35  int debug;
36 
37  try {
38 
39  JParser<> zap("Auxiliary program to merge detector files.");
40 
41  zap['a'] = make_field(detectorFile);
42  zap['o'] = make_field(outputFile);
43  zap['d'] = make_field(debug) = 1;
44 
45  zap(argc, argv);
46  }
47  catch(const exception &error) {
48  FATAL(error.what() << endl);
49  }
50 
51 
53 
54  for (vector<string>::const_iterator i = detectorFile.begin(); i != detectorFile.end(); ++i) {
55 
56  JDetector buffer;
57 
58  try {
59  load(*i, buffer);
60  }
61  catch(const JException& error) {
62  FATAL(error);
63  }
64 
65  if (detector.empty())
66  detector = buffer;
67  else
68  copy(buffer.begin(), buffer.end(), back_inserter(detector));
69  }
70 
71  try {
73  }
74  catch(const JException& error) {
75  FATAL(error);
76  }
77 }
Utility class to parse command line options.
Definition: JParser.hh:1500
General exception.
Definition: JException.hh:23
Detector data structure.
Definition: JDetector.hh:80
string outputFile
Detector file.
Definition: JHead.hh:196
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
void store(const std::string &file_name, const JDetector &detector)
Store detector to output file.
int debug
debug level
Definition: JSirene.cc:63
#define FATAL(A)
Definition: JMessage.hh:67
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:139
do set_variable DETECTOR_TXT $WORKDIR detector