47 JParser<> zap(
"Auxiliary program to set PMT thresholds according DAQ configuration.");
54 zap[
'P'] =
make_field(pmtFile,
"PMT parameters file") =
"";
55 zap[
'F'] =
make_field(formula,
"transfer function") =
"((x * 1.0)/255.0 * 1.6 + 0.8 - 0.989) / 0.44";
60 catch(
const exception& error) {
61 FATAL(error.what() << endl);
72 TF1 f1(
"user", formula.c_str());
75 FATAL(
"Formula <" << formula <<
"> invalid." << endl);
82 catch(
const exception& error) {
83 FATAL(error.what() << endl);
95 if (rs >> parameters) {
96 rs_oid = parameters.RUNSETUPID;
101 DEBUG(
"Run setup " << rs_oid << endl);
103 catch(
const exception& error) {
104 FATAL(error.what() << endl);
114 ResultSet& rs =
getResultSet(getTable<JAllParams>(), getSelector<JAllParams>(
"OPTICS"));
116 while (rs >> parameters) {
117 if (parameters.NAME.find(
"PMT_THRESHOLD") != string::npos) {
124 catch(
const exception& error) {
125 FATAL(error.what() << endl);
137 while (rs >> parameters) {
139 if (parameters.PAR_OID == upars.OID && parameters.ISINPUT ==
'Y') {
140 if (parameters.VALUE !=
"") {
141 umap[parameters.UPIFILTER] = to_value<int>(parameters.VALUE);
148 catch(
const exception& error) {
149 FATAL(error.what() << endl);
153 DEBUG(left << setw(20) << i->first <<
' ' << right << setw(3) << i->second << endl);
163 ResultSet& rs =
getResultSet(getTable<JDetectorIntegration>(), getSelector<JDetectorIntegration>(
is_integer(detid) ? to_value<int>(detid) :
getDetector(detid)));
165 while (rs >> parameters) {
171 catch(
const exception& error) {
172 FATAL(error.what() << endl);
179 if (i->PMTID != -1) {
181 const JUPI_t upi = i->PMTUPI;
185 bool is_default = (p == umap.end());
187 if (p == umap.end()) {
191 os << upi.getPBS() << JUPI_t::SEPARATOR
192 << upi.getVariant() << JUPI_t::SEPARATOR
195 p = umap.find(os.str());
198 if (p != umap.end()) {
200 const double threshold = f1.Eval((
double) p->second);
204 cout << setw(4) << i->DUID <<
' '
205 << setw(2) << i->FLOORID <<
' '
206 << setw(2) << i->CABLEPOS <<
' '
207 << setw(3) << p->second <<
' '
208 <<
FIXED(5,2) << threshold <<
' ';
211 cout <<
"* (" <<
FIXED(5,2) << JPMTParameters().threshold <<
")";
219 const JPMTIdentifier id(i->DOMID, i->CABLEPOS);
221 parameters[id].threshold = threshold;
226 ERROR(
"Missing threshold data PMT " << upi << endl);
233 parameters.comment.add(JMeta(argc, argv));
235 parameters.store(pmtFile.c_str());
239 cout << parameters << endl;
Utility class to parse command line options.
*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
Auxiliary data structure for floating point format specification.
JDetectorsHelper getDetector
Function object for mapping serial number to object identifier of detector and vice versa...
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
bool is_integer(const std::string &buffer)
Check if string is an integer.
ResultSet & getResultSet(const std::string &query)
Get result set.
do set_variable DETECTOR_TXT $WORKDIR detector
#define DEBUG(A)
Message macros.