Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Namespaces | Classes | Typedefs | Functions | Variables
JDATABASE Namespace Reference

Auxiliary classes and methods for database I/O. More...

Namespaces

 PBS
 

Classes

struct  JAHRS
 
struct  JAllParams
 
struct  JCLBMap
 
struct  JNullResultSet
 Auxiliary class for invalid result set. More...
 
class  JDatabaseObjectIterator
 Object iteration from database. More...
 
struct  JDatabaseObjectIterator< JTypeList< JHead_t, JTail_t > >
 Implementation of object iterator for multiple data types. More...
 
struct  JDatabaseObjectIterator< JTypeList< JHead_t, JNullType > >
 Terminator class of recursive JDatabaseObjectIterator class. More...
 
struct  JDatalog
 
struct  JDatalogNumbers
 
class  JDB
 Auxiliary class for connection to data base. More...
 
struct  JDBReader
 Auxiliary class to read ROOT object from database. More...
 
struct  JDBString
 Wrapper class to read string until end-of-line. More...
 
struct  JRun_t
 Auxiliary class for detector/run comparisons. More...
 
struct  JDetectorsHelper
 Auxiliary class for mapping serial number and object identifier of detectors. More...
 
struct  JDetectorIntegration
 
struct  JProductIntegration_t
 Auxiliary class for product integration data. More...
 
struct  JDetectorIntegration_t
 Detector integration. More...
 
struct  JProductTrace
 Auxiliary class to trace product. More...
 
struct  JDetectors
 
struct  JPBS
 Product breakdown structure (PBS). More...
 
struct  JPersons
 
struct  JPMTBestHVSettings
 
struct  JPMTHVRunSettings
 
struct  JPMTHVSettings
 
struct  JProductIntegration
 
struct  JLocation_t
 Auxiliary data structure for location of product in detector. More...
 
class  JProductRouter
 Auxiliary class to map UPI to location in detector. More...
 
struct  JRunQuality
 Auxiliary data structure for data quality. More...
 
struct  JRuns
 
struct  JRunsetupParams
 
struct  JRunsetups
 Auxiliary class for run setup evaluation. More...
 
struct  JRunSummaryNumbers
 
class  JSelector
 Auxiliary class for specifying selection of database data. More...
 
struct  getSelector
 Template definition for getting table specific selector. More...
 
struct  getSelector< T, JPersons, true >
 Template specialisation for getting table specific selector. More...
 
struct  getSelector< T, JDetectors, true >
 Template specialisation for getting table specific selector. More...
 
struct  getSelector< T, JRuns, true >
 Template specialisation for getting table specific selector. More...
 
struct  getSelector< T, JDatalogNumbers, true >
 Template specialisation for getting table specific selector. More...
 
struct  getSelector< T, JAllParams, true >
 Template specialisation for getting table specific selector. More...
 
struct  getSelector< T, JToAshort, true >
 Template specialisation for getting table specific selector. More...
 
struct  getSelector< T, JCLBMap, true >
 Template specialisation for getting table specific selector. More...
 
struct  getSelector< T, JDetectorIntegration, true >
 Template specialisation for getting table specific selector. More...
 
struct  getSelector< T, JRunSummaryNumbers, true >
 Template specialisation for getting table specific selector. More...
 
struct  getSelector< T, JRunQuality, true >
 Template specialisation for getting table specific selector. More...
 
struct  getSelector< T, JRunsetupParams, true >
 Template specialisation for getting table specific selector. More...
 
struct  getSelector< T, JPMTHVRunSettings, true >
 Template specialisation for getting table specific selector. More...
 
struct  JQueries
 Auxiliary method to get list of table names. More...
 
struct  JToAshort
 
struct  JUPI
 Universal product identifier (UPI). More...
 
struct  JVendorHV
 

Typedefs

typedef JEEP::JDate<'/'> JDate_t
 Type definition for integration date. More...
 
typedef JTOOLS::JRange< JDate_tJPeriod_t
 Type definition of period. More...
 

Functions

