CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/MagneticField/GeomBuilder/src/MagGeoBuilderFromDDD.h

Go to the documentation of this file.
00001 #ifndef MagGeoBuilderFromDDD_H
00002 #define MagGeoBuilderFromDDD_H
00003 
00013 #include "DataFormats/GeometrySurface/interface/ReferenceCounted.h" 
00014 #include "MagneticField/Interpolation/interface/MagProviderInterpol.h"
00015 
00016 #include "DetectorDescription/Core/interface/DDCompactView.h"
00017 
00018 #include <string>
00019 #include <vector>
00020 #include <map>
00021 #include <memory>
00022 
00023 class Surface;
00024 class MagBLayer;
00025 class MagESector;
00026 class MagVolume6Faces;
00027 namespace magneticfield {
00028   class VolumeBasedMagneticFieldESProducer;
00029   class AutoMagneticFieldESProducer;
00030 
00031   typedef std::map<unsigned, std::pair<std::string, int> > TableFileMap;
00032 }
00033 
00034 
00035 class MagGeoBuilderFromDDD  {
00036 public:
00038   MagGeoBuilderFromDDD(std::string tableSet_, int geometryVersion, bool debug=false);
00039 
00041   virtual ~MagGeoBuilderFromDDD();
00042 
00046   void setScaling(const std::vector<int>& keys, const std::vector<double>& values);
00047 
00048   void setGridFiles(const std::auto_ptr<magneticfield::TableFileMap> gridFiles);
00049 
00051   std::vector<MagBLayer*> barrelLayers() const;
00052 
00054   std::vector<MagESector*> endcapSectors() const;
00055 
00056   float maxR() const;
00057 
00058   float maxZ() const;  
00059 
00060 private:
00061   typedef ConstReferenceCountingPointer<Surface> RCPS;
00062 
00063   // Build the geometry. 
00064   //virtual void build();
00065   virtual void build(const DDCompactView & cpv);
00066 
00067 
00068   // FIXME: only for temporary tests and debug, to be removed
00069   friend class TestMagVolume;
00070   friend class MagGeometry;
00071   friend class magneticfield::VolumeBasedMagneticFieldESProducer;
00072   friend class magneticfield::AutoMagneticFieldESProducer;
00073 
00074 
00075   std::vector<MagVolume6Faces*> barrelVolumes() const;  
00076   std::vector<MagVolume6Faces*> endcapVolumes() const;
00077 
00078   // Temporary container to manipulate volumes and their surfaces.
00079   class volumeHandle;
00080   typedef std::vector<volumeHandle*> handles;
00081 
00082   // Build interpolator for the volume with "correct" rotation
00083   void buildInterpolator(const volumeHandle * vol, 
00084                          std::map<std::string, MagProviderInterpol*>& interpolators);
00085 
00086   // Build all MagVolumes setting the MagProviderInterpol
00087   void buildMagVolumes(const handles & volumes,
00088                        std::map<std::string, MagProviderInterpol*> & interpolators);
00089 
00090   // Print checksums for surfaces.
00091   void summary(handles & volumes);
00092 
00093   // Perform simple sanity checks
00094   void testInside(handles & volumes);
00095 
00096   // A layer of barrel volumes.
00097   class bLayer;
00098   // A sector of volumes in a layer.
00099   class bSector;
00100   // A rod of volumes in a sector.
00101   class bRod;
00102   // A slab of volumes in a rod.
00103   class bSlab;
00104   // A sector of endcap volumes.
00105   class eSector;  
00106   // A layer of volumes in an endcap sector.
00107   class eLayer;
00108  
00109   
00110   // Extractors for precomputed_value_sort (to sort containers of volumeHandles). 
00111   typedef std::unary_function<const volumeHandle*, double> uFcn;
00112   struct ExtractZ;
00113   struct ExtractAbsZ;
00114   struct ExtractPhi;
00115   struct ExtractPhiMax;
00116   struct ExtractR;
00117   struct ExtractRN;
00118   struct LessDPhi;
00119   // This one to be used only for max_element and min_element
00120   struct LessZ;
00121 
00122   handles bVolumes;  // the barrel volumes.
00123   handles eVolumes;  // the endcap volumes.
00124 
00125   std::vector<MagBLayer*> mBLayers; // Finally built barrel geometry
00126   std::vector<MagESector*> mESectors; // Finally built barrel geometry
00127 
00128   std::string tableSet; // Version of the data files to be used
00129   int geometryVersion;  // Version of MF geometry 
00130 
00131   std::map<int, double> theScalingFactors;
00132   std::auto_ptr<magneticfield::TableFileMap> theGridFiles;
00133 
00134   static bool debug;
00135 
00136 };
00137 #endif