Jpp  17.3.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Attributes | Static Protected Attributes | Friends | List of all members
JDETECTOR::JPMTParametersMap Class Reference

Auxiliary class for map of PMT parameters. More...

#include <JPMTParametersMap.hh>

Inheritance diagram for JDETECTOR::JPMTParametersMap:
std::map< JKey_t, JValue_t, JComparator_t, JAllocator_t > JLANG::JObjectStreamIO< T > JLANG::JThrow< T >

Classes

class  JPMTParametersMapHelper
 Auxiliary class for I/O of PMT parameters map. More...
 

Public Member Functions

 JPMTParametersMap (const JPMTParameters &parameters=JPMTParameters())
 Constructor. More...
 
 JPMTParametersMap (const char *const file_name)
 Constructor. More...
 
const JPMTParametersgetPMTParameters (const JPMTIdentifier &id) const
 Get PMT parameters. More...
 
double getQE (const JPMTIdentifier &id) const
 Get QE of given PMT. More...
 
double getHitProbability (const JPMTIdentifier &id) const
 Get ratio of hit probabilities of given PMT. More...
 
const JPMTParametersgetDefaultPMTParameters () const
 Get default PMT parameters. More...
 
JPMTParametersgetDefaultPMTParameters ()
 Get default PMT parameters. More...
 
void setDefaultPMTParameters (const JPMTParameters &parameters)
 Set default PMT parameters. More...
 
double getQE () const
 Get global QE. More...
 
void setQE (const double QE)
 Set global QE. More...
 
double getMu () const
 Get expectation value for number of photo-electrons given two-fold (or higher) coincidence rate. More...
 
bool is_valid () const
 Check validity of PMT parameters. More...
 
void convertHitProbabilityToQE (const double mu)
 Convert the hit probabilities to QEs for given expectation value. More...
 
JPMTParametersoperator[] (const JPMTIdentifier &id)
 Access parameters corresponding to given PMT identifier. More...
 
void load (const char *file_name)
 Load from input file. More...
 
void store (const char *file_name) const
 Store to output file. More...
 

Static Public Member Functions

static JEquationParametersgetEquationParameters ()
 Get equation parameters. More...
 
static void setEquationParameters (const JEquationParameters &equation)
 Set equation parameters. More...
 
static void Throw (const bool option)
 Enable/disable throw option. More...
 
static int Throw (const JException &error, const int value=-1)
 Throw exception or return error. More...
 

Public Attributes

JComment comment
 

Protected Attributes

JPMTParameters defaultPMTParameters
 Default PMT parameters. More...
 
double QE
 Global QE. More...
 
double mu
 Expectation value for number of photo-electrons given two-fold (or higher) coincidence rate. More...
 

Static Protected Attributes

static bool do_throw = true
 throw option More...
 

Friends

std::istream & operator>> (std::istream &in, JPMTParametersMap &object)
 Stream input. More...
 
std::ostream & operator<< (std::ostream &out, const JPMTParametersMap &object)
 Stream output. More...
 

Detailed Description

Auxiliary class for map of PMT parameters.

Input syntax as follows:

           QE=<value>
           mu=<value>
           %.<key>=<value>
           PMT=<module> <pmt> <PMT parameters>
           pmt=<module> <pmt> <key>=<value>[, <key>=<value>]
           file=<file name>

where

The global QE is applied as a multiplicative factor to the default and PMT specific QEs. It is set (read overwritten) in the JTriggerEfficiency[RunByRun].sh scripts.

The default values are provided by the method getDefaultPMTParameters and can also be modified using method setDefaultPMTParameters. If no optional values are given, the default values are maintained.

Finally, <PMT parameters> corresponds to the list of PMT parameter values that should be compatible with the I/O methods of the JDETECTOR::JPMTParameters data structure.

Note that multiple input sequences should be seperated by a semicolumn ';' or be terminated by a newline. When multiple input sequences appear for the same target, the last sequence prevails.

