From 2b90dc4a259b722874a7ef72458294b42d6f4358 Mon Sep 17 00:00:00 2001 From: Pavol Strizenec Date: Sun, 4 Aug 2019 15:16:46 +0200 Subject: [PATCH 1/2] LArOnlineID cleanup --- .../LArIdentifier/LArIdentifier/LArOnlineID.h | 362 -------- .../LArIdentifier/LArOnlineID_Base.h | 260 +++++- .../LArIdentifier/LArOnline_SuperCellID.h | 124 +-- .../LArIdentifier/src/LArOnlineID.cxx | 109 +-- .../LArIdentifier/src/LArOnlineID_Base.cxx | 122 ++- .../src/LArOnline_SuperCellID.cxx | 801 +++++++++--------- 6 files changed, 756 insertions(+), 1022 deletions(-) diff --git a/LArCalorimeter/LArIdentifier/LArIdentifier/LArOnlineID.h b/LArCalorimeter/LArIdentifier/LArIdentifier/LArOnlineID.h index 177f0ff3fbd..27e575d8ecc 100755 --- a/LArCalorimeter/LArIdentifier/LArIdentifier/LArOnlineID.h +++ b/LArCalorimeter/LArIdentifier/LArIdentifier/LArOnlineID.h @@ -16,97 +16,6 @@ class IdentifierHash; class Range; - - /** - * @brief Helper for the Liquid Argon Calorimeter cell identifiers. - * This class provides a hardware description of a calorimeter cell - * @author Arnaud Lucotte - * - * LArCalorimeter fields: - * ---------------------- - * Part: 4 = LArOnline - * barrel_ec : 0 = barrel - * 1 = end-cap - * pos_neg : 0 = negative eta side (C side) - * 1 = positive eta side (A side) - * feedthrough : - * [0,31] = EM BARREL crates - * 00,01,04,07,08,11,12,13, - * 14,17,18,19,20,23,24 = EMEC Standard crates - * 02,09,15,21 = EMEC Special crates - * 03,10,16,22 = HEC crates - * (note: slots 1&2 are EMEC slots) - * 06 = FCAL crate - * slot : - * 1 to 14 = EM BARREL crates - * 1 to 13 = Endcap Standard crates - * 1 to 15 = Endcap Special crates - * 5,6,7,8,9,10 = HEC in HEC crates - * 1,2 = EMEC in HEC crates - * 1 to 15 = FCAL crates - * channel: - * 0 to 127 - * - * In the following, four contexts are defined: - * - cryostatEndContext - * - feedthroughContext - * - febContext - * - channelContext - * - * Throw a LArOnlID_Exception if one parameter is out of range - * - * - * Access Methods : - * ---------------- - * There are three types of methods: - * - recommended methods - * - methods that can still be used but with special care - * - methods that are now obsolete - * - * RECOMMENDED methods : - * bool isEMBchannel (const HWIdentifier Id) const; - * bool isEMECchannel (const HWIdentifier Id) const; - * bool isHECchannel (const HWIdentifier Id) const; - * bool isFCALchannel (const HWIdentifier Id) const; - * bool isEMECIW (const HWIdentifier Id) const; - * bool isEMECOW (const HWIdentifier Id) const; - * bool isEndcapOnline (const HWIdentifier Id) const; - * bool isEmEndcapStandardOnline(const HWIdentifier Id) const; - * bool isEmEndcapSpecialOnline (const HWIdentifier Id) const; - * bool isEMBPS (const HWIdentifier Id) const; - * bool isEMECPS (const HWIdentifier Id) const; - * bool isPS (const HWIdentifier Id) const; - * - * USE-with-CARE methods (still used for historical reasons): - * bool isHecOnline (const HWIdentifier chId) const; - * bool isHecOnlineFebId(const HWIdentifier febId)const; - * bool isEMECinHECchannel(const HWIdentifier Id) const; - * - * OBSOLETE methods : - * bool isEmBarrelOnline(const HWIdentifier chId) const; -> use isEMBchannel - * bool isEmEndcapOnline(const HWIdentifier chId) const; -> use isEMECchannel - * bool isFcalOnline (const HWIdentifier chId) const; -> use isFCALchannel - * - * SPECIFIC usecases : - * bool is_H8 (const HWIdentifier id) const; - * bool is_H8crack (const HWIdentifier id) const; - * bool is_H8low (const HWIdentifier id) const; - * bool is_H8high (const HWIdentifier id) const; - * bool is_H6 (const HWIdentifier id) const; - * bool is_H6FT (const HWIdentifier feedthroughId) const; - * bool is_H6fcal (const HWIdentifier id) const; - * bool is_H6hec (const HWIdentifier id) const; - * bool is_H6emec (const HWIdentifier id) const; - * bool is_H8onlineOnly (const HWIdentifier id) const; - * - * int channelInSlotMax (const HWIdentifier Id) const; - * - * The following methods are now disabled: - * bool isEMB_BACK (const HWIdentifier id) const; - * bool isEMB_MIDDLE (const HWIdentifier id) const; - * bool isEMB_FRONT (const HWIdentifier id) const; - *=========================================================================== - */ class LArOnlineID : public LArOnlineID_Base { public: @@ -124,79 +33,6 @@ class LArOnlineID : public LArOnlineID_Base int initialize_from_dictionary(const IdDictMgr&); - /** - * @brief Build calibration module identifier from fields - */ - HWIdentifier calib_module_Id(int barrel_ec, - int pos_neg, - int feedthrough, - int slot ) const; - /** - * @brief Create calibration module identifier from hash identifiers - */ - HWIdentifier calib_module_Id(IdentifierHash calibModuleHash) const; - /** - * @brief create calibration module_hash identifier from module Identifier - */ - IdentifierHash calib_module_Hash(HWIdentifier calibModuleId) const; - - /** - * @brief Return an iterator pointing to a calibFeb identifier 's collection - */ - std::vector::const_iterator calib_module_begin(void) const; - std::vector::const_iterator calib_module_end (void) const; - - - /** - * @brief create calibration channel identifiers from fields - */ - HWIdentifier calib_channel_Id(int barrel_ec, - int pos_neg, - int feedthrough, - int slot, - int channel ) const; - /** - * @brief create calibration channel identifiers from hash identifiers - */ - HWIdentifier calib_channel_Id(IdentifierHash calibChannelHash) const; - /** - * @brief create hash calibration channel identifiers from calib channel identifiers - */ - IdentifierHash calib_channel_Hash(HWIdentifier calibChannelId) const; - /** - * @brief Return an iterator pointing to a collection of calibration channel identifiers - */ - std::vector::const_iterator calib_channel_begin(void) const; - std::vector::const_iterator calib_channel_end (void) const; - - - /** - * @brief Define a calibration module identifier from a channel identifier - */ - HWIdentifier calib_module_Id(const HWIdentifier ChannelId) const ; - /** - * @brief Define a calibration module identifier from a feedthrough identifier - */ - HWIdentifier calib_module_Id(const HWIdentifier FeedthroughId, int slot) const ; - /** - * @brief Define a calibration channel identifier from a feedthrough identifier - */ - HWIdentifier calib_channel_Id(const HWIdentifier FeedthroughId, int slot, int channel ) const ; - /** - * @brief Define a calibration channel identifier from a feb identifier - */ - HWIdentifier calib_channel_Id(const HWIdentifier febId, int ChannelId) const ; - - /** - * @brief Define calibration module hash tables max size - */ - size_type calibModuleHashMax (void) const; - - /** - * @brief Define calibration channel hash tables max size - */ - size_type calibChannelHashMax (void) const; - /* Test beam disctionaries */ bool is_H8 (const HWIdentifier channelId) const; @@ -210,185 +46,26 @@ class LArOnlineID : public LArOnlineID_Base bool is_H6emec (const HWIdentifier id) const; bool is_H8onlineOnly (const HWIdentifier id) const; - /* - * Removed in AUG-2008 / AL - bool isEMB_BACK (const HWIdentifier id) const; - bool isEMB_MIDDLE (const HWIdentifier id) const; - bool isEMB_FRONT (const HWIdentifier id) const; - */ private: /*==== */ - enum {NOT_VALID_HASH = 256000}; - - IdentifierHash feb_Hash_binary_search(HWIdentifier channelId) const; - - IdentifierHash channel_Hash_binary_search(HWIdentifier channelId) const; - // Test of Em EC special / standard bool isLArCalibOnline(const HWIdentifier id) const; // Check methods - int initLevelsFromDict(const std::string& group_name) ; int init_hashes(void) ; int init_H8Hashes(void) ; int init_H6Hashes(void) ; - int init_calib_hashes(void) ; - - /* Calib */ - MultiRange m_full_calib_laronline_range; - MultiRange m_full_calib_module_range; - size_type m_calibModuleHashMax; - size_type m_calibChannelHashMax; - std::vector m_calib_module_vec; - std::vector m_calib_channel_vec; }; -//static const int s_lar_online_field_value = 4 ; -//static const int s_lar_onlineCalib_field_value = 5 ; - //using the macro below we can assign an identifier (and a version) //This is required and checked at compile time when you try to record/retrieve CLASS_DEF( LArOnlineID , 158698068 , 1 ) - - - -//===================== -// Inline Definitions -//===================== - - - - -/* CALIB inline Identifiers */ -/*==========================*/ - -inline HWIdentifier LArOnlineID::calib_module_Id(int barrel_ec, int pos_neg, - int feedthrough, int slot ) const -/*=============================================================== */ -{ - HWIdentifier result(0); - /*Pack fields independently */ - m_lar_impl.pack (lar_field_value(), result); - m_laronline_impl.pack (5 , result); - m_bec_impl.pack (barrel_ec , result); - m_side_impl.pack (pos_neg , result); - m_feedthrough_impl.pack(feedthrough , result); - m_slot_impl.pack (slot , result); - return result; -} - -inline HWIdentifier LArOnlineID::calib_module_Id(const HWIdentifier feedthroughId , int slot) const -/*==================================================================================== */ -{ - HWIdentifier result(feedthroughId); - /* Pack fields independently */ - m_slot_impl.reset (result); - m_slot_impl.pack (slot , result); - return(result); -} - -inline HWIdentifier LArOnlineID::calib_module_Id(const HWIdentifier calibChannelId ) const -/*======================================================================= */ -{ - HWIdentifier result(calibChannelId); - m_channel_in_slot_impl.reset(result); - return(result); -} - -inline HWIdentifier LArOnlineID::calib_module_Id(IdentifierHash calibModuleHashId) const -/*=========================================================================== */ -{ - return(m_calib_module_vec[calibModuleHashId]); -} - -inline IdentifierHash LArOnlineID::calib_module_Hash (HWIdentifier calibModuleId) const -/*=============================================================================== */ -{ - std::vector::const_iterator it = std::lower_bound(m_calib_module_vec.begin(),m_calib_module_vec.end(),calibModuleId); - if ( it != m_calib_module_vec.end() ){ - return (it - m_calib_module_vec.begin()); - } - return (0); -} - -inline HWIdentifier LArOnlineID::calib_channel_Id( int barrel_ec, int pos_neg, int feedthrough, - int slot, int channel ) const -/*============================================================================== */ -{ - HWIdentifier result(0); - /* Pack fields independently */ - m_lar_impl.pack (lar_field_value() , result); - m_laronline_impl.pack (5 , result); - m_bec_impl.pack (barrel_ec , result); - m_side_impl.pack (pos_neg , result); - m_feedthrough_impl.pack (feedthrough , result); - m_slot_impl.pack (slot , result); - m_channel_in_slot_impl.pack(channel , result); - - return result; -} - -inline HWIdentifier LArOnlineID::calib_channel_Id(const HWIdentifier feedthroughId,int slot,int channel) const -/*==================================================================================================== */ -{ - HWIdentifier result(feedthroughId); - /* Pack fields independently */ - m_slot_impl.reset (result); - m_channel_in_slot_impl.reset(result); - m_slot_impl.pack (slot , result); - m_channel_in_slot_impl.pack (channel, result); - - return result; -} - -inline HWIdentifier LArOnlineID::calib_channel_Id(const HWIdentifier febId, int channel) const -/*======================================================================================= */ -{ - HWIdentifier result(febId); - /* Pack fields independently */ - m_channel_in_slot_impl.reset(result); - m_channel_in_slot_impl.pack (channel, result); - - return result; -} -inline HWIdentifier LArOnlineID::calib_channel_Id(IdentifierHash channelHashId) const -/*===================================================================*/ -{ - return(m_calib_channel_vec[channelHashId]); -} - -inline IdentifierHash LArOnlineID::calib_channel_Hash (HWIdentifier channelId) const -/*=========================================================================*/ -{ - std::vector::const_iterator it = std::lower_bound(m_calib_channel_vec.begin(),m_calib_channel_vec.end(),channelId); - if ( it != m_calib_channel_vec.end() ){ - return (it - m_calib_channel_vec.begin()); - } - return(0) ; -} - - -inline IdentifierHash LArOnlineID::channel_Hash_binary_search (HWIdentifier channelId) const -/*=========================================================================*/ -{ - std::vector::const_iterator it = std::lower_bound(m_channel_vec.begin(),m_channel_vec.end(),channelId); - if ( it != m_channel_vec.end() ){ - return (it - m_channel_vec.begin()); - } - return(0) ; -} - - - -/* BOOLEAN */ - - /* TEST BEAM dictionaries */ inline bool LArOnlineID::is_H8( const HWIdentifier Id ) const @@ -544,45 +221,6 @@ inline bool LArOnlineID::is_H6emec( const HWIdentifier Id ) const } -/* Calib */ -inline LArOnlineID::size_type LArOnlineID::calibModuleHashMax (void) const -/*=======================================================================*/ -{ - return m_calibModuleHashMax; -} -inline LArOnlineID::size_type LArOnlineID::calibChannelHashMax (void) const -/*====================================================================*/ -{ - return m_calibChannelHashMax; -} - - - - - -/* Calib */ -inline std::vector::const_iterator LArOnlineID::calib_module_begin(void) const -/*====================================================================*/ -{ - return(m_calib_module_vec.begin()); -} -inline std::vector::const_iterator LArOnlineID::calib_module_end(void) const -/*==================================================================*/ -{ - return(m_calib_module_vec.end()); -} - -inline std::vector::const_iterator LArOnlineID::calib_channel_begin(void) const -/*======================================================================*/ -{ - return(m_calib_channel_vec.begin()); -} -inline std::vector::const_iterator LArOnlineID::calib_channel_end(void) const -/*======================================================================*/ -{ - return(m_calib_channel_vec.end()); -} - #endif // LARONLINE_ID_H diff --git a/LArCalorimeter/LArIdentifier/LArIdentifier/LArOnlineID_Base.h b/LArCalorimeter/LArIdentifier/LArIdentifier/LArOnlineID_Base.h index bbec67b295d..bdaa6fef12e 100755 --- a/LArCalorimeter/LArIdentifier/LArIdentifier/LArOnlineID_Base.h +++ b/LArCalorimeter/LArIdentifier/LArIdentifier/LArOnlineID_Base.h @@ -98,10 +98,6 @@ class Range; * * int channelInSlotMax (const HWIdentifier Id) const; * - * The following methods are now disabled: - * bool isEMB_BACK (const HWIdentifier id) const; - * bool isEMB_MIDDLE (const HWIdentifier id) const; - * bool isEMB_FRONT (const HWIdentifier id) const; *=========================================================================== */ class LArOnlineID_Base : public AtlasDetectorID @@ -243,6 +239,77 @@ class LArOnlineID_Base : public AtlasDetectorID */ size_type channelHashMax (void) const; + /** + * @brief Build calibration module identifier from fields + */ + HWIdentifier calib_module_Id(int barrel_ec, + int pos_neg, + int feedthrough, + int slot ) const; + /** + * @brief Create calibration module identifier from hash identifiers + */ + HWIdentifier calib_module_Id(IdentifierHash calibModuleHash) const; + /** + * @brief create calibration module_hash identifier from module Identifier + */ + IdentifierHash calib_module_Hash(HWIdentifier calibModuleId) const; + + /** + * @brief Return an iterator pointing to a calibFeb identifier 's collection + */ + std::vector::const_iterator calib_module_begin(void) const; + std::vector::const_iterator calib_module_end (void) const; + + + /** + * @brief create calibration channel identifiers from fields + */ + HWIdentifier calib_channel_Id(int barrel_ec, + int pos_neg, + int feedthrough, + int slot, + int channel ) const; + /** + * @brief create calibration channel identifiers from hash identifiers + */ + HWIdentifier calib_channel_Id(IdentifierHash calibChannelHash) const; + /** + * @brief Return an iterator pointing to a collection of calibration channel identifiers + */ + std::vector::const_iterator calib_channel_begin(void) const; + std::vector::const_iterator calib_channel_end (void) const; + + + /** + * @brief Define a calibration module identifier from a channel identifier + */ + HWIdentifier calib_module_Id(const HWIdentifier ChannelId) const ; + /** + * @brief Define a calibration module identifier from a feedthrough identifier + */ + HWIdentifier calib_module_Id(const HWIdentifier FeedthroughId, int slot) const ; + /** + * @brief Define a calibration channel identifier from a feedthrough identifier + */ + HWIdentifier calib_channel_Id(const HWIdentifier FeedthroughId, int slot, int channel ) const ; + /** + * @brief Define a calibration channel identifier from a feb identifier + */ + HWIdentifier calib_channel_Id(const HWIdentifier febId, int ChannelId) const ; + + IdentifierHash calib_channel_Hash (HWIdentifier channelId) const ; + + /** + * @brief Define calibration module hash tables max size + */ + size_type calibModuleHashMax (void) const; + + /** + * @brief Define calibration channel hash tables max size + */ + size_type calibChannelHashMax (void) const; + /** * @returns true if the Id belongs to a subsystem @@ -394,6 +461,8 @@ protected: const IdContext* context) const; int initLevelsFromDict(const std::string& group_name) ; int init_hashes(void) ; + int init_calib_hashes(void) ; + size_type m_laronlineRegion_index; // LArOnline_region size_type m_lar_index; // LAr size_type m_laronline_index; // 4 @@ -417,6 +486,14 @@ protected: std::vector m_feb_vec; std::vector m_channel_vec; + /* Calib */ + MultiRange m_full_calib_laronline_range; + MultiRange m_full_calib_module_range; + size_type m_calibModuleHashMax; + size_type m_calibChannelHashMax; + std::vector m_calib_module_vec; + std::vector m_calib_channel_vec; + /** Field Implementation */ IdDictFieldImplementation m_lar_impl; IdDictFieldImplementation m_laronline_impl; @@ -453,10 +530,183 @@ protected: static const int s_lar_online_field_value = 4 ; static const int s_lar_onlineCalib_field_value = 5 ; +//===================== +// Inline Definitions +//===================== + +inline IdentifierHash LArOnlineID_Base::feb_Hash_binary_search (HWIdentifier febId) const +/*=============================================================================== */ +{ + std::vector::const_iterator it = std::lower_bound(m_feb_vec.begin(),m_feb_vec.end(),febId); + if ( it != m_feb_vec.end() ){ + return (it - m_feb_vec.begin()); + } + return (0); +} + + +inline IdentifierHash LArOnlineID_Base::channel_Hash_binary_search (HWIdentifier channelId) const +/*=========================================================================*/ +{ + std::vector::const_iterator it = std::lower_bound(m_channel_vec.begin(),m_channel_vec.end(),channelId); + if ( it != m_channel_vec.end() ){ + return (it - m_channel_vec.begin()); + } + return(0) ; +} + +/* CALIB inline Identifiers */ +/*==========================*/ + +inline HWIdentifier LArOnlineID_Base::calib_module_Id(int barrel_ec, int pos_neg, + int feedthrough, int slot ) const +/*=============================================================== */ +{ + HWIdentifier result(0); + /*Pack fields independently */ + m_lar_impl.pack (lar_field_value(), result); + m_laronline_impl.pack (5 , result); + m_bec_impl.pack (barrel_ec , result); + m_side_impl.pack (pos_neg , result); + m_feedthrough_impl.pack(feedthrough , result); + m_slot_impl.pack (slot , result); + return result; +} + +inline HWIdentifier LArOnlineID_Base::calib_module_Id(const HWIdentifier feedthroughId , int slot) const +/*==================================================================================== */ +{ + HWIdentifier result(feedthroughId); + /* Pack fields independently */ + m_slot_impl.reset (result); + m_slot_impl.pack (slot , result); + return(result); +} + +inline HWIdentifier LArOnlineID_Base::calib_module_Id(const HWIdentifier calibChannelId ) const +/*======================================================================= */ +{ + HWIdentifier result(calibChannelId); + m_channel_in_slot_impl.reset(result); + return(result); +} + +inline HWIdentifier LArOnlineID_Base::calib_module_Id(IdentifierHash calibModuleHashId) const +/*=========================================================================== */ +{ + return(m_calib_module_vec[calibModuleHashId]); +} + +inline IdentifierHash LArOnlineID_Base::calib_module_Hash (HWIdentifier calibModuleId) const +/*=============================================================================== */ +{ + std::vector::const_iterator it = std::lower_bound(m_calib_module_vec.begin(),m_calib_module_vec.end(),calibModuleId); + if ( it != m_calib_module_vec.end() ){ + return (it - m_calib_module_vec.begin()); + } + return (0); +} + +inline HWIdentifier LArOnlineID_Base::calib_channel_Id( int barrel_ec, int pos_neg, int feedthrough, + int slot, int channel ) const +/*============================================================================== */ +{ + HWIdentifier result(0); + /* Pack fields independently */ + m_lar_impl.pack (lar_field_value() , result); + m_laronline_impl.pack (5 , result); + m_bec_impl.pack (barrel_ec , result); + m_side_impl.pack (pos_neg , result); + m_feedthrough_impl.pack (feedthrough , result); + m_slot_impl.pack (slot , result); + m_channel_in_slot_impl.pack(channel , result); + + return result; +} + +inline HWIdentifier LArOnlineID_Base::calib_channel_Id(const HWIdentifier feedthroughId,int slot,int channel) const +/*==================================================================================================== */ +{ + HWIdentifier result(feedthroughId); + /* Pack fields independently */ + m_slot_impl.reset (result); + m_channel_in_slot_impl.reset(result); + m_slot_impl.pack (slot , result); + m_channel_in_slot_impl.pack (channel, result); + + return result; +} + +inline HWIdentifier LArOnlineID_Base::calib_channel_Id(const HWIdentifier febId, int channel) const +/*======================================================================================= */ +{ + HWIdentifier result(febId); + /* Pack fields independently */ + m_channel_in_slot_impl.reset(result); + m_channel_in_slot_impl.pack (channel, result); + + return result; +} +inline HWIdentifier LArOnlineID_Base::calib_channel_Id(IdentifierHash channelHashId) const +/*===================================================================*/ +{ + return(m_calib_channel_vec[channelHashId]); +} + +inline IdentifierHash LArOnlineID_Base::calib_channel_Hash (HWIdentifier channelId) const +/*=========================================================================*/ +{ + std::vector::const_iterator it = std::lower_bound(m_calib_channel_vec.begin(),m_calib_channel_vec.end(),channelId); + if ( it != m_calib_channel_vec.end() ){ + return (it - m_calib_channel_vec.begin()); + } + return(0) ; +} + +/* Calib */ +inline LArOnlineID_Base::size_type LArOnlineID_Base::calibModuleHashMax (void) const +/*=======================================================================*/ +{ + return m_calibModuleHashMax; +} +inline LArOnlineID_Base::size_type LArOnlineID_Base::calibChannelHashMax (void) const +/*====================================================================*/ +{ + return m_calibChannelHashMax; +} + + + + + +/* Calib */ +inline std::vector::const_iterator LArOnlineID_Base::calib_module_begin(void) const +/*====================================================================*/ +{ + return(m_calib_module_vec.begin()); +} +inline std::vector::const_iterator LArOnlineID_Base::calib_module_end(void) const +/*==================================================================*/ +{ + return(m_calib_module_vec.end()); +} + +inline std::vector::const_iterator LArOnlineID_Base::calib_channel_begin(void) const +/*======================================================================*/ +{ + return(m_calib_channel_vec.begin()); +} +inline std::vector::const_iterator LArOnlineID_Base::calib_channel_end(void) const +/*======================================================================*/ +{ + return(m_calib_channel_vec.end()); +} + + //using the macro below we can assign an identifier (and a version) //This is required and checked at compile time when you try to record/retrieve -//CLASS_DEF( LArOnlineID , 158698068 , 1 ) +CLASS_DEF( LArOnlineID_Base , 28598761 , 1 ) #endif // LARONLINE_ID_BASE_H diff --git a/LArCalorimeter/LArIdentifier/LArIdentifier/LArOnline_SuperCellID.h b/LArCalorimeter/LArIdentifier/LArIdentifier/LArOnline_SuperCellID.h index 9c33d9ccce7..7e6879bdc16 100755 --- a/LArCalorimeter/LArIdentifier/LArIdentifier/LArOnline_SuperCellID.h +++ b/LArCalorimeter/LArIdentifier/LArIdentifier/LArOnline_SuperCellID.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #ifndef LARONLINE_SUPERCELLID_H @@ -16,80 +16,6 @@ class IdentifierHash; class Range; - - /** - * @brief Helper for the Liquid Argon Calorimeter cell identifiers. - * This class provides a hardware description of a calorimeter cell - * @author Arnaud Lucotte - * - * LArCalorimeter fields: - * ---------------------- - * Part: 4 = LArOnline - * barrel_ec : 0 = barrel - * 1 = end-cap - * pos_neg : 0 = negative eta side (C side) - * 1 = positive eta side (A side) - * feedthrough : - * [0,31] = EM BARREL crates - * 00,01,04,07,08,11,12,13, - * 14,17,18,19,20,23,24 = EMEC Standard crates - * 02,09,15,21 = EMEC Special crates - * 03,10,16,22 = HEC crates - * (note: slots 1&2 are EMEC slots) - * 06 = FCAL crate - * slot : - * 1 = for all crates for now - * channel: - * 0 to 511 - * - * In the following, four contexts are defined: - * - cryostatEndContext - * - feedthroughContext - * - febContext - * - channelContext - * - * Throw a LArOnlID_Exception if one parameter is out of range - * - * - * Access Methods : - * ---------------- - * There are three types of methods: - * - recommended methods - * - methods that can still be used but with special care - * - methods that are now obsolete - * - * RECOMMENDED methods : - * bool isEMBchannel (const HWIdentifier Id) const; - * bool isEMECchannel (const HWIdentifier Id) const; - * bool isHECchannel (const HWIdentifier Id) const; - * bool isFCALchannel (const HWIdentifier Id) const; - * bool isEMECIW (const HWIdentifier Id) const; - * bool isEMECOW (const HWIdentifier Id) const; - * bool isEndcapOnline (const HWIdentifier Id) const; - * bool isEmEndcapStandardOnline(const HWIdentifier Id) const; - * bool isEmEndcapSpecialOnline (const HWIdentifier Id) const; - * bool isEMBPS (const HWIdentifier Id) const; - * bool isEMECPS (const HWIdentifier Id) const; - * bool isPS (const HWIdentifier Id) const; - * - * USE-with-CARE methods (still used for historical reasons): - * bool isHecOnline (const HWIdentifier chId) const; - * bool isHecOnlineFebId(const HWIdentifier febId)const; - * bool isEMECinHECchannel(const HWIdentifier Id) const; - * - * OBSOLETE methods : - * bool isEmBarrelOnline(const HWIdentifier chId) const; -> use isEMBchannel - * bool isEmEndcapOnline(const HWIdentifier chId) const; -> use isEMECchannel - * bool isFcalOnline (const HWIdentifier chId) const; -> use isFCALchannel - * - * int channelInSlotMax (const HWIdentifier Id) const; - * - * The following methods are now disabled: - * bool isEMB_BACK (const HWIdentifier id) const; - * bool isEMB_MIDDLE (const HWIdentifier id) const; - * bool isEMB_FRONT (const HWIdentifier id) const; - *=========================================================================== - */ class LArOnline_SuperCellID : public LArOnlineID_Base { public: @@ -106,66 +32,18 @@ class LArOnline_SuperCellID : public LArOnlineID_Base ~LArOnline_SuperCellID(void); - /** - * @brief Define feedthrough hash tables max size - */ - //size_type feedthroughHashMax (void) const; - /** - * @brief define feb hash tables max size - */ - //size_type febHashMax (void) const; - /** - * @brief Define channel hash tables max size - */ - //size_type channelHashMax (void) const; int initialize_from_dictionary (const IdDictMgr& dict_mgr); private: -/*==== */ - enum {NOT_VALID_HASH = 256000}; - - IdentifierHash feb_Hash_binary_search(HWIdentifier channelId) const; - - IdentifierHash channel_Hash_binary_search(HWIdentifier channelId) const; - - int initLevelsFromDict(const std::string&) ; int init_hashes(void) ; }; static const int s_slar_online_field_value = 4 ; -//static const int s_lar_onlineCalib_field_value = 5 ; - -//using the macro below we can assign an identifier (and a version) -//This is required and checked at compile time when you try to record/retrieve -// Number must be changed CLASS_DEF( LArOnline_SuperCellID , 115600394 , 1 ) - - - -//===================== -// Inline Definitions -//===================== - -inline IdentifierHash LArOnline_SuperCellID::channel_Hash_binary_search (HWIdentifier channelId) const -/*=========================================================================*/ -{ - std::vector::const_iterator it = std::lower_bound(m_channel_vec.begin(),m_channel_vec.end(),channelId); - if ( it != m_channel_vec.end() ){ - return (it - m_channel_vec.begin()); - } - return(0) ; -} - - - -/* BOOLEAN */ - #endif // LARONLINE_ID_H - - diff --git a/LArCalorimeter/LArIdentifier/src/LArOnlineID.cxx b/LArCalorimeter/LArIdentifier/src/LArOnlineID.cxx index fdee42d9027..fe82a23eb09 100755 --- a/LArCalorimeter/LArIdentifier/src/LArOnlineID.cxx +++ b/LArCalorimeter/LArIdentifier/src/LArOnlineID.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ #include "LArIdentifier/LArOnlineID.h" @@ -16,9 +16,7 @@ /* See comments in Base class */ LArOnlineID::LArOnlineID(void) : - LArOnlineID_Base(), - m_calibModuleHashMax(0), - m_calibChannelHashMax(0) + LArOnlineID_Base() { m_this_is_slar=false; } @@ -130,11 +128,6 @@ int LArOnlineID::initialize_from_dictionary (const IdDictMgr& dict_mgr) region_id.add(larField); region_id.add(larOnlineField); Range prefix; - /* Calib Multirange */ - ExpandedIdentifier region_id2; - region_id2.add(larField); - region_id2.add(larOnlineCalibField); - Range prefix2; /*Full range for all channels*/ m_full_laronline_range = m_dict->build_multirange( region_id , group_name, prefix); @@ -159,26 +152,6 @@ int LArOnlineID::initialize_from_dictionary (const IdDictMgr& dict_mgr) std::cout << strg3 << std::endl; } } - /* calib */ - /* Full range for calib channels */ - m_full_calib_laronline_range = m_dict->build_multirange( region_id2 , group_name, prefix2); - m_full_calib_module_range = m_dict->build_multirange( region_id2 , group_name, prefix2, "slot"); - - if (!m_quiet) { - std::string strg0= "=> initialize_from_dictionary : "; - std::string strg2= "=> Calib module range -> " + (std::string)m_full_calib_module_range; - std::string strg3= "=> Calib channel range -> " + (std::string)m_full_calib_laronline_range; - if(m_msgSvc) { - log << MSG::DEBUG << strg0 << endmsg; - log << MSG::DEBUG << strg2 << endmsg; - log << MSG::DEBUG << strg3 << endmsg; - } - else { - std::cout << strg0 << std::endl; - std::cout << strg2 << std::endl; - std::cout << strg3 << std::endl; - } - } /* Setup the hash tables */ @@ -804,81 +777,3 @@ int LArOnlineID::init_H6Hashes(void) -/*========================================*/ -int LArOnlineID::init_calib_hashes(void) -/*========================================*/ -{ - unsigned int nids=0; - std::set ids; - for (unsigned int i = 0; i < m_full_calib_laronline_range.size(); ++i) - { - const Range& range = m_full_calib_laronline_range[i]; - Range::const_identifier_factory first = range.factory_begin(); - Range::const_identifier_factory last = range.factory_end(); - for (; first != last; ++first) { - const ExpandedIdentifier& exp_id = (*first); - HWIdentifier id = this->calib_channel_Id(exp_id[m_bec_index], - exp_id[m_side_index], - exp_id[m_feedthrough_index], - exp_id[m_slot_index], - exp_id[m_channel_in_slot_index]); - if(!(ids.insert(id)).second) - { - std::cout << " LArOnlineID::init_calib_Hashes " - << " Error: duplicated id for channel id. nids= " << nids - << " compact Id " ; - (*first).show(); - std::cout << " " << show_to_string(id) << std::endl; - } - nids++; - } - } - unsigned int nidtb=0; - std::set::const_iterator first = ids.begin(); - std::set::const_iterator last = ids.end(); - for (;first != last && nidtb < nids; ++first) - { - m_calib_channel_vec.push_back(*first); - nidtb++; - } - m_calibChannelHashMax = m_calib_channel_vec.size(); - - /* FEB hash */ - /*==========*/ - nids = 0; - ids.clear(); - for (unsigned int i = 0; i < m_full_calib_module_range.size(); ++i) - { - const Range& range = m_full_calib_module_range[i]; - Range::const_identifier_factory first = range.factory_begin(); - Range::const_identifier_factory last = range.factory_end(); - for (; first != last; ++first) { - const ExpandedIdentifier& exp_id = (*first); - HWIdentifier febId = calib_module_Id( exp_id[m_bec_index], - exp_id[m_side_index], - exp_id[m_feedthrough_index], - exp_id[m_slot_index] ); - if(!(ids.insert(febId)).second){ - std::cout << " LArOnlineID::init_calibhashes " - << " Error: duplicated id for feb id. nids= " << nids - << " compact Id " ; - (*first).show(); - std::cout << " " << show_to_string(febId) << std::endl; - std::cout << std::endl; - } - nids++; - } - } - nidtb=0; - first = ids.begin(); - last = ids.end(); - for (;first != last && nidtb < nids; ++first) - { - m_calib_module_vec.push_back(*first); - nidtb++; - } - m_calibModuleHashMax = m_calib_module_vec.size(); - return (0); -} - - diff --git a/LArCalorimeter/LArIdentifier/src/LArOnlineID_Base.cxx b/LArCalorimeter/LArIdentifier/src/LArOnlineID_Base.cxx index 384974915bd..daa82cb762c 100755 --- a/LArCalorimeter/LArIdentifier/src/LArOnlineID_Base.cxx +++ b/LArCalorimeter/LArIdentifier/src/LArOnlineID_Base.cxx @@ -57,7 +57,9 @@ LArOnlineID_Base::LArOnlineID_Base(void) : m_dict(0), m_feedthroughHashMax(0), m_febHashMax(0), - m_channelHashMax(0) + m_channelHashMax(0), + m_calibModuleHashMax(0), + m_calibChannelHashMax(0) { } @@ -440,6 +442,26 @@ int LArOnlineID_Base::initialize_from_dictionary (const IdDictMgr& dict_mgr) std::cout << strg3 << std::endl; } + /* calib */ + /* Full range for calib channels */ + m_full_calib_laronline_range = m_dict->build_multirange( region_id2 , group_name, prefix2); + m_full_calib_module_range = m_dict->build_multirange( region_id2 , group_name, prefix2, "slot"); + + if (!m_quiet) { + std::string strg0= "=> initialize_from_dictionary : "; + std::string strg2= "=> Calib module range -> " + (std::string)m_full_calib_module_range; + std::string strg3= "=> Calib channel range -> " + (std::string)m_full_calib_laronline_range; + if(m_msgSvc) { + log << MSG::DEBUG << strg0 << endmsg; + log << MSG::DEBUG << strg2 << endmsg; + log << MSG::DEBUG << strg3 << endmsg; + } + else { + std::cout << strg0 << std::endl; + std::cout << strg2 << std::endl; + std::cout << strg3 << std::endl; + } + } /* Setup the hash tables */ std::stringstream strm; @@ -1545,16 +1567,6 @@ IdentifierHash LArOnlineID_Base::feb_Hash (HWIdentifier febId) const return (hc.m_hash + slotIndex); } -IdentifierHash LArOnlineID_Base::feb_Hash_binary_search (HWIdentifier febId) const -/*=============================================================================== */ -{ - std::vector::const_iterator it = std::lower_bound(m_feb_vec.begin(),m_feb_vec.end(),febId); - if ( it != m_feb_vec.end() ){ - return (it - m_feb_vec.begin()); - } - return (0); -} - HWIdentifier LArOnlineID_Base::channel_Id( int barrel_ec, int pos_neg, int feedthrough, int slot, int channel, @@ -1654,16 +1666,6 @@ IdentifierHash LArOnlineID_Base::channel_Hash (HWIdentifier channelId) const return (hc.m_hash + channel(channelId)); } -IdentifierHash LArOnlineID_Base::channel_Hash_binary_search (HWIdentifier channelId) const -/*=========================================================================*/ -{ - std::vector::const_iterator it = std::lower_bound(m_channel_vec.begin(),m_channel_vec.end(),channelId); - if ( it != m_channel_vec.end() ){ - return (it - m_channel_vec.begin()); - } - return(0) ; -} - /* BOOLEAN */ /* @@ -2034,6 +2036,84 @@ int LArOnlineID_Base::is_slar(const HWIdentifier id)const } +/*========================================*/ +int LArOnlineID_Base::init_calib_hashes(void) +/*========================================*/ +{ + unsigned int nids=0; + std::set ids; + for (unsigned int i = 0; i < m_full_calib_laronline_range.size(); ++i) + { + const Range& range = m_full_calib_laronline_range[i]; + Range::const_identifier_factory first = range.factory_begin(); + Range::const_identifier_factory last = range.factory_end(); + for (; first != last; ++first) { + const ExpandedIdentifier& exp_id = (*first); + HWIdentifier id = this->calib_channel_Id(exp_id[m_bec_index], + exp_id[m_side_index], + exp_id[m_feedthrough_index], + exp_id[m_slot_index], + exp_id[m_channel_in_slot_index]); + if(!(ids.insert(id)).second) + { + std::cout << " LArOnlineID_Base::init_calib_Hashes " + << " Error: duplicated id for channel id. nids= " << nids + << " compact Id " ; + (*first).show(); + std::cout << " " << show_to_string(id) << std::endl; + } + nids++; + } + } + unsigned int nidtb=0; + std::set::const_iterator first = ids.begin(); + std::set::const_iterator last = ids.end(); + for (;first != last && nidtb < nids; ++first) + { + m_calib_channel_vec.push_back(*first); + nidtb++; + } + m_calibChannelHashMax = m_calib_channel_vec.size(); + + /* FEB hash */ + /*==========*/ + nids = 0; + ids.clear(); + for (unsigned int i = 0; i < m_full_calib_module_range.size(); ++i) + { + const Range& range = m_full_calib_module_range[i]; + Range::const_identifier_factory first = range.factory_begin(); + Range::const_identifier_factory last = range.factory_end(); + for (; first != last; ++first) { + const ExpandedIdentifier& exp_id = (*first); + HWIdentifier febId = calib_module_Id( exp_id[m_bec_index], + exp_id[m_side_index], + exp_id[m_feedthrough_index], + exp_id[m_slot_index] ); + if(!(ids.insert(febId)).second){ + std::cout << " LArOnlineID_Base::init_calibhashes " + << " Error: duplicated id for feb id. nids= " << nids + << " compact Id " ; + (*first).show(); + std::cout << " " << show_to_string(febId) << std::endl; + std::cout << std::endl; + } + nids++; + } + } + nidtb=0; + first = ids.begin(); + last = ids.end(); + for (;first != last && nidtb < nids; ++first) + { + m_calib_module_vec.push_back(*first); + nidtb++; + } + m_calibModuleHashMax = m_calib_module_vec.size(); + return (0); +} + + diff --git a/LArCalorimeter/LArIdentifier/src/LArOnline_SuperCellID.cxx b/LArCalorimeter/LArIdentifier/src/LArOnline_SuperCellID.cxx index c75cf739d43..f816a4337cc 100755 --- a/LArCalorimeter/LArIdentifier/src/LArOnline_SuperCellID.cxx +++ b/LArCalorimeter/LArIdentifier/src/LArOnline_SuperCellID.cxx @@ -1,407 +1,400 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ -#include "LArIdentifier/LArOnline_SuperCellID.h" -#include "LArIdentifier/LArOnlID_Exception.h" -#include "Identifier/IdentifierHash.h" -#include "IdDict/IdDictDefs.h" -#include "GaudiKernel/MsgStream.h" -#include -#include -#include -#include -#include - -/* See comments in Base class */ - -LArOnline_SuperCellID::LArOnline_SuperCellID(void) : - LArOnlineID_Base() -{ - m_this_is_slar=true; -} - - -LArOnline_SuperCellID::~LArOnline_SuperCellID(void) -{ -} - -/* =================================================================== */ -int LArOnline_SuperCellID::initialize_from_dictionary (const IdDictMgr& dict_mgr) -/* =================================================================== */ -{ - MsgStream log(m_msgSvc, "LArOnline_SuperCellID" ); - std::string strg = "initialize_from_dictionary"; - if(m_msgSvc) { - log << MSG::INFO << strg << endmsg; - } - else { - std::cout << strg << std::endl; - } - - // Check whether this helper should be reinitialized - if (!reinitialize(dict_mgr)) { - if(m_msgSvc)log << MSG::DEBUG << "Request to reinitialize not satisfied - tags have not changed" << endmsg; - return (0); - } - else { - log << MSG::DEBUG << "(Re)initialize" << endmsg; - } - - // init base object - if(AtlasDetectorID::initialize_from_dictionary(dict_mgr)) return (1); - m_dict = dict_mgr.find_dictionary ("LArCalorimeter"); - if(!m_dict) { - - strg = " initialize_from_dictionary - cannot access LArCalorimeter dictionary "; - if(m_msgSvc) { - log << MSG::ERROR << strg << endmsg; - } - else { - std::cout << "LArOnline_SuperCellID::" << strg << std::endl; - } - return 1; - } - - // Register version of the dictionary used - if (register_dict_tag(dict_mgr, "LArCalorimeter")) return(1); - - // initialize dictionary version - AtlasDetectorID::setDictVersion(dict_mgr, "LArCalorimeter"); - - /* Initialize the field indices */ - std::string group_name("LArOnline_SuperCell"); - if(LArOnlineID_Base::initLevelsFromDict(group_name)) return (1); - - std::cout << "Finished initLevelsFromDict" << std::endl; - - - /* Find value for the field LAr Calorimeter */ - const IdDictDictionary* atlasDict = dict_mgr.find_dictionary ("ATLAS"); - int larField = -1; - if (atlasDict->get_label_value("subdet", "LArCalorimeter", larField)) { - std::stringstream strm; - strm << atlasDict->m_name; - strg= " Could not get value for label 'LArCalorimeter' of field 'subdet' in dictionary "+strm.str(); - if(m_msgSvc) { - log << MSG::ERROR << strg << endmsg; - } - else { - std::cout << "LArOnline_SuperCellID:" << strg << std::endl; - } - return (1); - } - - /* Find value for the field LArOnline */ - int larOnlineField = -4; - if (m_dict->get_label_value("part", "LArOnline", larOnlineField)) { - std::stringstream strm; - strm << m_dict->m_name; - strg = "Could not get value for label 'LArOnline' of field 'part' in dictionary "+strm.str(); - if(m_msgSvc) { - log << MSG::ERROR << strg << endmsg; - } - else { - std::cout << strg << std::endl; - } - return (1); - } - - /* Find value for the field calibLArOnline */ - int larOnlineCalibField = -5; - if (m_dict->get_label_value("part", "LArOnlineCalib", larOnlineCalibField)) { - std::stringstream strm; - strm << m_dict->m_name; - strg = "Could not get value for label 'LArOnlineCalib' of field 'part' in dictionary "+strm.str(); - if(m_msgSvc) { - log << MSG::ERROR << strg << endmsg; - } - else { - std::cout << strg << std::endl; - } - return (1); - } - - /* Set up id for Region and range prefix */ - ExpandedIdentifier region_id; - region_id.add(larField); - region_id.add(larOnlineField); - Range prefix; - /* Calib Multirange */ -/* - ExpandedIdentifier region_id2; - region_id2.add(larField); - region_id2.add(larOnlineCalibField); - Range prefix2; -*/ - - /*Full range for all channels*/ - m_full_laronline_range = m_dict->build_multirange( region_id, group_name, prefix); - m_full_feb_range = m_dict->build_multirange( region_id, group_name, prefix, "slar_slot"); - m_full_feedthrough_range = m_dict->build_multirange( region_id , group_name, prefix, "slar_feedthrough"); - - std::string strg0= " initialize_from_dictionary :"; - std::string strg1= " feedthrough range -> " + (std::string)m_full_feedthrough_range; - std::string strg2= " feedthrough slot range -> " + (std::string)m_full_feb_range; - std::string strg3= " channel range -> " + (std::string)m_full_laronline_range; - if(m_msgSvc) { - log << MSG::DEBUG << strg0 << endmsg; - log << MSG::DEBUG << strg1 << endmsg; - log << MSG::DEBUG << strg2 << endmsg; - log << MSG::DEBUG << strg3 << endmsg; - } - else { - std::cout << strg0 << std::endl; - std::cout << strg1 << std::endl; - std::cout << strg2 << std::endl; - std::cout << strg3 << std::endl; - } - - /* Setup the hash tables */ - std::stringstream strm; - strm << dictionaryVersion(); - strg="[initialize_from_dictionary] version= " + strm.str(); - if(m_msgSvc) { - log << MSG::DEBUG << strg << endmsg; - } - else { - std::cout << "LArOnline_SuperCellID: " << strg << std::endl; - } - if( dictionaryVersion() == "fullAtlas" ) { - if(LArOnlineID_Base::init_hashes()) return (1); - } - - // Setup for hash calculation for channels (febs is further below) - - // Febs have a uniform number of channels - // The lookup table only needs to contain the - // hash offset for each feb - - // The implementation requires: - - // 1) a lookup table for each feb containing hash offset - // 2) a decoder to access the "index" corresponding to the - // bec/side/ft/slot fields. These fields use x bits, so the - // vector has a length of 2**x. - - /* Create decoder for fields bec to slot */ - IdDictFieldImplementation::size_type bits = - m_bec_impl.bits() + - m_side_impl.bits() + - m_feedthrough_impl.bits() + - m_slot_impl.bits(); - IdDictFieldImplementation::size_type bits_offset = m_bec_impl.bits_offset(); - m_bec_slot_impl.set_bits(bits, bits_offset); - int size = (1 << bits); - - // Set up vector as lookup table for hash calculation. - m_chan_hash_calcs.resize(size); - - std::stringstream strm1; - std::stringstream strm2; - for (unsigned int i = 0; i < m_febHashMax; ++i) { - - HWIdentifier febId = feb_Id(i) ; - - HashCalc hc; - - HWIdentifier min = channel_Id ( febId, 0); - - IdentifierHash min_hash = channel_Hash_binary_search(min); - hc.m_hash = min_hash; - m_chan_hash_calcs[m_bec_slot_impl.unpack(min)] = hc; - - if (m_bec_slot_impl.unpack(min) >= size) { - strm << size; - strm1 << show_to_string(min); - strm2 << m_bec_slot_impl.unpack(min); - strg = "Min > "+strm.str(); - strg1= " "+strm1.str(); - strg2= " "+strm2.str(); - if(m_msgSvc) { - log << MSG::DEBUG << strg << endmsg; - log << MSG::DEBUG << strg1 << endmsg; - log << MSG::DEBUG << strg2 << endmsg; - } - else { - std::cout << strg << std::endl; - std::cout << strg1 << std::endl; - std::cout << strg2 << std::endl; - } - //std::cout << "min > " << size << " " - // << i << " " - // << show_to_string(min) << " " - // << m_pnz_reg_impl.unpack(min) << " " - // << std::endl; - } - } - - // Check channel hash calculation - for (unsigned int i = 0; i < m_channelHashMax; ++i) { - HWIdentifier id = channel_Id(i); - if (channel_Hash(id) != i) { - strm << show_to_string(id); - strm1 << channel_Hash(id); - strm2 << i; - strg = " ***** Error channel ranges, id, hash, i = "+strm.str(); - strg1= " , "+strm1.str(); - strg2= " , "+strm2.str(); - if(m_msgSvc) { - log << MSG::ERROR << strg << endmsg; - log << MSG::ERROR << strg1 << endmsg; - log << MSG::ERROR << strg2 << endmsg; - } - else { - std::cout << strg << std::endl; - std::cout << strg1 << std::endl; - std::cout << strg2 << std::endl; - } - } - } - - - - // Setup for hash calculation for febs - - // We calculate the feb hash by saving the hash of each - // feedthrough in a HashCalc object and then adding on the slot - // number for a particular feb - - // The implementation requires: - - // 1) a lookup table for each ft containing hash offset - // 2) a decoder to access the "index" corresponding to the - // bec/side/ft fields. These fields use x bits, so the - // vector has a length of 2**x. - - /* Create decoder for fields bec to ft */ - bits = m_bec_impl.bits() + - m_side_impl.bits() + - m_feedthrough_impl.bits(); - bits_offset = m_bec_impl.bits_offset(); - m_bec_ft_impl.set_bits(bits, bits_offset); - size = (1 << bits); - - // Set up vector as lookup table for hash calculation. - m_feb_hash_calcs.resize(size); - - // Get context for conversion to expanded ids - IdContext ftContext = feedthroughContext(); - ExpandedIdentifier ftExpId; - - for (unsigned int i = 0; i < m_feedthroughHashMax; ++i) { - - HWIdentifier min = feedthrough_Id(i) ; - - HashCalcFeb hc; - - // Set the hash id for each feedthrough, and then check if one - // needs to also save the slot values - IdentifierHash min_hash = LArOnlineID_Base::feb_Hash_binary_search(min); - hc.m_hash = min_hash; - - // For each feedthrough we save the possible slot values for - // the hash calculation. - if (get_expanded_id(min, ftExpId, &ftContext)) { - std::cout << " ***** Error cannot get ft expanded id for " << show_to_string(min) << std::endl; - } - - // If there is more than a single range found for this - // feedthrough, or if the slot values are enumerated, then we - // need to save all slot values in the HashCalculator. - unsigned int nrangesFound = 0; - //bool foundEnumerated = false; - // first check the ranges - for (unsigned int i = 0; i < m_full_feb_range.size(); ++i) { - if (m_full_feb_range[i].match(ftExpId)) { - nrangesFound += 1; - //const Range::field& slotField = m_full_feb_range[i][m_slot_index]; - //if (slotField.get_mode() == Range::field::enumerated) foundEnumerated = true; - } - } - - // Now repeat loop and save values if we either have an - // enumerated set of slots, or more than one FT - for (unsigned int i = 0; i < m_full_feb_range.size(); ++i) { - if (m_full_feb_range[i].match(ftExpId)) { - const Range::field& slotField = m_full_feb_range[i][m_slot_index]; - if (slotField.get_mode() == Range::field::both_bounded || - slotField.get_mode() == Range::field::enumerated) { - // save values - unsigned int nvalues = slotField.get_indices(); - hc.m_slot_values.reserve(hc.m_slot_values.size() + nvalues); - for (unsigned int j = 0; j < nvalues; ++j) { - hc.m_slot_values.push_back(slotField.get_value_at(j)); - } - } - } - } - - // for (unsigned int i = 0; i < m_full_feb_range.size(); ++i) { - // if (m_full_feb_range[i].match(ftExpId)) { - // nrangesFound += 1; - // const Range::field& slotField = m_full_feb_range[i][m_slot_index]; - // // if (slotField.get_mode() == Range::field::enumerated) { - // // // save values - // // hc.m_slot_values = slotField.get_values(); - // // } - // if (slotField.get_mode() == Range::field::both_bounded || - // slotField.get_mode() == Range::field::enumerated) { - // // save values - // unsigned int nvalues = slotField.get_indices(); - // hc.m_slot_values.reserve(hc.m_slot_values.size() + nvalues); - // for (unsigned int j = 0; j < nvalues; ++j) { - // hc.m_slot_values.push_back(slotField.get_value_at(j)); - // } - // } - // } - // } - - - // Set hash calculator - m_feb_hash_calcs[m_bec_ft_impl.unpack(min)] = hc; - - - if (m_bec_ft_impl.unpack(min) >= size) { - std::stringstream strm, strm1, strm2, strm3; - strm << size; - strm1 << show_to_string(min); - strm2 << m_bec_ft_impl.unpack(min); - strm3 << min_hash; - strg = "Min > " + strm.str() + " " + strm1.str() + " " + strm2.str() + " " + strm3.str(); - if(m_msgSvc) { - log << MSG::DEBUG << strg << endmsg; - } - else { - std::cout << strg << std::endl; - } - //std::cout << "min > " << size << " " - // << i << " " - // << show_to_string(min) << " " - // << m_pnz_reg_impl.unpack(min) << " " - // << std::endl; - } - } - - // Check feb hash calculation - for (unsigned int i = 0; i < m_febHashMax; ++i) { - HWIdentifier id = feb_Id(i); - if (feb_Hash(id) != i) { - std::stringstream strm, strm1, strm2; - strm << show_to_string(id); - strm1 << feb_Hash(id); - strm2 << i; - strg = " ***** Error feb ranges, id, hash, i = " + - strm.str() + " , " + strm1.str() + " , "+strm2.str(); - if(m_msgSvc) { - log << MSG::ERROR << strg << endmsg; - } - else { - std::cout << strg << std::endl; - } - } - } - - return 0; -} - +#include "LArIdentifier/LArOnline_SuperCellID.h" +#include "LArIdentifier/LArOnlID_Exception.h" +#include "Identifier/IdentifierHash.h" +#include "IdDict/IdDictDefs.h" +#include "GaudiKernel/MsgStream.h" +#include +#include +#include +#include +#include + +/* See comments in Base class */ + +LArOnline_SuperCellID::LArOnline_SuperCellID(void) : + LArOnlineID_Base() +{ + m_this_is_slar=true; +} + + +LArOnline_SuperCellID::~LArOnline_SuperCellID(void) +{ +} + +/* =================================================================== */ +int LArOnline_SuperCellID::initialize_from_dictionary (const IdDictMgr& dict_mgr) +/* =================================================================== */ +{ + MsgStream log(m_msgSvc, "LArOnline_SuperCellID" ); + std::string strg = "initialize_from_dictionary"; + if(m_msgSvc) { + log << MSG::INFO << strg << endmsg; + } + else { + std::cout << strg << std::endl; + } + + // Check whether this helper should be reinitialized + if (!reinitialize(dict_mgr)) { + if(m_msgSvc)log << MSG::DEBUG << "Request to reinitialize not satisfied - tags have not changed" << endmsg; + return (0); + } + else { + log << MSG::DEBUG << "(Re)initialize" << endmsg; + } + + // init base object + if(AtlasDetectorID::initialize_from_dictionary(dict_mgr)) return (1); + m_dict = dict_mgr.find_dictionary ("LArCalorimeter"); + if(!m_dict) { + + strg = " initialize_from_dictionary - cannot access LArCalorimeter dictionary "; + if(m_msgSvc) { + log << MSG::ERROR << strg << endmsg; + } + else { + std::cout << "LArOnline_SuperCellID::" << strg << std::endl; + } + return 1; + } + + // Register version of the dictionary used + if (register_dict_tag(dict_mgr, "LArCalorimeter")) return(1); + + // initialize dictionary version + AtlasDetectorID::setDictVersion(dict_mgr, "LArCalorimeter"); + + /* Initialize the field indices */ + std::string group_name("LArOnline_SuperCell"); + if(LArOnlineID_Base::initLevelsFromDict(group_name)) return (1); + + std::cout << "Finished initLevelsFromDict" << std::endl; + + + /* Find value for the field LAr Calorimeter */ + const IdDictDictionary* atlasDict = dict_mgr.find_dictionary ("ATLAS"); + int larField = -1; + if (atlasDict->get_label_value("subdet", "LArCalorimeter", larField)) { + std::stringstream strm; + strm << atlasDict->m_name; + strg= " Could not get value for label 'LArCalorimeter' of field 'subdet' in dictionary "+strm.str(); + if(m_msgSvc) { + log << MSG::ERROR << strg << endmsg; + } + else { + std::cout << "LArOnline_SuperCellID:" << strg << std::endl; + } + return (1); + } + + /* Find value for the field LArOnline */ + int larOnlineField = -4; + if (m_dict->get_label_value("part", "LArOnline", larOnlineField)) { + std::stringstream strm; + strm << m_dict->m_name; + strg = "Could not get value for label 'LArOnline' of field 'part' in dictionary "+strm.str(); + if(m_msgSvc) { + log << MSG::ERROR << strg << endmsg; + } + else { + std::cout << strg << std::endl; + } + return (1); + } + + /* Find value for the field calibLArOnline */ + int larOnlineCalibField = -5; + if (m_dict->get_label_value("part", "LArOnlineCalib", larOnlineCalibField)) { + std::stringstream strm; + strm << m_dict->m_name; + strg = "Could not get value for label 'LArOnlineCalib' of field 'part' in dictionary "+strm.str(); + if(m_msgSvc) { + log << MSG::ERROR << strg << endmsg; + } + else { + std::cout << strg << std::endl; + } + return (1); + } + + /* Set up id for Region and range prefix */ + ExpandedIdentifier region_id; + region_id.add(larField); + region_id.add(larOnlineField); + Range prefix; + + /*Full range for all channels*/ + m_full_laronline_range = m_dict->build_multirange( region_id, group_name, prefix); + m_full_feb_range = m_dict->build_multirange( region_id, group_name, prefix, "slar_slot"); + m_full_feedthrough_range = m_dict->build_multirange( region_id , group_name, prefix, "slar_feedthrough"); + + std::string strg0= " initialize_from_dictionary :"; + std::string strg1= " feedthrough range -> " + (std::string)m_full_feedthrough_range; + std::string strg2= " feedthrough slot range -> " + (std::string)m_full_feb_range; + std::string strg3= " channel range -> " + (std::string)m_full_laronline_range; + if(m_msgSvc) { + log << MSG::DEBUG << strg0 << endmsg; + log << MSG::DEBUG << strg1 << endmsg; + log << MSG::DEBUG << strg2 << endmsg; + log << MSG::DEBUG << strg3 << endmsg; + } + else { + std::cout << strg0 << std::endl; + std::cout << strg1 << std::endl; + std::cout << strg2 << std::endl; + std::cout << strg3 << std::endl; + } + + /* Setup the hash tables */ + std::stringstream strm; + strm << dictionaryVersion(); + strg="[initialize_from_dictionary] version= " + strm.str(); + if(m_msgSvc) { + log << MSG::DEBUG << strg << endmsg; + } + else { + std::cout << "LArOnline_SuperCellID: " << strg << std::endl; + } + if( dictionaryVersion() == "fullAtlas" ) { + if(LArOnlineID_Base::init_hashes()) return (1); + } + + // Setup for hash calculation for channels (febs is further below) + + // Febs have a uniform number of channels + // The lookup table only needs to contain the + // hash offset for each feb + + // The implementation requires: + + // 1) a lookup table for each feb containing hash offset + // 2) a decoder to access the "index" corresponding to the + // bec/side/ft/slot fields. These fields use x bits, so the + // vector has a length of 2**x. + + /* Create decoder for fields bec to slot */ + IdDictFieldImplementation::size_type bits = + m_bec_impl.bits() + + m_side_impl.bits() + + m_feedthrough_impl.bits() + + m_slot_impl.bits(); + IdDictFieldImplementation::size_type bits_offset = m_bec_impl.bits_offset(); + m_bec_slot_impl.set_bits(bits, bits_offset); + int size = (1 << bits); + + // Set up vector as lookup table for hash calculation. + m_chan_hash_calcs.resize(size); + + std::stringstream strm1; + std::stringstream strm2; + for (unsigned int i = 0; i < m_febHashMax; ++i) { + + HWIdentifier febId = feb_Id(i) ; + + HashCalc hc; + + HWIdentifier min = channel_Id ( febId, 0); + + IdentifierHash min_hash = channel_Hash_binary_search(min); + hc.m_hash = min_hash; + m_chan_hash_calcs[m_bec_slot_impl.unpack(min)] = hc; + + if (m_bec_slot_impl.unpack(min) >= size) { + strm << size; + strm1 << show_to_string(min); + strm2 << m_bec_slot_impl.unpack(min); + strg = "Min > "+strm.str(); + strg1= " "+strm1.str(); + strg2= " "+strm2.str(); + if(m_msgSvc) { + log << MSG::DEBUG << strg << endmsg; + log << MSG::DEBUG << strg1 << endmsg; + log << MSG::DEBUG << strg2 << endmsg; + } + else { + std::cout << strg << std::endl; + std::cout << strg1 << std::endl; + std::cout << strg2 << std::endl; + } + //std::cout << "min > " << size << " " + // << i << " " + // << show_to_string(min) << " " + // << m_pnz_reg_impl.unpack(min) << " " + // << std::endl; + } + } + + // Check channel hash calculation + for (unsigned int i = 0; i < m_channelHashMax; ++i) { + HWIdentifier id = channel_Id(i); + if (channel_Hash(id) != i) { + strm << show_to_string(id); + strm1 << channel_Hash(id); + strm2 << i; + strg = " ***** Error channel ranges, id, hash, i = "+strm.str(); + strg1= " , "+strm1.str(); + strg2= " , "+strm2.str(); + if(m_msgSvc) { + log << MSG::ERROR << strg << endmsg; + log << MSG::ERROR << strg1 << endmsg; + log << MSG::ERROR << strg2 << endmsg; + } + else { + std::cout << strg << std::endl; + std::cout << strg1 << std::endl; + std::cout << strg2 << std::endl; + } + } + } + + + + // Setup for hash calculation for febs + + // We calculate the feb hash by saving the hash of each + // feedthrough in a HashCalc object and then adding on the slot + // number for a particular feb + + // The implementation requires: + + // 1) a lookup table for each ft containing hash offset + // 2) a decoder to access the "index" corresponding to the + // bec/side/ft fields. These fields use x bits, so the + // vector has a length of 2**x. + + /* Create decoder for fields bec to ft */ + bits = m_bec_impl.bits() + + m_side_impl.bits() + + m_feedthrough_impl.bits(); + bits_offset = m_bec_impl.bits_offset(); + m_bec_ft_impl.set_bits(bits, bits_offset); + size = (1 << bits); + + // Set up vector as lookup table for hash calculation. + m_feb_hash_calcs.resize(size); + + // Get context for conversion to expanded ids + IdContext ftContext = feedthroughContext(); + ExpandedIdentifier ftExpId; + + for (unsigned int i = 0; i < m_feedthroughHashMax; ++i) { + + HWIdentifier min = feedthrough_Id(i) ; + + HashCalcFeb hc; + + // Set the hash id for each feedthrough, and then check if one + // needs to also save the slot values + IdentifierHash min_hash = LArOnlineID_Base::feb_Hash_binary_search(min); + hc.m_hash = min_hash; + + // For each feedthrough we save the possible slot values for + // the hash calculation. + if (get_expanded_id(min, ftExpId, &ftContext)) { + std::cout << " ***** Error cannot get ft expanded id for " << show_to_string(min) << std::endl; + } + + // If there is more than a single range found for this + // feedthrough, or if the slot values are enumerated, then we + // need to save all slot values in the HashCalculator. + unsigned int nrangesFound = 0; + //bool foundEnumerated = false; + // first check the ranges + for (unsigned int i = 0; i < m_full_feb_range.size(); ++i) { + if (m_full_feb_range[i].match(ftExpId)) { + nrangesFound += 1; + //const Range::field& slotField = m_full_feb_range[i][m_slot_index]; + //if (slotField.get_mode() == Range::field::enumerated) foundEnumerated = true; + } + } + + // Now repeat loop and save values if we either have an + // enumerated set of slots, or more than one FT + for (unsigned int i = 0; i < m_full_feb_range.size(); ++i) { + if (m_full_feb_range[i].match(ftExpId)) { + const Range::field& slotField = m_full_feb_range[i][m_slot_index]; + if (slotField.get_mode() == Range::field::both_bounded || + slotField.get_mode() == Range::field::enumerated) { + // save values + unsigned int nvalues = slotField.get_indices(); + hc.m_slot_values.reserve(hc.m_slot_values.size() + nvalues); + for (unsigned int j = 0; j < nvalues; ++j) { + hc.m_slot_values.push_back(slotField.get_value_at(j)); + } + } + } + } + + // for (unsigned int i = 0; i < m_full_feb_range.size(); ++i) { + // if (m_full_feb_range[i].match(ftExpId)) { + // nrangesFound += 1; + // const Range::field& slotField = m_full_feb_range[i][m_slot_index]; + // // if (slotField.get_mode() == Range::field::enumerated) { + // // // save values + // // hc.m_slot_values = slotField.get_values(); + // // } + // if (slotField.get_mode() == Range::field::both_bounded || + // slotField.get_mode() == Range::field::enumerated) { + // // save values + // unsigned int nvalues = slotField.get_indices(); + // hc.m_slot_values.reserve(hc.m_slot_values.size() + nvalues); + // for (unsigned int j = 0; j < nvalues; ++j) { + // hc.m_slot_values.push_back(slotField.get_value_at(j)); + // } + // } + // } + // } + + + // Set hash calculator + m_feb_hash_calcs[m_bec_ft_impl.unpack(min)] = hc; + + + if (m_bec_ft_impl.unpack(min) >= size) { + std::stringstream strm, strm1, strm2, strm3; + strm << size; + strm1 << show_to_string(min); + strm2 << m_bec_ft_impl.unpack(min); + strm3 << min_hash; + strg = "Min > " + strm.str() + " " + strm1.str() + " " + strm2.str() + " " + strm3.str(); + if(m_msgSvc) { + log << MSG::DEBUG << strg << endmsg; + } + else { + std::cout << strg << std::endl; + } + //std::cout << "min > " << size << " " + // << i << " " + // << show_to_string(min) << " " + // << m_pnz_reg_impl.unpack(min) << " " + // << std::endl; + } + } + + // Check feb hash calculation + for (unsigned int i = 0; i < m_febHashMax; ++i) { + HWIdentifier id = feb_Id(i); + if (feb_Hash(id) != i) { + std::stringstream strm, strm1, strm2; + strm << show_to_string(id); + strm1 << feb_Hash(id); + strm2 << i; + strg = " ***** Error feb ranges, id, hash, i = " + + strm.str() + " , " + strm1.str() + " , "+strm2.str(); + if(m_msgSvc) { + log << MSG::ERROR << strg << endmsg; + } + else { + std::cout << strg << std::endl; + } + } + } + + return 0; +} + -- GitLab From f679372d486f65cfeac6fbd594cba1c321c39cbd Mon Sep 17 00:00:00 2001 From: Pavol Strizenec Date: Mon, 5 Aug 2019 14:37:56 +0200 Subject: [PATCH 2/2] cleaning logging --- .../LArIdentifier/src/LArOnlineID.cxx | 88 ++++++++----------- .../LArIdentifier/src/LArOnlineID_Base.cxx | 75 +++++++++------- .../src/LArOnline_SuperCellID.cxx | 47 +++------- 3 files changed, 90 insertions(+), 120 deletions(-) diff --git a/LArCalorimeter/LArIdentifier/src/LArOnlineID.cxx b/LArCalorimeter/LArIdentifier/src/LArOnlineID.cxx index fe82a23eb09..cf1d0aa846f 100755 --- a/LArCalorimeter/LArIdentifier/src/LArOnlineID.cxx +++ b/LArCalorimeter/LArIdentifier/src/LArOnlineID.cxx @@ -43,11 +43,10 @@ int LArOnlineID::initialize_from_dictionary (const IdDictMgr& dict_mgr) // Check whether this helper should be reinitialized if (!reinitialize(dict_mgr)) { - if(m_msgSvc)log << MSG::DEBUG << "Request to reinitialize not satisfied - tags have not changed" << endmsg; + if(m_msgSvc) log << MSG::DEBUG << "Request to reinitialize not satisfied - tags have not changed" << endmsg; return (0); - } - else { - log << MSG::DEBUG << "(Re)initialize" << endmsg; + } else { + if(m_msgSvc) log << MSG::DEBUG << "(Re)initialize" << endmsg; } // init base object @@ -175,12 +174,14 @@ int LArOnlineID::initialize_from_dictionary (const IdDictMgr& dict_mgr) if(init_calib_hashes()) return (1); } if( dictionaryVersion() == "H6TestBeam" ) { - log << MSG::DEBUG << "[initialze_from_dictionary] ...call init_H6hashes.." << endmsg; + if(m_msgSvc) log << MSG::DEBUG << "[initialze_from_dictionary] ...call init_H6hashes.." << endmsg; if(init_H6Hashes()) return (1); if(init_calib_hashes()) return (1); } - log << MSG::DEBUG << "initialize_from_dictionary -> calibModuleHash= " << m_calibModuleHashMax << endmsg; - log << MSG::DEBUG << "initialize_from_dictionary -> calibChannelHash= " << m_calibChannelHashMax << endmsg; + if(m_msgSvc) { + log << MSG::DEBUG << "initialize_from_dictionary -> calibModuleHash= " << m_calibModuleHashMax << endmsg; + log << MSG::DEBUG << "initialize_from_dictionary -> calibChannelHash= " << m_calibChannelHashMax << endmsg; + } // Setup for hash calculation for channels (febs is further below) @@ -242,11 +243,6 @@ int LArOnlineID::initialize_from_dictionary (const IdDictMgr& dict_mgr) std::cout << strg1 << std::endl; std::cout << strg2 << std::endl; } - //std::cout << "min > " << size << " " - // << i << " " - // << show_to_string(min) << " " - // << m_pnz_reg_impl.unpack(min) << " " - // << std::endl; } } } @@ -322,7 +318,11 @@ int LArOnlineID::initialize_from_dictionary (const IdDictMgr& dict_mgr) // values are enumerated or not. If they are enumerate we must // save the values in order to calculate the fed hash if (get_expanded_id(min, ftExpId, &ftContext)) { - std::cout << " ***** Error cannot get ft expanded id for " << show_to_string(min) << std::endl; + if(m_msgSvc) { + log << MSG::WARNING << " ***** Warning cannot get ft expanded id for " << show_to_string(min) << endmsg; + } else { + std::cout << " ***** Warning cannot get ft expanded id for " << show_to_string(min) << std::endl; + } } unsigned int nrangesFound = 0; for (unsigned int i = 0; i < m_full_feb_range.size(); ++i) { @@ -352,8 +352,13 @@ int LArOnlineID::initialize_from_dictionary (const IdDictMgr& dict_mgr) } } else { - std::cout << " ***** Error feb range slot field is NOT both_bounded - id, slot mode: " - << show_to_string(min) << " " << slotField.get_mode() << std::endl; + if(m_msgSvc) { + log << MSG::WARNING << " ***** Warning feb range slot field is NOT both_bounded - id, slot mode: " + << show_to_string(min) << " " << slotField.get_mode() << endmsg; + } else { + std::cout << " ***** Warning feb range slot field is NOT both_bounded - id, slot mode: " + << show_to_string(min) << " " << slotField.get_mode() << std::endl; + } } } } @@ -377,11 +382,6 @@ int LArOnlineID::initialize_from_dictionary (const IdDictMgr& dict_mgr) else { std::cout << strg << std::endl; } - //std::cout << "min > " << size << " " - // << i << " " - // << show_to_string(min) << " " - // << m_pnz_reg_impl.unpack(min) << " " - // << std::endl; } } @@ -393,10 +393,10 @@ int LArOnlineID::initialize_from_dictionary (const IdDictMgr& dict_mgr) strm << show_to_string(id); strm1 << feb_Hash(id); strm2 << i; - std::string strg = " ***** Error feb ranges, id, hash, i = " + + std::string strg = " ***** Warning feb ranges, id, hash, i = " + strm.str() + " , " + strm1.str() + " , "+strm2.str(); if(m_msgSvc) { - log << MSG::ERROR << strg << endmsg; + log << MSG::WARNING << strg << endmsg; } else { std::cout << strg << std::endl; @@ -423,7 +423,7 @@ int LArOnlineID::init_H8Hashes(void) /* Channel hash */ unsigned int nids=0; std::set ids; - log << MSG::DEBUG << "[init_H8hashes] > ChannelId : m_full_laronline_range.size() = " << m_full_laronline_range.size() << endmsg; + if(m_msgSvc) log << MSG::DEBUG << "[init_H8hashes] > ChannelId : m_full_laronline_range.size() = " << m_full_laronline_range.size() << endmsg; for (unsigned int i = 0; i < m_full_laronline_range.size(); ++i) { const Range& range = m_full_laronline_range[i]; @@ -446,13 +446,11 @@ int LArOnlineID::init_H8Hashes(void) if(m_msgSvc) { log << MSG::ERROR << strg1 << endmsg; - //log << MSG::ERROR << strg2 << endmsg; log << MSG::ERROR << strg3 << endmsg; } else { std::cout << "LArOnlineID::Error" << strg1 << std::endl; - //std::cout << strg2 << std::endl; std::cout << strg3 << std::endl; } } @@ -477,7 +475,7 @@ int LArOnlineID::init_H8Hashes(void) /*==========*/ nids = 0; ids.clear(); - log << MSG::DEBUG << "[init_H8hashes] > FebId : m_full_feb_range.size() = " << m_full_feb_range.size() << endmsg; + if(m_msgSvc) log << MSG::DEBUG << "[init_H8hashes] > FebId : m_full_feb_range.size() = " << m_full_feb_range.size() << endmsg; for (unsigned int i = 0; i < m_full_feb_range.size(); ++i) { const Range& range = m_full_feb_range[i]; @@ -499,13 +497,11 @@ int LArOnlineID::init_H8Hashes(void) if(m_msgSvc) { log << MSG::ERROR << strg1 << endmsg; - //log << MSG::ERROR << strg2 << endmsg; log << MSG::ERROR << strg3 << endmsg; } else { std::cout << "LArOnlineID:: Error" << strg1 << std::endl; - //std::cout << strg2 << std::endl; std::cout << strg3 << std::endl; } } @@ -529,7 +525,7 @@ int LArOnlineID::init_H8Hashes(void) /*=================*/ nids = 0; ids.clear(); - log << MSG::DEBUG << "[init_H8hashes] FeedthroughId: m_feedthrough_range.size() = " << m_full_feedthrough_range.size() << endmsg; + if(m_msgSvc) log << MSG::DEBUG << "[init_H8hashes] FeedthroughId: m_feedthrough_range.size() = " << m_full_feedthrough_range.size() << endmsg; for (unsigned int i = 0; i < m_full_feedthrough_range.size(); ++i) { const Range& range = m_full_feedthrough_range[i]; @@ -544,7 +540,7 @@ int LArOnlineID::init_H8Hashes(void) int test_bec = barrel_ec( feedthroughId); int test_pn = pos_neg( feedthroughId); int test_ft = feedthrough( feedthroughId); - log << MSG::VERBOSE << "[init_H8hashes] in loop : [bec,pn,ft]= [" << test_bec + if(m_msgSvc) log << MSG::VERBOSE << "[init_H8hashes] in loop : [bec,pn,ft]= [" << test_bec << "," << test_pn << "," << test_ft << "]"<< endmsg; if(!(ids.insert(feedthroughId)).second) { @@ -555,13 +551,11 @@ int LArOnlineID::init_H8Hashes(void) if(m_msgSvc) { log << MSG::ERROR << strg1 << endmsg; - //log << MSG::ERROR << strg2 << endmsg; log << MSG::ERROR << strg3 << endmsg; } else { std::cout << "LArOnlineID::Error" << strg1 << std::endl; - //std::cout << strg2 << std::endl; std::cout << strg3 << std::endl; } } @@ -580,7 +574,7 @@ int LArOnlineID::init_H8Hashes(void) } } m_feedthroughHashMax = m_feedthrough_vec.size(); - log << MSG::DEBUG << "[init_H8hashes] final m_feedthroughHashMax = " << m_feedthroughHashMax << endmsg; + if(m_msgSvc) log << MSG::DEBUG << "[init_H8hashes] final m_feedthroughHashMax = " << m_feedthroughHashMax << endmsg; return (0); } @@ -600,8 +594,8 @@ int LArOnlineID::init_H6Hashes(void) unsigned int nids=0; std::set ids; - log << MSG::DEBUG << "[init_H6hashes] : ChannelId : m_full_laronline_range.size() = " - << m_full_laronline_range.size() << endmsg; + if(m_msgSvc) log << MSG::DEBUG << "[init_H6hashes] : ChannelId : m_full_laronline_range.size() = " + << m_full_laronline_range.size() << endmsg; for (unsigned int i = 0; i < m_full_laronline_range.size(); ++i) { const Range& range = m_full_laronline_range[i]; @@ -624,13 +618,11 @@ int LArOnlineID::init_H6Hashes(void) if(m_msgSvc) { log << MSG::ERROR << strg1 << endmsg; - //log << MSG::ERROR << strg2 << endmsg; log << MSG::ERROR << strg3 << endmsg; } else { std::cout << "LArOnlineID:: Error" << strg1 << std::endl; - //std::cout << strg2 << std::endl; std::cout << strg3 << std::endl; } } @@ -649,18 +641,12 @@ int LArOnlineID::init_H6Hashes(void) } } m_channelHashMax = m_channel_vec.size(); - /* - std::cout << "==> init_H6Hashes() -->LArOnlineID::init_H6hashes Found " - << m_channel_vec.size() - << " H6 channels " - << std::endl; - */ /* FEB hash */ /*==========*/ nids = 0; ids.clear(); - log << MSG::DEBUG << "[init_H6hashes] > FebId : m_full_feb_range.size() = " << m_full_feb_range.size() << endmsg; + if(m_msgSvc) log << MSG::DEBUG << "[init_H6hashes] > FebId : m_full_feb_range.size() = " << m_full_feb_range.size() << endmsg; for (unsigned int i = 0; i < m_full_feb_range.size(); ++i) { const Range& range = m_full_feb_range[i]; @@ -682,13 +668,11 @@ int LArOnlineID::init_H6Hashes(void) if(m_msgSvc) { log << MSG::ERROR << strg1 << endmsg; - //log << MSG::ERROR << strg2 << endmsg; log << MSG::ERROR << strg3 << endmsg; } else { std::cout << "LArOnlineID::Error" << strg1 << std::endl; - //std::cout << strg2 << std::endl; std::cout << strg3 << std::endl; } } @@ -714,7 +698,7 @@ int LArOnlineID::init_H6Hashes(void) nids = 0; ids.clear(); // AL--> - log << MSG::DEBUG << "[init_H6hashes] FeedthroughId: m_feedthrough_range.size() = " << m_full_feedthrough_range.size() << endmsg; + if(m_msgSvc) log << MSG::DEBUG << "[init_H6hashes] FeedthroughId: m_feedthrough_range.size() = " << m_full_feedthrough_range.size() << endmsg; for (unsigned int i = 0; i < m_full_feedthrough_range.size(); ++i) { const Range& range = m_full_feedthrough_range[i]; @@ -726,14 +710,14 @@ int LArOnlineID::init_H6Hashes(void) HWIdentifier feedthroughId = feedthrough_Id( exp_id[m_bec_index], exp_id[m_side_index], exp_id[m_feedthrough_index] ); - log << MSG::DEBUG << "[init_H6hashes] m_bec_index= " << m_bec_index + if(m_msgSvc) log << MSG::DEBUG << "[init_H6hashes] m_bec_index= " << m_bec_index << "m_side_index= " << m_bec_index << "m_feedthrough_index= " << m_bec_index << "m_slot_index= " << m_bec_index << endmsg; int test_bec = barrel_ec( feedthroughId); int test_pn = pos_neg( feedthroughId); int test_ft = feedthrough( feedthroughId); - log << MSG::DEBUG << "[init_H6hashes] in loop : [bec,pn,ft]= [" << test_bec + if(m_msgSvc) log << MSG::DEBUG << "[init_H6hashes] in loop : [bec,pn,ft]= [" << test_bec << "," << test_pn << "," << test_ft << "]"<< endmsg; if(!(ids.insert(feedthroughId)).second) { @@ -744,13 +728,11 @@ int LArOnlineID::init_H6Hashes(void) if(m_msgSvc) { log << MSG::ERROR << strg1 << endmsg; - //log << MSG::ERROR << strg2 << endmsg; log << MSG::ERROR << strg3 << endmsg; } else { std::cout << "LArOnlineID::Error" << strg1 << std::endl; - //std::cout << strg2 << std::endl; std::cout << strg3 << std::endl; } } @@ -764,13 +746,13 @@ int LArOnlineID::init_H6Hashes(void) { if( is_H6FT( *first )) { - log << MSG::DEBUG << "[init_H6hashes] filling m_feedthrough_vec IS-H6 !!"<< endmsg; + if(m_msgSvc) log << MSG::DEBUG << "[init_H6hashes] filling m_feedthrough_vec IS-H6 !!"<< endmsg; m_feedthrough_vec.push_back(*first); nidtb++; } } m_feedthroughHashMax = m_feedthrough_vec.size(); - log << MSG::DEBUG << "[init_H6hashes] final m_feedthroughHashMax = " << m_feedthroughHashMax << endmsg; + if(m_msgSvc) log << MSG::DEBUG << "[init_H6hashes] final m_feedthroughHashMax = " << m_feedthroughHashMax << endmsg; return (0); } diff --git a/LArCalorimeter/LArIdentifier/src/LArOnlineID_Base.cxx b/LArCalorimeter/LArIdentifier/src/LArOnlineID_Base.cxx index daa82cb762c..04c167806e4 100755 --- a/LArCalorimeter/LArIdentifier/src/LArOnlineID_Base.cxx +++ b/LArCalorimeter/LArIdentifier/src/LArOnlineID_Base.cxx @@ -534,11 +534,6 @@ int LArOnlineID_Base::initialize_from_dictionary (const IdDictMgr& dict_mgr) std::cout << strg1 << std::endl; std::cout << strg2 << std::endl; } - //std::cout << "min > " << size << " " - // << i << " " - // << show_to_string(min) << " " - // << m_pnz_reg_impl.unpack(min) << " " - // << std::endl; } } @@ -610,7 +605,11 @@ int LArOnlineID_Base::initialize_from_dictionary (const IdDictMgr& dict_mgr) // values are enumerated or not. If they are enumerate we must // save the values in order to calculate the fed hash if (get_expanded_id(min, ftExpId, &ftContext)) { - std::cout << " ***** Error cannot get ft expanded id for " << show_to_string(min) << std::endl; + if(m_msgSvc) { + log << MSG::WARNING << " ***** Warning cannot get ft expanded id for " << show_to_string(min) << endmsg; + } else { + std::cout << " ***** Warning cannot get ft expanded id for " << show_to_string(min) << std::endl; + } } unsigned int nrangesFound = 0; for (unsigned int i = 0; i < m_full_feb_range.size(); ++i) { @@ -640,8 +639,13 @@ int LArOnlineID_Base::initialize_from_dictionary (const IdDictMgr& dict_mgr) } } else { - std::cout << " ***** Error feb range slot field is NOT both_bounded - id, slot mode: " - << show_to_string(min) << " " << slotField.get_mode() << std::endl; + if(m_msgSvc) { + log << MSG::WARNING << " ***** Warning feb range slot field is NOT both_bounded - id, slot mode: " + << show_to_string(min) << " " << slotField.get_mode() << endmsg; + } else { + std::cout << " ***** Error feb range slot field is NOT both_bounded - id, slot mode: " + << show_to_string(min) << " " << slotField.get_mode() << std::endl; + } } } } @@ -665,11 +669,6 @@ int LArOnlineID_Base::initialize_from_dictionary (const IdDictMgr& dict_mgr) else { std::cout << strg << std::endl; } - //std::cout << "min > " << size << " " - // << i << " " - // << show_to_string(min) << " " - // << m_pnz_reg_impl.unpack(min) << " " - // << std::endl; } } @@ -1367,11 +1366,9 @@ int LArOnlineID_Base::init_hashes(void) bool LArOnlineID_Base::isValidId(const HWIdentifier id) const { - //std::cout << "larid=" << larid << ", onl=" << laronlineid << ", side=" << side << ", ft=" << ft << std::endl; const int larid=m_lar_impl.unpack(id); const int laronlineid=m_laronline_impl.unpack(id); - //std::cout << "larid=" << larid << ", onl=" << laronlineid << std::endl; if (larid!=lar_field_value()) return false; if (!(laronlineid==s_lar_online_field_value || laronlineid==s_lar_onlineCalib_field_value)) return false; @@ -1382,7 +1379,6 @@ bool LArOnlineID_Base::isValidId(const HWIdentifier id) const { const int bec=m_bec_impl.unpack(id); const int ft=m_feedthrough_impl.unpack(id); const int slot=m_slot_impl.unpack(id); - //std::cout << "bec=" << bec << ", ft=" << ft << ", slot=" << slot << std::endl; if (slot<1) return false; if (ft<0) return false; if (bec==0) { // Barrel case @@ -1548,6 +1544,7 @@ HWIdentifier LArOnlineID_Base::feb_Id(IdentifierHash febHashId) const IdentifierHash LArOnlineID_Base::feb_Hash (HWIdentifier febId) const /*=============================================================================== */ { + MsgStream log(m_msgSvc, "LArOnlineID_Base" ); // Get the hash caculator for the febs const HashCalcFeb& hc = m_feb_hash_calcs[m_bec_ft_impl.unpack(febId)]; // Two cases: @@ -1561,7 +1558,11 @@ IdentifierHash LArOnlineID_Base::feb_Hash (HWIdentifier febId) const for (int i = 0; (unsigned int)i < hc.m_slot_values.size(); ++i) { if (slotValue == hc.m_slot_values[i]) return (hc.m_hash + i); } - std::cout << "LArOnlineID_Base::feb_Hash - ***** ERROR: could not match slot value for has calculation " << std::endl; + if(m_msgSvc) { + log << MSG::WARNING << "LArOnlineID_Base::feb_Hash - ***** WARNING: could not match slot value for has calculation " << endmsg; + } else { + std::cout << "LArOnlineID_Base::feb_Hash - ***** WARNING: could not match slot value for has calculation " << std::endl; + } } size_type slotIndex = m_slot_impl.unpackToIndex(febId); return (hc.m_hash + slotIndex); @@ -2040,10 +2041,10 @@ int LArOnlineID_Base::is_slar(const HWIdentifier id)const int LArOnlineID_Base::init_calib_hashes(void) /*========================================*/ { + MsgStream log(m_msgSvc, "LArOnlineID_Base" ); unsigned int nids=0; std::set ids; - for (unsigned int i = 0; i < m_full_calib_laronline_range.size(); ++i) - { + for (unsigned int i = 0; i < m_full_calib_laronline_range.size(); ++i) { const Range& range = m_full_calib_laronline_range[i]; Range::const_identifier_factory first = range.factory_begin(); Range::const_identifier_factory last = range.factory_end(); @@ -2054,33 +2055,36 @@ int LArOnlineID_Base::init_calib_hashes(void) exp_id[m_feedthrough_index], exp_id[m_slot_index], exp_id[m_channel_in_slot_index]); - if(!(ids.insert(id)).second) - { + if(!(ids.insert(id)).second) { + if(m_msgSvc) { + log << MSG::WARNING << " LArOnlineID_Base::init_calib_Hashes " + << " Error: duplicated id for channel id. nids= " << nids + << " compact Id " << std::string(*first) << " " << show_to_string(id) << endmsg; + } else { std::cout << " LArOnlineID_Base::init_calib_Hashes " << " Error: duplicated id for channel id. nids= " << nids << " compact Id " ; (*first).show(); std::cout << " " << show_to_string(id) << std::endl; } + } nids++; } - } + } unsigned int nidtb=0; std::set::const_iterator first = ids.begin(); std::set::const_iterator last = ids.end(); - for (;first != last && nidtb < nids; ++first) - { + for (;first != last && nidtb < nids; ++first) { m_calib_channel_vec.push_back(*first); nidtb++; - } + } m_calibChannelHashMax = m_calib_channel_vec.size(); /* FEB hash */ /*==========*/ nids = 0; ids.clear(); - for (unsigned int i = 0; i < m_full_calib_module_range.size(); ++i) - { + for (unsigned int i = 0; i < m_full_calib_module_range.size(); ++i) { const Range& range = m_full_calib_module_range[i]; Range::const_identifier_factory first = range.factory_begin(); Range::const_identifier_factory last = range.factory_end(); @@ -2091,16 +2095,23 @@ int LArOnlineID_Base::init_calib_hashes(void) exp_id[m_feedthrough_index], exp_id[m_slot_index] ); if(!(ids.insert(febId)).second){ - std::cout << " LArOnlineID_Base::init_calibhashes " + if(m_msgSvc) { + log << MSG::WARNING << " LArOnlineID_Base::init_calibhashes " + << " Warning: duplicated id for feb id. nids= " << nids + << " compact Id " << std::string(*first) << " " << show_to_string(febId) << endmsg; + } else { + std::cout << " LArOnlineID_Base::init_calibhashes " << " Error: duplicated id for feb id. nids= " << nids << " compact Id " ; - (*first).show(); - std::cout << " " << show_to_string(febId) << std::endl; - std::cout << std::endl; + (*first).show(); + std::cout << " " << show_to_string(febId) << std::endl; + std::cout << std::endl; + + } } nids++; } - } + } nidtb=0; first = ids.begin(); last = ids.end(); diff --git a/LArCalorimeter/LArIdentifier/src/LArOnline_SuperCellID.cxx b/LArCalorimeter/LArIdentifier/src/LArOnline_SuperCellID.cxx index f816a4337cc..b68f8746f98 100755 --- a/LArCalorimeter/LArIdentifier/src/LArOnline_SuperCellID.cxx +++ b/LArCalorimeter/LArIdentifier/src/LArOnline_SuperCellID.cxx @@ -41,11 +41,11 @@ int LArOnline_SuperCellID::initialize_from_dictionary (const IdDictMgr& dict_mg // Check whether this helper should be reinitialized if (!reinitialize(dict_mgr)) { - if(m_msgSvc)log << MSG::DEBUG << "Request to reinitialize not satisfied - tags have not changed" << endmsg; + if(m_msgSvc) log << MSG::DEBUG << "Request to reinitialize not satisfied - tags have not changed" << endmsg; return (0); } else { - log << MSG::DEBUG << "(Re)initialize" << endmsg; + if(m_msgSvc) log << MSG::DEBUG << "(Re)initialize" << endmsg; } // init base object @@ -73,7 +73,11 @@ int LArOnline_SuperCellID::initialize_from_dictionary (const IdDictMgr& dict_mg std::string group_name("LArOnline_SuperCell"); if(LArOnlineID_Base::initLevelsFromDict(group_name)) return (1); - std::cout << "Finished initLevelsFromDict" << std::endl; + if(m_msgSvc) { + log << MSG::INFO << "Finished initLevelsFromDict" << endmsg; + } else { + std::cout << "Finished initLevelsFromDict" << std::endl; + } /* Find value for the field LAr Calorimeter */ @@ -221,11 +225,6 @@ int LArOnline_SuperCellID::initialize_from_dictionary (const IdDictMgr& dict_mg std::cout << strg1 << std::endl; std::cout << strg2 << std::endl; } - //std::cout << "min > " << size << " " - // << i << " " - // << show_to_string(min) << " " - // << m_pnz_reg_impl.unpack(min) << " " - // << std::endl; } } @@ -296,7 +295,11 @@ int LArOnline_SuperCellID::initialize_from_dictionary (const IdDictMgr& dict_mg // For each feedthrough we save the possible slot values for // the hash calculation. if (get_expanded_id(min, ftExpId, &ftContext)) { - std::cout << " ***** Error cannot get ft expanded id for " << show_to_string(min) << std::endl; + if(m_msgSvc) { + log << MSG::WARNING << " ***** Warning cannot get ft expanded id for " << show_to_string(min) << endmsg; + } else { + std::cout << " ***** Warning cannot get ft expanded id for " << show_to_string(min) << std::endl; + } } // If there is more than a single range found for this @@ -330,27 +333,6 @@ int LArOnline_SuperCellID::initialize_from_dictionary (const IdDictMgr& dict_mg } } - // for (unsigned int i = 0; i < m_full_feb_range.size(); ++i) { - // if (m_full_feb_range[i].match(ftExpId)) { - // nrangesFound += 1; - // const Range::field& slotField = m_full_feb_range[i][m_slot_index]; - // // if (slotField.get_mode() == Range::field::enumerated) { - // // // save values - // // hc.m_slot_values = slotField.get_values(); - // // } - // if (slotField.get_mode() == Range::field::both_bounded || - // slotField.get_mode() == Range::field::enumerated) { - // // save values - // unsigned int nvalues = slotField.get_indices(); - // hc.m_slot_values.reserve(hc.m_slot_values.size() + nvalues); - // for (unsigned int j = 0; j < nvalues; ++j) { - // hc.m_slot_values.push_back(slotField.get_value_at(j)); - // } - // } - // } - // } - - // Set hash calculator m_feb_hash_calcs[m_bec_ft_impl.unpack(min)] = hc; @@ -368,11 +350,6 @@ int LArOnline_SuperCellID::initialize_from_dictionary (const IdDictMgr& dict_mg else { std::cout << strg << std::endl; } - //std::cout << "min > " << size << " " - // << i << " " - // << show_to_string(min) << " " - // << m_pnz_reg_impl.unpack(min) << " " - // << std::endl; } } -- GitLab