Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JConvertDetectorFormat.cc
Go to the documentation of this file.
1 #include <string>
2 
3 #include "JDetector/JDetector.hh"
5 #include "JSupport/JMeta.hh"
6 
7 #include "Jeep/JParser.hh"
8 #include "Jeep/JMessage.hh"
9 
10 
11 /**
12  * \file
13  *
14  * Auxiliary program to convert format of detector files.
15  *
16  * The following combinations of file name extensions are supported:
17  * <table>
18  * <tr><th> input </th><th> output </th></tr>
19  * <tr><td> detx </td><td> detx </td></tr>
20  * <tr><td> detx </td><td> dat </td></tr>
21  * <tr><td> detx </td><td> gdml </td></tr>
22  * <tr><td> dat </td><td> detx </td></tr>
23  * <tr><td> dat </td><td> dat </td></tr>
24  * <tr><td> dat </td><td> gdml </td></tr>
25  * <tr><td> det </td><td> detx </td></tr>
26  * <tr><td> det </td><td> dat </td></tr>
27  * <tr><td> det </td><td> gdml </td></tr>
28  * </table>
29  *
30  * Note that if the output file name is the same as the input file name,
31  * the original file will be overwritten.
32  * \author rbruijn
33  */
34 int main(int argc, char **argv)
35 {
36 
37  using namespace std;
38  using namespace JPP;
39 
40  string detectorFile;
41  string outputFile;
42  string variant;
43  int debug;
44 
45  try {
46 
47  JParser<> zap("Auxiliary program to convert format of detector files.");
48 
49  zap['a'] = make_field(detectorFile);
50  zap['o'] = make_field(outputFile);
51  zap['V'] = make_field(variant, "\"\" maintains version") = getDetectorVersions<string>(), "";
52  zap['d'] = make_field(debug) = 0;
53 
54  zap(argc, argv);
55  }
56  catch(const exception &error) {
57  FATAL(error.what() << endl);
58  }
59 
61 
62  try {
63  load(detectorFile, detector);
64  }
65  catch(const JException& error) {
66  FATAL(error);
67  }
68 
69  if (variant != "") {
70  detector.setVersion(variant);
71  }
72 
73  detector.comment.add(JMeta(argc,argv));
74 
75  try {
77  }
78  catch(const JException& error) {
79  FATAL(error);
80  }
81 }
Auxiliary class for ROOT I/O of application specific meta data.
Definition: JMeta.hh:70
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
Data structure for detector geometry and calibration.
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.
ROOT I/O of application specific meta data.
int debug
debug level
Definition: JSirene.cc:63
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
Utility class to parse command line options.
do set_variable DETECTOR_TXT $WORKDIR detector
int main(int argc, char *argv[])
Definition: Main.cpp:15