Jpp 21.0.1
the software that should make you happy
Loading...
Searching...
No Matches
JPMTTTS.cc
Go to the documentation of this file.
1#include <string>
2#include <iostream>
3#include <iomanip>
4#include <limits>
5#include <map>
6#include <filesystem>
7
8#include "JDB/JDB.hh"
9#include "JDB/JSelector.hh"
11#include "JDB/JDBToolkit.hh"
13
15
16#include "JSupport/JMeta.hh"
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 set TTS function identifier in PMT parameters file according PMT variant.
27 * \author mdejong
28 */
29int main(int argc, char **argv)
30{
31 using namespace std;
32 using namespace JPP;
33
34 const std::string WILDCARD = "%"; //!< wild card
35
36 JServer server;
37 string usr;
38 string pwd;
39 string cookie;
40 string detid;
42 string pmtFile;
43 int debug;
44
45 TTS["HAMA-R12199"] = 1;
46 TTS["HAMA-R14374"] = 67;
47 TTS["HAMA-R14374-02"] = 67;
48 TTS[WILDCARD] = 1;
49
50 try {
51
52 JParser<> zap("Auxiliary program to set TTS function identifier in PMT parameters file according PMT variant.");
53
54 zap['s'] = make_field(server) = getServernames();
55 zap['u'] = make_field(usr) = "";
56 zap['!'] = make_field(pwd) = "";
57 zap['C'] = make_field(cookie) = "";
58 zap['D'] = make_field(detid);
59 zap['P'] = make_field(pmtFile, "PMT parameters file") = "";
60 zap['!'] = make_field(TTS, "map PMT variant to TTS function identifier") = JPARSER::initialised();
61 zap['d'] = make_field(debug) = 2;
62
63 zap(argc, argv);
64 }
65 catch(const exception &error) {
66 FATAL(error.what() << endl);
67 }
68
69
70 JPMTParametersMap parameters;
71
72 if (pmtFile != "" && filesystem::is_regular_file(pmtFile)) {
73 parameters.load(pmtFile.c_str());
74 }
75
76 try {
77
78 JDB::reset(usr, pwd, cookie);
79
80 ResultSet& rs = getResultSet(getTable<JDetectorIntegration>(), getSelector<JDetectorIntegration>(getDetector<int>(detid)));
81
82 for (JDetectorIntegration component; rs >> component; ) {
83
84 if (component.PMTUPI.getPBS() == PBS::PMT) {
85
87
88 if ((p = TTS.find(component.PMTUPI.getVariant())) != TTS.end())
89 ;
90 else if ((p = TTS.find(WILDCARD)) != TTS.end())
91 ;
92 else
93 FATAL("Invalid variant " << component.PMTUPI << ".");
94
95 const JPMTIdentifier id(component.DOMID, component.CABLEPOS);
96
97 parameters[id].TTS_ns = -(p->second);
98 }
99 }
100
101 rs.Close();
102 }
103 catch(const exception& error) {
104 FATAL(error.what() << endl);
105 }
106
107 if (pmtFile != "") {
108
109 parameters.comment.add(JMeta(argc, argv));
110
111 parameters.store(pmtFile.c_str());
112
113 } else {
114
115 cout << parameters << endl;
116 }
117}
General purpose messaging.
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:74
ROOT I/O of application specific meta data.
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2107
I/O formatting auxiliaries.
Auxiliary class for map of PMT parameters.
Utility class to parse command line options.
Definition JParser.hh:1664
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Wrapper class for server name.
Definition JDB.hh:54
Template definition for getting table specific selector.
JComment & add(const std::string &comment)
Add comment.
Definition JComment.hh:100
void store(const char *file_name) const
Store to output file.
void load(const char *file_name)
Load from input file.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition JParser.hh:66
Auxiliary class for ROOT I/O of application specific meta data.
Definition JMeta.hh:72