QwAnalysis
QwParityDB Class Reference

#include <QwParityDB.h>

+ Inheritance diagram for QwParityDB:
+ Collaboration diagram for QwParityDB:

Public Member Functions

 QwParityDB ()
 Simple constructor. More...
 
 QwParityDB (QwOptions &options)
 Constructor with QwOptions object. More...
 
virtual ~QwParityDB ()
 Destructor. More...
 
void SetupOneRun (QwEventBuffer &qwevt)
 
void FillParameterFiles (QwSubsystemArrayParity &subsys)
 
UInt_t GetMonitorID (const string &name, Bool_t zero_id_is_error=kTRUE)
 
UInt_t GetMainDetectorID (const string &name, Bool_t zero_id_is_error=kTRUE)
 
UInt_t GetLumiDetectorID (const string &name, Bool_t zero_id_is_error=kTRUE)
 
const string GetMeasurementID (const Int_t index)
 
UInt_t GetSlowControlDetectorID (const string &name)
 
UInt_t GetErrorCodeID (const string &name)
 
UInt_t GetRunNumber ()
 
UInt_t GetSegmentNumber ()
 
UInt_t GetRunID ()
 
UInt_t GetRunletID ()
 
UInt_t GetAnalysisID ()
 
UInt_t GetRunID (QwEventBuffer &qwevt)
 
UInt_t GetRunletID (QwEventBuffer &qwevt)
 
UInt_t GetAnalysisID (QwEventBuffer &qwevt)
 
Bool_t SetRunNumber (const UInt_t runnum)
 
Bool_t SetSegmentNumber (const UInt_t segment)
 
void ProcessAdditionalOptions (QwOptions &options)
 Processes the options contained in the QwOptions object. More...
 
- Public Member Functions inherited from QwDatabase
 QwDatabase (const string &major="00", const string &minor="00", const string &point="0000")
 Simple constructor. More...
 
 QwDatabase (QwOptions &options, const string &major="00", const string &minor="00", const string &point="0000")
 Constructor with QwOptions object. More...
 
virtual ~QwDatabase ()
 Destructor. More...
 
void SetAccessLevel (string accesslevel)
 Sets the access level flag based on string labels: "off", "ro", "rw". More...
 
Bool_t AllowsReadAccess ()
 
Bool_t AllowsWriteAccess ()
 
Bool_t Connect ()
 Open a connection to the database using the predefined parameters. More...
 
void Disconnect ()
 
Bool_t Connected ()
 
const string GetServerVersion ()
 
void ProcessOptions (QwOptions &options)
 Processes the options contained in the QwOptions object. More...
 
void ProcessOptions (const TString &dbname, const TString &username, const TString &passwd, const TString &dbhost="localhost", const Int_t dbport=0, const TString &accesslevel="ro")
 Processes database options. More...
 
mysqlpp::Query Query (const char *qstr=0)
 
mysqlpp::Query Query (const std::string &qstr)
 
const string GetVersion ()
 
const string GetVersionMajor ()
 Return a full version string for the DB schema. More...
 
const string GetVersionMinor ()
 
const string GetVersionPoint ()
 
const string GetValidVersion ()
 
void PrintServerInfo ()
 

Static Public Member Functions

static void DefineAdditionalOptions (QwOptions &options)
 Defines QwParityDB-specific class options for QwOptions. More...
 
- Static Public Member Functions inherited from QwDatabase
static void DefineOptions (QwOptions &options)
 Defines available class options for QwOptions. More...
 

Private Member Functions

UInt_t SetRunID (QwEventBuffer &qwevt)
 
UInt_t SetRunletID (QwEventBuffer &qwevt)
 
UInt_t SetAnalysisID (QwEventBuffer &qwevt)
 
void StoreMonitorIDs ()
 
void StoreMainDetectorIDs ()
 
void StoreLumiDetectorIDs ()
 
void StoreMeasurementIDs ()
 
void StoreSlowControlDetectorIDs ()
 
void StoreErrorCodeIDs ()
 

Private Attributes

UInt_t fRunNumber
 Run number of current run. More...
 
Int_t fSegmentNumber
 CODA file segment number of current run. More...
 
UInt_t fRunID
 run_id of current run More...
 
UInt_t fRunletID
 runlet_id of current run More...
 
UInt_t fAnalysisID
 analysis_id of current analysis pass More...
 
bool fDisableAnalysisCheck
 Flag to disable pre-existing analysis_id check. More...
 

Static Private Attributes

static std::map< string,
unsigned int > 
fMonitorIDs
 Associative array of beam monitor IDs. This declaration will be a problem if QwDatabase is used to connect to two databases simultaneously. More...
 
static std::map< string,
unsigned int > 
fMainDetectorIDs
 Associative array of main detector IDs. This declaration will be a problem if QwDatabase is used to connect to two databases simultaneously. More...
 
static std::map< string,
unsigned int > 
fLumiDetectorIDs
 Associative array of LUMI detector IDs. This declaration will be a problem if QwDatabase is used to connect to two databases simultaneously. More...
 
static std::map< string,
unsigned int > 
fSlowControlDetectorIDs
 Associative array of slow controls data IDs. This declaration will be a problem if QwDatabase is used to connect to two databases simultaneously. More...
 
static std::map< string,
unsigned char > 
fErrorCodeIDs
 Associative array of error code IDs. This declaration will be a problem if QwDatabase is used to connect to two databases simultaneously. More...
 
static std::vector< string > fMeasurementIDs
 

Friends

class StoreMonitorID
 
class StoreMainDetectorID
 
class StoreLumiDetectorID
 
class StoreMeasurementID
 
class StoreSlowControlDetectorID
 
class StoreErrorCodeID
 

Detailed Description

Definition at line 49 of file QwParityDB.h.

Constructor & Destructor Documentation

QwParityDB::QwParityDB ( )

Simple constructor.

The simple constructor initializes member fields. This class is not used to establish the database connection. It sets up a mysqlpp::Connection() object that has exception throwing disabled.

Definition at line 90 of file QwParityDB.cc.

References QwLog::endl(), fAnalysisID, fDisableAnalysisCheck, fRunID, fRunletID, fRunNumber, fSegmentNumber, and QwDebug.

90  : QwDatabase("01", "04", "0000")
91 {
92  QwDebug << "Greetings from QwParityDB simple constructor." << QwLog::endl;
93  // Initialize member fields
94 
95  fRunNumber = 0;
96  fRunID = 0;
97  fRunletID = 0;
98  fAnalysisID = 0;
99  fSegmentNumber = -1;
100  fDisableAnalysisCheck = false;
101 
102 }
UInt_t fRunletID
runlet_id of current run
Definition: QwParityDB.h:97
Int_t fSegmentNumber
CODA file segment number of current run.
Definition: QwParityDB.h:95
QwDatabase(const string &major="00", const string &minor="00", const string &point="0000")
Simple constructor.
bool fDisableAnalysisCheck
Flag to disable pre-existing analysis_id check.
Definition: QwParityDB.h:99
UInt_t fRunID
run_id of current run
Definition: QwParityDB.h:96
#define QwDebug
Predefined log drain for debugging output.
Definition: QwLog.h:60
UInt_t fAnalysisID
analysis_id of current analysis pass
Definition: QwParityDB.h:98
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
UInt_t fRunNumber
Run number of current run.
Definition: QwParityDB.h:94

+ Here is the call graph for this function:

QwParityDB::QwParityDB ( QwOptions options)

Constructor with QwOptions object.

The constructor initializes member fields using the values in the QwOptions object.

Parameters
optionsThe QwOptions object.

Definition at line 108 of file QwParityDB.cc.

