Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

BfldMapVoronoi.cxx

Go to the documentation of this file.
00001 
00002 // $Id: BfldMapVoronoi.cxx,v 1.9 2005/02/09 04:38:11 rhatcher Exp $
00003 // 
00004 // BfldMapVoronoi 
00005 // 
00006 // This structure provides services for holding the magnetic field components
00007 // at a series of points (cf. BfldMesh).  It encapsulates knowledge 
00008 // about the field values themselves, an possibly how to adjust them
00009 // for external effects (chemistry, coil current, etc.) but doesn't
00010 // explicitly hold any knowledge about the relative spatial placement
00011 // of the field values; that it must glean from BfldMesh.
00012 //
00013 // This class is specialized to handle maps associated with Voronoi meshes
00014 //
00015 // Author:  R. Hatcher 2000.06.20
00016 //
00018 #include "BField/BfldMapVoronoi.h"
00019 
00020 #include "BField/BfldMeshVoronoi.h"
00021 
00022 #include "MessageService/MsgService.h"
00023 CVSID("$Id: BfldMapVoronoi.cxx,v 1.9 2005/02/09 04:38:11 rhatcher Exp $");
00024 
00025 // necessary so that one can check "InheritsFrom"
00026 #include "TClass.h"
00027 // for expanding filename
00028 #include "TSystem.h"
00029 #include "TMath.h"
00030 
00031 #include <iostream>
00032 #include <fstream>
00033 #include <iomanip>
00034 
00035 ClassImp(BfldMapVoronoi)
00036 
00037 //_____________________________________________________________________________
00038 BfldMapVoronoi::BfldMapVoronoi() 
00039    : BfldMap()
00040 {
00041 
00042 }
00043 
00044 //_____________________________________________________________________________
00045 BfldMapVoronoi::BfldMapVoronoi(BfldGrid::Grid_t grid, Int_t variant) 
00046    : BfldMap(grid,variant)
00047 {
00048    // read in a Map
00049 
00050    // map from grid+variant to a file or database record
00051    switch (grid) {
00052    case BfldGrid::kNearCoarseV: 
00053       fDataSource = "NearDetBFld.default";
00054       fGeneratedCoilCurrent = 1.0; // should be part of the file
00055       break;
00056    default:
00057       MSG("Bfld",Msg::kWarning)
00058          << "BfldMapVoronoi not yet supported for grid " <<
00059          BfldGrid::AsString(grid) << " variant " << variant << endl;
00060       return;
00061       break;
00062    }
00063 
00064    Msg::LogLevel_t verbosity = Msg::kDebug;
00065 
00066    MSG("Bfld",verbosity) << "BfldMapVoronoi::ctor "
00067                          << fDataSource << endl;
00068 
00069    Int_t i = 0;
00070    Int_t NodeID = 0;
00071    Float_t bx, by, bz;
00072    Int_t NodeIDLast = -999;
00073 
00074    // allocate a container, don't know the size needed yet so 
00075    // take a guess ... actually since there's just but the one
00076    // file (see above) 
00077    Int_t initSize = 4092;
00078    ResizeVectors(initSize);
00079 
00080    ifstream DATA(fDataSource.c_str(),ios::in);
00081    if(!DATA) {
00082       MSG("Bfld",Msg::kWarning) << "BfldMapVoronoi No such file: " 
00083                                 << fDataSource << endl;
00084       return;
00085    }
00086 
00087    while(!DATA.eof()){
00088       DATA >> NodeID >> bx >> by >> bz; 
00089       if (NodeID != NodeIDLast) AddGenerator(NodeID,bx,by,bz);
00090       NodeIDLast = NodeID;
00091       i++;
00092    }
00093    DATA.close(); 
00094 
00095    MSG("Bfld",verbosity) << "BfldMapVoronoi file read in " << i 
00096                          << " vectors " <<endl;
00097 
00098    fFilledOkay = kTRUE;
00099 }
00100 
00101 //_____________________________________________________________________________
00102 BfldMapVoronoi::~BfldMapVoronoi()
00103 {
00104    // dtor deletes owned components
00105 
00106    MSG("Bfld",Msg::kInfo) << "~BfldMapVoronoi variant " << fVariant << endl;
00107 
00108    fGrid    = BfldGrid::kUndefined;
00109    fVariant = -1;
00110 
00111 }
00112 
00113 //_____________________________________________________________________________

Generated on Mon Feb 15 11:06:25 2010 for loon by  doxygen 1.3.9.1