Jpp  pmt_effective_area_update
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | List of all members
JDETECTOR::JGetDetectorVersion Struct Reference

Auxiliary class to map detector version to numerical value. More...

#include <JDetectorVersion.hh>

Inheritance diagram for JDETECTOR::JGetDetectorVersion:
std::map< std::string, JDetectorVersion::JVersion_t >

Public Member Functions

 JGetDetectorVersion ()
 Default constructor. More...
 
JDetectorVersion::JVersion_t operator() (const std::string &version) const
 Get numerical value. More...
 
JDetectorVersion::JVersion_t operator() (const JDetectorVersion &version) const
 Get numerical value. More...
 
int operator[] (const std::string &version) const
 Get index of detector version. More...
 
int operator[] (const JDetectorVersion &version) const
 Get index of detector version. More...
 
int operator[] (const JDetectorVersion::JVersion_t &value) const
 Get index of detector version. More...
 

Detailed Description

Auxiliary class to map detector version to numerical value.

Definition at line 130 of file JDetectorVersion.hh.

Constructor & Destructor Documentation

JDETECTOR::JGetDetectorVersion::JGetDetectorVersion ( )
inline

Default constructor.

Definition at line 136 of file JDetectorVersion.hh.

137  {
138  using namespace JPP;
139 
140 #define MAKE_ENTRY(A) std::make_pair(to_upper(getClassname(#A)), A)
141 
142  this->insert(MAKE_ENTRY(JDetectorVersion::V1));
143  this->insert(MAKE_ENTRY(JDetectorVersion::V2));
144  this->insert(MAKE_ENTRY(JDetectorVersion::V3));
145  this->insert(MAKE_ENTRY(JDetectorVersion::V4));
146 
147 #undef MAKE_ENTRY
148  }
Version with UTC time and UTM position data.
Version with PMT status field and comments.
Version with quaternion and time offset per module.
#define MAKE_ENTRY(A)

Member Function Documentation

JDetectorVersion::JVersion_t JDETECTOR::JGetDetectorVersion::operator() ( const std::string &  version) const
inline

Get numerical value.

Parameters
versionversion
Returns
numerical value

Definition at line 157 of file JDetectorVersion.hh.

158  {
159  using namespace JPP;
160 
161  const_iterator i = this->find(to_upper(version));
162 
163  if (i != this->end()) {
164  return i->second;
165  } else {
166  THROW(JTypeInformationException, "Invalid version <" << version << ">");
167  }
168  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:670
std::string to_upper(const std::string &value)
Convert all character to upper case.
version
Definition: JCalibratePMT.sh:7
JDetectorVersion::JVersion_t JDETECTOR::JGetDetectorVersion::operator() ( const JDetectorVersion version) const
inline

Get numerical value.

Parameters
versionversion
Returns
numerical value

Definition at line 177 of file JDetectorVersion.hh.

178  {
179  return (*this)(version.getVersion());
180  }
const std::string & getVersion() const
Get version.
int JDETECTOR::JGetDetectorVersion::operator[] ( const std::string &  version) const
inline

Get index of detector version.

Parameters
versionversion
Returns
index

Definition at line 189 of file JDetectorVersion.hh.

190  {
191  using namespace std;
192  using namespace JPP;
193 
194  const_iterator i = this->find(to_upper(version));
195 
196  if (i != this->end())
197  return distance(this->begin(), i);
198  else
199  return -1;
200  }
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
std::string to_upper(const std::string &value)
Convert all character to upper case.
version
Definition: JCalibratePMT.sh:7
int JDETECTOR::JGetDetectorVersion::operator[] ( const JDetectorVersion version) const
inline

Get index of detector version.

Parameters
versionversion
Returns
index

Definition at line 209 of file JDetectorVersion.hh.

210  {
211  return (*this)[version.getVersion()];
212  }
const std::string & getVersion() const
Get version.
int JDETECTOR::JGetDetectorVersion::operator[] ( const JDetectorVersion::JVersion_t value) const
inline

Get index of detector version.

Parameters
valuenumerical value
Returns
index

Definition at line 221 of file JDetectorVersion.hh.

222  {
223  using namespace std;
224 
225  for (const_iterator i = this->begin(); i != this->end(); ++i) {
226  if (i->second == value) {
227  return distance(this->begin(), i);
228  }
229  }
230 
231  return -1;
232  }
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.

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