References QwLog::endl(), fAnalysisID, fDisableAnalysisCheck, fRunID, fRunletID, fRunNumber, fSegmentNumber, ProcessAdditionalOptions(), and QwDebug.

108  : QwDatabase(options, "01", "04", "0000")
109 {
110  QwDebug << "Greetings from QwParityDB extended constructor." << QwLog::endl;
111 
112  // Initialize member fields
113  fRunNumber = 0;
114  fRunID = 0;
115  fRunletID = 0;
116  fAnalysisID = 0;
117  fSegmentNumber = -1;
118  fDisableAnalysisCheck = false;
119 
120  ProcessAdditionalOptions(options);
121 
122 }
UInt_t fRunletID
runlet_id of current run
Definition: QwParityDB.h:97
Int_t fSegmentNumber
CODA file segment number of current run.
Definition: QwParityDB.h:95
QwDatabase(const string &major="00", const string &minor="00", const string &point="0000")
Simple constructor.
bool fDisableAnalysisCheck
Flag to disable pre-existing analysis_id check.
Definition: QwParityDB.h:99
UInt_t fRunID
run_id of current run
Definition: QwParityDB.h:96
#define QwDebug
Predefined log drain for debugging output.
Definition: QwLog.h:60
UInt_t fAnalysisID
analysis_id of current analysis pass
Definition: QwParityDB.h:98
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
UInt_t fRunNumber
Run number of current run.
Definition: QwParityDB.h:94
void ProcessAdditionalOptions(QwOptions &options)
Processes the options contained in the QwOptions object.
Definition: QwParityDB.cc:891

+ Here is the call graph for this function:

QwParityDB::~QwParityDB ( )
virtual

Destructor.

The destructor says "Good-bye World!"

Definition at line 126 of file QwParityDB.cc.

References QwDatabase::Connected(), QwDatabase::Disconnect(), QwLog::endl(), and QwDebug.

127 {
128  QwDebug << "QwParityDB::~QwParityDB() : Good-bye World from QwParityDB destructor!" << QwLog::endl;
129  if( Connected() ) Disconnect();
130 }
void Disconnect()
Definition: QwDatabase.h:59
Bool_t Connected()
Definition: QwDatabase.h:60
#define QwDebug
Predefined log drain for debugging output.
Definition: QwLog.h:60
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299

+ Here is the call graph for this function:

Member Function Documentation

void QwParityDB::DefineAdditionalOptions ( QwOptions options)
static

Defines QwParityDB-specific class options for QwOptions.

Defines configuration options for QwParityDB class using QwOptions functionality.

Should apparently by called by QwOptions::DefineOptions() in QwParityOptions.h

Definition at line 877 of file QwParityDB.cc.

References QwOptions::AddOptions(), and default_bool_value.

Referenced by DefineOptionsParity().

878 {
879  // Specify command line options for use by QwParityDB
880  options.AddOptions("Parity Analyzer Database options")
881  ("QwParityDB.disable-analysis-check",
882  po::value<bool>()->default_bool_value(false),
883  "disable check of pre-existing analysis_id");
884 }
#define default_bool_value(b)
Definition: QwOptions.h:51
po::options_description_easy_init AddOptions(const std::string &blockname="Specialized options")
Add an option to a named block or create new block.
Definition: QwOptions.h:164

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QwParityDB::FillParameterFiles ( QwSubsystemArrayParity subsys)

Definition at line 563 of file QwParityDB.cc.

References QwDatabase::Connect(), QwDatabase::Disconnect(), QwLog::endl(), GetAnalysisID(), QwSubsystemArray::GetParamFileNameList(), QwDatabase::Query(), and QwError.

Referenced by main().

563  {
564  TList* param_file_list = subsys.GetParamFileNameList("mapfiles");
565  try {
566  this->Connect();
567  mysqlpp::Query query = this->Query();
568  parameter_files parameter_file_row(0);
569  parameter_file_row.analysis_id = GetAnalysisID();
570 
571  param_file_list->Print();
572  TIter next(param_file_list);
573  TList *pfl_elem;
574  while ((pfl_elem = (TList *) next())) {
575  parameter_file_row.filename = pfl_elem->GetName();
576  query.insert(parameter_file_row);
577  query.execute();
578  }
579 
580  this->Disconnect();
581 
582  delete param_file_list;
583  }
584  catch (const mysqlpp::Exception& er) {
585  QwError << er.what() << QwLog::endl;
586  this->Disconnect();
587  delete param_file_list;
588  }
589 }
void Disconnect()
Definition: QwDatabase.h:59
Bool_t Connect()
Open a connection to the database using the predefined parameters.
Definition: QwDatabase.cc:175
TList * GetParamFileNameList(TString name) const
Get list of parameter files.
UInt_t GetAnalysisID()
Definition: QwParityDB.h:71
mysqlpp::Query Query(const char *qstr=0)
Definition: QwDatabase.h:66
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
#define QwError
Predefined log drain for errors.
Definition: QwLog.h:40

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

UInt_t QwParityDB::GetAnalysisID ( QwEventBuffer qwevt)

This is a getter for analysis_id in the analysis table. Required by all queries on cerenkov, beam, etc. tables. Will return 0 if fRunID has not been successfully set. If fAnalysisID is not set, then calls code to insert into analysis table and retrieve analysis_id.

Definition at line 594 of file QwParityDB.cc.

References QwEventBuffer::AreRunletsSplit(), QwLog::endl(), fAnalysisID, fRunletID, fRunNumber, fSegmentNumber, QwEventBuffer::GetRunNumber(), QwEventBuffer::GetSegmentNumber(), QwDebug, QwError, and SetAnalysisID().

595 {
596  // Sanity check to make sure not calling this before runlet_id has been retrieved.
597  if (fRunletID == 0) {
598  QwDebug << "QwParityDB::GetAnalysisID() : fRunletID must be set before proceeding. Check to make sure run exists in database." << QwLog::endl;
599  return 0;
600  }
601 
602  if (fAnalysisID == 0 || fRunNumber != (UInt_t) qwevt.GetRunNumber()
603  || (qwevt.AreRunletsSplit() && fSegmentNumber!=qwevt.GetSegmentNumber())) {
604  QwDebug << "QwParityDB::GetAnalysisID() set fAnalysisID to " << SetAnalysisID(qwevt) << QwLog::endl;
605  if (fAnalysisID==0) {
606  QwError << "QwParityDB::SetAnalysisID() unable to set valid fAnalysisID for this run. Exiting." <<QwLog::endl;
607  exit(1);
608  }
609  }
610 
611  return fAnalysisID;
612 }
UInt_t fRunletID
runlet_id of current run
Definition: QwParityDB.h:97
Int_t fSegmentNumber
CODA file segment number of current run.
Definition: QwParityDB.h:95
Int_t GetSegmentNumber() const
Return CODA file segment number.
Definition: QwEventBuffer.h:82
UInt_t SetAnalysisID(QwEventBuffer &qwevt)
Definition: QwParityDB.cc:429
#define QwDebug
Predefined log drain for debugging output.
Definition: QwLog.h:60
UInt_t fAnalysisID
analysis_id of current analysis pass
Definition: QwParityDB.h:98
Int_t GetRunNumber() const
Return CODA file run number.
Definition: QwEventBuffer.h:80
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
UInt_t fRunNumber
Run number of current run.
Definition: QwParityDB.h:94
Bool_t AreRunletsSplit() const
Return true if file segments are being separated for.
Definition: QwEventBuffer.h:76
#define QwError
Predefined log drain for errors.
Definition: QwLog.h:40

+ Here is the call graph for this function:

UInt_t QwParityDB::GetErrorCodeID ( const string &  name)

