Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:13:38

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 
0014 #ifndef XML_LAYERING_H
0015 #define XML_LAYERING_H
0016 
0017 // Framework include files
0018 #include <XML/XMLElements.h>
0019 
0020 // C/C++ include files
0021 #include <vector>
0022 
0023 /// Namespace for the AIDA detector description toolkit
0024 namespace dd4hep {
0025 
0026   /// Class to describe the slice of one layer in a layering stack
0027   /**
0028    *  \author  M.Frank
0029    *  \version 1.0
0030    *  \ingroup DD4HEP
0031    */
0032   class LayerSlice {
0033   public:
0034     bool _sensitive;
0035     double _thickness;
0036     std::string _material;
0037     /// Initializing constructor
0038     LayerSlice(bool sens, double thick, const std::string& mat);
0039     /// Copy constructor
0040     LayerSlice(const LayerSlice& copy) = default;
0041     /// Assignment operator
0042     LayerSlice& operator=(const LayerSlice& copy) = default;
0043   };
0044 
0045   /// Initializing constructor
0046   inline LayerSlice::LayerSlice(bool sens, double thick, const std::string& mat)
0047     : _sensitive(sens), _thickness(thick), _material(mat) {
0048   }
0049 
0050   /// Class to describe one layer in a layering stack
0051   /**
0052    *  \author  M.Frank
0053    *  \version 1.0
0054    *  \ingroup DD4HEP
0055    */
0056   class Layer {
0057   public:
0058     double _thickness = 0.0;
0059     double _preOffset = 0.0;
0060     std::vector<LayerSlice> _slices;
0061 
0062     /// Default constructor
0063     Layer() = default;
0064     /// Copy constructor
0065     Layer(const Layer& copy) = default;
0066     /// Assignment operator
0067     Layer& operator=(const Layer& copy) = default;
0068 
0069     void compute();
0070     double thickness() const {
0071       return _thickness;
0072     }
0073     double thicknessWithPreOffset() const {
0074       return _thickness + _preOffset;
0075     }
0076     void add(const LayerSlice& slice) {
0077       _slices.emplace_back(slice);
0078     }
0079   };
0080 
0081   /// Class to describe a layering stack
0082   /**
0083    *  \author  M.Frank
0084    *  \version 1.0
0085    *  \ingroup DD4HEP
0086    */
0087   class LayerStack {
0088   public:
0089     std::vector<Layer*> _layers;
0090     /// Default constructor
0091     LayerStack() = default;
0092     /// Copy constructor
0093     LayerStack(const LayerStack& copy) = default;
0094     /// Default destructor
0095     ~LayerStack()  = default;
0096     /// Assignment operator
0097     LayerStack& operator=(const LayerStack& copy)  = default;
0098     std::vector<Layer*>& layers() {
0099       return _layers;
0100     }
0101     const std::vector<Layer*>& layers() const {
0102       return _layers;
0103     }
0104     double sectionThickness(size_t is, size_t ie) const;
0105     double totalThickness() const {
0106       return sectionThickness(0, _layers.size() - 1);
0107     }
0108   };
0109 
0110   /// Class to convert a layering object from the compact notation
0111   /**
0112    *  \author  M.Frank
0113    *  \version 1.0
0114    *  \ingroup DD4HEP
0115    */
0116   class Layering {
0117   public:
0118     LayerStack _stack;
0119     /// Default constructor
0120     Layering() = default;
0121     /// Initializing constructor
0122     Layering(xml::Element element);
0123     /// Default destructor
0124     ~Layering();
0125 
0126     std::vector<Layer*>& layers() {
0127       return _stack.layers();
0128     }
0129     const Layer* layer(size_t which) const;
0130 
0131     double totalThickness() const {
0132       return _stack.totalThickness();
0133     }
0134     double singleLayerThickness(xml::Element e) const;
0135     double absorberThicknessInLayer(xml::Element e) const;
0136     void sensitivePositionsInLayer(xml::Element e,std::vector<double>& sens_pos) const;
0137 
0138   };
0139 
0140   /// Namespace containing utilities to parse XML files using XercesC or TinyXML
0141   namespace xml {
0142 
0143     /// XML converter for layering objects
0144     /**
0145      *  \author  M.Frank
0146      *  \version 1.0
0147      *  \ingroup DD4HEP_XML
0148      */
0149     class LayeringCnv: public Element {
0150     public:
0151       /// Initializing constructor
0152       LayeringCnv(Element e);
0153       /// Invoke converter
0154       void fromCompact(Layering& layering) const;
0155     };
0156 
0157     /// Initializing constructor
0158     inline LayeringCnv::LayeringCnv(Element e)
0159       : Element(e) {
0160     }
0161   }
0162 }         /* End namespace dd4hep          */
0163 #endif // XML_LAYERING_H