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

BFLAnsysLookup.cxx

Go to the documentation of this file.
00001 
00002 //
00003 //  Author: Costas Andreopoulos
00004 //  Last revision: March 8, 2001
00005 //
00006 //  (c) 2001 University of Athens
00008 
00009 #include <cstdlib>
00010 #include <fstream>
00011 #include "TObjArray.h"
00012 
00013 #include "MessageService/MsgService.h"
00014 #include "BField/BFLAnsysLookup.h"
00015 
00016 ClassImp(BFLAnsysLookup)
00017 
00018 //_____________________________________________________________________
00019 BFLAnsysLookup::BFLAnsysLookup()
00020    : BFLLookupTable()
00021 {
00022 
00023 }
00024 //_____________________________________________________________________
00025 BFLAnsysLookup::BFLAnsysLookup(BfldGrid::Grid_t grid)
00026    : BFLLookupTable(grid)
00027 {
00028 
00029    switch(grid) {
00030    case BfldGrid::kNearCoarseV: 
00031        fLookupFilename = "NearDetANSYSLookup.default"; // tmp - hardcoded
00032        LoadLookupTable(fLookupFilename);
00033        break;
00034    default:
00035       // MSG("BFL",Msg::kWarning)
00036       //    << "Lookup table not yet supported for grid " <<
00037       //    BfldGrid::AsString(grid) << endl;
00038        break;
00039    }
00040 
00041 }
00042 //_____________________________________________________________________
00043 BFLAnsysLookup::~BFLAnsysLookup()
00044 {
00045    fGrid = BfldGrid::kUndefined;   
00046    if(fTable) fTable->Delete();
00047    delete fTable;
00048 }
00049 //_____________________________________________________________________
00050 void BFLAnsysLookup::FindNode(Int_t node, TObjArray * result)
00051 {
00052 // return all lookup table entries where Node ID = node
00053 //
00054   TIter next(fTable);
00055   BFLNode2ACell * entry;
00056   while( (entry = (BFLNode2ACell*)next()) ){
00057      if( entry->GetNodeID() == node ) result->Add(entry->Clone());
00058   }
00059 } 
00060 //_____________________________________________________________________
00061 void BFLAnsysLookup::FindCell(Int_t cell, TObjArray * result)
00062 {
00063 // return all lookup table entries where Cell ID = cell
00064 //
00065   TIter next(fTable);
00066   BFLNode2ACell * entry;
00067   while( (entry = (BFLNode2ACell*)next()) ){
00068      if( entry->GetCellID() == cell ) result->Add(entry->Clone());
00069   }
00070 } 
00071 //_____________________________________________________________________
00072 void BFLAnsysLookup::LoadLookupTable(TString filename)
00073 {
00074    Int_t CellID = -1, Node1 = -1, Node2 = -1, Node3 = -1, Node4 = -1,  i = 0;
00075    Int_t nodes[kNMaxNodesPerACell] = { 0, 1, 2, 3};
00076 
00077    ifstream LOOKUP(filename,ios::in);
00078    if(!LOOKUP) {
00079       cerr << "BFLAnsysLookup::LoadLookupTable : No such file as " << filename << endl;
00080       exit(1);
00081    }
00082 
00083    // --- lookup table has a very simple (repetitive) structure
00084    while(!LOOKUP.eof()) {
00085       LOOKUP >> CellID >> Node1 >> Node2 >> Node3 >> Node4;
00086 
00087       // again -> this structure of the lookup table makes searching easier
00088       fTable->AddAtAndExpand( new BFLNode2ACell(CellID,Node1,nodes), i++);
00089       fTable->AddAtAndExpand( new BFLNode2ACell(CellID,Node2,nodes), i++);
00090       fTable->AddAtAndExpand( new BFLNode2ACell(CellID,Node3,nodes), i++);
00091       fTable->AddAtAndExpand( new BFLNode2ACell(CellID,Node4,nodes), i++);
00092    }
00093    fTable->Sort();
00094 }
00095 //_____________________________________________________________________
00096 

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