Definition at line 725 of file QwParityDB.cc.

References QwLog::endl(), fErrorCodeIDs, QwError, and StoreErrorCodeIDs().

726 {
727  if (fErrorCodeIDs.size() == 0) {
729  }
730 
731  UInt_t error_code_id = fErrorCodeIDs[name];
732 
733  if (error_code_id==0) {
734  QwError << "QwParityDB::GetErrorCodeID() => Unable to determine valid ID for the error code " << name << QwLog::endl;
735  }
736 
737  return error_code_id;
738 
739 }
void StoreErrorCodeIDs()
Definition: QwParityDB.cc:767
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
static std::map< string, unsigned char > fErrorCodeIDs
Associative array of error code IDs. This declaration will be a problem if QwDatabase is used to conn...
Definition: QwParityDB.h:105
#define QwError
Predefined log drain for errors.
Definition: QwLog.h:40

+ Here is the call graph for this function:

UInt_t QwParityDB::GetLumiDetectorID ( const string &  name,
Bool_t  zero_id_is_error = kTRUE 
)

Definition at line 790 of file QwParityDB.cc.

References QwLog::endl(), fLumiDetectorIDs, QwError, and StoreLumiDetectorIDs().

Referenced by main(), QwDBInterface::SetDetectorID(), QwDBInterface::SetLumiDetectorID(), and QwErrDBInterface::SetLumiDetectorID().

791 {
792  if (fLumiDetectorIDs.size() == 0) {
794  }
795 
796  UInt_t lumi_detector_id = fLumiDetectorIDs[name];
797 
798  if (zero_id_is_error && lumi_detector_id==0) {
799  QwError << "QwParityDB::GetLumiDetectorID() => Unable to determine valid ID for beam lumi_detector " << name << QwLog::endl;
800  }
801 
802  return lumi_detector_id;
803 }
static std::map< string, unsigned int > fLumiDetectorIDs
Associative array of LUMI detector IDs. This declaration will be a problem if QwDatabase is used to c...
Definition: QwParityDB.h:103
void StoreLumiDetectorIDs()
Definition: QwParityDB.cc:808
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
#define QwError
Predefined log drain for errors.
Definition: QwLog.h:40

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

UInt_t QwParityDB::GetMainDetectorID ( const string &  name,
Bool_t  zero_id_is_error = kTRUE 
)

Definition at line 661 of file QwParityDB.cc.

References QwLog::endl(), fMainDetectorIDs, QwError, and StoreMainDetectorIDs().

Referenced by main(), QwDBInterface::SetDetectorID(), QwDBInterface::SetMainDetectorID(), and QwErrDBInterface::SetMainDetectorID().

662 {
663  if (fMainDetectorIDs.size() == 0) {
665  }
666 
667  UInt_t main_detector_id = fMainDetectorIDs[name];
668 
669  if (zero_id_is_error && main_detector_id==0) {
670  // main_detector_id = 19; // only for QwMockDataAnalysis
671  QwError << "QwParityDB::GetMainDetectorID() => Unable to determine valid ID for beam main_detector " << name << QwLog::endl;
672  }
673 
674  return main_detector_id;
675 
676 }
void StoreMainDetectorIDs()
Definition: QwParityDB.cc:682
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
static std::map< string, unsigned int > fMainDetectorIDs
Associative array of main detector IDs. This declaration will be a problem if QwDatabase is used to c...
Definition: QwParityDB.h:102
#define QwError
Predefined log drain for errors.
Definition: QwLog.h:40

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const string QwParityDB::GetMeasurementID ( const Int_t  index)

Definition at line 833 of file QwParityDB.cc.

References QwLog::endl(), fMeasurementIDs, QwError, and StoreMeasurementIDs().

834 {
835  if (fMeasurementIDs.size() == 0) {
837  }
838 
839  string measurement_type = fMeasurementIDs[index];
840 
841  if (measurement_type.empty()) {
842  QwError << "QwParityDB::GetMeasurementID() => Unable to determine valid ID for measurement type with " << index << QwLog::endl;
843  }
844 
845  return measurement_type;
846 }
static std::vector< string > fMeasurementIDs
Definition: QwParityDB.h:106
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
void StoreMeasurementIDs()
Definition: QwParityDB.cc:848
#define QwError
Predefined log drain for errors.
Definition: QwLog.h:40

+ Here is the call graph for this function:

UInt_t QwParityDB::GetMonitorID ( const string &  name,
Bool_t  zero_id_is_error = kTRUE 
)

Definition at line 618 of file QwParityDB.cc.

References QwLog::endl(), fMonitorIDs, QwError, and StoreMonitorIDs().

Referenced by QwBeamMod::FillDB_MPS(), main(), QwDBInterface::SetDetectorID(), QwDBInterface::SetMonitorID(), and QwErrDBInterface::SetMonitorID().

619 {
620  if (fMonitorIDs.size() == 0) {
621  StoreMonitorIDs();
622  }
623 
624  UInt_t monitor_id = fMonitorIDs[name];
625 
626  if (zero_id_is_error && monitor_id==0) {
627  // monitor_id = 6; // only for QwMockDataAnalysis
628  QwError << "QwParityDB::GetMonitorID() => Unable to determine valid ID for beam monitor " << name << QwLog::endl;
629  }
630 
631  return monitor_id;
632 
633 }
void StoreMonitorIDs()
Definition: QwParityDB.cc:638
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
static std::map< string, unsigned int > fMonitorIDs
Associative array of beam monitor IDs. This declaration will be a problem if QwDatabase is used to co...
Definition: QwParityDB.h:101
#define QwError
Predefined log drain for errors.
Definition: QwLog.h:40

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

UInt_t QwParityDB::GetRunID ( )
inline

Definition at line 69 of file QwParityDB.h.

References fRunID.

Referenced by main(), and SetupOneRun().

69 {return fRunID;} //<! Run ID getter
UInt_t fRunID
run_id of current run
Definition: QwParityDB.h:96

+ Here is the caller graph for this function:

UInt_t QwParityDB::GetRunID ( QwEventBuffer qwevt)

This is a getter for run_id in the run table. Should be used in subsequent queries to retain key relationships between tables.

Definition at line 290 of file QwParityDB.cc.

References QwLog::endl(), fAnalysisID, fRunID, fRunletID, fRunNumber, QwEventBuffer::GetRunNumber(), QwDebug, and SetRunID().

291 {
292  // If the stored run number does not agree with the CODA run number
293  // or if fRunID is not set, then retrieve data from database and update if necessary.
294 
295  // GetRunNumber() in QwEventBuffer returns Int_t, thus
296  // we should convert it to UInt_t here. I think, it is OK.
297 
298  if (fRunID == 0 || fRunNumber != (UInt_t) qwevt.GetRunNumber() ) {
299  QwDebug << "QwParityDB::GetRunID() set fRunID to " << SetRunID(qwevt) << QwLog::endl;
300  fRunletID = 0;
301  fAnalysisID = 0;
302  }
303 
304  return fRunID;
305 
306 }
UInt_t fRunletID
runlet_id of current run
Definition: QwParityDB.h:97
UInt_t SetRunID(QwEventBuffer &qwevt)
Definition: QwParityDB.cc:200
UInt_t fRunID
run_id of current run
Definition: QwParityDB.h:96
#define QwDebug
Predefined log drain for debugging output.
Definition: QwLog.h:60
UInt_t fAnalysisID
analysis_id of current analysis pass
Definition: QwParityDB.h:98
Int_t GetRunNumber() const
Return CODA file run number.
Definition: QwEventBuffer.h:80
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
UInt_t fRunNumber
Run number of current run.
Definition: QwParityDB.h:94

