![]() |
|
|||
File indexing completed on 2025-02-21 09:58:00
0001 //========================================================================== 0002 // AIDA Detector description implementation 0003 //-------------------------------------------------------------------------- 0004 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) 0005 // All rights reserved. 0006 // 0007 // For the licensing terms see $DD4hepINSTALL/LICENSE. 0008 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS. 0009 // 0010 // Author : M.Frank 0011 // 0012 //========================================================================== 0013 #ifndef DD4HEP_CONDITIONSMAP_H 0014 #define DD4HEP_CONDITIONSMAP_H 0015 0016 // Framework include files 0017 #include <DD4hep/Conditions.h> 0018 #include <DD4hep/DetElement.h> 0019 0020 // C/C++ include files 0021 #include <map> 0022 #include <unordered_map> 0023 0024 /// Namespace for the AIDA detector description toolkit 0025 namespace dd4hep { 0026 0027 /// ConditionsMap class. 0028 /** 0029 * Access mechanisms of dd4hep conditions for utilities 0030 * =================================================== 0031 * 0032 * The conditions map class is the basic interface to manage/access conditions 0033 * in dd4hep. It's main use is to provide a common interface to utilities using 0034 * dd4hep conditions, such as scanners, selectors, printers etc. 0035 * Such utilities often require access to conditions sets based on individual 0036 * DetElement instances. 0037 * 0038 * Access to conditions is solely supported using this interface 0039 * -- All utilities must use this interface. 0040 * -- Any concrete implementation using conditions/alignment utilities 0041 * must implement this interface 0042 * -- Basic implmentation using STL map, multimap and unordered_map are provided. 0043 * -- A special no-op implementation of this interface shall be provided to access 0044 * "default" alignment conditions. 0045 * This implementation shall fall-back internally to the DetElement::nominal() alignment. 0046 * Known clients: VolumeManager (hence: DDG4, DDRec, etc.) 0047 * 0048 * Though this sounds like a trivial change, the consequences concern the entire conditions 0049 * and alignment handling. This interface decouples entirely the core part of dd4hep 0050 * from the conditons cache handling and the alignment handling. 0051 * 0052 * Based on this interface most utilities used to handle conditions, detectors scans 0053 * to visit DetElement related condition sets, alignment and conditions printers etc. 0054 * 0055 * \author M.Frank 0056 * \version 1.0 0057 * \ingroup DD4HEP_CONDITIONS 0058 */ 0059 class ConditionsMap { 0060 public: 0061 enum { 0062 FIRST_ITEM = Condition::FIRST_ITEM_KEY, 0063 LAST_ITEM = Condition::LAST_ITEM_KEY 0064 }; 0065 enum { 0066 FIRST_KEY = Condition::FIRST_KEY, 0067 LAST_KEY = Condition::LAST_KEY 0068 }; 0069 0070 public: 0071 /// Standard destructor 0072 virtual ~ConditionsMap() = default; 0073 /// Insert a new entry to the map. The detector element key and the item key make a unique global conditions key 0074 virtual bool insert(DetElement detector, 0075 Condition::itemkey_type key, 0076 Condition condition) = 0; 0077 /// Interface to access conditions by hash value. The detector element key and the item key make a unique global conditions key 0078 virtual Condition get(DetElement detector, 0079 Condition::itemkey_type key) const = 0; 0080 /// Interface to scan data content of the conditions mapping 0081 virtual void scan(const Condition::Processor& processor) const = 0; 0082 0083 /** Partial implementations for utilities accessing DetElement conditions */ 0084 0085 /// No ConditionsMap overload: Access all conditions within a key range in the interval [lower,upper] 0086 /** Note: This default implementation uses 0087 * void scan(DetElement detector, 0088 * itemkey_type lower, 0089 * itemkey_type upper, 0090 * const Processor& collector) 0091 * The performance depends on the concrete implementation of the scan method! 0092 */ 0093 virtual std::vector<Condition> get(DetElement detector, 0094 Condition::itemkey_type lower, 0095 Condition::itemkey_type upper) const; 0096 0097 /// Interface to partially scan data content of the conditions mapping 0098 /** Note: This default implementation assumes unordered containers and hence is 0099 * not the most efficient implementation! 0100 * Internaly it uses "scan(Processor& processor)" 0101 * the subselection hence is linearly depending of the number of elements. 0102 * 0103 * This default implementation uses 0104 * std::vector<Condition> get(DetElement detector, 0105 * itemkey_type lower, 0106 * itemkey_type upper) 0107 * The performance depends on the concrete implementation of the scan method! 0108 * 0109 * Using ordered maps with "lower_bound(key)" this can be greatly improved. 0110 * See the concrete implementations below. 0111 */ 0112 virtual void scan(DetElement detector, 0113 Condition::itemkey_type lower, 0114 Condition::itemkey_type upper, 0115 const Condition::Processor& processor) const; 0116 }; 0117 0118 /// Concrete ConditionsMap implementation class using externally defined containers 0119 /** 0120 * \author M.Frank 0121 * \version 1.0 0122 * \ingroup DD4HEP_CONDITIONS 0123 */ 0124 template <typename T> 0125 class ConditionsMapping : virtual public ConditionsMap { 0126 public: 0127 /// The actual data container 0128 T data; 0129 public: 0130 /// Standard constructor to construct an empty object 0131 ConditionsMapping() = default; 0132 /// Standard destructor 0133 virtual ~ConditionsMapping() = default; 0134 /// No copy constructor 0135 ConditionsMapping(const ConditionsMapping& copy) = delete; 0136 /// No assignment 0137 ConditionsMapping& operator=(const ConditionsMapping& copy) = delete; 0138 /// Insert a new entry to the map 0139 virtual bool insert(DetElement detector, Condition::itemkey_type key, Condition condition) override; 0140 /// Interface to access conditions by hash value 0141 virtual Condition get(DetElement detector, Condition::itemkey_type key) const override; 0142 /// No ConditionsMap overload: Access all conditions within a key range in the interval [lower,upper] 0143 virtual std::vector<Condition> get(DetElement detector, 0144 Condition::itemkey_type lower, 0145 Condition::itemkey_type upper) const override { 0146 return this->ConditionsMap::get(detector,lower,upper); 0147 } 0148 /// Interface to scan data content of the conditions mapping 0149 virtual void scan(const Condition::Processor& processor) const override; 0150 /// Interface to partially scan data content of the conditions mapping 0151 virtual void scan(DetElement detector, 0152 Condition::itemkey_type lower, 0153 Condition::itemkey_type upper, 0154 const Condition::Processor& processor) const override; 0155 }; 0156 /// Concrete implementation of the conditions map using a left-right map 0157 typedef ConditionsMapping<std::map<Condition::key_type,Condition> > ConditionsTreeMap; 0158 /// Concrete implementation of the conditions map using a multimap 0159 typedef ConditionsMapping<std::multimap<Condition::key_type,Condition> > ConditionsMultiMap; 0160 /// Concrete implementation of the conditions map using a hashmap 0161 typedef ConditionsMapping<std::unordered_map<Condition::key_type,Condition> > ConditionsHashMap; 0162 0163 } /* End namespace dd4hep */ 0164 #endif // DD4HEP_CONDITIONSMAP_H
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |