Jpp
 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 36 of file JDBToolkit.hh.

Member Function Documentation

void JDATABASE::JDetectorsHelper::initialise ( )
inline

Initialise.

Definition at line 40 of file JDBToolkit.hh.

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

Get detector serial number.

Parameters
detidobject identifier
Returns
serial number

Definition at line 59 of file JDBToolkit.hh.

60  {
62 
63  if (p == det2id.end()) {
64 
65  initialise();
66 
67  p = det2id.find(detid);
68 
69  if (p == det2id.end()) {
70  THROW(JDatabaseException, "Invalid detector identifier " << detid);
71  }
72  }
73 
74  return p->second;
75  }
#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:104
void initialise()
Initialise.
Definition: JDBToolkit.hh:40
std::string JDATABASE::JDetectorsHelper::operator() ( const int  id)
inline

Get detector identifier.

Parameters
idserial number
Returns
object identifier

Definition at line 84 of file JDBToolkit.hh.

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

Member Data Documentation

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

Definition at line 103 of file JDBToolkit.hh.

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

Definition at line 104 of file JDBToolkit.hh.


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