Jpp  18.3.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
7 #include "JDB/JDB.hh"
8 #include "JDB/JSelector.hh"
10 #include "JDB/JDBToolkit.hh"
12 
14 
15 #include "JSystem/JStat.hh"
16 
17 #include "JSupport/JMeta.hh"
18 
19 #include "Jeep/JPrint.hh"
20 #include "Jeep/JParser.hh"
21 #include "Jeep/JMessage.hh"
22 
23 
24 /**
25  * \file
26  *
27  * Auxiliary program to set TTS function identifier in PMT parameters file according PMT variant.
28  * \author mdejong
29  */
30 int main(int argc, char **argv)
31 {
32  using namespace std;
33  using namespace JPP;
34 
35  const std::string WILDCARD = "%"; //!< wild card
36 
37  JServer server;
38  string usr;
39  string pwd;
40  string cookie;
41  string detid;
42  map<string, int> TTS;
43  string pmtFile;
44  int debug;
45 
46  TTS["HAMA-R12199"] = 1;
47  TTS["HAMA-R14374"] = 67;
48  TTS["HAMA-R14374-02"] = 67;
49  TTS[WILDCARD] = 1;
50 
51  try {
52 
53  JParser<> zap("Auxiliary program to set TTS function identifier in PMT parameters file according PMT variant.");
54 
55  zap['s'] = make_field(server) = getServernames();
56  zap['u'] = make_field(usr) = "";
57  zap['!'] = make_field(pwd) = "";
58  zap['C'] = make_field(cookie) = "";
59  zap['D'] = make_field(detid);
60  zap['P'] = make_field(pmtFile, "PMT parameters file") = "";
61  zap['!'] = make_field(TTS, "map PMT variant to TTS function identifier") = JPARSER::initialised();
62  zap['d'] = make_field(debug) = 2;
63 
64  zap(argc, argv);
65  }
66  catch(const exception &error) {
67  FATAL(error.what() << endl);
68  }
69 
70 
71  JPMTParametersMap parameters;
72 
73  if (pmtFile != "" && getFileStatus(pmtFile.c_str())) {
74  parameters.load(pmtFile.c_str());
75  }
76 
77  try {
78 
79  JDB::reset(usr, pwd, cookie);
80 
81  ResultSet& rs = getResultSet(getTable<JDetectorIntegration>(), getSelector<JDetectorIntegration>(getDetector<int>(detid)));
82 
83  for (JDetectorIntegration component; rs >> component; ) {
84 
85  if (component.PMTUPI.getPBS() == PBS::PMT) {
86 
88 
89  if ((p = TTS.find(component.PMTUPI.getVariant())) != TTS.end())
90  ;
91  else if ((p = TTS.find(WILDCARD)) != TTS.end())
92  ;
93  else
94  FATAL("Invalid variant " << component.PMTUPI << ".");
95 
96  const JPMTIdentifier id(component.DOMID, component.CABLEPOS);
97 
98  parameters[id].TTS_ns = -(p->second);
99  }
100  }
101 
102  rs.Close();
103  }
104  catch(const exception& error) {
105  FATAL(error.what() << endl);
106  }
107 
108  if (pmtFile != "") {
109 
110  parameters.comment.add(JMeta(argc, argv));
111 
112  parameters.store(pmtFile.c_str());
113 
114  } else {
115 
116  cout << parameters << endl;
117  }
118 }
Utility class to parse command line options.
Definition: JParser.hh:1514
int main(int argc, char *argv[])
Definition: Main.cc:15
static const JPBS_t PMT(3, 4, 2, 3)
PBS of photo-multiplier tube (PMT)
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
Definition: diff-Tuna.sh:38
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:83
static const char WILDCARD
Definition: JDAQTags.hh:50
I/O formatting auxiliaries.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
ROOT I/O of application specific meta data.
then awk string
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
static JStat getFileStatus
Function object for file status.
Definition: JStat.hh:173
void reset(T &value)
Reset value.
Utility class to parse command line options.
ResultSet & getResultSet(const std::string &query)
Get result set.
Definition: JDB.hh:436
std::vector< JServer > getServernames()
Get list of names of available database servers.
Definition: JDB.hh:106
int debug
debug level
File status.