CSidcDeltaR.C
//-----------------------------------------------------------------------------
// $Header: /asis/offline/ceres/cool/project/RCS/CSidcDeltaR.C,v 1.2 1997/06/24 16:14:56 messer Exp $
//
// COOL Program Library
// Copyright (C) CERES collaboration, 1996
//
// Implementation of class ...
//
//-----------------------------------------------------------------------------
#include "CSidcDeltaR.h"
#include "CLookupDeltaRadius.h"
#include "CDataStream.h"
CSidcDeltaR::CSidcDeltaR(const char * name)
{
fileName = name;
readIn();
}
CSidcDeltaR::~CSidcDeltaR()
{
}
CSidcDeltaR::CSidcDeltaR(const CSidcDeltaR &)
{
}
CSidcDeltaR & CSidcDeltaR::operator = (const CSidcDeltaR &)
{
return *this;
}
float CSidcDeltaR::getDeltaR(float uncorrectedRadius) const
{
CLookupDeltaRadius testItem(uncorrectedRadius, 0);
int index = items.getIndexOfBestMatch(testItem);
//
// The correction is set to zero at the ends of the vector
//
float radiusCorrection;
if (index <= 0 || index >= items.length()-1)
radiusCorrection = 0;
else
radiusCorrection = items(index)->getDeltaRadius();
return radiusCorrection;
}
void CSidcDeltaR::readIn()
{
if (!fileName) {
cerr << "CSidcDeltaR::readIn> no file name given !! Fatal !!" << endl;
return;
}
Cifstream file;
file.open(fileName);
if (!file) {
cerr << "CSidcDeltaR::readIn> could not open input file " << fileName << " !!" << endl;
return;
}
items.clearAndDestroy();
float newR, newDeltaR;
CLookupDeltaRadius *newItem;
while (!file.eof()) {
file >> newR >> newDeltaR;
if (!file.eof()) {
newItem = new CLookupDeltaRadius(newR, newDeltaR);
items.insert(newItem);
}
}
}