const char * getPrivateCookie ()
 Get private cookie. More...
 
const char * getPublicCookie ()
 Get public cookie. More...
 
template<class JTable_t >
const char * getTable ()
 Get table name. More...
 
template<class JTable_t , class JType_t >
const char * getColumn (JType_t JTable_t::*data_member)
 Get column name. More...
 
template<class JTable_t >
std::vector< std::string > getColumns ()
 Get column names. More...
 
ResultSet & getResultSet (const std::string &query)
 Get result set. More...
 
ResultSet & getResultSet (const std::string &query, const std::vector< Selector > &selection)
 Get result set. More...
 
template<class T >
bool operator>> (ResultSet &rs, T &object)
 Read ROOT object from result set. More...
 
template<class JElement_t , class JAllocator_t >
bool operator>> (ResultSet &rs, std::vector< JElement_t, JAllocator_t > &buffer)
 Read vector of ROOT objects from result set. More...
 
std::ostream & operator<< (std::ostream &out, const JPeriod_t &object)
 Write period to output stream. More...
 
bool operator>> (ResultSet &rs, JRunQuality &quality)
 Read data quality from result set. More...
 
bool operator< (const JRunQuality &first, const JRunQuality &second)
 Less-than operator. More...
 
bool operator< (const JRuns &first, const JRuns &second)
 Less-than operator. More...
 
const Selector::RelOp & getOperand (const int index)
 Get operand. More...
 
template<class JTypelist_t >
const std::vector< std::string > & getQueries ()
 Get list of possible queries. More...
 

Variables

static const char PREFIX_COOKIE = '_'
 Cookie prefix. More...
 
static const std::string PREFIX_DATAFILTER = "DAQ_triggerParameters"
 This string is prepended to every parameter in the database output for the corresponding process. More...
 
static const std::string PREFIX_ADF = "DAQ_ADF"
 
static const std::string SPECIAL_CHARACTERS = "!@#$%^&*()-+=[]{};:'\"\\|,.<>/?"
 Special characters. More...
 
static const JDetectorsHelpergetDetector = JDetectorsHelper::getInstance()
 Function object for mapping serial number and object identifier of detectors. More...
 
static const Selector::RelOp *const OPERAND []
 Available operands. More...
 
static const int NUMBER_OF_OPERANDS = sizeof(OPERAND) / sizeof(OPERAND[0])
 Number of available operands. More...
 

Detailed Description

Auxiliary classes and methods for database I/O.

Author
mdejong

Typedef Documentation

Type definition for integration date.

Definition at line 39 of file JDetectorIntegration_t.hh.

Type definition of period.

Definition at line 45 of file JDetectorIntegration_t.hh.

Function Documentation

const char* JDATABASE::getPrivateCookie ( )
inline

Get private cookie.

Returns
cookie

Definition at line 37 of file JDB.hh.

38  {
39  const char* home = getenv("HOME");
40 
41  return MAKE_CSTRING((home != NULL ? home : ".") << "/" << ".km3netdb_cookie");
42  }
#define MAKE_CSTRING(A)
Make C-string.
Definition: JPrint.hh:708
const char* JDATABASE::getPublicCookie ( )
inline

Get public cookie.

Returns
cookie

Definition at line 50 of file JDB.hh.

51  {
52  return getenv("DBCOOKIE");
53  }
template<class JTable_t >
const char* JDATABASE::getTable ( )
inline

Get table name.

Returns
table name

Definition at line 200 of file JDB.hh.

201  {
202  return JTable_t::getName();
203  }
const char * getName()
Get ROOT name of given data type.
Definition: JRootToolkit.hh:53
template<class JTable_t , class JType_t >
const char* JDATABASE::getColumn ( JType_t JTable_t::*  data_member)
inline

Get column name.

Parameters
data_memberdata member
Returns
column name

Definition at line 213 of file JDB.hh.

