Jpp
Namespaces | Classes | Typedefs | Functions | Variables
JDATABASE Namespace Reference

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

Namespaces

 PBS
 

Classes

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

Typedefs

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 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...
 
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...
 
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 SPECIAL_CHARACTERS = "!@#$%^&*()-+=[]{};:'\"\\|,.<>/?"
 Special characters. 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 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

◆ JPeriod_t

Type definition of period.

Definition at line 159 of file JDetectorIntegration.hh.

Function Documentation

◆ getPrivateCookie()

const char* JDATABASE::getPrivateCookie ( )
inline

Get private cookie.

Returns
cookie

Definition at line 46 of file JDB.hh.

47  {
48  const char* home = getenv("HOME");
49 
50  return MAKE_CSTRING((home != NULL ? home : ".") << "/" << ".km3netdb_cookie");
51  }

◆ getPublicCookie()

const char* JDATABASE::getPublicCookie ( )
inline

Get public cookie.

Returns
cookie

Definition at line 59 of file JDB.hh.

60  {
61  return getenv("DBCOOKIE");
62  }

◆ operator>>() [1/3]

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 295 of file JDB.hh.

296  {
297  static JDBReader<T> reader;
298 
299  if (rs.Next()) {
300 
301  object = reader(rs);
302 
303  return true;
304  }
305 
306  return false;
307  }

◆ operator>>() [2/3]

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 318 of file JDB.hh.

319  {
320  for (JElement_t object; rs >> object; ) {
321  buffer.push_back(object);
322  }
323 
324  return true;
325  }

◆ getTable()

template<class JTable_t >
const char* JDATABASE::getTable ( )
inline

Get table name.

Returns
table name

Definition at line 334 of file JDB.hh.

335  {
336  return JTable_t::getName();
337  }

◆ getColumn()

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 347 of file JDB.hh.

348  {
349  JTable_t* pc = NULL;
350  TClass* rc = dynamic_cast<TClass*>(TDictionary::GetDictionary(typeid(JTable_t)));
351 
352  if (rc != NULL) {
353 
354  TIterator* i = rc->GetListOfDataMembers()->MakeIterator();
355 
356  for (const TDataMember* p; (p = (const TDataMember*) i->Next()) != NULL; ) {
357 
358  if (p->GetOffset() == (char*) &(pc->*data_member) - (char*) pc) {
359  return p->GetName();
360  }
361  }
362  }
363 
364  return NULL;
365  }

◆ getColumns()

template<class JTable_t >
std::vector<std::string> JDATABASE::getColumns ( )
inline

Get column names.

Returns
column names

Definition at line 374 of file JDB.hh.

375  {
376  using namespace JPP;
377 
379 
380  TClass* rc = dynamic_cast<TClass*>(TDictionary::GetDictionary(typeid(JTable_t)));
381 
382  if (rc != NULL) {
383 
384  TIterator* i = rc->GetListOfDataMembers()->MakeIterator();
385 
386  for (const TDataMember* p; (p = (const TDataMember*) i->Next()) != NULL; ) {
387  if (JRootClass::is_class(*p)) {
388  buffer.push_back(p->GetName());
389  }
390  }
391  }
392 
393  return buffer;
394  }

◆ getResultSet() [1/2]

ResultSet& JDATABASE::getResultSet ( const std::string &  query)
inline

Get result set.

Parameters
queryquery / table name
Returns
result set

Definition at line 403 of file JDB.hh.

404  {
405  return JDB::get()->StreamDS(query.c_str(), std::vector<Selector>());
406  }

◆ getResultSet() [2/2]

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 416 of file JDB.hh.

417  {
418  return JDB::get()->StreamDS(query.c_str(), selection);
419  }

◆ operator<<()

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 169 of file JDetectorIntegration.hh.

170  {
171  return out << "(" << object.getLowerLimit() << "," << object.getUpperLimit() << ")";
172  }

◆ operator>>() [3/3]

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  }

◆ operator<() [1/2]

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  }

◆ operator<() [2/2]

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  }

◆ getOperand()

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  }

◆ getQueries()

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 238 of file JDB/JSupport.hh.

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

Variable Documentation

◆ PREFIX_COOKIE

const char JDATABASE::PREFIX_COOKIE = '_'
static

Cookie prefix.

Definition at line 68 of file JDB.hh.

◆ SPECIAL_CHARACTERS

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

Special characters.

Definition at line 74 of file JDB.hh.

◆ PREFIX_DATAFILTER

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 80 of file JDB.hh.

◆ PREFIX_ADF

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

Definition at line 81 of file JDB.hh.

◆ getDetector

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.

◆ OPERAND

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.

◆ NUMBER_OF_OPERANDS

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.

JROOT::JRootClass::is_class
static bool is_class(const char *const class_name)
Check class name against ROOT class names.
Definition: JRootClass.hh:47
std::vector< std::string >
JDATABASE::NUMBER_OF_OPERANDS
static const int NUMBER_OF_OPERANDS
Number of available operands.
Definition: JDB/JSelector.hh:46
JDATABASE::getDetector
static const JDetectorsHelper & getDetector
Function object for mapping serial number and object identifier of detectors.
Definition: JDBToolkit.hh:131
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
MAKE_CSTRING
#define MAKE_CSTRING(A)
Make C-string.
Definition: JPrint.hh:708
THROW
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:669
JDATABASE::OPERAND
static const Selector::RelOp *const OPERAND[]
Available operands.
Definition: JDB/JSelector.hh:32
JDATABASE::JRunQuality::detector
int detector
Definition: JRunQuality.hh:111
JROOT::getName
const char * getName()
Get ROOT name of given data type.
Definition: JRootToolkit.hh:45
std
Definition: jaanetDictionary.h:36
JDATABASE::JRuns::RUN
int RUN
Definition: JRuns.hh:23
JAANET::get
T get(const JHead &header)
Get object from header.
Definition: JHeadToolkit.hh:295
JDATABASE::JDBReader
Auxiliary class to read ROOT object from database.
Definition: JDB.hh:216
JDATABASE::JRunQuality::run
int run
Definition: JRunQuality.hh:112
JDATABASE::JRuns::DETID
int DETID
constraint
Definition: JRuns.hh:22