string numtobindstr(int32_t number) { // // Convert an integer to a string // ostringstream oss; oss << number; return ":" + oss.str(); } // ============================================================================= // ============================================================================= int32_t createqueriesandvalues() { // // Create the queries to fill the tables and vectors holding the values to be filled // into the tables using bind variables. // tpcQueries.clear(); sector_tpcQueries.clear(); sectorQueries.clear(); partition_sectorQueries.clear(); partitionQueries.clear(); fec_partitionQueries.clear(); fecQueries.clear(); cru_partitionQueries.clear(); cruQueries.clear(); pedestal_cruQueries.clear(); pedestalQueries.clear(); zsthr_cruQueries.clear(); zsthrQueries.clear(); onchannel_cruQueries.clear(); onchannelQueries.clear(); cmcorr_cruQueries.clear(); cmcorrQueries.clear(); itcorr1_cruQueries.clear(); itcorr1Queries.clear(); itcorr2_cruQueries.clear(); itcorr2Queries.clear(); tpcQueryCount = arguments.pSelectTagList.size(); sectorQueryCount = ciSectors*ciSides*tpcQueryCount; partitionQueryCount = ciPartitions*sectorQueryCount; cruQueryCount = 2*partitionQueryCount; fecQueryCount = cifecPerSector*sectorQueryCount; pedestalQueryCount = ciLinks*tpcQueryCount; FecFieldPositions FecTable; CruFieldPositions CruTable; PartitionFieldPositions PartitionTable; UlFieldPositions UlTable; fec_values = vector < vector >(FecTable.getNcols()); fec_partition_values = vector < vector >(2); partition_values = vector < vector >(PartitionTable.getNcols()); partition_sector_values = vector < vector >(2); cru_values = vector < vector >(CruTable.getNcols()); cru_partition_values = vector < vector >(2); pedestal_values = vector < vector >(UlTable.getNcols()); pedestal_cru_values = vector < vector >(2); zsthr_values = vector < vector >(UlTable.getNcols()); zsthr_cru_values = vector < vector >(2); onchannel_values = vector < vector >(UlTable.getNcols()); onchannel_cru_values = vector < vector >(2); cmcorr_values = vector < vector >(UlTable.getNcols()); cmcorr_cru_values = vector < vector >(2); itcorr1_values = vector < vector >(UlTable.getNcols()); itcorr1_cru_values = vector < vector >(2); itcorr2_values = vector < vector >(UlTable.getNcols()); itcorr2_cru_values = vector < vector >(2); for ( int32_t col = 0; col < 2; col++ ) { fec_partition_values[col] = vector(fecQueryCount); partition_sector_values[col] = vector(partitionQueryCount); cru_partition_values[col] = vector(cruQueryCount); pedestal_cru_values[col] = vector(pedestalQueryCount); zsthr_cru_values[col] = vector(pedestalQueryCount); onchannel_cru_values[col] = vector(pedestalQueryCount); cmcorr_cru_values[col] = vector(pedestalQueryCount); itcorr1_cru_values[col] = vector(pedestalQueryCount); itcorr2_cru_values[col] = vector(pedestalQueryCount); } for ( int32_t col = 0; col < FecTable.getNcols(); col++ ) { fec_values[col] = vector(fecQueryCount); } for ( int32_t col = 0; col < PartitionTable.getNcols(); col++ ) { partition_values[col] = vector(partitionQueryCount); } for ( int32_t col = 0; col < CruTable.getNcols(); col++ ) { cru_values[col] = vector(cruQueryCount); } for ( int32_t col = 0; col < UlTable.getNcols(); col++ ) { pedestal_values[col] = vector(pedestalQueryCount); zsthr_values[col] = vector(pedestalQueryCount); onchannel_values[col] = vector(pedestalQueryCount); cmcorr_values[col] = vector(pedestalQueryCount); itcorr1_values[col] = vector(pedestalQueryCount); itcorr2_values[col] = vector(pedestalQueryCount); } FecConfig *fecConf = 0; CruConfig *cruConf = 0; TpcConfig *tpcConf = new TpcConfig(); pb = new ProgressBar('=', 80, fecQueryCount, "Create Fill Values"); sw->start(); for ( uint32_t tagCounter = 0; tagCounter < arguments.pSelectTagList.size(); tagCounter++ ) { // Config types fecConf = new FecConfig(arguments.pSelectTagList.at(tagCounter), 0); cruConf = new CruConfig(arguments.pSelectTagList.at(tagCounter), 0); tpcQueries.push_back(dbq->getSqlInsertTPC(arguments.pSelectTagList.at(tagCounter))); tpcQueryIndex++; for (int32_t sideCounter = 0; sideCounter < ciSides; sideCounter++) { for (int32_t sectorCounter = 0; sectorCounter < ciSectors; sectorCounter++) { sectorQueries.push_back(dbq->getSqlInsertSECTOR(sectorIndex, sectorCounter, sideCounter)); sectorQueryIndex++; sector_tpcQueries.push_back(dbq->getSqlInsertSECTOR_TPC(sectorIndex, arguments.pSelectTagList.at(tagCounter))); sector_tpcQueryIndex++; for (int32_t partitionCounter = 0; partitionCounter < ciPartitions; partitionCounter++) { partition_values[0][partitionQueryIndex] = partitionIndex; // ID partition_values[1][partitionQueryIndex] = partitionCounter; // Position partition_values[2][partitionQueryIndex] = 1; // ON_PARTITION partitionQueryIndex++; partition_sector_values[0][partition_sectorQueryIndex] = partitionIndex; // Partition ID partition_sector_values[1][partition_sectorQueryIndex] = sectorIndex; // Sector ID partition_sectorQueryIndex++; for (int32_t cruCounter = 0; cruCounter < 2; cruCounter++) { cru_values[CruTable.getPosition("id")][cruQueryIndex] = cruIndex; // ID cru_values[CruTable.getPosition("Position")][cruQueryIndex] = cruCounter; // Position cru_values[CruTable.getPosition("ON_CRU")][cruQueryIndex] = cruConf->getState(sideCounter, sectorCounter, partitionCounter, cruCounter); cru_values[CruTable.getPosition("GFD_LINK_ACTIVE")][cruQueryIndex] = cruConf->getGFD_LINK_ACTIVE(sideCounter, sectorCounter, partitionCounter, cruCounter); cru_values[CruTable.getPosition("GFD_STRICT_SYNC")][cruQueryIndex] = cruConf->getGFD_STRICT_SYNC(sideCounter, sectorCounter, partitionCounter, cruCounter); cru_values[CruTable.getPosition("GFD_ENABLE_MASK")][cruQueryIndex] = cruConf->getGFD_ENABLE_MASK(sideCounter, sectorCounter, partitionCounter, cruCounter); for (int32_t ii=0; ii<24; ii++) cru_values[6+ii][cruQueryIndex] = cruConf->getGFD_STREAM_MASK(sideCounter, sectorCounter, partitionCounter, cruCounter); cru_values[CruTable.getPosition("ON_LINK")][cruQueryIndex] = cruConf->getON_LINK(sideCounter, sectorCounter, partitionCounter, cruCounter); cru_values[CruTable.getPosition("LINK_SELECTOR_A")][cruQueryIndex] = cruConf->getLINK_SELECTOR_A(sideCounter, sectorCounter, partitionCounter, cruCounter); cru_values[CruTable.getPosition("LINK_SELECTOR_B")][cruQueryIndex] = cruConf->getLINK_SELECTOR_B(sideCounter, sectorCounter, partitionCounter, cruCounter); cru_values[CruTable.getPosition("ZS_EN")][cruQueryIndex] = cruConf->getZS_EN(sideCounter, sectorCounter, partitionCounter, cruCounter); cru_values[CruTable.getPosition("TRG_WINDOW_SIZE")][cruQueryIndex] = cruConf->getTRG_WINDOW_SIZE(sideCounter, sectorCounter, partitionCounter, cruCounter); cru_values[CruTable.getPosition("MAX_PAYLOAD_SIZE")][cruQueryIndex] = cruConf->getMAX_PAYLOAD_SIZE(sideCounter, sectorCounter, partitionCounter, cruCounter); cru_values[CruTable.getPosition("SUPPRESS_HBR")][cruQueryIndex] = cruConf->getSUPPRESS_HBR(sideCounter, sectorCounter, partitionCounter, cruCounter); cru_values[CruTable.getPosition("USE_LINK_ID_15")][cruQueryIndex] = cruConf->getUSE_LINK_ID_15(sideCounter, sectorCounter, partitionCounter, cruCounter); cru_values[CruTable.getPosition("ITCORR0")][cruQueryIndex] = cruConf->getITCORR0(sideCounter, sectorCounter, partitionCounter, cruCounter); cru_values[CruTable.getPosition("ITF_EN")][cruQueryIndex] = cruConf->getITF_EN(sideCounter, sectorCounter, partitionCounter, cruCounter); cru_values[CruTable.getPosition("CMC_EN")][cruQueryIndex] = cruConf->getCMC_EN(sideCounter, sectorCounter, partitionCounter, cruCounter); cru_values[CruTable.getPosition("OFFSET")][cruQueryIndex] = cruConf->getOFFSET(sideCounter, sectorCounter, partitionCounter, cruCounter); cru_values[CruTable.getPosition("RESYNC_EN")][cruQueryIndex] = cruConf->getRESYNC_EN(sideCounter, sectorCounter, partitionCounter, cruCounter); cru_values[CruTable.getPosition("BC_EN")][cruQueryIndex] = cruConf->getBC_EN(sideCounter, sectorCounter, partitionCounter, cruCounter); cru_values[CruTable.getPosition("CMC_THRESH1")][cruQueryIndex] = cruConf->getCMC_THRESH1(sideCounter, sectorCounter, partitionCounter, cruCounter); cru_values[CruTable.getPosition("CMC_MIN_MATCHES")][cruQueryIndex] = cruConf->getCMC_MIN_MATCHES(sideCounter, sectorCounter, partitionCounter, cruCounter); cru_values[CruTable.getPosition("CMC_MATCH_DISTANCE")][cruQueryIndex] = cruConf->getCMC_MATCH_DISTANCE(sideCounter, sectorCounter, partitionCounter, cruCounter); cru_values[CruTable.getPosition("CMC_WRITEOUT_EN")][cruQueryIndex] = cruConf->getCMC_WRITEOUT_EN(sideCounter, sectorCounter, partitionCounter, cruCounter); cruQueryIndex++; cru_partition_values[0][cru_partitionQueryIndex] = cruIndex; // CRU ID cru_partition_values[1][cru_partitionQueryIndex] = partitionIndex; // Partition ID cru_partitionQueryIndex++; for (int32_t branchCounter = 0; branchCounter < 2; branchCounter++) { for (int32_t fecCounter = 0; fecCounter < fecPerPartitionBranch[partitionCounter][branchCounter]; fecCounter++) { pedestal_values[UlTable.getPosition("id")][pedestalQueryIndex] = pedestalIndex; // ID pedestal_values[UlTable.getPosition("BranchPosition")][pedestalQueryIndex] = branchCounter; // Branch pedestal_values[UlTable.getPosition("Position")][pedestalQueryIndex] = fecCounter; // Position zsthr_values[UlTable.getPosition("id")][pedestalQueryIndex] = pedestalIndex; // ID zsthr_values[UlTable.getPosition("BranchPosition")][pedestalQueryIndex] = branchCounter; // Branch zsthr_values[UlTable.getPosition("Position")][pedestalQueryIndex] = fecCounter; // Position onchannel_values[UlTable.getPosition("id")][pedestalQueryIndex] = pedestalIndex; // ID onchannel_values[UlTable.getPosition("BranchPosition")][pedestalQueryIndex] = branchCounter; // Branch onchannel_values[UlTable.getPosition("Position")][pedestalQueryIndex] = fecCounter; // Position cmcorr_values[UlTable.getPosition("id")][pedestalQueryIndex] = pedestalIndex; // ID cmcorr_values[UlTable.getPosition("BranchPosition")][pedestalQueryIndex] = branchCounter; // Branch cmcorr_values[UlTable.getPosition("Position")][pedestalQueryIndex] = fecCounter; // Position itcorr1_values[UlTable.getPosition("id")][pedestalQueryIndex] = pedestalIndex; // ID itcorr1_values[UlTable.getPosition("BranchPosition")][pedestalQueryIndex] = branchCounter; // Branch itcorr1_values[UlTable.getPosition("Position")][pedestalQueryIndex] = fecCounter; // Position itcorr2_values[UlTable.getPosition("id")][pedestalQueryIndex] = pedestalIndex; // ID itcorr2_values[UlTable.getPosition("BranchPosition")][pedestalQueryIndex] = branchCounter; // Branch itcorr2_values[UlTable.getPosition("Position")][pedestalQueryIndex] = fecCounter; // Position for (int32_t ii = 0; ii < 80; ii++) { pedestal_values[3+ii][pedestalQueryIndex] = 0; // Default value 0 zsthr_values[3+ii][pedestalQueryIndex] = 0; // Default value 0 onchannel_values[3+ii][pedestalQueryIndex] = 1; // Default value 1 cmcorr_values[3+ii][pedestalQueryIndex] = 1.; // Default value 1. (float) itcorr1_values[3+ii][pedestalQueryIndex] = 1.; // Default value 1. (float) itcorr2_values[3+ii][pedestalQueryIndex] = 1.; // Default value 1. (float) } pedestalQueryIndex++; pedestal_cru_values[0][pedestal_cruQueryIndex] = pedestalIndex; // Link ID pedestal_cru_values[1][pedestal_cruQueryIndex] = cruIndex; // CRU ID zsthr_cru_values[0][pedestal_cruQueryIndex] = pedestalIndex; // Link ID zsthr_cru_values[1][pedestal_cruQueryIndex] = cruIndex; // CRU ID onchannel_cru_values[0][pedestal_cruQueryIndex] = pedestalIndex; // Link ID onchannel_cru_values[1][pedestal_cruQueryIndex] = cruIndex; // CRU ID cmcorr_cru_values[0][pedestal_cruQueryIndex] = pedestalIndex; // Link ID cmcorr_cru_values[1][pedestal_cruQueryIndex] = cruIndex; // CRU ID itcorr1_cru_values[0][pedestal_cruQueryIndex] = pedestalIndex; // Link ID itcorr1_cru_values[1][pedestal_cruQueryIndex] = cruIndex; // CRU ID itcorr2_cru_values[0][pedestal_cruQueryIndex] = pedestalIndex; // Link ID itcorr2_cru_values[1][pedestal_cruQueryIndex] = cruIndex; // CRU ID pedestal_cruQueryIndex++; pedestalIndex++; } // End FEC loop } // End branch loop cruIndex++; } // End CRU loop for (int32_t branchCounter = 0; branchCounter < 2; branchCounter++) { for (int32_t fecCounter = 0; fecCounter < fecPerPartitionBranch[partitionCounter][branchCounter]; fecCounter++) { fec_values[FecTable.getPosition("id")][fecQueryIndex] = fecIndex; // ID fec_values[FecTable.getPosition("BranchPosition")][fecQueryIndex] = branchCounter; // BranchPosition fec_values[FecTable.getPosition("Position")][fecQueryIndex] = fecCounter; // Position fec_values[FecTable.getPosition("ON_FEC")][fecQueryIndex] = // ON_FEC fecConf->getState(sideCounter, sectorCounter, partitionCounter, branchCounter, fecCounter); fec_values[FecTable.getPosition("SAMPA_MASK")][fecQueryIndex] = // SAMPA_MASK fecConf->getSAMPA_MASK(sideCounter, sectorCounter, partitionCounter, branchCounter, fecCounter); fec_values[FecTable.getPosition("SAMPA_ANA_CFG")][fecQueryIndex] = // SAMPA_ANA_CFG fecConf->getSAMPA_ANA_CFG(sideCounter, sectorCounter, partitionCounter, branchCounter, fecCounter); fec_values[FecTable.getPosition("SAMPA_CLK_CFG")][fecQueryIndex] = // SAMPA_CLK_CFG fecConf->getSAMPA_CLK_CFG(sideCounter, sectorCounter, partitionCounter, branchCounter, fecCounter); int32_t pos = FecTable.getPosition("SAMPA_CLK_CFG") + 1; for (int32_t ii = 0; ii < 28; ii++) { fec_values[pos+ii][fecQueryIndex] = // GBTX0_SAMPLINGPHASEs fecConf->getGBTX0_SAMPLINGPHASE(sideCounter, sectorCounter, partitionCounter, branchCounter, fecCounter, ii); } fecQueryIndex++; fec_partition_values[0][fec_partitionQueryIndex] = fecIndex; // FEC ID fec_partition_values[1][fec_partitionQueryIndex] = partitionIndex; // Partition ID fec_partitionQueryIndex++; pb->print(fecIndex); fecIndex++; } // end FEC loop } // end branch loop partitionIndex++; } // end Partition loop sectorIndex++; } // end SECTOR Loop } // end SIDE Loop delete fecConf; fecConf = 0; delete cruConf; cruConf = 0; } // end Tag Loop delete tpcConf; tpcConf = 0; delete pb; sw->stop(); cout << "Finished | " << sw->formatRealTime() << "s, " << sw->formatSysTime() << "s" << endl; return 1; } // ============================================================================= // ============================================================================= int32_t filltables() { // // Fill Tables with default values // FecFieldPositions FecTable; CruFieldPositions CruTable; UlFieldPositions UlTable; // Find the max id's in the tables. The new data will be appended at the end of each table. if ( !findmaxids() ) { cerr << "*Error in filltables(): Could not find max id's!" << endl; return 0; } // Check if config exists. If yes, skip it. if ( !checkbeforefillconfigexists() ) { // Check if config exists. cerr << "*Function filltables(): Configuration already exists. Nothing to be done!" << endl; return 1; } // Create the queries and fill values if ( !createqueriesandvalues() ) { cerr << "*Error in filltables(): Error. Could not create queries and vectors with values!" << endl; return 0; } // Fill tables (or print queries to file) sw->start(); if ( arguments.pTest == true ) { // test mode ofstream *outFile = new ofstream(); outFile->open("FillBind.sql"); *outFile << dbq->getSqlBindInsertPEDESTAL() << ";" << endl; *outFile << dbq->getSqlBindInsertZSTHR() << ";" << endl; *outFile << dbq->getSqlBindInsertONCHANNEL() << ";" << endl; *outFile << dbq->getSqlBindInsertCMCORR() << ";" << endl; *outFile << dbq->getSqlBindInsertITCORR1() << ";" << endl; *outFile << dbq->getSqlBindInsertITCORR2() << ";" << endl; *outFile << dbq->getSqlBindInsertCRU() << ";" << endl; *outFile << dbq->getSqlBindInsertFEC() << ";" << endl; *outFile << dbq->getSqlBindInsertPARTITION() << ";" << endl; for(int32_t i = 0; i < sectorQueryCount; i++) *outFile << sectorQueries[i] << endl; for(int32_t i = 0; i < tpcQueryCount; i++) *outFile << tpcQueries[i] << endl; *outFile << dbq->getSqlBindInsertFEC_PARTITION() << ";" << endl; *outFile << dbq->getSqlBindInsertCRU_PARTITION() << ";" << endl; *outFile << dbq->getSqlBindInsertPARTITION_SECTOR() << ";" << endl; for(int32_t i = 0; i < sectorQueryCount; i++) *outFile << sector_tpcQueries[i] << endl; outFile->close(); delete outFile; } else { try { Statement st(con); cout << "Inserting PEDESTAL ... please wait ... " << flush; st.Prepare(dbq->getSqlBindInsertPEDESTAL()); // set sql statement in cache st.SetBindArraySize(pedestalQueryCount); for (uint32_t col = 0; col < UlTable.getNcols(); col++) st.Bind(numtobindstr(col+1), pedestal_values[col], BindInfo::In); st.ExecutePrepared(); cout << "Done, " << st.GetAffectedRows() << " rows processed." << endl; // cout << "Inserting ZSTHR ... please wait ... " << flush; st.Prepare(dbq->getSqlBindInsertZSTHR()); // set sql statement in cache st.SetBindArraySize(pedestalQueryCount); for (uint32_t col = 0; col < UlTable.getNcols(); col++) st.Bind(numtobindstr(col+1), zsthr_values[col], BindInfo::In); st.ExecutePrepared(); cout << "Done, " << st.GetAffectedRows() << " rows processed." << endl; // cout << "Inserting ON_CHANNEL ... please wait ... " << flush; st.Prepare(dbq->getSqlBindInsertONCHANNEL()); // set sql statement in cache st.SetBindArraySize(pedestalQueryCount); for (uint32_t col = 0; col < UlTable.getNcols(); col++) st.Bind(numtobindstr(col+1), onchannel_values[col], BindInfo::In); st.ExecutePrepared(); cout << "Done, " << st.GetAffectedRows() << " rows processed." << endl; // cout << "Inserting CMCORR ... please wait ... " << flush; st.Prepare(dbq->getSqlBindInsertCMCORR()); // set sql statement in cache st.SetBindArraySize(pedestalQueryCount); for (uint32_t col = 0; col < UlTable.getNcols(); col++) st.Bind(numtobindstr(col+1), cmcorr_values[col], BindInfo::In); st.ExecutePrepared(); cout << "Done, " << st.GetAffectedRows() << " rows processed." << endl; // cout << "Inserting ITCORR1 ... please wait ... " << flush; st.Prepare(dbq->getSqlBindInsertITCORR1()); // set sql statement in cache st.SetBindArraySize(pedestalQueryCount); for (uint32_t col = 0; col < UlTable.getNcols(); col++) st.Bind(numtobindstr(col+1), itcorr1_values[col], BindInfo::In); st.ExecutePrepared(); cout << "Done, " << st.GetAffectedRows() << " rows processed." << endl; // cout << "Inserting ITCORR2 ... please wait ... " << flush; st.Prepare(dbq->getSqlBindInsertITCORR2()); // set sql statement in cache st.SetBindArraySize(pedestalQueryCount); for (uint32_t col = 0; col < UlTable.getNcols(); col++) st.Bind(numtobindstr(col+1), itcorr2_values[col], BindInfo::In); st.ExecutePrepared(); cout << "Done, " << st.GetAffectedRows() << " rows processed." << endl; // cout << "Inserting FEC ... please wait ... " << flush; st.Prepare(dbq->getSqlBindInsertFEC()); // set sql statement in cache st.SetBindArraySize(fecQueryCount); for (uint32_t col = 0; col < FecTable.getNcols(); col++) st.Bind(numtobindstr(col+1), fec_values[col], BindInfo::In); st.ExecutePrepared(); cout << "Done, " << st.GetAffectedRows() << " rows processed." << endl; // cout << "Inserting CRU ... please wait ... " << flush; st.Prepare(dbq->getSqlBindInsertCRU()); // set sql statement in cache st.SetBindArraySize(cruQueryCount); for (uint32_t col = 0; col < CruTable.getNcols(); col++) st.Bind(numtobindstr(col+1), cru_values[col], BindInfo::In); st.ExecutePrepared(); cout << "Done, " << st.GetAffectedRows() << " rows processed." << endl; // cout << "Inserting PARTITION ... please wait ... " << flush; st.Prepare(dbq->getSqlBindInsertPARTITION()); // set sql statement in cache st.SetBindArraySize(partitionQueryCount); for (uint32_t col = 0; col < 3; col++) st.Bind(numtobindstr(col+1), partition_values[col], BindInfo::In); st.ExecutePrepared(); cout << "Done, " << st.GetAffectedRows() << " rows processed." << endl; // cout << "Inserting SECTOR ... please wait ... " << flush; for(int32_t i = 0; i < sectorQueryCount; i++) { st.Execute(sectorQueries[i]); // directly execute } cout << "Done." << endl; // cout << "Inserting TPC ... please wait ... " << flush; for(int32_t i = 0; i < tpcQueryCount; i++) { st.Execute(tpcQueries[i]); // directly execute } cout << "Done." << endl; // cout << "Inserting PEDESTAL-CRU Link ... please wait ... " << flush; st.Prepare(dbq->getSqlBindInsertPEDESTAL_CRU()); // set sql statement in cache st.SetBindArraySize(pedestalQueryCount); for (uint32_t col = 0; col < 2; col++) st.Bind(numtobindstr(col+1), pedestal_cru_values[col], BindInfo::In); st.ExecutePrepared(); cout << "Done, " << st.GetAffectedRows() << " rows processed." << endl; // cout << "Inserting ZSTHR-CRU Link ... please wait ... " << flush; st.Prepare(dbq->getSqlBindInsertZSTHR_CRU()); // set sql statement in cache st.SetBindArraySize(pedestalQueryCount); for (uint32_t col = 0; col < 2; col++) st.Bind(numtobindstr(col+1), zsthr_cru_values[col], BindInfo::In); st.ExecutePrepared(); cout << "Done, " << st.GetAffectedRows() << " rows processed." << endl; // cout << "Inserting ON_CHANNEL-CRU Link ... please wait ... " << flush; st.Prepare(dbq->getSqlBindInsertONCHANNEL_CRU()); // set sql statement in cache st.SetBindArraySize(pedestalQueryCount); for (uint32_t col = 0; col < 2; col++) st.Bind(numtobindstr(col+1), onchannel_cru_values[col], BindInfo::In); st.ExecutePrepared(); cout << "Done, " << st.GetAffectedRows() << " rows processed." << endl; // cout << "Inserting CMCORR-CRU Link ... please wait ... " << flush; st.Prepare(dbq->getSqlBindInsertCMCORR_CRU()); // set sql statement in cache st.SetBindArraySize(pedestalQueryCount); for (uint32_t col = 0; col < 2; col++) st.Bind(numtobindstr(col+1), cmcorr_cru_values[col], BindInfo::In); st.ExecutePrepared(); cout << "Done, " << st.GetAffectedRows() << " rows processed." << endl; // cout << "Inserting ITCORR1-CRU Link ... please wait ... " << flush; st.Prepare(dbq->getSqlBindInsertITCORR1_CRU()); // set sql statement in cache st.SetBindArraySize(pedestalQueryCount); for (uint32_t col = 0; col < 2; col++) st.Bind(numtobindstr(col+1), itcorr1_cru_values[col], BindInfo::In); st.ExecutePrepared(); cout << "Done, " << st.GetAffectedRows() << " rows processed." << endl; // cout << "Inserting ITCORR2-CRU Link ... please wait ... " << flush; st.Prepare(dbq->getSqlBindInsertITCORR2_CRU()); // set sql statement in cache st.SetBindArraySize(pedestalQueryCount); for (uint32_t col = 0; col < 2; col++) st.Bind(numtobindstr(col+1), itcorr2_cru_values[col], BindInfo::In); st.ExecutePrepared(); cout << "Done, " << st.GetAffectedRows() << " rows processed." << endl; // cout << "Inserting FEC-PARTITION Link ... please wait ... " << flush; st.Prepare(dbq->getSqlBindInsertFEC_PARTITION()); // set sql statement in cache st.SetBindArraySize(fecQueryCount); for (uint32_t col = 0; col < 2; col++) st.Bind(numtobindstr(col+1), fec_partition_values[col], BindInfo::In); st.ExecutePrepared(); cout << "Done, " << st.GetAffectedRows() << " rows processed." << endl; // cout << "Inserting CRU-PARTITION Link ... please wait ... " << flush; st.Prepare(dbq->getSqlBindInsertCRU_PARTITION()); // set sql statement in cache st.SetBindArraySize(cruQueryCount); for (uint32_t col = 0; col < 2; col++) st.Bind(numtobindstr(col+1), cru_partition_values[col], BindInfo::In); st.ExecutePrepared(); cout << "Done, " << st.GetAffectedRows() << " rows processed." << endl; // cout << "Inserting PARTITION-SECTOR Link ... please wait ... " << flush; st.Prepare(dbq->getSqlBindInsertPARTITION_SECTOR()); // set sql statement in cache st.SetBindArraySize(partitionQueryCount); for (uint32_t col = 0; col < 2; col++) st.Bind(numtobindstr(col+1), partition_sector_values[col], BindInfo::In); st.ExecutePrepared(); cout << "Done, " << st.GetAffectedRows() << " rows processed." << endl; // cout << "Inserting SECTOR-TPC Link ... please wait ... " << flush; for(int32_t i = 0; i < sectorQueryCount; i++) { st.Execute(sector_tpcQueries[i]); // directly execute } cout << "Done." << endl; con.Commit(); } catch (exception &ex) { cout << ex.what() << endl; } sw->stop(); } // end if test mode cout << "Hoooray! Filling was succesful! | " << sw->formatRealTime() << "s, " << sw->formatSysTime() << "s" << endl; return 1; } // ============================================================================= // ============================================================================= int32_t fillgbtx1() { // // Fill GBTX1 table // // Check if table is empty if ( !tableEmpty("GBTX1") ) { cerr << "*GBTX1 table is not empty!" << endl; return 0; } if (arguments.pTest == false) { cout << "Inserting GBTx configuration data from file config_fec-gbtx1.txt ... " << endl; try { Statement st(con); st.Execute(dbq->getSqlInsertGBTX1()); } catch (exception &ex) { cout << ex.what() << endl; } cout << "Done." << endl; } else { ofstream *outFile = new ofstream(); outFile->open("GBTX1.sql"); *outFile << dbq->getSqlInsertGBTX1() << ";" << endl; outFile->close(); delete outFile; } return 1; }