#include #include #include "ISlowControlDatabase.hxx" #include "gscUtils.hxx" #include "odbGscUtils.hxx" #include #include #include /// Example program shows how to access FGD 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 data event (note: we need to skip /// over the event with the ODB dump, since it does not have a valid partition code). class ITpcODBInformationLoop: public COMET::ICOMETEventLoopFunction { bool firstEvent; public: ITpcODBInformationLoop() { firstEvent = true; } virtual ~ITpcODBInformationLoop() {} // Only need to grab data for first event. bool operator () (COMET::ICOMETEvent& event) { // Skip first event, since it is useless ODB dump. // ODB dump has the wrong partition code. if(firstEvent){ firstEvent = false; return true; } // 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 FGD_editonstart, FGD_Runinfo and TPC_Laser. ISlowControlMySQLRow* rowEditOnStart = ISlowControlDatabase::Get().GetTable(utime,"FGD_editonstart"); ISlowControlMySQLRow* rowRunInfo = ISlowControlDatabase::Get().GetTable(utime,"FGD_Runinfo"); ISlowControlMySQLRow* rowCMBSettings = ISlowControlDatabase::Get().GetTable(utime,"FGD_CMB_Settings"); ISlowControlMySQLRow* rowCTMSettings = ISlowControlDatabase::Get().GetTable(utime,"FGD_CTM0"); // 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 FGD run:\n" << "Partition run number = " << rowRunInfo->GetValueString("Runnumber") << " taken at time " << rowEditOnStart->GetValueInteger("_i_time") << " " << rowCMBSettings->GetValueInteger("_i_time") << std::endl; std::cout << "Comments : " << rowEditOnStart->GetValueString("Comments") << std::endl; std::cout << "ExpTrigger : " << rowEditOnStart->GetValueString("ExpTrigger") << std::endl; std::cout << "Operators : " << rowEditOnStart->GetValueString("Operators") << std::endl; std::cout << "Keep Dark Noise Fraction : " << rowCMBSettings->GetValueInteger("KeepDarkNoise") << std::endl; std::cout << "Pulse Finder Threshold : " << rowCMBSettings->GetValueInteger("PulseFindThreshold") << std::endl; std::cout << "CMB ASUM Trigger Multiplicity : " << rowCMBSettings->GetValueInteger("cmbAsumMultiplicity") << std::endl; std::cout << "SCA Delay (beam) : " << rowCMBSettings->GetValueInteger("femScaStopBeamDelay") << std::endl; std::cout << "SCA Delay (cosmic) : " << rowCMBSettings->GetValueInteger("femScaStopCosmicDelay") << std::endl; std::cout << "SCA Delay (LED) : " << rowCMBSettings->GetValueInteger("femScaStopLEDDelay") << std::endl; std::cout << "SCA Delay (test) : " << rowCMBSettings->GetValueInteger("femScaStopTestDelay") << std::endl; std::cout << "Cosmic Trigger Algorithm : " << rowCTMSettings->GetValueInteger("CosmicTriggerAlgorithm") << std::endl; // Get some of the same information, but using an alternate access method, where we explicitly // check the event context matchs what is stored in the database. int retr = odbGscUtils::GetODBVarInteger(event.GetContext(),"FGD_CMB_Settings","KeepDarkNoise"); if(retr == odbGscUtils::odb_gsc_error){ std::cout << "The ODB information does not appear to be available for this context." << std::endl; exit(0); }else{ std::cout << "Alternate way of getting dark noise fraction: " << retr << std::endl; std::cout << "Alternate way of getting comment: " << odbGscUtils::GetODBVarString(event.GetContext(),"FGD_editonstart","Comments") << std::endl; } exit(0); return true; } }; int main(int argc, char **argv) { ITpcODBInformationLoop userCode; cometEventLoop(argc,argv,userCode); }