00001 #include "MagneticField/Interpolation/interface/MFGridFactory.h"
00002 #include "MagneticField/Interpolation/src/binary_ifstream.h"
00003 #include "DataFormats/GeometrySurface/interface/GloballyPositioned.h"
00004
00005 #include "MagneticField/Interpolation/src/RectangularCartesianMFGrid.h"
00006 #include "MagneticField/Interpolation/src/RectangularCylindricalMFGrid.h"
00007 #include "MagneticField/Interpolation/src/TrapezoidalCartesianMFGrid.h"
00008 #include "MagneticField/Interpolation/src/TrapezoidalCylindricalMFGrid.h"
00009 #include "MagneticField/Interpolation/src/SpecialCylindricalMFGrid.h"
00010 #include "MagneticField/Interpolation/src/CylinderFromSectorMFGrid.h"
00011
00012 #include <iostream>
00013
00014 using namespace std;
00015
00016 MFGrid* MFGridFactory::build(const string& name, const GloballyPositioned<float>& vol) {
00017 binary_ifstream inFile(name);
00018 int gridType;
00019 inFile >> gridType;
00020
00021 MFGrid* result;
00022 switch (gridType){
00023 case 1:
00024 result = new RectangularCartesianMFGrid(inFile, vol);
00025 break;
00026 case 2:
00027 result = new TrapezoidalCartesianMFGrid(inFile, vol);
00028 break;
00029 case 3:
00030 result = new RectangularCylindricalMFGrid(inFile, vol);
00031 break;
00032 case 4:
00033 result = new TrapezoidalCylindricalMFGrid(inFile, vol);
00034 break;
00035 case 5:
00036 result = new SpecialCylindricalMFGrid(inFile, vol, gridType);
00037 break;
00038 case 6:
00039 result = new SpecialCylindricalMFGrid(inFile, vol, gridType);
00040 break;
00041 default:
00042 cout << "ERROR Grid type unknown: " << gridType << endl;
00043
00044 result = 0;
00045 break;
00046 }
00047 inFile.close();
00048 return result;
00049 }
00050
00051 MFGrid* MFGridFactory::build(const string& name,
00052 const GloballyPositioned<float>& vol,
00053 double phiMin, double phiMax)
00054 {
00055 MFGrid* sectorGrid = build(name,vol);
00056 return new CylinderFromSectorMFGrid( vol, phiMin, phiMax, sectorGrid);
00057 }