Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JPMTSwapDB.cc
Go to the documentation of this file.
1#include <string>
2#include <iostream>
3#include <iomanip>
4#include <limits>
5#include <vector>
6#include <map>
7
8#include "JDB/JDB.hh"
9#include "JDB/JSelector.hh"
11#include "JDB/JDBToolkit.hh"
13#include "JDB/JLocation_t.hh"
14
17
18#include "Jeep/JPrint.hh"
19#include "Jeep/JParser.hh"
20#include "Jeep/JMessage.hh"
21
22
23/**
24 * \file
25 *
26 * Auxiliary program to check HV.
27 * \author mdejong
28 */
29int main(int argc, char **argv)
30{
31 using namespace std;
32 using namespace JPP;
33
34 JServer server;
35 string usr;
36 string pwd;
37 string cookie;
38 string detectorFile;
39 string outputFile;
40 int debug;
41
42 try {
43
44 JParser<> zap("Auxiliary program to check HV.");
45
46 zap['s'] = make_field(server) = getServernames();
47 zap['u'] = make_field(usr) = "";
48 zap['!'] = make_field(pwd) = "";
49 zap['C'] = make_field(cookie) = "";
50 zap['a'] = make_field(detectorFile);
51 zap['o'] = make_field(outputFile) = "";
52 zap['d'] = make_field(debug) = 2;
53
54 zap(argc, argv);
55 }
56 catch(const exception &error) {
57 FATAL(error.what() << endl);
58 }
59
60
61 JDetector detectorA;
62
63 try {
64 load(detectorFile, detectorA);
65 }
66 catch(const JException& error) {
67 FATAL(error);
68 }
69
70
71 try {
72
73 JDB::reset(usr, pwd, cookie);
74
75 const string detid = getDetector(detectorA.getID());
76
77 typedef map<int, JDetectorIntegration> detector_type;
78
79 detector_type detectorB;
80
81 {
82 ResultSet& rs = getResultSet(getTable<JDetectorIntegration>(), getSelector<JDetectorIntegration>(detectorA.getID()));
83
84 for (JDetectorIntegration parameters; rs >> parameters; ) {
85
86 if (parameters.PMTUPI.getPBS() == PBS::PMT) {
87 detectorB[parameters.PMTSER] = parameters;
88 }
89 }
90
91 rs.Close();
92 }
93
94 for (JDetector::iterator module = detectorA.begin(); module != detectorA.end(); ++module) {
95
96 vector<JPMT> buffer(module->begin(), module->end());
97
98 for (size_t i = 0; i != module->size(); ++i) {
99
100 const int pmt = (*module)[i].getID();
101
102 if (detectorB.count(pmt) == 1) {
103
104 const JDetectorIntegration& parameters = detectorB[pmt];
105
106 const JLocation location(parameters.DUID, parameters.FLOORID);
107
108 if (module->getLocation() != location) {
109 FATAL("Wrong location " << left << setw(5) << pmt << " " << module->getLocation() << " != " << location << endl);
110 }
111
112 if (parameters.PMTID != parameters.CABLEPOS) {
113
114 NOTICE("Swap PMT "
115 << right << setw(10) << module->getID() << ' '
116 << JLocation_t(parameters.DUID, parameters.FLOORID, parameters.CABLEPOS) << " <- "
117 << JLocation_t(parameters.DUID, parameters.FLOORID, parameters.PMTID) << endl);
118
119 buffer[parameters.CABLEPOS] = (*module)[parameters.PMTID];
120 }
121
122 if (parameters.PMTID != (int) i) {
123
124 ERROR("PMT serial number "
125 << setw(6) << pmt << ' '
126 << right << setw(10) << module->getID() << ' '
127 << JLocation_t(module->getString(), module->getFloor(), i) << " -> "
128 << JLocation_t(parameters.DUID, parameters.FLOORID, parameters.PMTID) << endl);
129 }
130
131 } else {
132
133 ERROR("Missing PMT " << left << setw(5) << pmt << right << setw(10) << module->getID() << "." << FILL(2,'0') << i << FILL() << endl);
134 }
135 }
136
137 module->swap(buffer);
138 }
139 }
140 catch(const exception& error) {
141 FATAL(error.what() << endl);
142 }
143
144
145 if (outputFile != "") {
146 try {
147 store(outputFile, detectorA);
148 }
149 catch(const JException& error) {
150 FATAL(error);
151 }
152 }
153}
string outputFile
Data structure for detector geometry and calibration.
General purpose messaging.
#define ERROR(A)
Definition JMessage.hh:66
#define NOTICE(A)
Definition JMessage.hh:64
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
int main(int argc, char **argv)
Definition JPMTSwapDB.cc:29
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
I/O formatting auxiliaries.
Detector data structure.
Definition JDetector.hh:96
Logical location of module.
Definition JLocation.hh:40
General exception.
Definition JException.hh:24
int getID() const
Get identifier.
Definition JObjectID.hh:50
Utility class to parse command line options.
Definition JParser.hh:1698
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary data structure for sequence of same character.
Definition JManip.hh:330
Auxiliary data structure for location of product in detector.
Wrapper class for server name.
Definition JDB.hh:54
Template definition for getting table specific selector.