Jpp - the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Attributes | List of all members
JDATABASE::JDetectorsHelper Struct Reference

Auxiliary class for mapping serial number and object identifier of detectors. More...

#include <JDBToolkit.hh>

Public Member Functions

void initialise ()
 Initialise. More...
 
int operator() (const std::string &detid)
 Get detector serial number. More...
 
std::string operator() (const int id)
 Get detector identifier. More...
 

Protected Attributes

std::map< int, std::string > id2det
 
std::map< std::string, int > det2id
 

Detailed Description

Auxiliary class for mapping serial number and object identifier of detectors.

Definition at line 37 of file JDBToolkit.hh.

Member Function Documentation

void JDATABASE::JDetectorsHelper::initialise ( )
inline

Initialise.

Definition at line 41 of file JDBToolkit.hh.

42  {
43  ResultSet& rs = JDB::get()->StreamDS(getTable<JDetectors>(), JSelector());
44 
45  for (JDetectors parameters; rs >> parameters; ) {
46  det2id[parameters.OID] = parameters.SERIALNUMBER;
47  id2det[parameters.SERIALNUMBER] = parameters.OID;
48  }
49 
50  rs.Close();
51  }
*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
Auxiliary class for specifying selection of database data.
std::map< std::string, int > det2id
Definition: JDBToolkit.hh:105
std::map< int, std::string > id2det
Definition: JDBToolkit.hh:104
static JDB & get()
Get connection to database.
Definition: JDB.hh:225
int JDATABASE::JDetectorsHelper::operator() ( const std::string &  detid)
inline

Get detector serial number.

Parameters
detidobject identifier
Returns
serial number

Definition at line 60 of file JDBToolkit.hh.

61  {
63 
64  if (p == det2id.end()) {
65 
66  initialise();
67 
68  p = det2id.find(detid);
69 
70  if (p == det2id.end()) {
71  THROW(JDatabaseException, "Invalid detector identifier " << detid);
72  }
73  }
74 
75  return p->second;
76  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:670
std::map< std::string, int > det2id
Definition: JDBToolkit.hh:105
void initialise()
Initialise.
Definition: JDBToolkit.hh:41
std::string JDATABASE::JDetectorsHelper::operator() ( const int  id)
inline

Get detector identifier.

Parameters
idserial number
Returns
object identifier

Definition at line 85 of file JDBToolkit.hh.

86  {
88 
89  if (p == id2det.end()) {
90 
91  initialise();
92 
93  p = id2det.find(id);
94 
95  if (p == id2det.end()) {
96  THROW(JDatabaseException, "Invalid detector identifier " << id);
97  }
98  }
99 
100  return p->second;
101  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:670
void initialise()
Initialise.
Definition: JDBToolkit.hh:41
std::map< int, std::string > id2det
Definition: JDBToolkit.hh:104

Member Data Documentation

std::map<int, std::string> JDATABASE::JDetectorsHelper::id2det
protected

Definition at line 104 of file JDBToolkit.hh.

std::map<std::string, int> JDATABASE::JDetectorsHelper::det2id
protected

Definition at line 105 of file JDBToolkit.hh.


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