214  {
215  JTable_t* pc = NULL;
216  TClass* rc = dynamic_cast<TClass*>(TDictionary::GetDictionary(typeid(JTable_t)));
217 
218  if (rc != NULL) {
219 
220  TIterator* i = rc->GetListOfDataMembers()->MakeIterator();
221 
222  for (const TDataMember* p; (p = (const TDataMember*) i->Next()) != NULL; ) {
223 
224  if (p->GetOffset() == (char*) &(pc->*data_member) - (char*) pc) {
225  return p->GetName();
226  }
227  }
228  }
229 
230  return NULL;
231  }
template<class JTable_t >
std::vector<std::string> JDATABASE::getColumns ( )
inline

Get column names.

Returns
column names

Definition at line 240 of file JDB.hh.

241  {
242  using namespace JPP;
243 
245 
246  TClass* rc = dynamic_cast<TClass*>(TDictionary::GetDictionary(typeid(JTable_t)));
247 
248  if (rc != NULL) {
249 
250  TIterator* i = rc->GetListOfDataMembers()->MakeIterator();
251 
252  for (const TDataMember* p; (p = (const TDataMember*) i->Next()) != NULL; ) {
253  if (JRootClass::is_class(*p)) {
254  buffer.push_back(p->GetName());
255  }
256  }
257  }
258 
259  return buffer;
260  }
static bool is_class(const char *const class_name)
Check class name against ROOT class names.
Definition: JRootClass.hh:47
ResultSet& JDATABASE::getResultSet ( const std::string &  query)
inline

Get result set.

Parameters
queryquery / table name
Returns
result set

Definition at line 269 of file JDB.hh.

270  {
271  return JDB::get()->StreamDS(query.c_str(), std::vector<Selector>());
272  }
T get(const JHead &header)
Get object from header.
ResultSet& JDATABASE::getResultSet ( const std::string &  query,
const std::vector< Selector > &  selection 
)
inline

Get result set.

Parameters
queryquery / table name
selectionselection
Returns
result set

Definition at line 282 of file JDB.hh.

283  {
284  return JDB::get()->StreamDS(query.c_str(), selection);
285  }
T get(const JHead &header)
Get object from header.
template<class T >
bool JDATABASE::operator>> ( ResultSet &  rs,
T object 
)
inline

Read ROOT object from result set.

Parameters
rsresult set
objectobject
Returns
true if read; else false

Definition at line 122 of file JDBReader.hh.

123  {
124  static JDBReader<T> reader;
125 
126  if (rs.Next()) {
127 
128  object = reader(rs);
129 
130  return true;
131  }
132 
133  return false;
134  }
Auxiliary class to read ROOT object from database.
Definition: JDBReader.hh:43
template<class JElement_t , class JAllocator_t >
bool JDATABASE::operator>> ( ResultSet &  rs,
std::vector< JElement_t, JAllocator_t > &  buffer 
)
inline

Read vector of ROOT objects from result set.

Parameters
rsresult set
buffer
Returns
true if read; else false

Definition at line 145 of file JDBReader.hh.

146  {
147  for (JElement_t object; rs >> object; ) {
148  buffer.push_back(object);
149  }
150 
151  return true;
152  }
std::ostream& JDATABASE::operator<< ( std::ostream &  out,
const JPeriod_t object 
)
inline

Write period to output stream.

Parameters
outoutput stream
objectperiod
Returns
output stream

Definition at line 55 of file JDetectorIntegration_t.hh.

56  {
57  return out << "(" << object.getLowerLimit() << "," << object.getUpperLimit() << ")";
58  }
bool JDATABASE::operator>> ( ResultSet &  rs,
JRunQuality &  quality 
)

Read data quality from result set.

Parameters
rsresult set
qualityquality
Returns
true if read; else false

Definition at line 59 of file JRunQuality.cc.

