Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:14:49

0001 //==============================================================================
0002 //  AIDA Detector description implementation for LHCb
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   Markus Frank
0011 //  \date     2018-03-08
0012 //  \version  1.0
0013 //
0014 //==============================================================================
0015 #ifndef DE_CTORS_DEFAULT
0016 #pragma error("This header should never be included directly. Inlcude Detector/DetectorElement.h instead!")
0017 #endif
0018 
0019 #ifndef DETECTOR_DEIOV_H
0020 #define DETECTOR_DEIOV_H
0021 
0022 /// Gaudi namespace declaration
0023 namespace gaudi   {
0024 
0025   /// Gaudi::detail namespace declaration
0026   namespace detail   {
0027 
0028     // Forward declarations
0029     class DeIOVObject;
0030     
0031     /// Base class for intervall of validity dependent DetectorElement data
0032     /**
0033      *  Need to store pointers in the child chache - 
0034      *  Handles are only defined below and cannot be used here.
0035      *  Though: The pointer can directly be assigned to handles.
0036      *
0037      *  Note:
0038      *  1) When populating the child chache it is the USER's responsibility
0039      *     To use ConditionsMaps with appropriate IOVs!
0040      *  2) The child chache may ONLY be populated while the condition is not
0041      *     active ie. during creation/initialization time. Otherwise
0042      *     MT races occur!
0043      *
0044      *  Concurrentcy notice:
0045      *  Except during filling, which is performed by the framework code,
0046      *  instances of this class are assumed to the read-only! 
0047      *  Thread safety hence is no issue.
0048      *
0049      *  \author  Markus Frank
0050      *  \date    2018-03-08
0051      *  \version  1.0
0052      */
0053     class DeIOVObject : public detail::ConditionObject    {
0054       DE_CONDITIONS_TYPEDEFS;
0055       typedef DeStatic::Object static_t;
0056 
0057     public:
0058       /// Helper to initialize the basic information
0059       DeIOVObject* fill_info(DetElement de, Catalog* cat);
0060       
0061     public: 
0062       /// Standard constructors and assignment
0063       DE_CTORS_DEFAULT(DeIOVObject);
0064 
0065       /// Initialization of sub-classes. May only be called while the condition is NOT active
0066       virtual void initialize();
0067       /// Fill the child cache. May only be called while the condition is NOT active
0068       void fillCache(ConditionsMap& m);
0069 
0070       /// Printout method to stdout
0071       virtual void print(int indent, int flags)  const;
0072       /// Check (enforce) the validity of the alignment object if required
0073       void checkAlignment()  const;
0074       /// Access daughter elements: IOV dependent part
0075       DeIOVObject* child(DetElement de)   const;
0076 
0077     public:
0078       /// The static part of the detector element
0079       DeStatic          de_static;
0080       /// Cache of static information of the children.
0081       std::map<DetElement,DeIOVObject*> childCache;
0082       /// The dd4hep detector element reference of this gaudi detector element
0083       DetElement        detector;
0084       /// All the time dependent conditions
0085       Conditions        conditions;
0086       /// The alignment object, which belongs to THIS detectoreleemnt
0087       Alignment         detectorAlignment;
0088       /// Alignments for daughter volumes not directly identified by a DetElement
0089       VolumeAlignments  volumeAlignments;
0090 
0091       /// We want to cache here the matrix from world to local (=inverse world2local)
0092       TGeoHMatrix       toLocalMatrix;
0093       /// We want to cache here the delta matrix
0094       TGeoHMatrix       deltaMatrix;
0095       /// Initialization flags to steer actions
0096       unsigned short    de_flags = 0;
0097       unsigned short    de_user  = 0;
0098       /// Item key
0099       itemkey_type      item_key = 0;
0100 
0101     public:
0102 
0103       /// Compute key value for caching
0104       static itemkey_type key(const std::string& value)
0105       {  return dd4hep::ConditionKey::itemCode(value);         }
0106       /// Compute key value for caching
0107       static itemkey_type key(const char* value)
0108       {  return dd4hep::ConditionKey::itemCode(value);         }
0109 
0110       /// Check if the condition identified by 'key' is in the list of conditionrefs.
0111       bool hasCondition(itemkey_type key) const
0112       {   return this->condition(key, false).isValid();        }
0113       /// Access condition by hash-key (fast)
0114       Condition condition(itemkey_type key)  const;
0115       /// Access condition by hash-key (fast)
0116       Condition condition(itemkey_type key, bool throw_if)  const;
0117 
0118       /// Check if the condition called 'name' is in the list of conditionrefs.
0119       bool hasCondition(const std::string& nam) const
0120       {   return this->condition(nam, false).isValid();        }
0121       /// Access condition by name (slow)
0122       Condition condition(const std::string& name)  const;
0123       /// Access condition by name (slow)
0124       Condition condition(const std::string& name, bool throw_if)  const;
0125      
0126       /// Local -> Global and Global -> Local transformations
0127       XYZPoint toLocal( const XYZPoint& global ) const
0128       {  return XYZPoint(detectorAlignment.worldToLocal(XYZVector(global)));     }
0129       XYZPoint toGlobal( const XYZPoint& local ) const
0130       {  return XYZPoint(detectorAlignment.localToWorld(XYZVector(local)));      }
0131       XYZVector toLocal( const XYZVector& globalDirection ) const
0132       {  return detectorAlignment.worldToLocal(globalDirection);                 }
0133       XYZVector toGlobal( const XYZVector& localDirection  ) const
0134       {  return detectorAlignment.localToWorld(localDirection);                  }
0135 
0136       const TGeoHMatrix& toGlobalMatrix() const {
0137         return detectorAlignment.worldTransformation();
0138       }
0139 
0140     };
0141   }    // End namespace detail
0142 
0143   /// Geometry access
0144   /**
0145    *
0146    *  \author  Markus Frank
0147    *  \date    2018-03-08
0148    *  \version  1.0
0149    */
0150   class DeIOVElement : public dd4hep::Handle<detail::DeIOVObject>  {
0151     DE_CONDITIONS_TYPEDEFS;
0152     /// Forward definition of the static type for facades
0153     typedef detail::DeStaticObject static_t;
0154     typedef detail::DeIOVObject    iov_t;
0155 
0156   public:
0157     /// Standard handle assignments and constructors
0158     DE_CTORS_HANDLE(DeIOVElement,Base);    
0159     /// Access to the static data
0160     static_t& staticData()  const  {  return access()->de_static;                }
0161   };
0162 }      // End namespace gaudi
0163 
0164 #endif // DETECTOR_DEIOV_H