// // Program to read a file containing an set of beamline database numbers // and insert them in a database. // The access is by specific run and version (simple keyed access). // // To run the program: // checkout the Alignment package // gmake Alignment.tbin // // bin/$BFARCH/AlFillDB DATABASE_IDENTIFIER RUN VERSION beam_filename // // The file is in the format defined by the DB container // // 11/00 Ray Culbertson, from an example by Mark Lancaster // // ----------------------------------------------------------------------- // #include #include #include #include //#include "Alignment/CotBeam.hh" #include "CalibDB/RunListKey.hh" #include "AlignmentDB/CotBeamPosition.Defs.hh" using namespace std; int main(int argc, char* argv[]) { if (argc < 6) { std::cerr << " Wrong # I/P arguments : format: " << std::endl << " [database_id] [run] [version] [status] [COT Beam file] " << std::endl << " (version < 0 implies next version) " << std::endl; return -1; } string dbid(argv[1]); int run = atoi(argv[2]); int version = atoi(argv[3]); CotBeamPositionContainer contDB; CotBeamPosition_mgr iomBeam(dbid,"CotBeamPosition"); if(iomBeam.isValid()==false) { std::cerr << " ERROR: CotBeamPosition_mgr initialization failure " << std::endl; return -1; } // Create a CalibKey for run, version RunListKey qk(run,version) ; qk.setDataStatus(string(argv[4])); if(version<0) qk.newVersion(); contDB.clear(); CotBeamPosition beam; std::ifstream is(argv[5],ios::in); is >> beam; std::cout << beam << std::endl; is.close(); contDB.push_back(beam); if(iomBeam.put(qk,contDB)!=Result::success) { std::cerr << " ERROR: Put failed for CotBeamPosition Run = " << run << std::endl; return -1; } std::cout << " Filled CotBeamPosition" << std::endl; //now read it back CotBeamPositionContainer_ptr gcont; qk.latestVersion(); if(iomBeam.get(qk, gcont)!=Result::success) { std::cerr << "ERROR: Failed to retrieve calibration" << std::endl; return -1; } std::cout << std::endl << "The follwing should be the created table" << std::endl; std::cout << endl << "CALIBRUNLIST row got (as stored in container)"<< std::endl << "Run = " << gcont->run() << std::endl << "Version = " << gcont->version() << std::endl << "CID = " << gcont->id() << std::endl << "Table = " << gcont->table() << std::endl << "Period = " << gcont->period() << std::endl << "Status = " << gcont->dataStatus() << endl << endl << std::endl ; return 0; }