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

BfldMeshVoronoi.cxx

Go to the documentation of this file.
00001 
00002 // $Id: BfldMeshVoronoi.cxx,v 1.11 2005/02/03 23:00:29 rhatcher Exp $
00003 // 
00004 // BfldMeshVoronoi 
00005 // 
00006 // This structure provides services for a 2d mesh representing an array of
00007 // points where magnetic field map is "known".
00008 //
00009 // This particular type is specialized to deal with a Voronoi mesh
00010 //
00011 // Author:  R. Hatcher 2000.06.20
00012 //
00014 #include "BField/BfldMeshVoronoi.h"
00015 
00016 #include "MessageService/MsgService.h"
00017 CVSID("$Id: BfldMeshVoronoi.cxx,v 1.11 2005/02/03 23:00:29 rhatcher Exp $");
00018 
00019 // necessary so that one can check "InheritsFrom"
00020 #include "TClass.h"
00021 // for expanding filename
00022 #include "TSystem.h"
00023 
00024 #include <iostream>
00025 #include <fstream>
00026 #include <iomanip>
00027 
00028 ClassImp(BfldMeshVoronoi)
00029 
00030 //_____________________________________________________________________________
00031 BfldMeshVoronoi::BfldMeshVoronoi() 
00032    : BfldMesh()
00033 {
00034 
00035 }
00036 
00037 //_____________________________________________________________________________
00038 BfldMeshVoronoi::BfldMeshVoronoi(BfldGrid::Grid_t grid, Int_t variant) 
00039    : BfldMesh(grid,variant)
00040 {
00041    // read in a Mesh ... generator positions currently in Map file
00042 
00043    // map from grid+variant to a file or database record
00044    switch (grid) {
00045    case BfldGrid::kNearCoarseV: fFilename = "NearDetMesh.default";
00046       break;
00047    default:
00048       MSG("Bfld",Msg::kWarning)
00049          << "BfldMeshVoronoi not yet supported for grid " <<
00050          BfldGrid::AsString(grid) << endl;
00051       return;
00052       break;
00053    }
00054 
00055    Msg::LogLevel_t verbosity = Msg::kDebug;
00056 
00057    MSG("Bfld",verbosity) << "BfldMeshVoronoi::ctor "
00058                          << fFilename << endl;
00059 
00060    Int_t ngen = 0;
00061    Int_t i = 0;
00062    Int_t NodeID = 0;
00063    Int_t VorCell;
00064    Int_t VorCellLast = -999;
00065    Float_t x, y;
00066 
00067    ifstream DATA(fFilename.c_str(),ios::in);
00068    if(!DATA) {
00069       MSG("Bfld",Msg::kWarning) << "BfldMeshVoronoi No such file: " 
00070                                 << fFilename << endl;
00071       return;
00072    }
00073 
00074    DATA >> ngen;
00075    // allocate a container
00076    fPositions = new TClonesArray("TVector3",ngen);
00077 
00078    while(!DATA.eof()){
00079       DATA >> NodeID >> VorCell >> x >> y;
00080       if (NodeID>=0 && VorCell != VorCellLast) {
00081          //         fPositions->Add(new TVector3(x,y,VorCell),NodeID); 
00082          new((*fPositions)[NodeID]) TVector3(x,y,VorCell);
00083          VorCellLast = VorCell;
00084       } else {
00085          MSG("Bfld",verbosity) 
00086             << "BfldMeshVoronoi::ctor NodeID<0 "
00087             << NodeID << " ( VorCell " << VorCell << " ) " << endl;
00088       }
00089       i++; 
00090    }
00091    DATA.close(); 
00092 
00093    MSG("Bfld",verbosity) << "BfldMeshVoronoi file read in " 
00094                          << i << " nodes " << endl;
00095 
00096    fReadOk = kTRUE;
00097 
00098 }
00099 
00100 //_____________________________________________________________________________
00101 BfldMeshVoronoi::~BfldMeshVoronoi()
00102 {
00103    MSG("Bfld",Msg::kDebug) 
00104      << "~BfldMeshVoroni grid " << BfldGrid::AsString(fGrid) 
00105      << endl;
00106 }
00107 
00108 //_____________________________________________________________________________
00109 TVector3 BfldMeshVoronoi::GetGeneratorPosition(Int_t /* nodeid */)
00110 {
00111    // return the TVector3 associated with a generator (mesh node)
00112 
00113    Float_t x = 0;
00114    Float_t y = 0;
00115    return TVector3(x,y,0.);
00116 }
00117 
00118 //_____________________________________________________________________________
00119 Int_t BfldMeshVoronoi::FindANSYSGenerator(Int_t VoronCellID)
00120 {
00121   Int_t NodeID = 1;
00122   TIter next(fPositions);
00123   TVector3 * genVec3;
00124 
00125   while( (genVec3 = (TVector3*)next()) ) {
00126      if( genVec3->Z() == VoronCellID ) return NodeID;
00127      NodeID++;  
00128   }
00129 
00130   return -1;
00131 }
00132 
00133 //_____________________________________________________________________________

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