+ Here is the call graph for this function:

UInt_t QwParityDB::GetRunletID ( )
inline

Definition at line 70 of file QwParityDB.h.

References fRunletID.

Referenced by QwEPICSEvent::FillDB(), QwEPICSEvent::FillSlowControlsData(), QwEPICSEvent::FillSlowControlsSettings(), QwEPICSEvent::FillSlowControlsStrigs(), SetAnalysisID(), and SetupOneRun().

70 {return fRunletID;} //<! Runlet ID getter
UInt_t fRunletID
runlet_id of current run
Definition: QwParityDB.h:97

+ Here is the caller graph for this function:

UInt_t QwParityDB::GetRunletID ( QwEventBuffer qwevt)

This is a getter for runlet_id in the runlet table. Should be used in subsequent queries to retain key relationships between tables.

Definition at line 412 of file QwParityDB.cc.

References QwEventBuffer::AreRunletsSplit(), QwLog::endl(), fAnalysisID, fRunletID, fRunNumber, fSegmentNumber, QwEventBuffer::GetRunNumber(), QwEventBuffer::GetSegmentNumber(), QwDebug, and SetRunletID().

413 {
414  // If the stored run number does not agree with the CODA run number
415  // or if fRunID is not set, then retrieve data from database and update if necessary.
416 
417  if (fRunletID == 0 || (qwevt.AreRunletsSplit() && fSegmentNumber!=qwevt.GetSegmentNumber()) || fRunNumber != (UInt_t) qwevt.GetRunNumber() ) {
418  QwDebug << "QwParityDB::GetRunletID() set fRunletID to " << SetRunletID(qwevt) << QwLog::endl;
419  fAnalysisID = 0;
420  }
421 
422  return fRunletID;
423 
424 }
UInt_t fRunletID
runlet_id of current run
Definition: QwParityDB.h:97
Int_t fSegmentNumber
CODA file segment number of current run.
Definition: QwParityDB.h:95
Int_t GetSegmentNumber() const
Return CODA file segment number.
Definition: QwEventBuffer.h:82
UInt_t SetRunletID(QwEventBuffer &qwevt)
Definition: QwParityDB.cc:313
#define QwDebug
Predefined log drain for debugging output.
Definition: QwLog.h:60
UInt_t fAnalysisID
analysis_id of current analysis pass
Definition: QwParityDB.h:98
Int_t GetRunNumber() const
Return CODA file run number.
Definition: QwEventBuffer.h:80
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
UInt_t fRunNumber
Run number of current run.
Definition: QwParityDB.h:94
Bool_t AreRunletsSplit() const
Return true if file segments are being separated for.
Definition: QwEventBuffer.h:76

+ Here is the call graph for this function:

UInt_t QwParityDB::GetRunNumber ( )
inline

Definition at line 67 of file QwParityDB.h.

References fRunNumber.

Referenced by QwBlinder::ReadSeed().

67 {return fRunNumber;} //<! Run number getter
UInt_t fRunNumber
Run number of current run.
Definition: QwParityDB.h:94

+ Here is the caller graph for this function:

UInt_t QwParityDB::GetSegmentNumber ( )
inline

Definition at line 68 of file QwParityDB.h.

References fSegmentNumber.

68 {return fSegmentNumber;} //<! CODA File segment number getter
Int_t fSegmentNumber
CODA file segment number of current run.
Definition: QwParityDB.h:95
UInt_t QwParityDB::GetSlowControlDetectorID ( const string &  name)

Definition at line 706 of file QwParityDB.cc.

References QwLog::endl(), fSlowControlDetectorIDs, QwError, and StoreSlowControlDetectorIDs().

Referenced by QwEPICSEvent::FillSlowControlsData(), and QwEPICSEvent::FillSlowControlsStrigs().

707 {
708  if (fSlowControlDetectorIDs.size() == 0) {
710  }
711 
712  UInt_t sc_detector_id = fSlowControlDetectorIDs[name];
713 
714  if (sc_detector_id==0) {
715  QwError << "QwParityDB::GetSlowControlDetectorID() => Unable to determine valid ID for the epics variable " << name << QwLog::endl;
716  }
717 
718  return sc_detector_id;
719 
720 }
static std::map< string, unsigned int > fSlowControlDetectorIDs
Associative array of slow controls data IDs. This declaration will be a problem if QwDatabase is used...
Definition: QwParityDB.h:104
void StoreSlowControlDetectorIDs()
Definition: QwParityDB.cc:744
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
#define QwError
Predefined log drain for errors.
Definition: QwLog.h:40

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QwParityDB::ProcessAdditionalOptions ( QwOptions options)

Processes the options contained in the QwOptions object.

Loads the configuration options for QwParityDB class into this instance of QwParityDB from the QwOptions object.

Parameters
optionsOptions object

Definition at line 891 of file QwParityDB.cc.

References fDisableAnalysisCheck, and QwOptions::GetValue().

Referenced by QwParityDB().

892 {
893  if (options.GetValue<bool>("QwParityDB.disable-analysis-check"))
895 
896  return;
897 }
bool fDisableAnalysisCheck
Flag to disable pre-existing analysis_id check.
Definition: QwParityDB.h:99
T GetValue(const std::string &key)
Get a templated value.
Definition: QwOptions.h:240

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

UInt_t QwParityDB::SetAnalysisID ( QwEventBuffer qwevt)
private

This is used to set the appropriate analysis_id for this run. Must be a valid runlet_id in the runlet table before proceeding. Will insert an entry into the analysis table if necessary.

Definition at line 429 of file QwParityDB.cc.

References QwDatabase::Connect(), QwDatabase::Disconnect(), QwLog::endl(), fAnalysisID, fDisableAnalysisCheck, QwRunCondition::Get(), QwOptions::GetArgc(), QwOptions::GetArgv(), QwEventBuffer::GetEventRange(), GetRunletID(), gQwOptions, QwDatabase::Query(), QwError, QwMessage, and QwWarning.

Referenced by GetAnalysisID().

