Public Member Functions | |
| GenTester (const char *genFile) | |
| ~GenTester (void) | |
| TVector3 | GetBFieldAtNearestGenerator (TVector3 &v) |
Private Member Functions | |
| float | SumSquares (float x, float y) |
Private Attributes | |
| vector< TVector3 > * | fGens |
| vector< TVector3 > * | fBfld |
Static Private Attributes | |
| const int | kDefaultNumGens = 3072 |
|
|
Definition at line 338 of file BfldDebugData.cc. References fBfld, fGens, and MSG. 00338 {
00339 MSG("Bfldtest",Msg::kInfo) << "Reading in generator file " << genFileName
00340 << endl;
00341
00342 ifstream genFile(genFileName,ios::in);
00343 if(!genFile.good()) {
00344 MSG("Bfldtest",Msg::kFatal) << "Couldn't open generator file "
00345 << genFileName << endl;
00346 MSG("Bfldtest",Msg::kFatal) << "Bailing out entirely." << endl;
00347 exit(1);
00348 }
00349
00350 float id, x, y, z, bx, by, bz;
00351 fGens = new vector<TVector3>(kDefaultNumGens);
00352 fBfld = new vector<TVector3>(kDefaultNumGens);
00353
00354 int i = 0,n = fGens->size();
00355 do {
00356 genFile >> id >> x >> y >> z >> bx >> by >> bz;
00357 if(i >= n) {
00358 n *= 2;
00359 fGens->resize(n);
00360 fBfld->resize(n);
00361 }
00362
00363 (*fGens)[i].SetXYZ(x,y,z);
00364 (*fBfld)[i].SetXYZ(bx,by,bz);
00365 ++i;
00366 } while(!genFile.eof() && !genFile.fail());
00367
00368 //For some reason, the last point read in is garbage because
00369 //the last line of the file is read twice. Discard it.
00370
00371 fGens->resize(i - 1);
00372 fBfld->resize(i - 1);
00373
00374 MSG("Bfldtest",Msg::kInfo) << "Read in " << i - 1 << " generators..."
00375 << endl;
00376 }
|
|
|
Definition at line 379 of file BfldDebugData.cc. 00379 {
00380 delete fGens;
00381 delete fBfld;
00382 }
|
|
|
Definition at line 384 of file BfldDebugData.cc. References fGens, MSG, and SumSquares(). Referenced by StoreDataPoint(). 00384 {
00385
00386 float bestDistSqr = SumSquares((*fGens)[0].X() - v.X(),
00387 (*fGens)[0].Y() - v.Y());
00388 int bestGen = 0;
00389 float distSqr;
00390
00391 int n = fGens->size(), i;
00392
00393 for(i = 1;i < n;i++) {
00394 distSqr = SumSquares(v.X() - (*fGens)[i].X(),v.Y() - (*fGens)[i].Y());
00395 if(distSqr < bestDistSqr) {
00396 bestGen = i;
00397 bestDistSqr = distSqr;
00398 }
00399 }
00400
00401 MSG("Bfldtest",Msg::kDebug)
00402 << "Nearest generator to (" << v.X() << "," << v.Y() << "): ("
00403 << (*fGens)[bestGen].X() << "," << (*fGens)[bestGen].Y() << ")"
00404 << endl;
00405
00406 return (*fBfld)[bestGen];
00407 }
|
|
||||||||||||
|
Definition at line 55 of file BfldDebugData.cc. Referenced by GetBFieldAtNearestGenerator(). 00055 {
00056 return x * x + y * y;
00057 }
|
|
|
Definition at line 62 of file BfldDebugData.cc. Referenced by GenTester(). |
|
|
Definition at line 61 of file BfldDebugData.cc. Referenced by GenTester(), and GetBFieldAtNearestGenerator(). |
|
|
Definition at line 59 of file BfldDebugData.cc. |
1.3.9.1