127{
130
131 string inputFile;
132 string detectorFile;
134 string UPIFile;
135
137 string testType;
138 string login;
139 string locationID;
141 int elapsedTime = 0;
142
143 double HVstepMin = 2 * 3.14;
145 -80 - 1e-2);
149
151
152
153 try {
154
156
163
165
170
171 JParser<> zap(
"Example program to find optimal HV-settings.");
172
173 zap[
'f'] =
make_field(inputFile,
"input file (ROOT format)");
175 zap[
'a'] =
make_field(detectorFile,
"detector file");
176 zap[
'b'] =
make_field(UPIFile,
"PMT UPI ASCII table");
180
181 zap(argc, argv);
182 }
183 catch(const exception &error) {
184 FATAL(error.what() << endl);
185 }
186
187 if (login.empty() || locationID.empty()) {
188
189 FATAL(
"Missing user information (please specify via -#login and -#locationID).");
190
191 } else if (testType.empty()) {
192
193 FATAL(
"Missing database test type (please specify via -#testType).");
194
196
197 FATAL(
"Missing run numbers.");
198 }
199
200
202
204
206
207 timer.
sub(elapsedTime);
208
210
211 try {
213 }
214 catch (const exception& error) {
215 FATAL(error.what() << endl);
216 }
217
219
220 JUPITable fetchUPI(UPIFile.c_str());
221
222
223
224
225 TFile input(inputFile.c_str(), "READ");
226
228
229 input >> manager;
230
231 input.Close();
232
233
234
235
236
238
242
243 NOTICE(
"Searching optimal high-voltage settings..." << endl <<
244 LEFT(30) <<
"UPI" <<
CENTER(35) <<
"(identifer / location)" <<
RIGHT(35) <<
"Inter-/Extrapolated high-voltage [-]" << endl);
245
247
248 const string& name = it->first;
250
251
252
253 const int seppos = name.find('.');
254 const int moduleID = stoi(name.substr(0, seppos));
255 const int tdc = stoi(name.substr(seppos + 1, seppos + 3));
256
257 const JModule& module = router.getModule(moduleID);
259
263 right <<
FILL(2,
'0') << tdc);
264
265 NOTICE(
LEFT(30) << pmtUPI <<
"(a.k.a. " << name <<
" / " << location <<
"): ");
266
267 if (
data.interpolateHV(gainTarget)) {
268
270 const double error =
data.getHVError();
271
273
275
276 } else {
277
278 WARNING(
"Could not find high-voltage corresponding to target gain; Setting zero." << endl);
279
281 }
282 }
283
284
285
287 string metaInfoStr;
288
289 metaInfo.push_back(
JMeta(argc, argv));
291
293
294 metaInfo.push_back(*in.next());
296 }
297
298 TFile output(inputFile.c_str(), "RECREATE");
299
302 }
303
304 output << manager;
305
306 output.Close();
307
308
309
311
313
317
320
328
336
338
345
346 } else {
347
348 FATAL(
"Invalid API version <" << APIversion <<
"> accepted major versions 1 and 2." << endl);
349 }
350
352
353 ofs << setw(2) << setprecision(8);
354 ofs << js;
355
356 ofs.close();
357}
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
#define MAKE_STRING(A)
Make string.
#define gmake_property(A)
macros to convert (template) parameter to JPropertiesElement object
const JLocation & getLocation() const
Get location.
int getFloor() const
Get floor number.
int getString() const
Get string number.
Router for direct addressing of module data in detector data structure.
Data structure for a composite optical module.
Data structure for PMT geometry, calibration and status.
Utility class to parse parameter values.
int getID() const
Get identifier.
Utility class to parse command line options.
Auxiliary class to manage set of compatible ROOT objects (e.g. histograms) using unique keys.
Object reading from a list of files.
virtual bool hasNext() override
Check availability of next element.
static const double FITTOT_GAIN_MAX
Default maximal gain.
static const double FITTOT_GAIN_MIN
Default minimal gain.
static const JPBS_t PMT(3, 4, 2, 3)
PBS of photo-multiplier tube (PMT)
static JDBTestTypesTuneHV & getDBVersionTuneHV
Function object for looking up the HV-tuning database version number corresponding to a specific test...
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
const double NOMINAL_GAIN
Specification for normalized gain corresponding to a one photo-electron pulse.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
bool putObject(TDirectory &dir, const TObject &object)
Write object to ROOT directory.
static const std::string Tests_t
static const std::string APIVersion_t
static const std::string User_t
static const std::string Encoding_t
static const std::string Message_t
static const std::string UUID_t
static const std::string Code_t
static const std::string Location_t
static const std::string Time_t
static const std::string Data_t
static const std::string Test_t
static const std::string OK_t
static const std::string Arguments_t
static const std::string Configuration_t
static const std::string End_t
static const std::string Fail_t
static const std::string Provenance_t
static const std::string Info_t
static const std::string Error_t
static const std::string Type_t
static const std::string Start_t
Auxiliary data structure for alignment of data.
Auxiliary data structure for sequence of same character.
Auxiliary data structure for floating point format specification.
Auxiliary data structure to store high-voltage versus gain data and interpolate the nominal high-volt...
static void setHVRange(const JRange< double > range)
Set valid gain range.
static void setMinHVDistance(const double minDist)
Set minimal separation distance for high-voltage.
static void setGainRange(const JRange< double > range)
Set valid gain range.
Universal product identifier (UPI).
Data structure for PMT high-voltage calibration.
static void setVersion(const int version)
Set HV-tuning database test type.
Auxiliary data structure for general purpose version number.
version_type getMajorVersion() const
Get major version.
static const JUUID & rndm()
Generate random UUID.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Auxiliary class for date and time.
std::string toString() const
Get ASCII formatted date and time.
void sub(const time_t t1)
Subtract given time.