//////////////////////////////////////////////////////////////////// /// \file ratdb_example.cc /// /// \brief A few functions to show how to access the database from ROOT /// /// \author N Barros /// /// REVISION HISTORY:\n /// 2017-03-16 : N Barros - First Revision. /// /// \details Just a couple of functions showing how to query the database /// to extract some useful information /// //////////////////////////////////////////////////////////////////// #include #include #include #include #include void GetRunRange(const int& run = 14229) { RAT::DB *db = RAT::DB::Get(); // This is not really needed, unless we want to revert to some default // if a table is not found in the remote server db->LoadDefaults(); db->SetServer("postgres://snoplus@pgsql.snopl.us:5400/ratdb"); // Create a run object to initialize the database to the appropriate run RAT::DS::Run Run; Run.SetRunID(run); db->BeginOfRun(Run); RAT::DBLinkPtr dblink = db->GetLink("PMT_DQXX"); std::vector run_range = dblink->GetIArray("run_range"); std::cout << "Table PMT_DQXX object has a run range of [ " << run_range.at(0) << " , " << run_range.at(1) << " ]" << std::endl; // -- Now perform the same check about the ECA_TSLP dblink = db->GetLink("ECA_TSLP","6_500"); run_range = dblink->GetIArray("run_range"); std::cout << "Table ECA_TSLP[6_500] object has a run range of [ " << run_range.at(0) << " , " << run_range.at(1) << " ]" << std::endl; }