From 20a555767ec9c3100b77be2f80b5269acf9795da Mon Sep 17 00:00:00 2001 From: Dave Casper <dcasper@uci.edu> Date: Mon, 29 Jul 2019 16:02:03 -0700 Subject: [PATCH] Start clean-up/commissioning of Identifiers --- .../DetDescrCnvSvc/src/DetDescrCnvSvc.cxx | 3 +- .../FaserDetDescr/CMakeLists.txt | 2 +- .../FaserDetDescr/FaserDetDescrDict.h | 3 +- .../FaserDetDescr/FaserDetectorID.h | 714 ++++----- .../FaserDetDescr/FaserDetectorID.hOld | 453 ++++++ .../FaserDetDescr/FaserDetectorIDBase.h | 470 ------ .../FaserDetDescr/FaserDetDescr/selection.xml | 3 +- .../FaserDetDescr/src/FaserDetectorID.cxx | 1315 +++++++++++++---- .../FaserDetDescr/src/FaserDetectorID.cxxOld | 363 +++++ .../FaserDetDescr/src/FaserDetectorIDBase.cxx | 1134 -------------- .../src/FaserDetectorIDHelper.cxx | 4 +- .../FaserDetectorManager.h | 4 +- .../src/FaserDetectorManager.cxx | 2 +- .../src/FaserIDDetDescrCnv.cxx | 12 +- .../ScintGeoModel/VetoDetectorTool.h | 4 +- .../ScintGeoModel/src/VetoDetectorTool.cxx | 4 +- 16 files changed, 2243 insertions(+), 2247 deletions(-) create mode 100644 DetectorDescription/FaserDetDescr/FaserDetDescr/FaserDetectorID.hOld delete mode 100644 DetectorDescription/FaserDetDescr/FaserDetDescr/FaserDetectorIDBase.h create mode 100644 DetectorDescription/FaserDetDescr/src/FaserDetectorID.cxxOld delete mode 100644 DetectorDescription/FaserDetDescr/src/FaserDetectorIDBase.cxx diff --git a/DetectorDescription/DetDescrCnvSvc/src/DetDescrCnvSvc.cxx b/DetectorDescription/DetDescrCnvSvc/src/DetDescrCnvSvc.cxx index c54cf388c..3d37d16d2 100644 --- a/DetectorDescription/DetDescrCnvSvc/src/DetDescrCnvSvc.cxx +++ b/DetectorDescription/DetDescrCnvSvc/src/DetDescrCnvSvc.cxx @@ -114,8 +114,7 @@ DetDescrCnvSvc::initialize() { if (status != StatusCode::SUCCESS) return status; // IdHelpers - // status = addToDetStore(125694213, "FaserID"); - status = addToDetStore(168050226, "FaserID"); + status = addToDetStore(125694213, "FaserID"); if (status != StatusCode::SUCCESS) return status; // status = addToDetStore(2516, "ScintID"); // if (status != StatusCode::SUCCESS) return status; diff --git a/DetectorDescription/FaserDetDescr/CMakeLists.txt b/DetectorDescription/FaserDetDescr/CMakeLists.txt index 3d2b5e8da..c8572d145 100644 --- a/DetectorDescription/FaserDetDescr/CMakeLists.txt +++ b/DetectorDescription/FaserDetDescr/CMakeLists.txt @@ -18,7 +18,7 @@ find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread ) # Component(s) in the package: atlas_add_library( FaserDetDescr - src/FaserDetectorIDBase.cxx + src/FaserDetectorID.cxx src/FaserDetectorIDHelper.cxx src/FaserRegionHelper.cxx PUBLIC_HEADERS FaserDetDescr diff --git a/DetectorDescription/FaserDetDescr/FaserDetDescr/FaserDetDescrDict.h b/DetectorDescription/FaserDetDescr/FaserDetDescr/FaserDetDescrDict.h index ac9179a17..8ab1b01b7 100644 --- a/DetectorDescription/FaserDetDescr/FaserDetDescr/FaserDetDescrDict.h +++ b/DetectorDescription/FaserDetDescr/FaserDetDescr/FaserDetDescrDict.h @@ -10,8 +10,7 @@ #define FASERDETDESCR_FASERDETDESCRDICT_H 1 #include "FaserDetDescr/FaserRegion.h" -#include "FaserDetDescr/FaserDetectorIDBase.h" -// #include "FaserDetDescr/FaserDetectorID.h" +#include "FaserDetDescr/FaserDetectorID.h" namespace FaserDetDescr { // Athena namespace autoloading trigger for ROOT6 diff --git a/DetectorDescription/FaserDetDescr/FaserDetDescr/FaserDetectorID.h b/DetectorDescription/FaserDetDescr/FaserDetDescr/FaserDetectorID.h index 7cfac9bdd..b17d61f72 100644 --- a/DetectorDescription/FaserDetDescr/FaserDetDescr/FaserDetectorID.h +++ b/DetectorDescription/FaserDetDescr/FaserDetDescr/FaserDetectorID.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ #ifndef FASERDETDESCR_FASERDETECTORID_H @@ -7,202 +7,99 @@ /** * @file FaserDetectorID.h * - * @brief This is an Identifier helper class for the all - * subdetectors. This class is a factory for creating compact - * Identifier objects and IdentifierHash or hash ids. And it also - * allows decoding of these ids. + * @brief This class provides an interface to generate or decode an + * identifier for the upper levels of the detector element + * hierarchy, i.e. Faser, the detector systems and detector + * subsystems. As well general "print out" methods are provide for + * all detector systems. All id helper classes derive from this + * class. This class also provides access to the version tags of the + * id dictionaries used by the helper. * + * @author RD Schaffer <R.D.Schaffer@cern.ch> + * + * Modified for FASER */ //<<<<<< INCLUDES >>>>>> -#include "FaserDetDescr/FaserDetectorIDBase.h" #include "Identifier/Identifier.h" -#include "Identifier/IdentifierHash.h" -#include "Identifier/Range.h" +#include "Identifier/IdContext.h" #include "Identifier/IdHelper.h" +#include "Identifier/Range.h" #include "IdDict/IdDictFieldImplementation.h" +#include "FaserDetTechnology.h" #include "AthenaKernel/CLASS_DEF.h" - #include <string> -#include <assert.h> -#include <algorithm> +#include <vector> -//<<<<<< PUBLIC DEFINES >>>>>> -//<<<<<< PUBLIC CONSTANTS >>>>>> //<<<<<< PUBLIC TYPES >>>>>> class IdDictDictionary; +class FaserDetectorIDHelper; -//<<<<<< PUBLIC VARIABLES >>>>>> -//<<<<<< PUBLIC FUNCTIONS >>>>>> //<<<<<< CLASS DECLARATIONS >>>>>> + /** - ** @class FaserDetectorID - ** - ** @brief This is an Identifier helper class for the FASER - ** subdetectors. This class is a factory for creating compact - ** Identifier objects and IdentifierHash or hash ids. And it also - ** allows decoding of these ids. - ** - ** Definition and the range of values for the levels of the - ** identifier are: - ** - ** @verbatim - ** element range meaning - ** ------- ----- ------- - ** - ** station - ** veto 0 - 1 front/back - ** trigger 0 single station - ** preshower 0 single station - ** sct 0 - 2 front, middle, back - ** ecal 0 single station - ** plane - ** veto 0 single plane - ** trigger 0 single plane - ** preshower 0 single plane - ** sct 0 - 2 three planes per station - ** ecal 0 single plane - ** module - ** veto 0 single plate - ** trigger 0 - 1 upper/lower plate - ** preshower 0 single plate - ** sct 0 - 7 eight modules per plane - ** ecal 0 - 3 four modules - ** submodule - ** veto 0 no segmentation - ** trigger 0 no segmentation - ** preshower 0 no segmentation - ** sct 0 - 1 two sides per module - ** ecal 0 - 66 scintillator layers - ** sensor - ** veto 0 single pmt - ** trigger 0 - 1 left/right pmt - ** preshower 0 single pmt - ** sct 0 - 767 strips - ** ecal 0 one tower per layer - ** @endverbatim - ** - */ -class FaserDetectorID : public FaserDetectorIDBase + * @class FaserDetectorID + * + * @brief This class provides an interface to generate or decode an + * identifier for the upper levels of the detector element + * hierarchy, i.e. Faser, the detector systems and detector + * subsystems. As well general "print out" methods are provide for + * all detector systems. All id helper classes derive from this + * class. This class also provides access to the version tags of the + * id dictionaries used by the helper. + **/ + +class FaserDetectorID : public IdHelper { public: - - /// @name public typedefs - //@{ - typedef Identifier::size_type size_type; - typedef std::vector<Identifier>::const_iterator const_id_iterator; - typedef MultiRange::const_identifier_factory const_expanded_id_iterator; - //@} - + /// @name strutors //@{ - FaserDetectorID(void); - virtual ~FaserDetectorID(void) = default; + FaserDetectorID(); + FaserDetectorID(const FaserDetectorID& other); + ~FaserDetectorID(void); + FaserDetectorID& operator= (const FaserDetectorID& other); //@} - - /// @name Creators for station, ids and pmt ids + + /// @name Detector system ids //@{ - /// For a single module - virtual Identifier module_id( int station, - int plane, - int module ) const = 0; - - /// For a module from a submodule id - Identifier module_id ( const Identifier& submodule_id ) const; - - /// For a single submodule - virtual Identifier submodule_id ( int station, - int plane, - int module, - int submodule ) const = 0; - - /// For a single submodule from a sensor id - Identifier submodule_id ( const Identifier& sensor_id ) const; - - /// From hash - optimized - Identifier submodule_id( IdentifierHash submodule_hash) const; - - /// For an individual sensor - virtual Identifier sensor_id ( int station, - int plane, - int module, - int submodule, - int sensor ) const = 0; - - - Identifier sensor_id ( const Identifier& submodule_id, - int sensor ) const; - + /// Detector systems: + Identifier scint (void) const; + Identifier tracker (void) const; + Identifier calo (void) const; //@} - /// @name Hash table maximum sizes + /// @name Scintillator subsystem ids //@{ - size_type submodule_hash_max (void) const; - size_type sensor_hash_max (void) const; + Identifier veto (void) const; + Identifier trigger (void) const; + Identifier preshower (void) const; //@} - /// @name Access to all ids + /// @name Tracker subsystem ids //@{ - /// Iterators over full set of ids. Submodule iterator is sorted - const_id_iterator submodule_begin (void) const; - const_id_iterator submodule_end (void) const; - /// For sensor ids, only expanded id iterators are available. Use - /// following "sensor_id" method to obtain a compact identifier - const_expanded_id_iterator sensor_begin (void) const; - const_expanded_id_iterator sensor_end (void) const; + Identifier sct (void) const; //@} + /// @name Calorimeter subsystem ids + //@{ + Identifier ecal (void) const; + //@} - /// submodule hash from id - optimized - IdentifierHash submodule_hash (Identifier submodule_id) const; - - - /// Values of different levels (failure returns 0) - int station (const Identifier& id) const; - int plane (const Identifier& id) const; - int module (const Identifier& id) const; - int submodule (const Identifier& id) const; - int sensor (const Identifier& id) const; + /// @name Contexts to provide id length - e.g. for use in generic decoding + //@{ + /// IdContext (indicates id length) for detector systems + IdContext detsystem_context (void) const; - // /// Max values for each field (-999 == failure) - int station_max (const Identifier& id) const; - int plane_max (const Identifier& id) const; - int module_max (const Identifier& id) const; - int submodule_max (const Identifier& id) const; - int sensor_max (const Identifier& id) const; + /// IdContext (indicates id length) for sub-detector + IdContext subdet_context (void) const; //@} - // /// @name module eta/phi navigation - // //@{ - // /// Previous wafer hash in phi (return == 0 for neighbor found) - // int get_prev_in_phi (const IdentifierHash& id, IdentifierHash& prev) const; - // /// Next wafer hash in phi (return == 0 for neighbor found) - // int get_next_in_phi (const IdentifierHash& id, IdentifierHash& next) const; - // /// Previous wafer hash in eta (return == 0 for neighbor found) - // int get_prev_in_eta (const IdentifierHash& id, IdentifierHash& prev) const; - // /// Next wafer hash in eta (return == 0 for neighbor found) - // int get_next_in_eta (const IdentifierHash& id, IdentifierHash& next) const; - // /// Wafer hash on other side - // int get_other_side (const IdentifierHash& id, IdentifierHash& other) const; - - // // To check for when phi wrap around may be needed, use - // bool is_phi_module_max(const Identifier& id) const; - // /// For the barrel - // bool is_eta_module_min(const Identifier& id) const; - // /// For the barrel - // bool is_eta_module_max(const Identifier& id) const; - // //@} - - // /// @name contexts to distinguish wafer id from pixel id - // //@{ - // IdContext wafer_context (void) const; - // IdContext strip_context (void) const; - // //@} - - /// @name methods from abstract interface - slower than opt version + + /// @name Generic conversion between identifier and idhash //@{ /// Create compact id from hash id (return == 0 for OK) virtual int get_id (const IdentifierHash& hash_id, @@ -215,239 +112,358 @@ public: const IdContext* context = 0) const; //@} - /// Return the lowest bit position used in the channel id - int base_bit (void) const; + /// @name Initialization and version name + //@{ + /// Initialization from the identifier dictionary + virtual int initialize_from_dictionary(const IdDictMgr& dict_mgr); - // /// Calculate a channel offset between the two identifiers. - // Identifier::diff_type calc_offset(const Identifier& base, - // const Identifier& target) const; + // retrieve version of the dictionary + virtual std::string dictionaryVersion (void) const; + //@} - // /// Create an identifier with a given base and channel offset - // Identifier strip_id_offset(const Identifier& base, - // Identifier::diff_type offset) const; - /// @name interaction with id dictionary + /// @name Generic printing of identifiers //@{ - /// Create sensor Identifier from expanded id, which is returned by the - /// id_iterators - Identifier sensor_id (const ExpandedIdentifier& sensor_id) const; - - /// Create expanded id from compact id (return == 0 for OK) - void get_expanded_id (const Identifier& id, - ExpandedIdentifier& exp_id, + /// Short print out of any identifier (optionally provide + /// separation character - default is '.'): + void show (Identifier id, + const IdContext* context = 0, + char sep = '.' ) const; + /// or provide the printout in string form + std::string show_to_string (Identifier id, + const IdContext* context = 0, + char sep = '.' ) const; + + /// Expanded print out of any identifier + void print (Identifier id, + const IdContext* context = 0) const; + /// or provide the printout in string form + std::string print_to_string (Identifier id, const IdContext* context = 0) const; + //@} + + /// @name Test of an Identifier to see if it belongs to a particular detector (sub)system: + //@{ + bool is_scint (Identifier id) const; + bool is_tracker (Identifier id) const; + bool is_calo (Identifier id) const; + bool is_veto (Identifier id) const; + bool is_trigger (Identifier id) const; + bool is_preshower (Identifier id) const; + bool is_sct (Identifier id) const; + bool is_ecal (Identifier id) const; + //@} - /// Initialization from the identifier dictionary - virtual int initialize_from_dictionary(const IdDictMgr& dict_mgr); + /// @name Test of an Identifier to see if it belongs to a particular detector (sub)system (using expanded ids): + //@{ + bool is_scint (const ExpandedIdentifier& id) const; + bool is_tracker (const ExpandedIdentifier& id) const; + bool is_calo (const ExpandedIdentifier& id) const; + bool is_veto (const ExpandedIdentifier& id) const; + bool is_trigger (const ExpandedIdentifier& id) const; + bool is_preshower (const ExpandedIdentifier& id) const; + bool is_sct (const ExpandedIdentifier& id) const; + bool is_ecal (const ExpandedIdentifier& id) const; + //@} + + /// @name Dictionary versioning: provide access to dictionary names and versions. Note that a helper may correspond to one or more id dictionary + //@{ + /// Dictionary names + std::vector<std::string> dict_names(void) const; + /// File names for subdet dictionaries + std::vector<std::string> file_names(void) const; + /// Version tags for subdet dictionaries + std::vector<std::string> dict_tags (void) const; + //@} + + /// @name Checks are performed by default in debug compilation and NOT in optimized compilation. One can switch or query this mode for any idHelper with the following methods: + //@{ + virtual bool do_checks (void) const; + virtual void set_do_checks (bool do_checks); + //@} + + /// @name neighbours are initialized by default. One can switch or query this mode with the following methods: + //@{ + virtual bool do_neighbours (void) const; + virtual void set_do_neighbours (bool do_neighbours); + //@} + + /// @name setting pointer to the MessageService + //@{ + virtual void setMessageSvc (IMessageSvc* msgSvc); + //@} + + /// Set flag for suppressing informational output. + void set_quiet (bool quiet); + + +protected: + + friend class FaserDetectorIDHelper; + + void setDictVersion (const IdDictMgr& dict_mgr, const std::string& name); + + std::string to_range (const ExpandedIdentifier& id) const; + + std::string fix_barrel_ec (const std::string& barrel_ec) const; + + /// Detector systems: + ExpandedIdentifier scint_exp (void) const; + ExpandedIdentifier tracker_exp (void) const; + ExpandedIdentifier calo_exp (void) const; + + /// Scintillator: + ExpandedIdentifier veto_exp (void) const; + ExpandedIdentifier trigger_exp (void) const; + ExpandedIdentifier preshower_exp (void) const; + + /// Tracker: + ExpandedIdentifier sct_exp (void) const; + + /// Calorimeter: + ExpandedIdentifier ecal_exp (void) const; + + /// Provide efficient access to individual field values, for + /// subclass idhelpers + int scint_field_value () const; + int tracker_field_value () const; + int calo_field_value () const; + int veto_field_value () const; + int trigger_field_value () const; + int preshower_field_value () const; + int sct_field_value () const; + int ecal_field_value () const; + + /// Register the file and tag names for a particular IdDict + /// dictionary + int register_dict_tag (const IdDictMgr& dict_mgr, + const std::string& dict_name); + + /// Test whether an idhelper should be reinitialized based on the + /// change of tags + bool reinitialize (const IdDictMgr& dict_mgr); + + /// Flag for subclasses to know whether or not to perform + /// checks. In general, this is set to false in optimized mode. + mutable bool m_do_checks; + /// Flag for subclasses to know whether or not to perform + /// neighbour initialization + mutable bool m_do_neighbours; + + /// pointer to the message service + IMessageSvc* m_msgSvc; + + /// If true, suppress DEBUG/INFO messages. + bool m_quiet; + + + /// List of dictionary names used by this helper + std::vector<std::string> m_dict_names; + + /// List of dictionary file names used by this helper + std::vector<std::string> m_file_names; + + /// List of dictionary versions used by this helper + std::vector<std::string> m_dict_tags; private: - typedef std::vector<Identifier> id_vec; - typedef id_vec::const_iterator id_vec_it; - typedef std::vector<unsigned short> hash_vec; - typedef hash_vec::const_iterator hash_vec_it; - - void submodule_id_checks ( int station, - int plane, - int module, - int submodule ) const; - - void sensor_id_checks ( int station, - int plane, - int module, - int submodule, - int sensor) const; - - int initLevelsFromDict(void); - - int init_hashes(void); - - int init_neighbors(void); - - size_type m_faser_region_index; - size_type m_SUBDET_INDEX; - size_type m_PART_INDEX; - size_type m_STATION_INDEX; - size_type m_PLANE_INDEX; - size_type m_MODULE_INDEX; - size_type m_SUBMODULE_INDEX; - size_type m_SENSOR_INDEX; - - const IdDictDictionary* m_dict; - MultiRange m_full_submodule_range; - MultiRange m_full_sensor_range; - size_type m_submodule_hash_max; - size_type m_sensor_hash_max; - id_vec m_submodule_vec; - // hash_vec m_prev_phi_wafer_vec; - // hash_vec m_next_phi_wafer_vec; - // hash_vec m_prev_eta_wafer_vec; - // hash_vec m_next_eta_wafer_vec; - - IdDictFieldImplementation m_subdet_impl ; - IdDictFieldImplementation m_part_impl ; - IdDictFieldImplementation m_station_impl ; - IdDictFieldImplementation m_plane_impl ; - IdDictFieldImplementation m_module_impl ; - IdDictFieldImplementation m_submodule_impl; - IdDictFieldImplementation m_sensor_impl ; -}; + typedef Identifier::size_type size_type; + // Identifiear numbering: + enum ID { + FASER_ID = static_cast<Identifier::value_type>(0), + MAX_BIT = Identifier::MAX_BIT, + ALL_BITS = Identifier::ALL_BITS }; + + int initLevelsFromDict(const IdDictMgr& dict_mgr); + + // dictionary version + std::string m_dict_version; + bool m_is_initialized_from_dict; + size_type m_DET_INDEX; + size_type m_SUBDET_INDEX; + int m_SCINT_ID; + int m_TRACKER_ID; + int m_CALO_ID; + int m_VETO_ID; + int m_TRIGGER_ID; + int m_PRESHOWER_ID; + int m_SCT_ID; + int m_ECAL_ID; + + /// Flag for slhc layout: + bool m_isSLHC; + + IdDictDictionary* m_faser_dict; + IdDictDictionary* m_scint_dict; + IdDictDictionary* m_tracker_dict; + IdDictDictionary* m_calo_dict; + FaserDetectorIDHelper* m_helper; + IdDictFieldImplementation m_det_impl; + IdDictFieldImplementation m_scint_part_impl; + IdDictFieldImplementation m_tracker_part_impl; + IdDictFieldImplementation m_calo_part_impl; +}; + + //<<<<<< INLINE PUBLIC 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(FaserDetectorID, 125694213 , 1) + ///////////////////////////////////////////////////////////////////////////// //<<<<<< 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(FaserDetectorID, 125694213, 1) - -//---------------------------------------------------------------------------- -// inline Identifier -// FaserDetectorID::module_id ( int station, -// int plane, -// int module ) const -// { - -// // Build identifier -// Identifier result((Identifier::value_type)0); +inline ExpandedIdentifier +FaserDetectorID::scint_exp (void) const +{ + ExpandedIdentifier result; + return (result << m_SCINT_ID); +} -// // Pack fields independently -// m_scint_impl.pack (scint_field_value(), result); -// m_veto_impl.pack (veto_field_value(), result); -// m_station_impl.pack (station, result); +inline ExpandedIdentifier +FaserDetectorID::tracker_exp (void) const +{ + ExpandedIdentifier result; + return (result << m_TRACKER_ID); +} -// return result; -// } +inline ExpandedIdentifier +FaserDetectorID::calo_exp(void) const +{ + ExpandedIdentifier result; + return (result << m_CALO_ID); +} -//---------------------------------------------------------------------------- -inline Identifier -FaserDetectorID::module_id ( const Identifier& submodule_id ) const +inline ExpandedIdentifier +FaserDetectorID::veto_exp (void) const { - Identifier result(submodule_id); - // Reset the plate and pmt fields - m_submodule_impl.reset(result); - m_sensor_impl.reset(result); - return (result); + ExpandedIdentifier result(scint_exp()); + return (result << m_VETO_ID); } -//---------------------------------------------------------------------------- -// inline Identifier -// FaserDetectorID::submodule_id ( int station, -// int plane, -// int module, -// int submodule ) const -// { -// // Build identifier -// Identifier result((Identifier::value_type)0); - -// // Pack fields independently -// m_scint_impl.pack (scint_field_value(), result); -// m_veto_impl.pack (veto_field_value(), result); -// m_station_impl.pack (station, result); -// m_plane_impl.pack (plane, result); -// m_module_impl.pack (module, result); -// m_submodule_impl.pack(submodule, result); - -// return result; -// } - -//---------------------------------------------------------------------------- -inline Identifier -FaserDetectorID::submodule_id ( const Identifier& sensor_id ) const +inline ExpandedIdentifier +FaserDetectorID::trigger_exp (void) const { - Identifier result(sensor_id); - // reset the strip field - m_sensor_impl.reset(result); - return (result); + ExpandedIdentifier result(scint_exp()); + return (result << m_TRIGGER_ID); } -inline IdentifierHash -FaserDetectorID::submodule_hash (Identifier submodule_id) const +inline ExpandedIdentifier +FaserDetectorID::preshower_exp (void) const { - id_vec_it it = std::lower_bound(m_submodule_vec.begin(), - m_submodule_vec.end(), - submodule_id); - // Require that submodule_id matches the one in vector - if (it != m_submodule_vec.end() && submodule_id == (*it)) { - return (it - m_submodule_vec.begin()); - } - IdentifierHash result; - return (result); // return hash in invalid state + ExpandedIdentifier result(scint_exp()); + return (result << m_PRESHOWER_ID); } -//---------------------------------------------------------------------------- -// inline Identifier -// FaserDetectorID::sensor_id ( int station, -// int plane, -// int module, -// int submodule, -// int sensor ) const -// { -// // Build identifier -// Identifier result((Identifier::value_type)0); - -// // Pack fields independently -// m_scint_impl.pack (scint_field_value(), result); -// m_veto_impl.pack (veto_field_value(), result); -// m_station_impl.pack (station, result); -// m_plane_impl.pack (plane, result); -// m_module_impl.pack (module, result); -// m_submodule_impl.pack(submodule, result); -// m_sensor_impl.pack (sensor, result); - -// return result; -// } - -//---------------------------------------------------------------------------- -inline Identifier -FaserDetectorID::sensor_id ( const Identifier& submodule_id, int sensor ) const +inline ExpandedIdentifier +FaserDetectorID::sct_exp (void) const { - // Build identifier - Identifier result(submodule_id); - - // Reset sensor and then add in value - m_sensor_impl.reset (result); - m_sensor_impl.pack (sensor, result); - - return result; + ExpandedIdentifier result(tracker_exp()); + return (result << m_SCT_ID); } -//---------------------------------------------------------------------------- -inline int -FaserDetectorID::station (const Identifier& id) const +inline ExpandedIdentifier +FaserDetectorID::ecal_exp (void) const { - return (m_station_impl.unpack(id)); + ExpandedIdentifier result(calo_exp()); + return (result << m_ECAL_ID); } -//---------------------------------------------------------------------------- -inline int -FaserDetectorID::plane (const Identifier& id) const +inline int +FaserDetectorID::scint_field_value () const {return (m_SCINT_ID);} + +inline int +FaserDetectorID::tracker_field_value () const {return (m_TRACKER_ID);} + +inline int +FaserDetectorID::calo_field_value () const {return (m_CALO_ID);} + +inline int +FaserDetectorID::veto_field_value () const {return (m_VETO_ID);} + +inline int +FaserDetectorID::trigger_field_value () const {return (m_TRIGGER_ID);} + +inline int +FaserDetectorID::preshower_field_value () const {return (m_PRESHOWER_ID);} + +inline int +FaserDetectorID::sct_field_value () const {return (m_SCT_ID);} + +inline int +FaserDetectorID::ecal_field_value () const {return (m_ECAL_ID);} + +inline bool +FaserDetectorID::is_scint (Identifier id) const { - return (m_plane_impl.unpack(id)); + return (m_det_impl.unpack(id) == m_SCINT_ID); } -//---------------------------------------------------------------------------- -inline int -FaserDetectorID::module (const Identifier& id) const + +inline bool +FaserDetectorID::is_tracker (Identifier id) const { - return (m_module_impl.unpack(id)); + return (m_det_impl.unpack(id) == m_TRACKER_ID); } -//---------------------------------------------------------------------------- -inline int -FaserDetectorID::submodule (const Identifier& id) const +inline bool +FaserDetectorID::is_calo (Identifier id) const { - return (m_submodule_impl.unpack(id)); + return (m_det_impl.unpack(id) == m_CALO_ID); } -//---------------------------------------------------------------------------- -inline int -FaserDetectorID::sensor (const Identifier& id) const +inline bool +FaserDetectorID::is_veto (Identifier id) const { - return (m_sensor_impl.unpack(id)); + bool result = false; + if(is_scint(id)) { + result = (m_scint_part_impl.unpack(id) == m_VETO_ID); + } + return result; } +inline bool +FaserDetectorID::is_trigger (Identifier id) const +{ + bool result = false; + if(is_scint(id)) { + result = (m_scint_part_impl.unpack(id) == m_TRIGGER_ID); + } + return result; +} + +inline bool +FaserDetectorID::is_preshower (Identifier id) const +{ + bool result = false; + if(is_scint(id)) { + result = (m_scint_part_impl.unpack(id) == m_PRESHOWER_ID); + } + return result; +} + +inline bool +FaserDetectorID::is_sct (Identifier id) const +{ + bool result = false; + if(is_tracker(id)) { + result = (m_tracker_part_impl.unpack(id) == m_SCT_ID); + } + return result; +} + +inline bool +FaserDetectorID::is_ecal (Identifier id) const +{ + bool result = false; + if(is_calo(id)) { + result = (m_calo_part_impl.unpack(id) == m_ECAL_ID); + } + return result; +} #endif // FASERDETDESCR_FASERDETECTORID_H diff --git a/DetectorDescription/FaserDetDescr/FaserDetDescr/FaserDetectorID.hOld b/DetectorDescription/FaserDetDescr/FaserDetDescr/FaserDetectorID.hOld new file mode 100644 index 000000000..7cfac9bdd --- /dev/null +++ b/DetectorDescription/FaserDetDescr/FaserDetDescr/FaserDetectorID.hOld @@ -0,0 +1,453 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef FASERDETDESCR_FASERDETECTORID_H +#define FASERDETDESCR_FASERDETECTORID_H +/** + * @file FaserDetectorID.h + * + * @brief This is an Identifier helper class for the all + * subdetectors. This class is a factory for creating compact + * Identifier objects and IdentifierHash or hash ids. And it also + * allows decoding of these ids. + * + */ + +//<<<<<< INCLUDES >>>>>> + +#include "FaserDetDescr/FaserDetectorIDBase.h" +#include "Identifier/Identifier.h" +#include "Identifier/IdentifierHash.h" +#include "Identifier/Range.h" +#include "Identifier/IdHelper.h" +#include "IdDict/IdDictFieldImplementation.h" +#include "AthenaKernel/CLASS_DEF.h" + +#include <string> +#include <assert.h> +#include <algorithm> + +//<<<<<< PUBLIC DEFINES >>>>>> +//<<<<<< PUBLIC CONSTANTS >>>>>> +//<<<<<< PUBLIC TYPES >>>>>> + +class IdDictDictionary; + +//<<<<<< PUBLIC VARIABLES >>>>>> +//<<<<<< PUBLIC FUNCTIONS >>>>>> +//<<<<<< CLASS DECLARATIONS >>>>>> + +/** + ** @class FaserDetectorID + ** + ** @brief This is an Identifier helper class for the FASER + ** subdetectors. This class is a factory for creating compact + ** Identifier objects and IdentifierHash or hash ids. And it also + ** allows decoding of these ids. + ** + ** Definition and the range of values for the levels of the + ** identifier are: + ** + ** @verbatim + ** element range meaning + ** ------- ----- ------- + ** + ** station + ** veto 0 - 1 front/back + ** trigger 0 single station + ** preshower 0 single station + ** sct 0 - 2 front, middle, back + ** ecal 0 single station + ** plane + ** veto 0 single plane + ** trigger 0 single plane + ** preshower 0 single plane + ** sct 0 - 2 three planes per station + ** ecal 0 single plane + ** module + ** veto 0 single plate + ** trigger 0 - 1 upper/lower plate + ** preshower 0 single plate + ** sct 0 - 7 eight modules per plane + ** ecal 0 - 3 four modules + ** submodule + ** veto 0 no segmentation + ** trigger 0 no segmentation + ** preshower 0 no segmentation + ** sct 0 - 1 two sides per module + ** ecal 0 - 66 scintillator layers + ** sensor + ** veto 0 single pmt + ** trigger 0 - 1 left/right pmt + ** preshower 0 single pmt + ** sct 0 - 767 strips + ** ecal 0 one tower per layer + ** @endverbatim + ** + */ +class FaserDetectorID : public FaserDetectorIDBase +{ +public: + + /// @name public typedefs + //@{ + typedef Identifier::size_type size_type; + typedef std::vector<Identifier>::const_iterator const_id_iterator; + typedef MultiRange::const_identifier_factory const_expanded_id_iterator; + //@} + + /// @name strutors + //@{ + FaserDetectorID(void); + virtual ~FaserDetectorID(void) = default; + //@} + + /// @name Creators for station, ids and pmt ids + //@{ + /// For a single module + virtual Identifier module_id( int station, + int plane, + int module ) const = 0; + + /// For a module from a submodule id + Identifier module_id ( const Identifier& submodule_id ) const; + + /// For a single submodule + virtual Identifier submodule_id ( int station, + int plane, + int module, + int submodule ) const = 0; + + /// For a single submodule from a sensor id + Identifier submodule_id ( const Identifier& sensor_id ) const; + + /// From hash - optimized + Identifier submodule_id( IdentifierHash submodule_hash) const; + + /// For an individual sensor + virtual Identifier sensor_id ( int station, + int plane, + int module, + int submodule, + int sensor ) const = 0; + + + Identifier sensor_id ( const Identifier& submodule_id, + int sensor ) const; + + //@} + + /// @name Hash table maximum sizes + //@{ + size_type submodule_hash_max (void) const; + size_type sensor_hash_max (void) const; + //@} + + /// @name Access to all ids + //@{ + /// Iterators over full set of ids. Submodule iterator is sorted + const_id_iterator submodule_begin (void) const; + const_id_iterator submodule_end (void) const; + /// For sensor ids, only expanded id iterators are available. Use + /// following "sensor_id" method to obtain a compact identifier + const_expanded_id_iterator sensor_begin (void) const; + const_expanded_id_iterator sensor_end (void) const; + //@} + + + /// submodule hash from id - optimized + IdentifierHash submodule_hash (Identifier submodule_id) const; + + + /// Values of different levels (failure returns 0) + int station (const Identifier& id) const; + int plane (const Identifier& id) const; + int module (const Identifier& id) const; + int submodule (const Identifier& id) const; + int sensor (const Identifier& id) const; + + // /// Max values for each field (-999 == failure) + int station_max (const Identifier& id) const; + int plane_max (const Identifier& id) const; + int module_max (const Identifier& id) const; + int submodule_max (const Identifier& id) const; + int sensor_max (const Identifier& id) const; + //@} + + // /// @name module eta/phi navigation + // //@{ + // /// Previous wafer hash in phi (return == 0 for neighbor found) + // int get_prev_in_phi (const IdentifierHash& id, IdentifierHash& prev) const; + // /// Next wafer hash in phi (return == 0 for neighbor found) + // int get_next_in_phi (const IdentifierHash& id, IdentifierHash& next) const; + // /// Previous wafer hash in eta (return == 0 for neighbor found) + // int get_prev_in_eta (const IdentifierHash& id, IdentifierHash& prev) const; + // /// Next wafer hash in eta (return == 0 for neighbor found) + // int get_next_in_eta (const IdentifierHash& id, IdentifierHash& next) const; + // /// Wafer hash on other side + // int get_other_side (const IdentifierHash& id, IdentifierHash& other) const; + + // // To check for when phi wrap around may be needed, use + // bool is_phi_module_max(const Identifier& id) const; + // /// For the barrel + // bool is_eta_module_min(const Identifier& id) const; + // /// For the barrel + // bool is_eta_module_max(const Identifier& id) const; + // //@} + + // /// @name contexts to distinguish wafer id from pixel id + // //@{ + // IdContext wafer_context (void) const; + // IdContext strip_context (void) const; + // //@} + + /// @name methods from abstract interface - slower than opt version + //@{ + /// Create compact id from hash id (return == 0 for OK) + virtual int get_id (const IdentifierHash& hash_id, + Identifier& id, + const IdContext* context = 0) const; + + /// Create hash id from compact id (return == 0 for OK) + virtual int get_hash (const Identifier& id, + IdentifierHash& hash_id, + const IdContext* context = 0) const; + //@} + + /// Return the lowest bit position used in the channel id + int base_bit (void) const; + + // /// Calculate a channel offset between the two identifiers. + // Identifier::diff_type calc_offset(const Identifier& base, + // const Identifier& target) const; + + // /// Create an identifier with a given base and channel offset + // Identifier strip_id_offset(const Identifier& base, + // Identifier::diff_type offset) const; + + /// @name interaction with id dictionary + //@{ + /// Create sensor Identifier from expanded id, which is returned by the + /// id_iterators + Identifier sensor_id (const ExpandedIdentifier& sensor_id) const; + + /// Create expanded id from compact id (return == 0 for OK) + void get_expanded_id (const Identifier& id, + ExpandedIdentifier& exp_id, + const IdContext* context = 0) const; + + /// Initialization from the identifier dictionary + virtual int initialize_from_dictionary(const IdDictMgr& dict_mgr); + +private: + + typedef std::vector<Identifier> id_vec; + typedef id_vec::const_iterator id_vec_it; + typedef std::vector<unsigned short> hash_vec; + typedef hash_vec::const_iterator hash_vec_it; + + void submodule_id_checks ( int station, + int plane, + int module, + int submodule ) const; + + void sensor_id_checks ( int station, + int plane, + int module, + int submodule, + int sensor) const; + + int initLevelsFromDict(void); + + int init_hashes(void); + + int init_neighbors(void); + + size_type m_faser_region_index; + size_type m_SUBDET_INDEX; + size_type m_PART_INDEX; + size_type m_STATION_INDEX; + size_type m_PLANE_INDEX; + size_type m_MODULE_INDEX; + size_type m_SUBMODULE_INDEX; + size_type m_SENSOR_INDEX; + + const IdDictDictionary* m_dict; + MultiRange m_full_submodule_range; + MultiRange m_full_sensor_range; + size_type m_submodule_hash_max; + size_type m_sensor_hash_max; + id_vec m_submodule_vec; + // hash_vec m_prev_phi_wafer_vec; + // hash_vec m_next_phi_wafer_vec; + // hash_vec m_prev_eta_wafer_vec; + // hash_vec m_next_eta_wafer_vec; + + IdDictFieldImplementation m_subdet_impl ; + IdDictFieldImplementation m_part_impl ; + IdDictFieldImplementation m_station_impl ; + IdDictFieldImplementation m_plane_impl ; + IdDictFieldImplementation m_module_impl ; + IdDictFieldImplementation m_submodule_impl; + IdDictFieldImplementation m_sensor_impl ; +}; + + +//<<<<<< 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(FaserDetectorID, 125694213, 1) + +//---------------------------------------------------------------------------- +// inline Identifier +// FaserDetectorID::module_id ( int station, +// int plane, +// int module ) const +// { + +// // Build identifier +// Identifier result((Identifier::value_type)0); + +// // Pack fields independently +// m_scint_impl.pack (scint_field_value(), result); +// m_veto_impl.pack (veto_field_value(), result); +// m_station_impl.pack (station, result); + +// return result; +// } + +//---------------------------------------------------------------------------- +inline Identifier +FaserDetectorID::module_id ( const Identifier& submodule_id ) const +{ + Identifier result(submodule_id); + // Reset the plate and pmt fields + m_submodule_impl.reset(result); + m_sensor_impl.reset(result); + return (result); +} + +//---------------------------------------------------------------------------- +// inline Identifier +// FaserDetectorID::submodule_id ( int station, +// int plane, +// int module, +// int submodule ) const +// { +// // Build identifier +// Identifier result((Identifier::value_type)0); + +// // Pack fields independently +// m_scint_impl.pack (scint_field_value(), result); +// m_veto_impl.pack (veto_field_value(), result); +// m_station_impl.pack (station, result); +// m_plane_impl.pack (plane, result); +// m_module_impl.pack (module, result); +// m_submodule_impl.pack(submodule, result); + +// return result; +// } + +//---------------------------------------------------------------------------- +inline Identifier +FaserDetectorID::submodule_id ( const Identifier& sensor_id ) const +{ + Identifier result(sensor_id); + // reset the strip field + m_sensor_impl.reset(result); + return (result); +} + +inline IdentifierHash +FaserDetectorID::submodule_hash (Identifier submodule_id) const +{ + id_vec_it it = std::lower_bound(m_submodule_vec.begin(), + m_submodule_vec.end(), + submodule_id); + // Require that submodule_id matches the one in vector + if (it != m_submodule_vec.end() && submodule_id == (*it)) { + return (it - m_submodule_vec.begin()); + } + IdentifierHash result; + return (result); // return hash in invalid state +} + +//---------------------------------------------------------------------------- +// inline Identifier +// FaserDetectorID::sensor_id ( int station, +// int plane, +// int module, +// int submodule, +// int sensor ) const +// { +// // Build identifier +// Identifier result((Identifier::value_type)0); + +// // Pack fields independently +// m_scint_impl.pack (scint_field_value(), result); +// m_veto_impl.pack (veto_field_value(), result); +// m_station_impl.pack (station, result); +// m_plane_impl.pack (plane, result); +// m_module_impl.pack (module, result); +// m_submodule_impl.pack(submodule, result); +// m_sensor_impl.pack (sensor, result); + +// return result; +// } + +//---------------------------------------------------------------------------- +inline Identifier +FaserDetectorID::sensor_id ( const Identifier& submodule_id, int sensor ) const +{ + // Build identifier + Identifier result(submodule_id); + + // Reset sensor and then add in value + m_sensor_impl.reset (result); + m_sensor_impl.pack (sensor, result); + + return result; +} + +//---------------------------------------------------------------------------- +inline int +FaserDetectorID::station (const Identifier& id) const +{ + return (m_station_impl.unpack(id)); +} + +//---------------------------------------------------------------------------- +inline int +FaserDetectorID::plane (const Identifier& id) const +{ + return (m_plane_impl.unpack(id)); +} +//---------------------------------------------------------------------------- +inline int +FaserDetectorID::module (const Identifier& id) const +{ + return (m_module_impl.unpack(id)); +} + +//---------------------------------------------------------------------------- +inline int +FaserDetectorID::submodule (const Identifier& id) const +{ + return (m_submodule_impl.unpack(id)); +} + +//---------------------------------------------------------------------------- +inline int +FaserDetectorID::sensor (const Identifier& id) const +{ + return (m_sensor_impl.unpack(id)); +} + + +#endif // FASERDETDESCR_FASERDETECTORID_H diff --git a/DetectorDescription/FaserDetDescr/FaserDetDescr/FaserDetectorIDBase.h b/DetectorDescription/FaserDetDescr/FaserDetDescr/FaserDetectorIDBase.h deleted file mode 100644 index a7fdbc623..000000000 --- a/DetectorDescription/FaserDetDescr/FaserDetDescr/FaserDetectorIDBase.h +++ /dev/null @@ -1,470 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef FASERDETDESCR_FASERDETECTORIDBASE_H -#define FASERDETDESCR_FASERDETECTORIDBASE_H -/** - * @file FaserDetectorIDBase.h - * - * @brief This class provides an interface to generate or decode an - * identifier for the upper levels of the detector element - * hierarchy, i.e. Faser, the detector systems and detector - * subsystems. As well general "print out" methods are provide for - * all detector systems. All id helper classes derive from this - * class. This class also provides access to the version tags of the - * id dictionaries used by the helper. - * - * @author RD Schaffer <R.D.Schaffer@cern.ch> - * - * $Id: AtlasDetectorID.h,v 1.38 2007-02-23 09:33:30 prieur Exp $ - * Modified for FASER - */ - -//<<<<<< INCLUDES >>>>>> - -#include "Identifier/Identifier.h" -#include "Identifier/IdContext.h" -#include "Identifier/IdHelper.h" -#include "Identifier/Range.h" -#include "IdDict/IdDictFieldImplementation.h" -#include "FaserDetTechnology.h" -#include "AthenaKernel/CLASS_DEF.h" -#include <string> -#include <vector> - -//<<<<<< PUBLIC TYPES >>>>>> - -class IdDictDictionary; -class FaserDetectorIDHelper; - -//<<<<<< CLASS DECLARATIONS >>>>>> - - -/** - * @class FaserDetectorIDBase - * - * @brief This class provides an interface to generate or decode an - * identifier for the upper levels of the detector element - * hierarchy, i.e. Faser, the detector systems and detector - * subsystems. As well general "print out" methods are provide for - * all detector systems. All id helper classes derive from this - * class. This class also provides access to the version tags of the - * id dictionaries used by the helper. - **/ - -class FaserDetectorIDBase : public IdHelper -{ -public: - - /// @name strutors - //@{ - FaserDetectorIDBase(); - FaserDetectorIDBase(const FaserDetectorIDBase& other); - ~FaserDetectorIDBase(void); - FaserDetectorIDBase& operator= (const FaserDetectorIDBase& other); - //@} - - /// @name Detector system ids - //@{ - /// Detector systems: - Identifier scint (void) const; - Identifier tracker (void) const; - Identifier calo (void) const; - //@} - - /// @name Scintillator subsystem ids - //@{ - Identifier veto (void) const; - Identifier trigger (void) const; - Identifier preshower (void) const; - //@} - - /// @name Tracker subsystem ids - //@{ - Identifier sct (void) const; - //@} - - /// @name Calorimeter subsystem ids - //@{ - Identifier ecal (void) const; - //@} - - /// @name Contexts to provide id length - e.g. for use in generic decoding - //@{ - /// IdContext (indicates id length) for detector systems - IdContext detsystem_context (void) const; - - /// IdContext (indicates id length) for sub-detector - IdContext subdet_context (void) const; - //@} - - - /// @name Generic conversion between identifier and idhash - //@{ - /// Create compact id from hash id (return == 0 for OK) - virtual int get_id (const IdentifierHash& hash_id, - Identifier& id, - const IdContext* context = 0) const; - - /// Create hash id from compact id (return == 0 for OK) - virtual int get_hash (const Identifier& id, - IdentifierHash& hash_id, - const IdContext* context = 0) const; - //@} - - /// @name Initialization and version name - //@{ - /// Initialization from the identifier dictionary - virtual int initialize_from_dictionary(const IdDictMgr& dict_mgr); - - // retrieve version of the dictionary - virtual std::string dictionaryVersion (void) const; - //@} - - - /// @name Generic printing of identifiers - //@{ - /// Short print out of any identifier (optionally provide - /// separation character - default is '.'): - void show (Identifier id, - const IdContext* context = 0, - char sep = '.' ) const; - /// or provide the printout in string form - std::string show_to_string (Identifier id, - const IdContext* context = 0, - char sep = '.' ) const; - - /// Expanded print out of any identifier - void print (Identifier id, - const IdContext* context = 0) const; - /// or provide the printout in string form - std::string print_to_string (Identifier id, - const IdContext* context = 0) const; - //@} - - /// @name Test of an Identifier to see if it belongs to a particular detector (sub)system: - //@{ - bool is_scint (Identifier id) const; - bool is_tracker (Identifier id) const; - bool is_calo (Identifier id) const; - bool is_veto (Identifier id) const; - bool is_trigger (Identifier id) const; - bool is_preshower (Identifier id) const; - bool is_sct (Identifier id) const; - bool is_ecal (Identifier id) const; - //@} - - - /// @name Test of an Identifier to see if it belongs to a particular detector (sub)system (using expanded ids): - //@{ - bool is_scint (const ExpandedIdentifier& id) const; - bool is_tracker (const ExpandedIdentifier& id) const; - bool is_calo (const ExpandedIdentifier& id) const; - bool is_veto (const ExpandedIdentifier& id) const; - bool is_trigger (const ExpandedIdentifier& id) const; - bool is_preshower (const ExpandedIdentifier& id) const; - bool is_sct (const ExpandedIdentifier& id) const; - bool is_ecal (const ExpandedIdentifier& id) const; - //@} - - /// @name Dictionary versioning: provide access to dictionary names and versions. Note that a helper may correspond to one or more id dictionary - //@{ - /// Dictionary names - std::vector<std::string> dict_names(void) const; - /// File names for subdet dictionaries - std::vector<std::string> file_names(void) const; - /// Version tags for subdet dictionaries - std::vector<std::string> dict_tags (void) const; - //@} - - /// @name Checks are performed by default in debug compilation and NOT in optimized compilation. One can switch or query this mode for any idHelper with the following methods: - //@{ - virtual bool do_checks (void) const; - virtual void set_do_checks (bool do_checks); - //@} - - /// @name neighbours are initialized by default. One can switch or query this mode with the following methods: - //@{ - virtual bool do_neighbours (void) const; - virtual void set_do_neighbours (bool do_neighbours); - //@} - - /// @name setting pointer to the MessageService - //@{ - virtual void setMessageSvc (IMessageSvc* msgSvc); - //@} - - /// Set flag for suppressing informational output. - void set_quiet (bool quiet); - - -protected: - - friend class FaserDetectorIDHelper; - - void setDictVersion (const IdDictMgr& dict_mgr, const std::string& name); - - std::string to_range (const ExpandedIdentifier& id) const; - - std::string fix_barrel_ec (const std::string& barrel_ec) const; - - /// Detector systems: - ExpandedIdentifier scint_exp (void) const; - ExpandedIdentifier tracker_exp (void) const; - ExpandedIdentifier calo_exp (void) const; - - /// Scintillator: - ExpandedIdentifier veto_exp (void) const; - ExpandedIdentifier trigger_exp (void) const; - ExpandedIdentifier preshower_exp (void) const; - - /// Tracker: - ExpandedIdentifier sct_exp (void) const; - - /// Calorimeter: - ExpandedIdentifier ecal_exp (void) const; - - /// Provide efficient access to individual field values, for - /// subclass idhelpers - int scint_field_value () const; - int tracker_field_value () const; - int calo_field_value () const; - int veto_field_value () const; - int trigger_field_value () const; - int preshower_field_value () const; - int sct_field_value () const; - int ecal_field_value () const; - - /// Register the file and tag names for a particular IdDict - /// dictionary - int register_dict_tag (const IdDictMgr& dict_mgr, - const std::string& dict_name); - - /// Test whether an idhelper should be reinitialized based on the - /// change of tags - bool reinitialize (const IdDictMgr& dict_mgr); - - /// Flag for subclasses to know whether or not to perform - /// checks. In general, this is set to false in optimized mode. - mutable bool m_do_checks; - /// Flag for subclasses to know whether or not to perform - /// neighbour initialization - mutable bool m_do_neighbours; - - /// pointer to the message service - IMessageSvc* m_msgSvc; - - /// If true, suppress DEBUG/INFO messages. - bool m_quiet; - - - /// List of dictionary names used by this helper - std::vector<std::string> m_dict_names; - - /// List of dictionary file names used by this helper - std::vector<std::string> m_file_names; - - /// List of dictionary versions used by this helper - std::vector<std::string> m_dict_tags; -private: - - typedef Identifier::size_type size_type; - - // Identifiear numbering: - enum ID { - FASER_ID = static_cast<Identifier::value_type>(0), - MAX_BIT = Identifier::MAX_BIT, - ALL_BITS = Identifier::ALL_BITS }; - - int initLevelsFromDict(const IdDictMgr& dict_mgr); - - // dictionary version - std::string m_dict_version; - bool m_is_initialized_from_dict; - size_type m_DET_INDEX; - size_type m_SUBDET_INDEX; - int m_SCINT_ID; - int m_TRACKER_ID; - int m_CALO_ID; - int m_VETO_ID; - int m_TRIGGER_ID; - int m_PRESHOWER_ID; - int m_SCT_ID; - int m_ECAL_ID; - - /// Flag for slhc layout: - bool m_isSLHC; - - IdDictDictionary* m_faser_dict; - IdDictDictionary* m_scint_dict; - IdDictDictionary* m_tracker_dict; - IdDictDictionary* m_calo_dict; - FaserDetectorIDHelper* m_helper; - IdDictFieldImplementation m_det_impl; - IdDictFieldImplementation m_scint_part_impl; - IdDictFieldImplementation m_tracker_part_impl; - IdDictFieldImplementation m_calo_part_impl; -}; - - - -//<<<<<< INLINE PUBLIC 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(FaserDetectorIDBase, 168050226 , 1) - -///////////////////////////////////////////////////////////////////////////// -//<<<<<< INLINE MEMBER FUNCTIONS >>>>>> -///////////////////////////////////////////////////////////////////////////// - -inline ExpandedIdentifier -FaserDetectorIDBase::scint_exp (void) const -{ - ExpandedIdentifier result; - return (result << m_SCINT_ID); -} - -inline ExpandedIdentifier -FaserDetectorIDBase::tracker_exp (void) const -{ - ExpandedIdentifier result; - return (result << m_TRACKER_ID); -} - -inline ExpandedIdentifier -FaserDetectorIDBase::calo_exp(void) const -{ - ExpandedIdentifier result; - return (result << m_CALO_ID); -} - -inline ExpandedIdentifier -FaserDetectorIDBase::veto_exp (void) const -{ - ExpandedIdentifier result(scint_exp()); - return (result << m_VETO_ID); -} - -inline ExpandedIdentifier -FaserDetectorIDBase::trigger_exp (void) const -{ - ExpandedIdentifier result(scint_exp()); - return (result << m_TRIGGER_ID); -} - -inline ExpandedIdentifier -FaserDetectorIDBase::preshower_exp (void) const -{ - ExpandedIdentifier result(scint_exp()); - return (result << m_PRESHOWER_ID); -} - -inline ExpandedIdentifier -FaserDetectorIDBase::sct_exp (void) const -{ - ExpandedIdentifier result(tracker_exp()); - return (result << m_SCT_ID); -} - -inline ExpandedIdentifier -FaserDetectorIDBase::ecal_exp (void) const -{ - ExpandedIdentifier result(calo_exp()); - return (result << m_ECAL_ID); -} - -inline int -FaserDetectorIDBase::scint_field_value () const {return (m_SCINT_ID);} - -inline int -FaserDetectorIDBase::tracker_field_value () const {return (m_TRACKER_ID);} - -inline int -FaserDetectorIDBase::calo_field_value () const {return (m_CALO_ID);} - -inline int -FaserDetectorIDBase::veto_field_value () const {return (m_VETO_ID);} - -inline int -FaserDetectorIDBase::trigger_field_value () const {return (m_TRIGGER_ID);} - -inline int -FaserDetectorIDBase::preshower_field_value () const {return (m_PRESHOWER_ID);} - -inline int -FaserDetectorIDBase::sct_field_value () const {return (m_SCT_ID);} - -inline int -FaserDetectorIDBase::ecal_field_value () const {return (m_ECAL_ID);} - -inline bool -FaserDetectorIDBase::is_scint (Identifier id) const -{ - return (m_det_impl.unpack(id) == m_SCINT_ID); -} - -inline bool -FaserDetectorIDBase::is_tracker (Identifier id) const -{ - return (m_det_impl.unpack(id) == m_TRACKER_ID); -} - -inline bool -FaserDetectorIDBase::is_calo (Identifier id) const -{ - return (m_det_impl.unpack(id) == m_CALO_ID); -} - -inline bool -FaserDetectorIDBase::is_veto (Identifier id) const -{ - bool result = false; - if(is_scint(id)) { - result = (m_scint_part_impl.unpack(id) == m_VETO_ID); - } - return result; -} - -inline bool -FaserDetectorIDBase::is_trigger (Identifier id) const -{ - bool result = false; - if(is_scint(id)) { - result = (m_scint_part_impl.unpack(id) == m_TRIGGER_ID); - } - return result; -} - -inline bool -FaserDetectorIDBase::is_preshower (Identifier id) const -{ - bool result = false; - if(is_scint(id)) { - result = (m_scint_part_impl.unpack(id) == m_PRESHOWER_ID); - } - return result; -} - -inline bool -FaserDetectorIDBase::is_sct (Identifier id) const -{ - bool result = false; - if(is_tracker(id)) { - result = (m_tracker_part_impl.unpack(id) == m_SCT_ID); - } - return result; -} - -inline bool -FaserDetectorIDBase::is_ecal (Identifier id) const -{ - bool result = false; - if(is_calo(id)) { - result = (m_calo_part_impl.unpack(id) == m_ECAL_ID); - } - return result; -} - -#endif // FASERDETDESCR_FASERDETECTORIDBASE_H diff --git a/DetectorDescription/FaserDetDescr/FaserDetDescr/selection.xml b/DetectorDescription/FaserDetDescr/FaserDetDescr/selection.xml index ee21d3231..e1dd6f004 100644 --- a/DetectorDescription/FaserDetDescr/FaserDetDescr/selection.xml +++ b/DetectorDescription/FaserDetDescr/FaserDetDescr/selection.xml @@ -1,6 +1,5 @@ <lcgdict> <enum pattern="FaserDetDescr::*"/> <class name="FaserDetDescr::ROOT6_NamespaceAutoloadHook" /> - <class name="FaserDetectorIDBase" /> - <!-- <class name="FaserDetectorID" /> --> + <class name="FaserDetectorID" /> </lcgdict> diff --git a/DetectorDescription/FaserDetDescr/src/FaserDetectorID.cxx b/DetectorDescription/FaserDetDescr/src/FaserDetectorID.cxx index 29b4ff691..6bbaec02b 100644 --- a/DetectorDescription/FaserDetDescr/src/FaserDetectorID.cxx +++ b/DetectorDescription/FaserDetDescr/src/FaserDetectorID.cxx @@ -1,21 +1,21 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ /*************************************************************************** - Scintillator identifier package - ------------------------------------------- + Detector Description + ----------------------------------------- ***************************************************************************/ //<<<<<< INCLUDES >>>>>> -#include "GaudiKernel/MsgStream.h" +#include "GaudiKernel/MsgStream.h" #include "FaserDetDescr/FaserDetectorID.h" -#include "Identifier/IdentifierHash.h" -#include "IdDict/IdDictDefs.h" -#include <set> -#include <algorithm> +#include "IdDict/IdDictDefs.h" +#include "FaserDetectorIDHelper.h" #include <iostream> +#include <stdio.h> +#include <assert.h> //<<<<<< PRIVATE DEFINES >>>>>> //<<<<<< PRIVATE CONSTANTS >>>>>> @@ -27,337 +27,1108 @@ //<<<<<< PUBLIC FUNCTION DEFINITIONS >>>>>> //<<<<<< MEMBER FUNCTION DEFINITIONS >>>>>> +FaserDetectorID::FaserDetectorID() + : + m_do_checks(false), + m_do_neighbours(true), + m_msgSvc(0), + m_quiet(false), + m_is_initialized_from_dict(false), + m_DET_INDEX(999), + m_SUBDET_INDEX(999), + m_SCINT_ID(2), + m_TRACKER_ID(3), + m_CALO_ID(4), + m_VETO_ID(1), + m_TRIGGER_ID(2), + m_PRESHOWER_ID(3), + m_SCT_ID(1), + m_ECAL_ID(1), + m_isSLHC(false), + m_faser_dict(0), + m_scint_dict(0), + m_tracker_dict(0), + m_calo_dict(0), + m_helper(0) +{} -///////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////// - +FaserDetectorID::~FaserDetectorID(void) +{ + delete m_helper; +} -FaserDetectorID::FaserDetectorID(void) +FaserDetectorID::FaserDetectorID(const FaserDetectorID& other) : - m_faser_region_index(0), - m_SUBDET_INDEX(0), - m_PART_INDEX(1), - m_STATION_INDEX(2), - m_PLANE_INDEX(3), - m_MODULE_INDEX(4), - m_SUBMODULE_INDEX(5), - m_SENSOR_INDEX(6), - m_dict(0), - m_submodule_hash_max(0), - m_sensor_hash_max(0) + IdHelper(), + m_do_checks (other.m_do_checks), + m_do_neighbours (other.m_do_neighbours), + m_msgSvc (other.m_msgSvc), + m_quiet (other.m_quiet), + m_dict_version (other.m_dict_version), + m_is_initialized_from_dict(other.m_is_initialized_from_dict), + m_DET_INDEX (other.m_DET_INDEX), + m_SUBDET_INDEX (other.m_SUBDET_INDEX), + m_SCINT_ID (other.m_SCINT_ID), + m_TRACKER_ID (other.m_TRACKER_ID), + m_CALO_ID (other.m_CALO_ID), + m_VETO_ID (other.m_VETO_ID), + m_TRIGGER_ID (other.m_TRIGGER_ID), + m_PRESHOWER_ID (other.m_PRESHOWER_ID), + m_SCT_ID (other.m_SCT_ID), + m_ECAL_ID (other.m_ECAL_ID), + m_isSLHC (other.m_isSLHC), + m_faser_dict (other.m_faser_dict), + m_scint_dict (other.m_scint_dict), + m_tracker_dict (other.m_tracker_dict), + m_calo_dict (other.m_calo_dict), + m_helper (0), + m_det_impl (other.m_det_impl), + m_scint_part_impl (other.m_scint_part_impl), + m_tracker_part_impl (other.m_tracker_part_impl), + m_calo_part_impl (other.m_calo_part_impl) + { + if (other.m_helper) { + // Must copy helper + m_helper = new FaserDetectorIDHelper(*other.m_helper); + m_helper->setMsgSvc(m_msgSvc); + } } -int -FaserDetectorID::init_hashes(void) -{ - - // - // create a vector(s) to retrieve the hashes for compact ids. For - // the moment, we implement a hash for submodules but NOT for sensors - // - MsgStream log(m_msgSvc, "FaserDetectorID"); - // wafer hash - m_submodule_hash_max = m_full_submodule_range.cardinality(); - m_submodule_vec.resize(m_submodule_hash_max); - unsigned int nids = 0; - std::set<Identifier> ids; - for (unsigned int i = 0; i < m_full_submodule_range.size(); ++i) { - const Range& range = m_full_submodule_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); - Identifier id = submodule_id(exp_id[m_STATION_INDEX], - exp_id[m_PLANE_INDEX], - exp_id[m_MODULE_INDEX], - exp_id[m_SUBMODULE_INDEX]); - if(!(ids.insert(id)).second) { - log << MSG::ERROR << " FaserDetectorID::init_hashes " - << " Error: duplicated id for plate id. nid " << nids - << " compact id " << id.getString() - << " id " << (std::string)exp_id << endmsg; - return (1); - } - nids++; +FaserDetectorID& +FaserDetectorID::operator= (const FaserDetectorID& other) +{ + if (this != &other) { + m_do_checks = other.m_do_checks; + m_do_neighbours = other.m_do_neighbours; + m_msgSvc = other.m_msgSvc; + m_quiet = other.m_quiet; + m_dict_version = other.m_dict_version; + m_is_initialized_from_dict = other.m_is_initialized_from_dict; + m_DET_INDEX = other.m_DET_INDEX; + m_SUBDET_INDEX = other.m_SUBDET_INDEX; + m_SCINT_ID = other.m_SCINT_ID; + m_TRACKER_ID = other.m_TRACKER_ID; + m_CALO_ID = other.m_CALO_ID; + m_VETO_ID = other.m_VETO_ID; + m_TRIGGER_ID = other.m_TRIGGER_ID; + m_PRESHOWER_ID = other.m_PRESHOWER_ID; + m_SCT_ID = other.m_SCT_ID; + m_ECAL_ID = other.m_ECAL_ID; + m_faser_dict = other.m_faser_dict; + m_scint_dict = other.m_scint_dict; + m_tracker_dict = other.m_tracker_dict; + m_calo_dict = other.m_calo_dict; + m_det_impl = other.m_det_impl; + m_scint_part_impl = other.m_scint_part_impl; + m_tracker_part_impl = other.m_tracker_part_impl; + m_calo_part_impl = other.m_calo_part_impl; + + if (other.m_helper) { + // Must copy helper. + delete m_helper; + m_helper = new FaserDetectorIDHelper(*other.m_helper); + m_helper->setMsgSvc(m_msgSvc); } } - if(ids.size() != m_submodule_hash_max) { - log << MSG::ERROR << " FaserDetectorID::init_hashes " - << " Error: set size NOT EQUAL to hash max. size " << ids.size() - << " hash max " << m_submodule_hash_max - << endmsg; - return (1); - } - nids = 0; - std::set<Identifier>::const_iterator first = ids.begin(); - std::set<Identifier>::const_iterator last = ids.end(); - for (; first != last && nids < m_submodule_vec.size(); ++first) { - m_submodule_vec[nids] = (*first); - nids++; - } + return (*this); +} + + +Identifier +FaserDetectorID::scint (void) const +{ + + Identifier result((Identifier::value_type)0); + // Pack field + m_det_impl.pack (scint_field_value(), result); + return (result); +} + +Identifier +FaserDetectorID::tracker (void) const +{ + Identifier result((Identifier::value_type)0); + // Pack field + m_det_impl.pack (tracker_field_value(), result); + return (result); +} - // sensor hash - we do not keep a vec for the sensors - m_sensor_hash_max = m_full_sensor_range.cardinality(); +Identifier +FaserDetectorID::calo(void) const +{ + Identifier result((Identifier::value_type)0); + // Pack field + m_det_impl.pack (calo_field_value(), result); + return (result); +} + +Identifier +FaserDetectorID::veto (void) const +{ + Identifier result((Identifier::value_type)0); + // Pack field + m_det_impl.pack (scint_field_value(), result); + m_scint_part_impl.pack(m_VETO_ID, result); + return (result); +} + +Identifier +FaserDetectorID::trigger (void) const +{ + Identifier result((Identifier::value_type)0); + // Pack field + m_det_impl.pack (scint_field_value(), result); + m_scint_part_impl.pack(m_TRIGGER_ID, result); + return (result); +} + +Identifier +FaserDetectorID::preshower (void) const +{ + Identifier result((Identifier::value_type)0); + // Pack field + m_det_impl.pack (scint_field_value(), result); + m_scint_part_impl.pack(m_PRESHOWER_ID, result); + return (result); +} + +Identifier +FaserDetectorID::sct (void) const +{ + Identifier result((Identifier::value_type)0); + // Pack field + m_det_impl.pack (tracker_field_value(), result); + m_tracker_part_impl.pack(m_SCT_ID, result); + return (result); +} + +Identifier +FaserDetectorID::ecal (void) const +{ + Identifier result((Identifier::value_type)0); + // Pack field + m_det_impl.pack (calo_field_value(), result); + m_calo_part_impl.pack(m_ECAL_ID, result); + return (result); +} + +/// IdContext (indicates id length) for detector systems +IdContext +FaserDetectorID::detsystem_context (void) const +{ + ExpandedIdentifier id; + return (IdContext(id, 0, m_DET_INDEX)); +} + +/// IdContext (indicates id length) for sub-detector +IdContext +FaserDetectorID::subdet_context (void) const +{ + ExpandedIdentifier id; + return (IdContext(id, 0, m_SUBDET_INDEX)); +} + + +int +FaserDetectorID::get_id (const IdentifierHash& /*hash_id*/, + Identifier& /*id*/, + const IdContext* /*context*/) const +{ return (0); } +int +FaserDetectorID::get_hash (const Identifier& /*id*/, + IdentifierHash& /*hash_id*/, + const IdContext* /*context*/) const +{ + return (0); +} int -FaserDetectorID::initialize_from_dictionary(const IdDictMgr& dict_mgr) +FaserDetectorID::register_dict_tag (const IdDictMgr& dict_mgr, + const std::string& dict_name) { - MsgStream log(m_msgSvc, "FaserDetectorID"); - log << MSG::INFO << "Initialize from dictionary" << endmsg; - - // Check whether this helper should be reinitialized - if (!reinitialize(dict_mgr)) { - log << MSG::INFO << "Request to reinitialize not satisfied - tags have not changed" << endmsg; - return (0); - } - else { - if (m_msgSvc) { - log << MSG::DEBUG << "(Re)initialize" << endmsg; + // Register version of dictionary dict_name + + // Access dictionary by name + IdDictDictionary* dict = dict_mgr.find_dictionary(dict_name); + if (!dict) return(1); + // Add in dict name, file name and version + m_dict_names.push_back(dict_name); + m_file_names.push_back(dict->file_name()); + m_dict_tags.push_back(dict->dict_tag()); + return (0); +} + +/// Test whether an idhelper should be reinitialized based on the +/// change of tags +bool +FaserDetectorID::reinitialize (const IdDictMgr& dict_mgr) +{ + // If no tag has been registered, then reinitialize + if (m_dict_tags.size() == 0) return (true); + + // If no dict names have been registered, then reinitialize + if (m_dict_names.size() == 0) return (true); + + // Loop over dict names and check version tags + if (m_dict_names.size() != m_dict_tags.size()) { + if(m_msgSvc) { + MsgStream log(m_msgSvc, "FaserDetectorID" ); + log << MSG::ERROR << "reinitialize: dict names and tags vectors not the same length " << endmsg; + log << MSG::ERROR << "names: " << m_dict_names.size() << " tags: " << m_dict_tags.size() << endmsg; } else { - std::cout << " DEBUG (Re)initialize" << std::endl; + std::cout << MSG::ERROR << "reinitialize: dict names and tags vectors not the same length " << std::endl; + std::cout << "FaserDetectorID::reinitialize ERROR names: " << m_dict_names.size() << " tags: " << m_dict_tags.size() << std::endl; + } + } + for (unsigned int i = 0; i < m_dict_names.size(); ++i) { + // Access dictionary by name + IdDictDictionary* dict = dict_mgr.find_dictionary(m_dict_names[i]); + if (!dict) { + if(m_msgSvc) { + MsgStream log(m_msgSvc, "FaserDetectorID" ); + log << MSG::ERROR << "reinitialize: could not find dict - " << m_dict_names[i] << endmsg; + } + else { + std::cout << "FaserDetectorID::reinitialize ERROR could not find dict - " << m_dict_names[i] << std::endl; + } + return(false); + } + if (m_dict_tags[i] != dict->dict_tag()) { + // Remove all memory of versions + m_dict_names.clear(); + m_dict_tags.clear(); + m_file_names.clear(); + return (true); } } - // init base object - if(FaserDetectorIDBase::initialize_from_dictionary(dict_mgr)) return (1); + // Tags match - don't reinitialize + return (false); +} + - // Register version of InnerDetector dictionary - if (register_dict_tag(dict_mgr, "Scintillator")) return(1); - m_dict = dict_mgr.find_dictionary ("Scintillator"); - if(!m_dict) { - log << MSG::ERROR << " FaserDetectorID::initialize_from_dict - cannot access Scintillator dictionary " << endmsg; - return 1; +int +FaserDetectorID::initialize_from_dictionary(const IdDictMgr& dict_mgr) +{ + + // Register version of FASER dictionary + if (register_dict_tag(dict_mgr, "FASER")) return(1); + + // Initialize helper, needed for init of FaserDetectorID + if(!m_helper) { + m_helper = new FaserDetectorIDHelper; + m_helper->setMsgSvc(m_msgSvc); } - // Initialize the field indices - if(initLevelsFromDict()) return (1); + if(m_helper->initialize_from_dictionary(dict_mgr)) return (1); - // - // Build multirange for the valid set of identifiers - // + // Initialize level indices and id values from dicts + if(initLevelsFromDict(dict_mgr)) return (1); + m_is_initialized_from_dict = true; - // Find value for the field Scintillator - const IdDictDictionary* faserDict = dict_mgr.find_dictionary ("FASER"); - int scintField = -1; - if (faserDict->get_label_value("subdet", "Scintillator", scintField)) { - log << MSG::ERROR << "Could not get value for label 'Scintillator' of field 'subdet' in dictionary " - << faserDict->m_name - << endmsg; - return (1); + if (!m_quiet) { + if(m_msgSvc) { + MsgStream log(m_msgSvc, "FaserDetectorID" ); + log << MSG::INFO << "initialize_from_dictionary - OK" << endmsg; + } + else { + std::cout << " FaserDetectorID::initialize_from_dictionary - OK " << std::endl; + } } + + return (0); +} - // Find value for the field Veto - int vetoField = -1; - if (m_dict->get_label_value("part", "Veto", vetoField)) { - log << MSG::ERROR << "Could not get value for label 'Veto' of field 'part' in dictionary " - << m_dict->m_name - << endmsg; - return (1); + +std::string +FaserDetectorID::dictionaryVersion (void) const +{ + return (m_dict_version); +} + +bool +FaserDetectorID::is_scint (const ExpandedIdentifier& id) const +{ + bool result = false; + if ( id.fields() > 0 ){ + if ( id[0] == m_SCINT_ID) result = true; } - if (m_msgSvc) { - log << MSG::DEBUG << " VetoID::initialize_from_dict " - << "Found field values: Veto " - << vetoField - << std::endl; + return result; +} + +bool +FaserDetectorID::is_tracker (const ExpandedIdentifier& id) const +{ + bool result = false; + if ( id.fields() > 0 ){ + if ( id[0] == m_TRACKER_ID) result = true; } - else { - std::cout << " DEBUG VetoID::initialize_from_dict " - << "Found field values: Veto " - << vetoField - << std::endl; + return result; +} + +bool +FaserDetectorID::is_calo (const ExpandedIdentifier& id) const +{ + bool result = false; + if ( id.fields() > 0 ){ + if ( id[0] == m_CALO_ID ) result = true; } - - // Set up id for region and range prefix - ExpandedIdentifier region_id; - region_id.add(scintField); - region_id.add(vetoField); - Range prefix; - m_full_plate_range = m_dict->build_multirange(region_id, prefix, "plate"); - m_full_pmt_range = m_dict->build_multirange(region_id, prefix); + return result; +} - - if (m_msgSvc) { - log << MSG::INFO << " VetoID::initialize_from_dict " << endmsg; - log << MSG::DEBUG - << "Plate range -> " << (std::string)m_full_plate_range - << endmsg; - log << MSG::DEBUG - << "Pmt range -> " << (std::string)m_full_pmt_range - << endmsg; +bool +FaserDetectorID::is_veto (const ExpandedIdentifier& id) const +{ + bool result = false; + if ( is_scint(id) && id.fields() > 1 ){ + if ( id[1] == m_VETO_ID ) result = true; + } + return result; +} + +bool +FaserDetectorID::is_trigger (const ExpandedIdentifier& id) const +{ + bool result = false; + if ( is_scint(id) && id.fields() > 1 ){ + if ( id[1] == m_TRIGGER_ID ) return(true); + } + return result; +} + +bool +FaserDetectorID::is_preshower (const ExpandedIdentifier& id) const +{ + bool result = false; + if ( is_scint(id) && id.fields() > 1 ){ + if ( id[1] == m_PRESHOWER_ID ) result = true; + } + return result; +} + +bool +FaserDetectorID::is_sct (const ExpandedIdentifier& id) const +{ + bool result = false; + if ( is_tracker(id) && id.fields() > 1 ){ + if ( id[1] == m_SCT_ID ) result = true; + } + return result; +} + +bool +FaserDetectorID::is_ecal (const ExpandedIdentifier& id) const +{ + bool result = false; + if ( is_calo(id) && id.fields() > 1 ){ + if ( id[1] == m_ECAL_ID ) result = true; + } + return result; +} + +// Short print out of any identifier: +void +FaserDetectorID::show (Identifier id, + const IdContext* context, + char sep ) const +{ + if(m_msgSvc) { + MsgStream log(m_msgSvc, "FaserDetectorID" ); + log << MSG::INFO << show_to_string(id, context, sep) << endmsg; } else { - std::cout << " INFO VetoID::initialize_from_dict " << std::endl; - std::cout << " DEBUG Plate range -> " << (std::string)m_full_plate_range - << std::endl; - std::cout << " DEBUG Pmt range -> " << (std::string)m_full_pmt_range - << std::endl; + std::cout << show_to_string(id, context, sep) << std::endl; } - - return 0; } -int -FaserDetectorID::initLevelsFromDict() +// or provide the printout in string form +std::string +FaserDetectorID::show_to_string (Identifier id, + const IdContext* context, + char sep ) const { + // Do a generic printout of identifier + std::string result("Unable to decode id"); + unsigned int max_index = (context) ? context->end_index() : 999; - MsgStream log(m_msgSvc, "FaserDetectorID"); - if(!m_dict) { - log << MSG::ERROR << " FaserDetectorID::initLevelsFromDict - dictionary NOT initialized " << endmsg; - return (1); + if (!m_is_initialized_from_dict) return (result); + + // Find the dictionary to use: + IdDictDictionary* dict = 0; + ExpandedIdentifier expId; + ExpandedIdentifier prefix; // default is null prefix + Identifier compact = id; + + if (is_scint(id)) { + dict = m_scint_dict; + } + else if (is_tracker(id)) { + dict = m_tracker_dict; + } + else if (is_calo(id)) { + dict = m_calo_dict; } - - // Find out which identifier field corresponds to each level. Use - // names to find each field/leve. - - m_SUBDET_INDEX = 999; - m_PART_INDEX = 999; - m_STATION_INDEX = 999; - m_PLANE_INDEX = 999; - m_MODULE_INDEX = 999; - m_SUBMODULE_INDEX = 999; - m_SENSOR_INDEX = 999; - - // Save index to a Veto region for unpacking - ExpandedIdentifier id; - id << scint_field_value() << veto_field_value(); - if (m_dict->find_region(id, m_veto_region_index)) { - log << MSG::ERROR << "FaserDetectorID::initLevelsFromDict - unable to find veto region index: id, reg " - << (std::string)id << " " << m_veto_region_index - << endmsg; - return (1); + if (!dict) return (result); + + if (dict->unpack(compact, + prefix, + max_index, + expId)) { + return (result); } - // Find a Vetp region - IdDictField* field = m_dict->find_field("subdet"); - if (field) { - m_SCINT_INDEX = field->m_index; + bool first = true; + char temp[20]; + + result = ""; + if ('.' == sep) result = "["; + for (unsigned int i = 0; i < expId.fields(); ++i) { + if (first) first = false; + else result += sep; + sprintf (temp, "%d", expId[i]); + result += temp; + } + if ('.' == sep) result += "]"; + +// result += " compact ["; +// sprintf (temp, "0x%x", (unsigned int)compact); +// result += temp; +// result += "]"; + + return (result); +} + + + +void +FaserDetectorID::print (Identifier id, + const IdContext* context) const +{ + if(m_msgSvc) { + MsgStream log(m_msgSvc, "FaserDetectorID" ); + log << MSG::INFO << print_to_string(id, context) << endmsg; } else { - log << MSG::ERROR << "VetoID::initLevelsFromDict - unable to find 'subdet' field " << endmsg; - return (1); + std::cout << print_to_string(id, context) << std::endl; } - field = m_dict->find_field("part"); - if (field) { - m_VETO_INDEX = field->m_index; +} + +std::string +FaserDetectorID::print_to_string (Identifier id, + const IdContext* context) const +{ + // Print out for any Faser identifier + std::string result; + if (m_is_initialized_from_dict) { + + // Do a generic printout of identifier from dictionary + unsigned int max_index = (context) ? context->end_index() : 999; + + // Find the dictionary to use: + IdDictDictionary* dict = 0; + ExpandedIdentifier expId; + ExpandedIdentifier prefix; // default is null prefix + Identifier compact = id; + + if (is_scint(id)) { + dict = m_scint_dict; + } + else if (is_tracker(id)) { + dict = m_tracker_dict; + } + else if (is_calo(id)) { + dict = m_calo_dict; + } + + if (!dict) return (result); + + if (dict->unpack(compact, + prefix, + max_index, + " ", + result)) { + return (result); + } + } + return (result); +} + +/// Dictionary name +std::vector<std::string> +FaserDetectorID::dict_names (void) const +{ + return (m_dict_names); +} + +/// File name +std::vector<std::string> +FaserDetectorID::file_names (void) const +{ + return (m_file_names); +} + +/// Version tag for subdet dictionary +std::vector<std::string> +FaserDetectorID::dict_tags (void) const +{ + return (m_dict_tags); +} + +bool +FaserDetectorID::do_checks (void) const +{ + return (m_do_checks); +} + +void +FaserDetectorID::set_do_checks (bool do_checks) +{ + m_do_checks = do_checks; +} + +bool +FaserDetectorID::do_neighbours (void) const +{ + return (m_do_neighbours); +} + +void +FaserDetectorID::set_do_neighbours (bool do_neighbours) +{ + m_do_neighbours = do_neighbours; +} + +void +FaserDetectorID::setMessageSvc (IMessageSvc* msgSvc) +{ + m_msgSvc = msgSvc ; +} + +void +FaserDetectorID::set_quiet (bool quiet) +{ + m_quiet = quiet ; +} + +void +FaserDetectorID::setDictVersion (const IdDictMgr& dict_mgr, const std::string& name) +{ + const IdDictDictionary* dict = dict_mgr.find_dictionary (name); + + m_dict_version = dict->m_version; +} + +std::string +FaserDetectorID::to_range (const ExpandedIdentifier& id) const +{ + + // Build a string from the contents of an identifier + + int fields = id.fields(); + char temp[10] = ""; + std::string result(""); + + for (int i = 0; i < fields; ++i) { + sprintf( temp, "%d", id[i]); + if (i > 0) result += '/'; // add '/' only if NOT last one + result += temp; + } + + return result; +} + +int +FaserDetectorID::initLevelsFromDict(const IdDictMgr& dict_mgr) +{ + + // Set do_checks flag + if (dict_mgr.do_checks()) m_do_checks = true; + // Set do_neighbours flag + if (!dict_mgr.do_neighbours()) m_do_neighbours = false; + + IdDictLabel* label = 0; + IdDictField* field = 0; + + // Find out from the dictionary the detector and subdetector + // levels and id values + m_DET_INDEX = 999; + m_SUBDET_INDEX = 999; + m_SCINT_ID = -1; + m_TRACKER_ID = -1; + m_CALO_ID = -1; + m_VETO_ID = -1; + m_TRIGGER_ID = -1; + m_PRESHOWER_ID = -1; + m_SCT_ID = -1; + m_ECAL_ID = -1; + + // Save generic dict for top levels + IdDictDictionary* top_dict = 0; + + // Get det ids + + // Initialize ids for InDet subdet + m_scint_dict = dict_mgr.find_dictionary ("Scintillator"); + if(!m_scint_dict) { + if(m_msgSvc) { + MsgStream log(m_msgSvc, "FaserDetectorID" ); + log << MSG::WARNING << "initLevelsFromDict - cannot access Scintillator dictionary" << endmsg; + } + else { + std::cout << " FaserDetectorID::initLevelsFromDict - Warning cannot access Scintillator dictionary " + << std::endl; + } } else { - log << MSG::ERROR << "VetoID::initLevelsFromDict - unable to find 'part' field " << endmsg; - return (1); + + // Found Scint dict + + top_dict = m_scint_dict; // save as top_dict + + // Check if this is SLHC layout + m_isSLHC = (m_scint_dict->m_version=="SLHC"); + + // Get Scint subdets + + field = m_scint_dict->find_field("part"); + if (!field) { + if(m_msgSvc) { + MsgStream log(m_msgSvc, "FaserDetectorID" ); + log << MSG::ERROR << "initLevelsFromDict - unable to find 'part' field for Scintillator dictionary" << endmsg; + } + else { + std::cout << "FaserDetectorID::initLevelsFromDict - unable to find 'part' field for Scintillator dictionary" + << std::endl; + } + return (1); + } + + label = field->find_label("Veto"); + if (label) { + if (label->m_valued) { + m_VETO_ID = label->m_value; + } + else { + if(m_msgSvc) { + MsgStream log(m_msgSvc, "FaserDetectorID" ); + log << MSG::ERROR << "initLevelsFromDict - label Veto does NOT have a value " + << endmsg; + } + else { + std::cout << "FaserDetectorID::initLevelsFromDict - label Veto does NOT have a value " + << std::endl; + } + return (1); + } + } + else { + if(m_msgSvc) { + MsgStream log(m_msgSvc, "FaserDetectorID" ); + log << MSG::ERROR << "initLevelsFromDict - unable to find 'Veto' label " + << endmsg; + } + else { + std::cout << "FaserDetectorID::initLevelsFromDict - unable to find 'Veto' label " + << std::endl; + } + return (1); + } + + label = field->find_label("Trigger"); + if (label) { + if (label->m_valued) { + m_TRIGGER_ID = label->m_value; + } + else { + if(m_msgSvc) { + MsgStream log(m_msgSvc, "FaserDetectorID" ); + log << MSG::ERROR << "initLevelsFromDict - label Trigger does NOT have a value " + << endmsg; + } + else { + std::cout << "FaserDetectorID::initLevelsFromDict - label Trigger does NOT have a value " + << std::endl; + } + return (1); + } + } + else { + if(m_msgSvc) { + MsgStream log(m_msgSvc, "FaserDetectorID" ); + log << MSG::ERROR << "initLevelsFromDict - unable to find 'Trigger' label " + << endmsg; + } + else { + std::cout << "FaserDetectorID::initLevelsFromDict - unable to find 'Trigger' label " + << std::endl; + } + return (1); + } + + label = field->find_label("Preshower"); + if (label) { + if (label->m_valued) { + m_PRESHOWER_ID = label->m_value; + } + else { + if(m_msgSvc) { + MsgStream log(m_msgSvc, "FaserDetectorID" ); + log << MSG::ERROR << "initLevelsFromDict - label Preshower does NOT have a value " + << endmsg; + } + else { + std::cout << "FaserDetectorID::initLevelsFromDict - label Preshower does NOT have a value " + << std::endl; + } + return (1); + } + } + else { + if(m_msgSvc) { + MsgStream log(m_msgSvc, "FaserDetectorID" ); + log << MSG::ERROR << "initLevelsFromDict - unable to find 'Preshower' label " + << endmsg; + } + else { + std::cout << "FaserDetectorID::initLevelsFromDict - unable to find 'Preshower' label " + << std::endl; + } + return (1); + } + } - field = m_dict->find_field("station"); - if (field) { - m_STATION_INDEX = field->m_index; + + // Initialize ids for Tracker + m_tracker_dict = dict_mgr.find_dictionary ("Tracker"); + if(!m_tracker_dict) { + if(m_msgSvc) { + MsgStream log(m_msgSvc, "FaserDetectorID" ); + log << MSG::WARNING << "initLevelsFromDict - cannot access Tracker dictionary " + << endmsg; + } + else { + std::cout << " FaserDetectorID::initLevelsFromDict - Warning cannot access Tracker dictionary " + << std::endl; + } } else { - log << MSG::ERROR << "VetoID::initLevelsFromDict - unable to find 'station' field " << endmsg; - return (1); + // Found Tracker dict + + if (!top_dict) top_dict = m_tracker_dict; // save as top_dict + + field = m_tracker_dict->find_field("part"); + if (!field) { + if(m_msgSvc) { + MsgStream log(m_msgSvc, "FaserDetectorID" ); + log << MSG::ERROR << "initLevelsFromDict - unable to find 'station' field for Tracker dictionary" + << endmsg; + } + else { + std::cout << "FaserDetectorID::initLevelsFromDict - unable to find 'station' field for Tracker dictionary" + << std::endl; + } + return (1); + } + + label = field->find_label("SCT"); + if (label) { + if (label->m_valued) { + m_SCT_ID = label->m_value; + } + else { + if(m_msgSvc) { + MsgStream log(m_msgSvc, "FaserDetectorID" ); + log << MSG::ERROR << "initLevelsFromDict - label SCT does NOT have a value " + << endmsg; + } + else { + std::cout << "FaserDetectorID::initLevelsFromDict - label SCT does NOT have a value " + << std::endl; + } + return (1); + } + } + else { + if(m_msgSvc) { + MsgStream log(m_msgSvc, "FaserDetectorID" ); + log << MSG::ERROR << "initLevelsFromDict - unable to find 'SCT' label " + << endmsg; + } + else { + std::cout << "FaserDetectorID::initLevelsFromDict - unable to find 'SCT' label " + << std::endl; + } + return (1); + } } - field = m_dict->find_field("plate"); - if (field) { - m_PLATE_INDEX = field->m_index; + + // Initialize id for Calo and fields for lvl1 and dead material + m_calo_dict = dict_mgr.find_dictionary ("Calorimeter"); + if(!m_calo_dict) { + if(m_msgSvc) { + MsgStream log(m_msgSvc, "FaserDetectorID" ); + log << MSG::ERROR << "initLevelsFromDict - Warning cannot access Calorimeter dictionary " + << endmsg; + } + else { + std::cout << " FaserDetectorID::initLevelsFromDict - Warning cannot access Calorimeter dictionary " + << std::endl; + } } else { - log << MSG::ERROR << "VetoID::initLevelsFromDict - unable to find 'plate' field " << endmsg; - return (1); + // Found calo dict + if (!top_dict) top_dict = m_calo_dict; // save as top_dict + + // Get Scint subdets + field = m_calo_dict->find_field("part"); + if (!field) { + if(m_msgSvc) { + MsgStream log(m_msgSvc, "FaserDetectorID" ); + log << MSG::ERROR << "initLevelsFromDict - unable to find 'part' field for Calorimeter dictionary" << endmsg; + } + else { + std::cout << "FaserDetectorID::initLevelsFromDict - unable to find 'part' field for Calorimeter dictionary" + << std::endl; + } + return (1); + } + + label = field->find_label("ECAL"); + if (label) { + if (label->m_valued) { + m_ECAL_ID = label->m_value; + } + else { + if(m_msgSvc) { + MsgStream log(m_msgSvc, "FaserDetectorID" ); + log << MSG::ERROR << "initLevelsFromDict - label ECAL does NOT have a value " + << endmsg; + } + else { + std::cout << "FaserDetectorID::initLevelsFromDict - label ECAL does NOT have a value " + << std::endl; + } + return (1); + } + } + else { + if(m_msgSvc) { + MsgStream log(m_msgSvc, "FaserDetectorID" ); + log << MSG::ERROR << "initLevelsFromDict - unable to find 'ECAL' label " + << endmsg; + } + else { + std::cout << "FaserDetectorID::initLevelsFromDict - unable to find 'ECAL' label " + << std::endl; + } + return (1); + } } - field = m_dict->find_field("pmt"); - if (field) { - m_PMT_INDEX = field->m_index; + + // set det/subdet indices + if (top_dict) { + field = top_dict->find_field("subdet"); + if (field) { + m_DET_INDEX = field->m_index; + } + else { + if(m_msgSvc) { + MsgStream log(m_msgSvc, "FaserDetectorID" ); + log << MSG::ERROR << "initLevelsFromDict - - unable to find 'subdet' field from dict " + << endmsg; + } + else { + std::cout << "FaserDetectorID::initLevelsFromDict - unable to find 'subdet' field from dict " + << top_dict->m_name + << std::endl; + } + return (1); + } + + // Get scint id + label = field->find_label("Scintillator"); + if (label) { + if (label->m_valued) { + m_SCINT_ID = label->m_value; + } + else { + if(m_msgSvc) { + MsgStream log(m_msgSvc, "FaserDetectorID" ); + log << MSG::ERROR << "initLevelsFromDict - label Scintillator does NOT have a value " + << endmsg; + } + else { + std::cout << "FaserDetectorID::initLevelsFromDict - label Scintillator does NOT have a value " + << std::endl; + } + return (1); + } + } + else { + if(m_msgSvc) { + MsgStream log(m_msgSvc, "FaserDetectorID" ); + log << MSG::ERROR << "initLevelsFromDict - unable to find 'Scintillator' label " + << endmsg; + } + else { + std::cout << "FaserDetectorID::initLevelsFromDict - unable to find 'Scintillator' label " + << std::endl; + } + return (1); + } + + // Get Tracker id + label = field->find_label("Tracker"); + if (label) { + if (label->m_valued) { + m_TRACKER_ID = label->m_value; + } + else { + if(m_msgSvc) { + MsgStream log(m_msgSvc, "FaserDetectorID" ); + log << MSG::ERROR << "initLevelsFromDict - label Tracker does NOT have a value " + << endmsg; + } + else { + std::cout << "FaserDetectorID::initLevelsFromDict - label Tracker does NOT have a value " + << std::endl; + } + return (1); + } + } + else { + if(m_msgSvc) { + MsgStream log(m_msgSvc, "FaserDetectorID" ); + log << MSG::ERROR << "initLevelsFromDict - unable to find 'Tracker' label " + << endmsg; + } + else { + std::cout << "FaserDetectorID::initLevelsFromDict - unable to find 'Tracker' label " + << std::endl; + } + return (1); + } + + // Get Calo id + label = field->find_label("Calorimeter"); + if (label) { + if (label->m_valued) { + m_CALO_ID = label->m_value; + } + else { + if(m_msgSvc) { + MsgStream log(m_msgSvc, "FaserDetectorID" ); + log << MSG::ERROR << "initLevelsFromDict - label Calorimeter does NOT have a value " + << endmsg; + } + else { + std::cout << "FaserDetectorID::initLevelsFromDict - label Calorimeter does NOT have a value " + << std::endl; + } + return (1); + } + } + else { + if(m_msgSvc) { + MsgStream log(m_msgSvc, "FaserDetectorID" ); + log << MSG::ERROR << "initLevelsFromDict - unable to find 'Calorimeter' label " + << endmsg; + } + else { + std::cout << "FaserDetectorID::initLevelsFromDict - unable to find 'Calorimeter' label " + << std::endl; + } + return (1); + } + + // Get name of next level + std::string name; + if (top_dict->m_name == "Scintillator") { + name = "part"; + } + else if (top_dict->m_name == "Calorimeter") { + name = "part"; + } + else if (top_dict->m_name == "Tracker") { + name = "part"; + } + + // While we're here, save the index to the sub-detector level + // ("part" for InDet) + field = top_dict->find_field(name); + if (field) { + m_SUBDET_INDEX = field->m_index; + } + else { + if(m_msgSvc) { + MsgStream log(m_msgSvc, "FaserDetectorID" ); + log << MSG::ERROR << "initLevelsFromDict - unable to find field " + << name << " from dict " + << top_dict->m_name + << endmsg; + } + else { + std::cout << "FaserDetectorID::initLevelsFromDict - unable to find field " + << name << " from dict " + << top_dict->m_name + << std::endl; + } + return (1); + } } else { - log << MSG::ERROR<< "VetoID::initLevelsFromDict - unable to find 'pmt' field " << endmsg; + if(m_msgSvc) { + MsgStream log(m_msgSvc, "FaserDetectorID" ); + log << MSG::ERROR << "initLevelsFromDict - no top dictionary defined " + << endmsg; + } + else { + std::cout << "FaserDetectorID::initLevelsFromDict - no top dictionary defined " + << std::endl; + } return (1); } - - // Set the field implementations: for station, plate, pmt - const IdDictRegion& region = *m_dict->m_regions[m_veto_region_index]; - m_scint_impl = region.m_implementation[m_SCINT_INDEX]; - m_veto_impl = region.m_implementation[m_VETO_INDEX]; - m_station_impl = region.m_implementation[m_STATION_INDEX]; - m_plate_impl = region.m_implementation[m_PLATE_INDEX]; - m_pmt_impl = region.m_implementation[m_PMT_INDEX]; + // Set the field implementations - if (m_msgSvc) { - log << MSG::DEBUG << "decode index and bit fields for each level: " << endmsg; - log << MSG::DEBUG << "scint " << m_scint_impl.show_to_string() << endmsg; - log << MSG::DEBUG << "veto " << m_veto_impl.show_to_string() << endmsg; - log << MSG::DEBUG << "station " << m_station_impl.show_to_string() << endmsg; - log << MSG::DEBUG << "plate " << m_plate_impl.show_to_string() << endmsg; - log << MSG::DEBUG << "pmt " << m_pmt_impl.show_to_string() << endmsg; + const IdDictRegion* region = 0; + size_type region_index = m_helper->veto_region_index(); + if (m_scint_dict && FaserDetectorIDHelper::UNDEFINED != region_index) { + region = m_scint_dict->m_regions[region_index]; + // Detector + m_det_impl = region->m_implementation[m_DET_INDEX]; + // InDet part + m_scint_part_impl = region->m_implementation[m_SUBDET_INDEX]; } - else { - std::cout << " DEBUG decode index and bit fields for each level: " << std::endl; - std::cout << " DEBUG scint " << m_scint_impl.show_to_string() << std::endl; - std::cout << " DEBUG veto " << m_veto_impl.show_to_string() << std::endl; - std::cout << " DEBUG station " << m_station_impl.show_to_string() << std::endl; - std::cout << " DEBUG plate " << m_plate_impl.show_to_string() << std::endl; - std::cout << " DEBUG pmt " << m_pmt_impl.show_to_string() << std::endl; + + region_index = m_helper->sct_region_index(); + if (m_tracker_dict && FaserDetectorIDHelper::UNDEFINED != region_index) { + region = m_tracker_dict->m_regions[region_index]; + // Detector + m_det_impl = region->m_implementation[m_DET_INDEX]; + // InDet part + m_tracker_part_impl = region->m_implementation[m_SUBDET_INDEX]; + } + + region_index = m_helper->ecal_region_index(); + if (m_calo_dict && FaserDetectorIDHelper::UNDEFINED != region_index) { + region = m_calo_dict->m_regions[region_index]; + // Detector + m_det_impl = region->m_implementation[m_DET_INDEX]; + // InDet part + m_calo_part_impl = region->m_implementation[m_SUBDET_INDEX]; } - -// 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 << "scint " << m_scint_impl.decode_index() << " " - << (std::string)m_scint_impl.ored_field() << " " - << std::hex << m_scint_impl.mask() << " " - << m_scint_impl.zeroing_mask() << " " - << std::dec << m_scint_impl.shift() << " " - << m_scint_impl.bits() << " " - << m_scint_impl.bits_offset() - << std::endl; - std::cout << "veto" << m_veto_impl.decode_index() << " " - << (std::string)m_veto_impl.ored_field() << " " - << std::hex << m_veto_impl.mask() << " " - << m_veto_impl.zeroing_mask() << " " - << std::dec << m_veto_impl.shift() << " " - << m_veto_impl.bits() << " " - << m_veto_impl.bits_offset() - << std::endl; - std::cout << "station" << m_station_impl.decode_index() << " " - << (std::string)m_station_impl.ored_field() << " " - << std::hex << m_station_impl.mask() << " " - << m_station_impl.zeroing_mask() << " " - << std::dec << m_station_impl.shift() << " " - << m_station_impl.bits() << " " - << m_station_impl.bits_offset() - << std::endl; - std::cout << "plate"<< m_plate_impl.decode_index() << " " - << (std::string)m_plate_impl.ored_field() << " " - << std::hex << m_plate_impl.mask() << " " - << m_plate_impl.zeroing_mask() << " " - << std::dec << m_plate_impl.shift() << " " - << m_plate_impl.bits() << " " - << m_plate_impl.bits_offset() - << std::endl; - std::cout << "pmt" << m_pmt_impl.decode_index() << " " - << (std::string)m_pmt_impl.ored_field() << " " - << std::hex << m_pmt_impl.mask() << " " - << m_pmt_impl.zeroing_mask() << " " - << std::dec << m_pmt_impl.shift() << " " - << m_pmt_impl.bits() << " " - << m_pmt_impl.bits_offset() - << std::endl; return (0); } - diff --git a/DetectorDescription/FaserDetDescr/src/FaserDetectorID.cxxOld b/DetectorDescription/FaserDetDescr/src/FaserDetectorID.cxxOld new file mode 100644 index 000000000..29b4ff691 --- /dev/null +++ b/DetectorDescription/FaserDetDescr/src/FaserDetectorID.cxxOld @@ -0,0 +1,363 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +/*************************************************************************** + Scintillator identifier package + ------------------------------------------- +***************************************************************************/ + +//<<<<<< INCLUDES >>>>>> +#include "GaudiKernel/MsgStream.h" + +#include "FaserDetDescr/FaserDetectorID.h" +#include "Identifier/IdentifierHash.h" +#include "IdDict/IdDictDefs.h" +#include <set> +#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 >>>>>> + + +///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// + + +FaserDetectorID::FaserDetectorID(void) + : + m_faser_region_index(0), + m_SUBDET_INDEX(0), + m_PART_INDEX(1), + m_STATION_INDEX(2), + m_PLANE_INDEX(3), + m_MODULE_INDEX(4), + m_SUBMODULE_INDEX(5), + m_SENSOR_INDEX(6), + m_dict(0), + m_submodule_hash_max(0), + m_sensor_hash_max(0) +{ +} + +int +FaserDetectorID::init_hashes(void) +{ + + // + // create a vector(s) to retrieve the hashes for compact ids. For + // the moment, we implement a hash for submodules but NOT for sensors + // + MsgStream log(m_msgSvc, "FaserDetectorID"); + // wafer hash + m_submodule_hash_max = m_full_submodule_range.cardinality(); + m_submodule_vec.resize(m_submodule_hash_max); + unsigned int nids = 0; + std::set<Identifier> ids; + for (unsigned int i = 0; i < m_full_submodule_range.size(); ++i) { + const Range& range = m_full_submodule_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); + Identifier id = submodule_id(exp_id[m_STATION_INDEX], + exp_id[m_PLANE_INDEX], + exp_id[m_MODULE_INDEX], + exp_id[m_SUBMODULE_INDEX]); + if(!(ids.insert(id)).second) { + log << MSG::ERROR << " FaserDetectorID::init_hashes " + << " Error: duplicated id for plate id. nid " << nids + << " compact id " << id.getString() + << " id " << (std::string)exp_id << endmsg; + return (1); + } + nids++; + } + } + if(ids.size() != m_submodule_hash_max) { + log << MSG::ERROR << " FaserDetectorID::init_hashes " + << " Error: set size NOT EQUAL to hash max. size " << ids.size() + << " hash max " << m_submodule_hash_max + << endmsg; + return (1); + } + + nids = 0; + std::set<Identifier>::const_iterator first = ids.begin(); + std::set<Identifier>::const_iterator last = ids.end(); + for (; first != last && nids < m_submodule_vec.size(); ++first) { + m_submodule_vec[nids] = (*first); + nids++; + } + + // sensor hash - we do not keep a vec for the sensors + m_sensor_hash_max = m_full_sensor_range.cardinality(); + + return (0); +} + + +int +FaserDetectorID::initialize_from_dictionary(const IdDictMgr& dict_mgr) +{ + MsgStream log(m_msgSvc, "FaserDetectorID"); + log << MSG::INFO << "Initialize from dictionary" << endmsg; + + // Check whether this helper should be reinitialized + if (!reinitialize(dict_mgr)) { + log << MSG::INFO << "Request to reinitialize not satisfied - tags have not changed" << endmsg; + return (0); + } + else { + if (m_msgSvc) { + log << MSG::DEBUG << "(Re)initialize" << endmsg; + } + else { + std::cout << " DEBUG (Re)initialize" << std::endl; + } + } + + // init base object + if(FaserDetectorIDBase::initialize_from_dictionary(dict_mgr)) return (1); + + // Register version of InnerDetector dictionary + if (register_dict_tag(dict_mgr, "Scintillator")) return(1); + + m_dict = dict_mgr.find_dictionary ("Scintillator"); + if(!m_dict) { + log << MSG::ERROR << " FaserDetectorID::initialize_from_dict - cannot access Scintillator dictionary " << endmsg; + return 1; + } + + // Initialize the field indices + if(initLevelsFromDict()) return (1); + + // + // Build multirange for the valid set of identifiers + // + + + // Find value for the field Scintillator + const IdDictDictionary* faserDict = dict_mgr.find_dictionary ("FASER"); + int scintField = -1; + if (faserDict->get_label_value("subdet", "Scintillator", scintField)) { + log << MSG::ERROR << "Could not get value for label 'Scintillator' of field 'subdet' in dictionary " + << faserDict->m_name + << endmsg; + return (1); + } + + // Find value for the field Veto + int vetoField = -1; + if (m_dict->get_label_value("part", "Veto", vetoField)) { + log << MSG::ERROR << "Could not get value for label 'Veto' of field 'part' in dictionary " + << m_dict->m_name + << endmsg; + return (1); + } + if (m_msgSvc) { + log << MSG::DEBUG << " VetoID::initialize_from_dict " + << "Found field values: Veto " + << vetoField + << std::endl; + } + else { + std::cout << " DEBUG VetoID::initialize_from_dict " + << "Found field values: Veto " + << vetoField + << std::endl; + } + + // Set up id for region and range prefix + ExpandedIdentifier region_id; + region_id.add(scintField); + region_id.add(vetoField); + Range prefix; + m_full_plate_range = m_dict->build_multirange(region_id, prefix, "plate"); + m_full_pmt_range = m_dict->build_multirange(region_id, prefix); + + + if (m_msgSvc) { + log << MSG::INFO << " VetoID::initialize_from_dict " << endmsg; + log << MSG::DEBUG + << "Plate range -> " << (std::string)m_full_plate_range + << endmsg; + log << MSG::DEBUG + << "Pmt range -> " << (std::string)m_full_pmt_range + << endmsg; + } + else { + std::cout << " INFO VetoID::initialize_from_dict " << std::endl; + std::cout << " DEBUG Plate range -> " << (std::string)m_full_plate_range + << std::endl; + std::cout << " DEBUG Pmt range -> " << (std::string)m_full_pmt_range + << std::endl; + } + + return 0; +} + +int +FaserDetectorID::initLevelsFromDict() +{ + + + MsgStream log(m_msgSvc, "FaserDetectorID"); + if(!m_dict) { + log << MSG::ERROR << " FaserDetectorID::initLevelsFromDict - dictionary NOT initialized " << endmsg; + return (1); + } + + // Find out which identifier field corresponds to each level. Use + // names to find each field/leve. + + m_SUBDET_INDEX = 999; + m_PART_INDEX = 999; + m_STATION_INDEX = 999; + m_PLANE_INDEX = 999; + m_MODULE_INDEX = 999; + m_SUBMODULE_INDEX = 999; + m_SENSOR_INDEX = 999; + + + // Save index to a Veto region for unpacking + ExpandedIdentifier id; + id << scint_field_value() << veto_field_value(); + if (m_dict->find_region(id, m_veto_region_index)) { + log << MSG::ERROR << "FaserDetectorID::initLevelsFromDict - unable to find veto region index: id, reg " + << (std::string)id << " " << m_veto_region_index + << endmsg; + return (1); + } + + // Find a Vetp region + IdDictField* field = m_dict->find_field("subdet"); + if (field) { + m_SCINT_INDEX = field->m_index; + } + else { + log << MSG::ERROR << "VetoID::initLevelsFromDict - unable to find 'subdet' field " << endmsg; + return (1); + } + field = m_dict->find_field("part"); + if (field) { + m_VETO_INDEX = field->m_index; + } + else { + log << MSG::ERROR << "VetoID::initLevelsFromDict - unable to find 'part' field " << endmsg; + return (1); + } + field = m_dict->find_field("station"); + if (field) { + m_STATION_INDEX = field->m_index; + } + else { + log << MSG::ERROR << "VetoID::initLevelsFromDict - unable to find 'station' field " << endmsg; + return (1); + } + field = m_dict->find_field("plate"); + if (field) { + m_PLATE_INDEX = field->m_index; + } + else { + log << MSG::ERROR << "VetoID::initLevelsFromDict - unable to find 'plate' field " << endmsg; + return (1); + } + field = m_dict->find_field("pmt"); + if (field) { + m_PMT_INDEX = field->m_index; + } + else { + log << MSG::ERROR<< "VetoID::initLevelsFromDict - unable to find 'pmt' field " << endmsg; + return (1); + } + + // Set the field implementations: for station, plate, pmt + + const IdDictRegion& region = *m_dict->m_regions[m_veto_region_index]; + + m_scint_impl = region.m_implementation[m_SCINT_INDEX]; + m_veto_impl = region.m_implementation[m_VETO_INDEX]; + m_station_impl = region.m_implementation[m_STATION_INDEX]; + m_plate_impl = region.m_implementation[m_PLATE_INDEX]; + m_pmt_impl = region.m_implementation[m_PMT_INDEX]; + + if (m_msgSvc) { + log << MSG::DEBUG << "decode index and bit fields for each level: " << endmsg; + log << MSG::DEBUG << "scint " << m_scint_impl.show_to_string() << endmsg; + log << MSG::DEBUG << "veto " << m_veto_impl.show_to_string() << endmsg; + log << MSG::DEBUG << "station " << m_station_impl.show_to_string() << endmsg; + log << MSG::DEBUG << "plate " << m_plate_impl.show_to_string() << endmsg; + log << MSG::DEBUG << "pmt " << m_pmt_impl.show_to_string() << endmsg; + } + else { + std::cout << " DEBUG decode index and bit fields for each level: " << std::endl; + std::cout << " DEBUG scint " << m_scint_impl.show_to_string() << std::endl; + std::cout << " DEBUG veto " << m_veto_impl.show_to_string() << std::endl; + std::cout << " DEBUG station " << m_station_impl.show_to_string() << std::endl; + std::cout << " DEBUG plate " << m_plate_impl.show_to_string() << std::endl; + std::cout << " DEBUG pmt " << m_pmt_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 << "scint " << m_scint_impl.decode_index() << " " + << (std::string)m_scint_impl.ored_field() << " " + << std::hex << m_scint_impl.mask() << " " + << m_scint_impl.zeroing_mask() << " " + << std::dec << m_scint_impl.shift() << " " + << m_scint_impl.bits() << " " + << m_scint_impl.bits_offset() + << std::endl; + std::cout << "veto" << m_veto_impl.decode_index() << " " + << (std::string)m_veto_impl.ored_field() << " " + << std::hex << m_veto_impl.mask() << " " + << m_veto_impl.zeroing_mask() << " " + << std::dec << m_veto_impl.shift() << " " + << m_veto_impl.bits() << " " + << m_veto_impl.bits_offset() + << std::endl; + std::cout << "station" << m_station_impl.decode_index() << " " + << (std::string)m_station_impl.ored_field() << " " + << std::hex << m_station_impl.mask() << " " + << m_station_impl.zeroing_mask() << " " + << std::dec << m_station_impl.shift() << " " + << m_station_impl.bits() << " " + << m_station_impl.bits_offset() + << std::endl; + std::cout << "plate"<< m_plate_impl.decode_index() << " " + << (std::string)m_plate_impl.ored_field() << " " + << std::hex << m_plate_impl.mask() << " " + << m_plate_impl.zeroing_mask() << " " + << std::dec << m_plate_impl.shift() << " " + << m_plate_impl.bits() << " " + << m_plate_impl.bits_offset() + << std::endl; + std::cout << "pmt" << m_pmt_impl.decode_index() << " " + << (std::string)m_pmt_impl.ored_field() << " " + << std::hex << m_pmt_impl.mask() << " " + << m_pmt_impl.zeroing_mask() << " " + << std::dec << m_pmt_impl.shift() << " " + << m_pmt_impl.bits() << " " + << m_pmt_impl.bits_offset() + << std::endl; + return (0); +} + diff --git a/DetectorDescription/FaserDetDescr/src/FaserDetectorIDBase.cxx b/DetectorDescription/FaserDetDescr/src/FaserDetectorIDBase.cxx deleted file mode 100644 index fb2b3706e..000000000 --- a/DetectorDescription/FaserDetDescr/src/FaserDetectorIDBase.cxx +++ /dev/null @@ -1,1134 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -/*************************************************************************** - Detector Description - ----------------------------------------- -***************************************************************************/ - -//<<<<<< INCLUDES >>>>>> - -#include "GaudiKernel/MsgStream.h" -#include "FaserDetDescr/FaserDetectorIDBase.h" -#include "IdDict/IdDictDefs.h" -#include "FaserDetectorIDHelper.h" -#include <iostream> -#include <stdio.h> -#include <assert.h> - -//<<<<<< PRIVATE DEFINES >>>>>> -//<<<<<< PRIVATE CONSTANTS >>>>>> -//<<<<<< PRIVATE TYPES >>>>>> -//<<<<<< PRIVATE VARIABLE DEFINITIONS >>>>>> -//<<<<<< PUBLIC VARIABLE DEFINITIONS >>>>>> -//<<<<<< CLASS STRUCTURE INITIALIZATION >>>>>> -//<<<<<< PRIVATE FUNCTION DEFINITIONS >>>>>> -//<<<<<< PUBLIC FUNCTION DEFINITIONS >>>>>> -//<<<<<< MEMBER FUNCTION DEFINITIONS >>>>>> - -FaserDetectorIDBase::FaserDetectorIDBase() - : - m_do_checks(false), - m_do_neighbours(true), - m_msgSvc(0), - m_quiet(false), - m_is_initialized_from_dict(false), - m_DET_INDEX(999), - m_SUBDET_INDEX(999), - m_SCINT_ID(2), - m_TRACKER_ID(3), - m_CALO_ID(4), - m_VETO_ID(1), - m_TRIGGER_ID(2), - m_PRESHOWER_ID(3), - m_SCT_ID(1), - m_ECAL_ID(1), - m_isSLHC(false), - m_faser_dict(0), - m_scint_dict(0), - m_tracker_dict(0), - m_calo_dict(0), - m_helper(0) -{} - -FaserDetectorIDBase::~FaserDetectorIDBase(void) -{ - delete m_helper; -} - -FaserDetectorIDBase::FaserDetectorIDBase(const FaserDetectorIDBase& other) - : - IdHelper(), - m_do_checks (other.m_do_checks), - m_do_neighbours (other.m_do_neighbours), - m_msgSvc (other.m_msgSvc), - m_quiet (other.m_quiet), - m_dict_version (other.m_dict_version), - m_is_initialized_from_dict(other.m_is_initialized_from_dict), - m_DET_INDEX (other.m_DET_INDEX), - m_SUBDET_INDEX (other.m_SUBDET_INDEX), - m_SCINT_ID (other.m_SCINT_ID), - m_TRACKER_ID (other.m_TRACKER_ID), - m_CALO_ID (other.m_CALO_ID), - m_VETO_ID (other.m_VETO_ID), - m_TRIGGER_ID (other.m_TRIGGER_ID), - m_PRESHOWER_ID (other.m_PRESHOWER_ID), - m_SCT_ID (other.m_SCT_ID), - m_ECAL_ID (other.m_ECAL_ID), - m_isSLHC (other.m_isSLHC), - m_faser_dict (other.m_faser_dict), - m_scint_dict (other.m_scint_dict), - m_tracker_dict (other.m_tracker_dict), - m_calo_dict (other.m_calo_dict), - m_helper (0), - m_det_impl (other.m_det_impl), - m_scint_part_impl (other.m_scint_part_impl), - m_tracker_part_impl (other.m_tracker_part_impl), - m_calo_part_impl (other.m_calo_part_impl) - -{ - if (other.m_helper) { - // Must copy helper - m_helper = new FaserDetectorIDHelper(*other.m_helper); - m_helper->setMsgSvc(m_msgSvc); - } -} - -FaserDetectorIDBase& -FaserDetectorIDBase::operator= (const FaserDetectorIDBase& other) -{ - if (this != &other) { - m_do_checks = other.m_do_checks; - m_do_neighbours = other.m_do_neighbours; - m_msgSvc = other.m_msgSvc; - m_quiet = other.m_quiet; - m_dict_version = other.m_dict_version; - m_is_initialized_from_dict = other.m_is_initialized_from_dict; - m_DET_INDEX = other.m_DET_INDEX; - m_SUBDET_INDEX = other.m_SUBDET_INDEX; - m_SCINT_ID = other.m_SCINT_ID; - m_TRACKER_ID = other.m_TRACKER_ID; - m_CALO_ID = other.m_CALO_ID; - m_VETO_ID = other.m_VETO_ID; - m_TRIGGER_ID = other.m_TRIGGER_ID; - m_PRESHOWER_ID = other.m_PRESHOWER_ID; - m_SCT_ID = other.m_SCT_ID; - m_ECAL_ID = other.m_ECAL_ID; - m_faser_dict = other.m_faser_dict; - m_scint_dict = other.m_scint_dict; - m_tracker_dict = other.m_tracker_dict; - m_calo_dict = other.m_calo_dict; - m_det_impl = other.m_det_impl; - m_scint_part_impl = other.m_scint_part_impl; - m_tracker_part_impl = other.m_tracker_part_impl; - m_calo_part_impl = other.m_calo_part_impl; - - if (other.m_helper) { - // Must copy helper. - delete m_helper; - m_helper = new FaserDetectorIDHelper(*other.m_helper); - m_helper->setMsgSvc(m_msgSvc); - } - } - - return (*this); -} - - -Identifier -FaserDetectorIDBase::scint (void) const -{ - - Identifier result((Identifier::value_type)0); - // Pack field - m_det_impl.pack (scint_field_value(), result); - return (result); -} - -Identifier -FaserDetectorIDBase::tracker (void) const -{ - Identifier result((Identifier::value_type)0); - // Pack field - m_det_impl.pack (tracker_field_value(), result); - return (result); -} - -Identifier -FaserDetectorIDBase::calo(void) const -{ - Identifier result((Identifier::value_type)0); - // Pack field - m_det_impl.pack (calo_field_value(), result); - return (result); -} - - -Identifier -FaserDetectorIDBase::veto (void) const -{ - Identifier result((Identifier::value_type)0); - // Pack field - m_det_impl.pack (scint_field_value(), result); - m_scint_part_impl.pack(m_VETO_ID, result); - return (result); -} - -Identifier -FaserDetectorIDBase::trigger (void) const -{ - Identifier result((Identifier::value_type)0); - // Pack field - m_det_impl.pack (scint_field_value(), result); - m_scint_part_impl.pack(m_TRIGGER_ID, result); - return (result); -} - -Identifier -FaserDetectorIDBase::preshower (void) const -{ - Identifier result((Identifier::value_type)0); - // Pack field - m_det_impl.pack (scint_field_value(), result); - m_scint_part_impl.pack(m_PRESHOWER_ID, result); - return (result); -} - -Identifier -FaserDetectorIDBase::sct (void) const -{ - Identifier result((Identifier::value_type)0); - // Pack field - m_det_impl.pack (tracker_field_value(), result); - m_tracker_part_impl.pack(m_SCT_ID, result); - return (result); -} - -Identifier -FaserDetectorIDBase::ecal (void) const -{ - Identifier result((Identifier::value_type)0); - // Pack field - m_det_impl.pack (calo_field_value(), result); - m_calo_part_impl.pack(m_ECAL_ID, result); - return (result); -} - -/// IdContext (indicates id length) for detector systems -IdContext -FaserDetectorIDBase::detsystem_context (void) const -{ - ExpandedIdentifier id; - return (IdContext(id, 0, m_DET_INDEX)); -} - -/// IdContext (indicates id length) for sub-detector -IdContext -FaserDetectorIDBase::subdet_context (void) const -{ - ExpandedIdentifier id; - return (IdContext(id, 0, m_SUBDET_INDEX)); -} - - -int -FaserDetectorIDBase::get_id (const IdentifierHash& /*hash_id*/, - Identifier& /*id*/, - const IdContext* /*context*/) const -{ - return (0); -} - -int -FaserDetectorIDBase::get_hash (const Identifier& /*id*/, - IdentifierHash& /*hash_id*/, - const IdContext* /*context*/) const -{ - return (0); -} - -int -FaserDetectorIDBase::register_dict_tag (const IdDictMgr& dict_mgr, - const std::string& dict_name) -{ - // Register version of dictionary dict_name - - // Access dictionary by name - IdDictDictionary* dict = dict_mgr.find_dictionary(dict_name); - if (!dict) return(1); - // Add in dict name, file name and version - m_dict_names.push_back(dict_name); - m_file_names.push_back(dict->file_name()); - m_dict_tags.push_back(dict->dict_tag()); - return (0); -} - -/// Test whether an idhelper should be reinitialized based on the -/// change of tags -bool -FaserDetectorIDBase::reinitialize (const IdDictMgr& dict_mgr) -{ - // If no tag has been registered, then reinitialize - if (m_dict_tags.size() == 0) return (true); - - // If no dict names have been registered, then reinitialize - if (m_dict_names.size() == 0) return (true); - - // Loop over dict names and check version tags - if (m_dict_names.size() != m_dict_tags.size()) { - if(m_msgSvc) { - MsgStream log(m_msgSvc, "FaserDetectorIDBase" ); - log << MSG::ERROR << "reinitialize: dict names and tags vectors not the same length " << endmsg; - log << MSG::ERROR << "names: " << m_dict_names.size() << " tags: " << m_dict_tags.size() << endmsg; - } - else { - std::cout << MSG::ERROR << "reinitialize: dict names and tags vectors not the same length " << std::endl; - std::cout << "FaserDetectorIDBase::reinitialize ERROR names: " << m_dict_names.size() << " tags: " << m_dict_tags.size() << std::endl; - } - } - for (unsigned int i = 0; i < m_dict_names.size(); ++i) { - // Access dictionary by name - IdDictDictionary* dict = dict_mgr.find_dictionary(m_dict_names[i]); - if (!dict) { - if(m_msgSvc) { - MsgStream log(m_msgSvc, "FaserDetectorIDBase" ); - log << MSG::ERROR << "reinitialize: could not find dict - " << m_dict_names[i] << endmsg; - } - else { - std::cout << "FaserDetectorIDBase::reinitialize ERROR could not find dict - " << m_dict_names[i] << std::endl; - } - return(false); - } - if (m_dict_tags[i] != dict->dict_tag()) { - // Remove all memory of versions - m_dict_names.clear(); - m_dict_tags.clear(); - m_file_names.clear(); - return (true); - } - } - - // Tags match - don't reinitialize - return (false); -} - - - -int -FaserDetectorIDBase::initialize_from_dictionary(const IdDictMgr& dict_mgr) -{ - - // Register version of FASER dictionary - if (register_dict_tag(dict_mgr, "FASER")) return(1); - - // Initialize helper, needed for init of FaserDetectorIDBase - if(!m_helper) { - m_helper = new FaserDetectorIDHelper; - m_helper->setMsgSvc(m_msgSvc); - } - - if(m_helper->initialize_from_dictionary(dict_mgr)) return (1); - - // Initialize level indices and id values from dicts - if(initLevelsFromDict(dict_mgr)) return (1); - - m_is_initialized_from_dict = true; - - if (!m_quiet) { - if(m_msgSvc) { - MsgStream log(m_msgSvc, "FaserDetectorIDBase" ); - log << MSG::INFO << "initialize_from_dictionary - OK" << endmsg; - } - else { - std::cout << " FaserDetectorIDBase::initialize_from_dictionary - OK " << std::endl; - } - } - - return (0); -} - - -std::string -FaserDetectorIDBase::dictionaryVersion (void) const -{ - return (m_dict_version); -} - -bool -FaserDetectorIDBase::is_scint (const ExpandedIdentifier& id) const -{ - bool result = false; - if ( id.fields() > 0 ){ - if ( id[0] == m_SCINT_ID) result = true; - } - return result; -} - -bool -FaserDetectorIDBase::is_tracker (const ExpandedIdentifier& id) const -{ - bool result = false; - if ( id.fields() > 0 ){ - if ( id[0] == m_TRACKER_ID) result = true; - } - return result; -} - -bool -FaserDetectorIDBase::is_calo (const ExpandedIdentifier& id) const -{ - bool result = false; - if ( id.fields() > 0 ){ - if ( id[0] == m_CALO_ID ) result = true; - } - return result; -} - -bool -FaserDetectorIDBase::is_veto (const ExpandedIdentifier& id) const -{ - bool result = false; - if ( is_scint(id) && id.fields() > 1 ){ - if ( id[1] == m_VETO_ID ) result = true; - } - return result; -} - -bool -FaserDetectorIDBase::is_trigger (const ExpandedIdentifier& id) const -{ - bool result = false; - if ( is_scint(id) && id.fields() > 1 ){ - if ( id[1] == m_TRIGGER_ID ) return(true); - } - return result; -} - -bool -FaserDetectorIDBase::is_preshower (const ExpandedIdentifier& id) const -{ - bool result = false; - if ( is_scint(id) && id.fields() > 1 ){ - if ( id[1] == m_PRESHOWER_ID ) result = true; - } - return result; -} - -bool -FaserDetectorIDBase::is_sct (const ExpandedIdentifier& id) const -{ - bool result = false; - if ( is_tracker(id) && id.fields() > 1 ){ - if ( id[1] == m_SCT_ID ) result = true; - } - return result; -} - -bool -FaserDetectorIDBase::is_ecal (const ExpandedIdentifier& id) const -{ - bool result = false; - if ( is_calo(id) && id.fields() > 1 ){ - if ( id[1] == m_ECAL_ID ) result = true; - } - return result; -} - -// Short print out of any identifier: -void -FaserDetectorIDBase::show (Identifier id, - const IdContext* context, - char sep ) const -{ - if(m_msgSvc) { - MsgStream log(m_msgSvc, "FaserDetectorIDBase" ); - log << MSG::INFO << show_to_string(id, context, sep) << endmsg; - } - else { - std::cout << show_to_string(id, context, sep) << std::endl; - } -} - -// or provide the printout in string form -std::string -FaserDetectorIDBase::show_to_string (Identifier id, - const IdContext* context, - char sep ) const -{ - // Do a generic printout of identifier - - std::string result("Unable to decode id"); - unsigned int max_index = (context) ? context->end_index() : 999; - - if (!m_is_initialized_from_dict) return (result); - - // Find the dictionary to use: - IdDictDictionary* dict = 0; - ExpandedIdentifier expId; - ExpandedIdentifier prefix; // default is null prefix - Identifier compact = id; - - if (is_scint(id)) { - dict = m_scint_dict; - } - else if (is_tracker(id)) { - dict = m_tracker_dict; - } - else if (is_calo(id)) { - dict = m_calo_dict; - } - - if (!dict) return (result); - - if (dict->unpack(compact, - prefix, - max_index, - expId)) { - return (result); - } - - bool first = true; - char temp[20]; - - result = ""; - if ('.' == sep) result = "["; - for (unsigned int i = 0; i < expId.fields(); ++i) { - if (first) first = false; - else result += sep; - sprintf (temp, "%d", expId[i]); - result += temp; - } - if ('.' == sep) result += "]"; - -// result += " compact ["; -// sprintf (temp, "0x%x", (unsigned int)compact); -// result += temp; -// result += "]"; - - return (result); -} - - - -void -FaserDetectorIDBase::print (Identifier id, - const IdContext* context) const -{ - if(m_msgSvc) { - MsgStream log(m_msgSvc, "FaserDetectorIDBase" ); - log << MSG::INFO << print_to_string(id, context) << endmsg; - } - else { - std::cout << print_to_string(id, context) << std::endl; - } -} - -std::string -FaserDetectorIDBase::print_to_string (Identifier id, - const IdContext* context) const -{ - // Print out for any Faser identifier - std::string result; - if (m_is_initialized_from_dict) { - - // Do a generic printout of identifier from dictionary - unsigned int max_index = (context) ? context->end_index() : 999; - - // Find the dictionary to use: - IdDictDictionary* dict = 0; - ExpandedIdentifier expId; - ExpandedIdentifier prefix; // default is null prefix - Identifier compact = id; - - if (is_scint(id)) { - dict = m_scint_dict; - } - else if (is_tracker(id)) { - dict = m_tracker_dict; - } - else if (is_calo(id)) { - dict = m_calo_dict; - } - - if (!dict) return (result); - - if (dict->unpack(compact, - prefix, - max_index, - " ", - result)) { - return (result); - } - } - return (result); -} - -/// Dictionary name -std::vector<std::string> -FaserDetectorIDBase::dict_names (void) const -{ - return (m_dict_names); -} - -/// File name -std::vector<std::string> -FaserDetectorIDBase::file_names (void) const -{ - return (m_file_names); -} - -/// Version tag for subdet dictionary -std::vector<std::string> -FaserDetectorIDBase::dict_tags (void) const -{ - return (m_dict_tags); -} - -bool -FaserDetectorIDBase::do_checks (void) const -{ - return (m_do_checks); -} - -void -FaserDetectorIDBase::set_do_checks (bool do_checks) -{ - m_do_checks = do_checks; -} - -bool -FaserDetectorIDBase::do_neighbours (void) const -{ - return (m_do_neighbours); -} - -void -FaserDetectorIDBase::set_do_neighbours (bool do_neighbours) -{ - m_do_neighbours = do_neighbours; -} - -void -FaserDetectorIDBase::setMessageSvc (IMessageSvc* msgSvc) -{ - m_msgSvc = msgSvc ; -} - -void -FaserDetectorIDBase::set_quiet (bool quiet) -{ - m_quiet = quiet ; -} - -void -FaserDetectorIDBase::setDictVersion (const IdDictMgr& dict_mgr, const std::string& name) -{ - const IdDictDictionary* dict = dict_mgr.find_dictionary (name); - - m_dict_version = dict->m_version; -} - -std::string -FaserDetectorIDBase::to_range (const ExpandedIdentifier& id) const -{ - - // Build a string from the contents of an identifier - - int fields = id.fields(); - char temp[10] = ""; - std::string result(""); - - for (int i = 0; i < fields; ++i) { - sprintf( temp, "%d", id[i]); - if (i > 0) result += '/'; // add '/' only if NOT last one - result += temp; - } - - return result; -} - -int -FaserDetectorIDBase::initLevelsFromDict(const IdDictMgr& dict_mgr) -{ - - // Set do_checks flag - if (dict_mgr.do_checks()) m_do_checks = true; - // Set do_neighbours flag - if (!dict_mgr.do_neighbours()) m_do_neighbours = false; - - IdDictLabel* label = 0; - IdDictField* field = 0; - - // Find out from the dictionary the detector and subdetector - // levels and id values - m_DET_INDEX = 999; - m_SUBDET_INDEX = 999; - m_SCINT_ID = -1; - m_TRACKER_ID = -1; - m_CALO_ID = -1; - m_VETO_ID = -1; - m_TRIGGER_ID = -1; - m_PRESHOWER_ID = -1; - m_SCT_ID = -1; - m_ECAL_ID = -1; - - // Save generic dict for top levels - IdDictDictionary* top_dict = 0; - - // Get det ids - - // Initialize ids for InDet subdet - m_scint_dict = dict_mgr.find_dictionary ("Scintillator"); - if(!m_scint_dict) { - if(m_msgSvc) { - MsgStream log(m_msgSvc, "FaserDetectorIDBase" ); - log << MSG::WARNING << "initLevelsFromDict - cannot access Scintillator dictionary" << endmsg; - } - else { - std::cout << " FaserDetectorIDBase::initLevelsFromDict - Warning cannot access Scintillator dictionary " - << std::endl; - } - } - else { - - // Found Scint dict - - top_dict = m_scint_dict; // save as top_dict - - // Check if this is SLHC layout - m_isSLHC = (m_scint_dict->m_version=="SLHC"); - - // Get Scint subdets - - field = m_scint_dict->find_field("part"); - if (!field) { - if(m_msgSvc) { - MsgStream log(m_msgSvc, "FaserDetectorIDBase" ); - log << MSG::ERROR << "initLevelsFromDict - unable to find 'part' field for Scintillator dictionary" << endmsg; - } - else { - std::cout << "FaserDetectorIDBase::initLevelsFromDict - unable to find 'part' field for Scintillator dictionary" - << std::endl; - } - return (1); - } - - label = field->find_label("Veto"); - if (label) { - if (label->m_valued) { - m_VETO_ID = label->m_value; - } - else { - if(m_msgSvc) { - MsgStream log(m_msgSvc, "FaserDetectorIDBase" ); - log << MSG::ERROR << "initLevelsFromDict - label Veto does NOT have a value " - << endmsg; - } - else { - std::cout << "FaserDetectorIDBase::initLevelsFromDict - label Veto does NOT have a value " - << std::endl; - } - return (1); - } - } - else { - if(m_msgSvc) { - MsgStream log(m_msgSvc, "FaserDetectorIDBase" ); - log << MSG::ERROR << "initLevelsFromDict - unable to find 'Veto' label " - << endmsg; - } - else { - std::cout << "FaserDetectorIDBase::initLevelsFromDict - unable to find 'Veto' label " - << std::endl; - } - return (1); - } - - label = field->find_label("Trigger"); - if (label) { - if (label->m_valued) { - m_TRIGGER_ID = label->m_value; - } - else { - if(m_msgSvc) { - MsgStream log(m_msgSvc, "FaserDetectorIDBase" ); - log << MSG::ERROR << "initLevelsFromDict - label Trigger does NOT have a value " - << endmsg; - } - else { - std::cout << "FaserDetectorIDBase::initLevelsFromDict - label Trigger does NOT have a value " - << std::endl; - } - return (1); - } - } - else { - if(m_msgSvc) { - MsgStream log(m_msgSvc, "FaserDetectorIDBase" ); - log << MSG::ERROR << "initLevelsFromDict - unable to find 'Trigger' label " - << endmsg; - } - else { - std::cout << "FaserDetectorIDBase::initLevelsFromDict - unable to find 'Trigger' label " - << std::endl; - } - return (1); - } - - label = field->find_label("Preshower"); - if (label) { - if (label->m_valued) { - m_PRESHOWER_ID = label->m_value; - } - else { - if(m_msgSvc) { - MsgStream log(m_msgSvc, "FaserDetectorIDBase" ); - log << MSG::ERROR << "initLevelsFromDict - label Preshower does NOT have a value " - << endmsg; - } - else { - std::cout << "FaserDetectorIDBase::initLevelsFromDict - label Preshower does NOT have a value " - << std::endl; - } - return (1); - } - } - else { - if(m_msgSvc) { - MsgStream log(m_msgSvc, "FaserDetectorIDBase" ); - log << MSG::ERROR << "initLevelsFromDict - unable to find 'Preshower' label " - << endmsg; - } - else { - std::cout << "FaserDetectorIDBase::initLevelsFromDict - unable to find 'Preshower' label " - << std::endl; - } - return (1); - } - - } - - // Initialize ids for Tracker - m_tracker_dict = dict_mgr.find_dictionary ("Tracker"); - if(!m_tracker_dict) { - if(m_msgSvc) { - MsgStream log(m_msgSvc, "FaserDetectorIDBase" ); - log << MSG::WARNING << "initLevelsFromDict - cannot access Tracker dictionary " - << endmsg; - } - else { - std::cout << " FaserDetectorIDBase::initLevelsFromDict - Warning cannot access Tracker dictionary " - << std::endl; - } - } - else { - // Found Tracker dict - - if (!top_dict) top_dict = m_tracker_dict; // save as top_dict - - field = m_tracker_dict->find_field("part"); - if (!field) { - if(m_msgSvc) { - MsgStream log(m_msgSvc, "FaserDetectorIDBase" ); - log << MSG::ERROR << "initLevelsFromDict - unable to find 'station' field for Tracker dictionary" - << endmsg; - } - else { - std::cout << "FaserDetectorIDBase::initLevelsFromDict - unable to find 'station' field for Tracker dictionary" - << std::endl; - } - return (1); - } - - label = field->find_label("SCT"); - if (label) { - if (label->m_valued) { - m_SCT_ID = label->m_value; - } - else { - if(m_msgSvc) { - MsgStream log(m_msgSvc, "FaserDetectorIDBase" ); - log << MSG::ERROR << "initLevelsFromDict - label SCT does NOT have a value " - << endmsg; - } - else { - std::cout << "FaserDetectorIDBase::initLevelsFromDict - label SCT does NOT have a value " - << std::endl; - } - return (1); - } - } - else { - if(m_msgSvc) { - MsgStream log(m_msgSvc, "FaserDetectorIDBase" ); - log << MSG::ERROR << "initLevelsFromDict - unable to find 'SCT' label " - << endmsg; - } - else { - std::cout << "FaserDetectorIDBase::initLevelsFromDict - unable to find 'SCT' label " - << std::endl; - } - return (1); - } - } - - // Initialize id for Calo and fields for lvl1 and dead material - m_calo_dict = dict_mgr.find_dictionary ("Calorimeter"); - if(!m_calo_dict) { - if(m_msgSvc) { - MsgStream log(m_msgSvc, "FaserDetectorIDBase" ); - log << MSG::ERROR << "initLevelsFromDict - Warning cannot access Calorimeter dictionary " - << endmsg; - } - else { - std::cout << " FaserDetectorIDBase::initLevelsFromDict - Warning cannot access Calorimeter dictionary " - << std::endl; - } - } - else { - // Found calo dict - if (!top_dict) top_dict = m_calo_dict; // save as top_dict - - // Get Scint subdets - field = m_calo_dict->find_field("part"); - if (!field) { - if(m_msgSvc) { - MsgStream log(m_msgSvc, "FaserDetectorIDBase" ); - log << MSG::ERROR << "initLevelsFromDict - unable to find 'part' field for Calorimeter dictionary" << endmsg; - } - else { - std::cout << "FaserDetectorIDBase::initLevelsFromDict - unable to find 'part' field for Calorimeter dictionary" - << std::endl; - } - return (1); - } - - label = field->find_label("ECAL"); - if (label) { - if (label->m_valued) { - m_ECAL_ID = label->m_value; - } - else { - if(m_msgSvc) { - MsgStream log(m_msgSvc, "FaserDetectorIDBase" ); - log << MSG::ERROR << "initLevelsFromDict - label ECAL does NOT have a value " - << endmsg; - } - else { - std::cout << "FaserDetectorIDBase::initLevelsFromDict - label ECAL does NOT have a value " - << std::endl; - } - return (1); - } - } - else { - if(m_msgSvc) { - MsgStream log(m_msgSvc, "FaserDetectorIDBase" ); - log << MSG::ERROR << "initLevelsFromDict - unable to find 'ECAL' label " - << endmsg; - } - else { - std::cout << "FaserDetectorIDBase::initLevelsFromDict - unable to find 'ECAL' label " - << std::endl; - } - return (1); - } - } - - // set det/subdet indices - if (top_dict) { - field = top_dict->find_field("subdet"); - if (field) { - m_DET_INDEX = field->m_index; - } - else { - if(m_msgSvc) { - MsgStream log(m_msgSvc, "FaserDetectorIDBase" ); - log << MSG::ERROR << "initLevelsFromDict - - unable to find 'subdet' field from dict " - << endmsg; - } - else { - std::cout << "FaserDetectorIDBase::initLevelsFromDict - unable to find 'subdet' field from dict " - << top_dict->m_name - << std::endl; - } - return (1); - } - - // Get scint id - label = field->find_label("Scintillator"); - if (label) { - if (label->m_valued) { - m_SCINT_ID = label->m_value; - } - else { - if(m_msgSvc) { - MsgStream log(m_msgSvc, "FaserDetectorIDBase" ); - log << MSG::ERROR << "initLevelsFromDict - label Scintillator does NOT have a value " - << endmsg; - } - else { - std::cout << "FaserDetectorIDBase::initLevelsFromDict - label Scintillator does NOT have a value " - << std::endl; - } - return (1); - } - } - else { - if(m_msgSvc) { - MsgStream log(m_msgSvc, "FaserDetectorIDBase" ); - log << MSG::ERROR << "initLevelsFromDict - unable to find 'Scintillator' label " - << endmsg; - } - else { - std::cout << "FaserDetectorIDBase::initLevelsFromDict - unable to find 'Scintillator' label " - << std::endl; - } - return (1); - } - - // Get Tracker id - label = field->find_label("Tracker"); - if (label) { - if (label->m_valued) { - m_TRACKER_ID = label->m_value; - } - else { - if(m_msgSvc) { - MsgStream log(m_msgSvc, "FaserDetectorIDBase" ); - log << MSG::ERROR << "initLevelsFromDict - label Tracker does NOT have a value " - << endmsg; - } - else { - std::cout << "FaserDetectorIDBase::initLevelsFromDict - label Tracker does NOT have a value " - << std::endl; - } - return (1); - } - } - else { - if(m_msgSvc) { - MsgStream log(m_msgSvc, "FaserDetectorIDBase" ); - log << MSG::ERROR << "initLevelsFromDict - unable to find 'Tracker' label " - << endmsg; - } - else { - std::cout << "FaserDetectorIDBase::initLevelsFromDict - unable to find 'Tracker' label " - << std::endl; - } - return (1); - } - - // Get Calo id - label = field->find_label("Calorimeter"); - if (label) { - if (label->m_valued) { - m_CALO_ID = label->m_value; - } - else { - if(m_msgSvc) { - MsgStream log(m_msgSvc, "FaserDetectorIDBase" ); - log << MSG::ERROR << "initLevelsFromDict - label Calorimeter does NOT have a value " - << endmsg; - } - else { - std::cout << "FaserDetectorIDBase::initLevelsFromDict - label Calorimeter does NOT have a value " - << std::endl; - } - return (1); - } - } - else { - if(m_msgSvc) { - MsgStream log(m_msgSvc, "FaserDetectorIDBase" ); - log << MSG::ERROR << "initLevelsFromDict - unable to find 'Calorimeter' label " - << endmsg; - } - else { - std::cout << "FaserDetectorIDBase::initLevelsFromDict - unable to find 'Calorimeter' label " - << std::endl; - } - return (1); - } - - // Get name of next level - std::string name; - if (top_dict->m_name == "Scintillator") { - name = "part"; - } - else if (top_dict->m_name == "Calorimeter") { - name = "part"; - } - else if (top_dict->m_name == "Tracker") { - name = "part"; - } - - // While we're here, save the index to the sub-detector level - // ("part" for InDet) - field = top_dict->find_field(name); - if (field) { - m_SUBDET_INDEX = field->m_index; - } - else { - if(m_msgSvc) { - MsgStream log(m_msgSvc, "FaserDetectorIDBase" ); - log << MSG::ERROR << "initLevelsFromDict - unable to find field " - << name << " from dict " - << top_dict->m_name - << endmsg; - } - else { - std::cout << "FaserDetectorIDBase::initLevelsFromDict - unable to find field " - << name << " from dict " - << top_dict->m_name - << std::endl; - } - return (1); - } - } - else { - if(m_msgSvc) { - MsgStream log(m_msgSvc, "FaserDetectorIDBase" ); - log << MSG::ERROR << "initLevelsFromDict - no top dictionary defined " - << endmsg; - } - else { - std::cout << "FaserDetectorIDBase::initLevelsFromDict - no top dictionary defined " - << std::endl; - } - return (1); - } - - - // Set the field implementations - - const IdDictRegion* region = 0; - size_type region_index = m_helper->veto_region_index(); - if (m_scint_dict && FaserDetectorIDHelper::UNDEFINED != region_index) { - region = m_scint_dict->m_regions[region_index]; - // Detector - m_det_impl = region->m_implementation[m_DET_INDEX]; - // InDet part - m_scint_part_impl = region->m_implementation[m_SUBDET_INDEX]; - } - - region_index = m_helper->sct_region_index(); - if (m_tracker_dict && FaserDetectorIDHelper::UNDEFINED != region_index) { - region = m_tracker_dict->m_regions[region_index]; - // Detector - m_det_impl = region->m_implementation[m_DET_INDEX]; - // InDet part - m_tracker_part_impl = region->m_implementation[m_SUBDET_INDEX]; - } - - region_index = m_helper->ecal_region_index(); - if (m_calo_dict && FaserDetectorIDHelper::UNDEFINED != region_index) { - region = m_calo_dict->m_regions[region_index]; - // Detector - m_det_impl = region->m_implementation[m_DET_INDEX]; - // InDet part - m_calo_part_impl = region->m_implementation[m_SUBDET_INDEX]; - } - return (0); -} diff --git a/DetectorDescription/FaserDetDescr/src/FaserDetectorIDHelper.cxx b/DetectorDescription/FaserDetDescr/src/FaserDetectorIDHelper.cxx index d83d06cac..0a877bb96 100644 --- a/DetectorDescription/FaserDetDescr/src/FaserDetectorIDHelper.cxx +++ b/DetectorDescription/FaserDetDescr/src/FaserDetectorIDHelper.cxx @@ -11,7 +11,7 @@ #include "FaserDetectorIDHelper.h" #include "IdDict/IdDictDefs.h" -#include "FaserDetDescr/FaserDetectorIDBase.h" +#include "FaserDetDescr/FaserDetectorID.h" #include "GaudiKernel/MsgStream.h" #include <iostream> @@ -48,7 +48,7 @@ FaserDetectorIDHelper::initialize_from_dictionary(const IdDictMgr& dict_mgr) if(m_initialized) return(0); m_initialized = true; - FaserDetectorIDBase faser_id; + FaserDetectorID faser_id; ExpandedIdentifier id; const IdDictDictionary* dict = dict_mgr.find_dictionary ("Scintillator"); diff --git a/DetectorDescription/FaserReadoutGeometry/FaserReadoutGeometry/FaserDetectorManager.h b/DetectorDescription/FaserReadoutGeometry/FaserReadoutGeometry/FaserDetectorManager.h index 385b8bbc9..1371cc404 100644 --- a/DetectorDescription/FaserReadoutGeometry/FaserReadoutGeometry/FaserDetectorManager.h +++ b/DetectorDescription/FaserReadoutGeometry/FaserReadoutGeometry/FaserDetectorManager.h @@ -29,7 +29,7 @@ class StoreGateSvc; class AlignableTransform; class Identifier; -class FaserDetectorIDBase; +class FaserDetectorID; class GeoVAlignmentStore; class CondAttrListCollection; @@ -175,7 +175,7 @@ namespace FaserDD { const CondAttrListCollection* obj=nullptr, GeoVAlignmentStore* alignStore=nullptr) const; - virtual const FaserDetectorIDBase* getIdHelper() const = 0; + virtual const FaserDetectorID* getIdHelper() const = 0; //Declaring private message stream member. mutable Athena::MsgStreamMember m_msg; diff --git a/DetectorDescription/FaserReadoutGeometry/src/FaserDetectorManager.cxx b/DetectorDescription/FaserReadoutGeometry/src/FaserDetectorManager.cxx index 558c8bf0d..053bf0d94 100644 --- a/DetectorDescription/FaserReadoutGeometry/src/FaserDetectorManager.cxx +++ b/DetectorDescription/FaserReadoutGeometry/src/FaserDetectorManager.cxx @@ -7,7 +7,7 @@ #include "StoreGate/StoreGateSvc.h" #include "DetDescrConditions/AlignableTransform.h" -#include "FaserDetDescr/FaserDetectorIDBase.h" +#include "FaserDetDescr/FaserDetectorID.h" #include "GeoPrimitives/CLHEPtoEigenConverter.h" #include "AthenaPoolUtilities/CondAttrListCollection.h" #include "AthenaBaseComps/AthMsgStreamMacros.h" diff --git a/DetectorDescription/IdDictDetDescrCnv/src/FaserIDDetDescrCnv.cxx b/DetectorDescription/IdDictDetDescrCnv/src/FaserIDDetDescrCnv.cxx index 0a9fc3970..dabb566be 100644 --- a/DetectorDescription/IdDictDetDescrCnv/src/FaserIDDetDescrCnv.cxx +++ b/DetectorDescription/IdDictDetDescrCnv/src/FaserIDDetDescrCnv.cxx @@ -18,7 +18,7 @@ #include "AthenaKernel/StorableConversions.h" #include "IdDictDetDescr/IdDictManager.h" -#include "FaserDetDescr/FaserDetectorIDBase.h" +#include "FaserDetDescr/FaserDetectorID.h" #include "CxxUtils/make_unique.h" //<<<<<< PRIVATE DEFINES >>>>>> @@ -90,7 +90,7 @@ FaserIDDetDescrCnv::createObj(IOpaqueAddress* pAddr, DataObject*& pObj) { //StatusCode sc = StatusCode::SUCCESS; MsgStream log(msgSvc(), "FaserIDDetDescrCnv"); - log << MSG::INFO << "in createObj: creating a FaserDetectorIDBase helper object in the detector store" << endmsg; + log << MSG::INFO << "in createObj: creating a FaserDetectorID helper object in the detector store" << endmsg; // Create a new AtlasDetectorID @@ -132,11 +132,11 @@ FaserIDDetDescrCnv::createObj(IOpaqueAddress* pAddr, DataObject*& pObj) // create the helper - auto faser_id = CxxUtils::make_unique<FaserDetectorIDBase>(); + auto faser_id = CxxUtils::make_unique<FaserDetectorID>(); faser_id->setMessageSvc(msgSvc()); if (idDictMgr->initializeHelper(*faser_id)) { - log << MSG::ERROR << "Unable to initialize FaserDetectorIDBase" << endmsg; + log << MSG::ERROR << "Unable to initialize FaserDetectorID" << endmsg; return StatusCode::FAILURE; } @@ -158,13 +158,13 @@ FaserIDDetDescrCnv::storageType() //-------------------------------------------------------------------- const CLID& FaserIDDetDescrCnv::classID() { - return ClassID_traits<FaserDetectorIDBase>::ID(); + return ClassID_traits<FaserDetectorID>::ID(); } //-------------------------------------------------------------------- FaserIDDetDescrCnv::FaserIDDetDescrCnv(ISvcLocator* svcloc) : - DetDescrConverter(ClassID_traits<FaserDetectorIDBase>::ID(), svcloc) + DetDescrConverter(ClassID_traits<FaserDetectorID>::ID(), svcloc) {} diff --git a/Scintillator/ScintDetDescr/ScintGeoModel/ScintGeoModel/VetoDetectorTool.h b/Scintillator/ScintDetDescr/ScintGeoModel/ScintGeoModel/VetoDetectorTool.h index a2b14569b..9e98acde0 100644 --- a/Scintillator/ScintDetDescr/ScintGeoModel/ScintGeoModel/VetoDetectorTool.h +++ b/Scintillator/ScintDetDescr/ScintGeoModel/ScintGeoModel/VetoDetectorTool.h @@ -21,7 +21,7 @@ namespace ScintDD { } //class VetoID; -class FaserDetectorIDBase; +class FaserDetectorID; class VetoDetectorTool : public GeoModelTool { @@ -46,7 +46,7 @@ private: const ScintDD::VetoDetectorManager* m_manager; - ScintGeoModelAthenaComps<FaserDetectorIDBase> m_athenaComps; + ScintGeoModelAthenaComps<FaserDetectorID> m_athenaComps; // ScintGeoModelAthenaComps<VetoID> m_athenaComps; ServiceHandle< IGeoDbTagSvc > m_geoDbTagSvc; diff --git a/Scintillator/ScintDetDescr/ScintGeoModel/src/VetoDetectorTool.cxx b/Scintillator/ScintDetDescr/ScintGeoModel/src/VetoDetectorTool.cxx index 30ae62864..ae32e5ded 100644 --- a/Scintillator/ScintDetDescr/ScintGeoModel/src/VetoDetectorTool.cxx +++ b/Scintillator/ScintDetDescr/ScintGeoModel/src/VetoDetectorTool.cxx @@ -12,7 +12,7 @@ // temporary // #include "InDetIdentifier/SCT_ID.h" // #include "ScintReadoutGeometry/VetoDetectorManager.h" -#include "FaserDetDescr/FaserDetectorIDBase.h" +#include "FaserDetDescr/FaserDetectorID.h" #include "DetDescrConditions/AlignableTransformContainer.h" #include "GeoModelUtilities/GeoModelExperiment.h" @@ -123,7 +123,7 @@ VetoDetectorTool::create() m_athenaComps.setGeoDbTagSvc(&*m_geoDbTagSvc); m_athenaComps.setGeometryDBSvc(&*m_geometryDBSvc); m_athenaComps.setRDBAccessSvc(&*m_rdbAccessSvc); - const FaserDetectorIDBase* idHelper{nullptr}; + const FaserDetectorID* idHelper{nullptr}; ATH_CHECK(detStore()->retrieve(idHelper, "FaserID")); m_athenaComps.setIdHelper(idHelper); -- GitLab