Commit e578e5a4 authored by Joerg Stelzer's avatar Joerg Stelzer Committed by Graeme Stewart
Browse files

TrigConf2Cool for MC: fix HLTPrescaleKey writing (TrigConfStorage-03-01-01)

	* TrigConf2Cool for MC: fix HLTPrescaleKey writing
	* TrigConfStorage-03-01-01

2015-03-31 Joerg Stelzer
	* MenuLoader: added loading of item monitoring data from XML and database
	* TrigConfStorage-03-01-00

2015-03-31 Francesca Pastore
	* JobOptionTableLoader: loading Menu components from TriggerDB is disabled (avoid crash in ATR-10453)
	* TrigConfStorage-03-00-99

2015-03-28 Joerg Stelzer
	* Adapt to Cool to 16 bunchgroups
	* TrigConfStorage-03-00-98

2015-03-18 Joerg Stelzer
	* TrigConfCoolWriter: fix reading of TriggerThresholds from COOL
	* TrigConfStorage-03-00-97

	* TrigConfStorage-03-00-95
parent 63a0c470
......@@ -560,9 +560,6 @@ TrigConf::JobOptionTableLoader::load( JobOptionTable& jot ) {
std::set<int> compIDsToLoad = loadComponentIDsFromSetup(setupId);
std::set<int> compIDsToLoad2 = loadComponentIDsFromMenu(triggerMenuID, level);
compIDsToLoad.insert(compIDsToLoad2.begin(), compIDsToLoad2.end());
TRG_MSG_INFO("Direct components => " << compIDsToLoad.size());
......
......@@ -101,6 +101,7 @@ TrigConf::MenuLoader::loadItems(TrigConf::Menu& menu) {
attList.extend<int> ( "TI.L1TI_VERSION" );
if(isRun2()) {
attList.extend<int> ( "TI.L1TI_PARTITION" );
attList.extend<string> ( "TI.L1TI_MONITOR" );
}
attList.extend<int> ( "TI.L1TI_CTP_ID" );
attList.extend<std::string>( "TI.L1TI_PRIORITY" );
......@@ -144,6 +145,12 @@ TrigConf::MenuLoader::loadItems(TrigConf::Menu& menu) {
item->setVersion (row["TI.L1TI_VERSION"].data<int>());
if(isRun2()) {
item->setPartition (row["TI.L1TI_PARTITION"].data<int>());
string mon = row["TI.L1TI_MONITOR"].data<string>();
unsigned short monMask = 0;
if(mon.find("TBP") != string::npos) monMask |= 0x1;
if(mon.find("TAP") != string::npos) monMask |= 0x2;
if(mon.find("TAV") != string::npos) monMask |= 0x4;
item->setMonitor( monMask );
}
string priority = row["TI.L1TI_PRIORITY"].data<string>();
......
......@@ -9,6 +9,7 @@
#include "CoolKernel/IFolder.h"
#include "CoralBase/Attribute.h"
#include "CoralBase/AttributeList.h"
#include "CoralBase/AttributeListException.h"
#include "CTPfragment/CTPdataformatVersion.h"
......@@ -218,20 +219,15 @@ TrigConfCoolL1PayloadConverters::createLvl1BGContentPayload( cool::IFolderPtr fl
Record payload(fld->payloadSpecification());
vector<unsigned char> codes(TrigConfCoolFolderSpec::mBGContentBlobSize,0);
// the output vector
vector<unsigned char> codes(2 * TrigConfCoolFolderSpec::mBGContentBlobSize, 0 );
std::vector<const BunchGroup*> bgOrdered(16,(const BunchGroup*)0);
// const vector<BunchGroup> & bgV = bgs.bunchGroups();
// vector<BunchGroup>::const_iterator bgIt = bgV.begin();
// for(bgIt = bgV.begin(); bgIt != bgV.end(); ++bgIt) {
// const BunchGroup* bgp = &*bgIt;
// bgOrdered.at(bgp->internalNumber()) = bgp;
// }
for(const BunchGroup & bgp: bgs.bunchGroups()) {
for(const BunchGroup & bgp: bgs.bunchGroups())
bgOrdered.at(bgp.internalNumber()) = &bgp;
}
for(int bgC=0; bgC<16; ++bgC) {
......@@ -239,31 +235,32 @@ TrigConfCoolL1PayloadConverters::createLvl1BGContentPayload( cool::IFolderPtr fl
if(bg==0) continue;
// mask describes the current bunchgroup (BG1: 1, BG2: 2, BG3: 4, ..., BG8: 128)
unsigned char mask = (1 << bgC);
const std::vector<int>& bV = bg->bunches();
std::vector<int>::const_iterator bIt = bV.begin();
for(; bIt!=bV.end(); ++bIt) {
if(*bIt<0 || *bIt>=TrigConfCoolFolderSpec::mBGContentBlobSize) {
unsigned char mask = (1 << (bgC % 8) );
unsigned int bgOffset = bgC < 8 ? 0 : TrigConfCoolFolderSpec::mBGContentBlobSize; // for BG 8-15 we use the higher part of the blob
for(int b : bg->bunches()) {
if(b<0 || b >= TrigConfCoolFolderSpec::mBGContentBlobSize) {
// this is a serious error which can't be ignored
std::string errorMsg = "Bunch groups ";
errorMsg += lexical_cast<std::string,int>(bgC);
errorMsg += " contains bunch number ";
errorMsg += lexical_cast<std::string,int>(*bIt);
errorMsg += " which is outside the range [0,3563]";
std::string errorMsg =
"Bunch group " + to_string(bgC) + " contains bunch number "
+ to_string(b) + " which is outside the range [0,3563]";
throw std::runtime_error(errorMsg);
}
codes[static_cast<unsigned int>(*bIt)] |= mask;
codes[static_cast<unsigned int>(b) + bgOffset] |= mask;
}
}
std::cout << "LVL1 bunchgroups [list 16 bunches per line]:" << std::endl;
// Get the blob, resize it to actual size, and push codes into it
//coral::Blob& blob = payload["BunchCode"].data<coral::Blob>();
coral::Blob blob;
blob.resize( TrigConfCoolFolderSpec::mBGContentBlobSize );
blob.resize( codes.size() );
unsigned char* p = static_cast<unsigned char*>(blob.startingAddress());
for (size_t i=0; i<static_cast<size_t>(TrigConfCoolFolderSpec::mBGContentBlobSize) ;++i,++p) {
for (size_t i=0; i < codes.size() ; ++i,++p) {
*p = codes[i];
cout << string(std::bitset<8>(codes[i]).to_string<char,std::char_traits<char>,std::allocator<char> >());
if((i+1)%16==0) cout << endl;
else cout << " ";
......@@ -512,21 +509,34 @@ TrigConfCoolL1PayloadConverters::createLvl1Threshold( const coral::AttributeList
vector<BunchGroup>
TrigConfCoolL1PayloadConverters::readLvl1BGContent( const coral::AttributeList & al) {
vector<BunchGroup> bgV(8);
const coral::Blob& blob = al["BunchCode"].data<coral::Blob>();
// check blob size - if we ever change the blob size, we have to work with schema versions here
if(blob.size() != TrigConfCoolFolderSpec::mBGContentBlobSize)
if(blob.size() != 3564 && blob.size() != 2 * 3564)
throw runtime_error("Read BLOB for BunchCode of unexpected size!");
unsigned int numberBG = (blob.size() == 3564) ? 8 : 16;
vector<BunchGroup> bgV(numberBG);
const unsigned char* p = static_cast<const unsigned char*>(blob.startingAddress());
for (size_t bunch = 0; bunch < static_cast<size_t>(blob.size());++bunch,++p) {
unsigned char mask = (*p);
if( bunch>3564 ) throw runtime_error("Exceed 3564 bunches!");
for (size_t bunch = 0; bunch < 3564; ++bunch, ++p) {
unsigned char mask = *p;
for(int i=0; i<8;i++) {
if( (mask>>i) & 0x1) bgV[i].addBunch(bunch);
}
}
if(blob.size() == 2 * 3564) { // Run 2 with have 8 more BG
for (size_t bunch = 0; bunch < 3564; ++bunch, ++p) {
unsigned char mask = *p;
for(int i=0; i<8;i++)
if( (mask>>i) & 0x1) bgV[8+i].addBunch(bunch);
}
}
return bgV;
}
......@@ -542,6 +552,17 @@ TrigConfCoolL1PayloadConverters::readLvl1BGDesc(const coral::AttributeList & al)
names.push_back(al["BunchGroup5"].data<cool::String255>());
names.push_back(al["BunchGroup6"].data<cool::String255>());
names.push_back(al["BunchGroup7"].data<cool::String255>());
try {
names.push_back(al["BunchGroup8"].data<cool::String255>());
names.push_back(al["BunchGroup9"].data<cool::String255>());
names.push_back(al["BunchGroup10"].data<cool::String255>());
names.push_back(al["BunchGroup11"].data<cool::String255>());
names.push_back(al["BunchGroup12"].data<cool::String255>());
names.push_back(al["BunchGroup13"].data<cool::String255>());
names.push_back(al["BunchGroup14"].data<cool::String255>());
names.push_back(al["BunchGroup15"].data<cool::String255>());
}
catch(const coral::AttributeListException &) {} // run2
std::map<unsigned int,unsigned char> codes;
const coral::Blob& blob = al["ItemToBunchGroupMap"].data<coral::Blob>();
......
......@@ -315,7 +315,7 @@ TrigConfCoolWriter::writeL1Payload( ValidityRange vr, const CTPConfig& ctpConfig
writeL1MenuPayload (vr, ctpConfig.menu());
writeL1BunchGroupRunPayload(vr, ctpConfig.menu(), ctpConfig.bunchGroupSet() ); // writes bunchgroup description folder
writeL1BunchGroupLBPayload (vr, ctpConfig.bunchGroupSet().id(), ctpConfig.bunchGroupSet()); // writes bunchgroup content and key folders
writeL1PrescalePayload(vr.since(), vr.until(), ctpConfig.id(), ctpConfig.prescaleSet());
writeL1PrescalePayload(vr.since(), vr.until(), ctpConfig.prescaleSet().id(), ctpConfig.prescaleSet());
}
catch(exception & e) {
m_ostream << "<writeL1Payload> caught and re-throw exception: " << e.what() << endl;
......@@ -455,6 +455,8 @@ TrigConfCoolWriter::writeRunPayload( const RunRangeVec& runRanges,
const TrigConf::HLTFrame & hltFrame,
const std::string & configSource)
{
cout << "JOERG begin of writeRunPayload" << endl;
AutoDBOpen db(this, READ_WRITE);
TrigConfCoolFolderSpec::createFolderStructure(m_dbPtr); // just in case
......@@ -740,8 +742,7 @@ TrigConf::TrigConfCoolWriter::writeL1MenuPayload( ValidityRange vr,
lvl1ThresholdFolder->setupStorageBuffer();
// go through the thresholds, channels assigned in the order (0..#thr-1)
// JOERG set back to 0 when done with the fixing
cool::ChannelId thrChannel = 2;
cool::ChannelId thrChannel = 0;
for(;thrIt != lvl1Thrs.end(); thrIt++) {
Record payloadThr = TrigConfCoolL1PayloadConverters::createLvl1ThresholdPayload( lvl1ThresholdFolder, **thrIt );
m_ostream << "Writing (to buffer) LVL1 threshold " << (*thrIt)->name()
......@@ -882,9 +883,6 @@ TrigConf::TrigConfCoolWriter::writeL1CTPCoreInputMapping( ValidityRange vr,
cool::IFolderPtr tipFolder = TrigConfCoolFolderSpec::getLvl1InputMapFolder(m_dbPtr);
tipFolder->setupStorageBuffer();
cout << "JOERG PIT SIZE " << lvl1Menu.pitVector().size() << endl;
cout << "JOERG TIP SIZE " << lvl1Menu.tipVector().size() << endl;
for ( const TIP * tip : lvl1Menu.tipVector() ) {
cool::ChannelId tipNum = static_cast<cool::ChannelId>(tip->tipNumber());
......@@ -917,17 +915,6 @@ TrigConf::TrigConfCoolWriter::writeL1CTPCoreInputMapping( ValidityRange vr,
// ------------------------------------------------------------
// writeLVL1BunchGroups()
// ------------------------------------------------------------
......@@ -1042,6 +1029,7 @@ TrigConf::TrigConfCoolWriter::writeHltPrescalePayload( ValidityKey since,
ValidityKey until,
const HLTPrescaleSet& pss)
{
AutoDBOpen db(this, READ_WRITE);
// writing configuration keys and prescales
try {
......@@ -1190,6 +1178,9 @@ TrigConf::TrigConfCoolWriter::writeL1PrescalePayload( cool::ValidityKey since,
unsigned int lvl1PrescaleKey,
const TrigConf::PrescaleSet & prescaleSet)
{
cout << "JOERG writeL1PrescalePayload " << lvl1PrescaleKey << endl;
prescaleSet.print("",5);
AutoDBOpen db(this, READ_WRITE);
// writing configuration keys and prescales
try {
......@@ -1198,18 +1189,20 @@ TrigConf::TrigConfCoolWriter::writeL1PrescalePayload( cool::ValidityKey since,
rangeInfo("LVL1 prescale key", since, until);
cool::Record payload =
TrigConfCoolL1PayloadConverters::createLvl1ConfigKeyPayload(lvl1CkConfFolder, lvl1PrescaleKey);
m_ostream << "Store LVL1 prescale key to /TRIGGER/LVL1/Lvl1ConfigKey" << endl;
m_ostream << "Store LVL1 prescale key " << lvl1PrescaleKey << " to /TRIGGER/LVL1/Lvl1ConfigKey" << endl;
lvl1CkConfFolder->storeObject(since, until, payload, 0);
}
if( shouldFolderBeUpdated("/TRIGGER/LVL1/Prescales") ) {
rangeInfo("LVL1 prescale set", since, until);
IFolderPtr lvl1PsConfFolder = TrigConfCoolFolderSpec::getLvl1PrescalesFolder(m_dbPtr);
// TODO: Changed to int64_t here
vector<int64_t> prescaleV = prescaleSet.prescales_ctp();
vector<int64_t>::const_iterator psIt = prescaleV.begin();
vector<int32_t> prescaleV = prescaleSet.cuts();
vector<int32_t>::const_iterator psIt = prescaleV.begin();
// use buffer to speed up COOL writing
lvl1PsConfFolder->setupStorageBuffer();
m_ostream << "Writing (to buffer) LVL1 prescales [(value/channel)]:" << endl;
for(int channel=0; psIt != prescaleV.end(); channel++, psIt++) {
Record payload =
......@@ -1421,18 +1414,12 @@ TrigConfCoolWriter::readL1Thresholds(unsigned int run,
AutoDBOpen db(this, READ_ONLY);
ValidityRange vr(run, 1);
thrs.clear();
IObjectIteratorPtr objects;
ChannelId thrChannel(0);
IFolderPtr L1thrFolder = TrigConfCoolFolderSpec::getLvl1ThresholdFolder(m_dbPtr);
for(;;) {
objects = L1thrFolder->browseObjects( vr.since(), vr.until()-1, thrChannel );
if(objects->size()==0) break;
while ( objects->goToNext() ) {
const IObject& obj = objects->currentRef();
const IRecord & payload = obj.payload();
thrs.push_back( createLvl1Threshold( payload.attributeList() ) );
}
thrChannel++;
IObjectIteratorPtr objects = L1thrFolder->browseObjects( vr.since(), vr.until()-1, cool::ChannelSelection() );
while ( objects->goToNext() ) {
const IObject& obj = objects->currentRef();
const IRecord & payload = obj.payload();
thrs.push_back( createLvl1Threshold( payload.attributeList() ) );
}
}
......@@ -1584,11 +1571,23 @@ TrigConfCoolWriter::readL1BunchGroupLBPayload( unsigned int run, unsigned int lb
pair< vector<string>, map<unsigned int,unsigned char> > bg_pair = readL1BunchGroupRunPayload(run);
vector<string> names = bg_pair.first;
uint newBGSSize = bgV.size() <= names.size() ? bgV.size() : names.size();
if(bgV.size() != names.size()) {
cout << "WARNING Bunchgroup content vector is of size " << bgV.size()
<< ", which is different from the size of the names vector: " << names.size()
<< ". Using " << newBGSSize << endl;
}
// create a new bunch group set, set names and bunch groups
bgs = BunchGroupSet();
for(unsigned int i=0; i<8; i++) {
if(names[i]=="") continue;
bgV[i].setName(names[i]);
for(unsigned int i=0; i<newBGSSize; i++) {
string bgname = names[i];
if(bgname=="") bgname = "NoName";
bgV[i].setName(bgname);
bgV[i].setInternalNumber(i);
bgs.addBunchGroup(bgV[i]);
}
......
......@@ -45,7 +45,14 @@ TrigConf::XMLMenuLoader::load(Menu& menu) {
if( readAttribute(v.second, "partition", ival) ) item->setPartition(ival);
if( readAttribute(v.second, "definition", sval) ) item->setDefinition(sval);
if( readAttribute(v.second, "ctpid", ival) ) item->setCtpId(ival);
if( readAttribute(v.second, "trigger_type", sval) ) { item->setTriggerType( TrigConf::bin2uint(sval) ); }
if( readAttribute(v.second, "trigger_type", sval) ) item->setTriggerType( TrigConf::bin2uint(sval) );
if( readAttribute(v.second, "monitor", sval) ) {
unsigned short monMask = 0;
if(sval.find("TBP") != string::npos) monMask |= 0x1;
if(sval.find("TAP") != string::npos) monMask |= 0x2;
if(sval.find("TAV") != string::npos) monMask |= 0x4;
item->setMonitor( monMask );
}
for(value_type top: v.second) {
if(top.first=="AND" || top.first=="InternalTrigger" || top.first=="TriggerCondition") {
......
......@@ -811,7 +811,7 @@ int main( int argc, char* argv[] ) {
ctpc.setBunchGroupSetId(bgKey);
sm->masterTableLoader().load(ctpc);
}
//ctpc.print();
//ctpc.print(" ",5);
}
// get the HLT trigger information
......@@ -839,21 +839,21 @@ int main( int argc, char* argv[] ) {
hltFrame,
configSource);
TrigConf::HLTPrescaleSet *hltpss = hltFrame.chains().extractPrescaleSet();
coolWriter.writeHltPrescalePayload( runRanges, *hltpss);
delete hltpss;
// TrigConf::HLTPrescaleSet *hltpss = hltFrame.chains().extractPrescaleSet();
// coolWriter.writeHltPrescalePayload( runRanges, *hltpss);
// delete hltpss;
} else {
coolWriter.writeL1MenuPayload(runRanges,ctpc.menu());
}
if(gConfig.WriteLevel() & JobConfig::LVL1) {
if(lvlPrescaleKey>0) {
coolWriter.writeL1PrescalePayload(runRanges,
lvlPrescaleKey,
lvl1ps);
}
}
// if(gConfig.WriteLevel() & JobConfig::LVL1) {
// if(lvlPrescaleKey>0) {
// coolWriter.writeL1PrescalePayload(runRanges,
// lvlPrescaleKey,
// lvl1ps);
// }
// }
} else { // write lumiblock-wise information (prescales only)
......@@ -1028,27 +1028,6 @@ int main( int argc, char* argv[] ) {
// ========================================
// READING information from the COOL DB for
// a certain run and print
......
......@@ -70,35 +70,40 @@ void printhelp(std::ostream & o, std::ostream& (*lineend) ( std::ostream& os ))
o << "TrigConfReadWrite <options>\n";
o << "\n";
o << "[Global options]\n";
o << " -i|--input input [input [input]] ... source of configuration (mandatory)\n";
o << " -2|--comp input [input [input]] ... source of a second configuration for comparison\n";
o << " -o|--output xml|cool [output[;cooldb]] ... output format, name\n";
o << " ... absolute output file name must contain '/', cooldb can be appended COMP200|OFLP200\n";
o << " -v|--loglevel <string> ... log level [NIL, VERBOSE, DEBUG, INFO, WARNING, ERROR, FATAL, ALWAYS]\n";
o << " -l|--log <string> ... name of a log file\n";
o << " --jo ... read and write job options where possible\n";
o << " --fw ... read ctp firmware\n";
o << " -p|--print <int> ... print configuration with detail 0...5 (default 1)\n";
o << " -h|--help ... this output\n";
o << " --nomerge ... internally don't merge L2 and EF (by default merge is enabled)\n";
o << "\n";
o << " -i|--input input [input [input]] ... source of configuration, format see below (mandatory)\n";
o << " -2|--comp input [input [input]] ... source of a second configuration for comparison\n";
o << " -o|--output xml|cool [output[;cooldb]] [run] ... output format, name (for cool optional run number)\n";
o << " ... absolute output file name must contain '/', cooldb can be appended COMP200|OFLP200\n";
o << " -v|--loglevel <string> ... log level [NIL, VERBOSE, DEBUG, INFO, WARNING, ERROR, FATAL, ALWAYS]\n";
o << " -l|--log <string> ... name of a log file\n";
o << " --jo ... read and write job options where possible\n";
o << " --fw ... read ctp firmware\n";
o << " -p|--print <int> ... print configuration with detail 0...5 (default 1)\n";
o << " -h|--help ... this output\n";
o << " --nomerge ... internally don't merge L2 and EF (by default merge is enabled)\n";
o << "\n\n";
o << "Input can be specified the following\n";
o << " -i [l1menu.xml] [hltmenu2.xml] ... to read L1 and/or HLT menu from XML [file names must end with '.xml'\n";
o << " -i DBALIAS|dbconnection smk[,l1psk,hltpsk,bgsk] ... to read the menu from a trigger db via alias or explicit connection specification (ORACLE or SQlite)\n";
o << " -i COOLDBALIAS|cooldbconnection run[,lb] ... to read the menu from COOL for a certain run and possbly LB\n";
o << " -i [l1menu.xml] [hltmenu2.xml] ... to read L1 and/or HLT menu from XML [file names must end with '.xml'\n";
o << " -i <TRIGDB_ALIAS>|<TRIGDB_connection> smk[,l1psk,hltpsk,bgsk] ... to read the menu from a trigger db via alias or explicit connection specification (ORACLE or SQlite)\n";
o << " -i <COOLDB_ALIAS>|<COOLDB_connection>|cool.db run[,lb] ... to read the menu from COOL for a certain run and possibly LB [file names must end with '.db']\n";
o << "\n";
o << "The dbconnection can be specified as following\n";
o << " 'sqlite:TriggerMenuSQLiteFile_rel1.sqlite'\n";
o << "The cool dbconnection can be specified as one of the following\n";
o << " - via alias : COOLONL_TRIGGER (use COOLONL_TRIGGER/COMP200 for Run 1 data)";
o << " - from sqlite : cool.db (use cool.db;COMP200 for Run 1 data)";
o << "\n";
o << "\n";
o << "Input for comparison can be specified the same way, using the '-2' or '--comp' option\n";
o << "\n";
o << "Input for comparison can be specified the same way, using the '-2' option\n";
o << "\n";
o << "Output formats can be xml or cool. In case a second input is specified for comparison, the output will be on screen or an xml file with the differences\n";
o << " -o xml test ... will produce LVL1config_test.xml and/or HLTconfig_test.xml. When\n";
o << " comparing two menus this will produce Diff_test.xml. In this case the\n";
o << " specification of '-o test' is sufficient\n";
o << " -o cool test ... will produce Menu_test.db\n";
o << " -o cool ... will produce trig_cool.db with cool db instance CONDBR2 and infinite IOV\n";
o << " -o cool 200000 ... will produce trig_cool.db with cool db instance CONDBR2 and run number 200000\n";
o << " -o cool test [200000] ... will produce trig_cool_test.db with cool db instance CONDBR2 [and run number 200000]\n";
o << " -o cool ../test.db [200000] ... will produce ../test.db with cool db instance CONDBR2 [and run number 200000]\n";
o << " -o cool 'test;COMP200' [200000] ... will produce Menu_test.db with cool db instance COMP200 [and run number 200000]\n";
o << "\n";
o << "================================================================================\n";
}
......@@ -121,8 +126,9 @@ public:
string l1xmlOutFile { "LVL1Config.xml" };
string l1topoOutFile { "L1TopoConfig.xml" };
string hltxmlOutFile { "HLTConfig.xml" };
string coolOutFile { "trig_cool.db" };
string coolDbname { "COMP200" };
string coolInputConnection { "" };
string coolOutputConnection { "" };
unsigned int coolOutputRunNr { 0 };
// other
bool help {false};
......@@ -160,6 +166,12 @@ namespace {
return false;
return (str.compare(0,sub.size(),sub) == 0);
}
bool isUnsignedInteger(const std::string& str) {
for(const char c : str)
if(c<'0' || c>'9') return false;
return true;
}
}
......@@ -228,11 +240,31 @@ JobConfig::parseProgramOptions(int argc, char* argv[]) {
if(inpar.size()==0)
error.push_back("No input specified, use '-i' option");
// parse the input
if( (inpar.size()==1 && endswith(inpar[0],".xml")) ||
(inpar.size()==2 && endswith(inpar[1],".xml") && endswith(inpar[1],".xml")) ) {
input = XML;
} else if( inpar.size()>=1 && ( endswith(inpar[0],".db") || startswith(inpar[0],"COOLONL_TRIGGER") ) ) {
} else if( inpar.size()>=1 && inpar[0].find(".db") != string::npos ) {
// sqlite file
input = COOL;
vector<string> ksv;
boost::split(ksv,inpar[0],boost::is_any_of(";"));
if(ksv.size()==1) { // defaults to CONDBR2
coolInputConnection = "sqlite://;schema="+ksv[0]+";dbname=CONDBR2";
} else {
coolInputConnection = "sqlite://;schema="+ksv[0]+";dbname=" + ksv[1];
}
} else if( inpar.size()>=1 && startswith(inpar[0],"COOLONL_TRIGGER") ) {
input = COOL;
vector<string> ksv;
boost::split(ksv,inpar[0],boost::is_any_of("/"));
if(ksv.size()==1) {
coolInputConnection = ksv[0]+"/CONDBR2";
} else {
coolInputConnection = ksv[0]+"/" + ksv[1];
}
} else if( inpar.size()==2 ) {
input = DB;
db = inpar[0];
......@@ -248,26 +280,33 @@ JobConfig::parseProgramOptions(int argc, char* argv[]) {
input2 = XML;
}
// parse the output
for(const string& o: outpar) {
if(o=="xml") { output |= XML; }
else if(o=="cool") { output |= COOL; }
else { outBase = o; }
if ( o=="xml") {
output |= XML;
} else if ( o=="cool" ) {
output |= COOL;
} else if ( isUnsignedInteger(o) ) {
coolOutputRunNr = boost::lexical_cast<unsigned int,string>(o);
} else {
outBase = o;
}
}
if (outBase != "") {
if( output & JobConfig::COOL ) {
string out = outBase;
size_t sempos = outBase.find(";");
if (sempos != string::npos) {
coolDbname = outBase.substr(sempos+1);
out = outBase.substr(0,sempos);
string dbname = "CONDBR2";
string outfile = outBase;
vector<string> ksv;
boost::split(ksv,outBase,boost::is_any_of(";"));
if(ksv.size()==2) { // defaults to CONDBR2
outfile = ksv[0];
dbname = ksv[1];
}
if (out.find("/") != string::npos) {
coolOutFile = out;
} else {
coolOutFile="trig_cool_" + out + ".db";
if (outfile.find("/")==string::npos && outfile.find('.')==string::npos) {
outfile="trig_cool_" + outfile + ".db";
}
coolOutputConnection = "sqlite://;schema="+outfile+";dbname="+dbname;