// // 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 #include "DBObjects/TimeStampDefs.hh" #include "CalibDB/RunListDefs.hh" #include "Alignment/SvxBeam.hh" #include "Alignment/CotBeam.hh" #include "AlignmentDB/SvxBeamPosition.Defs.hh" #include "CalibDB/RunListDefs.hh" using namespace std; int main(int argc, char* argv[]) { if (argc < 4) { std::cerr << " Wrong # of arguments : format = " << argv[0] ; std::cerr << " mode first_run last_run" << std::endl; return -1; } int mode = atoi(argv[1]); int firstRun = atoi(argv[2]); int lastRun = atoi(argv[3]); std::string dbid("onotl_prd"); // find the valid entries int* goodrunc; int ngoodc=0; int* goodruns; int ngoods=0; RunList_mgr runIom(dbid,"RunList"); if( !runIom.isValid() ) {std::cerr<< "Error opening RunList database" << std::endl;} RunListKey rlk("CotBeamPosition","UNDEFINED", Run::undefined,Version::undefined, PrimType::undefined, "UNDEFINED"); RunList_var row; if(runIom.get(rlk,row)!=Result::success) { std::cerr << "Failure of runIom.get() to retrieve db contents" << std::endl; } goodrunc = new int[row->size()]; for(RunList::iterator iter=row->begin(); iter!=row->end(); iter++) { if(iter->run()>=firstRun && iter->run()<=lastRun) { goodrunc[ngoodc++] = iter->run(); } } rlk.setTable("SvxBeamPosition"); if(runIom.get(rlk,row)!=Result::success) { std::cerr << "Failure of runIom.get() to retrieve db contents" << std::endl; } goodruns = new int[row->size()]; for(RunList::iterator iter=row->begin(); iter!=row->end(); iter++) { if(iter->run()>=firstRun && iter->run()<=lastRun) { bool matchc=false; for(int i=0; irun()) matchc=true; } if(matchc) { goodruns[ngoods++] = iter->run(); } else { std::cout << " found a run with svx but not cot: "<< iter->run() << std::endl; } } } std::cout << "Found "<< ngoodc << " cot entries" << std::endl; std::cout << "Found "<< ngoods << " svx entries" << std::endl; SvxBeam svxBeam("default"); CotBeam cotBeam("default"); SvxBeamPositionContainer scont; SvxBeamPosition_mgr siom(dbid,"SvxBeamPosition"); CotBeamPositionContainer ccont; CotBeamPosition_mgr ciom(dbid,"CotBeamPosition"); if(mode==0) { // 100030 scont.addParent(RunListKey(CID(99668))); scont.addParent(RunListKey(CID(99670))); scont.addParent(RunListKey(CID(99672))); scont.addParent(RunListKey(CID(99674))); scont.addParent(RunListKey(CID(99676))); for(int run=firstRun; run<=lastRun; run++) { bool ok = false; for(int i=0; i=152595 && run<=154012) { // fix wrong alignment svx._BeamX += -0.00519; svx._BeamY += 0.01261; svx._SlopeX += -0.0000041; svx._SlopeY += 0.0000398; } else { // fix bias svx._BeamX += -0.0004; svx._BeamY += 0.0025; svx._SlopeX += -0.000015; svx._SlopeY += 0.000030; } // put it back in db RunListKey qk(run,-1) ; qk.setDataStatus("GOOD"); qk.newVersion(); qk.setAlgorithm("4.8.4a"); scont.clear(); ccont.clear(); scont.push_back(svx); ccont.push_back(cot); if(siom.put(qk,scont)!=Result::success) { std::cerr << " ERROR: Put failed for SvxBeamPosition Run = " << run << std::endl; } if(ciom.put(qk,ccont)!=Result::success) { std::cerr << " ERROR: Put failed for CotBeamPosition Run = " << run << std::endl; } } else { std::cout << "Could not find history 17 " << run << " cot: "<< cotBeam.isValid() << " svx: "<< svxBeam.isValid() << std::endl; } // end both beamlines retrieved } // end ok } // end run loop } // endif mode=0 if(mode==1) { for(int run=firstRun; run<=lastRun; run++) { bool ok = false; for(int i=0; i SvxBeamPositionContainer; // ********** cot beam ccont.clear(); cotBeam.setHistoryCode(19); cotBeam.loadRun(run); if(cotBeam.isValid()) { CotBeamPositionContainer oldCont = cotBeam.getContainer(); for(int ic=0; ic