32 template<
class JAddress_t>
54 if (this->action ==
"set") {
58 }
else if (this->action ==
"add") {
62 }
else if (this->action ==
"sub") {
66 }
else if (this->action ==
"mul") {
70 }
else if (this->action ==
"div") {
79 catch(
const std::exception& error) {
80 cerr << error.what() << endl;
95 friend inline std::istream&
operator>>(std::istream& in, JModifier& modifier)
97 return in >> modifier.address
111 friend inline std::ostream&
operator<<(std::ostream& out,
const JModifier& modifier)
113 return out << modifier.address <<
' '
114 << modifier.action <<
' '
115 << modifier.key <<
' '
146 int main(
int argc,
char **argv)
151 typedef JModifier<JPMTPhysicalAddress> JModifier_t;
164 JParser<> zap(
"Auxiliary program to edit PMT parameters map.");
166 zap[
'a'] =
make_field(detectorFile,
"detector file.") =
"";
167 zap[
'D'] =
make_field(detectorID,
"detector identifier (in absence of detector file).") = 0;
170 zap[
'T'] =
make_field(T_ns,
"time-over-threshold range.") = JRange_t();
176 catch(
const exception &error) {
177 FATAL(error.what() << endl);
181 if (detectorFile !=
"") {
188 load(detectorFile, detector);
194 if (detectorID == 0) {
196 detectorID = detector.
getID();
198 }
else if (detectorID != detector.
getID()) {
200 FATAL(
"Inconsistent detector identifier " << detectorID <<
" != " << detector.
getID() << endl);
204 for (JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) {
206 for (
unsigned int pmt = 0; pmt != module->size(); ++pmt) {
210 if (parameters.find(
id) == parameters.end()) {
212 NOTICE(
"Setting default parameters for PMT " <<
id << endl);
214 parameters[id] = parameters.getDefaultPMTParameters();
220 if (!modifier.empty()) {
223 FATAL(
"Invalid detector identifier " << detectorID << endl);
228 for (JPMTParametersMap::iterator ps = parameters.begin(); ps != parameters.end(); ++ps) {
234 if (address == i->address) {
236 NOTICE(
"Modifying parameters for PMT " << ps->first << endl);
238 if (!i->apply(ps->second)) {
239 ERROR(
"No valid action: " << *i << endl);
247 if (T_ns != JRange_t()) {
251 for (JPMTParametersMap::iterator i = parameters.begin(); i != parameters.end(); ++i) {
256 cpu.
getNPE(T_ns.getUpperLimit(), NPE),
260 cpu.
getNPE(T_ns.getUpperLimit(), NPE),
268 parameters.comment.add(
JMeta(argc, argv));
272 out << parameters << endl;
Utility class to parse command line options.
std::istream & operator>>(std::istream &in, JHead &header)
Read header from input.
bool hasDetectorAddressMap(const int id)
Check if detector address map is available.
double getNPE(const double tot_ns, const double eps=1.0e-3) const
Get number of photo-electrons.
Lookup table for PMT addresses in detector.
Empty structure for specification of parser element that is initialised (i.e.
JProperties getProperties(const JEquationParameters &equation=JPMTParameters::getEquationParameters())
Get properties of this class.
Data structure for detector geometry and calibration.
const JModuleAddressMap & get(const int id) const
Get module address map.
const T & getValue(const std::string &key) const
Get value.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
int getID() const
Get identifier.
Auxiliary class for map of PMT parameters.
void load(const JString &file_name, JDetector &detector)
Load detector from input file.
JDetectorAddressMap & getDetectorAddressMap()
Get detector address map.
General purpose messaging.
PMT analogue signal processor.
Auxiliary class to define a range between two values.
Utility class to parse command line options.
PMT analogue signal processor.
Data structure for PMT physical address.
Data structure for PMT parameters.
double getIntegralOfProbability(const double xmin, const double xmax, const int NPE) const
Get integral of probability.
int main(int argc, char *argv[])