// ESAF : Euso Simulation and Analysis Framework
// $Id: OADBHeader.cc,v 1.4 2005/05/03 21:05:02 thea Exp $
// A.Thea, J.Watts created Mar, 16 2004
#include "OADBHeader.hh"
#include "TMath.h"
#include "Riostream.h"
#include "utils.hh"
#include <typeinfo>
ClassImp(OADBHeader)
// ctor
OADBHeader::OADBHeader(): fXYStep(0), fEntranceDiscRadius(0), fNumAngles(0),
fAngles(NULL), fNumWavelengths(0), fWavelengths(NULL), fNumRows(0),
fNumCols(NULL) {
}
// dtor
OADBHeader::~OADBHeader() {
}
// copy
void OADBHeader::Copy( TObject& o) const {
OADBHeader* h = dynamic_cast<OADBHeader*>(&o);
h->fXYStep = fXYStep;
h->fEntranceDiscRadius = fEntranceDiscRadius;
h->fNumRows = fNumRows;
}
// getters
// returns the n of columns of row
Int_t OADBHeader::GetNumCols( Int_t row ) const {
if (row < 0 || row > fNumRows-1 ) return -1;
else return fNumCols[row];
}
// get the i-th angle
Float_t OADBHeader::GetAngle(Int_t i) const {
if (i < 0 || i > fNumAngles-1 ) return -1;
else return fAngles[i];
}
// get the i-th wavelength
Float_t OADBHeader::GetWavelength(Int_t i) const {
if (i < 0 || i > fNumWavelengths-1 ) return -1;
else return fWavelengths[i];
}
// returns the total number of positions
Int_t OADBHeader::GetNumPos() const {
Int_t size(0);
for(Int_t i(0); i<fNumRows; i++) {
size+=fNumCols[i];
}
return size;
}
// setters
// set the number of columns to r and resize fNumCols
void OADBHeader::SetNumRows( Int_t r ) {
if ( r < 0 )
throw runtime_error("SetNumRows: index < 0");
if (fNumRows == r)
return;
if ( fNumCols )
delete [] fNumCols;
fNumRows = r;
fNumCols = new Int_t[fNumRows];
for(Int_t i(0); i < fNumRows; i++) {
fNumCols[i] = 0;
}
}
// set the number of cols at the r-th row to c
void OADBHeader::SetNumCols( Int_t r, Int_t c ) {
if ( r < fNumRows && r >= 0 )
fNumCols[r]=c;
}
// set the number of angles to n and resize fAngles
void OADBHeader::SetNumAngles( Int_t n ) {
if ( n < 0 )
throw runtime_error("SetNumAngles: index < 0");
if (fNumAngles == n)
return;
if ( fAngles )
delete [] fAngles;
fNumAngles = n;
fAngles = new Float_t[fNumAngles];
for(Int_t i(0); i < fNumAngles; i++) {
fAngles[i] = 0;
}
}
// set the angle at the i-th row to th
void OADBHeader::SetAngle( Int_t i, Float_t th ) {
if ( i < fNumAngles && i >= 0 )
fAngles[i]=th;
}
// set the number of wavelengths to n and resize fWavelengths
void OADBHeader::SetNumWavelengths( Int_t n ) {
if ( n < 0 )
throw runtime_error("SetNumWavelengths: index < 0");
if (fNumWavelengths == n)
return;
if ( fWavelengths )
delete [] fWavelengths;
fNumWavelengths = n;
fWavelengths = new Float_t[fNumWavelengths];
for(Int_t i(0); i < fNumWavelengths; i++) {
fWavelengths[i] = 0;
}
}
// set the wavelength at the i-th row to th
void OADBHeader::SetWavelength( Int_t i, Float_t th ) {
if ( i < fNumWavelengths && i >= 0 )
fWavelengths[i]=th;
}