Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:22:30

0001 #ifndef MagneticField_GeomBuilder_DD4hep_MagGeoBuilder_h
0002 #define MagneticField_GeomBuilder_DD4hep_MagGeoBuilder_h
0003 
0004 /** \class MagGeoBuilder
0005  *  Parse the XML magnetic geometry, build individual volumes and match their
0006  *  shared surfaces. Build MagVolume6Faces and organise them in a hierarchical
0007  *  structure. Build MagGeometry out of it.
0008  *
0009  *  \author N. Amapane - INFN Torino (original developer)
0010  */
0011 
0012 #include "CondFormats/MFObjects/interface/MagFieldConfig.h"
0013 #include "DataFormats/GeometrySurface/interface/ReferenceCounted.h"
0014 #include "DetectorDescription/DDCMS/interface/DDSpecParRegistry.h"
0015 #include "DetectorDescription/DDCMS/interface/DDDetector.h"
0016 #include "MagneticField/Interpolation/interface/MagProviderInterpol.h"
0017 #include "DD4hep_volumeHandle.h"
0018 
0019 #include <string>
0020 #include <vector>
0021 #include <map>
0022 #include <memory>
0023 
0024 namespace dd4hep {
0025   class Detector;
0026 }
0027 
0028 class Surface;
0029 class MagBLayer;
0030 class MagESector;
0031 class MagVolume6Faces;
0032 
0033 namespace magneticfield {
0034   class InterpolatorBuilder;
0035 
0036   class MagGeoBuilder {
0037   public:
0038     MagGeoBuilder(std::string tableSet, int geometryVersion, bool debug = false, bool useMergeFileIfAvailable = true);
0039 
0040     ~MagGeoBuilder();
0041 
0042     // Build the geometry.
0043     void build(const cms::DDDetector* det);
0044 
0045     ///  Set scaling factors for individual volumes.
0046     /// "keys" is a vector of 100*volume number + sector (sector 0 = all sectors)
0047     /// "values" are the corresponding scaling factors
0048     void setScaling(const std::vector<int>& keys, const std::vector<double>& values);
0049 
0050     void setGridFiles(const TableFileMap& gridFiles);
0051 
0052     /// Get barrel layers
0053     std::vector<MagBLayer*> barrelLayers() const;
0054 
0055     /// Get endcap layers
0056     std::vector<MagESector*> endcapSectors() const;
0057 
0058     float maxR() const;
0059 
0060     float maxZ() const;
0061 
0062     std::vector<MagVolume6Faces*> barrelVolumes() const;
0063     std::vector<MagVolume6Faces*> endcapVolumes() const;
0064 
0065   private:
0066     // Build interpolator for the volume with "correct" rotation
0067     MagProviderInterpol* buildInterpolator(const volumeHandle* vol, InterpolatorBuilder&) const;
0068 
0069     // Build all MagVolumes setting the MagProviderInterpol
0070     void buildMagVolumes(const handles& volumes,
0071                          const std::map<std::string, MagProviderInterpol*>& interpolators) const;
0072 
0073     // Print checksums for surfaces.
0074     void summary(handles& volumes) const;
0075 
0076     // Perform simple sanity checks
0077     void testInside(handles& volumes) const;
0078 
0079     handles bVolumes_;  // the barrel volumes.
0080     handles eVolumes_;  // the endcap volumes.
0081 
0082     std::vector<MagBLayer*> mBLayers_;    // Finally built barrel geometry
0083     std::vector<MagESector*> mESectors_;  // Finally built barrel geometry
0084 
0085     std::string tableSet_;  // Version of the data files to be used
0086     int geometryVersion_;   // Version of MF geometry
0087 
0088     std::map<int, double> theScalingFactors_;
0089     const TableFileMap* theGridFiles_;  // Non-owned pointer assumed to be valid until build() is called
0090 
0091     const bool debug_;
0092     const bool useMergeFileIfAvailable_;
0093   };
0094 }  // namespace magneticfield
0095 #endif