Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 // Magnetic Field Interpolation Test Program (formerly prepareFieldInterpolation.cpp)
0002 // by droll (03/02/04)
0003 // Updated N. Amapane 3/07 -former name
0004 
0005 #include <iostream>
0006 
0007 #include "prepareMagneticFieldGrid.h"
0008 
0009 using namespace std;
0010 
0011 int main(int argc, char **argv) {
0012   if (argc > 4) {
0013     cout << "SYNOPSIS:" << endl << " prepareFieldTable input.table output.bin [sector]" << endl;
0014     cout << "Example:" << endl
0015          << " prepareFieldTable /afs/cern.ch/cms/OO/mag_field/version_85l_030919/v-xyz-217.table grid.217.bin" << endl;
0016     return 1;
0017   }
0018 
0019   string filename1 = argv[1];
0020   string filename2 = argv[2];
0021 
0022   int sector = 0;
0023   if (argc == 4) {
0024     sector = atoi(argv[3]);
0025   }
0026 
0027   cout << "Using Rotation from sector " << sector << endl;
0028 
0029   prepareMagneticFieldGrid MFG001(sector);    // MFG001 for standard cases
0030   MFG001.countTrueNumberOfPoints(filename1);  // check, if file contains some points twice
0031 
0032   MFG001.fillFromFile(filename1);  // determine grid structure (standard cases)
0033   int type = MFG001.gridType();    // grid type
0034   if (type == 0) {
0035     cout << "  standard grid sructure detection failed, retrying with special grid sructure" << endl;
0036   } else {
0037     if (MFG001.isReady())
0038       MFG001.validateAllPoints();  // check position of every point
0039     if (MFG001.isReady()) {
0040       MFG001.saveGridToFile(filename2);  // write grid to disk
0041       cout << " " << endl;
0042       return 0;
0043     }
0044   }
0045 
0046   // MFG001 anlysis was not successful. Different processing for special cases
0047   prepareMagneticFieldGrid MFG002(sector);  // MFG002 for special cases
0048   MFG002.fillFromFileSpecial(filename1);    // determine grid structure (special cases)
0049   type = MFG002.gridType();                 // grid type
0050   if (type == 0)
0051     cout << "  special grid sructure detection failed " << endl;
0052   if (MFG002.isReady())
0053     MFG002.validateAllPoints();  // check position of every point
0054   if (MFG002.isReady()) {
0055     MFG002.saveGridToFile(filename2);  // write grid to disk
0056     cout << " " << endl;
0057     return 0;
0058   }
0059 
0060   return 1;
0061 }