diff --git a/HLT/Trigger/TrigConfiguration/TrigConf2COOLOnline/CMakeLists.txt b/HLT/Trigger/TrigConfiguration/TrigConf2COOLOnline/CMakeLists.txt deleted file mode 100644 index dad6c4d4a5c7760b3750e2852945691768f1f827..0000000000000000000000000000000000000000 --- a/HLT/Trigger/TrigConfiguration/TrigConf2COOLOnline/CMakeLists.txt +++ /dev/null @@ -1,33 +0,0 @@ -################################################################################ -# Package: TrigConf2COOLOnline -################################################################################ - -# Declare the package name: -atlas_subdir( TrigConf2COOLOnline ) - -# External dependencies: -find_package( Boost COMPONENTS program_options ) -find_package( COOL COMPONENTS CoolKernel CoolApplication ) -find_package( tdaq COMPONENTS daq-core-dal daq-hlt-dal - rc_CmdLine rc_ItemCtrl rc_OnlSvc rc_RCCommands omniORB4 omnithread owl is ipc config TTCInfo) -find_package( tdaq-common COMPONENTS ers ) -find_package( TBB ) - -# Component(s) in the package: -atlas_add_library( TrigConf2COOLOnline - src/*.cxx - PUBLIC_HEADERS TrigConf2COOLOnline - INCLUDE_DIRS ${TDAQ-COMMON_INCLUDE_DIRS} ${TDAQ_INCLUDE_DIRS} - PRIVATE_INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${COOL_INCLUDE_DIRS} - ${TBB_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR} - LINK_LIBRARIES ${TDAQ-COMMON_LIBRARIES} ${TDAQ_LIBRARIES} - PRIVATE_LINK_LIBRARIES ${Boost_LIBRARIES} ${COOL_LIBRARIES} ${TBB_LIBRARIES} - TrigConfHLTData TrigConfL1Data TrigConfStorage ) - -atlas_add_executable( TrigConf2CoolOnline - src/TrigConf2CoolOnline.cxx - INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${TDAQ-COMMON_INCLUDE_DIRS} - ${TDAQ_INCLUDE_DIRS} - LINK_LIBRARIES ${Boost_LIBRARIES} ${TDAQ-COMMON_LIBRARIES} ${TDAQ_LIBRARIES} - TrigConf2COOLOnline ) - diff --git a/HLT/Trigger/TrigConfiguration/TrigConf2COOLOnline/TrigConf2COOLOnline/OnlTrigC2CWriter.h b/HLT/Trigger/TrigConfiguration/TrigConf2COOLOnline/TrigConf2COOLOnline/OnlTrigC2CWriter.h deleted file mode 100644 index 1a0a9a735dbb963f5f7226d813c63d2f9a33168f..0000000000000000000000000000000000000000 --- a/HLT/Trigger/TrigConfiguration/TrigConf2COOLOnline/TrigConf2COOLOnline/OnlTrigC2CWriter.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -*/ - -/* - * @file OnlTrigC2CWriter.h - * @author Joerg Stelzer - * $Author: stelzer $ - * $Revision: 1.1 $ - * $Date: 2008-07-28 13:58:08 $ - * - * @brief the online controlable class for writing configuration - * information from the TriggerDB to COOL - */ - -#ifndef TRIGCONF_ONLTRIGC2CWRITER_H -#define TRIGCONF_ONLTRIGC2CWRITER_H - -#include <string> -#include <iostream> -#include "TrigConf2COOLOnline/TC2CConfig.h" -#include "RunControl/Common/Controllable.h" -#include "ipc/partition.h" -#include "is/infodictionary.h" - -namespace TrigConf { - class OnlTrigC2CWriter; - class TrigConfCoolWriter; - class HLTFrame; - class CTPConfig; -} - -class ISInfoReceiver; -class ISCallbackInfo; -class ISInfoDictionary; -class IPCPartition; - -class TrigConf::OnlTrigC2CWriter : public daq::rc::Controllable { -public: - - /**@brief:constructor. - * @param name: this is the named published in IPC (required) - */ - OnlTrigC2CWriter(const std::string & partitionName, const std::string & cooldb, const std::string& triggerdb, bool l1is, bool l1cool, bool mckcool = false ); - OnlTrigC2CWriter(const OnlTrigC2CWriter&) = delete; - OnlTrigC2CWriter& operator=(OnlTrigC2CWriter const&) = delete; - - virtual ~OnlTrigC2CWriter() noexcept; - virtual void configure (const daq::rc::TransitionCmd&) override; - virtual void connect (const daq::rc::TransitionCmd&) override; //< connect to COOL and to TriggerDB - virtual void prepareForRun(const daq::rc::TransitionCmd&) override; - virtual void unconfigure (const daq::rc::TransitionCmd&) override; - virtual void user (const daq::rc::UserCmd& usrCmd) override; - virtual void stopArchiving(const daq::rc::TransitionCmd& cmd) override; - - TC2CConfig& conf() { return m_jobConfig; } - -private: - - bool readOKS(); // reading the configuration from OKS - - bool subscribeToIS(); // subscribe to IS - - void publishToIS(); // publish to IS - - void readTriggerDb(); // read HLT menu from TriggerDB - - void runNumberCallback(ISCallbackInfo *isc); - - void readRunNumberFromIS(); - - void writeHLTPrescaleSetToCool(unsigned int lb, unsigned int pskey, std::string& name); - - TC2CConfig m_jobConfig; // object to hold different configuration parameters - TrigConf::TrigConfCoolWriter* m_conf2Cool; // the class that does all the work - std::string m_triggerDB; - ISInfoReceiver* m_infoRec; - IPCPartition* m_IPCPartition; // the ipc partition object - - TrigConf::HLTFrame* m_HLTFrame; // pointer to the HLTFrame (could be skipped at the moment since it is still a singleton) - TrigConf::CTPConfig* m_CTPConfig; // the pointer to the lvl1 ctpc; - bool m_forceTriggerDBReadAtPrepareForRun { false }; - -}; - -#endif diff --git a/HLT/Trigger/TrigConfiguration/TrigConf2COOLOnline/TrigConf2COOLOnline/TC2CConfig.h b/HLT/Trigger/TrigConfiguration/TrigConf2COOLOnline/TrigConf2COOLOnline/TC2CConfig.h deleted file mode 100644 index 4b323b40abcedb389d52b23316c980ec906fbda0..0000000000000000000000000000000000000000 --- a/HLT/Trigger/TrigConfiguration/TrigConf2COOLOnline/TrigConf2COOLOnline/TC2CConfig.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef TRIGCONF_TC2CCONFIG -#define TRIGCONF_TC2CCONFIG - -#include <string> -#include <iosfwd> - -class TC2CConfig; - -std::ostream& operator<<( std::ostream& os, const TC2CConfig& event ); - -class TC2CConfig { - - friend std::ostream& operator<<( std::ostream& os, const TC2CConfig& event ); - -public: - TC2CConfig(); - ~TC2CConfig(); - - std::string& PartitionName() { return fPartitionName; } - std::string& CoolDb() { return fCoolDb; } - std::string& DBType() { return fDBType; } - std::string& DBServer() { return fDBServer; } - std::string& DBConnection() { return fDBConnection; } - std::string& DBUser() { return fDBUser; } - std::string& DBPasswd() { return fDBPasswd; } - std::string& DBName() { return fDBName; } - unsigned long& DBSMK() { return fDBSMK; } - unsigned long& DBL1PSK() { return fDBL1PSK; } - unsigned long& DBHLTPSK() { return fDBHLTPSK; } - std::string& DBSMcomment() { return fDBSMcomment; } - std::string& DBL1PScomment() { return fDBL1PScomment; } - std::string& DBHLTPScomment() { return fDBHLTPScomment; } - bool& UseTriggerDB() { return fUseTriggerDB; } - uint32_t& CurrentRunNumber() { return fCurrentRunNumber; } - uint32_t& LastWrittenRunNumber() { return fLastWrittenRunNumber; } - bool& COOLconnStat() { return fCOOLconnStat; } - bool& TriggerDBconnStat() { return fTriggerDBconnStat; } - bool& L1toIS() { return fL1toIS; } - bool& L1toCOOL() { return fL1toCOOL; } - - void TriggerDbConnectionParams(std::string& conn, std::string& user, std::string& pw); - - bool& MCKtoCOOL() { return fMCKtoCOOL; } - - unsigned long& DBMCK() { return fDBMCK; } - std::string& DBMCKrelease() { return fDBMCKrelease; } - std::string& DBMCKinfo() { return fDBMCKinfo; } - - -private: - std::string fPartitionName {""}; - std::string fCoolDb {""}; - std::string fDBType {""}; - std::string fDBServer {""}; - std::string fDBConnection {""}; - std::string fDBUser {""}; - std::string fDBPasswd {""}; - std::string fDBName {""}; - unsigned long fDBSMK {0}; - unsigned long fDBL1PSK {0}; - unsigned long fDBHLTPSK {0}; - std::string fDBSMcomment {""}; - std::string fDBL1PScomment {""}; - std::string fDBHLTPScomment {""}; - bool fUseTriggerDB {false}; - uint32_t fCurrentRunNumber {0}; - uint32_t fLastWrittenRunNumber {0}; - bool fCOOLconnStat {false}; - bool fTriggerDBconnStat {false}; - bool fL1toIS {false}; - bool fL1toCOOL {false}; - - bool fMCKtoCOOL {false}; - - unsigned long fDBMCK {0}; - std::string fDBMCKrelease {""}; - std::string fDBMCKinfo {""}; - -}; -#endif diff --git a/HLT/Trigger/TrigConfiguration/TrigConf2COOLOnline/src/OnlTrigC2CWriter.cxx b/HLT/Trigger/TrigConfiguration/TrigConf2COOLOnline/src/OnlTrigC2CWriter.cxx deleted file mode 100644 index 0054daf58941193c2ef10be1169b7eae4b519524..0000000000000000000000000000000000000000 --- a/HLT/Trigger/TrigConfiguration/TrigConf2COOLOnline/src/OnlTrigC2CWriter.cxx +++ /dev/null @@ -1,685 +0,0 @@ -/* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration -*/ - - -#undef PACKAGE_VERSION - -#include "TrigConfStorage/TrigConfCoolWriter.h" -#include "TrigConfStorage/StorageMgr.h" -#include "TrigConfStorage/MCKLoader.h" - -#include "CoolKernel/Exception.h" - -#include "TrigConfL1Data/CTPConfig.h" -#include "TrigConfHLTData/HLTFrame.h" -#include "TrigConfHLTData/HLTPrescaleSet.h" - -#include "TrigConf2COOLOnline/OnlTrigC2CWriter.h" - -#include "TTCInfo/TrigConfSmKeyNamed.h" -#include "TTCInfo/TrigConfL1PsKeyNamed.h" -#include "TTCInfo/TrigConfHltPsKeyNamed.h" -#include "TTCInfo/TrigConfReleaseNamed.h" - -#include "config/Configuration.h" - -#include "dal/Partition.h" -#include "dal/TriggerConfiguration.h" -#include "dal/TriggerDBConnection.h" -#include "dal/L1TriggerConfiguration.h" -#include "HLTPUDal/HLTImplementationDB.h" - -#include "RunControl/Common/Exceptions.h" -#include "RunControl/Common/RunControlCommands.h" -#include "RunControl/Common/OnlineServices.h" - -#include "ipc/partition.h" -#include "is/inforeceiver.h" -#include "is/infoany.h" -#include "is/info.h" -#include "is/infodictionary.h" - -#include "ers/ers.h" - -#include "rc/RunParams.h" -#include "rc/RunParamsNamed.h" - -#include "boost/lexical_cast.hpp" -#include "boost/algorithm/string.hpp" - -#include <algorithm> -#include <iostream> - -ERS_DECLARE_ISSUE( TrigConf, - BadCoolDB, - "Archiving to COOL failed because " << explanation, - ((const char*) explanation) - ) - -ERS_DECLARE_ISSUE( TrigConf, - CoolWriting, - "Archiving to COOL failed because " << explanation, - ((const char*) explanation) - ) - -ERS_DECLARE_ISSUE( TrigConf, - InvalidConfiguration, - "Configuration error - " << explanation, - ((const char*) explanation) - ) - -ERS_DECLARE_ISSUE( TrigConf, - TriggerDBReadError, - "Error when reading TriggerDB: " << explanation, - ((const char*) explanation) - ) - -ERS_DECLARE_ISSUE( TrigConf, - ISPublishing, - "IS publishing error: " << explanation, - ((const char*) explanation) - ) - -ERS_DECLARE_ISSUE( TrigConf, - InvalidUserCommand, - "Invalid user command: " << explanation, - ((const char*) explanation) - ) - -using namespace std; -using namespace TrigConf; - -OnlTrigC2CWriter::OnlTrigC2CWriter(const std::string & partitionName, const std::string& cooldb, const std::string& triggerdb, bool l1is, bool l1cool, bool mckcool ) : - Controllable() - , m_conf2Cool( new TrigConfCoolWriter(cooldb) ) - , m_triggerDB(triggerdb) - , m_infoRec(0) - , m_IPCPartition(0) - , m_HLTFrame(0) - , m_CTPConfig(0) -{ - conf().CoolDb() = cooldb; - conf().L1toIS() = l1is; - conf().L1toCOOL() = l1cool; - conf().PartitionName() = partitionName; - conf().MCKtoCOOL() = mckcool; - - m_IPCPartition = new IPCPartition( conf().PartitionName() ); -} - -TrigConf::OnlTrigC2CWriter::~OnlTrigC2CWriter() noexcept { - delete m_IPCPartition; - delete m_HLTFrame; - delete m_CTPConfig; - delete m_conf2Cool; - delete m_infoRec; -} - - -bool -OnlTrigC2CWriter::readOKS() { - - ERS_INFO("Reading configuration for partition " << conf().PartitionName()); - - try { - Configuration& oks = daq::rc::OnlineServices::instance().getConfiguration(); - - // get partition - const daq::core::Partition& partition = daq::rc::OnlineServices::instance().getPartition(); - - // get trigger configuration - const daq::core::TriggerConfiguration* triggerConfig = partition.get_TriggerConfiguration(); - if( triggerConfig == 0) - throw daq::rc::ConfigurationIssue(ERS_HERE, "No trigger configuration object in partition!"); - - - // LVL1 configuration object (to get L1 PSK) - const daq::core::L1TriggerConfiguration * l1Config = triggerConfig->get_l1(); - if(l1Config!=0) { - conf().DBL1PSK() = l1Config->get_Lvl1PrescaleKey(); - ERS_INFO("Read L1 PSK " << conf().DBL1PSK() ); - } else { - conf().DBL1PSK() = 0; - ERS_INFO("No LVL1 configuration."); - } - - - // get the HLT configuration - const daq::core::HLTImplementation * hlt = triggerConfig->get_hlt(); - if(hlt==0) { - ERS_INFO("No HLTImplementation configured"); - return false; - } else { - ERS_INFO("Found HLT Implementation" << *hlt << " ... " << hlt->UID()); - } - - const daq::hlt::HLTImplementationDB* hltDB = oks.get<daq::hlt::HLTImplementationDB>( hlt->UID() ); - if(hltDB==0) - ERS_INFO("HLT implementation '" << hlt->UID() << "' is not for running from TriggerDB."); - - // setting the HLT prescale key - conf().DBHLTPSK() = hltDB!=0 ? boost::lexical_cast<unsigned long,std::string>( hltDB->get_hltPrescaleKey() ) : 0; - - // get the DB connection - const daq::core::TriggerDBConnection * trigDb = triggerConfig->get_TriggerDBConnection(); - conf().UseTriggerDB() = (trigDb!=0); - if( conf().UseTriggerDB() ) { - conf().DBSMK() = trigDb->get_SuperMasterKey(); - if (trigDb->get_Alias()!="") { - conf().DBType() = "dblookup"; - conf().DBServer() = trigDb->get_Alias(); - } - else { - conf().DBType() = trigDb->get_Type(); - conf().DBServer() = trigDb->get_Server(); - conf().DBUser() = trigDb->get_User(); - conf().DBPasswd() = trigDb->get_Password(); - conf().DBName() = trigDb->get_Name(); - } - } else { - ERS_INFO("TriggerDBConnection not set in '" << triggerConfig->full_name() << "'"); - } - } - catch (const daq::rc::ConfigurationIssue & e) { - InvalidConfiguration issue(ERS_HERE, e.what()); - ers::fatal(issue); - return false; - } - catch (const daq::config::Generic & e) { - InvalidConfiguration issue(ERS_HERE, e.what()); - ers::fatal(issue); - return false; - } - - //ERS_LOG("" << "\nRead configuration needed for " << getName() << " from oks\n"); // this is like cout but with time and line info - - return true; -} - -bool -TrigConf::OnlTrigC2CWriter::subscribeToIS() { - - ERS_INFO("subscribing to IS (RunParams)."); - - if(!m_infoRec) m_infoRec = new ISInfoReceiver(*m_IPCPartition); - - try { - m_infoRec->subscribe("RunParams.SOR_RunParams", &OnlTrigC2CWriter::runNumberCallback, this); - } - catch (const daq::is::Exception & ex ) { - ers::fatal(ex); - return false; - } - return true; -} - - -void -TrigConf::OnlTrigC2CWriter::readRunNumberFromIS() { - - ERS_INFO("readRunNumberFromIS entered"); - - RunParamsNamed rp(*m_IPCPartition,"RunParams.SOR_RunParams"); - - rp.checkout(); - - conf().CurrentRunNumber() = rp.run_number; - - ERS_INFO("Read new run number: " << conf().CurrentRunNumber()); - -} - -void -TrigConf::OnlTrigC2CWriter::runNumberCallback(ISCallbackInfo *isc) { - if (isc->reason() == is::Deleted) - return; - - RunParams sor; - isc->value(sor); - - conf().CurrentRunNumber() = sor.run_number; - - ERS_INFO("Received new run number: " << conf().CurrentRunNumber()); - - return; -} - -void -TrigConf::OnlTrigC2CWriter::publishToIS() { - ERS_INFO("Publish to IS"); - - TrigConfSmKeyNamed sm(*m_IPCPartition,"RunParams.TrigConfSmKey"); - sm.SuperMasterKey = conf().DBSMK(); - sm.SuperMasterComment = conf().DBSMcomment(); - - TrigConfL1PsKeyNamed l1ps(*m_IPCPartition,"RunParams.TrigConfL1PsKey"); - l1ps.L1PrescaleKey = conf().DBL1PSK(); - l1ps.L1PrescaleComment = conf().DBL1PScomment(); - - TrigConfHltPsKeyNamed hltps(*m_IPCPartition,"RunParams.TrigConfHltPsKey"); - hltps.HltPrescaleKey = conf().DBHLTPSK(); - hltps.HltPrescaleComment = conf().DBHLTPScomment(); - - TrigConfReleaseNamed rel(*m_IPCPartition,"RunParams.TrigConfRelease"); - rel.HLTReleaseVersion = getenv("AtlasVersion")?getenv("AtlasVersion"):"Unknown Version"; - - if(getenv("AtlasProject")) { - rel.HLTPatchProject = getenv("AtlasProject"); - } else { - rel.HLTPatchProject = "Unknown Project"; - } - rel.HLTExtraPatch = ""; - - sm.print(std::cout); - l1ps.print(std::cout); - hltps.print(std::cout); - rel.print(std::cout); - - try { - sm.checkin(); - if(conf().L1toIS()) l1ps.checkin(); - hltps.checkin(); - rel.checkin(); - } - catch (daq::is::Exception& ex) { - TrigConf::ISPublishing issue(ERS_HERE, ex.what()); - ers::fatal(issue); - } - catch (std::exception & ex) { - TrigConf::ISPublishing issue(ERS_HERE, ex.what()); - ers::fatal(issue); - } - catch (CORBA::SystemException& ex) { - TrigConf::ISPublishing issue(ERS_HERE, ex._name()); - ers::fatal(issue); - } - catch (...) { - TrigConf::ISPublishing issue(ERS_HERE,"unknown exception"); - ers::fatal(issue); - //throw; - } - -} - -void -TrigConf::OnlTrigC2CWriter::readTriggerDb() { - - if(!conf().UseTriggerDB()) return; - - m_forceTriggerDBReadAtPrepareForRun = false; - - // clear the menu - delete m_HLTFrame; m_HLTFrame = 0; - - - // get the TriggerDB connection - std::string conn, user, pw; - conf().TriggerDbConnectionParams(conn,user,pw); - if(m_triggerDB!="") { - conn = m_triggerDB; - } - cout << "Using triggerdb connection : " << conn << endl; - // cout << "user : " << user << endl; - // cout << "pw : " << pw << endl; - - std::unique_ptr< StorageMgr > sm( new StorageMgr(conn,user,pw, cout) ); - - sm->sessionMgr(); - - conf().DBConnection() = sm->sessionMgr().connection(); - - if(conf().DBSMK()!=0 && conf().DBHLTPSK()!=0) { - - m_HLTFrame = new HLTFrame(); - - ERS_INFO("Reading HLT menu from the TriggerDB with SMK " << conf().DBSMK() << " and HLT PSK " << conf().DBHLTPSK() << "."); - - m_HLTFrame->setSMK(conf().DBSMK()); - m_HLTFrame->thePrescaleSetCollection().set_prescale_key_to_load( conf().DBHLTPSK() ); - try { - sm->hltFrameLoader().load( *m_HLTFrame ); - } - catch(const std::exception & e) { - TrigConf::TriggerDBReadError issue(ERS_HERE, e.what()); - ers::fatal(issue); - } - //fHLTPrescaleSet->fillFromFrame(m_HLTFrame); - conf().DBSMcomment() = m_HLTFrame->name(); - conf().DBHLTPScomment() = m_HLTFrame->getPrescaleSetCollection().prescaleSet()->name(); - - ERS_INFO("Done reading HLT menu"); - - } else { - ERS_INFO("Will not read SMK since one of these keys is 0: SMK = " << conf().DBSMK() << ", HLT PSK = " << conf().DBHLTPSK() << "."); - conf().DBHLTPScomment() = "No HLT Prescale key specified"; - conf().DBSMcomment() = "Not read since HLT prescale key was not specified"; - conf().DBHLTPSK()=0; - } - - if ( conf().MCKtoCOOL() ) { - if ( conf().DBSMK()!=0 ) { - ERS_INFO("Reading Menu-aware Monitoring MCK from the TriggerDB with SMK " << conf().DBSMK() << "."); - - try { - // get the mck - uint mck {0}; - std::string release {""}; - auto fMCKLoader = new MCKLoader(*sm); - fMCKLoader->loadMCKlinkedToSMK(conf().DBSMK(), mck); - conf().DBMCK() = mck; - if ( conf().DBMCK() !=0 ) { - fMCKLoader->loadReleaseLinkedToMCK(conf().DBMCK(), release); - conf().DBMCKrelease() = release; - } - } - catch(const std::exception & e) { - TrigConf::TriggerDBReadError issue(ERS_HERE, e.what()); - ers::error(issue); - } - - ERS_INFO("Done reading MCK " << conf().DBMCK() << " for release " << conf().DBMCKrelease() << "."); - } else { - ERS_INFO("Will not read MCK since SMK is 0: SMK = " << conf().DBSMK() << "."); - conf().DBMCKinfo() = "Not read since SMK not specified"; - } - } else { - ERS_INFO("Writing of MCK in HLT archiver is disabled"); - } - - if( conf().L1toCOOL() ) { - if( conf().DBSMK()!=0 ) { - ERS_INFO("Reading LVL1 menu from the TriggerDB"); - - // write also the L1 stuff to COOL (key+menu+prescales) - // should only happen in rare circumstances - delete m_CTPConfig; - m_CTPConfig = new CTPConfig(); - - m_CTPConfig->setSuperMasterTableId(conf().DBSMK()); - try { - sm->masterTableLoader().load(*m_CTPConfig); - } - catch(const std::exception& e) { - TrigConf::TriggerDBReadError issue(ERS_HERE, e.what()); - ers::fatal(issue); - } - ERS_INFO("LVL1 menu read"); - - // prescales - PrescaleSet l1pss; - l1pss.setId(conf().DBL1PSK()); - try { - sm->prescaleSetLoader().load(l1pss); - } - catch(const std::exception& e) { - TrigConf::TriggerDBReadError issue(ERS_HERE, e.what()); - ers::fatal(issue); - } - ERS_INFO("LVL1 prescales read"); - - m_CTPConfig->setPrescaleSet( l1pss ); - - } - } else { - ERS_INFO("Writing of LVL1 menu in HLT archiver is disabled"); - } -} - -void -TrigConf::OnlTrigC2CWriter::configure(const daq::rc::TransitionCmd& cmd) { - ERS_INFO("CONFIGURE(" << cmd.toString() << ") -> read OKS, subscribe to IS for run number, read hlt config from TriggerDB."); - readOKS(); - ERS_INFO(conf()); - subscribeToIS(); - readTriggerDb(); -} - - -void -TrigConf::OnlTrigC2CWriter::connect(const daq::rc::TransitionCmd& cmd) { - if(conf().UseTriggerDB()) { - ERS_INFO("CONNECT(" << cmd.toString() << ") -> check COOL connection, publish to IS"); - } else { - ERS_INFO("CONNECT(" << cmd.toString() << ") -> nothing to do since we are not running from the TriggerDB"); - return; - } - // first thing to do is to check the connection to COOL. We quickly open and close. - ERS_INFO("Checking COOL DB connection."); - try { - m_conf2Cool->checkDbConnection(false); - } - catch(cool::Exception& e) { - TrigConf::BadCoolDB issue(ERS_HERE, e.what()); - ers::fatal(issue); - return; - } - - publishToIS(); -} - - -void -TrigConf::OnlTrigC2CWriter::prepareForRun(const daq::rc::TransitionCmd& cmd) { - - ERS_INFO("Entered prepareForRun"); - - if(m_forceTriggerDBReadAtPrepareForRun) { - ERS_INFO("m_forceTriggerDBReadAtPrepareForRun is true, rereading from triggerDB with this configuration."); - ERS_INFO(conf()); - readTriggerDb(); - } - - - - readRunNumberFromIS(); - - if(conf().UseTriggerDB()) { - ERS_INFO("PREPAREFORRUN(" << cmd.toString() << ") -> write hlt config to COOL. Current run number " << conf().CurrentRunNumber()); - } else { - ERS_INFO("PREPAREFORRUN(" << cmd.toString() << ") -> nothing to do since we are not running from the TriggerDB"); - return; - } - - TrigConf::ThresholdConfig thrcfg; - TrigConf::CaloInfo ci; - - std::string configurationSource = conf().DBConnection() + ","; - if(getenv("AtlasVersion")) { - configurationSource += std::string(getenv("AtlasVersion")) + std::string(","); - } else { - configurationSource += std::string("Unknown Version,"); - } - if(getenv("AtlasProject")) { - configurationSource += std::string(getenv("AtlasProject")); - } else { - configurationSource += std::string("Unknown Project"); - } - - // write the payload - std::cout << "Configuration source: " << configurationSource << std::endl; - std::cout << "=====================================================" << std::endl; - std::cout << m_CTPConfig << std::endl; - if(m_CTPConfig) - std::cout << *m_CTPConfig << std::endl; - std::cout << "=====================================================" << std::endl; - std::cout << m_HLTFrame << std::endl; - if(m_HLTFrame) - std::cout << *m_HLTFrame << std::endl; - std::cout << "=====================================================" << std::endl; - - - if(m_HLTFrame) { - if(0!=m_HLTFrame && 0!=m_CTPConfig) { - m_conf2Cool->writeRunPayload(conf().CurrentRunNumber(), - (unsigned int) conf().DBSMK(), - (unsigned int) conf().DBHLTPSK(), // if 0 then no menu will be saved - thrcfg, // ignored - *m_CTPConfig, - ci, // ignored - *m_HLTFrame, - configurationSource); - } else if (0!=m_HLTFrame && 0==m_CTPConfig) { - m_conf2Cool->writeHLTPayload( ValidityRange( conf().CurrentRunNumber() ), *m_HLTFrame, configurationSource); - ERS_INFO("Prescale Set ptr = " << (void*)m_HLTFrame->getPrescaleSetCollection().prescaleSet()); - m_conf2Cool->writeHltPrescalePayload( conf().CurrentRunNumber(), 1, *m_HLTFrame->getPrescaleSetCollection().prescaleSet()); - } - } else { - ERS_INFO("Menu will not be written to COOL, since it was not read from the TriggerDB"); - } - - if(conf().MCKtoCOOL()) { - if (conf().DBMCK() != 0){ - m_conf2Cool->writeMCKPayload( conf().CurrentRunNumber(), conf().DBMCK(), conf().DBMCKrelease(), conf().DBMCKinfo()); - ERS_INFO("Done writing MCK " << conf().DBMCK() << " for release " << conf().DBMCKrelease() << " to COOL."); - } else { - ERS_INFO("MCK not written to COOL since it is 0"); - } - } -} - - -void -TrigConf::OnlTrigC2CWriter::unconfigure(const daq::rc::TransitionCmd& cmd) { - ERS_INFO("UNCONFIGURE(" << cmd.toString() << ") -> unsubscribe from IS"); - - // unsubscribe from IS - try { - m_infoRec->unsubscribe(".*"); - } - catch(ers::Issue & e) { - } - delete m_infoRec; m_infoRec = 0; -} - - - -void -TrigConf::OnlTrigC2CWriter::writeHLTPrescaleSetToCool(unsigned int lb, unsigned int pskey, std::string& name) { - - ERS_INFO("Entered writeHLTPrescaleSetToCool with LB = " << lb << " and HLT psk " << pskey); - - if(!conf().UseTriggerDB()) return; - - if(!m_HLTFrame) { - ERS_INFO("Running without the HLT, can not write HLT prescales to COOL"); - return; - } - - readRunNumberFromIS(); - - std::string conn(""), user(""), pw(""); - conf().TriggerDbConnectionParams(conn,user,pw); - std::unique_ptr< TrigConf::StorageMgr > sm(new TrigConf::StorageMgr(conn,user,pw)); - - HLTPrescaleSet* hltPrescaleSet = new HLTPrescaleSet(); - - hltPrescaleSet->setId(pskey); - sm->hltPrescaleSetLoader().load( *hltPrescaleSet ); - name = hltPrescaleSet->name(); - - ERS_INFO("writeHLTPrescaleSetToCool: HLT psk " << pskey << ", name " << name << " for Run " << conf().CurrentRunNumber() << " and LB " << lb); - - m_HLTFrame->thePrescaleSetCollection().addPrescaleSet( lb, hltPrescaleSet ); - - m_conf2Cool->writeHltPrescalePayload( conf().CurrentRunNumber(), lb, *hltPrescaleSet ); -} - - -void -TrigConf::OnlTrigC2CWriter::user(const daq::rc::UserCmd& usrCmd) { - - string commandName = usrCmd.commandName(); - vector<string> arguments = usrCmd.commandParameters(); - - ERS_INFO("Received '" << commandName << "' [" << usrCmd.toString() << "]"); - - // this is a hack until the CTP controller sends the correct user command - - ERS_INFO("Received command " << commandName << " (" << usrCmd.toString() << ")"); - if(commandName == "USER") { - ERS_INFO("User command " << usrCmd.toString() << " not formed correctly, need to apply parser hack."); - - vector<string> splitarg; - boost::split(splitarg, arguments[0], boost::is_any_of(" ")); - - arguments.clear(); - bool first(true); - for(const string& s : splitarg) { - if(first) { - commandName = s; - first = false; - } else { - arguments.push_back(s); - } - } - } - - ERS_INFO("Command " << commandName); - unsigned int i(0); - for(const string& s :arguments) { - ERS_INFO(" arg " << i++ << " " << s); - } - - - if( commandName == "HLTPRESCALE2COOL" ) { - - if( arguments.size() != 2) { - TrigConf::InvalidUserCommand issue(ERS_HERE,"'HLTPRESCALE2COOL' needs exactly 2 arguments: LB and HLT PS key"); - ers::warning(issue); - return; - } - - unsigned int lb = boost::lexical_cast<unsigned int, std::string>(arguments[0]); - unsigned int pskey = boost::lexical_cast<unsigned int, std::string>(arguments[1]); - - std::string pssname(""); - try { - writeHLTPrescaleSetToCool(lb, pskey, pssname); - } - catch(std::exception & ex) { - TrigConf::CoolWriting issue(ERS_HERE, ex.what()); - ers::error(issue); - } - - // updating the internally held key - conf().DBHLTPSK() = pskey; - - - // publish to IS RunParams - TrigConfHltPsKeyNamed hltps(*m_IPCPartition,"RunParams.TrigConfHltPsKey"); - hltps.HltPrescaleKey = pskey; - hltps.HltPrescaleComment = pssname; - - try { - hltps.checkin(); - ERS_INFO("Published current hlt pskey " << pskey << " to RunParams.TrigConfHltPsKey"); - - } - catch (daq::is::Exception& ex) { - TrigConf::ISPublishing issue(ERS_HERE, ex.what()); - ers::error(issue); - } - catch (std::exception & ex) { - TrigConf::ISPublishing issue(ERS_HERE, ex.what()); - ers::error(issue); - } - catch (CORBA::SystemException& ex) { - TrigConf::ISPublishing issue(ERS_HERE, ex._name()); - ers::error(issue); - } - catch (...) { - TrigConf::ISPublishing issue(ERS_HERE,"unknown exception"); - ers::error(issue); - } - } -} - - -void -TrigConf::OnlTrigC2CWriter::stopArchiving(const daq::rc::TransitionCmd&) { - ERS_INFO("stopArchiving"); - ERS_INFO("setting m_forceTriggerDBReadAtPrepareForRun to true"); - m_forceTriggerDBReadAtPrepareForRun = true; - -} diff --git a/HLT/Trigger/TrigConfiguration/TrigConf2COOLOnline/src/TC2CConfig.cxx b/HLT/Trigger/TrigConfiguration/TrigConf2COOLOnline/src/TC2CConfig.cxx deleted file mode 100644 index 78054157b7e68474ee8ab0b44a0f19ec2d38d84e..0000000000000000000000000000000000000000 --- a/HLT/Trigger/TrigConfiguration/TrigConf2COOLOnline/src/TC2CConfig.cxx +++ /dev/null @@ -1,58 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#include <iostream> -#include <algorithm> - -#include "TrigConf2COOLOnline/TC2CConfig.h" - -using std::endl; - -TC2CConfig::TC2CConfig() -{} - -TC2CConfig::~TC2CConfig() -{} - -void -TC2CConfig::TriggerDbConnectionParams(std::string& conn, std::string& user, std::string& pw) { - user = DBUser(); - pw = DBPasswd(); - - std::string dbtype = DBType(); - std::transform(dbtype.begin(),dbtype.end(),dbtype.begin(),tolower); - if (dbtype == "oracle") { - conn = "oracle://" + DBServer() + "/" + DBName(); - } else if (dbtype == "mysql") { - conn = "mysql://" + DBServer() + "/" + DBName(); - } else if (dbtype == "sqlite") { - conn = "sqlite://" + DBServer() + "/" + DBName(); - } else if (dbtype == "dblookup") { - conn = DBServer(); - user = pw = ""; - } -} - - -std::ostream& operator<<(std::ostream& os, const TC2CConfig& c) { - os << "Job configuration:" << endl - << " COOL connection : " << c.fCoolDb << endl - << " Use TriggerDB : " << (c.fUseTriggerDB?"true":"false") << endl; - if(c.fUseTriggerDB) - os << " Trigger DB connection parameter" << endl - << " Type : " << c.fDBType << endl - << " Server : " << c.fDBServer << endl - << " User : " << c.fDBUser << endl - << " Passwd : " << c.fDBPasswd << endl - << " Name : " << c.fDBName << endl - << " SMK : " << c.fDBSMK << endl - << " L1 PSK : " << c.fDBL1PSK << endl - << " HLT PSK : " << c.fDBHLTPSK << endl; - os << " Current run number: " << c.fCurrentRunNumber << endl; - os << " Last run number written to COOL: " << c.fLastWrittenRunNumber << endl; - os << " COOL connection status: " << (c.fCOOLconnStat?"connected":"disconnected") << endl; - os << " TriggerDB connection status: " << (c.fTriggerDBconnStat?"connected":"disconnected") << endl; - - return os; -} diff --git a/HLT/Trigger/TrigConfiguration/TrigConf2COOLOnline/src/TrigConf2CoolOnline.cxx b/HLT/Trigger/TrigConfiguration/TrigConf2COOLOnline/src/TrigConf2CoolOnline.cxx deleted file mode 100644 index b371a66d6d3f9142b6a6555ca8ed6af11b3125a4..0000000000000000000000000000000000000000 --- a/HLT/Trigger/TrigConfiguration/TrigConf2COOLOnline/src/TrigConf2CoolOnline.cxx +++ /dev/null @@ -1,126 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -/** - * @file TrigConf2CoolOnline.cxx - * @author Joerg Stelzer - * $Author: stelzer $ - * $Revision: 1.1 $ - * $Date: 2008-07-28 13:58:08 $ - * - * @brief Application to write trigger configuration from TriggerDB to COOL - * - */ - -#undef PACKAGE_VERSION - -#include "TrigConf2COOLOnline/OnlTrigC2CWriter.h" - -#include "ipc/core.h" -#include "ers/ers.h" -#include "cmdl/cmdargs.h" - -#include <string> -#include "RunControl/Common/CmdLineParser.h" -#include "RunControl/Common/Exceptions.h" -#include "RunControl/ItemCtrl/ItemCtrl.h" - -#include <boost/program_options.hpp> - -namespace po = boost::program_options; - -using namespace std; -using namespace daq; -using namespace TrigConf; - -ERS_DECLARE_ISSUE (TrigConf, ExitNow, "FATAL ERROR: ", ) - - - - -ERS_DECLARE_ISSUE(TrigConf, Exception, ERS_EMPTY, ERS_EMPTY) - -ERS_DECLARE_ISSUE_BASE ( TrigConf, - CmdLineError, - TrigConf::Exception, - "Error parsing the command line options: " << reason, - ERS_EMPTY, - ((std::string) reason) - ) - - - -int main (int argc, char **argv) { - - for(int i=0; i<argc; ++i) - cout << argv[i] << " "; - cout << endl; - - try { - IPCCore::init(argc,argv); - } - catch(daq::ipc::CannotInitialize& e) { - ers::fatal(e); - abort(); - } - catch(daq::ipc::AlreadyInitialized& e) { - ers::warning(e); - } - - // parse commandline parameters - po::options_description desc("This program writes the trigger configuration for the current run to COOL"); - desc.add_options() - ("help,h", "print usage and exit") - ("cooldb", po::value<string>(), "COOL db connection tech://schema=;dbname=\nsqlite://;schema=trigconf.db;dbname=TRIGCONF") - ("triggerdb", po::value<string>(), "TriggerDB connection alias") - ("l1is", "if set L1 key is written to IS") - ("l1cool", "if set L1 information is written to COOL") - ("name,n", po::value<string>(), "application name") - ("mckcool", "if set MCK is written to COOL") - ; - - // Get commandline parameters - po::variables_map vm; - po::store( po::command_line_parser(argc, argv).options(desc).allow_unregistered().run(), vm); - po::notify(vm); - - string cooldb("sqlite://;schema=trigconf.db;dbname=TRIGCONF"); - - if(vm.count("cooldb")) { - cooldb = vm["cooldb"].as<string>(); - cout << "Application parameter cooldb=" << cooldb << endl; - } else if(!vm.count("help")) { - ers::fatal( TrigConf::CmdLineError(ERS_HERE, "No cool connection parameter has been defined") ); - return EXIT_FAILURE; - } - bool l1is = vm.count("l1is")>0; - bool l1cool = vm.count("l1cool")>0; - bool mckcool = vm.count("mckcool")>0; - string triggerdb( vm.count("triggerdb") ? vm["triggerdb"].as<string>() : string("") ); - - rc::CmdLineParser cmdParser(argc, argv, true); - - try { - rc::ItemCtrl itemCtrl(cmdParser, - shared_ptr<rc::Controllable>(new OnlTrigC2CWriter(cmdParser.partitionName(), cooldb, triggerdb, l1is, l1cool, mckcool))); - itemCtrl.init(); - itemCtrl.run(); - } - catch(daq::rc::CmdLineHelp& ex) { - cout << desc << endl; - cout << ex.message() << endl; - } - catch(ers::Issue& ex) { - TrigConf::ExitNow issue(ERS_HERE, ex); - ers::fatal(ex); - return EXIT_FAILURE; - } - catch(po::error& ex) { - ers::fatal(rc::CmdLineError(ERS_HERE, ex.what(), ex)); - return EXIT_FAILURE; - } - - return EXIT_SUCCESS; - -}