00001 #include "NPtGainTestResult.h"
00002 #include "ResponseCurve.h"
00003 #include "FitScanResult.h"
00004 #include "CalChargeVariable.h"
00005 #include "ThresholdVariable.h"
00006 #include "Sct/SctParameters.h"
00007
00008 #include <sstream>
00009
00010
00011 #include <TF1.h>
00012 #include <TH2.h>
00013 #include <TGraph.h>
00014
00015 using namespace std;
00016
00017 namespace SctData {
00018
00019 NPtGainTestResult::NPtGainTestResult() throw() : noiseSlope("NPtGainTestResult::noiseSlope"),
00020 offsetSlope("NPtGainTestResult::offsetSlope"),
00021 gainSlope("NPtGainTestResult::gainSlope"),
00022 specialScanIndex(0),
00023 chipData("NPtGainTestResult::ChipData"),
00024 channelData("NPtGainTestResult::ChannelData")
00025
00026 {
00027 chipData.resize(nChipModule);
00028 channelData.resize(nChannelModule);
00029 }
00030
00031 NPtGainTestResult::NPtGainTestResult(unsigned int runNumber, const string & moduleName,
00032 const CalChargeVariable& testVariable, const ThresholdVariable& scanVariable) throw()
00033 : TestResult(runNumber, moduleName, testVariable, scanVariable),
00034 noiseSlope("NPtGainTestResult::noiseSlope"),
00035 offsetSlope("NPtGainTestResult::offsetSlope"),
00036 gainSlope("NPtGainTestResult::gainSlope"),
00037 specialScanIndex(0),
00038 chipData("NPtGainTestResult::ChipData"),
00039 channelData("NPtGainTestResult::ChannelData") {
00040 chipData.resize(nChipModule);
00041 channelData.resize(nChannelModule);
00042 }
00043
00044 NPtGainTestResult::~NPtGainTestResult() throw() {
00045
00046 }
00047
00048 shared_ptr<TGraph> NPtGainTestResult::getNoiseGraph() const{
00049 shared_ptr<TGraph> graph (new TGraph(nChannelModule));
00050 for (unsigned int i=0; i<nChannelModule; ++i) {
00051 const NPtGainTestResultData& chanData = getChannelData(i);
00052 graph->SetPoint(i, i, chanData.noise);
00053 }
00054 return graph;
00055 }
00056
00057 shared_ptr<TGraph> NPtGainTestResult::getGainGraph() const{
00058 shared_ptr<TGraph> graph (new TGraph(nChannelModule));
00059 for (unsigned int i=0; i<nChannelModule; ++i) {
00060 const NPtGainTestResultData& chanData = getChannelData(i);
00061 graph->SetPoint(i, i, chanData.gain);
00062 }
00063 return graph;
00064 }
00065
00066 shared_ptr<TGraph> NPtGainTestResult::getOffsetGraph() const{
00067 shared_ptr<TGraph> graph (new TGraph(nChannelModule));
00068 for (unsigned int i=0; i<nChannelModule; ++i) {
00069 const NPtGainTestResultData& chanData = getChannelData(i);
00070 graph->SetPoint(i, i, chanData.offset);
00071 }
00072 return graph;
00073 }
00074
00075 string NPtGainTestResult::getClassName() const throw() {
00076 return "SctData::NPtGainTestResult";
00077 }
00078
00079 void NPtGainTestResult::setSpecialScanPointValue(double pointValue) throw(LogicError) {
00080 for (unsigned int i=0; i<data.size(); ++i) {
00081 if (fabs(data[i].testPoint - pointValue) < 10e-6) {
00082 specialScanIndex = i;
00083 return;
00084 }
00085 }
00086
00087 ostringstream text;
00088 text << "TestResult::setSpecialPoint cannot be set to " << pointValue;
00089 throw InvalidArgumentError( text.str(), __FILE__, __LINE__ );
00090 }
00091
00092 void NPtGainTestResult::setChannelDataSize(unsigned int i) throw() {
00093 channelData.resize(i);
00094 }
00095
00096 void NPtGainTestResult::setChipDataSize(unsigned int i) throw() {
00097 chipData.resize(i);
00098 }
00099
00100 }