60  {
61  using namespace std;
62  using namespace JPP;
63 
64  quality.run = -1;
65 
66  for (JRunSummaryNumbers parameters; ; ) {
67 
68  bool has_next = false;
69 
70  try {
71  has_next = (rs >> parameters);
72  }
73  catch(const exception& error) {
74  has_next = false;
75  }
76 
77  if (parameters.RUN != quality.run || !has_next) {
78 
79  if (quality.run != -1) {
80 
81  return true;
82 
83  } else if (!has_next) {
84 
85  rs.Close();
86 
87  return false;
88  }
89 
90  quality = JRunQuality();
91  quality.GIT = parameters.SOURCE_NAME;
92  quality.detector = getDetector(parameters.DETID);
93  quality.run = parameters.RUN;
94  }
95 
96  quality.put(parameters.PARAMETER_NAME, parameters.DATA_VALUE);
97  }
98  }
*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
static const JDetectorsHelper & getDetector
Function object for mapping serial number and object identifier of detectors.
Definition: JDBToolkit.hh:131
bool JDATABASE::operator< ( const JRunQuality first,
const JRunQuality second 
)
inline

Less-than operator.

Parameters
firstfirst run quaility
secondsecond run quaility
Returns
true if first run quality less than second; else false

Definition at line 149 of file JRunQuality.hh.

151  {
152  if (first.detector == second.detector)
153  return first.run < second.run;
154  else
155  return first.detector < second.detector;
156  }
bool JDATABASE::operator< ( const JRuns first,
const JRuns second 
)
inline

Less-than operator.

Parameters
firstfirst run
secondsecond run
Returns
true if first run less than second; else false

Definition at line 56 of file JRuns.hh.

58  {
59  if (first.DETID == second.DETID)
60  return first.RUN < second.RUN;
61  else
62  return first.DETID < second.DETID;
63  }
int DETID
constraint
Definition: JRuns.hh:22
const Selector::RelOp& JDATABASE::getOperand ( const int  index)
inline

Get operand.

Parameters
indexindex
Returns
operand

Definition at line 55 of file JDB/JSelector.hh.

56  {
57  if (index >= 0 && index <= NUMBER_OF_OPERANDS)
58  return *OPERAND[index];
59  else
60  THROW(JIndexOutOfRange, "Invalid index " << index);
61  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:670
static const int NUMBER_OF_OPERANDS
Number of available operands.
static const Selector::RelOp *const OPERAND[]
Available operands.
template<class JTypelist_t >
const std::vector<std::string>& JDATABASE::getQueries ( )
inline

Get list of possible queries.

Returns
list of possible queries

Definition at line 239 of file JDB/JSupport.hh.

240  {
241  static const JQueries<JTypelist_t> buffer;
242 
243  return buffer;
244  }

Variable Documentation

const char JDATABASE::PREFIX_COOKIE = '_'
static

Cookie prefix.

Definition at line 59 of file JDB.hh.

const std::string JDATABASE::PREFIX_DATAFILTER = "DAQ_triggerParameters"
static

This string is prepended to every parameter in the database output for the corresponding process.

Definition at line 65 of file JDB.hh.

const std::string JDATABASE::PREFIX_ADF = "DAQ_ADF"
static

Definition at line 66 of file JDB.hh.

const std::string JDATABASE::SPECIAL_CHARACTERS = "!@#$%^&*()-+=[]{};:'\"\\|,.<>/?"
static

Special characters.

Definition at line 33 of file JDBReader.hh.

const JDetectorsHelper& JDATABASE::getDetector = JDetectorsHelper::getInstance()
static

Function object for mapping serial number and object identifier of detectors.

Definition at line 131 of file JDBToolkit.hh.

const Selector::RelOp* const JDATABASE::OPERAND[]
static
Initial value:
=
{
&Selector::RelOp::Equal,
&Selector::RelOp::Different,
&Selector::RelOp::Less,
&Selector::RelOp::LessEqual,
&Selector::RelOp::Greater,
&Selector::RelOp::GreaterEqual
}

Available operands.

Definition at line 32 of file JDB/JSelector.hh.

const int JDATABASE::NUMBER_OF_OPERANDS = sizeof(OPERAND) / sizeof(OPERAND[0])
static

Number of available operands.

Definition at line 46 of file JDB/JSelector.hh.