Jpp  master_rocky-43-ge265d140c
the software that should make you happy
Functions
JPrintPMTParameters.cc File Reference

Auxiliary program to print PMT parameters. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <vector>
#include "JLang/JVectorize.hh"
#include "JDetector/JPMTParameters.hh"
#include "JDetector/JPMTParametersMap.hh"
#include "JDetector/JPMTIdentifier.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Auxiliary program to print PMT parameters.

NOTE: PMT identifiers need to be specified as <module>.<channel> or as "%" in case the default PMT parameters need to be printed.

Author
mdejong, bjung

Definition in file JPrintPMTParameters.cc.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 80 of file JPrintPMTParameters.cc.

81 {
82  using namespace std;
83  using namespace JPP;
84 
85  JPMTParametersMap parameters;
86  vector<string> pmts;
87  vector<string> keys;
88  int debug;
89 
90  try {
91 
92  const JPMTParameters& buffer = parameters.getDefaultPMTParameters();
93  const JProperties properties = buffer.getProperties();
94 
95  JParser<> zap("Auxiliary program to print PMT parameters.");
96 
97  zap['P'] = make_field(parameters, "PMT simulation data (or corresponding file name)") = JPMTParametersMap();
98  zap['p'] = make_field(pmts, "PMT identifier, e.g. <module identifier>.<PMT> or \"%\"") = JPARSER::initialised();
99  zap['k'] = make_field(keys, "parameters:" << endl << get_keys(properties)) = JPARSER::initialised();
100  zap['d'] = make_field(debug) = 3;
101 
102  zap(argc, argv);
103  }
104  catch(const exception &error) {
105  FATAL(error.what() << endl);
106  }
107 
108 
109  for (vector<string>::const_iterator i = pmts.cbegin(); i != pmts.cend(); ++i) {
110 
111  if ((*i) != DEFAULT_ID) { // Print PMT-specific parameters
112 
113  const size_t pos = i->find(SEPARATOR);
114 
115  if (pos == string::npos) {
116  FATAL("Invalid PMT specifier " << *i << endl);
117  }
118 
119  const JPMTIdentifier id(stoi(i->substr(0, pos)), stoi(i->substr(pos + 1)));
120 
121  for (JPMTParametersMap::const_iterator ps = parameters.cbegin(); ps != parameters.cend(); ++ps) {
122  if (compare(ps->first, id)) {
123  print(cout, *i, ps->second, keys.cbegin(), keys.cend());
124  }
125  }
126 
127  } else { // Print default PMT parameters
128 
129  print(cout, *i, parameters.getDefaultPMTParameters(), keys.cbegin(), keys.cend());
130  }
131  }
132 
133  return 0;
134 }
#define FATAL(A)
Definition: JMessage.hh:67
int debug
debug level
Definition: JSirene.cc:69
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2142
Auxiliary class for map of PMT parameters.
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.
Utility class to parse parameter values.
Definition: JProperties.hh:501
Utility class to parse command line options.
Definition: JParser.hh:1698
std::ostream & print(std::ostream &out, const JTestSummary &summary, const char delimiter=' ', const bool useColors=true)
Print test summary.
const array_type< JKey_t > & get_keys(const std::map< JKey_t, JValue_t, JComparator_t, JAllocator_t > &data)
Method to create array of keys of map.
Definition: JVectorize.hh:139
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JSTDTypes.hh:14
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:68