diff --git a/InnerDetector/InDetDetDescr/InDetIdentifier/InDetIdentifier/SCT_ID.h b/InnerDetector/InDetDetDescr/InDetIdentifier/InDetIdentifier/SCT_ID.h index b56ad7508c2e4b2fb26e9fbf754eedc55e4c01da..63921eedceb8cede50e33e80ee2f84866b52d8a1 100755 --- a/InnerDetector/InDetDetDescr/InDetIdentifier/InDetIdentifier/SCT_ID.h +++ b/InnerDetector/InDetDetDescr/InDetIdentifier/InDetIdentifier/SCT_ID.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef INDETIDENTIFIER_SCT_ID_H @@ -17,7 +17,6 @@ * $Id: SCT_ID.h,v 1.30 2008-12-13 07:11:00 dquarrie Exp $ */ -//<<<<<< INCLUDES >>>>>> #include "AtlasDetDescr/AtlasDetectorID.h" #include "Identifier/Identifier.h" @@ -28,18 +27,12 @@ #include "AthenaKernel/CLASS_DEF.h" #include <string> -#include <assert.h> +#include <cassert> #include <algorithm> -//<<<<<< PUBLIC DEFINES >>>>>> -//<<<<<< PUBLIC CONSTANTS >>>>>> -//<<<<<< PUBLIC TYPES >>>>>> class IdDictDictionary; -//<<<<<< PUBLIC VARIABLES >>>>>> -//<<<<<< PUBLIC FUNCTIONS >>>>>> -//<<<<<< CLASS DECLARATIONS >>>>>> /** ** @class SCT_ID @@ -81,7 +74,7 @@ public: typedef MultiRange::const_identifier_factory const_expanded_id_iterator; //@} - /// @name strutors + /// @name structors //@{ SCT_ID(void); virtual ~SCT_ID(void) = default; @@ -120,7 +113,7 @@ public: Identifier wafer_id ( const Identifier& strip_id ) const; /// From hash - optimized - Identifier wafer_id ( IdentifierHash wafer_hash ) const; + Identifier wafer_id ( const IdentifierHash & wafer_hash ) const; /// For an individual strip Identifier strip_id ( int barrel_ec, @@ -186,7 +179,7 @@ public: /// @name Optimized accessors - ASSUMES id IS a sct id, i.e. NOT pixel or other //@{ /// wafer hash from id - optimized - IdentifierHash wafer_hash (Identifier wafer_id) const; + IdentifierHash wafer_hash (const Identifier & wafer_id) const; /// Test for barrel - WARNING: id MUST be sct id, otherwise answer is not accurate. Use SiliconID for generic test. bool is_barrel (const Identifier& id) const; @@ -314,6 +307,9 @@ private: int init_hashes(void); int init_neighbors(void); + + IdentifierHash + nextInSequence(const IdentifierHash& id,const hash_vec & vectorOfHashes) const; // Temporary method for adapting an identifier for the MultiRange // check - MR is missing the InnerDetector level @@ -356,12 +352,6 @@ private: }; -//<<<<<< INLINE PUBLIC FUNCTIONS >>>>>> - -///////////////////////////////////////////////////////////////////////////// -//<<<<<< INLINE MEMBER FUNCTIONS >>>>>> -///////////////////////////////////////////////////////////////////////////// - //using the macros 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(SCT_ID, 2517, 1) @@ -468,13 +458,15 @@ SCT_ID::wafer_id ( const Identifier& strip_id ) const } //---------------------------------------------------------------------------- -inline Identifier SCT_ID::wafer_id ( IdentifierHash wafer_hash ) const +inline Identifier +SCT_ID::wafer_id ( const IdentifierHash & wafer_hash ) const { return (m_wafer_vec[wafer_hash]); } //---------------------------------------------------------------------------- -inline IdentifierHash SCT_ID::wafer_hash (Identifier wafer_id) const +inline IdentifierHash +SCT_ID::wafer_hash (const Identifier & wafer_id) const { id_vec_it it = std::lower_bound(m_wafer_vec.begin(), m_wafer_vec.end(), @@ -820,5 +812,16 @@ SCT_ID::strip (const Identifier& id) const return (m_strip_impl.unpack(id)); } +inline IdentifierHash +SCT_ID::nextInSequence(const IdentifierHash& id, const hash_vec & vectorOfHashes) const{ + unsigned short index = id; + if (index < vectorOfHashes.size()) { + return vectorOfHashes[index]; + } + return NOT_VALID_HASH; +} + + + #endif // INDETIDENTIFIER_SCT_ID_H diff --git a/InnerDetector/InDetDetDescr/InDetIdentifier/src/SCT_ID.cxx b/InnerDetector/InDetDetDescr/InDetIdentifier/src/SCT_ID.cxx index 521ac2909e062c9b11a0e4b2760c436f43eed786..ef0c6486989963bb8cc7a8b0cd94b07d94ab1f9f 100755 --- a/InnerDetector/InDetDetDescr/InDetIdentifier/src/SCT_ID.cxx +++ b/InnerDetector/InDetDetDescr/InDetIdentifier/src/SCT_ID.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ /*************************************************************************** @@ -7,10 +7,7 @@ ------------------------------------------- ***************************************************************************/ -//<doc><file> $Id: SCT_ID.cxx,v 1.43.2.1 2009-03-26 21:54:31 jtseng Exp $ -//<version> $Name: not supported by cvs2svn $ -//<<<<<< INCLUDES >>>>>> #include "GaudiKernel/MsgStream.h" #include "InDetIdentifier/SCT_ID.h" @@ -20,21 +17,8 @@ #include <algorithm> #include <iostream> -//<<<<<< PRIVATE DEFINES >>>>>> -//<<<<<< PRIVATE CONSTANTS >>>>>> -//<<<<<< PRIVATE TYPES >>>>>> -//<<<<<< PRIVATE VARIABLE DEFINITIONS >>>>>> -//<<<<<< PUBLIC VARIABLE DEFINITIONS >>>>>> -//<<<<<< CLASS STRUCTURE INITIALIZATION >>>>>> -//<<<<<< PRIVATE FUNCTION DEFINITIONS >>>>>> -//<<<<<< PUBLIC FUNCTION DEFINITIONS >>>>>> -//<<<<<< MEMBER FUNCTION DEFINITIONS >>>>>> -///////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////// - SCT_ID::SCT_ID(void) : @@ -453,49 +437,45 @@ SCT_ID::init_hashes(void) int SCT_ID::get_prev_in_phi(const IdentifierHash& id, IdentifierHash& prev) const { - unsigned short index = id; - if (index < m_prev_phi_wafer_vec.size()) { - if (m_prev_phi_wafer_vec[index] == NOT_VALID_HASH) return (1); - prev = m_prev_phi_wafer_vec[index]; - return (0); + const auto result = nextInSequence(id,m_prev_phi_wafer_vec); + if (result != NOT_VALID_HASH){ + prev=result; + return 0; } - return (1); + return 1; } int SCT_ID::get_next_in_phi(const IdentifierHash& id, IdentifierHash& next) const { - unsigned short index = id; - if (index < m_next_phi_wafer_vec.size()) { - if (m_next_phi_wafer_vec[index] == NOT_VALID_HASH) return (1); - next = m_next_phi_wafer_vec[index]; - return (0); + const auto result = nextInSequence(id,m_next_phi_wafer_vec); + if (result != NOT_VALID_HASH){ + next=result; + return 0; } - return (1); + return 1; } int SCT_ID::get_prev_in_eta(const IdentifierHash& id, IdentifierHash& prev) const { - unsigned short index = id; - if (index < m_prev_eta_wafer_vec.size()) { - if (m_prev_eta_wafer_vec[index] == NOT_VALID_HASH) return (1); - prev = m_prev_eta_wafer_vec[index]; - return (0); + const auto result = nextInSequence(id,m_prev_eta_wafer_vec); + if (result != NOT_VALID_HASH){ + prev=result; + return 0; } - return (1); + return 1; } int SCT_ID::get_next_in_eta(const IdentifierHash& id, IdentifierHash& next) const { - unsigned short index = id; - if (index < m_next_eta_wafer_vec.size()) { - if (m_next_eta_wafer_vec[index] == NOT_VALID_HASH) return (1); - next = m_next_eta_wafer_vec[index]; - return (0); + const auto result = nextInSequence(id,m_next_eta_wafer_vec); + if (result != NOT_VALID_HASH){ + next=result; + return 0; } - return (1); + return 1; } int @@ -642,21 +622,6 @@ SCT_ID::init_neighbors(void) } m_next_eta_wafer_vec[index] = hash_id; } - - -// std::cout << " SCT_ID::init_neighbors " -// << " phi, previous, next " << id[m_PHI_MODULE_INDEX] -// << " " << pphi -// << " " << previous_phi -// << " " << nphi -// << " " << next_phi -// << " eta, previous, next " << id[m_ETA_MODULE_INDEX] -// << " " << peta -// << " " << previous_eta -// << " " << neta -// << " " << next_eta -// << " id " << (std::string)(*first) -// << std::endl; } } return (0); @@ -764,13 +729,7 @@ SCT_ID::initLevelsFromDict() m_ROW_INDEX = field->m_index; m_hasRows = true ; } - - else { - - //log << MSG::ERROR << "SCT_ID::initLevelsFromDict - unable to find 'row' field " << endmsg; - //return (1); - } - + field = m_dict->find_field("strip"); if (field) { @@ -825,16 +784,6 @@ SCT_ID::initLevelsFromDict() } std::cout << " DEBUG strip " << m_strip_impl.show_to_string() << std::endl; } - -// std::cout << "SCT_ID::initLevelsFromDict - found levels " << std::endl; -// std::cout << "subdet " << m_INDET_INDEX << std::endl; -// std::cout << "part " << m_SCT_INDEX << std::endl; -// std::cout << "barrel_endcap " << m_BARREL_EC_INDEX << std::endl; -// std::cout << "layer or disk " << m_LAYER_DISK_INDEX << std::endl; -// std::cout << "phi_module " << m_PHI_MODULE_INDEX << std::endl; -// std::cout << "eta_module " << m_ETA_MODULE_INDEX << std::endl; -// std::cout << "side " << m_SIDE_INDEX << std::endl; -// std::cout << "strip " << m_STRIP_INDEX << std::endl; std::cout << "indet " << m_indet_impl.decode_index() << " " << (std::string)m_indet_impl.ored_field() << " "