Commit eed979a8 authored by Joerg Stelzer's avatar Joerg Stelzer
Browse files

Protect some L1 menu clients against missing l1menu

parent ec235493
......@@ -233,7 +233,7 @@ StatusCode TrigALFAROBMonitor::execute (const EventContext& ctx) const {
if(sc.isFailure()){
ATH_MSG_ERROR("Can't get EventIinfo object");
return StatusCode::SUCCESS;
}
}
*/
//--------------------------------------------------------------------------
......@@ -324,7 +324,7 @@ StatusCode TrigALFAROBMonitor::execute (const EventContext& ctx) const {
ATH_MSG_DEBUG(" roiAV "<<std::hex<<roIWord<<std::dec);
}
}
// get the ALFA ROBs
//std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> ALFARobFragmentVec;
const std::vector<uint32_t> mc_ALFARobIds = {0x840000,0x840001};
......@@ -336,7 +336,7 @@ StatusCode TrigALFAROBMonitor::execute (const EventContext& ctx) const {
ATH_MSG_INFO(" No ALFA ROB found.");
return StatusCode::SUCCESS;
}
// loop over retrieved ROBs and do checks
for (std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*>::iterator it = ALFARobFragmentVec.begin();
......@@ -394,20 +394,20 @@ StatusCode TrigALFAROBMonitor::start() {
}
SG::ReadHandle<TrigConf::L1Menu> l1MenuHandle = SG::makeHandle( m_L1MenuKey );
ATH_CHECK( l1MenuHandle.isValid() );
for ( const TrigConf::L1Item& item: *l1MenuHandle ){
ATH_MSG_INFO("new L1 item: "<<item.name() << "; ctpId: " << item.ctpId() <<"; definition: " <<item.definition());
}
for (const TrigConf::L1Item& item: *l1MenuHandle) {
ATH_MSG_DEBUG(" triggerItem "<<item.name().c_str()<< "ctpId "<<item.ctpId());
std::map<std::string, int>::iterator it = m_map_TrgNamesToHistGroups.find(item.name());
if (it != m_map_TrgNamesToHistGroups.end()) {
m_map_TrgItemNumbersToHistGroups[item.ctpId()] = it->second;
// locate golden alfa triggers for data quality assesment base on the ratio of tracks in elastic triggered events
if (item.name().compare("L1_ALFA_ELAST15") == 0) { m_elast15 = item.ctpId(); continue; }
if (item.name().compare("L1_ALFA_ELAST18") == 0) m_elast18 = item.ctpId();
}
if( l1MenuHandle.isValid() ) {
for ( const TrigConf::L1Item& item: *l1MenuHandle ){
ATH_MSG_DEBUG("new L1 item: "<<item.name() << "; ctpId: " << item.ctpId() <<"; definition: " <<item.definition());
}
for (const TrigConf::L1Item& item: *l1MenuHandle) {
ATH_MSG_DEBUG(" triggerItem "<<item.name().c_str()<< "ctpId "<<item.ctpId());
std::map<std::string, int>::iterator it = m_map_TrgNamesToHistGroups.find(item.name());
if (it != m_map_TrgNamesToHistGroups.end()) {
m_map_TrgItemNumbersToHistGroups[item.ctpId()] = it->second;
// locate golden alfa triggers for data quality assesment base on the ratio of tracks in elastic triggered events
if (item.name().compare("L1_ALFA_ELAST15") == 0) { m_elast15 = item.ctpId(); continue; }
if (item.name().compare("L1_ALFA_ELAST18") == 0) m_elast18 = item.ctpId();
}
}
}
ATH_MSG_DEBUG("TrigALFAROBMonitor::start() 2 ; m_map_TrgItemNumbersToHistGroups.size() = "<<m_map_TrgItemNumbersToHistGroups.size());
......@@ -584,6 +584,7 @@ StatusCode TrigALFAROBMonitor::start() {
}
}
if ( m_doODDistance.value() ) {
std::string histTitle;
......
......@@ -156,7 +156,7 @@ private:
//TrigConf::HLTChain* m_HLTcostMon_chain;
int m_elast15, m_elast18; // ctp-items id numbers to select golden alfa trigger for data quality assesment
int m_elast15 {0}, m_elast18 {0}; // ctp-items id numbers to select golden alfa trigger for data quality assesment
//mutable int m_nbOfTracksInDetectors[8]; // counters for track candidates - needed in data quality assesment
// ALFA extensions
......
......@@ -63,6 +63,8 @@ namespace TrigConf {
void setData(const ptree & data);
void setData(ptree && data);
virtual std::string className() const;
/** Clearing the configuration data
*
* leads to an uninitialized object
......@@ -71,6 +73,9 @@ namespace TrigConf {
/** Access to the underlying data, if needed */
const ptree & data() const {
if( ! isInitialized() ) {
throw std::runtime_error("Trying to access data of uninitialized object of type " + className());
}
return ownsData() ? *m_dataSPtr.get() : *m_dataPtr;
}
......@@ -159,6 +164,7 @@ namespace TrigConf {
/** Access to initialized state */
explicit operator bool() const { return m_initialized; }
bool isValid() const { return m_initialized; }
bool isInitialized() const { return m_initialized; }
/** Check if children exist */
bool empty() const { return data().empty(); }
......
......@@ -77,6 +77,11 @@ TrigConf::DataStructure::hasAttribute(const std::string & key) const {
return child.get().empty(); // if empty then it is an attribute, otherwise a child note
}
std::string
TrigConf::DataStructure::className() const {
return "DataStructure";
}
bool
TrigConf::DataStructure::hasChild(const std::string & path) const {
......
......@@ -19,6 +19,9 @@ TrigConf::L1Item::~L1Item()
void
TrigConf::L1Item::update()
{
if(! isInitialized() || empty() ) {
return;
}
for(auto & bg : getList("bunchgroups") ) {
m_bunchgroups.push_back(bg.getValue<std::string>());
}
......
......@@ -22,6 +22,9 @@ TrigConf::L1Menu::~L1Menu()
void
TrigConf::L1Menu::update()
{
if(! isInitialized() || empty() ) {
return;
}
m_name = getAttribute("name");
// thresholds
......@@ -84,7 +87,16 @@ TrigConf::L1Menu::size() const
TrigConf::L1Item
TrigConf::L1Menu::item(const std::string & itemName) const
{
return L1Item(data().get_child(ptree::path_type("items/"+itemName,'/'))); // '/' is not used in any item Name
if(itemName=="") {
throw std::runtime_error("L1Menu::item() was called with empty itemName");
}
ptree pt;
try {
pt = data().get_child(ptree::path_type("items/"+itemName,'/')); // '/' is not used in any item Name, so we can use it as separator in the path
} catch(boost::property_tree::ptree_bad_path & ex) {
throw std::runtime_error("L1Item " + itemName + " does not exist in the menu");
}
return L1Item(pt);
}
TrigConf::L1Menu::const_iterator
......
......@@ -74,7 +74,13 @@ LVL1ConfigSvc::~LVL1ConfigSvc()
StatusCode
LVL1ConfigSvc::writeConfigToDetectorStore() {
TrigConf::L1Menu * l1menu = new TrigConf::L1Menu;
// do not write empty menu to storegate, so people can check on handlekey being valid
if( m_inputType == "none" ) {
ATH_MSG_INFO( "No L1 menu recorded in the detector store" );
return StatusCode::SUCCESS;
}
TrigConf::L1Menu * l1menu = new TrigConf::L1Menu();
if( m_inputType == "db" ) {
......
......@@ -32,7 +32,7 @@ StatusCode TrigSignatureMoniMT::start() {
ATH_CHECK( hltMenuHandle.isValid() );
SG::ReadHandle<TrigConf::L1Menu> l1MenuHandle = SG::makeHandle( m_L1MenuKey );
ATH_CHECK( l1MenuHandle.isValid() );
bool gotL1Menu = l1MenuHandle.isValid();
//retrieve chain information from menus
std::vector<std::string> bcidChainNames;
......@@ -50,13 +50,11 @@ StatusCode TrigSignatureMoniMT::start() {
m_streamToChainMap[stream.getAttribute("name")].insert( HLT::Identifier(chain.name()) );
}
auto item = std::find_if(l1MenuHandle->begin(), l1MenuHandle->end(),
[&](const TrigConf::L1Item& item){ return item.name()==chain.l1item();});
if ( item != l1MenuHandle->end() ){
for ( auto group : (*item).getList("bunchgroups", true) ){
if ( group.getValue() != "BGRP0" ){
m_chainIDToBunchMap[HLT::Identifier(chain.name())].insert(group.getValue());
if( gotL1Menu && !chain.l1item().empty() ) {
TrigConf::L1Item item = l1MenuHandle->item(chain.l1item());
for ( const std::string & group : item.bunchgroups() ) {
if ( group != "BGRP0" ) {
m_chainIDToBunchMap[HLT::Identifier(chain.name())].insert(group);
}
}
}
......@@ -74,7 +72,7 @@ StatusCode TrigSignatureMoniMT::start() {
const int xc = sequencesSet.size();
const int y = nBinsY();
const int yr = nRateBinsY();
const int yb = nBunchBinsY(l1MenuHandle);
const int yb = gotL1Menu ? nBunchBinsY(l1MenuHandle) : 16;
const int ybc = bcidChainNames.size();
const int yc = 1; //Rate
......@@ -473,6 +471,9 @@ StatusCode TrigSignatureMoniMT::initBCIDhist(LockedHandle<TH2>& hist, const std:
}
StatusCode TrigSignatureMoniMT::initBunchHist(LockedHandle<TH2>& hist, SG::ReadHandle<TrigConf::HLTMenu>& hltMenuHandle, SG::ReadHandle<TrigConf::L1Menu>& l1MenuHandle) {
bool gotL1Menu = l1MenuHandle.isValid() && l1MenuHandle->isInitialized();
TAxis* x = hist->GetXaxis();
x->SetBinLabel(1, "All");
int bin = 2;
......@@ -488,14 +489,22 @@ StatusCode TrigSignatureMoniMT::initBunchHist(LockedHandle<TH2>& hist, SG::ReadH
++bin;
}
TAxis* y = hist->GetYaxis();
std::vector<std::string> sortedBunchGroups = l1MenuHandle->getObject("bunchGroups").getKeys();
std::sort( sortedBunchGroups.begin(), sortedBunchGroups.end() );
sortedBunchGroups.erase(std::remove(sortedBunchGroups.begin(), sortedBunchGroups.end(), "BGRP0"), sortedBunchGroups.end());
std::vector<std::string> sortedBunchGroups;
if( gotL1Menu ) {
sortedBunchGroups = l1MenuHandle->getObject("bunchGroups").getKeys();
std::sort( sortedBunchGroups.begin(), sortedBunchGroups.end() );
sortedBunchGroups.erase(std::remove(sortedBunchGroups.begin(), sortedBunchGroups.end(), "BGRP0"), sortedBunchGroups.end());
} else {
for(size_t i = 1; i<=16; ++i) {
sortedBunchGroups.emplace_back("BGRP" + std::to_string(i));
}
}
bin = 1;
TAxis* y = hist->GetYaxis();
for ( const std::string& group : sortedBunchGroups ){
y->SetBinLabel( bin, l1MenuHandle->getAttribute( "bunchGroups." + group + ".name", true).c_str() );
std::string bgname = gotL1Menu ? l1MenuHandle->getAttribute( "bunchGroups." + group + ".name", true) : group;
y->SetBinLabel( bin, bgname.c_str() );
m_nameToBinMap[group] = bin;
++bin;
}
......
......@@ -199,7 +199,7 @@ def defineMenu():
# XE
"L1_XE35", "L1_XE40", "L1_XE45", "L1_XE50",
"L1_XE10", "L1_XE35", "L1_XE40", "L1_XE45", "L1_XE50",
"L1_XE55", "L1_XE60", "L1_XE70", "L1_XE80",
'L1_XE30', 'L1_XE300',
'L1_gXERHO50',
......@@ -553,7 +553,6 @@ def defineMenu():
'L1_2eEM20VH' : 49,
'L1_2eEM8VH_MU10' : 50,
'L1_eEM15VHI_2eTAU12IM_4jJ12' : 59,
'L1_eEM15VHI_2eTAU12IM_jJ25_3jJ12' : 68,
'L1_eEM15VHI_2eTAU12IM_gXERHO35' : 73,
'L1_eEM15VH_MU10' : 82,
'L1_eEM18VHI_3jJ20' : 86,
......@@ -719,6 +718,7 @@ def defineMenu():
#'L1_J75_XE40' : 143,
#'L1_XE25': 82,
'L1_XE10': 68,
'L1_XE30': 85,
'L1_XE300': 187,
......
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