Jpp 21.0.0-rc.1-88-g0130508c4
the software that should make you happy
Loading...
Searching...
No Matches
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.
 
 JPMTParametersMap (const char *const file_name)
 Constructor.
 
const JPMTParametersgetPMTParameters (const JPMTIdentifier &id) const
 Get PMT parameters.
 
double getQE (const JPMTIdentifier &id) const
 Get QE of given PMT.
 
double getHitProbability (const JPMTIdentifier &id) const
 Get ratio of hit probabilities of given PMT.
 
const JPMTParametersgetDefaultPMTParameters () const
 Get default PMT parameters.
 
JPMTParametersgetDefaultPMTParameters ()
 Get default PMT parameters.
 
void setDefaultPMTParameters (const JPMTParameters &parameters)
 Set default PMT parameters.
 
double getQE () const
 Get global QE.
 
void setQE (const double QE)
 Set global QE.
 
double getMu () const
 Get expectation value for number of photo-electrons given two-fold (or higher) coincidence rate.
 
bool is_valid () const
 Check validity of PMT parameters.
 
void convertHitProbabilityToQE (const double mu)
 Convert the hit probabilities to QEs for given expectation value.
 
void convertQEToHitProbability ()
 Convert the QEs to hit probabilities for given expectation value.
 
JPMTParametersoperator[] (const JPMTIdentifier &id)
 Access parameters corresponding to given PMT identifier.
 
void load (const char *file_name)
 Load from input file.
 
void store (const char *file_name) const
 Store to output file.
 

Static Public Member Functions

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

Public Attributes

JComment comment
 

Protected Attributes

struct { 
 
   JPMTParameters   parameters 
 Default PMT parameters. More...
 
   double   QE = 1.0 
 Global QE. More...
 
   double   mu = 0.0 
 Expectation value for number of photo-electrons given two-fold (or higher) coincidence rate. More...
 
internal 
 

Static Protected Attributes

static bool do_throw = true
 throw option
 

Friends

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

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