430 {
431 
432  // If there is already an analysis_id for this run, then let's bomb out.
433 
434  try {
435  this->Connect();
436  mysqlpp::Query query= this->Query();
437  query << "SELECT analysis_id FROM analysis WHERE beam_mode=" << mysqlpp::quote << "nbm";
438  query << " AND slope_calculation=" << mysqlpp::quote << "off";
439  query << " AND slope_correction=" << mysqlpp::quote << "off";
440  query << " AND runlet_id = " << mysqlpp::quote << this->GetRunletID(qwevt);
441 
442  mysqlpp::StoreQueryResult res = query.store();
443 
444  if (res.num_rows() != 0) {
445  QwError << "This runlet has already been analyzed by the engine!" << QwLog::endl;
446  QwError << "The following analysis_id values already exist in the database: ";
447  for (size_t i=0; i<res.num_rows(); i++) {
448  QwError << res[i][0] << " ";
449  }
450  QwError << QwLog::endl;
451 
452  if (fDisableAnalysisCheck==false) {
453  QwError << "Analysis of this run will now be terminated." << QwLog::endl;
454 
455  return 0;
456  } else {
457  QwWarning << "Analysis will continue. A duplicate entry with new analysis_id will be added to the analysis table." << QwLog::endl;
458  }
459  }
460 
461  this->Disconnect();
462  }
463  catch (const mysqlpp::Exception& er) {
464  QwError << er.what() << QwLog::endl;
465  QwError << "Unable to determine if there are other database entries for this run. Exiting." << QwLog::endl;
466  this->Disconnect();
467  return 0;
468  }
469 
470 
471  try {
472 
473  analysis analysis_row(0);
474 
475  analysis_row.runlet_id = GetRunletID(qwevt);
476  analysis_row.seed_id = 1;
477 
478  std::pair<UInt_t, UInt_t> event_range;
479  event_range = qwevt.GetEventRange();
480 
481  analysis_row.time = mysqlpp::DateTime::now();
482  analysis_row.bf_checksum = "empty"; // we will match this as a real one later
483  analysis_row.beam_mode = "nbm"; // we will match this as a real one later
484  analysis_row.n_mps = 0; // we will match this as a real one later
485  analysis_row.n_qrt = 4; // we will match this as a real one later
486  analysis_row.first_event = event_range.first;
487  analysis_row.last_event = event_range.second;
488  analysis_row.segment = 0; // we will match this as a real one later
489  analysis_row.slope_calculation = "off"; // we will match this as a real one later
490  analysis_row.slope_correction = "off"; // we will match this as a real one later
491 
492  // Analyzer Information Parsing
493  QwRunCondition run_condition(
496  "run_condition"
497  );
498 
499  run_condition.Get()->Print();
500 
501  TIter next(run_condition.Get());
502  TObjString *obj_str;
503  TString str_val, str_var;
504  Ssiz_t location;
505 
506  // Iterate over each entry in run_condition
507  while ((obj_str = (TObjString *) next())) {
508  QwMessage << obj_str->GetName() << QwLog::endl;
509 
510  // Store string contents for parsing
511  str_var = str_val = obj_str->GetString();
512  location = str_val.First(":"); // The first : separates variable from value
513  location = location + 2; // Value text starts two characters after :
514  str_val.Remove(0,location); //str_val stores value to go in DB
515 
516  // Decision tree to figure out which variable to store in
517  if (str_var.BeginsWith("ROOT Version")) {
518  analysis_row.root_version = str_val;
519  } else if (str_var.BeginsWith("ROOT file creating time")) {
520  analysis_row.root_file_time = str_val;
521  } else if (str_var.BeginsWith("ROOT file created on Hostname")) {
522  analysis_row.root_file_host = str_val;
523  } else if (str_var.BeginsWith("ROOT file created by the user")) {
524  analysis_row.root_file_user = str_val;
525  } else if (str_var.BeginsWith("QwAnalyzer Name")) {
526  analysis_row.analyzer_name = str_val;
527  } else if (str_var.BeginsWith("QwAnalyzer Options")) {
528  analysis_row.analyzer_argv = str_val;
529  } else if (str_var.BeginsWith("QwAnalyzer SVN Revision")) {
530  analysis_row.analyzer_svn_rev = str_val;
531  } else if (str_var.BeginsWith("QwAnalyzer SVN Last Changed Revision")) {
532  analysis_row.analyzer_svn_lc_rev = str_val;
533  } else if (str_var.BeginsWith("QwAnalyzer SVN URL")) {
534  analysis_row.analyzer_svn_url = str_val;
535  } else if (str_var.BeginsWith("DAQ ROC flags when QwAnalyzer runs")) {
536  analysis_row.roc_flags = str_val;
537  } else {
538  }
539  }
540  this->Connect();
541  mysqlpp::Query query= this->Query();
542  query.insert(analysis_row);
543  //QwMessage << "\nQwParityDB::SetAnalysisID() => Analysis Insert Query = " << query.str() << QwLog::endl<< QwLog::endl;
544  query.execute();
545 
546  if (query.insert_id()!=0)
547  {
548  fAnalysisID = query.insert_id();
549  }
550 
551  this->Disconnect();
552  return fAnalysisID;
553  }
554  catch (const mysqlpp::Exception& er) {
555  QwError << er.what() << QwLog::endl;
556  this->Disconnect();
557  return 0;
558  }
559 
560 
561 }
UInt_t GetRunletID()
Definition: QwParityDB.h:70
#define QwMessage
Predefined log drain for regular messages.
Definition: QwLog.h:50
void Disconnect()
Definition: QwDatabase.h:59
Bool_t Connect()
Open a connection to the database using the predefined parameters.
Definition: QwDatabase.cc:175
bool fDisableAnalysisCheck
Flag to disable pre-existing analysis_id check.
Definition: QwParityDB.h:99
QwOptions gQwOptions
Definition: QwOptions.cc:27
char ** GetArgv()
Get the vector of command line arguments.
Definition: QwOptions.h:278
std::pair< UInt_t, UInt_t > GetEventRange() const
Definition: QwEventBuffer.h:86
UInt_t fAnalysisID
analysis_id of current analysis pass
Definition: QwParityDB.h:98
mysqlpp::Query Query(const char *qstr=0)
Definition: QwDatabase.h:66
int GetArgc()
Get the number of command line arguments.
Definition: QwOptions.h:276
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
#define QwWarning
Predefined log drain for warnings.
Definition: QwLog.h:45
#define QwError
Predefined log drain for errors.
Definition: QwLog.h:40

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

UInt_t QwParityDB::SetRunID ( QwEventBuffer qwevt)
private

This function sets the fRunID for the run being replayed as determined by the QwEventBuffer class.

Definition at line 200 of file QwParityDB.cc.

References QwDatabase::Connect(), QwDatabase::Disconnect(), QwLog::endl(), fRunID, fRunNumber, MQwCodaControlEvent::GetEndUnixTime(), QwEventBuffer::GetRunNumber(), MQwCodaControlEvent::GetStartUnixTime(), QwDatabase::Query(), QwDebug, and QwError.

Referenced by GetRunID().

201 {
202 
203  // Check to see if run is already in database. If so retrieve run ID and exit.
204  try
205  {
206  this->Connect();
207  mysqlpp::Query query = this->Query();
208 
209  query << "SELECT * FROM run WHERE run_number = " << qwevt.GetRunNumber();
210  std::vector<run> res;
211  query.storein(res);
212  QwDebug << "QwParityDB::SetRunID => Number of rows returned: " << res.size() << QwLog::endl;
213 
214  // If there is more than one run in the DB with the same run number, then there will be trouble later on. Catch and bomb out.
215  if (res.size()>1)
216  {
217  QwError << "Unable to find unique run number " << qwevt.GetRunNumber() << " in database." << QwLog::endl;
218  QwError << "Run number query returned " << res.size() << "rows." << QwLog::endl;
219  QwError << "Please make sure that the database contains one unique entry for this run." << QwLog::endl;
220  this->Disconnect();
221  return 0;
222  }
223 
224  // Run already exists in database. Pull run_id and move along.
225  if (res.size()==1)
226  {
227  QwDebug << "QwParityDB::SetRunID => Run ID = " << res.at(0).run_id << QwLog::endl;
228 
229  fRunNumber = qwevt.GetRunNumber();
230  fRunID = res.at(0).run_id;
231  this->Disconnect();
232  return fRunID;
233  }
234  this->Disconnect();
235  }
236  catch (const mysqlpp::Exception& er)
237  {
238 
239  QwError << er.what() << QwLog::endl;
240  this->Disconnect();
241  return 0;
242  }
243 
244  // Run is not in database so insert pertinent data and retrieve run ID
245  // Right now this does not insert start/stop times or info on number of events.
246  try
247  {
248 
249  this->Connect();
250  run row(0);
251  row.run_number = qwevt.GetRunNumber();
252  row.run_type = "good"; // qwevt.GetRunType(); RunType is the confused name because we have also a CODA run type.
253  row.start_time = mysqlpp::DateTime(qwevt.GetStartUnixTime());
254  row.end_time = mysqlpp::DateTime(qwevt.GetEndUnixTime());
255  row.n_mps = 0;
256  row.n_qrt = 0;
257  // Set following quantities to 9999 as "uninitialized value". DTS 8/3/2012
258  row.slug = 9999;
259  row.wien_slug = 9999;
260  row.injector_slug = 9999;
261 // row.n_mps=10; // This works
262  // row.start_time = mysqlpp::null; // This works
263  // row.start_time = qwevt.GetStartSQLTime().Data(); // This does not work
264  mysqlpp::Query query=this->Query();
265  query.insert(row);
266  QwDebug<< "QwParityDB::SetRunID() => Run Insert Query = " << query.str() << QwLog::endl;
267 
268  query.execute();
269 
270  if (query.insert_id()!=0)
271  {
272  fRunNumber = qwevt.GetRunNumber();
273  fRunID = query.insert_id();
274  }
275  this->Disconnect();
276  return fRunID;
277  }
278  catch (const mysqlpp::Exception& er)
279  {
280  QwError << er.what() << QwLog::endl;
281  this->Disconnect();
282  return 0;
283  }
284 
285 }
void Disconnect()
Definition: QwDatabase.h:59
Bool_t Connect()
Open a connection to the database using the predefined parameters.
Definition: QwDatabase.cc:175
UInt_t fRunID
run_id of current run
Definition: QwParityDB.h:96
#define QwDebug
Predefined log drain for debugging output.
Definition: QwLog.h:60
mysqlpp::Query Query(const char *qstr=0)
Definition: QwDatabase.h:66
Int_t GetRunNumber() const
Return CODA file run number.
Definition: QwEventBuffer.h:80
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
UInt_t fRunNumber
Run number of current run.
Definition: QwParityDB.h:94
#define QwError
Predefined log drain for errors.
Definition: QwLog.h:40

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

