Commit 06adca04 authored by Joerg Stelzer's avatar Joerg Stelzer Committed by Walter Lampl
Browse files

Dropping dependency on athena on demand

L1 trigger software can use these packages setting
set( BuildWithoutAthena True )
parent fd483d80
......@@ -7,8 +7,9 @@ atlas_subdir( TrigConfBase )
# Declare the package's dependencies:
atlas_depends_on_subdirs(
PRIVATE
Control/AthenaBaseComps )
PRIVATE
Control/AthenaBaseComps
)
# External dependencies:
find_package( Boost COMPONENTS regex thread )
......@@ -24,12 +25,14 @@ atlas_install_joboptions( share/*.py )
# Tests:
if( NOT XAOD_STANDALONE )
atlas_add_component( TrigConfBaseTest
test/TrigConfMsgAlg.cxx
LINK_LIBRARIES TrigConfBase AthenaBaseComps )
atlas_add_test( trigconf_msg_athena_test
SCRIPT athena.py TrigConfBase/test_TrigConfMsgAlg.py )
endif()
if( APPLE )
......
......@@ -9,17 +9,29 @@ atlas_subdir( TrigConfData )
atlas_depends_on_subdirs( PUBLIC
Control/AthenaKernel
PRIVATE
Control/CxxUtils
)
# External dependencies:
find_package( Boost REQUIRED )
# Component(s) in the package:
atlas_add_library ( TrigConfData TrigConfData/*.h src/*.cxx
# athena library for the package:
# defines CLID for some data objects
atlas_add_library ( TrigConfData
TrigConfData/*.h src/*.cxx
PUBLIC_HEADERS TrigConfData
INCLUDE_DIRS ${Boost_INCLUDE_DIRS}
LINK_LIBRARIES ${Boost_LIBRARIES} AthenaKernel
)
# standalone library for use by detector software:
# no Athena / Gaudi dependency
atlas_add_library ( TrigConfDataSA
TrigConfData/*.h src/*.cxx
PUBLIC_HEADERS TrigConfData
INCLUDE_DIRS ${Boost_INCLUDE_DIRS}
LINK_LIBRARIES ${Boost_LIBRARIES} AthenaKernel )
LINK_LIBRARIES ${Boost_LIBRARIES}
DEFINITIONS -DTRIGCONF_STANDALONE
)
atlas_add_test( ConstIter SOURCES test/itertest.cxx
INCLUDE_DIRS ${Boost_INCLUDE_DIRS}
......
......@@ -12,7 +12,8 @@
* @brief Forward iterator to traverse the main components of the trigger configuration
*/
#include "CxxUtils/checker_macros.h"
#include "TrigConfData/TSCheckMacros.h"
#include <iostream>
#include <functional>
......
......@@ -169,11 +169,15 @@ namespace TrigConf {
}
#include "AthenaKernel/CLASS_DEF.h"
#ifndef TRIGCONF_STANDALONE
#include "AthenaKernel/CLASS_DEF.h"
CLASS_DEF( TrigConf::DataStructure , 98904516 , 1 )
#include "AthenaKernel/CondCont.h"
CONDCONT_DEF( TrigConf::DataStructure , 265887802 );
#endif
#endif
......@@ -53,11 +53,14 @@ namespace TrigConf {
};
}
#ifndef TRIGCONF_STANDALONE
#include "AthenaKernel/CLASS_DEF.h"
CLASS_DEF( TrigConf::HLTMenu , 24176960 , 1 )
#include "AthenaKernel/CondCont.h"
CONDCONT_DEF( TrigConf::HLTMenu , 155284098 );
#endif
#endif
......@@ -66,6 +66,8 @@ namespace TrigConf {
};
}
#ifndef TRIGCONF_STANDALONE
#include "AthenaKernel/CLASS_DEF.h"
CLASS_DEF( TrigConf::HLTPrescalesSet , 134177107 , 1 )
......@@ -73,3 +75,5 @@ CLASS_DEF( TrigConf::HLTPrescalesSet , 134177107 , 1 )
CONDCONT_DEF( TrigConf::HLTPrescalesSet , 130966407 );
#endif
#endif
......@@ -72,6 +72,8 @@ namespace TrigConf {
}
#ifndef TRIGCONF_STANDALONE
#include "AthenaKernel/CLASS_DEF.h"
CLASS_DEF( TrigConf::L1Menu , 26419484 , 1 )
......@@ -79,3 +81,5 @@ CLASS_DEF( TrigConf::L1Menu , 26419484 , 1 )
CONDCONT_DEF( TrigConf::L1Menu , 11747932 );
#endif
#endif
......@@ -57,6 +57,8 @@ namespace TrigConf {
};
}
#ifndef TRIGCONF_STANDALONE
#include "AthenaKernel/CLASS_DEF.h"
CLASS_DEF( TrigConf::L1PrescalesSet , 146597935 , 1 )
......@@ -64,3 +66,5 @@ CLASS_DEF( TrigConf::L1PrescalesSet , 146597935 , 1 )
CONDCONT_DEF( TrigConf::L1PrescalesSet , 124562173 );
#endif
#endif
/*
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/
#ifndef TRIGCONFDATA_TSCHECKMACROS_H
#define TRIGCONFDATA_TSCHECKMACROS_H
#ifdef TRIGCONF_STANDALONE
#ifdef ATLAS_GCC_CHECKERS
#define ATLAS_THREAD_SAFE [[gnu::thread_safe]]
#else
#define ATLAS_THREAD_SAFE
#endif
#else
#include "CxxUtils/checker_macros.h"
#endif
#endif
......@@ -4,7 +4,6 @@
#include <iostream>
#include "TrigConfData/DataStructure.h"
#include <boost/property_tree/json_parser.hpp>
using TV = boost::property_tree::ptree::value_type; // tree-value type
using namespace std;
......
......@@ -7,43 +7,43 @@ atlas_subdir( TrigConfIO )
# Declare the package's dependencies:
atlas_depends_on_subdirs( PUBLIC
GaudiKernel
Trigger/TrigConfiguration/TrigConfData
Trigger/TrigConfiguration/TrigConfBase
Trigger/TrigConfiguration/TrigConfData
PRIVATE
Control/StoreGate
Control/AthenaBaseComps
Tools/PathResolver
)
# External dependencies:
find_package( Boost )
find_package( CORAL COMPONENTS CoralBase CoralKernel RelationalAccess )
# Component(s) in the package:
atlas_add_library( TrigConfIOLib
TrigConfIO/*.h src/JsonFileLoader.cxx src/TrigDBLoader.cxx src/TrigDBMenuLoader.cxx src/TrigDBJobOptionsLoader.cxx src/TrigDBL1PrescalesSetLoader.cxx src/TrigDBHLTPrescalesSetLoader.cxx
atlas_add_library( TrigConfIO
TrigConfIO/*.h src/*.cxx
PUBLIC_HEADERS TrigConfIO
INCLUDE_DIRS ${Boost_INCLUDE_DIRS}
LINK_LIBRARIES ${Boost_LIBRARIES} TrigConfBase TrigConfData GaudiKernel
PRIVATE_LINK_LIBRARIES PathResolver
PRIVATE_INCLUDE_DIRS ${CORAL_INCLUDE_DIRS}
LINK_LIBRARIES TrigConfData TrigConfBase
PRIVATE_LINK_LIBRARIES ${Boost_LIBRARIES} ${CORAL_LIBRARIES} -lstdc++fs
)
atlas_add_component( TrigConfIO
src/HLTMenuCondAlg.* src/L1MenuCondAlg.* src/components/*.cxx
LINK_LIBRARIES GaudiKernel AthenaBaseComps StoreGateLib TrigConfData
TrigConfIOLib
atlas_add_library( TrigConfIOSA
TrigConfIO/*.h src/*.cxx
PUBLIC_HEADERS TrigConfIO
INCLUDE_DIRS ${Boost_INCLUDE_DIRS}
PRIVATE_INCLUDE_DIRS ${CORAL_INCLUDE_DIRS}
LINK_LIBRARIES TrigConfDataSA TrigConfBase
DEFINITIONS -DTRIGCONF_STANDALONE
PRIVATE_LINK_LIBRARIES ${Boost_LIBRARIES} ${CORAL_LIBRARIES} -lstdc++fs
)
atlas_add_executable( TestTriggerMenuAccess utils/TestTriggerMenuAccess.cxx
INCLUDE_DIRS ${Boost_INCLUDE_DIRS}
LINK_LIBRARIES ${Boost_LIBRARIES} TrigConfData TrigConfIOLib
)
INCLUDE_DIRS ${Boost_INCLUDE_DIRS}
LINK_LIBRARIES ${Boost_LIBRARIES} TrigConfData TrigConfIO
)
atlas_add_executable( TriggerMenuRW utils/TriggerMenuRW.cxx
INCLUDE_DIRS ${Boost_INCLUDE_DIRS}
LINK_LIBRARIES ${Boost_LIBRARIES} TrigConfIOLib
LINK_LIBRARIES ${Boost_LIBRARIES} TrigConfIO
)
# Install files from the package.
......@@ -54,9 +54,9 @@ atlas_install_joboptions( share/*.py )
# Test(s) in the package.
atlas_add_test( ReadTriggerConfig
SOURCES test/read_config_info.cxx
LINK_LIBRARIES TrigConfData TrigConfIOLib
ENVIRONMENT "TESTFILEPATH=${CMAKE_CURRENT_SOURCE_DIR}/test/data"
POST_EXEC_SCRIPT nopost.sh
)
SOURCES test/read_config_info.cxx
LINK_LIBRARIES TrigConfData TrigConfIO
ENVIRONMENT "TESTFILEPATH=${CMAKE_CURRENT_SOURCE_DIR}/test/data"
POST_EXEC_SCRIPT nopost.sh
)
......@@ -12,13 +12,11 @@
#ifndef TRIGCONFSTORAGE_JSONFILELOADER_H
#define TRIGCONFSTORAGE_JSONFILELOADER_H
#include "GaudiKernel/StatusCode.h"
#include "boost/property_tree/ptree.hpp"
#include "TrigConfBase/TrigConfMessaging.h"
#include "TrigConfData/DataStructure.h"
#include "boost/property_tree/ptree.hpp"
namespace TrigConf {
/**
......@@ -49,9 +47,9 @@ namespace TrigConf {
* fileLoader.loadFile( l1_filename, metSignificance, "CaloInfo.METSignificance");
@endcode
*/
StatusCode loadFile( const std::string & filename,
boost::property_tree::ptree & data,
const std::string & pathToChild = "") const;
bool loadFile( const std::string & filename,
boost::property_tree::ptree & data,
const std::string & pathToChild = "") const;
/**
* @brief Load content of json file into a ptree
......@@ -59,9 +57,9 @@ namespace TrigConf {
* @param data [out]
* @param pathToChild [in] Path to a sub structure for partial loading of data
*/
StatusCode loadFile( const std::string & filename,
DataStructure & data,
const std::string & pathToChild = "") const;
bool loadFile( const std::string & filename,
DataStructure & data,
const std::string & pathToChild = "") const;
/**
......@@ -75,13 +73,16 @@ namespace TrigConf {
* @param filename [in] Name of the json file
* @param level [out] either "L1", "HLT" or "UNKNOWN"
*/
StatusCode checkTriggerLevel( const std::string & filename,
std::string & level ) const;
bool checkTriggerLevel( const std::string & filename,
std::string & level ) const;
void setLevel(MSGTC::Level lvl) { msg().setLevel(lvl); }
MSGTC::Level outputLevel() const { return msg().level(); }
private:
std::string findFile(const std::string & filename) const;
};
}
......
......@@ -3,13 +3,14 @@
*/
#include "TrigConfIO/JsonFileLoader.h"
#include "PathResolver/PathResolver.h"
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <sys/stat.h>
#include <filesystem>
#include <cstdlib>
#include <cstring>
using ptree = boost::property_tree::ptree;
......@@ -21,7 +22,51 @@ TrigConf::JsonFileLoader::JsonFileLoader() :
TrigConf::JsonFileLoader::~JsonFileLoader()
{}
StatusCode
/*
File will be search first absolute (when starting with "/" or
relative to the current path
If not found it will be searched in XMLPATH
*/
std::string
TrigConf::JsonFileLoader::findFile(const std::string & filename) const {
// check for the file as specified
if( std::filesystem::exists( filename ) ) {
return filename;
}
// check if absolute location has been specified
if (filename.find("/")==0) {
TRG_MSG_WARNING("Can not find file with absolute location " << filename);
return "";
}
// check if environment DATAPATH exists
const char * dp = std::getenv("XMLPATH");
if( dp == nullptr ) {
TRG_MSG_WARNING("Path environment $DATAPATH has not been defined");
return "";
}
// resolve location using XMLPATH
std::string fnCopy(filename);
char *token = std::strtok( &*fnCopy.begin(), ":");
while ( token != nullptr ) {
std::cout << token << '\n';
std::filesystem::path fullname(token);
fullname /= filename;
if( std::filesystem::exists( fullname ) ) {
return filename;
}
// go to the next
token = std::strtok( nullptr, " ");
}
return "";
}
bool
TrigConf::JsonFileLoader::loadFile( const std::string & filename,
boost::property_tree::ptree & data,
const std::string & pathToChild ) const
......@@ -33,34 +78,10 @@ TrigConf::JsonFileLoader::loadFile( const std::string & filename,
2) if not and the path is not an absolute one, use the DATAPATH
*/
std::string file=""; // resolved file name
struct stat buffer;
bool existsAsSpecified = (stat (filename.c_str(), &buffer) == 0);
if( existsAsSpecified ) {
file = filename;
} else {
if (filename.find("/")==0) { // absolute location
TRG_MSG_WARNING("Can not find file with absolute location " << filename);
return StatusCode::RECOVERABLE;
} else {
// check if environment DATAPATH exists
PathResolver::SearchPathStatus pathStatus = PathResolver::check_search_path ("DATAPATH");
if ( pathStatus == PathResolver::EnvironmentVariableUndefined ) {
TRG_MSG_WARNING("Path environment $DATAPATH has not been defined");
return StatusCode::RECOVERABLE;
}
// resolve absolute location
file = PathResolver::find_file (filename, "DATAPATH");
if ( file == "" ) {
TRG_MSG_WARNING("Did not find file " << filename << " in $DATAPATH");
return StatusCode::RECOVERABLE;
}
}
std::string file = findFile(filename); // resolved file name
if ( file == "" ) {
return false;
}
TRG_MSG_INFO("Reading information from " << file);
// Load the json file
......@@ -69,7 +90,7 @@ TrigConf::JsonFileLoader::loadFile( const std::string & filename,
}
catch (const boost::property_tree::json_parser_error& e) {
TRG_MSG_WARNING("Could either not locate or parse the file " << file);
return StatusCode::RECOVERABLE;
return false;
}
if( ! pathToChild.empty() ) {
......@@ -84,36 +105,33 @@ TrigConf::JsonFileLoader::loadFile( const std::string & filename,
}
}
return StatusCode::SUCCESS;
return true;
}
StatusCode
bool
TrigConf::JsonFileLoader::loadFile( const std::string & filename,
DataStructure & data,
const std::string & pathToChild ) const
{
boost::property_tree::ptree pt;
StatusCode sc = this -> loadFile( filename, pt, pathToChild);
if(!sc.isSuccess())
return sc;
if( ! loadFile( filename, pt, pathToChild) )
return false;
data.setData(pt);
return StatusCode::SUCCESS;
return true;
}
std::string
TrigConf::JsonFileLoader::getFileType( const std::string & filename ) const {
TrigConf::JsonFileLoader::getFileType( const std::string & filename ) const
{
std::string ft = "UNKNOWN";
DataStructure data;
StatusCode sc = this -> loadFile ( filename, data );
if (sc == StatusCode::SUCCESS) {
if ( loadFile ( filename, data ) ) {
ft = data.getAttribute("filetype", /*ignoreIfMissing*/ true, ft);
}
......@@ -121,16 +139,17 @@ TrigConf::JsonFileLoader::getFileType( const std::string & filename ) const {
}
StatusCode
bool
TrigConf::JsonFileLoader::checkTriggerLevel( const std::string & filename,
std::string & level ) const {
std::string & level ) const
{
level = "UNKNOWN";
DataStructure data;
StatusCode sc = this -> loadFile ( filename, data );
bool succeeded = this -> loadFile ( filename, data );
if (sc == StatusCode::SUCCESS) {
if ( succeeded ) {
if (data.hasChild("chains")) {
level = "HLT";
} else if (data.hasChild("items")) {
......@@ -138,5 +157,5 @@ TrigConf::JsonFileLoader::checkTriggerLevel( const std::string & filename,
}
}
return sc;
return succeeded;
}
#include "../L1MenuCondAlg.h"
#include "../HLTMenuCondAlg.h"
DECLARE_COMPONENT( TrigConf::L1MenuCondAlg )
DECLARE_COMPONENT( TrigConf::HLTMenuCondAlg )
......@@ -36,13 +36,13 @@ int main() {
TrigConf::L1TopoMenu l1topomenu;
TrigConf::L1Menu l1menu;
TrigConf::HLTMenu hltmenu;
bool loadTestL1Topo = fileLoader.loadFile( l1topofn, l1topomenu ).isSuccess();
bool loadTestL1Topo = fileLoader.loadFile( l1topofn, l1topomenu );
cout << "Test loading of L1Topo file ... " << ( loadTestL1Topo ? "passed" : "failed" ) << endl;
bool loadTestL1 = fileLoader.loadFile( l1fn, l1menu ).isSuccess();
bool loadTestL1 = fileLoader.loadFile( l1fn, l1menu );
cout << "Test loading of L1 file ... " << ( loadTestL1 ? "passed" : "failed" ) << endl;
bool loadTestHLT = fileLoader.loadFile( hltfn, hltmenu ).isSuccess();
bool loadTestHLT = fileLoader.loadFile( hltfn, hltmenu );
cout << "Test loading of HLT file ... " << ( loadTestHLT ? "passed" : "failed" ) << endl;
if ( ( loadTestL1Topo && loadTestL1 && loadTestHLT ) == false ) return 1; // can't not continue with the other tests
......
......@@ -38,10 +38,9 @@ find_package( cx_Oracle )
find_package( nlohmann_json )
atlas_add_component( TrigConfigSvc
src/*.cxx
src/components/*.cxx
src/*.cxx src/components/*.cxx
INCLUDE_DIRS ${COOL_INCLUDE_DIRS}
LINK_LIBRARIES AthAnalysisBaseCompsLib AthenaBaseComps TrigConfIOLib TrigConfData TrigConfStorage TrigConfL1Data L1TopoConfig EventInfo AthenaMonitoringLib nlohmann_json::nlohmann_json )
LINK_LIBRARIES AthAnalysisBaseCompsLib AthenaBaseComps TrigConfIO TrigConfData TrigConfStorage TrigConfL1Data L1TopoConfig EventInfo AthenaMonitoringLib nlohmann_json::nlohmann_json )
# Install files from the package:
atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} )
......
......@@ -43,6 +43,8 @@
#include "TrigConfHLTData/HLTPrescaleSetCollection.h"
#include "AthenaMonitoringKernel/OHLockedHist.h"
#include "TrigConfData/HLTMenu.h"
#include "TrigConfInterfaces/IJobOptionsSvc.h"
#include "TrigConfInterfaces/IJobOptionsSvc.h"
......@@ -109,7 +111,7 @@ HLTConfigSvc::writeConfigToDetectorStore() {
TrigConf::JsonFileLoader fileLoader;
fileLoader.setLevel(TrigConf::MSGTC::WARNING);
if( fileLoader.loadFile( m_hltFileName, *hltmenu ).isSuccess() ) {
if( fileLoader.loadFile( m_hltFileName, *hltmenu ) ) {
ATH_MSG_INFO( "Loaded HLT menu file " << m_hltFileName.value() );
} else {
ATH_MSG_WARNING( "Failed loading HLT menu file " << m_hltFileName.value());
......
......@@ -16,7 +16,6 @@
#include "TrigConfInterfaces/IHLTConfigSvc.h"
#include "TrigConfHLTData/HLTFrame.h"
#include "TrigConfData/HLTMenu.h"
class TH1F;
class TH2I;
......@@ -75,8 +74,6 @@ namespace TrigConf {
Gaudi::Property< std::string > m_dbConnection { this, "TriggerDB", "TRIGGERDB", "DB connection alias, needed if InputType is db" };
Gaudi::Property< unsigned int > m_smk { this, "SMK", 0, "DB smk, needed if InputType is db" };
// SG::WriteHandleKey<TrigConf::HLTMenu> m_hltMenuKey{"DetectorStore+HLTTriggerMenu"};
StatusCode assignPrescalesToChains(uint lumiblock );
StatusCode bookHistograms();
......
......@@ -45,7 +45,7 @@ TrigConf::HLTMenuCondAlg::execute(const EventContext& ctx) const {
fileLoader.setLevel(TrigConf::MSGTC::WARNING);
TrigConf::HLTMenu * hltmenu = new TrigConf::HLTMenu;
if( m_inputType == "file" ) {
if( fileLoader.loadFile( m_fileName, *hltmenu ).isSuccess() ) {
if( fileLoader.loadFile( m_fileName, *hltmenu ) ) {
ATH_MSG_INFO( "Loaded HLT menu file " << m_fileName );
} else {
ATH_MSG_WARNING( "Failed loading HLT menu file " << m_fileName.value() );
......
......@@ -10,6 +10,7 @@
#include "StoreGate/WriteCondHandleKey.h"
#include "TrigConfData/HLTMenu.h"
namespace TrigConf {
/**
...<