Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-21 09:57:59

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_ALIGNMENTSNOMINALMAP_H
0014 #define DD4HEP_ALIGNMENTSNOMINALMAP_H
0015 
0016 // Framework include files
0017 #include <DD4hep/ConditionsMap.h>
0018 
0019 // C/C++ include files
0020 
0021 /// Namespace for the AIDA detector description toolkit
0022 namespace dd4hep {
0023 
0024   /// An implementation of the ConditionsMap interface to fall back to nominal alignment.
0025   /**
0026    *  The AlignmentsNominalMap is not a conditions cache per se. This implementation 
0027    *  behaves like a conditionsmap, but it shall not return real conditions to the user,
0028    *  but rather return the default alignment objects (which at the basis are conditions 
0029    *  as well) to the user. These alignments are taken from the DetElement in question
0030    *  Alignment DetElement::nominal().
0031    *
0032    *  The basic idea is to enable users to write code "as if" there would be conditions
0033    *  present. This is important to ease in the lifetime of the experiment the step from
0034    *  the design phase (where obviously no conditions are taken into account) to a more
0035    *  mature phase, where alignment studies etc. actually are part of the 
0036    *  "bread and butter work".
0037    *
0038    *  See dd4hep/ConditionsMap.h for further information.
0039    *
0040    *  \author  M.Frank
0041    *  \version 1.0
0042    *  \ingroup DD4HEP_CONDITIONS
0043    */
0044   class AlignmentsNominalMap : public ConditionsMap   {
0045   public:
0046     /// Reference to the top detector element
0047     DetElement  world;
0048     /// Potential cache of real conditions
0049     std::map<Condition::key_type,Condition> data;
0050 
0051   public:
0052     /// Standard constructor
0053     AlignmentsNominalMap(DetElement wrld);
0054     /// Standard destructor
0055     virtual ~AlignmentsNominalMap() = default;
0056     /// Insert a new entry to the map. The detector element key and the item key make a unique global alignments key
0057     virtual bool insert(DetElement detector, Condition::itemkey_type key, Condition condition)  override;
0058     /// Interface to access alignments by hash value. The detector element key and the item key make a unique global alignments key
0059     virtual Condition get(DetElement detector, Condition::itemkey_type key) const  override;
0060     /// Interface to scan data content of the alignments mapping
0061     virtual void scan(const Condition::Processor& processor) const  override;
0062 
0063     /** Partial implementations for utilities accessing DetElement alignments      */
0064 
0065     /// No AlignmentsMap overload: Access all alignments within a key range in the interval [lower,upper]
0066     /** Note: This default implementation uses 
0067      *        std::vector<Condition> get(DetElement detector,
0068      *                                  itemkey_type lower,
0069      *                                  itemkey_type upper)
0070      *        The performance depends on the concrete implementation of the scan method!
0071      */
0072     virtual std::vector<Condition> get(DetElement detector,
0073                                        Condition::itemkey_type lower,
0074                                        Condition::itemkey_type upper)  const  override
0075     {  return this->ConditionsMap::get(detector, lower, upper);                   }
0076       
0077     /// Interface to partially scan data content of the alignments mapping
0078     /** Note: This default implementation assumes unordered containers and hence is
0079      *        not the most efficient implementation!
0080      *        Internaly it uses "scan(Processor& processor)"
0081      *        the subselection hence is linearly depending of the number of elements.
0082      *        
0083      *        Using ordered maps with "lower_bound(key)" this can be greatly improved.
0084      *        See the concrete implementations below.
0085      */
0086     virtual void scan(DetElement       detector,
0087                       Condition::itemkey_type     lower,
0088                       Condition::itemkey_type     upper,
0089                       const Condition::Processor& processor) const  override;
0090   };
0091 }         /* End namespace dd4hep                        */
0092 #endif // DD4HEP_ALIGNMENTSNOMINALMAP_H