Skip to content
Snippets Groups Projects
Commit fa7fcd3e authored by Christopher Rob Jones's avatar Christopher Rob Jones Committed by Christopher Rob Jones
Browse files

RichTel40CableMapping: Only warning against missing source IDs in Tel40 link condition on use

parent e5597f15
No related branches found
No related tags found
2 merge requests!4575Synchronize master branch with 2024-patches,!4503RichTel40CableMapping: Only warning against missing source IDs in Tel40 link condition on use
Pipeline #7428335 passed
......@@ -52,6 +52,8 @@ namespace Gaudi {
#include <ostream>
#include <set>
#include <sstream>
#include <string>
#include <unordered_set>
#include <vector>
namespace Rich::Future::DAQ {
......@@ -107,6 +109,8 @@ namespace Rich::Future::DAQ {
bool isHType{false};
/// Is Link Active
bool isActive{false};
/// Was this source ID in the Tel40 Links condition
bool inTell40Condition{false};
/// Module Name
std::string name{"UNDEFINED"};
......@@ -114,15 +118,16 @@ namespace Rich::Future::DAQ {
/// Default constructor
Tel40LinkData() = default;
/// Constructor from values
Tel40LinkData( const std::string& n, ///< Tel40 link name
const LHCb::RichSmartID ID, ///< Cached Smart ID for panel
const Rich::DAQ::SourceID sID, ///< Source ID
const Rich::DAQ::Tel40Connector c, ///< Tel40 connector
const bool isH, ///< Is H type PMT
const bool act, ///< Active Link Flag
const Rich::DAQ::PDModuleNumber mod, ///< PDM Module Number
const Rich::DAQ::PDMDBID pdmdb, ///< PDMDB number
const Rich::DAQ::PDMDBFrame link ///< PDMDB Link (Frame)
Tel40LinkData( const std::string& n, ///< Tel40 link name
const LHCb::RichSmartID ID, ///< Cached Smart ID for panel
const Rich::DAQ::SourceID sID, ///< Source ID
const Rich::DAQ::Tel40Connector c, ///< Tel40 connector
const bool isH, ///< Is H type PMT
const bool act, ///< Active Link Flag
const Rich::DAQ::PDModuleNumber mod, ///< PDM Module Number
const Rich::DAQ::PDMDBID pdmdb, ///< PDMDB number
const Rich::DAQ::PDMDBFrame link, ///< PDMDB Link (Frame)
const bool inTel40Cond ///< Was this link in the LHCb Tel40 Condition
)
: smartID( ID )
, sourceID( sID )
......@@ -132,6 +137,7 @@ namespace Rich::Future::DAQ {
, linkNum( link )
, isHType( isH )
, isActive( act )
, inTell40Condition( inTel40Cond )
, name( n ) {}
public:
......@@ -183,17 +189,15 @@ namespace Rich::Future::DAQ {
bool hasInactiveLinks{false};
/// Total number of active links;
std::size_t nActiveLinks{0};
/// Source ID
Rich::DAQ::SourceID sourceID;
/// Was this source ID in the Tel40 Links condition
bool inTell40Condition{false};
};
/// connection data for each SourceID
using Tel40SourceIDs = DetectorArray<PanelArray<std::vector<Tel40Connections>>>;
private:
// methods
/// fill Tel40 cable map data
void fillCableMaps( const LHCb::Detector::DeLHCb& lhcb, const Conds& C );
public:
// accessors
......@@ -204,13 +208,15 @@ namespace Rich::Future::DAQ {
const auto& tel40Data( const LHCb::RichSmartID id, // PD ID
const Rich::DAQ::PDMDBID pdmdb, // PDMDB ID
const Rich::DAQ::PDMDBFrame frame // PDMDB Frame
) const noexcept {
) const {
// module number
const auto modN = id.pdMod();
// return tel40 data
const auto& data = m_tel40ModuleData.at( modN ).at( pdmdb.data() ).at( frame.data() );
// check data
assert( data.isValid() );
// finally return
if ( !data.inTell40Condition ) { warnTel40LinksMissing( data.sourceID ); }
// return
return data;
}
......@@ -220,7 +226,12 @@ namespace Rich::Future::DAQ {
/// Access the Tel40 connection data for a given SourceID
const auto& tel40Data( const Rich::DAQ::SourceID sID ) const {
assert( sID.isValid() );
return m_tel40ConnData.at( sID.rich() ).at( sID.side() ).at( sID.payload() );
const auto& data = m_tel40ConnData.at( sID.rich() ).at( sID.side() ).at( sID.payload() );
// check data
assert( sID == data.sourceID );
if ( !data.inTell40Condition ) { warnTel40LinksMissing( data.sourceID ); }
// return
return data;
}
/// mapping version
......@@ -309,6 +320,12 @@ namespace Rich::Future::DAQ {
return m_parent;
}
/// fill Tel40 cable map data
void fillCableMaps( const LHCb::Detector::DeLHCb& lhcb, const Conds& C );
/// warning for when a source ID was missing in LHCb tel40 links condition
void warnTel40LinksMissing( const Rich::DAQ::SourceID sourceID ) const;
private:
// data
......@@ -330,9 +347,11 @@ namespace Rich::Future::DAQ {
/// Pointer back to parent algorithm (for messaging)
const Gaudi::Algorithm* m_parent{nullptr};
private:
/// Allocation tracking
Rich::AllocateCount<Tel40CableMapping> m_track_instances;
/// One time SourceID warnings
mutable std::unordered_set<Rich::DAQ::SourceID::Type> m_warnSIDs;
};
// Convertor to Allen data format, suitable for GPU processing
......
......@@ -20,32 +20,29 @@
// Gaudi
#include "Gaudi/Algorithm.h"
// Messaging
#include "RichFutureUtils/RichMessaging.h"
#define debug( ... ) \
if ( messenger() ) { ri_debug( __VA_ARGS__ ); }
#define verbo( ... ) \
if ( messenger() ) { ri_verbo( __VA_ARGS__ ); }
#define warning( ... ) \
if ( messenger() ) { ri_warning( __VA_ARGS__ ); }
#define info( ... ) \
if ( messenger() ) { ri_info( __VA_ARGS__ ); }
// boost
#include "boost/container/static_vector.hpp"
// STL
#include <algorithm>
#include <limits>
#include <string>
#include <unordered_set>
#include <mutex>
#include <utility>
#include <vector>
using namespace Rich::Future::DAQ;
using namespace Rich::Detector;
using namespace Rich::DAQ;
// Messaging
#include "RichFutureUtils/RichMessaging.h"
#define debug( ... ) \
if ( messenger() ) { ri_debug( __VA_ARGS__ ); }
#define verbo( ... ) \
if ( messenger() ) { ri_verbo( __VA_ARGS__ ); }
#define warning( ... ) \
if ( messenger() ) { ri_warning( __VA_ARGS__ ); }
#define info( ... ) \
if ( messenger() ) { ri_info( __VA_ARGS__ ); }
void Tel40CableMapping::fillCableMaps( const LHCb::Detector::DeLHCb&
#ifdef USE_DD4HEP
lhcb
......@@ -76,10 +73,6 @@ void Tel40CableMapping::fillCableMaps( const LHCb::Detector::DeLHCb&
}
debug( " -> Mapping Version ", m_mappingVer, endmsg );
#ifdef USE_DD4HEP
std::unordered_set<SourceID::Type> warnSIDs;
#endif
// extract the mappings
for ( const auto&& [cond, rich, panel, name] : Ranges::ConstZip( C, rich_types, panel_types, ConditionPaths ) ) {
......@@ -169,33 +162,33 @@ void Tel40CableMapping::fillCableMaps( const LHCb::Detector::DeLHCb&
bool linkIsActive = ( 0 != status );
#ifdef USE_DD4HEP
// Use link status flag from general LHCb condition instead of from RICH condition.
const auto linksActive = lhcb.tell40links( sourceID.data() );
const auto linksActive = lhcb.tell40links( sourceID.data() );
bool inTell40Cond = false;
if ( !linksActive.has_value() ) {
// Only warn once per SourceID
if ( warnSIDs.find( sourceID.data() ) == warnSIDs.end() ) {
warning( "Source ID ", sourceID, " is missing in LHCb Tel40 Link condition", endmsg );
warnSIDs.insert( sourceID.data() );
}
debug( "Source ID ", sourceID, " is missing in LHCb Tel40 Link condition", endmsg );
} else {
// LHCb general condition has this source ID so use its value instead.
linkIsActive = linksActive.value().isEnabled( link.data() );
inTell40Cond = true;
}
#else
// with DetDesc just use RICH value
// Eventually once DetDesc is dropped the use of the RICH status code can be dropped
// entirely both here and from the condition itself in dd4hep.
const bool inTell40Cond = true;
#endif
// link data struct
const Tel40LinkData linkD( name, //
smartID, //
sourceID, //
link, //
isLargePMT, //
linkIsActive, //
PDModuleNumber( modN ), //
PDMDBID( pdmdb ), //
PDMDBFrame( pdmdbLink ) );
const Tel40LinkData linkD( name, //
smartID, //
sourceID, //
link, //
isLargePMT, //
linkIsActive, //
PDModuleNumber( modN ), //
PDMDBID( pdmdb ), //
PDMDBFrame( pdmdbLink ), //
inTell40Cond );
// fill the Tel40 connection data structure
const std::size_t idx = sourceID.payload();
......@@ -211,6 +204,14 @@ void Tel40CableMapping::fillCableMaps( const LHCb::Detector::DeLHCb&
} else {
conData.hasInactiveLinks = true;
}
if ( !conData.sourceID.isValid() ) {
// first time through set source ID
conData.sourceID = sourceID;
conData.inTell40Condition = inTell40Cond;
} else {
// should always be the same on subsequent passes
assert( sourceID == conData.sourceID );
}
verbo( " -> ", linkD, endmsg );
// fill Tel40 module data structure
......@@ -229,3 +230,15 @@ void Tel40CableMapping::fillCableMaps( const LHCb::Detector::DeLHCb&
} // conditions loop
}
/// warning for when a source ID was missing in LHCb tel40 links condition
void Tel40CableMapping::warnTel40LinksMissing( const Rich::DAQ::SourceID sourceID ) const {
// use lock for thread safe updates
static std::mutex mtx;
std::scoped_lock lock( mtx );
// Only warn once per Source ID per condition instance
if ( m_warnSIDs.find( sourceID.data() ) == m_warnSIDs.end() ) {
warning( "Source ID ", sourceID, " is missing in LHCb Tel40 Link condition", endmsg );
m_warnSIDs.insert( sourceID.data() );
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment