Jpp  18.2.1-ARCA-DF-PATCH
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JAttachPMTs.cc File Reference

Auxiliary program to attach PMTs to detector. More...

#include <string>
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JSupport/JMeta.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 attach PMTs to detector.

Author
mdejong

Definition in file JAttachPMTs.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 18 of file JAttachPMTs.cc.

19 {
20 
21  using namespace std;
22  using namespace JPP;
23 
24  string detectorFile_a;
25  string detectorFile_b;
26  string outputFile;
27  int debug;
28 
29  try {
30 
31  JParser<> zap("Auxiliary program to attach PMTs to detector.");
32 
33  zap['a'] = make_field(detectorFile_a, "detector file w/o PMTs");
34  zap['f'] = make_field(detectorFile_b, "detector file with PMTs");
35  zap['o'] = make_field(outputFile, "detector file with PMTs");
36  zap['d'] = make_field(debug) = 0;
37 
38  zap(argc, argv);
39  }
40  catch(const exception &error) {
41  FATAL(error.what() << endl);
42  }
43 
44  JDetector detector_a;
45  JDetector detector_b;
46 
47  try {
48  load(detectorFile_a, detector_a);
49  load(detectorFile_b, detector_b);
50  }
51  catch(const JException& error) {
52  FATAL(error);
53  }
54 
55  detector_a.comment.add(JMeta(argc,argv));
56 
57  if (detector_a.setToLatestVersion()) {
58  NOTICE("Set detector version to " << detector_a.getVersion() << endl);
59  }
60 
61  for (JDetector::iterator module_b = detector_b.begin(); module_b != detector_b.end(); ++module_b) {
62 
63  for (JDetector::iterator module_a = detector_a.begin(); module_a != detector_a.end(); ++module_a) {
64 
65  if (module_a->getID() == module_b->getID()) {
66 
67  DEBUG("Attach PMTs in module " << setw(10) << module_a->getID() << endl);
68 
69  module_b->set ( module_a->getPosition());
70  module_b->swap(*module_a);
71 
72  break;
73  }
74  }
75  }
76 
77  try {
78  store(outputFile, detector_a);
79  }
80  catch(const JException& error) {
81  FATAL(error);
82  }
83 }
Utility class to parse command line options.
Definition: JParser.hh:1514
string outputFile
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
void store(const std::string &file_name, const JDetector &detector)
Store detector to output file.
#define NOTICE(A)
Definition: JMessage.hh:64
#define FATAL(A)
Definition: JMessage.hh:67
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
int debug
debug level
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62