#include #include #include "ISlowControlDatabase.hxx" #include "gscUtils.hxx" #include /// Example program shows how to access TPC ODB information for a single run. /// The program requires the user to provide an input file; this is only necessary /// in order to get the time stamp for the first event. class ITpcODBInformationLoop: public COMET::ICOMETEventLoopFunction { public: ITpcODBInformationLoop() {} virtual ~ITpcODBInformationLoop() {} // Only need to grab data for first event. bool operator () (COMET::ICOMETEvent& event) { // Add 5 seconds to the time for this event. int utime = event.GetContext().GetTimeStamp() + 5; std::cout << "utime for first event: " << utime << std::endl; // Get the row for the tables TPC_editonstart, TPC_DCC_Settings, TPC_Runinfo and TPC_Laser. ISlowControlMySQLRow* rowEditOnStart = ISlowControlDatabase::Get().GetTable(utime,"TPC_editonstart"); ISlowControlMySQLRow* rowSettings = ISlowControlDatabase::Get().GetTable(utime,"TPC_DCC_Settings"); ISlowControlMySQLRow* rowRunInfo = ISlowControlDatabase::Get().GetTable(utime,"TPC_Runinfo"); ISlowControlMySQLRow* rowLaser = ISlowControlDatabase::Get().GetTable(utime,"TPC_Laser"); ISlowControlMySQLRow* rowModule = ISlowControlDatabase::Get().GetTable(utime,"TPC_DCC_FEM_Module"); //ISlowControlMySQLRow* rowASIC = ISlowControlDatabase::Get().GetTable(utime,"TPC_DCC_FEM_FEC_ASIC"); ISlowControlMySQLRow* rowDCC0 = ISlowControlDatabase::Get().GetTable(utime,"TPC_DCC_0_Settings"); ISlowControlMySQLRow* rowDCC1 = ISlowControlDatabase::Get().GetTable(utime,"TPC_DCC_1_Settings"); // If row is not valid, means that we somehow ended up giving a bad timestamp. Shouldn't happen. if(!rowEditOnStart){ std::cerr << "Didn't find database row at all. " << "Indicates that ODB information not loaded for this run." << std::endl; exit(0); } // Get information and print to screen std::cout << "\n____________________________________________________________________" << std::endl; std::cout << "Information for TPC run:\n" << "Partition run number = " << rowRunInfo->GetValueString("Runnumber") << " taken at time " << rowEditOnStart->GetValueInteger("_i_time") << std::endl; std::cout << "Comments : " << rowEditOnStart->GetValueString("Comments") << std::endl; std::cout << "Purpose : " << rowEditOnStart->GetValueString("Purpose") << std::endl; std::cout << "ExpTrigger : " << rowEditOnStart->GetValueString("ExpTrigger") << std::endl; std::cout << "Operators : " << rowEditOnStart->GetValueString("Operators") << std::endl; std::cout << "Pedestal run = " << rowEditOnStart->GetValueString("Pedestalsrun") << std::endl; std::cout << "Read command : " << rowSettings->GetValueString("cmdRead") << std::endl; std::cout << "splitAreq: " << rowSettings->GetValueString("splitAreq") << std::endl; std::cout << "Laser : lowerADCCut = " << rowLaser->GetValueInteger("lowerADCCut") << ", upperADCCut = " << rowLaser->GetValueInteger("upperADCCut") << std::endl; std::cout << "FEM divideScaClockBy = " << rowModule->GetValueInteger("divideScaClockBy") << ", FEM nClocksBeforeStop = " << rowModule->GetValueInteger("nClocksBeforeStop") << std::endl; std::cout << "DCC 0 trigger type 0 latency = " << rowDCC0->GetValueInteger("TrigLat0") << std::endl; std::cout << "DCC 0 trigger type 1 latency = " << rowDCC0->GetValueInteger("TrigLat1") << std::endl; std::cout << "DCC 0 trigger type 2 latency = " << rowDCC0->GetValueInteger("TrigLat2") << std::endl; std::cout << "DCC 0 trigger type 3 latency = " << rowDCC0->GetValueInteger("TrigLat3") << std::endl; std::cout << "DCC 1 trigger type 0 latency = " << rowDCC1->GetValueInteger("TrigLat0") << std::endl; std::cout << "DCC 1 trigger type 1 latency = " << rowDCC1->GetValueInteger("TrigLat1") << std::endl; std::cout << "DCC 1 trigger type 2 latency = " << rowDCC1->GetValueInteger("TrigLat2") << std::endl; std::cout << "DCC 1 trigger type 3 latency = " << rowDCC1->GetValueInteger("TrigLat3") << std::endl; exit(0); return true; } }; int main(int argc, char **argv) { ITpcODBInformationLoop userCode; cometEventLoop(argc,argv,userCode); }