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_ALIGNMENTSPROCESSOR_H
0014 #define DD4HEP_ALIGNMENTSPROCESSOR_H
0015 
0016 // Framework includes
0017 #include <DD4hep/ConditionsMap.h>
0018 #include <DD4hep/AlignmentData.h>
0019 #include <DD4hep/Alignments.h>
0020 #include <DD4hep/Printout.h>
0021 
0022 // C/C++ include files
0023 #include <memory>
0024 
0025 /// Namespace for the AIDA detector description toolkit
0026 namespace dd4hep {
0027 
0028   /// Namespace for the AIDA detector description toolkit supporting XML utilities
0029   namespace align {
0030     
0031     /// Generic alignment processor facade for the Conditons::Processor object
0032     /**
0033      *  This wrapper converts any object, which has the signature
0034      *  int operator()(Alignment cond) const
0035      *  The object is automatically wrapped to a Alignment::Processor object
0036      *  and allows to scan trees using e.g. DetElementProcessors etc.
0037      *  
0038      *  \author  M.Frank
0039      *  \version 1.0
0040      *  \date    01/04/2016
0041      */
0042     template <typename T> class AlignmentsProcessor : public Alignment::Processor  {
0043       T& processor;
0044     public:
0045       /// Default constructor
0046       AlignmentsProcessor() = default;
0047       /// Initializing constructor
0048       AlignmentsProcessor(T& p) : processor(p) {}
0049       /// Default move constructor is disabled
0050       AlignmentsProcessor(T&& p) = delete;
0051       /// R-value copy from a temporary (Since processor is reference)
0052       AlignmentsProcessor(AlignmentsProcessor&& copy) = default;
0053       /// Copy constructor
0054       AlignmentsProcessor(const AlignmentsProcessor& copy) = default;
0055       /// Default destructor
0056       virtual ~AlignmentsProcessor() = default;
0057       /// Assignment operator
0058       AlignmentsProcessor& operator=(const AlignmentsProcessor& copy) = default;
0059       /// Processing callback
0060       virtual int operator()(Alignment alignment)  const override  {
0061         return (processor)(alignment);
0062       }
0063     };
0064     /// Creator utility function for AlignmentsProcessor objects
0065     template <typename T> inline
0066     AlignmentsProcessor<typename std::remove_reference<T>::type> alignmentsProcessor(T&& obj)
0067     {  return AlignmentsProcessor<typename std::remove_reference<T>::type>(obj);    }
0068 
0069     /// Generic alignment processor facade for the Conditons::Processor object
0070     /**
0071      *  This wrapper converts any object, which has the signature
0072      *  int operator()(Alignment cond) const
0073      *  The object is automatically wrapped to a Alignment::Processor object
0074      *  and allows to scan trees using e.g. DetElementProcessors etc.
0075      *
0076      *  
0077      *  \author  M.Frank
0078      *  \version 1.0
0079      *  \date    01/04/2016
0080      */
0081     template <typename T> class AlignmentsProcessorWrapper : public Alignment::Processor  {
0082       std::unique_ptr<T> processor;
0083     public:
0084       /// Default constructor
0085       AlignmentsProcessorWrapper() = default;
0086       /// Initializing constructor
0087       AlignmentsProcessorWrapper(T* p) : processor(p) {}
0088       /// Copy constructor
0089       AlignmentsProcessorWrapper(const AlignmentsProcessorWrapper& copy) = default;
0090       /// Default destructor
0091       virtual ~AlignmentsProcessorWrapper() = default;
0092       /// Assignment operator
0093       AlignmentsProcessorWrapper& operator=(const AlignmentsProcessorWrapper& copy) = default;
0094       /// Processing callback
0095       virtual int operator()(Alignment c)  const override  {
0096         return (*(processor.get()))(c);
0097       }
0098     };
0099     /// Creator utility function for AlignmentsProcessorWrapper objects
0100     template <typename T> inline AlignmentsProcessorWrapper<T>* createProcessorWrapper(T* obj)  {
0101       return new AlignmentsProcessorWrapper<T>(obj);
0102     }
0103     /// Creator utility function for AlignmentsProcessorWrapper objects
0104     template <typename T> inline AlignmentsProcessorWrapper<T> processorWrapper(T* obj)  {
0105       return AlignmentsProcessorWrapper<T>(obj);
0106     }
0107 
0108     /// Generic Alignment-Delta collector keyed by detector elements
0109     /**
0110      *   To be used with utilities like DetElementProcessor etc.
0111      *
0112      *  
0113      *  \author  M.Frank
0114      *  \version 1.0
0115      *  \date    01/04/2016
0116      */
0117     template <typename T> class DeltaCollector  {
0118     public:
0119       /// Reference to the user pool
0120       ConditionsMap& mapping;
0121       /// Collection container
0122       T&             deltas;
0123     public:
0124       /// Default constructor
0125       DeltaCollector(ConditionsMap& m, T& d) : mapping(m), deltas(d) {}
0126       /// Default move constructor is disabled
0127       DeltaCollector(ConditionsMap& m, T&& p) = delete;
0128       /// R-value copy from a temporary
0129       DeltaCollector(DeltaCollector&& copy) = default;
0130       /// Copy constructor
0131       DeltaCollector(const DeltaCollector& copy) = default;
0132       /// Default destructor
0133       ~DeltaCollector() = default;
0134       /// Assignment operator
0135       DeltaCollector& operator=(const DeltaCollector& copy) = default;
0136       /// Callback to output alignments information
0137       /** Note: Valid implementations exist for the container types:
0138        *        std::list<Delta>
0139        *        std::vector<Delta>
0140        *        std::map<DetElement,Delta>
0141        *        std::multimap<DetElement,Delta>
0142        *        std::map<std::string,Delta>        key = DetElement.path()
0143        *        std::multimap<std::string,Delta>   key = DetElement.path()
0144        */
0145       virtual int operator()(DetElement de, int level=0)  const final;
0146     };
0147 
0148     /// Creator function for alignment collector objects
0149     template <typename T> inline
0150     DeltaCollector<typename std::remove_reference<T>::type> deltaCollector(ConditionsMap& m, T&& deltas)
0151     {    return DeltaCollector<typename std::remove_reference<T>::type>(m, deltas);    }
0152 
0153     /// Generic alignment collector keyed by detector elements
0154     /**
0155      *   To be used with utilities like DetElementProcessor etc.
0156      *
0157      *  
0158      *  \author  M.Frank
0159      *  \version 1.0
0160      *  \date    01/04/2016
0161      */
0162     template <typename T> class AlignmentsCollector  {
0163     public:
0164       /// Reference to the user pool
0165       ConditionsMap& mapping;
0166       /// Collection container
0167       T&             alignments;
0168     public:
0169       /// Default constructor
0170       AlignmentsCollector(ConditionsMap& m, T& d) : mapping(m), alignments(d) {}
0171       /// Default move constructor is disabled
0172       AlignmentsCollector(ConditionsMap& m, T&& p) = delete;
0173       /// Copy constructor
0174       AlignmentsCollector(const AlignmentsCollector& copy) = default;
0175       /// Default destructor
0176       ~AlignmentsCollector() = default;
0177       /// Assignment operator
0178       AlignmentsCollector& operator=(const AlignmentsCollector& copy) = default;
0179       /// Callback to output alignments information
0180       /** Note: Valid implementations exist for the container types:
0181        *        std::list<Alignment>
0182        *        std::vector<Alignment>
0183        *        std::map<DetElement,Alignment>
0184        *        std::multimap<DetElement,Alignment>
0185        *        std::map<std::string,Alignment>        key = DetElement.path()
0186        *        std::multimap<std::string,Alignment>   key = DetElement.path()
0187        */
0188       virtual int operator()(DetElement de, int level=0)  const final;
0189     };
0190 
0191     /// Creator function for alignment collector objects
0192     template <typename T> inline
0193     AlignmentsCollector<typename std::remove_reference<T>::type> alignmentsCollector(ConditionsMap& m, T&& alignments)
0194     { return AlignmentsCollector<typename std::remove_reference<T>::type>(m, alignments); }
0195 
0196   }    /* End namespace align  */
0197 }      /* End namespace dd4hep      */
0198 #endif // DD4HEP_ALIGNMENTSPROCESSOR_H