  • QE refers to the global quantum efficiency which is reserved for the overall light scaling;
  • mu refers to the expectation value for number of photo-electrons given two-fold (or higher) coincidence rate;
  • '%' to the default values;
  • <module> to the module identifier;
  • <pmt> to the readout channel;
  • <key> to one of the data members of the JDETECTOR::JPMTParameters data structure; and
  • <value> to the corresponding value.

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

◆ JPMTParametersMap() [1/2]

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

Constructor.

Parameters
parametersPMT parameters

Definition at line 100 of file JPMTParametersMap.hh.

100 :
102 {
104 }
JPMTParameters parameters
Default PMT parameters.
void setDefaultPMTParameters(const JPMTParameters &parameters)
Set default PMT parameters.
std::map< JPMTIdentifier, JPMTParameters > JPMTParametersMap_t
Type definition of map PMT identifier to PMT parameters.

◆ JPMTParametersMap() [2/2]

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

Constructor.

Parameters
file_namefile name

Definition at line 112 of file JPMTParametersMap.hh.

112 :
114 {
115 using namespace std;
116
117 ifstream in(file_name);
118
119 in >> *this;
120
121 in.close();
122 }

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

137 {
138 static JPMTParameters parameters;
139
140 JPMTParametersMap_t::const_iterator i = find(id);
141
142 if (i != end()) {
143 parameters = i->second;
144 } else {
146 }
147
148 parameters.QE *= internal.QE;
149
150 return parameters;
151 }
struct JDETECTOR::JPMTParametersMap::@9 internal
const JPMTParameters & getDefaultPMTParameters() const
Get default PMT parameters.
double QE
relative quantum efficiency

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

161 {
162 return getPMTParameters(id).QE;
163 }
const JPMTParameters & getPMTParameters(const JPMTIdentifier &id) const
Get PMT parameters.

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

173 {
175 }
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.

◆ getDefaultPMTParameters() [1/2]

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

Get default PMT parameters.

Returns
PMT parameters

Definition at line 183 of file JPMTParametersMap.hh.

184 {
185 return internal.parameters;
186 }

◆ getDefaultPMTParameters() [2/2]

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

Get default PMT parameters.

Returns
PMT parameters

Definition at line 194 of file JPMTParametersMap.hh.

195 {
196 return internal.parameters;
197 }

◆ setDefaultPMTParameters()

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

Set default PMT parameters.

Parameters
parametersPMT parameters

Definition at line 205 of file JPMTParametersMap.hh.

206 {
207 internal.parameters = parameters;
208 }

◆ getQE() [2/2]

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

Get global QE.

Returns
QE

Definition at line 216 of file JPMTParametersMap.hh.

217 {
218 return internal.QE;
219 }

◆ setQE()

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

Set global QE.

Parameters
QEQE

Definition at line 227 of file JPMTParametersMap.hh.

228 {
229 internal.QE = QE;
230 }

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

239 {
240 return internal.mu;
241 }

◆ is_valid()

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

Check validity of PMT parameters.

Returns
true if valid; else false

Definition at line 249 of file JPMTParametersMap.hh.

250 {
251 try {
252
253 if (internal.QE < 0.0) {
254 THROW(JException, "Invalid global QE " << internal.QE);
255 }
256
257 if (internal.mu < 0.0) {
258 THROW(JException, "Invalid expectation value number of photo-electrons " << internal.mu);
259 }
260
261 if (!internal.parameters.is_valid()) {
262 THROW(JException, "Invalid default PMT parameters");
263 }
264
265 for (const_iterator i = this->begin(); i != this->end(); ++i) {
266
267 if (!i->second.is_valid()) {
268 THROW(JException, "Invalid PMT parameters at " << i->first);
269 }
270
271 if (i->second.QE * internal.QE > 1.0 ||
272 i->second.QE * internal.QE < 0.0) {
273 THROW(JException, "Invalid PMT QE at " << i->first << ' ' << i->second.QE * internal.QE);
274 }
275 }
276
277 return true;
278 }
279 catch(const JException& error) {
280
281 Throw(error);
282
283 return false;
284 }
285 }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
static void Throw(const bool option)
Enable/disable throw option.
Definition JThrow.hh:37

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

Parameters
muexpectation value

Definition at line 296 of file JPMTParametersMap.hh.

297 {
298 if (internal.mu != 0.0) {
299 THROW(JValueOutOfRange, "Non-zero internal expectation value " << internal.mu << "; use first method convertQEToHitProbability().");
300 }
301
302 const double Pmax = getMaximalHitProbability(mu);
303
304 for (JPMTParametersMap::const_iterator i = this->begin(); i != this->end(); ++i) {
305 if (i->second.QE > Pmax) {
306 THROW(JValueOutOfRange, "Hit probability PMT " << i->first << ' ' << i->second.QE << " > maximum probability given expectation value " << mu);
307 }
308 }
309
310 internal.mu = mu;
311
312 for (JPMTParametersMap::iterator i = this->begin(); i != this->end(); ++i) {
313
314 if (i->second.QE > 0.0)
315 i->second.QE = JDETECTOR::getQE(i->second.QE, internal.mu);
316 else
317 i->second.QE = 0.0;
318 }
319 }
double mu
Expectation value for number of photo-electrons given two-fold (or higher) coincidence rate.
double getMaximalHitProbability(const double mu)
Get maximal ratio of hit probabilities for given QE and expectation value of the number of photo-elec...
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.

◆ convertQEToHitProbability()

void JDETECTOR::JPMTParametersMap::convertQEToHitProbability ( )
inline

Convert the QEs to hit probabilities for given expectation value.

The expectation value is set to zero.

Definition at line 327 of file JPMTParametersMap.hh.

328 {
329 // backward correction QE -> P
330
331 if (internal.mu > 0.0) {
332
333 for (JPMTParametersMap::iterator i = this->begin(); i != this->end(); ++i) {
334
335 if (i->second.QE > 0.0)
336 i->second.QE = JDETECTOR::getHitProbability(i->second.QE, internal.mu);
337 else
338 i->second.QE = 0.0;
339 }
340
341 internal.mu = 0.0;
342 }
343 }

◆ operator[]()

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

356 {
357 JPMTParametersMap_t::iterator i = find(id);
358
359 if (i == end()) {
360 i = this->insert(i, std::make_pair(id, getDefaultPMTParameters()));
361 }
362
363 return i->second;
364 }

◆ getEquationParameters()

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

Get equation parameters.

Returns
equation parameters

Definition at line 435 of file JPMTParametersMap.hh.

436 {
438
439 return parameters;
440 }
Simple data structure to support I/O of equations (see class JLANG::JEquation).

◆ setEquationParameters()

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

Set equation parameters.

Parameters
equationequation parameters

Definition at line 448 of file JPMTParametersMap.hh.

449 {
450 getEquationParameters() = equation;
451 }
static JEquationParameters & getEquationParameters()
Get equation parameters.

◆ 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 }
void load(const std::string &file_name, T &object)
Load object from input file.
Definition JObjectIO.hh:55