Definition at line 89 of file JPMTParametersMap.hh.

Constructor & Destructor Documentation

JDETECTOR::JPMTParametersMap::JPMTParametersMap ( const JPMTParameters parameters = JPMTParameters())
inline

Constructor.

Parameters
parametersPMT parameters

Definition at line 100 of file JPMTParametersMap.hh.

100  :
102  QE(1.0),
103  mu(0.0)
104  {
105  setDefaultPMTParameters(parameters);
106  }
double mu
Expectation value for number of photo-electrons given two-fold (or higher) coincidence rate...
std::map< JPMTIdentifier, JPMTParameters > JPMTParametersMap_t
Type definition of map PMT identifier to PMT parameters.
void setDefaultPMTParameters(const JPMTParameters &parameters)
Set default PMT parameters.
JDETECTOR::JPMTParametersMap::JPMTParametersMap ( const char *const  file_name)
inline

Constructor.

Parameters
file_namefile name

Definition at line 114 of file JPMTParametersMap.hh.

114  :
116  QE(1.0),
117  mu(0.0)
118  {
119  using namespace std;
120 
121  ifstream in(file_name);
122 
123  in >> *this;
124 
125  in.close();
126  }
double mu
Expectation value for number of photo-electrons given two-fold (or higher) coincidence rate...
std::map< JPMTIdentifier, JPMTParameters > JPMTParametersMap_t
Type definition of map PMT identifier to PMT parameters.
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:46

Member Function Documentation

const JPMTParameters& JDETECTOR::JPMTParametersMap::getPMTParameters ( const JPMTIdentifier id) const
inline

Get PMT parameters.


This method returns the default PMT parameters if the parameters corresponding to the given PMT identifier have not been defined.

Note that the value of QE as part of the return value has been scaled with the global QE of the PMT parameters map.

Parameters
idPMT identifier
Returns
PMT parameters

Definition at line 140 of file JPMTParametersMap.hh.

141  {
142  static JPMTParameters parameters;
143 
144  JPMTParametersMap_t::const_iterator i = find(id);
145 
146  if (i != end()) {
147  parameters = i->second;
148  } else {
149  parameters = getDefaultPMTParameters();
150  }
151 
152  parameters.QE *= this->QE;
153 
154  return parameters;
155  }
*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
const JPMTParameters & getDefaultPMTParameters() const
Get default PMT parameters.
Data structure for PMT parameters.
double QE
relative quantum efficiency
double JDETECTOR::JPMTParametersMap::getQE ( const JPMTIdentifier id) const
inline

Get QE of given PMT.

Parameters
idPMT identifier
Returns
QE

Definition at line 164 of file JPMTParametersMap.hh.

165  {
166  return getPMTParameters(id).QE;
167  }
const JPMTParameters & getPMTParameters(const JPMTIdentifier &id) const
Get PMT parameters.
double QE
relative quantum efficiency
double JDETECTOR::JPMTParametersMap::getHitProbability ( const JPMTIdentifier id) const
inline

Get ratio of hit probabilities of given PMT.

Parameters
idPMT identifier
Returns
ratio

Definition at line 176 of file JPMTParametersMap.hh.

177  {
179 
180  return getHitProbability(getQE(id), this->mu);
181  }
double mu
Expectation value for number of photo-electrons given two-fold (or higher) coincidence rate...
double getQE() const
Get global QE.
double getHitProbability(const double QE, const double mu)
Get ratio of hit probabilities for given QE and expectation value of the number of photo-electrons...
double getHitProbability(const JPMTIdentifier &id) const
Get ratio of hit probabilities of given PMT.
const JPMTParameters& JDETECTOR::JPMTParametersMap::getDefaultPMTParameters ( ) const
inline

Get default PMT parameters.

Returns
PMT parameters

Definition at line 189 of file JPMTParametersMap.hh.

190  {
191  return defaultPMTParameters;
192  }
JPMTParameters defaultPMTParameters
Default PMT parameters.
JPMTParameters& JDETECTOR::JPMTParametersMap::getDefaultPMTParameters ( )
inline

Get default PMT parameters.

Returns
PMT parameters

Definition at line 200 of file JPMTParametersMap.hh.

201  {
202  return defaultPMTParameters;
203  }
JPMTParameters defaultPMTParameters
Default PMT parameters.
void JDETECTOR::JPMTParametersMap::setDefaultPMTParameters ( const JPMTParameters parameters)
inline

Set default PMT parameters.

Parameters
parametersPMT parameters

Definition at line 211 of file JPMTParametersMap.hh.

212  {
214  }
*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
JPMTParameters defaultPMTParameters
Default PMT parameters.
double JDETECTOR::JPMTParametersMap::getQE ( ) const
inline

Get global QE.

Returns
QE

Definition at line 222 of file JPMTParametersMap.hh.

223  {
224  return this->QE;
225  }
void JDETECTOR::JPMTParametersMap::setQE ( const double  QE)
inline

Set global QE.

Parameters
QEQE

Definition at line 233 of file JPMTParametersMap.hh.

234  {
235  this->QE = QE;
236  }
double JDETECTOR::JPMTParametersMap::getMu ( ) const
inline

Get expectation value for number of photo-electrons given two-fold (or higher) coincidence rate.

Returns
expectation value

Definition at line 244 of file JPMTParametersMap.hh.

245  {
246  return this->mu;
247  }
double mu
Expectation value for number of photo-electrons given two-fold (or higher) coincidence rate...
bool JDETECTOR::JPMTParametersMap::is_valid ( ) const
inline

Check validity of PMT parameters.

Returns
true if valid; else false

Definition at line 255 of file JPMTParametersMap.hh.

256  {
257  try {
258 
259  if (this->QE < 0) {
260  THROW(JException, "Invalid global QE " << QE);
261  }
262 
263  if (this->mu < 0) {
264  THROW(JException, "Invalid expectation value number of photo-electrons " << mu);
265  }
266 
268  THROW(JException, "Invalid default PMT parameters");
269  }
270 
271  for (const_iterator i = this->begin(); i != this->end(); ++i) {
272 
273  if (!i->second.is_valid()) {
274  THROW(JException, "Invalid PMT parameters at " << i->first);
275  }
276 
277  if (i->second.QE * this->QE > 1.0 ||
278  i->second.QE * this->QE < 0.0) {
279  THROW(JException, "Invalid PMT QE at " << i->first << ' ' << i->second.QE * this->QE);
280  }
281  }
282 
283  return true;
284  }
285  catch(const JException& error) {
286 
287  Throw(error);
288 
289  return false;
290  }
291  }
General exception.
Definition: JException.hh:23
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:696
then usage $script< detector file >< detectorfile > nIf the range of floors is the first detector file is aligned to the second before the comparison nIn this
double mu
Expectation value for number of photo-electrons given two-fold (or higher) coincidence rate...
JPMTParameters defaultPMTParameters
Default PMT parameters.
bool is_valid() const
Check validity of PMT parameters.
static void Throw(const bool option)
Enable/disable throw option.
Definition: JThrow.hh:37
void JDETECTOR::JPMTParametersMap::convertHitProbabilityToQE ( const double  mu)
inline

Convert the hit probabilities to QEs for given expectation value.

The expectation value corresponds to the number of photo-electrons given the multiplicity range of coincidences as specified at JCalibrateK40.cc.

Parameters
muexpectation value

Definition at line 302 of file JPMTParametersMap.hh.

303  {
304  using namespace std;
306  using JDETECTOR::getQE;
307 
308  this->mu = mu;
309 
310  const double Pmax = getMaximalHitProbability(this->mu);
311 
312  for (JPMTParametersMap::const_iterator i = this->begin(); i != this->end(); ++i) {
313  if (i->second.QE > Pmax) {
314  THROW(JValueOutOfRange, "Hit probability PMT " << i->first << ' ' << i->second.QE << " > maximum probability given expectation value " << this->mu << endl);
315  }
316  }
317 
318  for (JPMTParametersMap::iterator i = this->begin(); i != this->end(); ++i) {
319 
320  if (i->second.QE > 0.0)
321  i->second.QE = getQE(i->second.QE, this->mu);
322  else
323  i->second.QE = 0.0;
324  }
325  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:696
then usage $script< detector file >< detectorfile > nIf the range of floors is the first detector file is aligned to the second before the comparison nIn this
double mu
Expectation value for number of photo-electrons given two-fold (or higher) coincidence rate...
double getQE() const
Get global QE.
double getQE(const double R, const double mu)
Get QE for given ratio of hit probabilities and expectation value of the number of photo-electrons...
double getHitProbability(const double QE, const double mu)
Get ratio of hit probabilities for given QE and expectation value of the number of photo-electrons...
Exception for accessing a value in a collection that is outside of its range.
Definition: JException.hh:162
double getMaximalHitProbability(const double mu)
Get maximal ratio of hit probabilities for given QE and expectation value of the number of photo-elec...
JPMTParameters& JDETECTOR::JPMTParametersMap::operator[] ( const JPMTIdentifier id)
inline

Access parameters corresponding to given PMT identifier.

Note: The default PMT parameters are inserted if no parameters for the given PMT identifier are contained at the time of the function call.

Parameters
idPMT identifier
Returns
parameters

Definition at line 337 of file JPMTParametersMap.hh.

338  {
339  JPMTParametersMap_t::iterator i = find(id);
340 
341  if (i == end()) {
342  i = this->insert(i, std::make_pair(id, getDefaultPMTParameters()));
343  }
344 
345  return i->second;
346  }
const JPMTParameters & getDefaultPMTParameters() const
Get default PMT parameters.
static JEquationParameters& JDETECTOR::JPMTParametersMap::getEquationParameters ( )
inlinestatic

Get equation parameters.

Returns
equation parameters

Definition at line 417 of file JPMTParametersMap.hh.

418  {
420 
421  return parameters;
422  }
*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
Simple data structure to support I/O of equations (see class JLANG::JEquation).
static void JDETECTOR::JPMTParametersMap::setEquationParameters ( const JEquationParameters equation)
inlinestatic

Set equation parameters.

Parameters
equationequation parameters

Definition at line 430 of file JPMTParametersMap.hh.

431  {
432  getEquationParameters() = equation;
433  }
static JEquationParameters & getEquationParameters()
Get equation parameters.
template<class T>
void JLANG::JObjectStreamIO< T >::load ( const char *  file_name)
inlineinherited

Load from input file.

Parameters
file_namefile name

Definition at line 30 of file JObjectStreamIO.hh.

31  {
32  JLANG::load<std::ifstream>(file_name, static_cast<T&>(*this));
33  }
do set_variable OUTPUT_DIRECTORY $WORKDIR T
template<class T>
void JLANG::JObjectStreamIO< T >::store ( const char *  file_name) const
inlineinherited

Store to output file.

Parameters
file_namefile name

Definition at line 41 of file JObjectStreamIO.hh.

42  {
43  JLANG::store<std::ofstream>(file_name, static_cast<const T&>(*this));
44  }
do set_variable OUTPUT_DIRECTORY $WORKDIR T
template<class T>
static void JLANG::JThrow< T >::Throw ( const bool  option)
inlinestaticinherited

Enable/disable throw option.

Parameters
optiontrue enable; false disable

Definition at line 37 of file JThrow.hh.

38  {
39  do_throw = option;
40  }
static bool do_throw
throw option
Definition: JThrow.hh:28
template<class T>
static int JLANG::JThrow< T >::Throw ( const JException error,
const int  value = -1 
)
inlinestaticinherited

Throw exception or return error.

Parameters
errorexception
valuereturn code
Returns
return code

Definition at line 50 of file JThrow.hh.

51  {
52  using namespace std;
53 
54  if (do_throw) {
55  throw error;
56  }
57 
58  cerr << error.what() << endl;
59 
60  return value;
61  }
virtual const char * what() const override
Get error message.
Definition: JException.hh:48
static bool do_throw
throw option
Definition: JThrow.hh:28

Friends And Related Function Documentation

std::istream& operator>> ( std::istream &  in,
JPMTParametersMap object 
)
friend

Stream input.

Parameters
ininput stream
objectPMT parameters map
Returns
input stream

Definition at line 356 of file JPMTParametersMap.hh.

357  {
358  using namespace std;
359  using namespace JPP;
360 
362 
363  if (getFileStatus(is.str().c_str())) {
364  is.load();
365  }
366 
367  JProperties properties(getEquationParameters(), 1);
368 
369  JPMTParametersMapHelper helper(object, getEquationParameters());
370  JProperties demo = object.defaultPMTParameters.getProperties();
371 
372  properties["PMT"] = static_cast<JPMTParametersMap_t&>(object);
373  properties["pmt"] = helper;
374  properties["%"] = demo;
375  properties["QE"] = object.QE;
376  properties["mu"] = object.mu;
377 
378  is >> object.comment;
379  is >> properties;
380 
381  return in;
382  }
Utility class to parse parameter values.
Definition: JProperties.hh:496
is
Definition: JDAQCHSM.chsm:167
static JEquationParameters & getEquationParameters()
Get equation parameters.
static JStat getFileStatus
Function object for file status.
Definition: JStat.hh:173
Wrapper class around STL stringstream class to facilitate optional loading of data from file...
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:46
std::ostream& operator<< ( std::ostream &  out,
const JPMTParametersMap object 
)
friend

Stream output.

Parameters
outoutput stream
objectPMT parameters map
Returns
output stream

Definition at line 392 of file JPMTParametersMap.hh.

393  {
394  using namespace JLANG;
395 
396  JProperties properties(getEquationParameters());
397 
398  JProperties demo = object.defaultPMTParameters.getProperties();
399 
400  properties["PMT"] = static_cast<const JPMTParametersMap_t&>(object);
401  properties["%"] = demo;
402 
403  out << object.comment;
404  out << setequation(getEquationParameters()) << JEquation::make_equation("QE", object.QE);
405  out << setequation(getEquationParameters()) << JEquation::make_equation("mu", object.mu);
406  out << properties;
407 
408  return out;
409  }
Utility class to parse parameter values.
Definition: JProperties.hh:496
double mu
Expectation value for number of photo-electrons given two-fold (or higher) coincidence rate...
static JEquationParameters & getEquationParameters()
Get equation parameters.
JLANG::JEquationFacet setequation
Type definition of stream manipulator for equational I/O.

Member Data Documentation

JComment JDETECTOR::JPMTParametersMap::comment

Definition at line 436 of file JPMTParametersMap.hh.

JPMTParameters JDETECTOR::JPMTParametersMap::defaultPMTParameters
protected

Default PMT parameters.

Definition at line 442 of file JPMTParametersMap.hh.

double JDETECTOR::JPMTParametersMap::QE
protected

Global QE.

Definition at line 447 of file JPMTParametersMap.hh.

double JDETECTOR::JPMTParametersMap::mu
protected

Expectation value for number of photo-electrons given two-fold (or higher) coincidence rate.

Definition at line 453 of file JPMTParametersMap.hh.

template<class T>
bool JLANG::JThrow< T >::do_throw = true
staticprotectedinherited

throw option

Set default throw option to true.

Definition at line 28 of file JThrow.hh.


The documentation for this class was generated from the following file: