00001
00002
00003
00004
00005
00006
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";
00032 LoadLookupTable(fLookupFilename);
00033 break;
00034 default:
00035
00036
00037
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
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
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
00084 while(!LOOKUP.eof()) {
00085 LOOKUP >> CellID >> Node1 >> Node2 >> Node3 >> Node4;
00086
00087
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