Jpp test-rotations-new
the software that should make you happy
Loading...
Searching...
No Matches
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

◆ main()

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 bool squash;
28 int debug;
29
30 try {
31
32 JParser<> zap("Auxiliary program to attach PMTs to detector.");
33
34 zap['a'] = make_field(detectorFile_a, "detector file w/o PMTs");
35 zap['f'] = make_field(detectorFile_b, "detector file with PMTs");
36 zap['o'] = make_field(outputFile, "detector file with PMTs");
37 zap['q'] = make_field(squash, "squash meta data");
38 zap['d'] = make_field(debug) = 0;
39
40 zap(argc, argv);
41 }
42 catch(const exception &error) {
43 FATAL(error.what() << endl);
44 }
45
46 JDetector detector_a;
47 JDetector detector_b;
48
49 try {
50 load(detectorFile_a, detector_a);
51 load(detectorFile_b, detector_b);
52 }
53 catch(const JException& error) {
54 FATAL(error);
55 }
56
57 if (squash) {
58 detector_a.comment.clear();
59 }
60
61 detector_a.comment.add(JMeta(argc,argv));
62
63 if (detector_a.setToLatestVersion()) {
64 NOTICE("Set detector version to " << detector_a.getVersion() << endl);
65 }
66
67 for (JDetector::iterator module_b = detector_b.begin(); module_b != detector_b.end(); ++module_b) {
68
69 for (JDetector::iterator module_a = detector_a.begin(); module_a != detector_a.end(); ++module_a) {
70
71 if (module_a->getID() == module_b->getID()) {
72
73 DEBUG("Attach PMTs in module " << setw(10) << module_a->getID() << endl);
74
75 module_b->set ( module_a->getPosition());
76 module_b->swap(*module_a);
77
78 break;
79 }
80 }
81 }
82
83 try {
84 store(outputFile, detector_a);
85 }
86 catch(const JException& error) {
87 FATAL(error);
88 }
89}
string outputFile
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
#define NOTICE(A)
Definition JMessage.hh:64
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
Detector data structure.
Definition JDetector.hh:96
bool setToLatestVersion()
Set to latest version.
Definition JDetector.hh:170
General exception.
Definition JException.hh:24
Utility class to parse command line options.
Definition JParser.hh:1698
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
void store(const std::string &file_name, const JDetector &detector)
Store detector to output file.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
const std::string & getVersion() const
Get version.
JComment & add(const std::string &comment)
Add comment.
Definition JComment.hh:100
Auxiliary class for ROOT I/O of application specific meta data.
Definition JMeta.hh:72