◆ 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 }
void store(const std::string &file_name, const T &object)
Store object to output file.
Definition JObjectIO.hh:68

◆ 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 }
static bool do_throw
throw option
Definition JThrow.hh:28

◆ Throw() [2/2]

template<class T >
template<class JException_t >
static int JLANG::JThrow< T >::Throw ( const JException_t & error,
const int value = -1 )
inlinestaticinherited

Throw exception or return error.

Parameters
errorexception
valuereturn code
Returns
return code

Definition at line 51 of file JThrow.hh.

52 {
53 using namespace std;
54
55 if (do_throw) {
56 throw error;
57 }
58
59 cerr << error.what() << endl;
60
61 return value;
62 }

Friends And Related Symbol 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 374 of file JPMTParametersMap.hh.

375 {
376 using namespace std;
377 using namespace JPP;
378
379 JStringStream is(in);
380
381 if (getFileStatus(is.str().c_str())) {
382 is.load();
383 }
384
385 JProperties properties(getEquationParameters(), 1);
386
387 JPMTParametersMapHelper helper(object, getEquationParameters());
388 JProperties demo = object.internal.parameters.getProperties();
389
390 properties["PMT"] = static_cast<JPMTParametersMap_t&>(object);
391 properties["pmt"] = helper;
392 properties["%"] = demo;
393 properties["QE"] = object.internal.QE;
394 properties["mu"] = object.internal.mu;
395
396 is >> object.comment;
397 is >> properties;
398
399 return in;
400 }
Utility class to parse parameter values.
Wrapper class around STL stringstream class to facilitate optional loading of data from file.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).

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

411 {
412 using namespace JLANG;
413
415
416 JProperties demo = object.internal.parameters.getProperties();
417
418 properties["PMT"] = static_cast<const JPMTParametersMap_t&>(object);
419 properties["%"] = demo;
420
421 out << object.comment;
422 out << setequation(getEquationParameters()) << JEquation::make_equation("QE", object.internal.QE);
423 out << setequation(getEquationParameters()) << JEquation::make_equation("mu", object.internal.mu);
424 out << properties;
425
426 return out;
427 }
Facet class to specify parsing of equations in currect locale (see class JLANG::JEquation).
Auxiliary classes and methods for language specific functionality.

Member Data Documentation

◆ comment

JComment JDETECTOR::JPMTParametersMap::comment

Definition at line 454 of file JPMTParametersMap.hh.

◆ parameters

JPMTParameters JDETECTOR::JPMTParametersMap::parameters

Default PMT parameters.

Definition at line 459 of file JPMTParametersMap.hh.

◆ QE

double JDETECTOR::JPMTParametersMap::QE = 1.0

Global QE.

Definition at line 460 of file JPMTParametersMap.hh.

◆ mu

double JDETECTOR::JPMTParametersMap::mu = 0.0

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

Definition at line 461 of file JPMTParametersMap.hh.

◆ [struct]

struct { ... } JDETECTOR::JPMTParametersMap::internal

◆ 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: