// ============================================================================= // ============================================================================= int updatercubind() { // // Update one value for an Rcu. Use bind variables. // FERODBFieldPositions *fp = new FERODBFieldPositions(); if ( fp->RcuTable->getPosition(arguments.pSelectField) < 0 ) { cerr << "*Error: Column " << arguments.pSelectField << " does not exist in RCU Table (case sensitive)!" << endl; delete fp; fp = 0; return 0; } delete fp; fp = 0; if ( arguments.pTest == true ) { ofstream *seperateOutFile = new ofstream(); seperateOutFile->open("UpdateBind.sql"); *seperateOutFile << dbq->getSqlBindUpdateRcuField(arguments.pSelectField) << endl; seperateOutFile->close(); delete seperateOutFile; } else { int32_t ctr = 0; try { int32_t pbsize = arguments.pSelectSideList.size()*arguments.pSelectSectorList.size()*arguments.pSelectRcuList.size(); pb = new ProgressBar('=', 80, pbsize, "Update RCU Table "); sw->start(); for ( uint32_t iSide=0; iSidecreateTransaction(); // Put values // set sql statement in cache db->setSQL(dbq->getSqlBindUpdateRcuField(arguments.pSelectTagList, arguments.pSelectField)); db->setNumber(0, arguments.pUpdateValue); // new value db->setNumber(1, arguments.pSelectSideList.at(iSide)); // side db->setNumber(2, arguments.pSelectSectorList.at(iSec)); // sector db->setNumber(3, arguments.pSelectRcuList.at(iRcu)); // rcu db->executeUpdate(); //db->freeResult(); pb->print(ctr++); } // end rcu loop } // end sector loop } // end side loop // mark configuration(s) as updated in TPC table db->executeUpdate(dbq->getSqlUpdateUpdated(arguments.pSelectTagList)); //db->freeResult(); delete pb; sw->stop(); cout << "updated RCU table | " << sw->formatRealTime() << " s, " << sw->formatSysTime() << "s" << endl; } catch(SQLException& ea) { cout << ea.what() << endl; return 0; } } // end if pTest return 1; } // ============================================================================= // ============================================================================= int32_t updatefecbind() { // // Update a value for one FEC. Use bind variables. // FERODBFieldPositions *fp = new FERODBFieldPositions(); if ( fp->FecTable->getPosition(arguments.pSelectField) <0 ) { cerr << "*Error: Column " << arguments.pSelectField << " does not exist in FEC Table (case sensitive)!" << endl; delete fp; fp = 0; return 0; } delete fp; fp = 0; if ( arguments.pTest == true ) { ofstream *seperateOutFile = new ofstream(); seperateOutFile->open("UpdateBind.sql"); *seperateOutFile << dbq->getSqlBindUpdateFecField(arguments.pSelectField) << endl; seperateOutFile->close(); delete seperateOutFile; } else { int32_t ctr = 0; try { int32_t pbsize = arguments.pSelectSideList.size()*arguments.pSelectSectorList.size()*arguments.pSelectRcuList.size(); pbsize *= arguments.pSelectBranchList.size()*arguments.pSelectFecList.size(); pb = new ProgressBar('=', 80, pbsize, "Update FEC Table "); sw->start(); for ( uint32_t iSide=0; iSidecreateTransaction(); // Put values // set sql statement in cache db->setSQL(dbq->getSqlBindUpdateFecField(arguments.pSelectTagList, arguments.pSelectField)); db->setNumber(0, arguments.pUpdateValue); // new value db->setNumber(1, arguments.pSelectSideList.at(iSide)); // side db->setNumber(2, arguments.pSelectSectorList.at(iSec)); // sector db->setNumber(3, arguments.pSelectRcuList.at(iRcu)); // rcu db->setNumber(4, arguments.pSelectBranchList.at(iBranch)); // branch db->setNumber(5, arguments.pSelectFecList.at(iFec)); // fec db->executeUpdate(); //db->freeResult(); pb->print(ctr++); } // end fec loop } // end branch loop } // end rcu loop } // end sector loop } // end side loop // mark configuration(s) as updated in TPC table db->executeUpdate(dbq->getSqlUpdateUpdated(arguments.pSelectTagList)); //db->freeResult(); delete pb; sw->stop(); cout << "Updated FEC table | " << sw->formatRealTime() << " s, " << sw->formatSysTime() << "s" << endl; } catch(SQLException& ea) { cout << ea.what() << endl; return 0; } } // end if pTest return 1; } // ============================================================================= // ============================================================================= int32_t updatealtrobind() { // // Update a value for one Altro. Use bind variables. // FERODBFieldPositions *fp = new FERODBFieldPositions(); if ( fp->AltroTable->getPosition(arguments.pSelectField) < 0 ) { cerr << "*Error: Column " << arguments.pSelectField << " does not exist in ALTRO Table (case sensitive)!" << endl; delete fp; fp = 0; return 0; } delete fp; fp = 0; if ( arguments.pTest == true ) { ofstream *seperateOutFile = new ofstream(); seperateOutFile->open("UpdateBind.sql"); *seperateOutFile << dbq->getSqlBindUpdateAltroField(arguments.pSelectField) << endl; seperateOutFile->close(); delete seperateOutFile; } else { int32_t ctr = 0; try { int32_t pbsize = arguments.pSelectSideList.size()*arguments.pSelectSectorList.size()*arguments.pSelectRcuList.size(); pbsize *= arguments.pSelectBranchList.size()*arguments.pSelectFecList.size()*arguments.pSelectAltroList.size(); pb = new ProgressBar('=', 80, pbsize, "Update ALTRO Table"); sw->start(); for ( uint32_t iSide=0; iSidecreateTransaction(); // Put values // set sql statement in cache db->setSQL(dbq->getSqlBindUpdateAltroField(arguments.pSelectTagList, arguments.pSelectField)); db->setNumber(0, arguments.pUpdateValue); // new value db->setNumber(1, arguments.pSelectSideList.at(iSide)); // side db->setNumber(2, arguments.pSelectSectorList.at(iSec)); // sector db->setNumber(3, arguments.pSelectRcuList.at(iRcu)); // rcu db->setNumber(4, arguments.pSelectBranchList.at(iBranch)); // branch db->setNumber(5, arguments.pSelectFecList.at(iFec)); // fec db->setNumber(6, arguments.pSelectAltroList.at(iAltro)); // altro db->executeUpdate(); //db->freeResult(); pb->print(ctr++); } // end Altro loop } // end FEC loop } // end branch loop } // end rcu loop } // end Sector loop } // end side loop // mark configuration(s) as updated in TPC table db->executeUpdate(dbq->getSqlUpdateUpdated(arguments.pSelectTagList)); //db->freeResult(); delete pb; sw->stop(); cout << "updated ALTRO table | " << sw->formatRealTime() << " s, " << sw->formatSysTime() << "s" << endl; } catch(SQLException& ea) { cout << ea.what() << endl; return 0; } } // end if pTest return 1; } // ============================================================================= // ============================================================================= int32_t updatealtroACQ_START() { // // Update all ACQ_START values for all altros with given config ID. // The values are set for all sectors (and all tags) at the same time, // since the TPC is symmetric. Here we cut out the two cones towards // low pt. Angle and offset (distance from interaction point) can be // set. // uint32_t fecPerRCUBranch[6][2] = {{9, 9}, {13, 12}, {9, 9}, {10, 10}, {10, 10}, {10, 10}}; if ( arguments.pTest == true ) { // test mode ofstream *seperateOutFile = new ofstream(); seperateOutFile->open("UpdateBind.sql"); *seperateOutFile << dbq->getSqlBindUpdateAltroField("TRCFG_ACQ_START") << endl; seperateOutFile->close(); delete seperateOutFile; } else { // real update try { // open transaction and define sql statement to be held in cache db->createTransaction(); // the query db->setSQL(dbq->getSqlBindUpdateAltroFieldAllSectors(arguments.pSelectTagList, "TRCFG_ACQ_START")); int32_t newValue = 0; Mapping pm; if ( arguments.pGeomAngle > 0. ) pm.SetAngle(arguments.pGeomAngle); if ( arguments.pGeomOffset > 0. ) pm.SetOffset(arguments.pGeomOffset); cout << "*Update all ACQ_START values for the selected tags according to geometry information:" << endl; cout << "*Angle=" << pm.GetAngle() << "deg" << endl; cout << "*Offset=" << pm.GetOffset() << "cm" << endl; cout << "*Min TimeBin=" << arguments.pGeomMinTB << endl; cout << "*Max TimeBin=" << arguments.pGeomMaxTB << endl; pb = new ProgressBar('=', 80, 121*8, "Update ALTRO Table"); sw->start(); int32_t ctr = 0; for ( uint32_t iRcu=0; iRcu<6; iRcu++ ) { for ( uint32_t iBranch=0; iBranch<2; iBranch++ ) { for ( uint32_t iFec=0; iFec (int)arguments.pGeomMaxTB ) newValue = arguments.pGeomMaxTB; db->setNumber(0, newValue); // new value db->setNumber(1, iRcu); // rcu db->setNumber(2, iBranch); // branch db->setNumber(3, iFec); // fec db->setNumber(4, iAltro); // altro db->executeUpdate(); pb->print(ctr++); } } } } // mark configuration(s) as updated in TPC table db->executeUpdate(dbq->getSqlUpdateUpdated(arguments.pSelectTagList)); delete pb; sw->stop(); cout << "updated ALTRO table | " << sw->formatRealTime() << " s, " << sw->formatSysTime() << "s" << endl; } catch(SQLException& ea) { cout << ea.what() << endl; return 0; } } return 1; } // ============================================================================= // ============================================================================= int32_t updatealtroACQ_START2() { // // Update all ACQ_START values for all altros with given config ID. // The values are set according to the specfied value, but using desyncronisation: // ALTROs 0/2, 1/3, 4/6, 5/7 have the same value. // uint32_t fecPerRCUBranch[6][2] = {{9, 9}, {13, 12}, {9, 9}, {10, 10}, {10, 10}, {10, 10}}; if ( arguments.pTest == true ) { // test mode ofstream *seperateOutFile = new ofstream(); seperateOutFile->open("UpdateBind.sql"); *seperateOutFile << dbq->getSqlBindUpdateAltroField("TRCFG_ACQ_START") << endl; seperateOutFile->close(); delete seperateOutFile; } else { // real update try { // open transaction and define sql statement to be held in cache db->createTransaction(); // the query db->setSQL(dbq->getSqlBindUpdateAltroFieldAllSectors(arguments.pSelectTagList, "TRCFG_ACQ_START")); int32_t newValue = 0; pb = new ProgressBar('=', 80, 121*8, "Update ALTRO Table"); sw->start(); int32_t ctr = 0; for ( uint32_t iRcu=0; iRcu<6; iRcu++ ) { for ( uint32_t iBranch=0; iBranch<2; iBranch++ ) { for ( uint32_t iFec=0; iFecsetNumber(0, newValue); // new value db->setNumber(1, iRcu); // rcu db->setNumber(2, iBranch); // branch db->setNumber(3, iFec); // fec db->setNumber(4, iAltro); // altro db->executeUpdate(); pb->print(ctr++); } } } } // mark configuration(s) as updated in TPC table db->executeUpdate(dbq->getSqlUpdateUpdated(arguments.pSelectTagList)); delete pb; sw->stop(); cout << "updated ALTRO table | " << sw->formatRealTime() << " s, " << sw->formatSysTime() << "s" << endl; } catch(SQLException& ea) { cout << ea.what() << endl; return 0; } } return 1; }