210{
213
215
216 string detectorFile;
217 int detectorID;
226 bool squash;
228
229 try {
230
231 JParser<> zap(
"Auxiliary program to edit PMT parameters map.");
232
233 zap[
'a'] =
make_field(detectorFile,
"detector file.") =
"";
234 zap[
'D'] =
make_field(detectorID,
"detector identifier (in absence of detector file).") = 0;
239 zap[
'E'] =
make_field(mu,
"expectation value for npe given two-fold coincidence (" << mu .getOption() <<
" -> " << mu .getCustom() <<
")") = 0.0;
240 zap[
'T'] =
make_field(T_ns,
"time-over-threshold rang (" << T_ns.getOption() <<
" -> " << T_ns.getCustom() <<
")") =
JRange_t();
243 zap[
'q'] =
make_field(squash,
"squash meta data");
245
246 zap(argc, argv);
247 }
248 catch(const exception &error) {
249 FATAL(error.what() << endl);
250 }
251
252
253 if (squash) {
255 }
256
258
259
260 for (
vector< JModifier<> >::const_iterator i = hdr.begin(); i != hdr.end(); ++i) {
261
262 DEBUG(
"Modifying default PMT parameters " << i->action <<
' ' << i->key <<
' ' << i->value << endl);
263
265 ERROR(
"No valid action: " << *i << endl);
266 }
267 }
268
269 if (detectorFile != "") {
270
271
272
274
275 try {
277 }
280 }
281
282 if (detectorID == 0) {
283
285
286 }
else if (detectorID !=
detector.getID()) {
287
288 FATAL(
"Inconsistent detector identifier " << detectorID <<
" != " <<
detector.getID() << endl);
289 }
290
291
292 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
293
294 for (unsigned int pmt = 0; pmt != module->size(); ++pmt) {
295
297
298 if (parameters.find(id) == parameters.end()) {
299
300 DEBUG(
"Setting default parameters for PMT " <<
id << endl);
301
303 }
304 }
305 }
306 }
307
308 if (!mod.empty()) {
309
311 FATAL(
"Invalid detector identifier " << detectorID << endl);
312 }
313
315
316 for (JPMTParametersMap::iterator ps = parameters.begin(); ps != parameters.end(); ++ps) {
317
319
320 for (
vector< JModifier<JPMTPhysicalAddress> >::const_iterator i = mod.begin(); i != mod.end(); ++i) {
321
322 if (compare(i->address, address)) {
323
324 DEBUG(
"Modifying parameters for PMT " << ps->first <<
' ' << i->action <<
' ' << i->key <<
' ' << i->value << endl);
325
326 if (!i->apply(ps->second)) {
327 ERROR(
"No valid action: " << *i << endl);
328 }
329 }
330 }
331 }
332 }
333
334 if (!daq.empty()) {
335
336 for (JPMTParametersMap::iterator ps = parameters.begin(); ps != parameters.end(); ++ps) {
337
338 for (
vector< JModifier<JPMTIdentifier> >::const_iterator i = daq.begin(); i != daq.end(); ++i) {
339
340 if (compare(ps->first, i->address)) {
341
342 DEBUG(
"Modifying parameters for PMT " << ps->first <<
' ' << i->action <<
' ' << i->key <<
' ' << i->value << endl);
343
344 if (!i->apply(ps->second)) {
345 ERROR(
"No valid action: " << *i << endl);
346 }
347 }
348 }
349 }
350 }
351
352
353 if (mu > 0.0) {
354
355 DEBUG(
"Correct measured QE for two-hit probability " << mu << endl);
356
357 try {
359 }
362 }
363
364 } else if (mu < 0.0) {
365
366 FATAL(
"Invalid expection value for two-hit probability " << mu << endl);
367 }
368
369
371
372 DEBUG(
"Correct measured QE for time-over-threshold range " << T_ns << endl);
373
374 const int NPE = 1;
375
376 for (JPMTParametersMap::iterator i = parameters.begin(); i != parameters.end(); ++i) {
377
379
380 i->second.QE *= (cpu.getIntegralOfChargeProbability(i->second.threshold,
381 cpu.getNPE(T_ns.getUpperLimit()),
382 NPE)
383 /
384 cpu.getIntegralOfChargeProbability(cpu.getNPE(T_ns.getLowerLimit()),
385 cpu.getNPE(T_ns.getUpperLimit()),
386 NPE));
387 }
388 }
389
390
392
393 for (JPMTParametersMap::iterator i = parameters.begin(); i != parameters.end(); ++i) {
394 i->second.QE = QE.
constrain(i->second.QE);
395 }
396 }
397
398
400
402
404
405 out << parameters << endl;
406
407 out.close();
408 }
409}
#define DEBUG(A)
Message macros.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Lookup table for PMT addresses in detector.
const JModuleAddressMap & get(const int id) const
Get module address map.
Auxiliary class for map of PMT parameters.
void convertHitProbabilityToQE(const double mu)
Convert the hit probabilities to QEs for given expectation value.
const JPMTParameters & getDefaultPMTParameters() const
Get default PMT parameters.
Data structure for PMT physical address.
virtual const char * what() const override
Get error message.
Utility class to parse command line options.
Auxiliary class to assign a custom value following the reading of a specific textual value.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
JDetectorAddressMap & getDetectorAddressMap()
Get detector address map.
bool hasDetectorAddressMap(const int id)
Check if detector address map is available.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Type definition of range.
PMT analogue signal processor.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...