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

BFLHandler.cxx

Go to the documentation of this file.
00001 #include <iostream>
00002 using std::cerr;
00003 
00004 #include <fstream>
00005 #include <string.h>
00006 
00007 #ifndef CSTDLIB
00008 #include <cstdlib>
00009 #define CSTDLIB
00010 #endif
00011 
00012 #include <TVector3.h>
00013 #include <stdlib.h>
00014 
00015 #include "BField/BFLInterpolation.h" 
00016 #include "BField/BFLWingedEdge.h"
00017 #include "BField/BFLHandler.h"
00018 #include "BField/BFLNode.h"
00019 
00020 ClassImp(BFLHandler) 
00021 
00022 BFLHandler::BFLHandler(Int_t DetectorToLoadDefaults)
00023 {
00024   Char_t VoronoiFile[] = "NearDetVorD.default";
00025   Char_t MeshFile[]    = "NearDetMesh.default";
00026   Char_t BFieldFile[]  = "NearDetBFld.default";
00027   
00028   switch(DetectorToLoadDefaults) {
00029     case (1):
00030        strcpy(VoronoiFile,"FarDetVorD.default");
00031        strcpy(MeshFile,   "FarDetMesh.default");
00032        strcpy(BFieldFile, "FarDetBFld.default");
00033        break;
00034     case (0): 
00035        strcpy(VoronoiFile,"NearDetVorD.default");
00036        strcpy(MeshFile,   "NearDetMesh.default");
00037        strcpy(BFieldFile, "NearDetBFld.default");
00038        break;
00039     default:      
00040        strcpy(VoronoiFile,"NearDetVorD.default");
00041        strcpy(MeshFile,   "NearDetMesh.default");
00042        strcpy(BFieldFile, "NearDetBFld.default");
00043        break;
00044   } 
00045   
00046   fBField = new TObjArray(1000);     /* BF Vectors */ 
00047   fVor = new BFLWingedEdge();        /* A Voronoi diagram object */
00048 
00049   LoadBField(BFieldFile);            /* Fill fBField */ 
00050   fVor->Load(VoronoiFile);           /* Fill fVor */ 
00051   fVor->LoadNodalSet(MeshFile);      /* Fill fGenerators */
00052 
00053   fInt = new BFLInterpolation(fBField, fVor); 
00054 }
00056 
00057 BFLHandler::BFLHandler(Char_t VoronoiFile[], Char_t MeshFile[], 
00058                        Char_t BFieldFile[])
00059 { 
00060   fBField = new TObjArray(1000);     /* BF Vectors */ 
00061   fVor = new BFLWingedEdge();        /* A Voronoi diagram object */
00062   
00063   LoadBField(BFieldFile);            /* Fill fBField */ 
00064   fVor->Load(VoronoiFile);           /* Fill fVor */ 
00065   fVor->LoadNodalSet(MeshFile); 
00066   
00067   fInt = new BFLInterpolation(fBField, fVor); 
00068 }
00070 
00071 BFLHandler::~BFLHandler()
00072 {
00073     delete fInt;    fInt=0;
00074     // already done by BFLInterpolation //delete fVor;    fVor=0;
00075     // already done by BFLInterpolation //delete fBField; fBField=0;
00076 }
00078 
00079 Int_t BFLHandler::LoadBField(Char_t BFieldFile[])
00080 {
00081   Int_t NodeID = 0;
00082   Float_t bx, by, bz;
00083   Int_t NodeIDLast = -999;
00084   
00085   ifstream DATA(BFieldFile,std::ios::in);
00086   if(!DATA) {
00087      cerr << "No such file: " << BFieldFile << endl;
00088      exit(1);
00089   }
00090 
00091   while(!DATA.eof()){
00092      DATA >> NodeID >> bx >> by >> bz; 
00093      if (NodeID != NodeIDLast) 
00094         fBField->AddAtAndExpand(new TVector3(bx,by,bz),NodeID);     
00095      NodeIDLast = NodeID;
00096   }
00097   DATA.close(); 
00098 
00099   return 0;
00100 } 
00102 
00103 TVector3 BFLHandler::GetBField(const TVector3& GlobalPosVector,
00104                                const Bool_t updateSeedPolygon)
00105 {
00106     return fInt->GetB(GlobalPosVector,updateSeedPolygon);
00107 }

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