30 static const char WILDCARD_RING =
'*';
31 static const int WILDCARD_POSITION = -1;
32 static const int WILDCARD = -1;
44 return (((first == second)) ||
49 ((first.
ring == WILDCARD_RING || second.
ring == WILDCARD_RING) &&
50 (first.
position == WILDCARD_POSITION || second.
position == WILDCARD_POSITION)));
63 return (((first == second)) ||
68 ((first.
getID() == WILDCARD || second.
getID() == WILDCARD) &&
69 (first.
getTDC() == WILDCARD || second.
getTDC() == WILDCARD)));
76 struct JEmptyAddress {
77 friend inline std::istream&
operator>>(std::istream& in, JEmptyAddress&
object) {
return in; }
78 friend inline std::ostream&
operator<<(std::ostream& out,
const JEmptyAddress&
object) {
return out; }
85 template<
class JAddress_t = JEmptyAddress>
107 if (this->action ==
"set") {
111 }
else if (this->action ==
"add") {
115 }
else if (this->action ==
"sub") {
119 }
else if (this->action ==
"mul") {
123 }
else if (this->action ==
"div") {
132 catch(
const std::exception& error) {
133 cerr << error.what() << endl;
148 friend inline std::istream&
operator>>(std::istream& in, JModifier& modifier)
150 return in >> modifier.address
164 friend inline std::ostream&
operator<<(std::ostream& out,
const JModifier& modifier)
166 return out << modifier.address <<
' '
167 << modifier.action <<
' '
168 << modifier.key <<
' '
232 JParser<> zap(
"Auxiliary program to edit PMT parameters map.");
234 zap[
'a'] =
make_field(detectorFile,
"detector file.") =
"";
235 zap[
'D'] =
make_field(detectorID,
"detector identifier (in absence of detector file).") = 0;
240 zap[
'E'] =
make_field(mu,
"expectation value for npe given two-fold coincidence (" << mu .getOption() <<
" -> " << mu .getCustom() <<
")") = 0.0;
241 zap[
'T'] =
make_field(T_ns,
"time-over-threshold rang (" << T_ns.getOption() <<
" -> " << T_ns.getCustom() <<
")") =
JRange_t();
244 zap[
'q'] =
make_field(squash,
"squash meta data");
249 catch(
const exception &error) {
250 FATAL(error.what() << endl);
258 for (
vector< JModifier<> >::const_iterator i = hdr.begin(); i != hdr.end(); ++i) {
260 DEBUG(
"Modifying default PMT parameters " << i->action <<
' ' << i->key <<
' ' << i->value << endl);
263 ERROR(
"No valid action: " << *i << endl);
267 if (detectorFile !=
"") {
280 if (detectorID == 0) {
284 }
else if (detectorID !=
detector.getID()) {
286 FATAL(
"Inconsistent detector identifier " << detectorID <<
" != " <<
detector.getID() << endl);
290 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
292 for (
unsigned int pmt = 0; pmt !=
module->size(); ++pmt) {
296 if (parameters.find(
id) == parameters.end()) {
298 DEBUG(
"Setting default parameters for PMT " <<
id << endl);
307 for (JPMTParametersMap::iterator ps = parameters.begin(); ps != parameters.end(); ) {
312 ps = parameters.erase(ps);
319 FATAL(
"Invalid detector identifier " << detectorID << endl);
324 for (JPMTParametersMap::iterator ps = parameters.begin(); ps != parameters.end(); ++ps) {
328 for (
vector< JModifier<JPMTPhysicalAddress> >::const_iterator i = mod.begin(); i != mod.end(); ++i) {
330 if (compare(i->address, address)) {
332 DEBUG(
"Modifying parameters for PMT " << ps->first <<
' ' << i->action <<
' ' << i->key <<
' ' << i->value << endl);
334 if (!i->apply(ps->second)) {
335 ERROR(
"No valid action: " << *i << endl);
344 for (JPMTParametersMap::iterator ps = parameters.begin(); ps != parameters.end(); ++ps) {
346 for (
vector< JModifier<JPMTIdentifier> >::const_iterator i = daq.begin(); i != daq.end(); ++i) {
348 if (compare(ps->first, i->address)) {
350 DEBUG(
"Modifying parameters for PMT " << ps->first <<
' ' << i->action <<
' ' << i->key <<
' ' << i->value << endl);
352 if (!i->apply(ps->second)) {
353 ERROR(
"No valid action: " << *i << endl);
360 if (mu != parameters.
getMu()) {
366 DEBUG(
"Correct measured QE for two-hit probability " << mu << endl);
375 }
else if (mu < 0.0) {
377 FATAL(
"Invalid expection value for two-hit probability " << mu << endl);
380 DEBUG(
"mu is unchanged" << endl);
386 DEBUG(
"Correct measured QE for time-over-threshold range " << T_ns << endl);
390 for (JPMTParametersMap::iterator i = parameters.begin(); i != parameters.end(); ++i) {
395 cpu.
getNPE(T_ns.getUpperLimit()),
399 cpu.
getNPE(T_ns.getUpperLimit()),
407 for (JPMTParametersMap::iterator i = parameters.begin(); i != parameters.end(); ++i) {
408 i->second.QE = QE.
constrain(i->second.QE);
419 out << parameters << endl;
Data structure for detector geometry and calibration.
General purpose messaging.
#define DEBUG(A)
Message macros.
Direct access to module in detector data structure.
PMT analogue signal processor.
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Auxiliary class to define a range between two values.
Lookup table for PMT addresses in detector.
const JModuleAddressMap & get(const int id) const
Get module address map.
Router for direct addressing of module data in detector data structure.
bool hasModule(const JModuleIdentifier &id) const
Has module.
Auxiliary class for map of PMT parameters.
double getMu() const
Get expectation value for number of photo-electrons given two-fold (or higher) coincidence rate.
void convertHitProbabilityToQE(const double mu)
Convert the hit probabilities to QEs for given expectation value.
void convertQEToHitProbability()
Convert the QEs to hit probabilities for given expectation value.
const JPMTParameters & getDefaultPMTParameters() const
Get default PMT parameters.
Data structure for PMT parameters.
JProperties getProperties(const JEquationParameters &equation=JPMTParameters::getEquationParameters())
Get properties of this class.
Data structure for PMT physical address.
char ring
ring number ['A','F']
int position
position within ring [1,6]
int getTDC() const
Get TDC.
const T & getValue(const std::string &key) const
Get value.
virtual const char * what() const override
Get error message.
int getID() const
Get identifier.
Utility class to parse command line options.
Auxiliary class to assign a custom value following the reading of a specific textual value.
std::ostream & operator<<(std::ostream &out, const morphology_type &object)
Write morphology to output stream.
std::istream & operator>>(std::istream &in, morphology_type &object)
Read morphology from input stream.
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.
virtual double getNPE(const double tot_ns) const override
Get number of photo-electrons.
double getIntegralOfChargeProbability(const double xmin, const double xmax, const int NPE) const
Get integral of probability.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...