Jpp
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...
 
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...
 
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.

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 88 of file JPMTParametersMap.hh.

Constructor & Destructor Documentation

◆ JPMTParametersMap() [1/2]

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

Constructor.

Parameters
parametersPMT parameters

Definition at line 99 of file JPMTParametersMap.hh.

99  :
101  QE(1.0),
102  mu(0.0)
103  {
104  setDefaultPMTParameters(parameters);
105  }

◆ JPMTParametersMap() [2/2]

JDETECTOR::JPMTParametersMap::JPMTParametersMap ( const char *const  file_name)
inline

Constructor.

Parameters
file_namefile name

Definition at line 113 of file JPMTParametersMap.hh.

113  :
115  QE(1.0),
116  mu(0.0)
117  {
118  using namespace std;
119 
120  ifstream in(file_name);
121 
122  in >> *this;
123 
124  in.close();
125  }

Member Function Documentation

◆ getPMTParameters()

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 139 of file JPMTParametersMap.hh.

140  {
141  static JPMTParameters parameters;
142 
143  JPMTParametersMap_t::const_iterator i = find(id);
144 
145  if (i != end())
146  parameters = i->second;
147  else
148  parameters = getDefaultPMTParameters();
149 
150  parameters.QE *= this->QE;
151 
152  return parameters;
153  }

◆ getQE() [1/2]

double JDETECTOR::JPMTParametersMap::getQE ( const JPMTIdentifier id) const
inline

Get QE of given PMT.

Parameters
idPMT identifier
Returns
QE

Definition at line 162 of file JPMTParametersMap.hh.

163  {
164  return getPMTParameters(id).QE;
165  }

◆ getHitProbability()

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 174 of file JPMTParametersMap.hh.

175  {
177 
178  return getHitProbability(getQE(id), this->mu);
179  }

◆ getDefaultPMTParameters()

const JPMTParameters& JDETECTOR::JPMTParametersMap::getDefaultPMTParameters ( ) const
inline

Get default PMT parameters.

Returns
PMT parameters

Definition at line 187 of file JPMTParametersMap.hh.

188  {
189  return defaultPMTParameters;
190  }

◆ setDefaultPMTParameters()

void JDETECTOR::JPMTParametersMap::setDefaultPMTParameters ( const JPMTParameters parameters)
inline

Set default PMT parameters.

Parameters
parametersPMT parameters

Definition at line 198 of file JPMTParametersMap.hh.

199  {
200  defaultPMTParameters = parameters;
201  }

◆ getQE() [2/2]

double JDETECTOR::JPMTParametersMap::getQE ( ) const
inline

Get global QE.

Returns
QE

Definition at line 209 of file JPMTParametersMap.hh.

210  {
211  return this->QE;
212  }

◆ setQE()

void JDETECTOR::JPMTParametersMap::setQE ( const double  QE)
inline

Set global QE.

Parameters
QEQE

Definition at line 220 of file JPMTParametersMap.hh.

221  {
222  this->QE = QE;
223  }

◆ getMu()

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 231 of file JPMTParametersMap.hh.

232  {
233  return this->mu;
234  }

◆ is_valid()

bool JDETECTOR::JPMTParametersMap::is_valid ( ) const
inline

Check validity of PMT parameters.

Returns
true if valid; else false

Definition at line 242 of file JPMTParametersMap.hh.

243  {
244  try {
245 
246  if (this->QE < 0) {
247  THROW(JException, "Invalid global QE " << QE);
248  }
249 
250  if (this->mu < 0) {
251  THROW(JException, "Invalid expectation value number of photo-electrons " << mu);
252  }
253 
255  THROW(JException, "Invalid default PMT parameters");
256  }
257 
258  for (const_iterator i = this->begin(); i != this->end(); ++i) {
259 
260  if (!i->second.is_valid()) {
261  THROW(JException, "Invalid PMT parameters at " << i->first);
262  }
263 
264  if (i->second.QE * this->QE > 1.0 ||
265  i->second.QE * this->QE < 0.0) {
266  THROW(JException, "Invalid PMT QE at " << i->first << ' ' << i->second.QE * this->QE);
267  }
268  }
269 
270  return true;
271  }
272  catch(const JException& error) {
273 
274  Throw(error);
275 
276  return false;
277  }
278  }

◆ convertHitProbabilityToQE()

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.
The survival probability is taken into account in the conversion (see method JDETECTOR::getSurvivalProbability).

Parameters
muexpectation value

Definition at line 291 of file JPMTParametersMap.hh.

292  {
293  using namespace std;
295  using JDETECTOR::getQE;
296 
297  this->mu = mu;
298 
299  const double Pmax = getMaximalHitProbability(this->mu);
300 
301  for (JPMTParametersMap::const_iterator i = this->begin(); i != this->end(); ++i) {
302  if (i->second.QE > Pmax) {
303  THROW(JValueOutOfRange, "Hit probability PMT " << i->first << ' ' << i->second.QE << " > maximum probability given expectation value " << this->mu << endl);
304  }
305  }
306 
307  for (JPMTParametersMap::iterator i = this->begin(); i != this->end(); ++i) {
308 
309  const double P = getSurvivalProbability(i->second);
310 
311  if (i->second.QE > 0.0 && P > 0.0)
312  i->second.QE = getQE(i->second.QE, this->mu) / P;
313  else
314  i->second.QE = 0.0;
315  }
316  }

◆ getEquationParameters()

static JEquationParameters& JDETECTOR::JPMTParametersMap::getEquationParameters ( )
inlinestatic

Get equation parameters.

Returns
equation parameters

Definition at line 387 of file JPMTParametersMap.hh.

388  {
389  static JEquationParameters parameters;
390 
391  return parameters;
392  }

◆ setEquationParameters()

static void JDETECTOR::JPMTParametersMap::setEquationParameters ( const JEquationParameters equation)
inlinestatic

Set equation parameters.

Parameters
equationequation parameters

Definition at line 400 of file JPMTParametersMap.hh.

401  {
402  getEquationParameters() = equation;
403  }

◆ load()

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  }

◆ store()

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  }

◆ Throw() [1/2]

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  }

◆ Throw() [2/2]

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  }

Friends And Related Function Documentation

◆ operator>>

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

Stream input.

Parameters
ininput stream
objectPMT parameters map
Returns
input stream

Definition at line 326 of file JPMTParametersMap.hh.

327  {
328  using namespace std;
329  using namespace JPP;
330 
331  JStringStream is(in);
332 
333  if (getFileStatus(is.str().c_str())) {
334  is.load();
335  }
336 
337  JProperties properties(getEquationParameters(), 1);
338 
339  JPMTParametersMapHelper helper(object, getEquationParameters());
340  JProperties demo = object.defaultPMTParameters.getProperties();
341 
342  properties["PMT"] = static_cast<JPMTParametersMap_t&>(object);
343  properties["pmt"] = helper;
344  properties["%"] = demo;
345  properties["QE"] = object.QE;
346  properties["mu"] = object.mu;
347 
348  is >> object.comment;
349  is >> properties;
350 
351  return in;
352  }

◆ operator<<

std::ostream& operator<< ( std::ostream &  out,
const JPMTParametersMap object 
)
friend

Stream output.

Parameters
outoutput stream
objectPMT parameters map
Returns
output stream

Definition at line 362 of file JPMTParametersMap.hh.

363  {
364  using namespace JLANG;
365 
366  JProperties properties(getEquationParameters());
367 
368  JProperties demo = object.defaultPMTParameters.getProperties();
369 
370  properties["PMT"] = static_cast<const JPMTParametersMap_t&>(object);
371  properties["%"] = demo;
372 
373  out << object.comment;
374  out << setequation(getEquationParameters()) << JEquation::make_equation("QE", object.QE);
375  out << setequation(getEquationParameters()) << JEquation::make_equation("mu", object.mu);
376  out << properties;
377 
378  return out;
379  }

Member Data Documentation

◆ comment

JComment JDETECTOR::JPMTParametersMap::comment

Definition at line 406 of file JPMTParametersMap.hh.

◆ defaultPMTParameters

JPMTParameters JDETECTOR::JPMTParametersMap::defaultPMTParameters
protected

Default PMT parameters.

Definition at line 412 of file JPMTParametersMap.hh.

◆ QE

double JDETECTOR::JPMTParametersMap::QE
protected

Global QE.

Definition at line 417 of file JPMTParametersMap.hh.

◆ mu

double JDETECTOR::JPMTParametersMap::mu
protected

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

Definition at line 423 of file JPMTParametersMap.hh.

