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

Add support for RICH readout mapping condition versions

parent d35406a5
No related branches found
No related tags found
1 merge request!3718Add support for RICH readout mapping versions
Pipeline #4314388 passed
......@@ -18,6 +18,7 @@
#endif
#include <cassert>
#include <utility>
namespace Rich::Detector {
......@@ -27,21 +28,47 @@ namespace Rich::Detector {
using Condition = ParamValidDataObject;
#endif
// tutorial on how to use yaml-cpp can be found at
// https://github.com/jbeder/yaml-cpp/wiki/Tutorial
inline auto condition_param_exists( const Condition& cond, const std::string& paramName ) {
#ifdef USE_DD4HEP
return cond[paramName].IsDefined();
#else
return cond.exists( paramName );
#endif
}
inline auto condition_param_exists( const Condition* cond, const std::string& paramName ) {
assert( cond );
return condition_param_exists( *cond, paramName );
}
template <typename T>
inline auto condition_param( const Condition& cond, const std::string& paramName ) {
#ifdef USE_DD4HEP
// tutorial on how to use yaml-cpp can be found at
// https://github.com/jbeder/yaml-cpp/wiki/Tutorial
return cond[paramName].as<T>();
#else
return cond.param<T>( paramName );
#endif
}
template <typename T>
inline auto condition_param( const Condition* cond, const std::string& paramName ) {
assert( cond );
return condition_param<T>( *cond, paramName );
}
template <typename T>
inline auto condition_param( const Condition& cond, const std::string& paramName, const T def ) {
#ifdef USE_DD4HEP
return cond[paramName].as<T>( def );
#else
return ( condition_param_exists( cond, paramName ) ? cond.param<T>( paramName ) : def );
#endif
}
template <typename T>
inline auto condition_param( const Condition* cond, const std::string& paramName, const T def ) {
assert( cond );
return condition_param<T>( *cond, paramName, std::move( def ) );
}
} // namespace Rich::Detector
......@@ -74,7 +74,7 @@ namespace Rich::Future::DAQ {
const Gaudi::Algorithm* parent = nullptr )
: m_parent( parent ) {
// load the mapping conditions needed for encoding
m_isInitialised = fillRType( C ) && fillHType( C );
m_isInitialised = checkVersion( C ) && fillRType( C ) && fillHType( C );
}
public:
......@@ -143,6 +143,9 @@ namespace Rich::Future::DAQ {
private:
// methods
/// checks mapping version
bool checkVersion( const DecodingConds& C );
/// fill R Type PMT anode map data
bool fillRType( const DecodingConds& C );
......@@ -152,6 +155,9 @@ namespace Rich::Future::DAQ {
public:
// accessors
/// mapping version
auto version() const noexcept { return m_mappingVer; }
/// Access the initialisation state
inline bool isInitialised() const noexcept { return m_isInitialised; }
......@@ -258,8 +264,11 @@ namespace Rich::Future::DAQ {
/// Flag to indicate initialisation status
bool m_isInitialised{false};
/// Mapping version
int m_mappingVer{-1};
/// Pointer back to parent algorithm (for messaging)
const Gaudi::Algorithm* m_parent{nullptr};
}; // namespace Rich::Future::DAQ
};
} // namespace Rich::Future::DAQ
......@@ -71,7 +71,7 @@ namespace Rich::Future::DAQ {
const Gaudi::Algorithm* parent = nullptr )
: m_parent( parent ) {
// load the mapping conditions needed for encoding
m_isInitialised = fillRType( C ) && fillHType( C );
m_isInitialised = checkVersion( C ) && fillRType( C ) && fillHType( C );
}
public:
......@@ -135,6 +135,9 @@ namespace Rich::Future::DAQ {
private:
// methods
/// checks mapping version
bool checkVersion( const EncodingConds& C );
/// fill R Type PMT anode map data
bool fillRType( const EncodingConds& C );
......@@ -144,6 +147,9 @@ namespace Rich::Future::DAQ {
public:
// accessors
/// mapping version
auto version() const noexcept { return m_mappingVer; }
/// Access the initialisation state
inline bool isInitialised() const noexcept { return m_isInitialised; }
......@@ -258,6 +264,9 @@ namespace Rich::Future::DAQ {
/// Flag to indicate initialisation status
bool m_isInitialised{false};
/// Mapping version
int m_mappingVer{-1};
/// Pointer back to parent algorithm (for messaging)
const Gaudi::Algorithm* m_parent{nullptr};
};
......
......@@ -225,6 +225,9 @@ namespace Rich::Future::DAQ {
return m_tel40ConnData[rich][side][idx];
}
/// mapping version
auto version() const noexcept { return m_mappingVer; }
public:
// Conditions handling
......@@ -313,6 +316,9 @@ namespace Rich::Future::DAQ {
/// Flag to indicate initialisation status
bool m_isInitialised{false};
/// Mapping version
int m_mappingVer{-1};
/// Pointer back to parent algorithm (for messaging)
const Gaudi::Algorithm* m_parent{nullptr};
}; // namespace Rich::Future::DAQ
......
......@@ -27,13 +27,46 @@
#define verbo( ... ) \
if ( messenger() ) { ri_verbo( __VA_ARGS__ ); }
// boost
#include "boost/container/static_vector.hpp"
// STL
#include <algorithm>
#include <vector>
using namespace Rich::Future::DAQ;
using namespace Rich::DAQ;
using namespace Rich::Detector;
bool PDMDBDecodeMapping::checkVersion( const DecodingConds& C ) {
bool OK = true;
// mapping version
boost::container::static_vector<int, 3> condVers;
auto checkV = [&]( const auto& cond ) {
// Access parameter, with default value 0 if missing
condVers.push_back( condition_param<int>( cond, "MappingVersion", 0 ) );
};
// extract version from all conditions
for ( const auto rich : Rich::detectors() ) { checkV( C.rTypeConds[rich] ); }
checkV( C.hTypeCond );
// Should all be the same for all panels.
if ( !condVers.empty() && std::all_of( condVers.begin(), condVers.end(),
[first = condVers.front()]( const auto& e ) { return e == first; } ) ) {
m_mappingVer = condVers.front();
} else {
OK = false;
throw Rich::Exception( "Inconsistent mapping versions" );
}
debug( " -> Mapping Version ", m_mappingVer, endmsg );
return OK;
}
bool PDMDBDecodeMapping::fillRType( const DecodingConds& C ) {
bool OK = true;
......
......@@ -27,15 +27,47 @@
#define verbo( ... ) \
if ( messenger() ) { ri_verbo( __VA_ARGS__ ); }
// boost
#include "boost/container/static_vector.hpp"
// STL
#include <algorithm>
#include <vector>
using namespace Rich::Future::DAQ;
using namespace Rich::Detector;
using namespace Rich::DAQ;
bool PDMDBEncodeMapping::fillRType( const EncodingConds& C ) {
bool PDMDBEncodeMapping::checkVersion( const EncodingConds& C ) {
using namespace Rich::DAQ;
bool OK = true;
// mapping version
boost::container::static_vector<int, 3> condVers;
auto checkV = [&]( const auto& cond ) {
// Access parameter, with default value 0 if missing
condVers.push_back( condition_param<int>( cond, "MappingVersion", 0 ) );
};
// extract version from all conditions
for ( const auto rich : Rich::detectors() ) { checkV( C.rTypeConds[rich] ); }
checkV( C.hTypeCond );
// Should all be the same for all panels.
if ( !condVers.empty() && std::all_of( condVers.begin(), condVers.end(),
[first = condVers.front()]( const auto& e ) { return e == first; } ) ) {
m_mappingVer = condVers.front();
} else {
OK = false;
throw Rich::Exception( "Inconsistent mapping versions" );
}
debug( " -> Mapping Version ", m_mappingVer, endmsg );
return OK;
}
bool PDMDBEncodeMapping::fillRType( const EncodingConds& C ) {
bool OK = true;
......
......@@ -20,12 +20,6 @@
// Gaudi
#include "Gaudi/Algorithm.h"
// STL
#include <algorithm>
#include <limits>
#include <string>
#include <vector>
// Messaging
#include "RichFutureUtils/RichMessaging.h"
#define debug( ... ) \
......@@ -33,6 +27,15 @@
#define verbo( ... ) \
if ( messenger() ) { ri_verbo( __VA_ARGS__ ); }
// boost
#include "boost/container/static_vector.hpp"
// STL
#include <algorithm>
#include <limits>
#include <string>
#include <vector>
using namespace Rich::Future::DAQ;
using namespace Rich::Detector;
......@@ -43,8 +46,28 @@ bool Tel40CableMapping::fillCableMaps( const Conds& C ) {
// default to properly initialised
bool ok = true;
// panel data
const auto rich_types = std::array{Rich::Rich1, Rich::Rich1, Rich::Rich2, Rich::Rich2};
const auto panel_types = std::array{Rich::top, Rich::bottom, Rich::aside, Rich::cside};
// mapping version
boost::container::static_vector<int, rich_types.size()> condVers;
for ( const auto& cond : C ) {
// Access parameter, with default value 0 if missing
condVers.push_back( condition_param<int>( cond, "MappingVersion", 0 ) );
}
assert( condVers.size() == rich_types.size() );
// Should all be the same for all panels.
if ( !condVers.empty() && std::all_of( condVers.begin(), condVers.end(),
[first = condVers.front()]( const auto& e ) { return e == first; } ) ) {
m_mappingVer = condVers.front();
} else {
ok = false;
throw Rich::Exception( "Inconsistent mapping versions" );
}
debug( " -> Mapping Version ", m_mappingVer, endmsg );
// extract the mappings
for ( const auto&& [cond, rich, panel, name] : Ranges::ConstZip( C, rich_types, panel_types, ConditionPaths ) ) {
// Number of links for this RICH panel
......
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