// // 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/SvxBeamFillDB 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 "AlignmentDB/SvxBeam.hh" #include "AlignmentDB/SvxBeamPosition.Defs.hh" using namespace std; int main(int argc, char* argv[]) { if (argc < 6) { std::cerr << " Wrong # I/P arguments : format: " << std::endl << argv[0] << " [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]); SvxBeamPositionContainer contDB; SvxBeamPosition_mgr iomBeam(dbid,"SvxBeamPosition"); if(iomBeam.isValid()==false) { std::cerr << " ERROR: SvxBeamPosition_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(); SvxBeamPosition beam; std::ifstream is(argv[5]); is >> beam; while(!is.eof()) { std::cout << "Dump of file contents" << std::endl; std::cout << beam << std::endl; contDB.push_back(beam); is >> beam; } is.close(); if(iomBeam.put(qk,contDB)!=Result::success) { std::cerr << " ERROR: Put failed for SvxBeamPosition Run = " << run << std::endl; return -1; } std::cout << " Filled SvxBeamPosition" << std::endl; //now read it back SvxBeamPositionContainer_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; RunListKey k = gcont->key(); std::cout << endl << "CALIBRUNLIST row got (as stored in container)"<< std::endl << "Run = " << k.run() << std::endl << "Version = " << k.version() << std::endl << "CID = " << k.id() << std::endl << "Table = " << k.table() << std::endl << "Period = " << k.period() << std::endl << "Status = " << k.dataStatus() << endl << endl << std::endl ; return 0; }