Main Page   Modules   Namespace List   Class Hierarchy   Data Structures   File List   Namespace Members   Data Fields   Globals   Related Pages  

ScanPoints.cpp

Go to the documentation of this file.
00001 #include "ScanPoints.h"
00002 #include "TAxis.h"
00003 #include "Sct/LogicErrors.h"
00004 
00005 using Sct::LogicError;
00006 using Sct::IllegalStateError;
00007 
00008 namespace SctData {
00009     
00010     ScanPoints::ScanPoints(const unsigned nPoints, const float* points, 
00011                const unsigned* nEvents, const unsigned* nErrorEvents) throw() : points("ScanPoints::points") {
00012     for (unsigned i=0; i<nPoints; ++i) {
00013         addPoint(points[i], nEvents[i], nErrorEvents[i]);
00014     }
00015     }
00016     
00017     ScanPoints::ScanPoints() throw() : points("ScanPoints::points") {}
00018     
00019     string ScanPoints::getClassName() const throw() {
00020     return "SctData::ScanPoints";
00021     }
00022     
00023     unsigned ScanPoints::getNPoints() const throw() {
00024     return points.size();
00025     }
00026     
00027     double ScanPoints::getPoint(const unsigned i) const  throw(LogicError) {
00028     return points[i];
00029     }
00030     
00031     double ScanPoints::operator[] (const unsigned i) const  throw(LogicError) {
00032     return points[i];
00033     }
00034     
00035     double& ScanPoints::operator[] (const unsigned i)  throw(LogicError) {
00036     return points[i].point;
00037     }
00038     
00039     unsigned int ScanPoints::getNEvents(const unsigned i) const  throw(LogicError) {
00040     return points[i].nEvents;
00041     }
00042     
00043     unsigned int ScanPoints::getNErrorEvents(const unsigned i) const throw(LogicError) {
00044     return points[i].nErrorEvents;
00045     }
00046     
00047     void ScanPoints::addPoint(const double point, const unsigned events, const unsigned errorEvents) throw() {
00048     points.push_back( ScanPoint(point, events, errorEvents) );
00049     }
00050     
00051 //Set lowedge to points[0] + 0.5 * (points[0]- points[1]);
00052     double* ScanPoints::getEdges() const throw(LogicError) {
00053     if (points.size()<2) throw IllegalStateError("ScanPoints::getEdges() must have two points", __FILE__, __LINE__) ;
00054     
00055     double* bins = new double[points.size()+1];
00056     
00057     double lowedge = points[0] + 0.5 * (points[0]- points[1]);
00058     bins[0] = lowedge;
00059     for (unsigned int i=1; i<=points.size(); i++) {
00060         bins[i] = 2*points[i-1] - bins[i-1];
00061     }
00062     return bins;
00063     }
00064     
00065     void ScanPoints::setAxis(TAxis& axis) const throw(LogicError) {
00066     double* bins = getEdges();
00067     axis.Set(points.size(), bins);
00068     delete [] bins;
00069     }
00070 
00071 } 

Generated on Mon Dec 15 19:36:14 2003 for SCT DAQ/DCS Software by doxygen1.3-rc3