#include #include "JDetector/JDetector.hh" #include "JDetector/JDetectorToolkit.hh" #include "JSupport/JMeta.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * * Auxiliary program to attach PMTs to detector. * * \author mdejong */ int main(int argc, char **argv) { using namespace std; using namespace JPP; string detectorFile_a; string detectorFile_b; string outputFile; bool squash; int debug; try { JParser<> zap("Auxiliary program to attach PMTs to detector."); zap['a'] = make_field(detectorFile_a, "detector file w/o PMTs"); zap['f'] = make_field(detectorFile_b, "detector file with PMTs"); zap['o'] = make_field(outputFile, "detector file with PMTs"); zap['q'] = make_field(squash, "squash meta data"); zap['d'] = make_field(debug) = 0; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } JDetector detector_a; JDetector detector_b; try { load(detectorFile_a, detector_a); load(detectorFile_b, detector_b); } catch(const JException& error) { FATAL(error); } if (squash) { detector_a.comment.clear(); } detector_a.comment.add(JMeta(argc,argv)); if (detector_a.setToLatestVersion()) { NOTICE("Set detector version to " << detector_a.getVersion() << endl); } for (JDetector::iterator module_b = detector_b.begin(); module_b != detector_b.end(); ++module_b) { for (JDetector::iterator module_a = detector_a.begin(); module_a != detector_a.end(); ++module_a) { if (module_a->getID() == module_b->getID()) { DEBUG("Attach PMTs in module " << setw(10) << module_a->getID() << endl); module_b->set ( module_a->getPosition()); module_b->swap(*module_a); break; } } } try { store(outputFile, detector_a); } catch(const JException& error) { FATAL(error); } }