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

TestPerf.cc File Reference

#include <iostream>
#include <fstream>
#include <vector>
#include "TVector3.h"
#include "TStopwatch.h"
#include "BField/BfldValidate.h"
#include "BField/BfldLoanPool.h"
#include "MessageService/MsgService.h"
#include "TestConstants.h"

Go to the source code of this file.

Classes

class  PerfTestFile

Functions

 CVSID ("$Id: TestPerf.cc,v 1.3 2001/08/21 19:42:54 agoldst Exp $")
void BenchmarkPerformance (const char *outFileName, const char *rectMapFileName, const char *vorMapFileName, const char *vorMeshFileName, const char *vorBFldFileName, const char *testPtsFileName)
double RectPerformanceTest (const char *mapFileName, BfldInterpMethod::InterpMethod_t interpMethod, vector< TVector3 > &testPts)
double VorPerformanceTest (const char *vorMapFileName, const char *meshFileName, const char *vorBFieldFileName, BfldInterpMethod::InterpMethod_t interpMethod, vector< TVector3 > &testPts)
int GetNumPointsRect (const char *fileName)
int GetNumPointsVor (const char *fileName)
BFieldNewBFieldRect (const char *mapFileName)
BFieldNewBFieldVor (const char *vorMapFileName, const char *meshFileName, const char *vorBFieldFileName)
void GetPerfTestPts (vector< TVector3 > &pts, const char *fileName)

Variables

const int kDefaultNumPerfTestPts = 1224


Function Documentation

void BenchmarkPerformance const char *  outFileName,
const char *  rectMapFileName,
const char *  vorMapFileName,
const char *  vorMeshFileName,
const char *  vorBFldFileName,
const char *  testPtsFileName
 

Referenced by main().

CVSID "$Id: TestPerf.  cc,
v 1.3 2001/08/21 19:42:54 agoldst Exp $" 
 

int GetNumPointsRect const char *  fileName  ) 
 

int GetNumPointsVor const char *  fileName  ) 
 

void GetPerfTestPts vector< TVector3 > &  pts,
const char *  fileName
 

Definition at line 196 of file TestPerf.cc.

References MSG.

Referenced by BenchmarkPerformance().

00196                                                                 {
00197   //Read fileName into pts
00198   //For now, assume the file has the format of NuMuEventHits.dat
00199   //To wit, each line is int id, float x, float y, float z.
00200   //And the units are cm.
00201   //What does Swimmer output look like? This should really be isolated out.
00202 
00203   MSG("Bfldtest",Msg::kDebug) << "Reading in performance test points file "
00204                               << fileName << endl;
00205 
00206   ifstream inFile(fileName,ios::in);
00207   if(!inFile.good()) {
00208     MSG("Bfldtest",Msg::kWarning)
00209       << "Error opening file " << fileName << endl;
00210     return;
00211   }
00212 
00213   int n = pts.size();
00214   int i = 0;
00215 
00216   int id_ignored;
00217   float x,y,z;
00218 
00219   while(!inFile.eof()) {
00220     inFile >> id_ignored >> x >> y >> z;
00221     if(i >= n) {
00222       n *= 2;
00223       pts.resize(n);
00224     }
00225 
00226     pts[i].SetXYZ(x / 100.0,y / 100.0,z / 100.0);
00227     i++;
00228   }
00229   
00230   pts.resize(i);
00231 }

BField* NewBFieldRect const char *  mapFileName  ) 
 

BField* NewBFieldVor const char *  vorMapFileName,
const char *  meshFileName,
const char *  vorBFieldFileName
 

double RectPerformanceTest const char *  mapFileName,
BfldInterpMethod::InterpMethod_t  interpMethod,
vector< TVector3 > &  testPts
 

Definition at line 126 of file TestPerf.cc.

References BField::GetBField(), MSG, NewBFieldRect(), BField::SetInterpMethod(), and timer().

Referenced by BenchmarkPerformance().

00128                                                       {
00129   //For the given mapFile, time how long it takes to compute the B field
00130   //by rectilinear interpolation at the points given in the performance test
00131   //point file--typically consisting of a number of plausible paths of muons
00132   //through the detectors.
00133 
00134   //Here should set up the rect interpolator (BField theField) using mapFile.
00135   //Will have to rewrite Bfld package to accept an arbitrary file in this form.
00136   //This should not take too much work. Otherwise, can be kludged.
00137 
00138   MSG("Bfldtest",Msg::kDebug) << "Beginning performance test..." << endl;
00139 
00140   BField *theField = NewBFieldRect(mapFileName);
00141   theField->SetInterpMethod(interpMethod);
00142 
00143   TVector3 b;
00144   int i;
00145   TStopwatch timer;
00146 
00147   theField->GetBField(testPts[0]);
00148   //We make a dummy call because the first call on GetBField has
00149   //lots of overhead (allocating maps, etc.)
00150 
00151   timer.Start();
00152   for(i = 0;i < testPts.size();++i)
00153     b = theField->GetBField(testPts[i]);
00154   timer.Stop();
00155 
00156   delete theField; //NewBFieldRect allocates memory!
00157 
00158   MSG("Bfldtest",Msg::kDebug) << "Test done." << endl;
00159 
00160   return timer.CpuTime();
00161 }

double VorPerformanceTest const char *  vorMapFileName,
const char *  meshFileName,
const char *  vorBFieldFileName,
BfldInterpMethod::InterpMethod_t  interpMethod,
vector< TVector3 > &  testPts
 

Definition at line 163 of file TestPerf.cc.

References BField::GetBField(), MSG, NewBFieldVor(), BField::SetInterpMethod(), and timer().

Referenced by BenchmarkPerformance().

00166                                                      {
00167   //For the given mapFile, compute the time needed to calculate the B field
00168   //at the points given in the performance test point file using the method
00169   //of the team from Athens, with the given interpolation method.
00170 
00171   BField *theField =  NewBFieldVor(vorMapFileName,meshFileName,
00172                                    vorBFieldFileName);
00173   theField->SetInterpMethod(interpMethod);
00174   TVector3 v,b;
00175   int i;
00176 
00177   theField->GetBField(testPts[0]);
00178   //We make a dummy call because the first call on GetBField has
00179   //lots of overhead (allocating maps, etc.)
00180 
00181   MSG("Bfldtest",Msg::kDebug) << "Beginning performance test..." << endl;
00182 
00183   TStopwatch timer;
00184   timer.Start();
00185   for(i = 0;i < testPts.size();++i)
00186     b = theField->GetBField(testPts[i]);
00187   timer.Stop();
00188 
00189   delete theField;
00190 
00191   MSG("Bfldtest",Msg::kDebug) << "Test done." << endl;
00192 
00193   return timer.CpuTime();
00194 }


Variable Documentation

const int kDefaultNumPerfTestPts = 1224
 

Definition at line 16 of file TestPerf.cc.

Referenced by BenchmarkPerformance().


Generated on Mon Feb 15 11:08:14 2010 for loon by  doxygen 1.3.9.1