Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef MagGeoBuilderFromDDD_H
0002 #define MagGeoBuilderFromDDD_H
0003 
0004 /** \class MagGeoBuilderFromDDD
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
0010  */
0011 #include "MagneticField/Interpolation/interface/MagProviderInterpol.h"
0012 
0013 #include "DetectorDescription/Core/interface/DDCompactView.h"
0014 #include "CondFormats/MFObjects/interface/MagFieldConfig.h"
0015 
0016 #include <string>
0017 #include <vector>
0018 #include <map>
0019 #include <memory>
0020 
0021 class Surface;
0022 class MagBLayer;
0023 class MagESector;
0024 class MagVolume6Faces;
0025 namespace magneticfield {
0026   class VolumeBasedMagneticFieldESProducer;
0027   class VolumeBasedMagneticFieldESProducerFromDB;
0028   class BaseVolumeHandle;  // Needs to be public to share code with DD4hep
0029   using handles = std::vector<BaseVolumeHandle*>;
0030 }  // namespace magneticfield
0031 
0032 class MagGeoBuilderFromDDD {
0033 public:
0034   /// Constructor.
0035   MagGeoBuilderFromDDD(std::string tableSet_, int geometryVersion, bool debug = false);
0036 
0037   /// Destructor
0038   virtual ~MagGeoBuilderFromDDD();
0039 
0040   ///  Set scaling factors for individual volumes.
0041   /// "keys" is a vector of 100*volume number + sector (sector 0 = all sectors)
0042   /// "values" are the corresponding scaling factors
0043   void setScaling(const std::vector<int>& keys, const std::vector<double>& values);
0044 
0045   void setGridFiles(const magneticfield::TableFileMap& gridFiles);
0046 
0047   /// Get barrel layers
0048   std::vector<MagBLayer*> barrelLayers() const;
0049 
0050   /// Get endcap layers
0051   std::vector<MagESector*> endcapSectors() const;
0052 
0053   float maxR() const;
0054 
0055   float maxZ() const;
0056 
0057   // Temporary container to manipulate volumes and their surfaces.
0058   class volumeHandle;  // Needs to be public to share code with DD4hep
0059 
0060 private:
0061   // Build the geometry.
0062   //virtual void build();
0063   virtual void build(const DDCompactView& cpv);
0064 
0065   // FIXME: only for temporary tests and debug, to be removed
0066   friend class TestMagVolume;
0067   friend class MagGeometry;
0068   friend class magneticfield::VolumeBasedMagneticFieldESProducer;
0069   friend class magneticfield::VolumeBasedMagneticFieldESProducerFromDB;
0070 
0071   std::vector<MagVolume6Faces*> barrelVolumes() const;
0072   std::vector<MagVolume6Faces*> endcapVolumes() const;
0073 
0074   // Build interpolator for the volume with "correct" rotation
0075   void buildInterpolator(const volumeHandle* vol, std::map<std::string, MagProviderInterpol*>& interpolators);
0076 
0077   // Build all MagVolumes setting the MagProviderInterpol
0078   void buildMagVolumes(const magneticfield::handles& volumes,
0079                        std::map<std::string, MagProviderInterpol*>& interpolators);
0080 
0081   // Print checksums for surfaces.
0082   void summary(magneticfield::handles& volumes);
0083 
0084   // Perform simple sanity checks
0085   void testInside(magneticfield::handles& volumes);
0086 
0087   magneticfield::handles bVolumes;  // the barrel volumes.
0088   magneticfield::handles eVolumes;  // the endcap volumes.
0089 
0090   std::vector<MagBLayer*> mBLayers;    // Finally built barrel geometry
0091   std::vector<MagESector*> mESectors;  // Finally built barrel geometry
0092 
0093   std::string tableSet;  // Version of the data files to be used
0094   int geometryVersion;   // Version of MF geometry
0095 
0096   std::map<int, double> theScalingFactors;
0097   const magneticfield::TableFileMap* theGridFiles;  // Non-owned pointer assumed to be valid until build() is called
0098 
0099   const bool debug;
0100 };
0101 #endif