◆ do_throw

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:
JDETECTOR::getHitProbability
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.
Definition: JPMTParametersToolkit.hh:52
JDETECTOR::JPMTParametersMap::defaultPMTParameters
JPMTParameters defaultPMTParameters
Default PMT parameters.
Definition: JPMTParametersMap.hh:412
JDETECTOR::JPMTParametersMap::getEquationParameters
static JEquationParameters & getEquationParameters()
Get equation parameters.
Definition: JPMTParametersMap.hh:387
JDETECTOR::getSurvivalProbability
double getSurvivalProbability(const JPMTParameters &parameters)
Get model dependent probability that a one photo-electron hit survives the simulation of the PMT assu...
Definition: JPMTParametersToolkit.hh:32
JDETECTOR::JPMTParameters::is_valid
bool is_valid() const
Check validity of PMT parameters.
Definition: JPMTParameters.hh:117
JDETECTOR::getQE
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.
Definition: JPMTParametersToolkit.hh:89
JDETECTOR::JPMTParametersMap_t
std::map< JPMTIdentifier, JPMTParameters > JPMTParametersMap_t
Type definition of map PMT identifier to PMT parameters.
Definition: JPMTParametersMap.hh:47
JDETECTOR::JPMTParametersMap::getQE
double getQE() const
Get global QE.
Definition: JPMTParametersMap.hh:209
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
JSYSTEM::getFileStatus
static JStat getFileStatus
Function object for file status.
Definition: JStat.hh:173
THROW
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:669
JLANG::JValueOutOfRange
Exception for accessing a value in a collection that is outside of its range.
Definition: JException.hh:162
JDETECTOR::JPMTParametersMap::getPMTParameters
const JPMTParameters & getPMTParameters(const JPMTIdentifier &id) const
Get PMT parameters.
Definition: JPMTParametersMap.hh:139
JLANG::JThrow::Throw
static void Throw(const bool option)
Enable/disable throw option.
Definition: JThrow.hh:37
JDETECTOR::JPMTParametersMap::getDefaultPMTParameters
const JPMTParameters & getDefaultPMTParameters() const
Get default PMT parameters.
Definition: JPMTParametersMap.hh:187
JLANG::JEquationParameters
Simple data structure to support I/O of equations (see class JLANG::JEquation).
Definition: JEquationParameters.hh:20
JLANG::setequation
JLANG::JEquationFacet setequation
Type definition of stream manipulator for equational I/O.
Definition: JEquationFacet.hh:468
JDETECTOR::JPMTParametersMap::getHitProbability
double getHitProbability(const JPMTIdentifier &id) const
Get ratio of hit probabilities of given PMT.
Definition: JPMTParametersMap.hh:174
JEEP::JProperties
Utility class to parse parameter values.
Definition: JProperties.hh:496
JDETECTOR::JPMTParametersMap::QE
double QE
Global QE.
Definition: JPMTParametersMap.hh:417
std
Definition: jaanetDictionary.h:36
JLANG::JThrow::do_throw
static bool do_throw
throw option
Definition: JThrow.hh:28
JLANG::JException::what
virtual const char * what() const
Get error message.
Definition: JException.hh:65
JLANG::JStringStream
Wrapper class around STL stringstream class to facilitate optional loading of data from file.
Definition: JStringStream.hh:22
JDETECTOR::JPMTParametersMap::mu
double mu
Expectation value for number of photo-electrons given two-fold (or higher) coincidence rate.
Definition: JPMTParametersMap.hh:423
JLANG
Auxiliary classes and methods for language specific functionality.
Definition: JAbstractClass.hh:10
JDETECTOR::JPMTParameters::QE
double QE
relative quantum efficiency
Definition: JPMTParameters.hh:216
JDETECTOR::JPMTParameters
Data structure for PMT parameters.
Definition: JPMTParameters.hh:29
JDETECTOR::getMaximalHitProbability
double getMaximalHitProbability(const double mu)
Get maximal ratio of hit probabilities for given QE and expectation value of the number of photo-elec...
Definition: JPMTParametersToolkit.hh:69
JLANG::JException
General exception.
Definition: JException.hh:40
JDETECTOR::JPMTParametersMap::setDefaultPMTParameters
void setDefaultPMTParameters(const JPMTParameters &parameters)
Set default PMT parameters.
Definition: JPMTParametersMap.hh:198