UInt_t QwParityDB::SetRunletID ( QwEventBuffer qwevt)
private

This function sets the fRunletID for the run being replayed as determined by the QwEventBuffer class.

Runlets are differentiated by file segment number at the moment, not by event range or start/stop time. This function will need to be altered if we opt to differentiate between runlets in a different way.

Definition at line 313 of file QwParityDB.cc.

References QwEventBuffer::AreRunletsSplit(), QwDatabase::Connect(), QwDatabase::Disconnect(), QwLog::endl(), fRunID, fRunletID, fSegmentNumber, QwEventBuffer::GetRunNumber(), QwEventBuffer::GetSegmentNumber(), QwDatabase::Query(), QwDebug, and QwError.

Referenced by GetRunletID().

314 {
315 
316  // Make sure 'run' table has been populated and retrieve run_id
317  // UInt_t runid = this->GetRunID(qwevt);
318 
319  // Check to see if runlet is already in database. If so retrieve runlet_id and exit.
320  try
321  {
322  this->Connect();
323  mysqlpp::Query query = this->Query();
324 
325  // Query is slightly different if file segments are being chained together for replay or not.
326  if (qwevt.AreRunletsSplit()) {
328  query << "SELECT * FROM runlet WHERE run_id = " << fRunID << " AND full_run = 'false' AND segment_number = " << fSegmentNumber;
329  } else {
330  query << "SELECT * FROM runlet WHERE run_id = " << fRunID << " AND full_run = 'true'";
331  }
332 
333  std::vector<runlet> res;
334  query.storein(res);
335  QwDebug << "QwParityDB::SetRunletID => Number of rows returned: " << res.size() << QwLog::endl;
336 
337  // If there is more than one run in the DB with the same runlet number, then there will be trouble later on. Catch and bomb out.
338  if (res.size()>1)
339  {
340  QwError << "Unable to find unique runlet number " << qwevt.GetRunNumber() << " in database." << QwLog::endl;
341  QwError << "Run number query returned " << res.size() << "rows." << QwLog::endl;
342  QwError << "Please make sure that the database contains one unique entry for this run." << QwLog::endl;
343  this->Disconnect();
344  return 0;
345  }
346 
347  // Run already exists in database. Pull runlet_id and move along.
348  if (res.size()==1)
349  {
350  QwDebug << "QwParityDB::SetRunletID => Runlet ID = " << res.at(0).runlet_id << QwLog::endl;
351 
352  fRunletID = res.at(0).runlet_id;
353  this->Disconnect();
354  return fRunletID;
355  }
356  this->Disconnect();
357  }
358  catch (const mysqlpp::Exception& er)
359  {
360 
361  QwError << er.what() << QwLog::endl;
362  this->Disconnect();
363  return 0;
364  }
365 
366  // Runlet is not in database so insert pertinent data and retrieve run ID
367  // Right now this does not insert start/stop times or info on number of events.
368  try
369  {
370 
371  this->Connect();
372  runlet row(0);
373  row.run_id = fRunID;
374  row.run_number = qwevt.GetRunNumber();
375  row.start_time = mysqlpp::null;
376  row.end_time = mysqlpp::null;
377  row.first_mps = 0;
378  row.last_mps = 0;
379  if (qwevt.AreRunletsSplit()) {
380  row.segment_number = fSegmentNumber;
381  row.full_run = "false";
382  } else {
383  row.segment_number = mysqlpp::null;
384  row.full_run = "true";
385  }
386 
387  mysqlpp::Query query=this->Query();
388  query.insert(row);
389  QwDebug<< "QwParityDB::SetRunletID() => Run Insert Query = " << query.str() << QwLog::endl;
390 
391  query.execute();
392 
393  if (query.insert_id()!=0)
394  {
395  fRunletID = query.insert_id();
396  }
397  this->Disconnect();
398  return fRunletID;
399  }
400  catch (const mysqlpp::Exception& er)
401  {
402  QwError << er.what() << QwLog::endl;
403  this->Disconnect();
404  return 0;
405  }
406 
407 }
UInt_t fRunletID
runlet_id of current run
Definition: QwParityDB.h:97
Int_t fSegmentNumber
CODA file segment number of current run.
Definition: QwParityDB.h:95
Int_t GetSegmentNumber() const
Return CODA file segment number.
Definition: QwEventBuffer.h:82
void Disconnect()
Definition: QwDatabase.h:59
Bool_t Connect()
Open a connection to the database using the predefined parameters.
Definition: QwDatabase.cc:175
UInt_t fRunID
run_id of current run
Definition: QwParityDB.h:96
#define QwDebug
Predefined log drain for debugging output.
Definition: QwLog.h:60
mysqlpp::Query Query(const char *qstr=0)
Definition: QwDatabase.h:66
Int_t GetRunNumber() const
Return CODA file run number.
Definition: QwEventBuffer.h:80
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
Bool_t AreRunletsSplit() const
Return true if file segments are being separated for.
Definition: QwEventBuffer.h:76
#define QwError
Predefined log drain for errors.
Definition: QwLog.h:40

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool QwParityDB::SetRunNumber ( const UInt_t  runnum)

Sets run number for subsequent database interactions. Makes sure correct entry exists in run table and retrieves run_id.

Definition at line 158 of file QwParityDB.cc.

References QwDatabase::Connect(), QwDatabase::Disconnect(), QwLog::endl(), fRunID, fRunNumber, QwDatabase::Query(), QwDebug, and QwError.

159 {
160 
161  QwDebug << "Made it into QwParityDB::SetRunNumber()" << QwLog::endl;
162 
163  try {
164 
165  this->Connect();
166 
167  mysqlpp::Query query= this->Query();
168  query << "SELECT * FROM run WHERE run_number = " << runnum;
169  std::vector<run> res;
170  query.storein(res);
171 
172  QwDebug << "Number of rows returned: " << res.size() << QwLog::endl;
173 
174  if (res.size()!=1) {
175  QwError << "Unable to find unique run number " << runnum << " in database." << QwLog::endl;
176  QwError << "Run number query returned " << res.size() << "rows." << QwLog::endl;
177  QwError << "Please make sure that the database contains one unique entry for this run." << QwLog::endl;
178  return false;
179  }
180 
181  QwDebug << "Run ID = " << res.at(0).run_id << QwLog::endl;
182 
183  fRunNumber = runnum;
184  fRunID = res.at(0).run_id;
185 
186  this->Disconnect();
187  }
188  catch (const mysqlpp::Exception& er) {
189  QwError << er.what() << QwLog::endl;
190  return false;
191  }
192 
193  return true;
194 
195 }
void Disconnect()
Definition: QwDatabase.h:59
Bool_t Connect()
Open a connection to the database using the predefined parameters.
Definition: QwDatabase.cc:175
UInt_t fRunID
run_id of current run
Definition: QwParityDB.h:96
#define QwDebug
Predefined log drain for debugging output.
Definition: QwLog.h:60
mysqlpp::Query Query(const char *qstr=0)
Definition: QwDatabase.h:66
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
UInt_t fRunNumber
Run number of current run.
Definition: QwParityDB.h:94
#define QwError
Predefined log drain for errors.
Definition: QwLog.h:40

+ Here is the call graph for this function:

Bool_t QwParityDB::SetSegmentNumber ( const UInt_t  segment)
void QwParityDB::SetupOneRun ( QwEventBuffer qwevt)

Sets run number for subsequent database interactions. Makes sure correct entry exists in run table and retrieves run_id.

Definition at line 136 of file QwParityDB.cc.

References QwDatabase::AllowsReadAccess(), QwLog::endl(), GetAnalysisID(), GetRunID(), GetRunletID(), QwEventBuffer::GetRunNumber(), Qw::kBoldMagenta, Qw::kNormal, and QwMessage.

Referenced by main().

137 {
138  if (this->AllowsReadAccess()) {
139  UInt_t run_id = this->GetRunID(qwevt);
140  UInt_t runlet_id = this->GetRunletID(qwevt);
141  UInt_t analysis_id = this->GetAnalysisID(qwevt);
142 
143  // Write from the datebase
144  QwMessage << "QwParityDB::SetupOneRun::"
145  << " Run Number " << QwColor(Qw::kBoldMagenta) << qwevt.GetRunNumber() << QwColor(Qw::kNormal)
146  << " Run ID " << QwColor(Qw::kBoldMagenta) << run_id << QwColor(Qw::kNormal)
147  << " Runlet ID " << QwColor(Qw::kBoldMagenta) << runlet_id << QwColor(Qw::kNormal)
148  << " Analysis ID " << QwColor(Qw::kBoldMagenta) << analysis_id
149  << QwColor(Qw::kNormal)
150  << QwLog::endl;
151  }
152 }
UInt_t GetRunletID()
Definition: QwParityDB.h:70
#define QwMessage
Predefined log drain for regular messages.
Definition: QwLog.h:50
UInt_t GetAnalysisID()
Definition: QwParityDB.h:71
UInt_t GetRunID()
Definition: QwParityDB.h:69
Bool_t AllowsReadAccess()
Definition: QwDatabase.h:55
Int_t GetRunNumber() const
Return CODA file run number.
Definition: QwEventBuffer.h:80
A color changing class for the output stream.
Definition: QwColor.h:98
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QwParityDB::StoreErrorCodeIDs ( )
private

Definition at line 767 of file QwParityDB.cc.

References QwDatabase::Connect(), QwDatabase::Disconnect(), QwLog::endl(), QwDatabase::Query(), QwError, and StoreErrorCodeID.

Referenced by GetErrorCodeID().

768 {
769 
770  try {
771  this->Connect();
772  mysqlpp::Query query=this->Query();
773  query.for_each(error_code(), StoreErrorCodeID());
774 
775 // QwDebug<< "QwParityDB::SetAnalysisID() => Analysis Insert Query = " << query.str() << QwLog::endl;
776 
777  this->Disconnect();
778  }
779  catch (const mysqlpp::Exception& er) {
780  QwError << er.what() << QwLog::endl;
781  Disconnect();
782  exit(1);
783  }
784  return;
785 }
void Disconnect()
Definition: QwDatabase.h:59
Bool_t Connect()
Open a connection to the database using the predefined parameters.
Definition: QwDatabase.cc:175
mysqlpp::Query Query(const char *qstr=0)
Definition: QwDatabase.h:66
friend class StoreErrorCodeID
Definition: QwParityDB.h:113
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
#define QwError
Predefined log drain for errors.
Definition: QwLog.h:40

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QwParityDB::StoreLumiDetectorIDs ( )
private

Definition at line 808 of file QwParityDB.cc.

References QwDatabase::Connect(), QwDatabase::Disconnect(), QwLog::endl(), QwDatabase::Query(), QwError, and StoreLumiDetectorID.

Referenced by GetLumiDetectorID().

809 {
810 
811  try {
812  this->Connect();
813 
814  mysqlpp::Query query=this->Query();
815  query.for_each(lumi_detector(), StoreLumiDetectorID());
816 
817 // QwDebug<< "QwParityDB::SetAnalysisID() => Analysis Insert Query = " << query.str() << QwLog::endl;
818 
819  this->Disconnect();
820 
821  }
822  catch (const mysqlpp::Exception& er) {
823  QwError << er.what() << QwLog::endl;
824  Disconnect();
825  exit(1);
826  }
827  return;
828 }
void Disconnect()
Definition: QwDatabase.h:59
Bool_t Connect()
Open a connection to the database using the predefined parameters.
Definition: QwDatabase.cc:175
mysqlpp::Query Query(const char *qstr=0)
Definition: QwDatabase.h:66
friend class StoreLumiDetectorID
Definition: QwParityDB.h:110
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
#define QwError
Predefined log drain for errors.
Definition: QwLog.h:40

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QwParityDB::StoreMainDetectorIDs ( )
private

Definition at line 682 of file QwParityDB.cc.

References QwDatabase::Connect(), QwDatabase::Disconnect(), QwLog::endl(), QwDatabase::Query(), QwError, and StoreMainDetectorID.

Referenced by GetMainDetectorID().

683 {
684 
685  try {
686  this->Connect();
687  mysqlpp::Query query=this->Query();
688  query.for_each(main_detector(), StoreMainDetectorID());
689 
690 // QwDebug<< "QwParityDB::SetAnalysisID() => Analysis Insert Query = " << query.str() << QwLog::endl;
691 
692  this->Disconnect();
693  }
694  catch (const mysqlpp::Exception& er) {
695  QwError << er.what() << QwLog::endl;
696  Disconnect();
697  exit(1);
698  }
699  return;
700 }
void Disconnect()
Definition: QwDatabase.h:59
Bool_t Connect()
Open a connection to the database using the predefined parameters.
Definition: QwDatabase.cc:175
friend class StoreMainDetectorID
Definition: QwParityDB.h:109
mysqlpp::Query Query(const char *qstr=0)
Definition: QwDatabase.h:66
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
#define QwError
Predefined log drain for errors.
Definition: QwLog.h:40

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QwParityDB::StoreMeasurementIDs ( )
private

Definition at line 848 of file QwParityDB.cc.

References QwDatabase::Connect(), QwDatabase::Disconnect(), QwLog::endl(), QwDatabase::Query(), QwError, and StoreMeasurementID.

Referenced by GetMeasurementID().

