Commit 759d795f authored by Xanthe Hoad's avatar Xanthe Hoad Committed by Graeme Stewart
Browse files

tag for MAM MCK testing (TrigConfStorage-03-01-23)

	* Extend CoolFix application: possibility to fix specific LB ranges,
	implement fixing of L1 prescales and BGS
	* TrigConfStorage-03-01-22


Former-commit-id: fd7cb783
parent 63ecc206
......@@ -17,7 +17,8 @@ namespace TrigConf {
MCKLoader(StorageMgr& sm);
virtual ~MCKLoader();
bool loadMCKlinkedToSMK(unsigned int smk, unsigned int & mck);
bool loadMCKlinkedToSMK(unsigned int smk, unsigned int & mck);
bool loadReleaseLinkedToMCK(unsigned int mck, std::string & mck_release);
};
......
......@@ -140,7 +140,11 @@ namespace TrigConf {
// /TRIGGER/HLT/HltConfigKeys
static cool::IFolderPtr getHltConfKeyFolder(cool::IDatabasePtr db);
// /TRIGGER/HLT/MenuAwareMonConfigKey
static cool::IFolderPtr getMonConfKeyFolder(cool::IDatabasePtr db);
// /TRIGGER/HLT/Prescales
static cool::IFolderPtr getHltPrescalesFolder(cool::IDatabasePtr db);
......
......@@ -55,6 +55,16 @@ namespace TrigConf {
unsigned int hltPrescaleKey, const std::string& configSource );
/**@brief build a COOL db record from a HLT monitoring configuration key
*
* @param MCK the monitoring configuration key
* @param configSource the source of configuration information (DB
* connection string or XML file name)
*
* @returns a COOL db record
*/
cool::Record createMonConfigKeyPayload(cool::IFolderPtr fld, uint MCK, std::string& info );
/**@brief build a COOL db record from a HLT prescale value
*
* @param prescale the prescale value
......
......@@ -132,6 +132,11 @@ namespace TrigConf {
void writeHLTPayload( ValidityRange vr,
const HLTFrame& hltFrame,
const std::string& configSource);
void writeMCKPayload(ValidityRange vr,
unsigned int mck,
std::string& release,
std::string& info);
/**@brief Writing run-wise configuration information the COOL database
......@@ -219,6 +224,10 @@ namespace TrigConf {
const TrigConf::HLTPrescaleSet & pss);
void writeHltPrescalePayload( const RunRangeVec& runRanges,
const TrigConf::HLTPrescaleSet & pss);
void writeHltPrescalePayload( cool::ValidityKey since,
cool::ValidityKey until,
const TrigConf::HLTPrescaleSet & pss);
/**@brief Writing luminosityblock-wise configuration information the COOL database
*
......@@ -234,11 +243,10 @@ namespace TrigConf {
void writeL1PrescalePayload( const RunRangeVec& runRanges,
unsigned int lvl1PrescaleKey,
const TrigConf::PrescaleSet & prescale);
void writeL1PrescalePayload( cool::ValidityKey since,
cool::ValidityKey until,
unsigned int lvl1PrescaleKey,
const TrigConf::PrescaleSet & prescaleSet);
......@@ -364,7 +372,7 @@ namespace TrigConf {
*/
void readL1Menu(unsigned int runNumber, CTPConfig & ctpc);
std::vector<std::string> checkPayloadSize(unsigned int run, unsigned int lb, int displayMode);
std::vector<std::string> checkPayloadSize(unsigned int run, unsigned int lb, int displayMode, bool openend, unsigned int lbend);
void addWriteFolder(const std::string& fname) { m_writeFolderList.push_back( fname ); }
......@@ -419,17 +427,6 @@ namespace TrigConf {
void rangeInfo(const std::string& content, cool::ValidityKey since, cool::ValidityKey until);
/**@brief the writer for the HLT prescale set*/
void writeHltPrescalePayload( cool::ValidityKey since,
cool::ValidityKey until,
const TrigConf::HLTPrescaleSet & pss);
/**@brief the writer for the prescale set*/
void writeL1PrescalePayload( cool::ValidityKey since,
cool::ValidityKey until,
unsigned int lvl1PrescaleKey,
const TrigConf::PrescaleSet & prescaleSet);
/**@brief check if foldername is in list of writeable folders*/
bool shouldFolderBeUpdated(const std::string & foldername) {
if( m_writeFolderList.size()==0 ) return true; // nothing specified --> write everything (default)
......
......@@ -34,7 +34,7 @@ TrigConf::MCKLoader::loadMCKlinkedToSMK(unsigned int smk, unsigned int & mck)
TRG_MSG_WARNING("MAM tables not found in this trigger database");
return false;
}
std::string theCondition = "SMK_LINK_SMK = :smId";
theCondition += string( " AND SMK_LINK_ACTIVE_MCK = 1" );
......@@ -69,3 +69,58 @@ TrigConf::MCKLoader::loadMCKlinkedToSMK(unsigned int smk, unsigned int & mck)
return nFound==1;
}
bool
TrigConf::MCKLoader::loadReleaseLinkedToMCK(unsigned int mck, std::string & mck_release)
{
//load athena release (when MCK!=0)
if ( mck == 0 ){
TRG_MSG_ERROR("No release exists for MCK 0");
return false;
}
startSession();
unique_ptr< coral::IQuery > q;
try {
unique_ptr< coral::IQuery > qtmp( m_session.nominalSchema().tableHandle( "MCK_TABLE").newQuery() );
q = std::move(qtmp);
}
catch(coral::TableNotExistingException & ex) {
TRG_MSG_WARNING("MAM tables not found in this trigger database");
return false;
}
coral::AttributeList bindings;
bindings.extend<int>("mck");
bindings[0].data<int>() = mck;
q->setCondition( "MCK_ID = :mck", bindings );
coral::AttributeList attList;
attList.extend<std::string> ( "MCK_ATHENA_VERSION" );
fillQuery(q.get(), attList);
coral::ICursor& cursor = q->execute();
int nFound(0);
while (cursor.next()) {
++nFound;
const coral::AttributeList& row = cursor.currentRow();
mck_release = row["MCK_ATHENA_VERSION"].data<std::string>();
}
commitSession();
if(nFound>1) {
TRG_MSG_ERROR("Found more than one release for MCK " << mck);
} else if(nFound==1) {
TRG_MSG_INFO("Found release " << mck_release << " for MCK " << mck);
} else {
TRG_MSG_INFO("Found no release for MCK " << mck);
}
return nFound==1;
}
......@@ -553,6 +553,10 @@ IFolderPtr TrigConfCoolFolderSpec::getHltConfKeyFolder(IDatabasePtr db) {
return db->getFolder( "/TRIGGER/HLT/HltConfigKeys" );
}
IFolderPtr TrigConfCoolFolderSpec::getMonConfKeyFolder(IDatabasePtr db) {
return db->getFolder( "/TRIGGER/HLT/MenuAwareMonConfigKey" );
}
IFolderPtr TrigConfCoolFolderSpec::getHltPrescalesFolder(IDatabasePtr db) {
return db->getFolder( "/TRIGGER/HLT/Prescales" );
}
......
......@@ -79,6 +79,13 @@ TrigConfCoolHLTPayloadConverters::createHltConfigKeysPayload(cool::IFolderPtr fl
return payload;
}
Record
TrigConfCoolHLTPayloadConverters::createMonConfigKeyPayload(cool::IFolderPtr fld, uint mck, string& info ) {
Record payload(fld->payloadSpecification());
payload["MonConfigKey"].setValue<cool::UInt32>(mck);
payload["Info"].setValue<cool::String4k>(info);
return payload;
}
Record
TrigConfCoolHLTPayloadConverters::createHltPrescalesPayload(cool::IFolderPtr fld, float prescale,
......
......@@ -6,6 +6,7 @@
#include "TrigConfStorage/TrigConfCoolFolderSpec.h"
#include "TrigConfStorage/TrigConfCoolHLTPayloadConverters.h"
#include "TrigConfStorage/TrigConfCoolL1PayloadConverters.h"
#include "TrigConfStorage/MCKLoader.h"
#include "TrigConfL1Data/PrescaleSet.h"
#include "TrigConfL1Data/BunchGroupSet.h"
......@@ -421,9 +422,34 @@ TrigConf::TrigConfCoolWriter::writeHLTPayload( ValidityRange vr,
}
// ------------------------------------------------------------
// writeMCKPayload()
// ------------------------------------------------------------
void
TrigConf::TrigConfCoolWriter::writeMCKPayload(ValidityRange vr,
unsigned int mck,
std::string & release,
std::string & info)
{
AutoDBOpen db(this, READ_WRITE);
TrigConfCoolFolderSpec::createFolderStructure(m_dbPtr); // just in case
// writing monitoring configuration key
if( shouldFolderBeUpdated("/TRIGGER/HLT/MenuAwareMonConfigKey") ) {
rangeInfo("Monitoring configuration key", vr.since(), vr.until());
try {
IFolderPtr monconfkeyFolder = TrigConfCoolFolderSpec::getMonConfKeyFolder(m_dbPtr);
Record payload = createMonConfigKeyPayload(monconfkeyFolder, mck, info);
monconfkeyFolder->storeObject(vr.since(), vr.until(), payload, 0, "MenuAwareMonConfigKey-"+release); //tag
}
catch(exception & e) {
m_ostream << "<writeMCKPayload> caught and re-throw exception: " << e.what() << endl
<< "WARNING: Failed to write monitoring configuration key (MCK) to COOL" << endl;
throw;
}
}
}
// ------------------------------------------------------------
......@@ -1677,10 +1703,19 @@ TrigConf::TrigConfCoolWriter::HLTPrescaleFolderExists() {
*-----------------------------------------------------------*/
vector<string>
TrigConf::TrigConfCoolWriter::checkPayloadSize(unsigned int run, unsigned int lb, int displayMode) {
TrigConf::TrigConfCoolWriter::checkPayloadSize(unsigned int run, unsigned int lb, int displayMode, bool openend, unsigned int lbend) {
AutoDBOpen db(this, READ_ONLY);
ValidityRange vr(run, lb); //
ValidityRange vr(run);
if(openend) {
vr = ValidityRange(run, lb);
} else {
ValidityKey since(run); since <<= 32; since += lb;
ValidityKey until(run); until <<= 32; until += lbend+1;
vr = ValidityRange(since, until);
}
m_ostream << "Checking for run " << run << " and lb range " << (vr.since() & 0xFFFFFFFF) << " - " << ( (vr.until()-1) & 0xFFFFFFFF) << endl
<< endl
<< " Folder Payload Size" << endl
......
......@@ -65,7 +65,7 @@ void printhelp(std::ostream & o, std::ostream& (*lineend) ( std::ostream& os ))
o << "[Global options]\n";
o << " -c|--cooldb <cooldb> ... cool database and run number (default is COOLONL_TRIGGER/CONDBR2)\n";
o << " e.g. COOLONL_TRIGGER/CONDBR2 or testcool.db \n";
o << " -r|--run <run> [<lb>] ... run number (mandatory) and lb\n";
o << " -r|--run <run> [<lb>] [<lbend>] ... run number (mandatory) and optionally lb (range)\n";
o << "\n";
o << " --triggerdb <triggerdb> ... trigger database as source of information (default is TRIGGERDBR2)\n";
o << " --smk <smk> ... SMK to load to cool (specify when needed)\n";
......@@ -95,6 +95,8 @@ public:
string cooldb{"COOLONL_TRIGGER/CONDBR2"};
unsigned int run {0};
unsigned int lb {0};
unsigned int lbend {0};
bool openended {true};
// fix the database
bool fix {false};
bool extendedSelection {false}; // if true also allows fixing of MV folders
......@@ -124,6 +126,7 @@ int
JobConfig::parseProgramOptions(int argc, char* argv[]) {
std::string currentPar("");
std::string listofUnknownParameters = "";
uint runargpos(0);
for(int i=1; i<argc; i++) {
string currInput(argv[i]);
int fchar = currInput.find_first_not_of('-');
......@@ -153,12 +156,21 @@ JobConfig::parseProgramOptions(int argc, char* argv[]) {
currentPar = stripped;
} else {
if(currentPar == "c" || currentPar == "cooldb") { cooldb = stripped; currentPar=""; continue; }
if(currentPar == "r" || currentPar == "run") {
if(run==0) {
run = boost::lexical_cast<int,string>(stripped);
} else {
lb = boost::lexical_cast<int,string>(stripped);
}
if(currentPar == "r" || currentPar == "run") {
unsigned int val = boost::lexical_cast<unsigned int,string>(stripped);
switch(runargpos) {
case 0:
run = val;
break;
case 1:
lb = val;
break;
case 2:
lbend = val;
openended = false;
break;
}
runargpos++;
continue;
}
if(currentPar == "triggerdb") { triggerdb = stripped; continue; }
......@@ -225,7 +237,7 @@ JobConfig::PrintSetup() {
cout << "JOB SETUP: " << endl;
cout << "----------" << endl;
cout << " Run : " << run << endl;
cout << " LB : " << lb << endl;
cout << " LB : " << lb << " - " << lbend << endl;
cout << " Cool DB : " << coolConnection << endl;
cout << " Trigger database : " << triggerdb << endl;
cout << " Fix flag : " << (fix ? "yes" : "no") << endl;
......@@ -276,7 +288,7 @@ int main( int argc, char* argv[] ) {
int displayMode = gConfig.fix ? ( gConfig.extendedSelection ? 2 : 1 ) : 0;
vector<string> fixableFolders = coolReader->checkPayloadSize( gConfig.run, gConfig.lb, displayMode );
vector<string> fixableFolders = coolReader->checkPayloadSize( gConfig.run, gConfig.lb, displayMode, gConfig.openended, gConfig.lbend );
if( ! gConfig.fix ) {
delete coolReader;
......@@ -328,7 +340,7 @@ int main( int argc, char* argv[] ) {
gConfig.extendedSelection = !gConfig.extendedSelection;
fixableFolders = coolReader->checkPayloadSize( gConfig.run, gConfig.lb, gConfig.extendedSelection ? 2 : 1 );
fixableFolders = coolReader->checkPayloadSize( gConfig.run, gConfig.lb, gConfig.extendedSelection ? 2 : 1, gConfig.openended, gConfig.lbend );
selectForFixing.clear();
......@@ -416,7 +428,12 @@ int main( int argc, char* argv[] ) {
readKeyFromPrompt("Please specify L1 Prescaleset key : ", gConfig.l1psk );
if( loadHLTPSK && gConfig.hltpsk==0) {
string prompt = "Please specify HLT Prescaleset key (starting at LB " + lexical_cast<string,int>(gConfig.lb) + "): ";
string prompt = "Please specify HLT Prescaleset key";
if(gConfig.openended) {
prompt += " (starting at LB " + lexical_cast<string,int>(gConfig.lb) + "): ";
} else {
prompt += " (for LB " + lexical_cast<string,int>(gConfig.lb) + " - " + std::to_string(gConfig.lbend) + "): ";
}
readKeyFromPrompt( prompt, gConfig.hltpsk );
}
......@@ -491,41 +508,75 @@ int main( int argc, char* argv[] ) {
cout << "Writing cool to destination " << gConfig.coolConnection << endl;
TrigConfCoolWriter * coolWriter = new TrigConfCoolWriter( gConfig.coolConnection );
for(const string & folderToFix : foldersToFix) {
ValidityRange vr(gConfig.run);
if(gConfig.openended) {
vr = ValidityRange(gConfig.run, gConfig.lb);
} else {
cool::ValidityKey since(gConfig.run); since <<= 32; since += gConfig.lb;
cool::ValidityKey until(gConfig.run); until <<= 32; until += gConfig.lbend+1;
vr = ValidityRange(since, until);
}
/**
* BGSK
*/
if( folderToFix == "/TRIGGER/LVL1/BunchGroupKey")
cout << "Writing of COOL folder " << folderToFix << " not yet implemented" << endl;
if( folderToFix == "/TRIGGER/LVL1/BunchGroupContent")
cout << "Writing of COOL folder " << folderToFix << " not yet implemented" << endl;
/**
* BGSK
*/
{
if( folderToFix == "/TRIGGER/LVL1/BunchGroupDescription") {
if(ctpConfig && bgs) {
coolWriter->writeL1BunchGroupRunPayload( ValidityRange(gConfig.run),
ctpConfig->menu(),
*bgs);
bool doWrite(false);
for(const string & folderToFix : foldersToFix) {
if( folderToFix == "/TRIGGER/LVL1/BunchGroupKey" ||
folderToFix == "/TRIGGER/LVL1/BunchGroupContent") {
coolWriter->addWriteFolder( folderToFix );
doWrite = true;
}
}
if(loadBGSK && doWrite) {
coolWriter->writeL1BunchGroupLBPayload( vr, bgs->id(), *bgs);
}
coolWriter->clearWriteFolder();
/**
* L1PSK
*/
if( folderToFix == "/TRIGGER/LVL1/Lvl1ConfigKey")
cout << "Writing of COOL folder " << folderToFix << " not yet implemented" << endl;
for(const string & folderToFix : foldersToFix) {
if( folderToFix == "/TRIGGER/LVL1/BunchGroupDescription") {
if(ctpConfig && bgs) {
coolWriter->writeL1BunchGroupRunPayload( vr,
ctpConfig->menu(),
*bgs);
}
}
}
if( folderToFix == "/TRIGGER/LVL1/Prescales")
cout << "Writing of COOL folder " << folderToFix << " not yet implemented" << endl;
}
/**
* L1PSK
*/
{
bool doWrite(false);
for(const string & folderToFix : foldersToFix) {
if( folderToFix == "/TRIGGER/LVL1/Lvl1ConfigKey" ||
folderToFix == "/TRIGGER/LVL1/Prescales") {
coolWriter->addWriteFolder( folderToFix );
doWrite = true;
}
}
if(loadL1PSK && doWrite) {
coolWriter->writeL1PrescalePayload( vr.since(), vr.until(), l1pss->id() , *l1pss);
}
coolWriter->clearWriteFolder();
}
/**
* HLT prescales
*/
{
bool doWrite(false);
for(const string & folderToFix : foldersToFix) {
if( folderToFix == "/TRIGGER/HLT/PrescaleKey" ||
......@@ -535,7 +586,7 @@ int main( int argc, char* argv[] ) {
}
}
if(hltpss && doWrite) {
coolWriter->writeHltPrescalePayload( gConfig.run, gConfig.lb, *hltpss);
coolWriter->writeHltPrescalePayload( vr.since(), vr.until(), *hltpss);
}
coolWriter->clearWriteFolder();
}
......
......@@ -418,7 +418,8 @@ int main( int argc, char* argv[] ) {
BunchGroupSet* bgs(nullptr);
HLTFrame* hltFrame(0);
TXC::L1TopoMenu* l1tm = nullptr;
uint smk(0),l1psk(0),hltpsk(0),bgsk(0);
uint smk(0),l1psk(0),hltpsk(0),bgsk(0), mck{0};
string release;
/*------------------
......@@ -460,11 +461,15 @@ int main( int argc, char* argv[] ) {
bgsk = gConfig.getKey(3);
// loading attached MCK
unsigned int mck{0};
auto mckloader = new MCKLoader(*sm);
mckloader->loadMCKlinkedToSMK(smk, mck);
if ( mck != 0 ) {
mckloader->loadReleaseLinkedToMCK(mck,release);
log << "Loaded MCK " << mck << " (active for SMK " << smk << " and release " << release << ")" << endl;
} else {
log << "Did not load MCK from DB as MCK is 0 or no MCK is linked";
}
log << "Loaded MCK " << mck << " (active for SMK " << smk << ")" << endl;
}
/*------------------
......@@ -667,6 +672,7 @@ int main( int argc, char* argv[] ) {
log << lineend;
TrigConfCoolWriter * coolWriter = new TrigConfCoolWriter( gConfig.coolOutputConnection );
string configSource("");
string info("");
unsigned int runNr = gConfig.coolOutputRunNr;
if(runNr == 0) { runNr = 0x80000000; } // infinite range
......@@ -675,7 +681,9 @@ int main( int argc, char* argv[] ) {
if(hltFrame)
coolWriter->writeHLTPayload(runNr, *hltFrame, configSource);
if(mck)
coolWriter->writeMCKPayload(runNr, mck, release, info);
}
delete ctpc;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment