Jpp  18.2.1-ARCA-DF-PATCH
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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

int main ( int  argc,
char **  argv 
)

Definition at line 80 of file JPrintPMTParameters.cc.

81 {
82  using namespace std;
83  using namespace JPP;
84 
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 }
Utility class to parse command line options.
Definition: JParser.hh:1514
Utility class to parse parameter values.
Definition: JProperties.hh:497
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
Definition: diff-Tuna.sh:38
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:83
JProperties getProperties(const JEquationParameters &equation=JPMTParameters::getEquationParameters())
Get properties of this class.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
Auxiliary class for map of PMT parameters.
print
Definition: JConvertDusj.sh:44
#define FATAL(A)
Definition: JMessage.hh:67
Data structure for PMT parameters.
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
int debug
debug level