849 {
850 
851  try {
852  this->Connect();
853 
854  mysqlpp::Query query=this->Query();
855  query.for_each(measurement_type(), StoreMeasurementID());
856 
857  // QwDebug<< "QwParityDB::SetAnalysisID() => Analysis Insert Query = " << query.str() << QwLog::endl;
858 
859  this->Disconnect();
860 
861  }
862  catch (const mysqlpp::Exception& er) {
863  QwError << er.what() << QwLog::endl;
864  Disconnect();
865  exit(1);
866  }
867  return;
868 }
void Disconnect()
Definition: QwDatabase.h:59
Bool_t Connect()
Open a connection to the database using the predefined parameters.
Definition: QwDatabase.cc:175
friend class StoreMeasurementID
Definition: QwParityDB.h:111
mysqlpp::Query Query(const char *qstr=0)
Definition: QwDatabase.h:66
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
#define QwError
Predefined log drain for errors.
Definition: QwLog.h:40

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QwParityDB::StoreMonitorIDs ( )
private

Definition at line 638 of file QwParityDB.cc.

References QwDatabase::Connect(), QwDatabase::Disconnect(), QwLog::endl(), QwDatabase::Query(), QwError, and StoreMonitorID.

Referenced by GetMonitorID().

639 {
640  try {
641 
642  this->Connect();
643  mysqlpp::Query query=this->Query();
644  query.for_each(monitor(), StoreMonitorID());
645 
646 // QwDebug<< "QwParityDB::SetAnalysisID() => Analysis Insert Query = " << query.str() << QwLog::endl;
647  this->Disconnect();
648  }
649 
650  catch (const mysqlpp::Exception& er) {
651  QwError << er.what() << QwLog::endl;
652  Disconnect();
653  exit(1);
654  }
655  return;
656 }
void Disconnect()
Definition: QwDatabase.h:59
Bool_t Connect()
Open a connection to the database using the predefined parameters.
Definition: QwDatabase.cc:175
mysqlpp::Query Query(const char *qstr=0)
Definition: QwDatabase.h:66
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
friend class StoreMonitorID
Definition: QwParityDB.h:108
#define QwError
Predefined log drain for errors.
Definition: QwLog.h:40

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QwParityDB::StoreSlowControlDetectorIDs ( )
private

Definition at line 744 of file QwParityDB.cc.

References QwDatabase::Connect(), QwDatabase::Disconnect(), QwLog::endl(), QwDatabase::Query(), QwError, and StoreSlowControlDetectorID.

Referenced by GetSlowControlDetectorID().

745 {
746 
747  try {
748  this->Connect();
749  mysqlpp::Query query=this->Query();
750  query.for_each(sc_detector(), StoreSlowControlDetectorID());
751 
752 // QwDebug<< "QwParityDB::SetAnalysisID() => Analysis Insert Query = " << query.str() << QwLog::endl;
753 
754  this->Disconnect();
755  }
756  catch (const mysqlpp::Exception& er) {
757  QwError << er.what() << QwLog::endl;
758  Disconnect();
759  exit(1);
760  }
761  return;
762 }
friend class StoreSlowControlDetectorID
Definition: QwParityDB.h:112
void Disconnect()
Definition: QwDatabase.h:59
Bool_t Connect()
Open a connection to the database using the predefined parameters.
Definition: QwDatabase.cc:175
mysqlpp::Query Query(const char *qstr=0)
Definition: QwDatabase.h:66
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
#define QwError
Predefined log drain for errors.
Definition: QwLog.h:40

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Friends And Related Function Documentation

friend class StoreErrorCodeID
friend

Definition at line 113 of file QwParityDB.h.

Referenced by StoreErrorCodeIDs().

friend class StoreLumiDetectorID
friend

Definition at line 110 of file QwParityDB.h.

Referenced by StoreLumiDetectorIDs().

friend class StoreMainDetectorID
friend

Definition at line 109 of file QwParityDB.h.

Referenced by StoreMainDetectorIDs().

friend class StoreMeasurementID
friend

Definition at line 111 of file QwParityDB.h.

Referenced by StoreMeasurementIDs().

friend class StoreMonitorID
friend

Definition at line 108 of file QwParityDB.h.

Referenced by StoreMonitorIDs().

friend class StoreSlowControlDetectorID
friend

Definition at line 112 of file QwParityDB.h.

Referenced by StoreSlowControlDetectorIDs().

Field Documentation

UInt_t QwParityDB::fAnalysisID
private

analysis_id of current analysis pass

Definition at line 98 of file QwParityDB.h.

Referenced by GetAnalysisID(), GetRunID(), GetRunletID(), QwParityDB(), and SetAnalysisID().

bool QwParityDB::fDisableAnalysisCheck
private

Flag to disable pre-existing analysis_id check.

Definition at line 99 of file QwParityDB.h.

Referenced by ProcessAdditionalOptions(), QwParityDB(), and SetAnalysisID().

std::map< string, unsigned char > QwParityDB::fErrorCodeIDs
staticprivate

Associative array of error code IDs. This declaration will be a problem if QwDatabase is used to connect to two databases simultaneously.

Definition at line 105 of file QwParityDB.h.

Referenced by GetErrorCodeID(), and StoreErrorCodeID::operator()().

std::map< string, unsigned int > QwParityDB::fLumiDetectorIDs
staticprivate

Associative array of LUMI detector IDs. This declaration will be a problem if QwDatabase is used to connect to two databases simultaneously.

Definition at line 103 of file QwParityDB.h.

Referenced by GetLumiDetectorID(), and StoreLumiDetectorID::operator()().

std::map< string, unsigned int > QwParityDB::fMainDetectorIDs
staticprivate

Associative array of main detector IDs. This declaration will be a problem if QwDatabase is used to connect to two databases simultaneously.

Definition at line 102 of file QwParityDB.h.

Referenced by GetMainDetectorID(), and StoreMainDetectorID::operator()().

std::vector< string > QwParityDB::fMeasurementIDs
staticprivate

Definition at line 106 of file QwParityDB.h.

Referenced by GetMeasurementID(), and StoreMeasurementID::operator()().

std::map< string, unsigned int > QwParityDB::fMonitorIDs
staticprivate

Associative array of beam monitor IDs. This declaration will be a problem if QwDatabase is used to connect to two databases simultaneously.

Definition at line 101 of file QwParityDB.h.

Referenced by GetMonitorID(), and StoreMonitorID::operator()().

UInt_t QwParityDB::fRunID
private

run_id of current run

Definition at line 96 of file QwParityDB.h.

Referenced by GetRunID(), QwParityDB(), SetRunID(), SetRunletID(), and SetRunNumber().

UInt_t QwParityDB::fRunletID
private

runlet_id of current run

Definition at line 97 of file QwParityDB.h.

Referenced by GetAnalysisID(), GetRunID(), GetRunletID(), QwParityDB(), and SetRunletID().

UInt_t QwParityDB::fRunNumber
private

Run number of current run.

Definition at line 94 of file QwParityDB.h.

Referenced by GetAnalysisID(), GetRunID(), GetRunletID(), GetRunNumber(), QwParityDB(), SetRunID(), and SetRunNumber().

Int_t QwParityDB::fSegmentNumber
private

CODA file segment number of current run.

Definition at line 95 of file QwParityDB.h.

Referenced by GetAnalysisID(), GetRunletID(), GetSegmentNumber(), QwParityDB(), and SetRunletID().

std::map< string, unsigned int > QwParityDB::fSlowControlDetectorIDs
staticprivate

Associative array of slow controls data IDs. This declaration will be a problem if QwDatabase is used to connect to two databases simultaneously.

Definition at line 104 of file QwParityDB.h.

Referenced by GetSlowControlDetectorID(), and StoreSlowControlDetectorID::operator()().


The documentation for this class was generated from the following files: