// // Program to create a file containing an set of beam position numbers // after reading them from 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/SvxBeamReadDB DATABASE_IDENTIFIER RUN VERSION beam_filename // // The file is in the format define by the Db container operator << // // 11/00 Ray Culbertson, from an example by Mark Lancaster // // ----------------------------------------------------------------------- // #include #include #include #include // --> Classes defining a row & managers of TIMESTAMP & the Key #include "DBObjects/TimeStampDefs.hh" // --> Classes defining a row & managers of CALIBRUNLISTS + the Key #include "CalibDB/RunListDefs.hh" // --> The actual table definition -- code generated from java #include "AlignmentDB/SvxBeamPosition.Defs.hh" using namespace std; int main(int argc, char* argv[]) { if (argc < 6) { std::cerr << " Wrong # of arguments : format = " << argv[0] << std::endl; std::cerr << " [database_id] [run] [version] [status] [beam file]" << std::endl; return -1; } string dbid(argv[1]); int run = atoi(argv[2]); int version = atoi(argv[3]); SvxBeamPositionContainer_ptr gcont; SvxBeamPosition_mgr iom(dbid,"SvxBeamPosition"); if(iom.isValid()==false) { std::cerr << " ERROR: SvxBeamPosition_mgr initialisation failure " << std::endl; return -1; } // Create a CalibKey for run, version RunListKey qk(run,version); qk.setDataStatus(string(argv[4])); if(version<0) qk.latestVersion(); if(iom.get(qk, gcont)!=Result::success) { std::cerr << "ERROR: Failed to retrieve calibration" << std::endl; return -1; } 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 << "Status = " << k.dataStatus() << endl << endl << std::endl ; ofstream os(argv[5]); SvxBeamPositionContainer::iterator pi = gcont->begin(); while(pi!=gcont->end()) { SvxBeamPosition beam = *pi; os << beam; std::cout << "Dump of contents:" << std::endl; std::cout << beam << std::endl; pi++; } os.close(); return 0; }