started with the encapsulation of the data structure which should reduce the number of crashes and help to reduce memory leaks

This commit is contained in:
nemu 2009-10-07 12:26:41 +00:00
parent ea3fc6b037
commit 33222b675c
19 changed files with 657 additions and 649 deletions

View File

@ -44,6 +44,7 @@ cpp_sources = \
PMsr2Data.cpp \ PMsr2Data.cpp \
PMsrHandler.cpp \ PMsrHandler.cpp \
PMusrCanvas.cpp \ PMusrCanvas.cpp \
PMusr.cpp \
PMusrT0.cpp \ PMusrT0.cpp \
PRunAsymmetry.cpp \ PRunAsymmetry.cpp \
PRunBase.cpp \ PRunBase.cpp \

View File

@ -37,7 +37,7 @@ using namespace std;
#include "TH1F.h" #include "TH1F.h"
#include "TF1.h" #include "TF1.h"
#include "TFile.h" //#include "TFile.h"
#include "PMusr.h" #include "PMusr.h"
#include "PFourier.h" #include "PFourier.h"

View File

@ -414,51 +414,51 @@ void PMsr2Data::WriteOutput(const string &outfile, bool db, bool withHeader) con
PMsrRunList *msrRunList(fMsrHandler->GetMsrRunList()); PMsrRunList *msrRunList(fMsrHandler->GetMsrRunList());
PRawRunData *rawRunData(fDataHandler->GetRunData((*msrRunList)[0].fRunName[0])); PRawRunData *rawRunData(fDataHandler->GetRunData((*msrRunList)[0].fRunName[0]));
switch (rawRunData->fTemp.size()) { switch (rawRunData->GetNoOfTemperatures()) {
case 1: case 1:
dataParamNames.push_back("dataT"); dataParamNames.push_back("dataT");
dataParamLabels.push_back("T (K)"); dataParamLabels.push_back("T (K)");
dataParam.push_back(rawRunData->fTemp[0].first); dataParam.push_back(rawRunData->GetTemperature(0));
dataParamErr.push_back(rawRunData->fTemp[0].second); dataParamErr.push_back(rawRunData->GetTempError(0));
break; break;
default: default:
ostringstream oss; ostringstream oss;
for (unsigned int i(0); i<rawRunData->fTemp.size(); i++) { for (unsigned int i(0); i<rawRunData->GetNoOfTemperatures(); i++) {
oss << "dataT" << i; oss << "dataT" << i;
dataParamNames.push_back(oss.str()); dataParamNames.push_back(oss.str());
oss.str(""); oss.str("");
oss << "T" << i << " (K)"; oss << "T" << i << " (K)";
dataParamLabels.push_back(oss.str()); dataParamLabels.push_back(oss.str());
oss.str(""); oss.str("");
dataParam.push_back(rawRunData->fTemp[i].first); dataParam.push_back(rawRunData->GetTemperature(i));
dataParamErr.push_back(rawRunData->fTemp[i].second); dataParamErr.push_back(rawRunData->GetTempError(i));
} }
break; break;
} }
double value; double value;
value = rawRunData->fField; value = rawRunData->GetField();
if (value != -9.9e99) { if (value != PMUSR_UNDEFINED) {
dataParamNames.push_back("dataB"); dataParamNames.push_back("dataB");
dataParamLabels.push_back("mu0 H (G)"); dataParamLabels.push_back("mu0 H (G)");
dataParam.push_back(value); dataParam.push_back(value);
} }
value = rawRunData->fEnergy; value = rawRunData->GetEnergy();
if (value != -999.0) { if (value != PMUSR_UNDEFINED) {
dataParamNames.push_back("dataE"); dataParamNames.push_back("dataE");
dataParamLabels.push_back("Implantation Energy (keV)"); dataParamLabels.push_back("Implantation Energy (keV)");
dataParam.push_back(value); dataParam.push_back(value);
} }
value = rawRunData->fTransport; value = rawRunData->GetTransport();
if (value != -999.0) { if (value != PMUSR_UNDEFINED) {
dataParamNames.push_back("dataTr"); dataParamNames.push_back("dataTr");
dataParamLabels.push_back("Transport (kV)"); dataParamLabels.push_back("Transport (kV)");
dataParam.push_back(value); dataParam.push_back(value);
} }
vector<double> ra(rawRunData->fRingAnode); PDoubleVector ra(rawRunData->GetRingAnode());
if (ra.size() > 1) { if (ra.size() > 1) {
dataParamNames.push_back("dataRALRAR"); dataParamNames.push_back("dataRALRAR");
dataParamLabels.push_back("RAL-RAR (kV)"); dataParamLabels.push_back("RAL-RAR (kV)");
@ -473,7 +473,7 @@ void PMsr2Data::WriteOutput(const string &outfile, bool db, bool withHeader) con
} }
// get the independent variable values from the runlist file if needed // get the independent variable values from the runlist file if needed
vector<double> indVarValues; PDoubleVector indVarValues;
if (fRunListFile) { if (fRunListFile) {
string line; string line;

View File

@ -11,7 +11,7 @@
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007 by Andreas Suter * * Copyright (C) 2007 by Andreas Suter *
* andreas.suter@psi.c * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by * * it under the terms of the GNU General Public License as published by *
@ -326,8 +326,8 @@ int PMsrHandler::WriteMsrLogFile(const bool messages)
int plotNo = -1; int plotNo = -1;
string line; string line;
TString str, sstr; TString str, sstr;
TObjArray *tokens; TObjArray *tokens = 0;
TObjString *ostr; TObjString *ostr = 0;
bool found = false; bool found = false;
bool statisticBlockFound = false; bool statisticBlockFound = false;
bool partialStatisticBlockFound = true; bool partialStatisticBlockFound = true;
@ -468,6 +468,8 @@ int PMsrHandler::WriteMsrLogFile(const bool messages)
} else { // not a parameter, hence just copy it } else { // not a parameter, hence just copy it
fout << str.Data() << endl; fout << str.Data() << endl;
} }
// clean up tokens
delete tokens;
} }
break; break;
case MSR_TAG_THEORY: case MSR_TAG_THEORY:
@ -1177,8 +1179,8 @@ bool PMsrHandler::HandleFitParameterEntry(PMsrLines &lines)
PMsrLines::iterator iter; PMsrLines::iterator iter;
TObjArray *tokens; TObjArray *tokens = 0;
TObjString *ostr; TObjString *ostr = 0;
TString str; TString str;
// fill param structure // fill param structure
@ -1420,8 +1422,8 @@ bool PMsrHandler::HandleRunEntry(PMsrLines &lines)
bool error = false; bool error = false;
TString str; TString str;
TObjString *ostr; TObjArray *tokens = 0;
TObjArray *tokens; TObjString *ostr = 0;
// init some stuff // init some stuff
param.fXYDataIndex[0] = -1; param.fXYDataIndex[0] = -1;
@ -2068,8 +2070,8 @@ bool PMsrHandler::HandleFourierEntry(PMsrLines &lines)
PMsrLines::iterator iter; PMsrLines::iterator iter;
TObjArray *tokens; TObjArray *tokens = 0;
TObjString *ostr; TObjString *ostr = 0;
TString str; TString str;
int ival; int ival;
@ -2247,6 +2249,13 @@ bool PMsrHandler::HandleFourierEntry(PMsrLines &lines)
} }
} }
// clean up
if (tokens) {
delete tokens;
tokens = 0;
}
++iter; ++iter;
} }
@ -2291,9 +2300,9 @@ bool PMsrHandler::HandlePlotEntry(PMsrLines &lines)
PMsrLines::iterator iter1; PMsrLines::iterator iter1;
PMsrLines::iterator iter2; PMsrLines::iterator iter2;
TObjArray *tokens; TObjArray *tokens = 0;
TObjArray *tokens2; TObjArray *tokens2 = 0;
TObjString *ostr; TObjString *ostr = 0;
TString str; TString str;
TString str2; TString str2;

View File

@ -1397,35 +1397,35 @@ void PMusrCanvas::HandleDataSet(unsigned int plotNo, unsigned int runNo, PRunDat
name += (int)runNo; name += (int)runNo;
name += "_"; name += "_";
name += fPlotNumber; name += fPlotNumber;
start = data->fDataTimeStart - data->fDataTimeStep/2.0; start = data->GetDataTimeStart() - data->GetDataTimeStep()/2.0;
end = start + data->fValue.size()*data->fDataTimeStep; end = start + data->GetValue()->size()*data->GetDataTimeStep();
size = data->fValue.size(); size = data->GetValue()->size();
//cout << endl << ">> PMusrCanvas::HandleDataSet(): data->fDataTimeStart = " << data->fDataTimeStart << ", data->fDataTimeStep = " << data->fDataTimeStep << endl; //cout << endl << ">> PMusrCanvas::HandleDataSet(): data->GetDataTimeStart = " << data->GetDataTimeStart << ", data->GetDataTimeStep() = " << data->GetDataTimeStep() << endl;
// check if 'use_fit_range' plotting is whished // check if 'use_fit_range' plotting is whished
if (fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fUseFitRanges) { if (fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fUseFitRanges) {
start = fMsrHandler->GetMsrRunList()->at(runNo).fFitRange[0]; // needed to estimate size start = fMsrHandler->GetMsrRunList()->at(runNo).fFitRange[0]; // needed to estimate size
end = fMsrHandler->GetMsrRunList()->at(runNo).fFitRange[1]; // needed to estimate size end = fMsrHandler->GetMsrRunList()->at(runNo).fFitRange[1]; // needed to estimate size
size = (int) ((end - start) / data->fDataTimeStep) + 1; size = (int) ((end - start) / data->GetDataTimeStep()) + 1;
start = data->fDataTimeStart + start = data->GetDataTimeStart() +
(int)((fMsrHandler->GetMsrRunList()->at(runNo).fFitRange[0] - data->fDataTimeStart)/data->fDataTimeStep) * data->fDataTimeStep - (int)((fMsrHandler->GetMsrRunList()->at(runNo).fFitRange[0] - data->GetDataTimeStart())/data->GetDataTimeStep()) * data->GetDataTimeStep() -
data->fDataTimeStep/2.0; // closesd start value compatible with the user given data->GetDataTimeStep()/2.0; // closesd start value compatible with the user given
end = start + size * data->fDataTimeStep; // closesd end value compatible with the user given end = start + size * data->GetDataTimeStep(); // closesd end value compatible with the user given
} }
// check if 'sub_ranges' plotting is whished // check if 'sub_ranges' plotting is whished
if (fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmin.size() > 1) { if (fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmin.size() > 1) {
start = fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmin[runNo]; // needed to estimate size start = fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmin[runNo]; // needed to estimate size
end = fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmax[runNo]; // needed to estimate size end = fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmax[runNo]; // needed to estimate size
size = (int) ((end - start) / data->fDataTimeStep) + 1; size = (int) ((end - start) / data->GetDataTimeStep()) + 1;
start = data->fDataTimeStart + start = data->GetDataTimeStart() +
(int)((fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmin[runNo] - data->fDataTimeStart)/data->fDataTimeStep) * data->fDataTimeStep - (int)((fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmin[runNo] - data->GetDataTimeStart())/data->GetDataTimeStep()) * data->GetDataTimeStep() -
data->fDataTimeStep/2.0; // closesd start value compatible with the user given data->GetDataTimeStep()/2.0; // closesd start value compatible with the user given
end = start + size * data->fDataTimeStep; // closesd end value compatible with the user given end = start + size * data->GetDataTimeStep(); // closesd end value compatible with the user given
} }
//cout << endl << ">> PMusrCanvas::HandleDataSet(): start = " << start << ", end = " << end << ", size = " << size << ", data->fDataTimeStep = " << data->fDataTimeStep << endl; //cout << endl << ">> PMusrCanvas::HandleDataSet(): start = " << start << ", end = " << end << ", size = " << size << ", data->GetDataTimeStep() = " << data->GetDataTimeStep() << endl;
// invoke histo // invoke histo
dataHisto = new TH1F(name, name, size, start, end); dataHisto = new TH1F(name, name, size, start, end);
@ -1433,24 +1433,24 @@ void PMusrCanvas::HandleDataSet(unsigned int plotNo, unsigned int runNo, PRunDat
// fill histogram // fill histogram
// 1st calculate the bin-range according to the plot options // 1st calculate the bin-range according to the plot options
UInt_t startBin = 0; UInt_t startBin = 0;
UInt_t endBin = data->fValue.size(); UInt_t endBin = data->GetValue()->size();
// check if 'use_fit_range' plotting is whished // check if 'use_fit_range' plotting is whished
if (fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fUseFitRanges) { if (fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fUseFitRanges) {
startBin = (UInt_t)((fMsrHandler->GetMsrRunList()->at(runNo).fFitRange[0] - data->fDataTimeStart)/data->fDataTimeStep); startBin = (UInt_t)((fMsrHandler->GetMsrRunList()->at(runNo).fFitRange[0] - data->GetDataTimeStart())/data->GetDataTimeStep());
endBin = (UInt_t)((fMsrHandler->GetMsrRunList()->at(runNo).fFitRange[1] - data->fDataTimeStart)/data->fDataTimeStep); endBin = (UInt_t)((fMsrHandler->GetMsrRunList()->at(runNo).fFitRange[1] - data->GetDataTimeStart())/data->GetDataTimeStep());
} }
// check if 'sub_ranges' plotting is whished // check if 'sub_ranges' plotting is whished
if (fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmin.size() > 1) { if (fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmin.size() > 1) {
startBin = (UInt_t)((fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmin[runNo] - data->fDataTimeStart)/data->fDataTimeStep); startBin = (UInt_t)((fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmin[runNo] - data->GetDataTimeStart())/data->GetDataTimeStep());
endBin = (UInt_t)((fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmax[runNo] - data->fDataTimeStart)/data->fDataTimeStep); endBin = (UInt_t)((fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmax[runNo] - data->GetDataTimeStart())/data->GetDataTimeStep());
} }
//cout << endl << ">> PMusrCanvas::HandleDataSet(): data: startBin = " << startBin << ", endBin = " << endBin << endl; //cout << endl << ">> PMusrCanvas::HandleDataSet(): data: startBin = " << startBin << ", endBin = " << endBin << endl;
for (UInt_t i=startBin; i<endBin; i++) { for (UInt_t i=startBin; i<endBin; i++) {
dataHisto->SetBinContent(i-startBin+1, data->fValue[i]); dataHisto->SetBinContent(i-startBin+1, data->GetValue()->at(i));
dataHisto->SetBinError(i-startBin+1, data->fError[i]); dataHisto->SetBinError(i-startBin+1, data->GetError()->at(i));
} }
// set marker and line color // set marker and line color
@ -1479,56 +1479,56 @@ void PMusrCanvas::HandleDataSet(unsigned int plotNo, unsigned int runNo, PRunDat
name += (int)runNo; name += (int)runNo;
name += "_"; name += "_";
name += fPlotNumber; name += fPlotNumber;
start = data->fTheoryTimeStart - data->fTheoryTimeStep/2.0; start = data->GetTheoryTimeStart() - data->GetTheoryTimeStep()/2.0;
end = start + data->fTheory.size()*data->fTheoryTimeStep; end = start + data->GetTheory()->size()*data->GetTheoryTimeStep();
size = data->fTheory.size(); size = data->GetTheory()->size();
// check if 'use_fit_range' plotting is whished // check if 'use_fit_range' plotting is whished
if (fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fUseFitRanges) { if (fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fUseFitRanges) {
start = fMsrHandler->GetMsrRunList()->at(runNo).fFitRange[0]; // needed to estimate size start = fMsrHandler->GetMsrRunList()->at(runNo).fFitRange[0]; // needed to estimate size
end = fMsrHandler->GetMsrRunList()->at(runNo).fFitRange[1]; // needed to estimate size end = fMsrHandler->GetMsrRunList()->at(runNo).fFitRange[1]; // needed to estimate size
size = (int) ((end - start) / data->fTheoryTimeStep) + 1; size = (int) ((end - start) / data->GetTheoryTimeStep()) + 1;
start = data->fTheoryTimeStart + start = data->GetTheoryTimeStart() +
(int)((fMsrHandler->GetMsrRunList()->at(runNo).fFitRange[0] - data->fTheoryTimeStart)/data->fTheoryTimeStep) * data->fTheoryTimeStep - (int)((fMsrHandler->GetMsrRunList()->at(runNo).fFitRange[0] - data->GetTheoryTimeStart())/data->GetTheoryTimeStep()) * data->GetTheoryTimeStep() -
data->fTheoryTimeStep/2.0; // closesd start value compatible with the user given data->GetTheoryTimeStep()/2.0; // closesd start value compatible with the user given
end = start + size * data->fTheoryTimeStep; // closesd end value compatible with the user given end = start + size * data->GetTheoryTimeStep(); // closesd end value compatible with the user given
} }
// check if 'sub_ranges' plotting is whished // check if 'sub_ranges' plotting is whished
if (fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmin.size() > 1) { if (fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmin.size() > 1) {
start = fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmin[runNo]; // needed to estimate size start = fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmin[runNo]; // needed to estimate size
end = fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmax[runNo]; // needed to estimate size end = fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmax[runNo]; // needed to estimate size
size = (int) ((end - start) / data->fTheoryTimeStep) + 1; size = (int) ((end - start) / data->GetTheoryTimeStep()) + 1;
start = data->fTheoryTimeStart + start = data->GetTheoryTimeStart() +
(int)((fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmin[runNo] - data->fTheoryTimeStart)/data->fTheoryTimeStep) * data->fTheoryTimeStep - (int)((fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmin[runNo] - data->GetTheoryTimeStart())/data->GetTheoryTimeStep()) * data->GetTheoryTimeStep() -
data->fTheoryTimeStep/2.0; // closesd start value compatible with the user given data->GetTheoryTimeStep()/2.0; // closesd start value compatible with the user given
end = start + size * data->fTheoryTimeStep; // closesd end value compatible with the user given end = start + size * data->GetTheoryTimeStep(); // closesd end value compatible with the user given
} }
//cout << endl << ">> PMusrCanvas::HandleDataSet(): start = " << start << ", end = " << end << ", size = " << size << ", data->fTheoryTimeStep = " << data->fTheoryTimeStep << endl; //cout << endl << ">> PMusrCanvas::HandleDataSet(): start = " << start << ", end = " << end << ", size = " << size << ", data->GetTheoryTimeStep() = " << data->GetTheoryTimeStep() << endl;
// invoke histo // invoke histo
theoHisto = new TH1F(name, name, size, start, end); theoHisto = new TH1F(name, name, size, start, end);
// fill histogram // fill histogram
startBin = 0; startBin = 0;
endBin = data->fTheory.size(); endBin = data->GetTheory()->size();
// check if 'use_fit_range' plotting is whished // check if 'use_fit_range' plotting is whished
if (fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fUseFitRanges) { if (fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fUseFitRanges) {
startBin = (UInt_t)((fMsrHandler->GetMsrRunList()->at(runNo).fFitRange[0] - data->fDataTimeStart)/data->fTheoryTimeStep); startBin = (UInt_t)((fMsrHandler->GetMsrRunList()->at(runNo).fFitRange[0] - data->GetDataTimeStart())/data->GetTheoryTimeStep());
endBin = (UInt_t)((fMsrHandler->GetMsrRunList()->at(runNo).fFitRange[1] - data->fDataTimeStart)/data->fTheoryTimeStep); endBin = (UInt_t)((fMsrHandler->GetMsrRunList()->at(runNo).fFitRange[1] - data->GetDataTimeStart())/data->GetTheoryTimeStep());
} }
//cout << endl << ">> PMusrCanvas::HandleDataSet(): theory: startBin = " << startBin << ", endBin = " << endBin << endl; //cout << endl << ">> PMusrCanvas::HandleDataSet(): theory: startBin = " << startBin << ", endBin = " << endBin << endl;
// check if 'sub_ranges' plotting is whished // check if 'sub_ranges' plotting is whished
if (fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmin.size() > 1) { if (fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmin.size() > 1) {
startBin = (UInt_t)((fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmin[runNo] -data->fDataTimeStart)/data->fTheoryTimeStep); startBin = (UInt_t)((fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmin[runNo] -data->GetDataTimeStart())/data->GetTheoryTimeStep());
endBin = (UInt_t)((fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmax[runNo] -data->fDataTimeStart)/data->fTheoryTimeStep); endBin = (UInt_t)((fMsrHandler->GetMsrPlotList()->at(fPlotNumber).fTmax[runNo] -data->GetDataTimeStart())/data->GetTheoryTimeStep());
} }
for (UInt_t i=startBin; i<endBin; i++) { for (UInt_t i=startBin; i<endBin; i++) {
theoHisto->SetBinContent(i-startBin+1, data->fTheory[i]); theoHisto->SetBinContent(i-startBin+1, data->GetTheory()->at(i));
} }
//cout << endl << ">> PMusrCanvas::HandleDataSet(): after fill theory histo" << endl; //cout << endl << ">> PMusrCanvas::HandleDataSet(): after fill theory histo" << endl;
@ -1572,12 +1572,12 @@ void PMusrCanvas::HandleNonMusrDataSet(unsigned int plotNo, unsigned int runNo,
// dataHisto ------------------------------------------------------------- // dataHisto -------------------------------------------------------------
// invoke graph // invoke graph
dataHisto = new TGraphErrors(data->fX.size()); dataHisto = new TGraphErrors(data->GetX()->size());
// fill graph // fill graph
for (unsigned int i=0; i<data->fX.size(); i++) { for (unsigned int i=0; i<data->GetX()->size(); i++) {
dataHisto->SetPoint(i, data->fX[i], data->fValue[i]); dataHisto->SetPoint(i, data->GetX()->at(i), data->GetValue()->at(i));
dataHisto->SetPointError(i, 0.0, data->fError[i]); dataHisto->SetPointError(i, 0.0, data->GetError()->at(i));
} }
// set marker and line color // set marker and line color
@ -1603,11 +1603,11 @@ void PMusrCanvas::HandleNonMusrDataSet(unsigned int plotNo, unsigned int runNo,
// theoHisto ------------------------------------------------------------- // theoHisto -------------------------------------------------------------
// invoke graph // invoke graph
theoHisto = new TGraphErrors(data->fXTheory.size()); theoHisto = new TGraphErrors(data->GetXTheory()->size());
// fill graph // fill graph
for (unsigned int i=0; i<data->fXTheory.size(); i++) { for (unsigned int i=0; i<data->GetXTheory()->size(); i++) {
theoHisto->SetPoint(i, data->fXTheory[i], data->fTheory[i]); theoHisto->SetPoint(i, data->GetXTheory()->at(i), data->GetTheory()->at(i));
theoHisto->SetPointError(i, 0.0, 0.0); theoHisto->SetPointError(i, 0.0, 0.0);
} }

View File

@ -87,19 +87,19 @@ PMusrT0::PMusrT0()
PMusrT0::PMusrT0(PRawRunData *rawRunData, int runNo, int histoNo, int detectorTag, int addRunNo) : PMusrT0::PMusrT0(PRawRunData *rawRunData, int runNo, int histoNo, int detectorTag, int addRunNo) :
fRunNo(runNo), fDetectorTag(detectorTag), fAddRunNo(addRunNo) fRunNo(runNo), fDetectorTag(detectorTag), fAddRunNo(addRunNo)
{ {
cout << endl << "run Name = " << rawRunData->fRunName.Data() << ", runNo = " << fRunNo << ", histoNo = " << histoNo << endl; cout << endl << "run Name = " << rawRunData->GetRunName()->Data() << ", runNo = " << fRunNo << ", histoNo = " << histoNo << endl;
fStatus = 0; // default is quit locally fStatus = 0; // default is quit locally
fAddRunOffset = 0; fAddRunOffset = 0;
TString str = rawRunData->fRunName + TString(" : "); TString str = *rawRunData->GetRunName() + TString(" : ");
str += histoNo; str += histoNo;
// feed necessary objects // feed necessary objects
// feed raw data histo // feed raw data histo
Int_t noOfBins = rawRunData->fDataBin[histoNo-1].size(); Int_t noOfBins = rawRunData->GetDataBin(histoNo-1)->size();
Double_t start = -0.5; Double_t start = -0.5;
Double_t end = noOfBins - 0.5; // -0.5 is correct since the data start at 0.0 Double_t end = noOfBins - 0.5; // -0.5 is correct since the data start at 0.0
fHisto = new TH1F("fHisto", str.Data(), noOfBins, start, end); fHisto = new TH1F("fHisto", str.Data(), noOfBins, start, end);
@ -107,8 +107,8 @@ cout << endl << "run Name = " << rawRunData->fRunName.Data() << ", runNo = " <<
fHisto->SetMarkerSize(0.5); fHisto->SetMarkerSize(0.5);
fHisto->SetMarkerColor(TColor::GetColor(0,0,0)); // black fHisto->SetMarkerColor(TColor::GetColor(0,0,0)); // black
for (unsigned int i=0; i<rawRunData->fDataBin[histoNo-1].size(); i++) { for (unsigned int i=0; i<rawRunData->GetDataBin(histoNo-1)->size(); i++) {
fHisto->SetBinContent(i+1, rawRunData->fDataBin[histoNo-1][i]); fHisto->SetBinContent(i+1, rawRunData->GetDataBin(histoNo-1)->at(i));
} }
// generate canvas etc // generate canvas etc

View File

@ -11,7 +11,7 @@
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007 by Andreas Suter * * Copyright (C) 2007 by Andreas Suter *
* andreas.suter@psi.c * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by * * it under the terms of the GNU General Public License as published by *
@ -110,7 +110,7 @@ PRunAsymmetry::PRunAsymmetry(PMsrHandler *msrInfo, PRunDataHandler *rawData, uns
else else
fAlphaBetaTag = 4; fAlphaBetaTag = 4;
//cout << endl << ">> PRunAsymmetry::PRunAsymmetry(): fAlphaBetaTag = " << fAlphaBetaTag; //cout << endl << ">> PRunAsymmetry::PRunAsymmetry(): fAlphaBetaTag = " << fAlphaBetaTag << endl;
// calculate fData // calculate fData
if (!PrepareData()) if (!PrepareData())
@ -154,8 +154,8 @@ double PRunAsymmetry::CalcChiSquare(const std::vector<double>& par)
// calculate chisq // calculate chisq
double time; double time;
for (unsigned int i=0; i<fData.fValue.size(); i++) { for (unsigned int i=0; i<fData.GetValue()->size(); i++) {
time = fData.fDataTimeStart + (double)i*fData.fDataTimeStep; time = fData.GetDataTimeStart() + (double)i*fData.GetDataTimeStep();
if ((time>=fFitStartTime) && (time<=fFitStopTime)) { if ((time>=fFitStartTime) && (time<=fFitStopTime)) {
switch (fAlphaBetaTag) { switch (fAlphaBetaTag) {
case 1: // alpha == 1, beta == 1 case 1: // alpha == 1, beta == 1
@ -181,8 +181,8 @@ double PRunAsymmetry::CalcChiSquare(const std::vector<double>& par)
break; break;
} }
//if (i==0) cout << endl << "A(0) = " << asymFcnValue; //if (i==0) cout << endl << "A(0) = " << asymFcnValue;
diff = fData.fValue[i] - asymFcnValue; diff = fData.GetValue()->at(i) - asymFcnValue;
chisq += diff*diff / (fData.fError[i]*fData.fError[i]); chisq += diff*diff / (fData.GetError()->at(i)*fData.GetError()->at(i));
} }
} }
@ -230,8 +230,8 @@ void PRunAsymmetry::CalcTheory()
double asymFcnValue = 0.0; double asymFcnValue = 0.0;
double a, b, f; double a, b, f;
double time; double time;
for (unsigned int i=0; i<fData.fValue.size(); i++) { for (unsigned int i=0; i<fData.GetValue()->size(); i++) {
time = fData.fDataTimeStart + (double)i*fData.fDataTimeStep; time = fData.GetDataTimeStart() + (double)i*fData.GetDataTimeStep();
switch (fAlphaBetaTag) { switch (fAlphaBetaTag) {
case 1: // alpha == 1, beta == 1 case 1: // alpha == 1, beta == 1
asymFcnValue = fTheory->Func(time, par, fFuncValues); asymFcnValue = fTheory->Func(time, par, fFuncValues);
@ -256,7 +256,7 @@ void PRunAsymmetry::CalcTheory()
asymFcnValue = 0.0; asymFcnValue = 0.0;
break; break;
} }
fData.fTheory.push_back(asymFcnValue); fData.AppendTheoryValue(asymFcnValue);
} }
// clean up // clean up
@ -276,7 +276,7 @@ void PRunAsymmetry::CalcTheory()
*/ */
bool PRunAsymmetry::PrepareData() bool PRunAsymmetry::PrepareData()
{ {
//cout << endl << "in PRunAsymmetry::PrepareData(): will feed fData"; //cout << endl << "in PRunAsymmetry::PrepareData(): will feed fData" << endl;
// get forward/backward histo from PRunDataHandler object ------------------------ // get forward/backward histo from PRunDataHandler object ------------------------
// get the correct run // get the correct run
@ -287,41 +287,41 @@ bool PRunAsymmetry::PrepareData()
} }
// keep the time resolution in (us) // keep the time resolution in (us)
fTimeResolution = runData->fTimeResolution/1.0e3; fTimeResolution = runData->GetTimeResolution()/1.0e3;
// keep start/stop time for fit // keep start/stop time for fit
fFitStartTime = fRunInfo->fFitRange[0]; fFitStartTime = fRunInfo->fFitRange[0];
fFitStopTime = fRunInfo->fFitRange[1]; fFitStopTime = fRunInfo->fFitRange[1];
//cout << endl << "start/stop (fit): " << fFitStartTime << ", " << fFitStopTime; //cout << endl << "start/stop (fit): " << fFitStartTime << ", " << fFitStopTime << endl;
// check if the t0's are given in the msr-file // check if the t0's are given in the msr-file
if (fRunInfo->fT0.size() == 0) { // t0's are NOT in the msr-file if (fRunInfo->fT0.size() == 0) { // t0's are NOT in the msr-file
// check if the t0's are in the data file // check if the t0's are in the data file
if (runData->fT0s.size() != 0) { // t0's in the run data if (runData->GetT0s().size() != 0) { // t0's in the run data
// keep the proper t0's. For asymmetry runs, forward/backward are holding the histo no // keep the proper t0's. For asymmetry runs, forward/backward are holding the histo no
// fForwardHistoNo starts with 1 not with 0 etc. ;-) // fForwardHistoNo starts with 1 not with 0 etc. ;-)
fT0s.push_back(runData->fT0s[fRunInfo->fForwardHistoNo-1]); // forward t0 fT0s.push_back(runData->GetT0(fRunInfo->fForwardHistoNo-1)); // forward t0
fT0s.push_back(runData->fT0s[fRunInfo->fBackwardHistoNo-1]); // backward t0 fT0s.push_back(runData->GetT0(fRunInfo->fBackwardHistoNo-1)); // backward t0
} else { // t0's are neither in the run data nor in the msr-file -> not acceptable! } else { // t0's are neither in the run data nor in the msr-file -> not acceptable!
cout << endl << "PRunAsymmetry::PrepareData(): NO t0's found, neither in the run data nor in the msr-file!"; cout << endl << "PRunAsymmetry::PrepareData(): NO t0's found, neither in the run data nor in the msr-file!";
return false; return false;
} }
} else { // t0's in the msr-file } else { // t0's in the msr-file
// check if t0's are given in the data file // check if t0's are given in the data file
if (runData->fT0s.size() != 0) { if (runData->GetT0s().size() != 0) {
// compare t0's of the msr-file with the one in the data file // compare t0's of the msr-file with the one in the data file
if (fabs(fRunInfo->fT0[0]-runData->fT0s[fRunInfo->fForwardHistoNo-1])>5.0) { // given in bins!! if (fabs(fRunInfo->fT0[0]-runData->GetT0(fRunInfo->fForwardHistoNo-1))>5.0) { // given in bins!!
cout << endl << "PRunAsymmetry::PrepareData(): **WARNING**: forward histo"; cout << endl << "PRunAsymmetry::PrepareData(): **WARNING**: forward histo";
cout << endl << " t0 from the msr-file is " << fRunInfo->fT0[0]; cout << endl << " t0 from the msr-file is " << fRunInfo->fT0[0];
cout << endl << " t0 from the data file is " << runData->fT0s[fRunInfo->fForwardHistoNo-1]; cout << endl << " t0 from the data file is " << runData->GetT0(fRunInfo->fForwardHistoNo-1);
cout << endl << " This is quite a deviation! Is this done intentionally??"; cout << endl << " This is quite a deviation! Is this done intentionally??";
cout << endl; cout << endl;
} }
if (fabs(fRunInfo->fT0[1]-runData->fT0s[fRunInfo->fBackwardHistoNo-1])>5.0) { // given in bins!! if (fabs(fRunInfo->fT0[1]-runData->GetT0(fRunInfo->fBackwardHistoNo-1))>5.0) { // given in bins!!
cout << endl << "PRunAsymmetry::PrepareData(): **WARNING**: backward histo"; cout << endl << "PRunAsymmetry::PrepareData(): **WARNING**: backward histo";
cout << endl << " t0 from the msr-file is " << fRunInfo->fT0[1]; cout << endl << " t0 from the msr-file is " << fRunInfo->fT0[1];
cout << endl << " t0 from the data file is " << runData->fT0s[fRunInfo->fBackwardHistoNo-1]; cout << endl << " t0 from the data file is " << runData->GetT0(fRunInfo->fBackwardHistoNo-1);
cout << endl << " This is quite a deviation! Is this done intentionally??"; cout << endl << " This is quite a deviation! Is this done intentionally??";
cout << endl; cout << endl;
} }
@ -335,21 +335,21 @@ bool PRunAsymmetry::PrepareData()
histoNo[0] = fRunInfo->fForwardHistoNo-1; histoNo[0] = fRunInfo->fForwardHistoNo-1;
histoNo[1] = fRunInfo->fBackwardHistoNo-1; histoNo[1] = fRunInfo->fBackwardHistoNo-1;
// first check if forward/backward given in the msr-file are valid // first check if forward/backward given in the msr-file are valid
if ((runData->fDataBin.size() < histoNo[0]+1) || (histoNo[0] < 0) || if ((runData->GetNoOfHistos() < histoNo[0]+1) || (histoNo[0] < 0) ||
(runData->fDataBin.size() < histoNo[1]+1) || (histoNo[1] < 0)) { (runData->GetNoOfHistos() < histoNo[1]+1) || (histoNo[1] < 0)) {
cout << endl << "PRunAsymmetry::PrepareData(): **PANIC ERROR**:"; cout << endl << "PRunAsymmetry::PrepareData(): **PANIC ERROR**:";
cout << endl << " forward/backward histo no found = " << histoNo[0]+1; cout << endl << " forward/backward histo no found = " << histoNo[0]+1;
cout << ", " << histoNo[1]+1 << ", but there are only " << runData->fDataBin.size() << " histo sets!?!?"; cout << ", " << histoNo[1]+1 << ", but there are only " << runData->GetNoOfHistos() << " histo sets!?!?";
cout << endl << " Will quit :-("; cout << endl << " Will quit :-(";
cout << endl; cout << endl;
return false; return false;
} }
// get raw forward/backward histo data // get raw forward/backward histo data
for (unsigned int i=0; i<runData->fDataBin[histoNo[0]].size(); i++) { fForward.resize(runData->GetDataBin(histoNo[0])->size());
fForward.push_back(runData->fDataBin[histoNo[0]][i]); fBackward.resize(runData->GetDataBin(histoNo[0])->size());
fBackward.push_back(runData->fDataBin[histoNo[1]][i]); fForward = *runData->GetDataBin(histoNo[0]);
} fBackward = *runData->GetDataBin(histoNo[1]);
// check if addrun's are present, and if yes add data // check if addrun's are present, and if yes add data
// check if there are runs to be added to the current one // check if there are runs to be added to the current one
@ -368,11 +368,11 @@ bool PRunAsymmetry::PrepareData()
// check if the t0's are given in the msr-file // check if the t0's are given in the msr-file
if (i >= fRunInfo->fT0.size()) { // t0's are NOT in the msr-file if (i >= fRunInfo->fT0.size()) { // t0's are NOT in the msr-file
// check if the t0's are in the data file // check if the t0's are in the data file
if (addRunData->fT0s.size() != 0) { // t0's in the run data if (addRunData->GetT0s().size() != 0) { // t0's in the run data
// keep the proper t0's. For asymmetry runs, forward/backward are holding the histo no // keep the proper t0's. For asymmetry runs, forward/backward are holding the histo no
// fForwardHistoNo starts with 1 not with 0 etc. ;-) // fForwardHistoNo starts with 1 not with 0 etc. ;-)
t0Add[0] = addRunData->fT0s[fRunInfo->fForwardHistoNo-1]; // forward t0 t0Add[0] = addRunData->GetT0(fRunInfo->fForwardHistoNo-1); // forward t0
t0Add[1] = addRunData->fT0s[fRunInfo->fBackwardHistoNo-1]; // backward t0 t0Add[1] = addRunData->GetT0(fRunInfo->fBackwardHistoNo-1); // backward t0
} else { // t0's are neither in the run data nor in the msr-file -> not acceptable! } else { // t0's are neither in the run data nor in the msr-file -> not acceptable!
cout << endl << "PRunAsymmetry::PrepareData(): NO t0's found, neither in the addrun (" << fRunInfo->fRunName[i].Data() << ") data nor in the msr-file!"; cout << endl << "PRunAsymmetry::PrepareData(): NO t0's found, neither in the addrun (" << fRunInfo->fRunName[i].Data() << ") data nor in the msr-file!";
return false; return false;
@ -391,20 +391,20 @@ bool PRunAsymmetry::PrepareData()
t0Add[0] = fRunInfo->fT0[0]; t0Add[0] = fRunInfo->fT0[0];
t0Add[1] = fRunInfo->fT0[1]; t0Add[1] = fRunInfo->fT0[1];
} }
if (addRunData->fT0s.size() != 0) { if (addRunData->GetT0s().size() != 0) {
// compare t0's of the msr-file with the one in the data file // compare t0's of the msr-file with the one in the data file
if (fabs(t0Add[0]-addRunData->fT0s[fRunInfo->fForwardHistoNo-1])>5.0) { // given in bins!! if (fabs(t0Add[0]-addRunData->GetT0(fRunInfo->fForwardHistoNo-1))>5.0) { // given in bins!!
cout << endl << "PRunAsymmetry::PrepareData(): **WARNING**: forward histo"; cout << endl << "PRunAsymmetry::PrepareData(): **WARNING**: forward histo";
cout << endl << " t0 from the msr-file is " << fRunInfo->fT0[2*i]; cout << endl << " t0 from the msr-file is " << fRunInfo->fT0[2*i];
cout << endl << " t0 from the data file is " << addRunData->fT0s[fRunInfo->fForwardHistoNo-1]; cout << endl << " t0 from the data file is " << addRunData->GetT0(fRunInfo->fForwardHistoNo-1);
cout << endl << " This is quite a deviation! Is this done intentionally??"; cout << endl << " This is quite a deviation! Is this done intentionally??";
cout << endl << " addrun: " << fRunInfo->fRunName[i].Data(); cout << endl << " addrun: " << fRunInfo->fRunName[i].Data();
cout << endl; cout << endl;
} }
if (fabs(t0Add[1]-addRunData->fT0s[fRunInfo->fBackwardHistoNo-1])>5.0) { // given in bins!! if (fabs(t0Add[1]-addRunData->GetT0(fRunInfo->fBackwardHistoNo-1))>5.0) { // given in bins!!
cout << endl << "PRunAsymmetry::PrepareData(): **WARNING**: backward histo"; cout << endl << "PRunAsymmetry::PrepareData(): **WARNING**: backward histo";
cout << endl << " t0 from the msr-file is " << fRunInfo->fT0[2*i+1]; cout << endl << " t0 from the msr-file is " << fRunInfo->fT0[2*i+1];
cout << endl << " t0 from the data file is " << addRunData->fT0s[fRunInfo->fBackwardHistoNo-1]; cout << endl << " t0 from the data file is " << addRunData->GetT0(fRunInfo->fBackwardHistoNo-1);
cout << endl << " This is quite a deviation! Is this done intentionally??"; cout << endl << " This is quite a deviation! Is this done intentionally??";
cout << endl << " addrun: " << fRunInfo->fRunName[i].Data(); cout << endl << " addrun: " << fRunInfo->fRunName[i].Data();
cout << endl; cout << endl;
@ -413,18 +413,20 @@ bool PRunAsymmetry::PrepareData()
} }
// add forward run // add forward run
for (unsigned int j=0; j<runData->fDataBin[histoNo[0]].size(); j++) { UInt_t addRunSize = addRunData->GetDataBin(histoNo[0])->size();
for (unsigned int j=0; j<runData->GetDataBin(histoNo[0])->size(); j++) {
// make sure that the index stays in the proper range // make sure that the index stays in the proper range
if ((j-t0Add[0]+fT0s[0] >= 0) && (j-t0Add[0]+fT0s[0] < addRunData->fDataBin[histoNo[0]].size())) { if ((j-t0Add[0]+fT0s[0] >= 0) && (j-t0Add[0]+fT0s[0] < addRunSize)) {
fForward[j] += addRunData->fDataBin[histoNo[0]][j-t0Add[0]+fT0s[0]]; fForward[j] += addRunData->GetDataBin(histoNo[0])->at(j-t0Add[0]+fT0s[0]);
} }
} }
// add backward run // add backward run
for (unsigned int j=0; j<runData->fDataBin[histoNo[1]].size(); j++) { addRunSize = addRunData->GetDataBin(histoNo[1])->size();
for (unsigned int j=0; j<runData->GetDataBin(histoNo[1])->size(); j++) {
// make sure that the index stays in the proper range // make sure that the index stays in the proper range
if ((j-t0Add[1]+fT0s[1] >= 0) && (j-t0Add[1]+fT0s[1] < addRunData->fDataBin[histoNo[1]].size())) { if ((j-t0Add[1]+fT0s[1] >= 0) && (j-t0Add[1]+fT0s[1] < addRunSize)) {
fBackward[j] += addRunData->fDataBin[histoNo[1]][j-t0Add[1]+fT0s[1]]; fBackward[j] += addRunData->GetDataBin(histoNo[1])->at(j-t0Add[1]+fT0s[1]);
} }
} }
} }
@ -619,17 +621,17 @@ bool PRunAsymmetry::PrepareFitData(PRawRunData* runData, unsigned int histoNo[2]
start[i] = keep; start[i] = keep;
} }
// 2nd check if start is within proper bounds // 2nd check if start is within proper bounds
if ((start[i] < 0) || (start[i] > (int)runData->fDataBin[histoNo[i]].size())) { if ((start[i] < 0) || (start[i] > (int)runData->GetDataBin(histoNo[i])->size())) {
cout << endl << "PRunAsymmetry::PrepareFitData(): **ERROR** start data bin doesn't make any sense!"; cout << endl << "PRunAsymmetry::PrepareFitData(): **ERROR** start data bin doesn't make any sense!";
return false; return false;
} }
// 3rd check if end is within proper bounds // 3rd check if end is within proper bounds
if ((end[i] < 0) || (end[i] > (int)runData->fDataBin[histoNo[i]].size())) { if ((end[i] < 0) || (end[i] > (int)runData->GetDataBin(histoNo[i])->size())) {
cout << endl << "PRunAsymmetry::PrepareFitData(): **ERROR** end data bin doesn't make any sense!"; cout << endl << "PRunAsymmetry::PrepareFitData(): **ERROR** end data bin doesn't make any sense!";
return false; return false;
} }
// 4th check if t0 is within proper bounds // 4th check if t0 is within proper bounds
if ((t0[i] < 0) || (t0[i] > (int)runData->fDataBin[histoNo[i]].size())) { if ((t0[i] < 0) || (t0[i] > (int)runData->GetDataBin(histoNo[i])->size())) {
cout << endl << "PRunAsymmetry::PrepareFitData(): **ERROR** t0 data bin doesn't make any sense!"; cout << endl << "PRunAsymmetry::PrepareFitData(): **ERROR** t0 data bin doesn't make any sense!";
return false; return false;
} }
@ -643,18 +645,18 @@ bool PRunAsymmetry::PrepareFitData(PRawRunData* runData, unsigned int histoNo[2]
// forward // forward
for (int i=start[0]; i<end[0]; i++) { for (int i=start[0]; i<end[0]; i++) {
if (fRunInfo->fPacking == 1) { if (fRunInfo->fPacking == 1) {
forwardPacked.fValue.push_back(fForward[i]); forwardPacked.AppendValue(fForward[i]);
forwardPacked.fError.push_back(fForwardErr[i]); forwardPacked.AppendErrorValue(fForwardErr[i]);
} else { // packed data, i.e. fRunInfo->fPacking > 1 } else { // packed data, i.e. fRunInfo->fPacking > 1
if (((i-start[0]) % fRunInfo->fPacking == 0) && (i != start[0])) { // fill data if (((i-start[0]) % fRunInfo->fPacking == 0) && (i != start[0])) { // fill data
// in order that after rebinning the fit does not need to be redone (important for plots) // in order that after rebinning the fit does not need to be redone (important for plots)
// the value is normalize to per bin // the value is normalize to per bin
value /= fRunInfo->fPacking; value /= fRunInfo->fPacking;
forwardPacked.fValue.push_back(value); forwardPacked.AppendValue(value);
if (value == 0.0) if (value == 0.0)
forwardPacked.fError.push_back(1.0); forwardPacked.AppendErrorValue(1.0);
else else
forwardPacked.fError.push_back(TMath::Sqrt(error)/fRunInfo->fPacking); forwardPacked.AppendErrorValue(TMath::Sqrt(error)/fRunInfo->fPacking);
value = 0.0; value = 0.0;
error = 0.0; error = 0.0;
} }
@ -665,18 +667,18 @@ bool PRunAsymmetry::PrepareFitData(PRawRunData* runData, unsigned int histoNo[2]
// backward // backward
for (int i=start[1]; i<end[1]; i++) { for (int i=start[1]; i<end[1]; i++) {
if (fRunInfo->fPacking == 1) { if (fRunInfo->fPacking == 1) {
backwardPacked.fValue.push_back(fBackward[i]); backwardPacked.AppendValue(fBackward[i]);
backwardPacked.fError.push_back(fBackwardErr[i]); backwardPacked.AppendErrorValue(fBackwardErr[i]);
} else { // packed data, i.e. fRunInfo->fPacking > 1 } else { // packed data, i.e. fRunInfo->fPacking > 1
if (((i-start[1]) % fRunInfo->fPacking == 0) && (i != start[1])) { // fill data if (((i-start[1]) % fRunInfo->fPacking == 0) && (i != start[1])) { // fill data
// in order that after rebinning the fit does not need to be redone (important for plots) // in order that after rebinning the fit does not need to be redone (important for plots)
// the value is normalize to per bin // the value is normalize to per bin
value /= fRunInfo->fPacking; value /= fRunInfo->fPacking;
backwardPacked.fValue.push_back(value); backwardPacked.AppendValue(value);
if (value == 0.0) if (value == 0.0)
backwardPacked.fError.push_back(1.0); backwardPacked.AppendErrorValue(1.0);
else else
backwardPacked.fError.push_back(TMath::Sqrt(error)/fRunInfo->fPacking); backwardPacked.AppendErrorValue(TMath::Sqrt(error)/fRunInfo->fPacking);
value = 0.0; value = 0.0;
error = 0.0; error = 0.0;
} }
@ -686,10 +688,10 @@ bool PRunAsymmetry::PrepareFitData(PRawRunData* runData, unsigned int histoNo[2]
} }
// check if packed forward and backward hist have the same size, otherwise take the minimum size // check if packed forward and backward hist have the same size, otherwise take the minimum size
unsigned int noOfBins = forwardPacked.fValue.size(); unsigned int noOfBins = forwardPacked.GetValue()->size();
if (forwardPacked.fValue.size() != backwardPacked.fValue.size()) { if (forwardPacked.GetValue()->size() != backwardPacked.GetValue()->size()) {
if (forwardPacked.fValue.size() > backwardPacked.fValue.size()) if (forwardPacked.GetValue()->size() > backwardPacked.GetValue()->size())
noOfBins = backwardPacked.fValue.size(); noOfBins = backwardPacked.GetValue()->size();
} }
// form asymmetry including error propagation // form asymmetry including error propagation
@ -697,42 +699,38 @@ bool PRunAsymmetry::PrepareFitData(PRawRunData* runData, unsigned int histoNo[2]
double f, b, ef, eb; double f, b, ef, eb;
// fill data time start, and step // fill data time start, and step
// data start at data_start-t0 shifted by (pack-1)/2 // data start at data_start-t0 shifted by (pack-1)/2
fData.fDataTimeStart = fTimeResolution*((double)start[0]-t0[0]+(double)(fRunInfo->fPacking-1)/2.0); fData.SetDataTimeStart(fTimeResolution*((double)start[0]-t0[0]+(double)(fRunInfo->fPacking-1)/2.0));
fData.fDataTimeStep = fTimeResolution*(double)fRunInfo->fPacking; fData.SetDataTimeStep(fTimeResolution*(double)fRunInfo->fPacking);
for (unsigned int i=0; i<noOfBins; i++) { for (unsigned int i=0; i<noOfBins; i++) {
// to make the formulae more readable // to make the formulae more readable
f = forwardPacked.fValue[i]; f = forwardPacked.GetValue()->at(i);
b = backwardPacked.fValue[i]; b = backwardPacked.GetValue()->at(i);
ef = forwardPacked.fError[i]; ef = forwardPacked.GetError()->at(i);
eb = backwardPacked.fError[i]; eb = backwardPacked.GetError()->at(i);
// check that there are indeed bins // check that there are indeed bins
if (f+b != 0.0) if (f+b != 0.0)
asym = (f-b) / (f+b); asym = (f-b) / (f+b);
else else
asym = 0.0; asym = 0.0;
fData.fValue.push_back(asym); fData.AppendValue(asym);
// calculate the error // calculate the error
if (f+b != 0.0) if (f+b != 0.0)
error = 2.0/((f+b)*(f+b))*TMath::Sqrt(b*b*ef*ef+eb*eb*f*f); error = 2.0/((f+b)*(f+b))*TMath::Sqrt(b*b*ef*ef+eb*eb*f*f);
else else
error = 1.0; error = 1.0;
fData.fError.push_back(error); fData.AppendErrorValue(error);
} }
// count the number of bins to be fitted // count the number of bins to be fitted
double time; double time;
fNoOfFitBins=0; fNoOfFitBins=0;
for (unsigned int i=0; i<fData.fValue.size(); i++) { for (unsigned int i=0; i<fData.GetValue()->size(); i++) {
time = fData.fDataTimeStart + (double)i * fData.fDataTimeStep; time = fData.GetDataTimeStart() + (double)i * fData.GetDataTimeStep();
if ((time >= fFitStartTime) && (time <= fFitStopTime)) if ((time >= fFitStartTime) && (time <= fFitStopTime))
fNoOfFitBins++; fNoOfFitBins++;
} }
// clean up // clean up
forwardPacked.fValue.clear();
forwardPacked.fError.clear();
backwardPacked.fValue.clear();
backwardPacked.fError.clear();
fForward.clear(); fForward.clear();
fForwardErr.clear(); fForwardErr.clear();
fBackward.clear(); fBackward.clear();
@ -782,8 +780,8 @@ cout << endl;
*/ */
// make sure that there are equal number of rebinned bins in forward and backward // make sure that there are equal number of rebinned bins in forward and backward
unsigned int noOfBins0 = (runData->fDataBin[histoNo[0]].size()-start[0])/packing; unsigned int noOfBins0 = (runData->GetDataBin(histoNo[0])->size()-start[0])/packing;
unsigned int noOfBins1 = (runData->fDataBin[histoNo[1]].size()-start[1])/packing; unsigned int noOfBins1 = (runData->GetDataBin(histoNo[1])->size()-start[1])/packing;
if (noOfBins0 > noOfBins1) if (noOfBins0 > noOfBins1)
noOfBins0 = noOfBins1; noOfBins0 = noOfBins1;
end[0] = start[0] + noOfBins0 * packing; end[0] = start[0] + noOfBins0 * packing;
@ -798,17 +796,17 @@ cout << endl;
start[i] = keep; start[i] = keep;
} }
// 2nd check if start is within proper bounds // 2nd check if start is within proper bounds
if ((start[i] < 0) || (start[i] > (int)runData->fDataBin[histoNo[i]].size())) { if ((start[i] < 0) || (start[i] > (int)runData->GetDataBin(histoNo[i])->size())) {
cout << endl << "PRunAsymmetry::PrepareViewData(): **ERROR** start data bin doesn't make any sense!"; cout << endl << "PRunAsymmetry::PrepareViewData(): **ERROR** start data bin doesn't make any sense!";
return false; return false;
} }
// 3rd check if end is within proper bounds // 3rd check if end is within proper bounds
if ((end[i] < 0) || (end[i] > (int)runData->fDataBin[histoNo[i]].size())) { if ((end[i] < 0) || (end[i] > (int)runData->GetDataBin(histoNo[i])->size())) {
cout << endl << "PRunAsymmetry::PrepareViewData(): **ERROR** end data bin doesn't make any sense!"; cout << endl << "PRunAsymmetry::PrepareViewData(): **ERROR** end data bin doesn't make any sense!";
return false; return false;
} }
// 4th check if t0 is within proper bounds // 4th check if t0 is within proper bounds
if ((t0[i] < 0) || (t0[i] > (int)runData->fDataBin[histoNo[i]].size())) { if ((t0[i] < 0) || (t0[i] > (int)runData->GetDataBin(histoNo[i])->size())) {
cout << endl << "PRunAsymmetry::PrepareViewData(): **ERROR** t0 data bin doesn't make any sense!"; cout << endl << "PRunAsymmetry::PrepareViewData(): **ERROR** t0 data bin doesn't make any sense!";
return false; return false;
} }
@ -822,18 +820,18 @@ cout << endl;
// forward // forward
for (int i=start[0]; i<end[0]; i++) { for (int i=start[0]; i<end[0]; i++) {
if (packing == 1) { if (packing == 1) {
forwardPacked.fValue.push_back(fForward[i]); forwardPacked.AppendValue(fForward[i]);
forwardPacked.fError.push_back(fForwardErr[i]); forwardPacked.AppendErrorValue(fForwardErr[i]);
} else { // packed data, i.e. packing > 1 } else { // packed data, i.e. packing > 1
if (((i-start[0]) % packing == 0) && (i != start[0])) { // fill data if (((i-start[0]) % packing == 0) && (i != start[0])) { // fill data
// in order that after rebinning the fit does not need to be redone (important for plots) // in order that after rebinning the fit does not need to be redone (important for plots)
// the value is normalize to per bin // the value is normalize to per bin
value /= packing; value /= packing;
forwardPacked.fValue.push_back(value); forwardPacked.AppendValue(value);
if (value == 0.0) if (value == 0.0)
forwardPacked.fError.push_back(1.0); forwardPacked.AppendErrorValue(1.0);
else else
forwardPacked.fError.push_back(TMath::Sqrt(error)/packing); forwardPacked.AppendErrorValue(TMath::Sqrt(error)/packing);
value = 0.0; value = 0.0;
error = 0.0; error = 0.0;
} }
@ -844,18 +842,18 @@ cout << endl;
// backward // backward
for (int i=start[1]; i<end[1]; i++) { for (int i=start[1]; i<end[1]; i++) {
if (packing == 1) { if (packing == 1) {
backwardPacked.fValue.push_back(fBackward[i]); backwardPacked.AppendValue(fBackward[i]);
backwardPacked.fError.push_back(fBackwardErr[i]); backwardPacked.AppendErrorValue(fBackwardErr[i]);
} else { // packed data, i.e. packing > 1 } else { // packed data, i.e. packing > 1
if (((i-start[1]) % packing == 0) && (i != start[1])) { // fill data if (((i-start[1]) % packing == 0) && (i != start[1])) { // fill data
// in order that after rebinning the fit does not need to be redone (important for plots) // in order that after rebinning the fit does not need to be redone (important for plots)
// the value is normalize to per bin // the value is normalize to per bin
value /= packing; value /= packing;
backwardPacked.fValue.push_back(value); backwardPacked.AppendValue(value);
if (value == 0.0) if (value == 0.0)
backwardPacked.fError.push_back(1.0); backwardPacked.AppendErrorValue(1.0);
else else
backwardPacked.fError.push_back(TMath::Sqrt(error)/packing); backwardPacked.AppendErrorValue(TMath::Sqrt(error)/packing);
value = 0.0; value = 0.0;
error = 0.0; error = 0.0;
} }
@ -865,10 +863,10 @@ cout << endl;
} }
// check if packed forward and backward hist have the same size, otherwise take the minimum size // check if packed forward and backward hist have the same size, otherwise take the minimum size
unsigned int noOfBins = forwardPacked.fValue.size(); unsigned int noOfBins = forwardPacked.GetValue()->size();
if (forwardPacked.fValue.size() != backwardPacked.fValue.size()) { if (forwardPacked.GetValue()->size() != backwardPacked.GetValue()->size()) {
if (forwardPacked.fValue.size() > backwardPacked.fValue.size()) if (forwardPacked.GetValue()->size() > backwardPacked.GetValue()->size())
noOfBins = backwardPacked.fValue.size(); noOfBins = backwardPacked.GetValue()->size();
} }
// form asymmetry including error propagation // form asymmetry including error propagation
@ -876,11 +874,11 @@ cout << endl;
double f, b, ef, eb, alpha = 1.0, beta = 1.0; double f, b, ef, eb, alpha = 1.0, beta = 1.0;
// fill data time start, and step // fill data time start, and step
// data start at data_start-t0 // data start at data_start-t0
fData.fDataTimeStart = fTimeResolution*((double)start[0]-t0[0]+(double)(packing-1)/2.0); fData.SetDataTimeStart(fTimeResolution*((double)start[0]-t0[0]+(double)(packing-1)/2.0));
fData.fDataTimeStep = fTimeResolution*(double)packing; fData.SetDataTimeStep(fTimeResolution*(double)packing);
/* /*
cout << endl << ">> start time = " << fData.fDataTimeStart << ", step = " << fData.fDataTimeStep; cout << endl << ">> start time = " << fData.GetDataTimeStart() << ", step = " << fData.GetDataTimeStep();
cout << endl << "--------------------------------" << endl; cout << endl << "--------------------------------" << endl;
*/ */
@ -907,40 +905,36 @@ cout << endl << "--------------------------------" << endl;
} }
//cout << endl << ">> alpha = " << alpha << ", beta = " << beta; //cout << endl << ">> alpha = " << alpha << ", beta = " << beta;
for (unsigned int i=0; i<forwardPacked.fValue.size(); i++) { for (unsigned int i=0; i<forwardPacked.GetValue()->size(); i++) {
// to make the formulae more readable // to make the formulae more readable
f = forwardPacked.fValue[i]; f = forwardPacked.GetValue()->at(i);
b = backwardPacked.fValue[i]; b = backwardPacked.GetValue()->at(i);
ef = forwardPacked.fError[i]; ef = forwardPacked.GetError()->at(i);
eb = backwardPacked.fError[i]; eb = backwardPacked.GetError()->at(i);
// check that there are indeed bins // check that there are indeed bins
if (f+b != 0.0) if (f+b != 0.0)
asym = (alpha*f-b) / (alpha*beta*f+b); asym = (alpha*f-b) / (alpha*beta*f+b);
else else
asym = 0.0; asym = 0.0;
fData.fValue.push_back(asym); fData.AppendValue(asym);
// calculate the error // calculate the error
if (f+b != 0.0) if (f+b != 0.0)
error = 2.0/((f+b)*(f+b))*TMath::Sqrt(b*b*ef*ef+eb*eb*f*f); error = 2.0/((f+b)*(f+b))*TMath::Sqrt(b*b*ef*ef+eb*eb*f*f);
else else
error = 1.0; error = 1.0;
fData.fError.push_back(error); fData.AppendErrorValue(error);
} }
// count the number of bins to be fitted // count the number of bins to be fitted
double time; double time;
fNoOfFitBins=0; fNoOfFitBins=0;
for (unsigned int i=0; i<fData.fValue.size(); i++) { for (unsigned int i=0; i<fData.GetValue()->size(); i++) {
time = fData.fDataTimeStart + (double)i * fData.fDataTimeStep; time = fData.GetDataTimeStart() + (double)i * fData.GetDataTimeStep();
if ((time >= fFitStartTime) && (time <= fFitStopTime)) if ((time >= fFitStartTime) && (time <= fFitStopTime))
fNoOfFitBins++; fNoOfFitBins++;
} }
// clean up // clean up
forwardPacked.fValue.clear();
forwardPacked.fError.clear();
backwardPacked.fValue.clear();
backwardPacked.fError.clear();
fForward.clear(); fForward.clear();
fForwardErr.clear(); fForwardErr.clear();
fBackward.clear(); fBackward.clear();
@ -953,22 +947,22 @@ cout << endl << "--------------------------------" << endl;
} }
// calculate theory // calculate theory
unsigned int size = runData->fDataBin[histoNo[0]].size(); unsigned int size = runData->GetDataBin(histoNo[0])->size();
double factor = 1.0; double factor = 1.0;
if (fData.fValue.size() * 10 > runData->fDataBin[histoNo[0]].size()) { if (fData.GetValue()->size() * 10 > runData->GetDataBin(histoNo[0])->size()) {
size = fData.fValue.size() * 10; size = fData.GetValue()->size() * 10;
factor = (double)runData->fDataBin[histoNo[0]].size() / (double)size; factor = (double)runData->GetDataBin(histoNo[0])->size() / (double)size;
} }
//cout << endl << ">> runData->fDataBin[histoNo[0]].size() = " << runData->fDataBin[histoNo[0]].size() << ", fData.fValue.size() * 10 = " << fData.fValue.size() * 10 << ", size = " << size << ", factor = " << factor << endl; //cout << endl << ">> runData->fDataBin[histoNo[0]].size() = " << runData->fDataBin[histoNo[0]].size() << ", fData.GetValue()->size() * 10 = " << fData.GetValue()->size() * 10 << ", size = " << size << ", factor = " << factor << endl;
fData.fTheoryTimeStart = fData.fDataTimeStart; fData.SetTheoryTimeStart(fData.GetDataTimeStart());
fData.fTheoryTimeStep = fTimeResolution*factor; fData.SetTheoryTimeStep(fTimeResolution*factor);
for (unsigned int i=0; i<size; i++) { for (unsigned int i=0; i<size; i++) {
time = fData.fTheoryTimeStart + (double)i*fTimeResolution*factor; time = fData.GetTheoryTimeStart() + (double)i*fTimeResolution*factor;
value = fTheory->Func(time, par, fFuncValues); value = fTheory->Func(time, par, fFuncValues);
if (fabs(value) > 10.0) { // dirty hack needs to be fixed!! if (fabs(value) > 10.0) { // dirty hack needs to be fixed!!
value = 0.0; value = 0.0;
} }
fData.fTheory.push_back(value); fData.AppendTheoryValue(value);
} }
// clean up // clean up

View File

@ -11,7 +11,7 @@
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007 by Andreas Suter * * Copyright (C) 2007 by Andreas Suter *
* andreas.suter@psi.c * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by * * it under the terms of the GNU General Public License as published by *
@ -36,7 +36,7 @@
#include <TString.h> #include <TString.h>
#include <TObjArray.h> #include <TObjArray.h>
#include <TObjString.h> #include <TObjString.h>
#include <TFile.h> //#include <TFile.h>
#include <TFolder.h> #include <TFolder.h>
#include "TLemRunHeader.h" #include "TLemRunHeader.h"
@ -126,10 +126,6 @@ PRunBase::~PRunBase()
{ {
fParamNo.clear(); fParamNo.clear();
fData.fValue.clear();
fData.fError.clear();
fData.fTheory.clear();
fT0s.clear(); fT0s.clear();
fFuncValues.clear(); fFuncValues.clear();
@ -144,7 +140,6 @@ PRunBase::~PRunBase()
*/ */
void PRunBase::CleanUp() void PRunBase::CleanUp()
{ {
//cout << endl << "PRunBase::CleanUp() ..." << endl;
if (fTheory) { if (fTheory) {
delete fTheory; delete fTheory;
fTheory = 0; fTheory = 0;

View File

@ -11,7 +11,7 @@
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007 by Andreas Suter * * Copyright (C) 2007 by Andreas Suter *
* andreas.suter@psi.c * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by * * it under the terms of the GNU General Public License as published by *
@ -92,11 +92,6 @@ PRunDataHandler::PRunDataHandler(PMsrHandler *msrInfo, const PStringVector dataP
*/ */
PRunDataHandler::~PRunDataHandler() PRunDataHandler::~PRunDataHandler()
{ {
for (UInt_t i=0; i<fData.size(); i++) {
fData[i].fT0s.clear();
for (UInt_t j=0; j<fData[i].fDataBin.size(); j++)
fData[i].fDataBin[j].clear();
}
fData.clear(); fData.clear();
} }
@ -116,7 +111,7 @@ PRawRunData* PRunDataHandler::GetRunData(const TString &runName)
UInt_t i; UInt_t i;
for (i=0; i<fData.size(); i++) { for (i=0; i<fData.size(); i++) {
if (!fData[i].fRunName.CompareTo(runName)) // run found if (!fData[i].GetRunName()->CompareTo(runName)) // run found
break; break;
} }
@ -193,7 +188,7 @@ Bool_t PRunDataHandler::ReadFile()
Bool_t PRunDataHandler::FileAlreadyRead(TString runName) Bool_t PRunDataHandler::FileAlreadyRead(TString runName)
{ {
for (UInt_t i=0; i<fData.size(); i++) { for (UInt_t i=0; i<fData.size(); i++) {
if (!fData[i].fRunName.CompareTo(runName)) { // run alread read if (!fData[i].GetRunName()->CompareTo(runName)) { // run alread read
return true; return true;
} }
} }
@ -393,27 +388,26 @@ Bool_t PRunDataHandler::ReadRootFile(Bool_t notPostPileup)
// get run title // get run title
TObjString ostr = runHeader->GetRunTitle(); TObjString ostr = runHeader->GetRunTitle();
runData.fRunTitle = ostr.GetString(); runData.SetRunTitle(ostr.GetString());
// get temperature // get temperature
runData.fTemp.resize(1); runData.ClearTemperature();
runData.fTemp[0].first = runHeader->GetSampleTemperature(); runData.SetTemperature(0, runHeader->GetSampleTemperature(), runHeader->GetSampleTemperatureError());
runData.fTemp[0].second = runHeader->GetSampleTemperatureError();
// get field // get field
runData.fField = runHeader->GetSampleBField(); runData.SetField(runHeader->GetSampleBField());
// get implantation energy // get implantation energy
runData.fEnergy = runHeader->GetImpEnergy(); runData.SetEnergy(runHeader->GetImpEnergy());
// get moderator HV // get moderator HV
runData.fTransport = runHeader->GetModeratorHV(); runData.SetTransport(runHeader->GetModeratorHV());
// get setup // get setup
runData.fSetup = runHeader->GetLemSetup().GetString(); runData.SetSetup(runHeader->GetLemSetup().GetString());
// get time resolution // get time resolution
runData.fTimeResolution = runHeader->GetTimeResolution(); runData.SetTimeResolution(runHeader->GetTimeResolution());
// get number of histogramms // get number of histogramms
Int_t noOfHistos = runHeader->GetNHist(); Int_t noOfHistos = runHeader->GetNHist();
@ -424,7 +418,7 @@ Bool_t PRunDataHandler::ReadRootFile(Bool_t notPostPileup)
if (t0[0] != -1) { // ugly, but at the moment there is no other way if (t0[0] != -1) { // ugly, but at the moment there is no other way
// copy t0's so they are not lost // copy t0's so they are not lost
for (Int_t i=0; i<noOfHistos; i++) { for (Int_t i=0; i<noOfHistos; i++) {
runData.fT0s.push_back((Int_t)t0[i]); runData.AppendT0((Int_t)t0[i]);
} }
} }
@ -433,7 +427,7 @@ Bool_t PRunDataHandler::ReadRootFile(Bool_t notPostPileup)
// check if run summary is valid // check if run summary is valid
if (!runSummary) { if (!runSummary) {
cout << endl << "Couldn't obtain run summary info from ROOT file " << fRunPathName.Data() << endl; cout << endl << "**INFO** Couldn't obtain run summary info from ROOT file " << fRunPathName.Data() << endl;
// this is not fatal... only RA-HV values are not available // this is not fatal... only RA-HV values are not available
} else { // it follows a (at least) little bit strange extraction of the RA values from Thomas' TObjArray... } else { // it follows a (at least) little bit strange extraction of the RA values from Thomas' TObjArray...
//streaming of a ASCII-file would be more easy //streaming of a ASCII-file would be more easy
@ -442,21 +436,19 @@ Bool_t PRunDataHandler::ReadRootFile(Bool_t notPostPileup)
TObjString *os(dynamic_cast<TObjString*>(summIter.Next())); TObjString *os(dynamic_cast<TObjString*>(summIter.Next()));
TObjArray *oa(0); TObjArray *oa(0);
TObjString *objTok(0); TObjString *objTok(0);
while(os != 0){ while (os != 0) {
s = os->GetString(); s = os->GetString();
// will put four parallel if's since it may be that more than one RA-values are on one line // will put four parallel if's since it may be that more than one RA-values are on one line
if(s.Contains("RA-L")){ if (s.Contains("RA-L")) {
if(runData.fRingAnode.empty() || runData.fRingAnode.size() == 2)
runData.fRingAnode.resize(2);
oa = s.Tokenize(" "); oa = s.Tokenize(" ");
TObjArrayIter lineIter(oa); TObjArrayIter lineIter(oa);
objTok = dynamic_cast<TObjString*>(lineIter.Next()); objTok = dynamic_cast<TObjString*>(lineIter.Next());
while (objTok != 0){ while (objTok != 0) {
if(!objTok->GetString().CompareTo("RA-L")){ if (!objTok->GetString().CompareTo("RA-L")) {
objTok = dynamic_cast<TObjString*>(lineIter.Next()); // "=" objTok = dynamic_cast<TObjString*>(lineIter.Next()); // "="
if(objTok != 0 && !objTok->GetString().CompareTo("=")){ if (objTok != 0 && !objTok->GetString().CompareTo("=")) {
objTok = dynamic_cast<TObjString*>(lineIter.Next()); // HV value objTok = dynamic_cast<TObjString*>(lineIter.Next()); // HV value
runData.fRingAnode[0] = objTok->GetString().Atof(); // fill RA-R value into the runData structure runData.SetRingAnode(0, objTok->GetString().Atof()); // fill RA-R value into the runData structure
break; break;
} }
} }
@ -464,18 +456,16 @@ Bool_t PRunDataHandler::ReadRootFile(Bool_t notPostPileup)
} }
} }
if(s.Contains("RA-R")){ if (s.Contains("RA-R")) {
if(runData.fRingAnode.empty() || runData.fRingAnode.size() == 2)
runData.fRingAnode.resize(2);
oa = s.Tokenize(" "); oa = s.Tokenize(" ");
TObjArrayIter lineIter(oa); TObjArrayIter lineIter(oa);
objTok = dynamic_cast<TObjString*>(lineIter.Next()); objTok = dynamic_cast<TObjString*>(lineIter.Next());
while (objTok != 0){ while (objTok != 0){
if(!objTok->GetString().CompareTo("RA-R")){ if (!objTok->GetString().CompareTo("RA-R")) {
objTok = dynamic_cast<TObjString*>(lineIter.Next()); // "=" objTok = dynamic_cast<TObjString*>(lineIter.Next()); // "="
if(objTok != 0 && !objTok->GetString().CompareTo("=")){ if (objTok != 0 && !objTok->GetString().CompareTo("=")) {
objTok = dynamic_cast<TObjString*>(lineIter.Next()); // HV value objTok = dynamic_cast<TObjString*>(lineIter.Next()); // HV value
runData.fRingAnode[1] = objTok->GetString().Atof(); // fill RA-R value into the runData structure runData.SetRingAnode(1, objTok->GetString().Atof()); // fill RA-R value into the runData structure
break; break;
} }
} }
@ -483,18 +473,16 @@ Bool_t PRunDataHandler::ReadRootFile(Bool_t notPostPileup)
} }
} }
if(s.Contains("RA-T")){ if (s.Contains("RA-T")) {
if(runData.fRingAnode.empty() || runData.fRingAnode.size() == 2)
runData.fRingAnode.resize(4);
oa = s.Tokenize(" "); oa = s.Tokenize(" ");
TObjArrayIter lineIter(oa); TObjArrayIter lineIter(oa);
objTok = dynamic_cast<TObjString*>(lineIter.Next()); objTok = dynamic_cast<TObjString*>(lineIter.Next());
while (objTok != 0){ while (objTok != 0){
if(!objTok->GetString().CompareTo("RA-T")){ if (!objTok->GetString().CompareTo("RA-T")) {
objTok = dynamic_cast<TObjString*>(lineIter.Next()); // "=" objTok = dynamic_cast<TObjString*>(lineIter.Next()); // "="
if(objTok != 0 && !objTok->GetString().CompareTo("=")){ if (objTok != 0 && !objTok->GetString().CompareTo("=")) {
objTok = dynamic_cast<TObjString*>(lineIter.Next()); // HV value objTok = dynamic_cast<TObjString*>(lineIter.Next()); // HV value
runData.fRingAnode[2] = objTok->GetString().Atof(); // fill RA-T value into the runData structure runData.SetRingAnode(2, objTok->GetString().Atof()); // fill RA-T value into the runData structure
break; break;
} }
} }
@ -502,18 +490,16 @@ Bool_t PRunDataHandler::ReadRootFile(Bool_t notPostPileup)
} }
} }
if(s.Contains("RA-B")){ if (s.Contains("RA-B")) {
if(runData.fRingAnode.empty() || runData.fRingAnode.size() == 2)
runData.fRingAnode.resize(4);
oa = s.Tokenize(" "); oa = s.Tokenize(" ");
TObjArrayIter lineIter(oa); TObjArrayIter lineIter(oa);
objTok = dynamic_cast<TObjString*>(lineIter.Next()); objTok = dynamic_cast<TObjString*>(lineIter.Next());
while (objTok != 0){ while (objTok != 0){
if(!objTok->GetString().CompareTo("RA-B")){ if (!objTok->GetString().CompareTo("RA-B")) {
objTok = dynamic_cast<TObjString*>(lineIter.Next()); // "=" objTok = dynamic_cast<TObjString*>(lineIter.Next()); // "="
if(objTok != 0 && !objTok->GetString().CompareTo("=")){ if (objTok != 0 && !objTok->GetString().CompareTo("=")) {
objTok = dynamic_cast<TObjString*>(lineIter.Next()); // HV value objTok = dynamic_cast<TObjString*>(lineIter.Next()); // HV value
runData.fRingAnode[3] = objTok->GetString().Atof(); // fill RA-B value into the runData structure runData.SetRingAnode(3, objTok->GetString().Atof()); // fill RA-B value into the runData structure
break; break;
} }
} }
@ -547,7 +533,7 @@ Bool_t PRunDataHandler::ReadRootFile(Bool_t notPostPileup)
for (Int_t j=1; j<histo->GetNbinsX(); j++) for (Int_t j=1; j<histo->GetNbinsX(); j++)
histoData.push_back(histo->GetBinContent(j)); histoData.push_back(histo->GetBinContent(j));
// store them in runData vector // store them in runData vector
runData.fDataBin.push_back(histoData); runData.AppendDataBin(histoData);
// clear histoData for the next histo // clear histoData for the next histo
histoData.clear(); histoData.clear();
} }
@ -563,7 +549,7 @@ Bool_t PRunDataHandler::ReadRootFile(Bool_t notPostPileup)
for (Int_t j=1; j<histo->GetNbinsX(); j++) for (Int_t j=1; j<histo->GetNbinsX(); j++)
histoData.push_back(histo->GetBinContent(j)); histoData.push_back(histo->GetBinContent(j));
// store them in runData vector // store them in runData vector
runData.fDataBin.push_back(histoData); runData.AppendDataBin(histoData);
// clear histoData for the next histo // clear histoData for the next histo
histoData.clear(); histoData.clear();
} }
@ -572,18 +558,11 @@ Bool_t PRunDataHandler::ReadRootFile(Bool_t notPostPileup)
f.Close(); f.Close();
// keep run name // keep run name
runData.fRunName = fRunName; runData.SetRunName(fRunName);
// add run to the run list // add run to the run list
fData.push_back(runData); fData.push_back(runData);
// clean up
for (UInt_t i=0; i<runData.fDataBin.size(); i++)
runData.fDataBin[i].clear();
runData.fDataBin.clear();
runData.fRingAnode.clear();
return true; return true;
} }
@ -616,17 +595,6 @@ Bool_t PRunDataHandler::ReadWkmFile()
PDoubleVector histoData; PDoubleVector histoData;
PRawRunData runData; PRawRunData runData;
// init runData header info
runData.fRunName = TString("");
runData.fRunTitle = TString("");
runData.fSetup = TString("");
runData.fField = -9.9e99;
runData.fTemp.clear();
runData.fEnergy = -999.0; // standard LEM values...
runData.fTransport = -999.0; // standard LEM values...
runData.fRingAnode.clear();
runData.fTimeResolution = 0.0;
// open file // open file
ifstream f; ifstream f;
@ -666,7 +634,7 @@ Bool_t PRunDataHandler::ReadWkmFile()
idx = line.Index(":"); idx = line.Index(":");
line.Replace(0, idx+1, 0, 0); // remove 'Title:' line.Replace(0, idx+1, 0, 0); // remove 'Title:'
StripWhitespace(line); StripWhitespace(line);
runData.fRunTitle = line; runData.SetRunTitle(line);
} else if (line.Contains("Field")) { } else if (line.Contains("Field")) {
idx = line.Index(":"); idx = line.Index(":");
line.Replace(0, idx+1, 0, 0); // remove 'Field:' line.Replace(0, idx+1, 0, 0); // remove 'Field:'
@ -676,12 +644,12 @@ Bool_t PRunDataHandler::ReadWkmFile()
line.Resize(idx); line.Resize(idx);
dval = ToDouble(line, ok); dval = ToDouble(line, ok);
if (ok) if (ok)
runData.fField = dval; runData.SetField(dval);
} else if (line.Contains("Setup")) { } else if (line.Contains("Setup")) {
idx = line.Index(":"); idx = line.Index(":");
line.Replace(0, idx+1, 0, 0); // remove 'Setup:' line.Replace(0, idx+1, 0, 0); // remove 'Setup:'
StripWhitespace(line); StripWhitespace(line);
runData.fSetup = line; runData.SetSetup(line);
} else if (line.Contains("Temp:") || line.Contains("Temp(meas1):")) { } else if (line.Contains("Temp:") || line.Contains("Temp(meas1):")) {
linecp = line; linecp = line;
idx = line.Index(":"); idx = line.Index(":");
@ -694,17 +662,15 @@ Bool_t PRunDataHandler::ReadWkmFile()
if (idx > 0) if (idx > 0)
line.Resize(idx); line.Resize(idx);
dval = ToDouble(line, ok); dval = ToDouble(line, ok);
if (ok){ if (ok) {
runData.fTemp.resize(1); runData.SetTemperature(0, dval, 0.0);
runData.fTemp[0].first = dval;
runData.fTemp[0].second = 0.0;
} }
idx = linecp.Index("+/-"); // get the error idx = linecp.Index("+/-"); // get the error
linecp.Replace(0, idx+3, 0, 0); linecp.Replace(0, idx+3, 0, 0);
StripWhitespace(linecp); StripWhitespace(linecp);
dval = ToDouble(linecp, ok); dval = ToDouble(linecp, ok);
if (ok && !runData.fTemp.empty()){ if (ok) {
runData.fTemp[0].second = dval; runData.SetTempError(0, dval);
} }
} else if (line.Contains("Temp(meas2):")) { } else if (line.Contains("Temp(meas2):")) {
linecp = line; linecp = line;
@ -718,17 +684,15 @@ Bool_t PRunDataHandler::ReadWkmFile()
if (idx > 0) if (idx > 0)
line.Resize(idx); line.Resize(idx);
dval = ToDouble(line, ok); dval = ToDouble(line, ok);
if (ok){ if (ok) {
runData.fTemp.resize(2); runData.SetTemperature(1, dval, 0.0);
runData.fTemp[1].first = dval;
runData.fTemp[1].second = 0.0;
} }
idx = linecp.Index("+/-"); // get the error idx = linecp.Index("+/-"); // get the error
linecp.Replace(0, idx+3, 0, 0); linecp.Replace(0, idx+3, 0, 0);
StripWhitespace(linecp); StripWhitespace(linecp);
dval = ToDouble(linecp, ok); dval = ToDouble(linecp, ok);
if (ok && runData.fTemp.size() > 1){ if (ok) {
runData.fTemp[1].second = dval; runData.SetTempError(1, dval);
} }
} else if (line.Contains("Groups")) { } else if (line.Contains("Groups")) {
idx = line.Index(":"); idx = line.Index(":");
@ -750,7 +714,7 @@ Bool_t PRunDataHandler::ReadWkmFile()
StripWhitespace(line); StripWhitespace(line);
dval = ToDouble(line, ok); dval = ToDouble(line, ok);
if (ok) if (ok)
runData.fTimeResolution = dval * 1000.0; runData.SetTimeResolution(dval * 1000.0);
} }
} }
@ -758,11 +722,11 @@ Bool_t PRunDataHandler::ReadWkmFile()
f.getline(instr, sizeof(instr)); f.getline(instr, sizeof(instr));
} while (headerInfo && !f.eof()); } while (headerInfo && !f.eof());
if ((groups == 0) || (channels == 0) || runData.fTimeResolution == 0.0) { if ((groups == 0) || (channels == 0) || runData.GetTimeResolution() == 0.0) {
cerr << endl << "PRunDataHandler::ReadWkmFile(): **ERROR** essential header informations are missing!"; cerr << endl << "PRunDataHandler::ReadWkmFile(): **ERROR** essential header informations are missing!";
cerr << endl << " >> groups = " << groups; cerr << endl << " >> groups = " << groups;
cerr << endl << " >> channels = " << channels; cerr << endl << " >> channels = " << channels;
cerr << endl << " >> time resolution = " << runData.fTimeResolution; cerr << endl << " >> time resolution = " << runData.GetTimeResolution();
cerr << endl; cerr << endl;
f.close(); f.close();
return false; return false;
@ -777,7 +741,7 @@ Bool_t PRunDataHandler::ReadWkmFile()
do { do {
// check if empty line, i.e. new group // check if empty line, i.e. new group
if (IsWhitespace(instr)) { if (IsWhitespace(instr)) {
runData.fDataBin.push_back(histoData); runData.AppendDataBin(histoData);
histoData.clear(); histoData.clear();
group_counter++; group_counter++;
} else { } else {
@ -792,10 +756,6 @@ Bool_t PRunDataHandler::ReadWkmFile()
if (!tokens) { // no tokens found if (!tokens) { // no tokens found
cerr << endl << "PRunDataHandler::ReadWkmFile(): **ERROR** while reading data: coulnd't tokenize run data."; cerr << endl << "PRunDataHandler::ReadWkmFile(): **ERROR** while reading data: coulnd't tokenize run data.";
// clean up
for (UInt_t i=0; i<group_counter; i++)
runData.fDataBin[i].clear();
runData.fDataBin.clear();
return false; return false;
} }
for (Int_t i=0; i<tokens->GetEntries(); i++) { for (Int_t i=0; i<tokens->GetEntries(); i++) {
@ -807,9 +767,6 @@ Bool_t PRunDataHandler::ReadWkmFile()
} else { } else {
cerr << endl << "PRunDataHandler::ReadWkmFile(): **ERROR** while reading data: data line contains non-integer values."; cerr << endl << "PRunDataHandler::ReadWkmFile(): **ERROR** while reading data: data line contains non-integer values.";
// clean up // clean up
for (UInt_t i=0; i<group_counter; i++)
runData.fDataBin[i].clear();
runData.fDataBin.clear();
delete tokens; delete tokens;
return false; return false;
} }
@ -832,10 +789,6 @@ Bool_t PRunDataHandler::ReadWkmFile()
tokens = line.Tokenize(" "); tokens = line.Tokenize(" ");
if (!tokens) { // no tokens found if (!tokens) { // no tokens found
cerr << endl << "PRunDataHandler::ReadWkmFile(): **ERROR** while reading data: coulnd't tokenize run data."; cerr << endl << "PRunDataHandler::ReadWkmFile(): **ERROR** while reading data: coulnd't tokenize run data.";
// clean up
for (UInt_t i=0; i<group_counter; i++)
runData.fDataBin[i].clear();
runData.fDataBin.clear();
return false; return false;
} }
for (Int_t i=0; i<tokens->GetEntries(); i++) { for (Int_t i=0; i<tokens->GetEntries(); i++) {
@ -847,9 +800,6 @@ Bool_t PRunDataHandler::ReadWkmFile()
} else { } else {
cerr << endl << "PRunDataHandler::ReadWkmFile(): **ERROR** while reading data: data line contains non-integer values."; cerr << endl << "PRunDataHandler::ReadWkmFile(): **ERROR** while reading data: data line contains non-integer values.";
// clean up // clean up
for (UInt_t i=0; i<group_counter; i++)
runData.fDataBin[i].clear();
runData.fDataBin.clear();
delete tokens; delete tokens;
return false; return false;
} }
@ -863,7 +813,7 @@ Bool_t PRunDataHandler::ReadWkmFile()
// save the last histo if not empty // save the last histo if not empty
if (histoData.size() > 0) { if (histoData.size() > 0) {
runData.fDataBin.push_back(histoData); runData.AppendDataBin(histoData);
histoData.clear(); histoData.clear();
} }
@ -871,40 +821,27 @@ Bool_t PRunDataHandler::ReadWkmFile()
f.close(); f.close();
// check if all groups are found // check if all groups are found
if ((Int_t) runData.fDataBin.size() != groups) { if ((Int_t) runData.GetNoOfHistos() != groups) {
cerr << endl << "PRunDataHandler::ReadWkmFile(): **ERROR**"; cerr << endl << "PRunDataHandler::ReadWkmFile(): **ERROR**";
cerr << endl << " expected " << groups << " histos, but found " << runData.fDataBin.size(); cerr << endl << " expected " << groups << " histos, but found " << runData.GetNoOfHistos();
// clean up
for (UInt_t i=0; i<runData.fDataBin.size(); i++)
runData.fDataBin[i].clear();
runData.fDataBin.clear();
return false; return false;
} }
// check if all groups have enough channels // check if all groups have enough channels
for (UInt_t i=0; i<runData.fDataBin.size(); i++) { for (UInt_t i=0; i<runData.GetNoOfHistos(); i++) {
if ((Int_t) runData.fDataBin[i].size() != channels) { if ((Int_t) runData.GetDataBin(i)->size() != channels) {
cerr << endl << "PRunDataHandler::ReadWkmFile(): **ERROR**"; cerr << endl << "PRunDataHandler::ReadWkmFile(): **ERROR**";
cerr << endl << " expected " << channels << " bins in histo " << i << ", but found " << runData.fDataBin[i].size(); cerr << endl << " expected " << channels << " bins in histo " << i << ", but found " << runData.GetDataBin(i)->size();
// clean up
for (UInt_t j=0; j<runData.fDataBin.size(); j++)
runData.fDataBin[j].clear();
runData.fDataBin.clear();
return false; return false;
} }
} }
// keep run name // keep run name
runData.fRunName = fRunName; runData.SetRunName(fRunName);
// add run to the run list // add run to the run list
fData.push_back(runData); fData.push_back(runData);
// clean up
for (UInt_t i=0; i<runData.fDataBin.size(); i++)
runData.fDataBin[i].clear();
runData.fDataBin.clear();
return true; return true;
} }
@ -963,42 +900,37 @@ Bool_t PRunDataHandler::ReadPsiBinFile()
PRawRunData runData; PRawRunData runData;
Double_t dval; Double_t dval;
// keep run name // keep run name
runData.fRunName = fRunName; runData.SetRunName(fRunName);
// get run title // get run title
runData.fRunTitle = TString(psiBin.get_comment().c_str()); // run title runData.SetRunTitle(TString(psiBin.get_comment().c_str())); // run title
// get setup // get setup
runData.fSetup = TString(psiBin.get_orient().c_str()); runData.SetSetup(TString(psiBin.get_orient().c_str()));
// set LEM specific information to default value since it is not in the file and not used... // set LEM specific information to default value since it is not in the file and not used...
runData.fEnergy = -999.0; runData.SetEnergy(PMUSR_UNDEFINED);
runData.fTransport = -999.0; runData.SetTransport(PMUSR_UNDEFINED);
runData.fRingAnode.clear();
// get field // get field
status = sscanf(psiBin.get_field().c_str(), "%lfG", &dval); status = sscanf(psiBin.get_field().c_str(), "%lfG", &dval);
if (status == 1) if (status == 1)
runData.fField = dval; runData.SetField(dval);
// get temperature // get temperature
PDoubleVector tempVec(psiBin.get_temperatures_vector()); PDoubleVector tempVec(psiBin.get_temperatures_vector());
PDoubleVector tempDevVec(psiBin.get_devTemperatures_vector()); PDoubleVector tempDevVec(psiBin.get_devTemperatures_vector());
if(tempVec.size() > 1 && tempDevVec.size() > 1 && tempVec[0] && tempVec[1]) { if ((tempVec.size() > 1) && (tempDevVec.size() > 1) && tempVec[0] && tempVec[1]) {
runData.fTemp.resize(2);
// take only the first two values for now... // take only the first two values for now...
//maybe that's not enough - e.g. in older GPD data I saw the "correct values in the second and third entry..." //maybe that's not enough - e.g. in older GPD data I saw the "correct values in the second and third entry..."
for (UInt_t i(0); i<2; i++){ for (UInt_t i(0); i<2; i++) {
runData.fTemp[i].first = tempVec[i]; runData.SetTemperature(i, tempVec[i], tempDevVec[i]);
runData.fTemp[i].second = tempDevVec[i];
} }
tempVec.clear(); tempVec.clear();
tempDevVec.clear(); tempDevVec.clear();
} else { } else {
status = sscanf(psiBin.get_temp().c_str(), "%lfK", &dval); status = sscanf(psiBin.get_temp().c_str(), "%lfK", &dval);
if (status == 1) if (status == 1)
runData.fTemp.resize(1); runData.SetTemperature(0, dval, 0.0);
runData.fTemp[0].first = dval;
runData.fTemp[0].second = 0.0;
} }
// get time resolution (ns) // get time resolution (ns)
runData.fTimeResolution = psiBin.get_binWidth_ns(); runData.SetTimeResolution(psiBin.get_binWidth_ns());
// get t0's // get t0's
ivec = psiBin.get_t0_vector(); ivec = psiBin.get_t0_vector();
if (ivec.empty()) { if (ivec.empty()) {
@ -1007,7 +939,7 @@ Bool_t PRunDataHandler::ReadPsiBinFile()
return false; return false;
} }
for (UInt_t i=0; i<ivec.size(); i++) for (UInt_t i=0; i<ivec.size(); i++)
runData.fT0s.push_back(ivec[i]); runData.AppendT0(ivec[i]);
// fill raw data // fill raw data
PDoubleVector histoData; PDoubleVector histoData;
@ -1018,19 +950,13 @@ Bool_t PRunDataHandler::ReadPsiBinFile()
histoData.push_back(histo[j]); histoData.push_back(histo[j]);
} }
delete histo; delete histo;
runData.fDataBin.push_back(histoData); runData.AppendDataBin(histoData);
histoData.clear(); histoData.clear();
} }
// add run to the run list // add run to the run list
fData.push_back(runData); fData.push_back(runData);
// clean up
runData.fT0s.clear();
for (UInt_t i=0; i<runData.fDataBin.size(); i++)
runData.fDataBin[i].clear();
runData.fDataBin.clear();
return success; return success;
} }
@ -1062,7 +988,7 @@ Bool_t PRunDataHandler::ReadMudFile()
// read necessary header information // read necessary header information
// keep run name // keep run name
runData.fRunName = fRunName; runData.SetRunName(fRunName);
// get run title // get run title
success = MUD_getTitle( fh, str, sizeof(str) ); success = MUD_getTitle( fh, str, sizeof(str) );
@ -1070,59 +996,56 @@ Bool_t PRunDataHandler::ReadMudFile()
cerr << endl << "**WARNING** Couldn't obtain the run title of run " << fRunName.Data(); cerr << endl << "**WARNING** Couldn't obtain the run title of run " << fRunName.Data();
cerr << endl; cerr << endl;
} }
runData.fRunTitle = TString(str); runData.SetRunTitle(TString(str));
// get setup // get setup
TString setup;
success = MUD_getLab( fh, str, sizeof(str) ); success = MUD_getLab( fh, str, sizeof(str) );
if (success) { if (success) {
runData.fSetup = TString(str) + TString("/"); setup = TString(str) + TString("/");
} }
success = MUD_getArea( fh, str, sizeof(str) ); success = MUD_getArea( fh, str, sizeof(str) );
if (success) { if (success) {
runData.fSetup += TString(str) + TString("/"); setup += TString(str) + TString("/");
} }
success = MUD_getApparatus( fh, str, sizeof(str) ); success = MUD_getApparatus( fh, str, sizeof(str) );
if (success) { if (success) {
runData.fSetup += TString(str) + TString("/"); setup += TString(str) + TString("/");
} }
success = MUD_getSample( fh, str, sizeof(str) ); success = MUD_getSample( fh, str, sizeof(str) );
if (success) { if (success) {
runData.fSetup += TString(str); setup += TString(str);
} }
runData.SetSetup(setup);
// set LEM specific information to default value since it is not in the file and not used... // set LEM specific information to default value since it is not in the file and not used...
runData.fEnergy = -999.0; runData.SetEnergy(PMUSR_UNDEFINED);
runData.fTransport = -999.0; runData.SetTransport(PMUSR_UNDEFINED);
runData.fRingAnode.clear();
// get field // get field
success = MUD_getField( fh, str, sizeof(str) ); success = MUD_getField( fh, str, sizeof(str) );
if (success) { if (success) {
success = sscanf(str, "%lf G", &dval); success = sscanf(str, "%lf G", &dval);
if (success == 1) { if (success == 1) {
runData.fField = dval; runData.SetField(dval);
} else { } else {
runData.fField = -9.9e99; runData.SetField(PMUSR_UNDEFINED);
} }
} else { } else {
runData.fField = -9.9e99; runData.SetField(PMUSR_UNDEFINED);
} }
// get temperature // get temperature
success = MUD_getTemperature( fh, str, sizeof(str) ); success = MUD_getTemperature( fh, str, sizeof(str) );
if (success) { if (success) {
runData.fTemp.resize(1);
success = sscanf(str, "%lf K", &dval); success = sscanf(str, "%lf K", &dval);
if (success == 1) { if (success == 1) {
runData.fTemp[0].first = dval; runData.SetTemperature(0, dval, 0.0);
runData.fTemp[0].second = 0.0;
} else { } else {
runData.fTemp[0].first = -9.9e99; runData.SetTemperature(0, PMUSR_UNDEFINED, 0.0);
runData.fTemp[0].second = 0.0;
} }
} else { } else {
runData.fTemp[0].first = -9.9e99; runData.SetTemperature(0, PMUSR_UNDEFINED, 0.0);
runData.fTemp[0].second = 0.0;
} }
// get number of histogramms // get number of histogramms
@ -1161,7 +1084,7 @@ Bool_t PRunDataHandler::ReadMudFile()
} }
} }
} }
runData.fTimeResolution = (Double_t)fsTimeResolution / 1.0e6; // fs -> ns runData.SetTimeResolution((Double_t)fsTimeResolution / 1.0e6); // fs -> ns
// read histograms // read histograms
pair<Int_t, Int_t> valPair; pair<Int_t, Int_t> valPair;
@ -1178,7 +1101,7 @@ Bool_t PRunDataHandler::ReadMudFile()
cerr << endl << "**WARNING** Couldn't get t0 of histo " << i << " of run " << fRunName.Data(); cerr << endl << "**WARNING** Couldn't get t0 of histo " << i << " of run " << fRunName.Data();
cerr << endl; cerr << endl;
} }
runData.fT0s.push_back((Int_t)val); runData.AppendT0((Int_t)val);
// get bkg bins // get bkg bins
success = MUD_getHistBkgd1( fh, i, &val ); success = MUD_getHistBkgd1( fh, i, &val );
@ -1199,9 +1122,7 @@ Bool_t PRunDataHandler::ReadMudFile()
valPair.second = (Int_t)val; valPair.second = (Int_t)val;
if ((valPair.first != -1) && (valPair.second != -1)) { // bkg bin1 && bkg bin2 found if ((valPair.first != -1) && (valPair.second != -1)) { // bkg bin1 && bkg bin2 found
runData.fBkgBin.push_back(valPair); runData.AppendBkgBin(valPair);
} else {
runData.fBkgBin.clear();
} }
// get good data bins // get good data bins
@ -1223,9 +1144,7 @@ Bool_t PRunDataHandler::ReadMudFile()
valPair.second = (Int_t)val; valPair.second = (Int_t)val;
if ((valPair.first != -1) && (valPair.second != -1)) { // good bin1 && good bin2 found if ((valPair.first != -1) && (valPair.second != -1)) { // good bin1 && good bin2 found
runData.fGoodDataBin.push_back(valPair); runData.AppendGoodDataBin(valPair);
} else {
runData.fGoodDataBin.clear();
} }
// get number of bins // get number of bins
@ -1261,7 +1180,7 @@ Bool_t PRunDataHandler::ReadMudFile()
for (UInt_t j=0; j<noOfBins; j++) { for (UInt_t j=0; j<noOfBins; j++) {
histoData.push_back(pData[j]); histoData.push_back(pData[j]);
} }
runData.fDataBin.push_back(histoData); runData.AppendDataBin(histoData);
histoData.clear(); histoData.clear();
free(pData); free(pData);
@ -1289,12 +1208,6 @@ cout << endl;
// add run to the run list // add run to the run list
fData.push_back(runData); fData.push_back(runData);
// clean up
runData.fT0s.clear();
for (UInt_t i=0; i<runData.fDataBin.size(); i++)
runData.fDataBin[i].clear();
runData.fDataBin.clear();
return true; return true;
} }
@ -1353,11 +1266,11 @@ Bool_t PRunDataHandler::ReadAsciiFile()
PRawRunData runData; PRawRunData runData;
// init some stuff // init some stuff
runData.fDataNonMusr.fFromAscii = true; runData.fDataNonMusr.SetFromAscii(true);
runData.fDataNonMusr.fLabels.push_back("??"); // x default label runData.fDataNonMusr.AppendLabel("??"); // x default label
runData.fDataNonMusr.fLabels.push_back("??"); // y default label runData.fDataNonMusr.AppendLabel("??"); // y default label
runData.fRunName = fRunName; // keep the run name runData.SetRunName(fRunName); // keep the run name
Int_t lineNo = 0; Int_t lineNo = 0;
Char_t instr[512]; Char_t instr[512];
@ -1400,9 +1313,9 @@ Bool_t PRunDataHandler::ReadAsciiFile()
workStr = line; workStr = line;
workStr.Remove(TString::kLeading, ' '); // remove spaces from the beining workStr.Remove(TString::kLeading, ' '); // remove spaces from the beining
if (workStr.BeginsWith("title:", TString::kIgnoreCase)) { if (workStr.BeginsWith("title:", TString::kIgnoreCase)) {
runData.fRunTitle = TString(workStr.Data()+workStr.First(":")+2); runData.SetRunTitle(TString(workStr.Data()+workStr.First(":")+2));
} else if (workStr.BeginsWith("setup:", TString::kIgnoreCase)) { } else if (workStr.BeginsWith("setup:", TString::kIgnoreCase)) {
runData.fSetup = TString(workStr.Data()+workStr.First(":")+2); runData.SetSetup(TString(workStr.Data()+workStr.First(":")+2));
} else if (workStr.BeginsWith("field:", TString::kIgnoreCase)) { } else if (workStr.BeginsWith("field:", TString::kIgnoreCase)) {
workStr = TString(workStr.Data()+workStr.First(":")+2); workStr = TString(workStr.Data()+workStr.First(":")+2);
if (!workStr.IsFloat()) { if (!workStr.IsFloat()) {
@ -1411,11 +1324,11 @@ Bool_t PRunDataHandler::ReadAsciiFile()
success = false; success = false;
break; break;
} }
runData.fField = workStr.Atof(); runData.SetField(workStr.Atof());
} else if (workStr.BeginsWith("x-axis-title:", TString::kIgnoreCase)) { } else if (workStr.BeginsWith("x-axis-title:", TString::kIgnoreCase)) {
runData.fDataNonMusr.fLabels[0] = TString(workStr.Data()+workStr.First(":")+2); runData.fDataNonMusr.SetLabel(0, TString(workStr.Data()+workStr.First(":")+2));
} else if (workStr.BeginsWith("y-axis-title:", TString::kIgnoreCase)) { } else if (workStr.BeginsWith("y-axis-title:", TString::kIgnoreCase)) {
runData.fDataNonMusr.fLabels[1] = TString(workStr.Data()+workStr.First(":")+2); runData.fDataNonMusr.SetLabel(1, TString(workStr.Data()+workStr.First(":")+2));
} else if (workStr.BeginsWith("temp:", TString::kIgnoreCase)) { } else if (workStr.BeginsWith("temp:", TString::kIgnoreCase)) {
workStr = TString(workStr.Data()+workStr.First(":")+2); workStr = TString(workStr.Data()+workStr.First(":")+2);
if (!workStr.IsFloat()) { if (!workStr.IsFloat()) {
@ -1424,9 +1337,7 @@ Bool_t PRunDataHandler::ReadAsciiFile()
success = false; success = false;
break; break;
} }
runData.fTemp.resize(1); runData.SetTemperature(0, workStr.Atof(), 0.0);
runData.fTemp[0].first = workStr.Atof();
runData.fTemp[0].second = 0.0;
} else if (workStr.BeginsWith("energy:", TString::kIgnoreCase)) { } else if (workStr.BeginsWith("energy:", TString::kIgnoreCase)) {
workStr = TString(workStr.Data()+workStr.First(":")+2); workStr = TString(workStr.Data()+workStr.First(":")+2);
if (!workStr.IsFloat()) { if (!workStr.IsFloat()) {
@ -1435,9 +1346,8 @@ Bool_t PRunDataHandler::ReadAsciiFile()
success = false; success = false;
break; break;
} }
runData.fEnergy = workStr.Atof(); runData.SetEnergy(workStr.Atof());
runData.fTransport = -999.0; // just to initialize the variables to some "meaningful" value runData.SetTransport(PMUSR_UNDEFINED); // just to initialize the variables to some "meaningful" value
runData.fRingAnode.clear();
} else { // error } else { // error
cerr << endl << "PRunDataHandler::ReadAsciiFile **ERROR** line no " << lineNo << ", illegal header line."; cerr << endl << "PRunDataHandler::ReadAsciiFile **ERROR** line no " << lineNo << ", illegal header line.";
cerr << endl; cerr << endl;
@ -1516,10 +1426,10 @@ Bool_t PRunDataHandler::ReadAsciiFile()
f.close(); f.close();
// keep values // keep values
runData.fDataNonMusr.fData.push_back(xVec); runData.fDataNonMusr.AppendData(xVec);
runData.fDataNonMusr.fErrData.push_back(exVec); runData.fDataNonMusr.AppendErrData(exVec);
runData.fDataNonMusr.fData.push_back(yVec); runData.fDataNonMusr.AppendData(yVec);
runData.fDataNonMusr.fErrData.push_back(eyVec); runData.fDataNonMusr.AppendErrData(eyVec);
fData.push_back(runData); fData.push_back(runData);
@ -1528,8 +1438,6 @@ Bool_t PRunDataHandler::ReadAsciiFile()
exVec.clear(); exVec.clear();
yVec.clear(); yVec.clear();
eyVec.clear(); eyVec.clear();
runData.fDataNonMusr.fData.clear();
runData.fDataNonMusr.fErrData.clear();
return success; return success;
} }
@ -1660,7 +1568,7 @@ Bool_t PRunDataHandler::ReadDBFile()
PRawRunData runData; PRawRunData runData;
runData.fDataNonMusr.fFromAscii = false; runData.fDataNonMusr.SetFromAscii(false);
Int_t lineNo = 0; Int_t lineNo = 0;
Int_t idx; Int_t idx;
@ -1712,7 +1620,7 @@ Bool_t PRunDataHandler::ReadDBFile()
tokens = workStr.Tokenize(" ,\t"); tokens = workStr.Tokenize(" ,\t");
for (Int_t i=1; i<tokens->GetEntries(); i++) { for (Int_t i=1; i<tokens->GetEntries(); i++) {
ostr = dynamic_cast<TObjString*>(tokens->At(i)); ostr = dynamic_cast<TObjString*>(tokens->At(i));
runData.fDataNonMusr.fDataTags.push_back(ostr->GetString()); runData.fDataNonMusr.AppendDataTag(ostr->GetString());
} }
// clean up tokens // clean up tokens
@ -1725,7 +1633,7 @@ Bool_t PRunDataHandler::ReadDBFile()
switch (dbTag) { switch (dbTag) {
case 0: // TITLE case 0: // TITLE
runData.fRunTitle = workStr; runData.SetRunTitle(workStr);
break; break;
case 1: // ABSTRACT case 1: // ABSTRACT
// nothing to be done for now // nothing to be done for now
@ -1734,7 +1642,7 @@ Bool_t PRunDataHandler::ReadDBFile()
// nothing to be done for now // nothing to be done for now
break; break;
case 3: // LABEL case 3: // LABEL
runData.fDataNonMusr.fLabels.push_back(workStr); runData.fDataNonMusr.AppendLabel(workStr);
break; break;
case 4: // DATA case 4: // DATA
// filter out potential start data tag // filter out potential start data tag
@ -1763,9 +1671,9 @@ Bool_t PRunDataHandler::ReadDBFile()
// prepare data vector for use // prepare data vector for use
PDoubleVector dummy; PDoubleVector dummy;
for (UInt_t i=0; i<runData.fDataNonMusr.fDataTags.size(); i++) { for (UInt_t i=0; i<runData.fDataNonMusr.GetDataTags()->size(); i++) {
runData.fDataNonMusr.fData.push_back(dummy); runData.fDataNonMusr.AppendData(dummy);
runData.fDataNonMusr.fErrData.push_back(dummy); runData.fDataNonMusr.AppendErrData(dummy);
} }
firstData = false; firstData = false;
@ -1776,7 +1684,7 @@ Bool_t PRunDataHandler::ReadDBFile()
const Char_t *str = workStr.Data(); const Char_t *str = workStr.Data();
if (isdigit(str[0])) { // run line if (isdigit(str[0])) { // run line
TString run("run"); TString run("run");
idx = GetDataTagIndex(run, runData.fDataNonMusr.fDataTags); idx = GetDataTagIndex(run, runData.fDataNonMusr.GetDataTags());
if (idx == -1) { if (idx == -1) {
cerr << endl << "PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo << ":"; cerr << endl << "PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo << ":";
cerr << endl << ">> " << workStr.Data(); cerr << endl << ">> " << workStr.Data();
@ -1796,8 +1704,8 @@ Bool_t PRunDataHandler::ReadDBFile()
return false; return false;
} }
val = tstr.Atof(); val = tstr.Atof();
runData.fDataNonMusr.fData[idx].push_back(val); runData.fDataNonMusr.AppendSubData(idx, val);
runData.fDataNonMusr.fErrData[idx].push_back(1.0); runData.fDataNonMusr.AppendSubErrData(idx, 1.0);
} else { // tag = data line } else { // tag = data line
// remove all possible spaces // remove all possible spaces
workStr.ReplaceAll(" ", ""); workStr.ReplaceAll(" ", "");
@ -1812,7 +1720,7 @@ Bool_t PRunDataHandler::ReadDBFile()
} }
ostr = dynamic_cast<TObjString*>(tokens->At(0)); ostr = dynamic_cast<TObjString*>(tokens->At(0));
tstr = ostr->GetString(); tstr = ostr->GetString();
idx = GetDataTagIndex(tstr, runData.fDataNonMusr.fDataTags); idx = GetDataTagIndex(tstr, runData.fDataNonMusr.GetDataTags());
if (idx == -1) { if (idx == -1) {
cerr << endl << "PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo << ":"; cerr << endl << "PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo << ":";
cerr << endl << ">> " << workStr.Data(); cerr << endl << ">> " << workStr.Data();
@ -1834,8 +1742,8 @@ Bool_t PRunDataHandler::ReadDBFile()
return false; return false;
} }
val = tstr.Atof(); val = tstr.Atof();
runData.fDataNonMusr.fData[idx].push_back(val); runData.fDataNonMusr.AppendSubData(idx, val);
runData.fDataNonMusr.fErrData[idx].push_back(1.0); runData.fDataNonMusr.AppendSubErrData(idx, 1.0);
break; break;
case 4: // tag = val,err,, case 4: // tag = val,err,,
case 5: // tag = val,err1,err2, case 5: // tag = val,err1,err2,
@ -1851,7 +1759,7 @@ Bool_t PRunDataHandler::ReadDBFile()
return false; return false;
} }
val = tstr.Atof(); val = tstr.Atof();
runData.fDataNonMusr.fData[idx].push_back(val); runData.fDataNonMusr.AppendSubData(idx, val);
// handle err1 (err2 will be ignored for the time being) // handle err1 (err2 will be ignored for the time being)
ostr = dynamic_cast<TObjString*>(tokens->At(2)); ostr = dynamic_cast<TObjString*>(tokens->At(2));
tstr = ostr->GetString(); tstr = ostr->GetString();
@ -1864,7 +1772,7 @@ Bool_t PRunDataHandler::ReadDBFile()
return false; return false;
} }
val = tstr.Atof(); val = tstr.Atof();
runData.fDataNonMusr.fErrData[idx].push_back(val); runData.fDataNonMusr.AppendSubErrData(idx, val);
break; break;
default: default:
cerr << endl << "PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo << ":"; cerr << endl << "PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo << ":";
@ -1879,11 +1787,11 @@ Bool_t PRunDataHandler::ReadDBFile()
} else { // handle row formated data } else { // handle row formated data
// split string in tokens // split string in tokens
tokens = workStr.Tokenize(","); // line has structure: val1, err11, err12, ..., valn, errn1, errn2, runNo, , , , runTitle tokens = workStr.Tokenize(","); // line has structure: val1, err11, err12, ..., valn, errn1, errn2, runNo, , , , runTitle
if (tokens->GetEntries() != (Int_t)(3*runData.fDataNonMusr.fDataTags.size()+1)) { if (tokens->GetEntries() != (Int_t)(3*runData.fDataNonMusr.GetDataTags()->size()+1)) {
cerr << endl << "PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo << ":"; cerr << endl << "PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo << ":";
cerr << endl << ">> " << workStr.Data(); cerr << endl << ">> " << workStr.Data();
cerr << endl << ">> Expected db-data line with structure: val1, err11, err12, ..., valn, errn1, errn2, runNo, , , , runTitle"; cerr << endl << ">> Expected db-data line with structure: val1, err11, err12, ..., valn, errn1, errn2, runNo, , , , runTitle";
cerr << endl << ">> found = " << tokens->GetEntries() << " tokens, however expected " << 3*runData.fDataNonMusr.fDataTags.size()+1; cerr << endl << ">> found = " << tokens->GetEntries() << " tokens, however expected " << 3*runData.fDataNonMusr.GetDataTags()->size()+1;
cerr << endl << ">> Perhaps there are commas without space inbetween, like 12.3,, 3.2,..."; cerr << endl << ">> Perhaps there are commas without space inbetween, like 12.3,, 3.2,...";
delete tokens; delete tokens;
return false; return false;
@ -1902,15 +1810,15 @@ Bool_t PRunDataHandler::ReadDBFile()
delete tokens; delete tokens;
return false; return false;
} }
runData.fDataNonMusr.fData[j].push_back(tstr.Atof()); runData.fDataNonMusr.AppendSubData(j, tstr.Atof());
// handle 1st error if present (2nd will be ignored for now) // handle 1st error if present (2nd will be ignored for now)
ostr = dynamic_cast<TObjString*>(tokens->At(i+1)); ostr = dynamic_cast<TObjString*>(tokens->At(i+1));
tstr = ostr->GetString(); tstr = ostr->GetString();
if (tstr.IsWhitespace()) { if (tstr.IsWhitespace()) {
runData.fDataNonMusr.fErrData[j].push_back(1.0); runData.fDataNonMusr.AppendSubErrData(j, 1.0);
} else if (tstr.IsFloat()) { } else if (tstr.IsFloat()) {
runData.fDataNonMusr.fErrData[j].push_back(tstr.Atof()); runData.fDataNonMusr.AppendSubErrData(j, tstr.Atof());
} else { } else {
cerr << endl << "PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo << ":"; cerr << endl << "PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo << ":";
cerr << endl << ">> " << workStr.Data(); cerr << endl << ">> " << workStr.Data();
@ -1931,10 +1839,10 @@ Bool_t PRunDataHandler::ReadDBFile()
f.close(); f.close();
// check that the number of labels == the number of data tags // check that the number of labels == the number of data tags
if (runData.fDataNonMusr.fLabels.size() != runData.fDataNonMusr.fDataTags.size()) { if (runData.fDataNonMusr.GetLabels()->size() != runData.fDataNonMusr.GetDataTags()->size()) {
cerr << endl << "PRunDataHandler::ReadDBFile **ERROR**"; cerr << endl << "PRunDataHandler::ReadDBFile **ERROR**";
cerr << endl << ">> number of LABELS found = " << runData.fDataNonMusr.fLabels.size(); cerr << endl << ">> number of LABELS found = " << runData.fDataNonMusr.GetLabels()->size();
cerr << endl << ">> number of Data tags found = " << runData.fDataNonMusr.fDataTags.size(); cerr << endl << ">> number of Data tags found = " << runData.fDataNonMusr.GetDataTags()->size();
cerr << endl << ">> They have to be equal!!"; cerr << endl << ">> They have to be equal!!";
if (tokens) { if (tokens) {
delete tokens; delete tokens;
@ -1944,19 +1852,19 @@ Bool_t PRunDataHandler::ReadDBFile()
} }
// check if all vectors have the same size // check if all vectors have the same size
for (UInt_t i=1; i<runData.fDataNonMusr.fData.size(); i++) { for (UInt_t i=1; i<runData.fDataNonMusr.GetData()->size(); i++) {
if (runData.fDataNonMusr.fData[i].size() != runData.fDataNonMusr.fData[i-1].size()) { if (runData.fDataNonMusr.GetData()->at(i).size() != runData.fDataNonMusr.GetData()->at(i-1).size()) {
cerr << endl << "PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo; cerr << endl << "PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo;
cerr << endl << ">> label: " << runData.fDataNonMusr.fDataTags[i-1].Data() << ", number data elements = " << runData.fDataNonMusr.fData[i-1].size(); cerr << endl << ">> label: " << runData.fDataNonMusr.GetDataTags()->at(i-1).Data() << ", number data elements = " << runData.fDataNonMusr.GetData()->at(i-1).size();
cerr << endl << ">> label: " << runData.fDataNonMusr.fDataTags[i].Data() << ", number data elements = " << runData.fDataNonMusr.fData[i].size(); cerr << endl << ">> label: " << runData.fDataNonMusr.GetDataTags()->at(i).Data() << ", number data elements = " << runData.fDataNonMusr.GetData()->at(i).size();
cerr << endl << ">> They have to be equal!!"; cerr << endl << ">> They have to be equal!!";
success = false; success = false;
break; break;
} }
if (runData.fDataNonMusr.fErrData[i].size() != runData.fDataNonMusr.fErrData[i-1].size()) { if (runData.fDataNonMusr.GetErrData()->at(i).size() != runData.fDataNonMusr.GetErrData()->at(i-1).size()) {
cerr << endl << "PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo; cerr << endl << "PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo;
cerr << endl << ">> label: " << runData.fDataNonMusr.fDataTags[i-1].Data() << ", number data elements = " << runData.fDataNonMusr.fData[i-1].size(); cerr << endl << ">> label: " << runData.fDataNonMusr.GetDataTags()->at(i-1).Data() << ", number data elements = " << runData.fDataNonMusr.GetData()->at(i-1).size();
cerr << endl << ">> label: " << runData.fDataNonMusr.fDataTags[i].Data() << ", number error data elements = " << runData.fDataNonMusr.fErrData[i].size(); cerr << endl << ">> label: " << runData.fDataNonMusr.GetDataTags()->at(i).Data() << ", number error data elements = " << runData.fDataNonMusr.GetErrData()->at(i).size();
cerr << endl << ">> They have to be equal!!"; cerr << endl << ">> They have to be equal!!";
success = false; success = false;
break; break;
@ -1970,7 +1878,7 @@ Bool_t PRunDataHandler::ReadDBFile()
} }
// keep run name // keep run name
runData.fRunName = fRunName; runData.SetRunName(fRunName);
fData.push_back(runData); fData.push_back(runData);
@ -2181,13 +2089,13 @@ Int_t PRunDataHandler::ToInt(TString &str, Bool_t &ok)
* *
* <b>return:</b> if found returns the data tag index (from the dataTags vector), otherwise -1 * <b>return:</b> if found returns the data tag index (from the dataTags vector), otherwise -1
*/ */
Int_t PRunDataHandler::GetDataTagIndex(TString &str, PStringVector &dataTags) Int_t PRunDataHandler::GetDataTagIndex(TString &str, const PStringVector* dataTags)
{ {
Int_t result = -1; Int_t result = -1;
// check all the other possible data tags // check all the other possible data tags
for (UInt_t i=0; i<dataTags.size(); i++) { for (UInt_t i=0; i<dataTags->size(); i++) {
if (!dataTags[i].CompareTo(str, TString::kIgnoreCase)) { if (!dataTags->at(i).CompareTo(str, TString::kIgnoreCase)) {
result = i; result = i;
break; break;
} }

View File

@ -441,9 +441,9 @@ PRunData* PRunListCollection::GetNonMusr(unsigned int index, EDataSwitch tag)
* *
* \param runName * \param runName
*/ */
vector< pair<double, double> > PRunListCollection::GetTemp(const TString &runName) const PDoublePairVector PRunListCollection::GetTemp(const TString &runName) const
{ {
return fData->GetRunData(runName)->fTemp; return fData->GetRunData(runName)->GetTemperature();
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
@ -456,7 +456,7 @@ vector< pair<double, double> > PRunListCollection::GetTemp(const TString &runNam
*/ */
double PRunListCollection::GetField(const TString &runName) const double PRunListCollection::GetField(const TString &runName) const
{ {
return fData->GetRunData(runName)->fField; return fData->GetRunData(runName)->GetField();
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
@ -469,7 +469,7 @@ double PRunListCollection::GetField(const TString &runName) const
*/ */
double PRunListCollection::GetEnergy(const TString &runName) const double PRunListCollection::GetEnergy(const TString &runName) const
{ {
return fData->GetRunData(runName)->fEnergy; return fData->GetRunData(runName)->GetEnergy();
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
@ -482,7 +482,7 @@ double PRunListCollection::GetEnergy(const TString &runName) const
*/ */
const char* PRunListCollection::GetSetup(const TString &runName) const const char* PRunListCollection::GetSetup(const TString &runName) const
{ {
return fData->GetRunData(runName)->fSetup.Data(); return fData->GetRunData(runName)->GetSetup()->Data();
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
@ -504,13 +504,13 @@ const char* PRunListCollection::GetXAxisTitle(const TString &runName, const unsi
const char *result = 0; const char *result = 0;
if (runData->fDataNonMusr.fFromAscii) { if (runData->fDataNonMusr.FromAscii()) {
result = runData->fDataNonMusr.fLabels[0].Data(); result = runData->fDataNonMusr.GetLabels()->at(0).Data();
} else { } else {
for (unsigned int i=0; i<fRunNonMusrList.size(); i++) { for (unsigned int i=0; i<fRunNonMusrList.size(); i++) {
if (fRunNonMusrList[i]->GetRunNo() == idx) { if (fRunNonMusrList[i]->GetRunNo() == idx) {
int index = fRunNonMusrList[i]->GetXIndex(); int index = fRunNonMusrList[i]->GetXIndex();
result = runData->fDataNonMusr.fLabels[index].Data(); result = runData->fDataNonMusr.GetLabels()->at(index).Data();
break; break;
} }
} }
@ -537,13 +537,13 @@ const char* PRunListCollection::GetYAxisTitle(const TString &runName, const unsi
const char *result = 0; const char *result = 0;
if (runData->fDataNonMusr.fFromAscii) { if (runData->fDataNonMusr.FromAscii()) {
result = runData->fDataNonMusr.fLabels[1].Data(); result = runData->fDataNonMusr.GetLabels()->at(1).Data();
} else { } else {
for (unsigned int i=0; i<fRunNonMusrList.size(); i++) { for (unsigned int i=0; i<fRunNonMusrList.size(); i++) {
if (fRunNonMusrList[i]->GetRunNo() == idx) { if (fRunNonMusrList[i]->GetRunNo() == idx) {
int index = fRunNonMusrList[i]->GetYIndex(); int index = fRunNonMusrList[i]->GetYIndex();
result = runData->fDataNonMusr.fLabels[index].Data(); result = runData->fDataNonMusr.GetLabels()->at(index).Data();
break; break;
} }
} }

View File

@ -11,7 +11,7 @@
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007 by Andreas Suter * * Copyright (C) 2007 by Andreas Suter *
* andreas.suter@psi.c * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by * * it under the terms of the GNU General Public License as published by *
@ -105,11 +105,11 @@ double PRunNonMusr::CalcChiSquare(const std::vector<double>& par)
// calculate chi square // calculate chi square
double x; double x;
for (unsigned int i=0; i<fData.fValue.size(); i++) { for (unsigned int i=0; i<fData.GetValue()->size(); i++) {
x = fData.fX[i]; x = fData.GetX()->at(i);
if ((x>=fFitStartTime) && (x<=fFitStopTime)) { if ((x>=fFitStartTime) && (x<=fFitStopTime)) {
diff = fData.fValue[i] - fTheory->Func(x, par, fFuncValues); diff = fData.GetValue()->at(i) - fTheory->Func(x, par, fFuncValues);
chisq += diff*diff / (fData.fError[i]*fData.fError[i]); chisq += diff*diff / (fData.GetError()->at(i)*fData.GetError()->at(i));
} }
} }
@ -195,24 +195,24 @@ bool PRunNonMusr::PrepareFitData()
double value = 0.0; double value = 0.0;
double err = 0.0; double err = 0.0;
// cout << endl << ">> fRawRunData->fDataNonMusr.fData[" << xIndex << "].size()=" << fRawRunData->fDataNonMusr.fData[xIndex].size(); // cout << endl << ">> fRawRunData->fDataNonMusr.fData[" << xIndex << "].size()=" << fRawRunData->fDataNonMusr.fData[xIndex].size();
for (unsigned int i=0; i<fRawRunData->fDataNonMusr.fData[xIndex].size(); i++) { for (unsigned int i=0; i<fRawRunData->fDataNonMusr.GetData()->at(xIndex).size(); i++) {
// cout << endl << ">> i=" << i << ", packing=" << fRunInfo->fPacking; // cout << endl << ">> i=" << i << ", packing=" << fRunInfo->fPacking;
if (fRunInfo->fPacking == 1) { if (fRunInfo->fPacking == 1) {
fData.fX.push_back(fRawRunData->fDataNonMusr.fData[xIndex][i]); fData.AppendXValue(fRawRunData->fDataNonMusr.GetData()->at(xIndex).at(i));
fData.fValue.push_back(fRawRunData->fDataNonMusr.fData[yIndex][i]); fData.AppendValue(fRawRunData->fDataNonMusr.GetData()->at(yIndex).at(i));
fData.fError.push_back(fRawRunData->fDataNonMusr.fErrData[yIndex][i]); fData.AppendErrorValue(fRawRunData->fDataNonMusr.GetErrData()->at(yIndex).at(i));
} else { // packed data, i.e. fRunInfo->fPacking > 1 } else { // packed data, i.e. fRunInfo->fPacking > 1
if ((i % fRunInfo->fPacking == 0) && (i != 0)) { // fill data if ((i % fRunInfo->fPacking == 0) && (i != 0)) { // fill data
// cout << endl << "-> i=" << i; // cout << endl << "-> i=" << i;
fData.fX.push_back(fRawRunData->fDataNonMusr.fData[xIndex][i]-(fRawRunData->fDataNonMusr.fData[xIndex][i]-fRawRunData->fDataNonMusr.fData[xIndex][i-fRunInfo->fPacking])/2.0); fData.AppendXValue(fRawRunData->fDataNonMusr.GetData()->at(xIndex).at(i)-(fRawRunData->fDataNonMusr.GetData()->at(xIndex).at(i)-fRawRunData->fDataNonMusr.GetData()->at(xIndex).at(i-fRunInfo->fPacking))/2.0);
fData.fValue.push_back(value); fData.AppendValue(value);
fData.fError.push_back(TMath::Sqrt(err)); fData.AppendErrorValue(TMath::Sqrt(err));
value = 0.0; value = 0.0;
err = 0.0; err = 0.0;
} }
// sum raw data values // sum raw data values
value += fRawRunData->fDataNonMusr.fData[yIndex][i]; value += fRawRunData->fDataNonMusr.GetData()->at(yIndex).at(i);
err += fRawRunData->fDataNonMusr.fErrData[yIndex][i]*fRawRunData->fDataNonMusr.fErrData[yIndex][i]; err += fRawRunData->fDataNonMusr.GetErrData()->at(yIndex).at(i)*fRawRunData->fDataNonMusr.GetErrData()->at(yIndex).at(i);
} }
} }
// cout << endl << ">> fData.fValue.size()=" << fData.fValue.size(); // cout << endl << ">> fData.fValue.size()=" << fData.fValue.size();
@ -220,8 +220,8 @@ bool PRunNonMusr::PrepareFitData()
// count the number of bins to be fitted // count the number of bins to be fitted
fNoOfFitBins=0; fNoOfFitBins=0;
double x; double x;
for (unsigned int i=0; i<fData.fValue.size(); i++) { for (unsigned int i=0; i<fData.GetValue()->size(); i++) {
x = fData.fX[i]; x = fData.GetX()->at(i);
if ((x >= fFitStartTime) && (x <= fFitStopTime)) if ((x >= fFitStartTime) && (x <= fFitStopTime))
fNoOfFitBins++; fNoOfFitBins++;
} }
@ -253,30 +253,30 @@ bool PRunNonMusr::PrepareViewData()
double value = 0.0; double value = 0.0;
double err = 0.0; double err = 0.0;
// cout << endl << ">> fRawRunData->fDataNonMusr.fData[" << xIndex << "].size()=" << fRawRunData->fDataNonMusr.fData[xIndex].size(); // cout << endl << ">> fRawRunData->fDataNonMusr.fData[" << xIndex << "].size()=" << fRawRunData->fDataNonMusr.fData[xIndex].size();
for (unsigned int i=0; i<fRawRunData->fDataNonMusr.fData[xIndex].size(); i++) { for (unsigned int i=0; i<fRawRunData->fDataNonMusr.GetData()->at(xIndex).size(); i++) {
// cout << endl << ">> i=" << i << ", packing=" << fRunInfo->fPacking; // cout << endl << ">> i=" << i << ", packing=" << fRunInfo->fPacking;
if (fRunInfo->fPacking == 1) { if (fRunInfo->fPacking == 1) {
fData.fX.push_back(fRawRunData->fDataNonMusr.fData[xIndex][i]); fData.AppendXValue(fRawRunData->fDataNonMusr.GetData()->at(xIndex).at(i));
fData.fValue.push_back(fRawRunData->fDataNonMusr.fData[yIndex][i]); fData.AppendValue(fRawRunData->fDataNonMusr.GetData()->at(yIndex).at(i));
fData.fError.push_back(fRawRunData->fDataNonMusr.fErrData[yIndex][i]); fData.AppendErrorValue(fRawRunData->fDataNonMusr.GetErrData()->at(yIndex).at(i));
} else { // packed data, i.e. fRunInfo->fPacking > 1 } else { // packed data, i.e. fRunInfo->fPacking > 1
if ((i % fRunInfo->fPacking == 0) && (i != 0)) { // fill data if ((i % fRunInfo->fPacking == 0) && (i != 0)) { // fill data
// cout << endl << "-> i=" << i; // cout << endl << "-> i=" << i;
fData.fX.push_back(fRawRunData->fDataNonMusr.fData[xIndex][i]-(fRawRunData->fDataNonMusr.fData[xIndex][i]-fRawRunData->fDataNonMusr.fData[xIndex][i-fRunInfo->fPacking])/2.0); fData.AppendXValue(fRawRunData->fDataNonMusr.GetData()->at(xIndex).at(i)-(fRawRunData->fDataNonMusr.GetData()->at(xIndex).at(i)-fRawRunData->fDataNonMusr.GetData()->at(xIndex).at(i-fRunInfo->fPacking))/2.0);
fData.fValue.push_back(value); fData.AppendValue(value);
fData.fError.push_back(TMath::Sqrt(err)); fData.AppendErrorValue(TMath::Sqrt(err));
value = 0.0; value = 0.0;
err = 0.0; err = 0.0;
} }
// sum raw data values // sum raw data values
value += fRawRunData->fDataNonMusr.fData[yIndex][i]; value += fRawRunData->fDataNonMusr.GetData()->at(yIndex).at(i);
err += fRawRunData->fDataNonMusr.fErrData[yIndex][i]*fRawRunData->fDataNonMusr.fErrData[yIndex][i]; err += fRawRunData->fDataNonMusr.GetErrData()->at(yIndex).at(i)*fRawRunData->fDataNonMusr.GetErrData()->at(yIndex).at(i);
} }
} }
// cout << endl << ">> fData.fValue.size()=" << fData.fValue.size(); // cout << endl << ">> fData.fValue.size()=" << fData.fValue.size();
// count the number of bins to be fitted // count the number of bins to be fitted
fNoOfFitBins = fData.fValue.size(); fNoOfFitBins = fData.GetValue()->size();
// cout << endl << ">> fNoOfFitBins=" << fNoOfFitBins; // cout << endl << ">> fNoOfFitBins=" << fNoOfFitBins;
// fill theory histo // fill theory histo
@ -341,17 +341,17 @@ bool PRunNonMusr::PrepareViewData()
// typically take 1000 points to calculate the theory, except if there are more data points, than take that number // typically take 1000 points to calculate the theory, except if there are more data points, than take that number
double xStep; double xStep;
if (fData.fX.size() > 1000.0) if (fData.GetX()->size() > 1000.0)
xStep = (xMax-xMin)/fData.fX.size(); xStep = (xMax-xMin)/fData.GetX()->size();
else else
xStep = (xMax-xMin)/1000.0; xStep = (xMax-xMin)/1000.0;
double xx = xAbsMin; double xx = xAbsMin;
do { do {
// fill x-vector // fill x-vector
fData.fXTheory.push_back(xx); fData.AppendXTheoryValue(xx);
// fill y-vector // fill y-vector
fData.fTheory.push_back(fTheory->Func(xx, par, fFuncValues)); fData.AppendTheoryValue(fTheory->Func(xx, par, fFuncValues));
// calculate next xx // calculate next xx
xx += xStep; xx += xStep;
} while (xx < xAbsMax); } while (xx < xAbsMax);
@ -375,7 +375,7 @@ unsigned int PRunNonMusr::GetXIndex()
bool found = false; bool found = false;
//cout << endl << ">> PRunNonMusr::GetXIndex: fRawRunData->fDataNonMusr.fFromAscii = " << fRawRunData->fDataNonMusr.fFromAscii; //cout << endl << ">> PRunNonMusr::GetXIndex: fRawRunData->fDataNonMusr.fFromAscii = " << fRawRunData->fDataNonMusr.fFromAscii;
if (fRawRunData->fDataNonMusr.fFromAscii) { // ascii-file format if (fRawRunData->fDataNonMusr.FromAscii()) { // ascii-file format
//cout << endl << ">> PRunNonMusr::GetXIndex: ascii-file format"; //cout << endl << ">> PRunNonMusr::GetXIndex: ascii-file format";
index = 0; index = 0;
found = true; found = true;
@ -387,8 +387,8 @@ unsigned int PRunNonMusr::GetXIndex()
found = true; found = true;
} else { // xy-data data tags which needs to be converted to an index } else { // xy-data data tags which needs to be converted to an index
//cout << endl << ">> fDataTags.size()=" << fRawRunData->fDataNonMusr.fDataTags.size(); //cout << endl << ">> fDataTags.size()=" << fRawRunData->fDataNonMusr.fDataTags.size();
for (unsigned int i=0; i<fRawRunData->fDataNonMusr.fDataTags.size(); i++) { for (unsigned int i=0; i<fRawRunData->fDataNonMusr.GetDataTags()->size(); i++) {
if (fRawRunData->fDataNonMusr.fDataTags[i].CompareTo(fRunInfo->fXYDataLabel[0]) == 0) { if (fRawRunData->fDataNonMusr.GetDataTags()->at(i).CompareTo(fRunInfo->fXYDataLabel[0]) == 0) {
//cout << endl << ">> i=" << i << ", fRawRunData->fDataNonMusr.fDataTags[i]=" << fRawRunData->fDataNonMusr.fDataTags[i].Data(); //cout << endl << ">> i=" << i << ", fRawRunData->fDataNonMusr.fDataTags[i]=" << fRawRunData->fDataNonMusr.fDataTags[i].Data();
//cout << endl << ">> fRunInfo->fXYDataLabel[0]=" << fRunInfo->fXYDataLabel[0].Data(); //cout << endl << ">> fRunInfo->fXYDataLabel[0]=" << fRunInfo->fXYDataLabel[0].Data();
index = i; index = i;
@ -421,7 +421,7 @@ unsigned int PRunNonMusr::GetYIndex()
bool found = false; bool found = false;
// cout << endl << ">> PRunNonMusr::GetYIndex:"; // cout << endl << ">> PRunNonMusr::GetYIndex:";
if (fRawRunData->fDataNonMusr.fFromAscii) { // ascii-file format if (fRawRunData->fDataNonMusr.FromAscii()) { // ascii-file format
index = 1; index = 1;
found = true; found = true;
} else { // db-file format } else { // db-file format
@ -429,8 +429,8 @@ unsigned int PRunNonMusr::GetYIndex()
index = fRunInfo->fXYDataIndex[1]-1; // since xy-data start with 1 ... index = fRunInfo->fXYDataIndex[1]-1; // since xy-data start with 1 ...
found = true; found = true;
} else { // xy-data data tags which needs to be converted to an index } else { // xy-data data tags which needs to be converted to an index
for (unsigned int i=0; i<fRawRunData->fDataNonMusr.fDataTags.size(); i++) { for (unsigned int i=0; i<fRawRunData->fDataNonMusr.GetDataTags()->size(); i++) {
if (fRawRunData->fDataNonMusr.fDataTags[i].CompareTo(fRunInfo->fXYDataLabel[1]) == 0) { if (fRawRunData->fDataNonMusr.GetDataTags()->at(i).CompareTo(fRunInfo->fXYDataLabel[1]) == 0) {
// cout << endl << ">> i=" << i << ", fRawRunData->fDataNonMusr.fDataTags[i]=" << fRawRunData->fDataNonMusr.fDataTags[i].Data(); // cout << endl << ">> i=" << i << ", fRawRunData->fDataNonMusr.fDataTags[i]=" << fRawRunData->fDataNonMusr.fDataTags[i].Data();
// cout << endl << ">> fRunInfo->fXYDataLabel[1]=" << fRunInfo->fXYDataLabel[1].Data(); // cout << endl << ">> fRunInfo->fXYDataLabel[1]=" << fRunInfo->fXYDataLabel[1].Data();
index = i; index = i;

View File

@ -11,7 +11,7 @@
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007 by Andreas Suter * * Copyright (C) 2007 by Andreas Suter *
* andreas.suter@psi.c * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by * * it under the terms of the GNU General Public License as published by *
@ -137,12 +137,12 @@ double PRunSingleHisto::CalcChiSquare(const std::vector<double>& par)
// calculate chi square // calculate chi square
double time; double time;
for (unsigned int i=0; i<fData.fValue.size(); i++) { for (unsigned int i=0; i<fData.GetValue()->size(); i++) {
time = fData.fDataTimeStart + (double)i*fData.fDataTimeStep; time = fData.GetDataTimeStart() + (double)i*fData.GetDataTimeStep();
if ((time>=fFitStartTime) && (time<=fFitStopTime)) { if ((time>=fFitStartTime) && (time<=fFitStopTime)) {
diff = fData.fValue[i] - diff = fData.GetValue()->at(i) -
(N0*TMath::Exp(-time/tau)*(1.0+fTheory->Func(time, par, fFuncValues))+bkg); (N0*TMath::Exp(-time/tau)*(1.0+fTheory->Func(time, par, fFuncValues))+bkg);
chisq += diff*diff / (fData.fError[i]*fData.fError[i]); chisq += diff*diff / (fData.GetError()->at(i)*fData.GetError()->at(i));
} }
} }
@ -150,7 +150,7 @@ double PRunSingleHisto::CalcChiSquare(const std::vector<double>& par)
static int firstTime = 0; static int firstTime = 0;
if (firstTime < 4) { if (firstTime < 4) {
firstTime++; firstTime++;
cout << endl << "size=" << fData.fValue.size() << ", fDataTimeStart=" << fData.fDataTimeStart << ", fDataTimeStep=" << fData.fDataTimeStep << ", fFitStartTime=" << fFitStartTime << ", fFitStopTime=" << fFitStopTime; cout << endl << "size=" << fData.GetValue()->size() << ", fDataTimeStart=" << fData.GetDataTimeStart() << ", fDataTimeStep=" << fData.GetDataTimeStep() << ", fFitStartTime=" << fFitStartTime << ", fFitStopTime=" << fFitStopTime;
cout << endl << "chisq=" << chisq*fRunInfo->fPacking; cout << endl << "chisq=" << chisq*fRunInfo->fPacking;
cout << endl << "----"; cout << endl << "----";
} }
@ -212,14 +212,14 @@ double PRunSingleHisto::CalcMaxLikelihood(const std::vector<double>& par)
double theo; double theo;
double data; double data;
double time; double time;
for (unsigned int i=0; i<fData.fValue.size(); i++) { for (unsigned int i=0; i<fData.GetValue()->size(); i++) {
time = fData.fDataTimeStart + (double)i*fData.fDataTimeStep; time = fData.GetDataTimeStart() + (double)i*fData.GetDataTimeStep();
if ((time>=fFitStartTime) && (time<=fFitStopTime)) { if ((time>=fFitStartTime) && (time<=fFitStopTime)) {
// calculate theory for the given parameter set // calculate theory for the given parameter set
theo = N0*TMath::Exp(-time/tau)*(1+fTheory->Func(time, par, fFuncValues))+bkg; theo = N0*TMath::Exp(-time/tau)*(1+fTheory->Func(time, par, fFuncValues))+bkg;
// check if data value is not too small // check if data value is not too small
if (fData.fValue[i] > 1.0e-9) if (fData.GetValue()->at(i) > 1.0e-9)
data = fData.fValue[i]; data = fData.GetValue()->at(i);
else else
data = 1.0e-9; data = 1.0e-9;
// add maximum log likelihood contribution of bin i // add maximum log likelihood contribution of bin i
@ -282,13 +282,13 @@ void PRunSingleHisto::CalcTheory()
} }
// calculate theory // calculate theory
unsigned int size = fData.fValue.size(); unsigned int size = fData.GetValue()->size();
double start = fData.fDataTimeStart; double start = fData.GetDataTimeStart();
double resolution = fData.fDataTimeStep; double resolution = fData.GetDataTimeStep();
double time; double time;
for (unsigned int i=0; i<size; i++) { for (unsigned int i=0; i<size; i++) {
time = start + (double)i*resolution; time = start + (double)i*resolution;
fData.fTheory.push_back(N0*TMath::Exp(-time/tau)*(1+fTheory->Func(time, par, fFuncValues))+bkg); fData.AppendTheoryValue(N0*TMath::Exp(-time/tau)*(1+fTheory->Func(time, par, fFuncValues))+bkg);
} }
// clean up // clean up
@ -318,9 +318,9 @@ bool PRunSingleHisto::PrepareData()
unsigned int histoNo; unsigned int histoNo;
histoNo = fRunInfo->fForwardHistoNo-1; histoNo = fRunInfo->fForwardHistoNo-1;
if ((runData->fDataBin.size() < histoNo) || (histoNo < 0)) { if ((runData->GetNoOfHistos() < histoNo) || (histoNo < 0)) {
cout << endl << "PRunSingleHisto::PrepareData(): **PANIC ERROR**:"; cout << endl << "PRunSingleHisto::PrepareData(): **PANIC ERROR**:";
cout << endl << " histoNo found = " << histoNo << ", but there are only " << runData->fDataBin.size() << " runs!?!?"; cout << endl << " histoNo found = " << histoNo << ", but there are only " << runData->GetNoOfHistos() << " runs!?!?";
cout << endl << " Will quite :-("; cout << endl << " Will quite :-(";
cout << endl; cout << endl;
return false; return false;
@ -329,10 +329,10 @@ bool PRunSingleHisto::PrepareData()
// check if the t0's are given in the msr-file // check if the t0's are given in the msr-file
if (fRunInfo->fT0.size() == 0) { // t0's are NOT in the msr-file if (fRunInfo->fT0.size() == 0) { // t0's are NOT in the msr-file
// check if the t0's are in the data file // check if the t0's are in the data file
if (runData->fT0s.size() != 0) { // t0's in the run data if (runData->GetT0s().size() != 0) { // t0's in the run data
// keep the proper t0's. For single histo runs, forward is holding the histo no // keep the proper t0's. For single histo runs, forward is holding the histo no
// fForwardHistoNo starts with 1 not with 0 ;-) // fForwardHistoNo starts with 1 not with 0 ;-)
fT0s.push_back(runData->fT0s[fRunInfo->fForwardHistoNo-1]); fT0s.push_back(runData->GetT0(fRunInfo->fForwardHistoNo-1));
} else { // t0's are neither in the run data nor in the msr-file -> not acceptable! } else { // t0's are neither in the run data nor in the msr-file -> not acceptable!
cout << endl << "PRunSingleHisto::PrepareData(): **ERROR** NO t0's found, neither in the run data nor in the msr-file!"; cout << endl << "PRunSingleHisto::PrepareData(): **ERROR** NO t0's found, neither in the run data nor in the msr-file!";
cout << endl << " run: " << fRunInfo->fRunName[0].Data(); cout << endl << " run: " << fRunInfo->fRunName[0].Data();
@ -340,12 +340,12 @@ bool PRunSingleHisto::PrepareData()
} }
} else { // t0's in the msr-file } else { // t0's in the msr-file
// check if t0's are given in the data file // check if t0's are given in the data file
if (runData->fT0s.size() != 0) { if (runData->GetT0s().size() != 0) {
// compare t0's of the msr-file with the one in the data file // compare t0's of the msr-file with the one in the data file
if (fabs(fRunInfo->fT0[0]-runData->fT0s[fRunInfo->fForwardHistoNo-1])>5.0) { // given in bins!! if (fabs(fRunInfo->fT0[0]-runData->GetT0(fRunInfo->fForwardHistoNo-1))>5.0) { // given in bins!!
cout << endl << "PRunSingleHisto::PrepareData(): **WARNING**:"; cout << endl << "PRunSingleHisto::PrepareData(): **WARNING**:";
cout << endl << " t0 from the msr-file is " << fRunInfo->fT0[0]; cout << endl << " t0 from the msr-file is " << fRunInfo->fT0[0];
cout << endl << " t0 from the data file is " << runData->fT0s[fRunInfo->fForwardHistoNo-1]; cout << endl << " t0 from the data file is " << runData->GetT0(fRunInfo->fForwardHistoNo-1);
cout << endl << " This is quite a deviation! Is this done intentionally??"; cout << endl << " This is quite a deviation! Is this done intentionally??";
cout << endl; cout << endl;
} }
@ -355,7 +355,7 @@ bool PRunSingleHisto::PrepareData()
// check if t0 is within proper bounds // check if t0 is within proper bounds
int t0 = fT0s[0]; int t0 = fT0s[0];
if ((t0 < 0) || (t0 > (int)runData->fDataBin[histoNo].size())) { if ((t0 < 0) || (t0 > (int)runData->GetDataBin(histoNo)->size())) {
cout << endl << "PRunSingleHisto::PrepareData(): **ERROR** t0 data bin doesn't make any sense!"; cout << endl << "PRunSingleHisto::PrepareData(): **ERROR** t0 data bin doesn't make any sense!";
return false; return false;
} }
@ -377,10 +377,10 @@ bool PRunSingleHisto::PrepareData()
// check if the t0's are given in the msr-file // check if the t0's are given in the msr-file
if (i >= fRunInfo->fT0.size()) { // t0's are NOT in the msr-file if (i >= fRunInfo->fT0.size()) { // t0's are NOT in the msr-file
// check if the t0's are in the data file // check if the t0's are in the data file
if (addRunData->fT0s.size() != 0) { // t0's in the run data if (addRunData->GetT0s().size() != 0) { // t0's in the run data
// keep the proper t0's. For single histo runs, forward is holding the histo no // keep the proper t0's. For single histo runs, forward is holding the histo no
// fForwardHistoNo starts with 1 not with 0 ;-) // fForwardHistoNo starts with 1 not with 0 ;-)
t0Add = addRunData->fT0s[fRunInfo->fForwardHistoNo-1]; t0Add = addRunData->GetT0(fRunInfo->fForwardHistoNo-1);
} else { // t0's are neither in the run data nor in the msr-file -> not acceptable! } else { // t0's are neither in the run data nor in the msr-file -> not acceptable!
cout << endl << "PRunSingleHisto::PrepareData(): **ERROR** NO t0's found, neither in the addrun data nor in the msr-file!"; cout << endl << "PRunSingleHisto::PrepareData(): **ERROR** NO t0's found, neither in the addrun data nor in the msr-file!";
cout << endl << " addrun: " << fRunInfo->fRunName[i].Data(); cout << endl << " addrun: " << fRunInfo->fRunName[i].Data();
@ -388,12 +388,12 @@ bool PRunSingleHisto::PrepareData()
} }
} else { // t0's in the msr-file } else { // t0's in the msr-file
// check if t0's are given in the data file // check if t0's are given in the data file
if (addRunData->fT0s.size() != 0) { if (addRunData->GetT0s().size() != 0) {
// compare t0's of the msr-file with the one in the data file // compare t0's of the msr-file with the one in the data file
if (fabs(fRunInfo->fT0[i]-addRunData->fT0s[fRunInfo->fForwardHistoNo-1])>5.0) { // given in bins!! if (fabs(fRunInfo->fT0[i]-addRunData->GetT0(fRunInfo->fForwardHistoNo-1))>5.0) { // given in bins!!
cout << endl << "PRunSingleHisto::PrepareData(): **WARNING**:"; cout << endl << "PRunSingleHisto::PrepareData(): **WARNING**:";
cout << endl << " t0 from the msr-file is " << fRunInfo->fT0[i]; cout << endl << " t0 from the msr-file is " << fRunInfo->fT0[i];
cout << endl << " t0 from the data file is " << addRunData->fT0s[fRunInfo->fForwardHistoNo-1]; cout << endl << " t0 from the data file is " << addRunData->GetT0(fRunInfo->fForwardHistoNo-1);
cout << endl << " This is quite a deviation! Is this done intentionally??"; cout << endl << " This is quite a deviation! Is this done intentionally??";
cout << endl << " addrun: " << fRunInfo->fRunName[i].Data(); cout << endl << " addrun: " << fRunInfo->fRunName[i].Data();
cout << endl; cout << endl;
@ -412,17 +412,17 @@ bool PRunSingleHisto::PrepareData()
} }
// add run // add run
for (unsigned int j=0; j<runData->fDataBin[histoNo].size(); j++) { for (unsigned int j=0; j<runData->GetDataBin(histoNo)->size(); j++) {
// make sure that the index stays in the proper range // make sure that the index stays in the proper range
if ((j-t0Add+t0 >= 0) && (j-t0Add+t0 < addRunData->fDataBin[histoNo].size())) { if ((j-t0Add+t0 >= 0) && (j-t0Add+t0 < addRunData->GetDataBin(histoNo)->size())) {
runData->fDataBin[histoNo][j] += addRunData->fDataBin[histoNo][j-t0Add+t0]; runData->AddDataBin(histoNo, j, addRunData->GetDataBin(histoNo)->at(j-t0Add+t0));
} }
} }
} }
} }
// keep the time resolution in (us) // keep the time resolution in (us)
fTimeResolution = runData->fTimeResolution/1.0e3; fTimeResolution = runData->GetTimeResolution()/1.0e3;
if (fHandleTag == kFit) if (fHandleTag == kFit)
success = PrepareFitData(runData, histoNo); success = PrepareFitData(runData, histoNo);
@ -466,12 +466,12 @@ bool PRunSingleHisto::PrepareFitData(PRawRunData* runData, const unsigned int hi
start = keep; start = keep;
} }
// 2nd check if start is within proper bounds // 2nd check if start is within proper bounds
if ((start < 0) || (start > (int)runData->fDataBin[histoNo].size())) { if ((start < 0) || (start > (int)runData->GetDataBin(histoNo)->size())) {
cout << endl << "PRunSingleHisto::PrepareFitData(): **ERROR** start data bin doesn't make any sense!"; cout << endl << "PRunSingleHisto::PrepareFitData(): **ERROR** start data bin doesn't make any sense!";
return false; return false;
} }
// 3rd check if end is within proper bounds // 3rd check if end is within proper bounds
if ((end < 0) || (end > (int)runData->fDataBin[histoNo].size())) { if ((end < 0) || (end > (int)runData->GetDataBin(histoNo)->size())) {
cout << endl << "PRunSingleHisto::PrepareFitData(): **ERROR** end data bin doesn't make any sense!"; cout << endl << "PRunSingleHisto::PrepareFitData(): **ERROR** end data bin doesn't make any sense!";
return false; return false;
} }
@ -497,42 +497,42 @@ bool PRunSingleHisto::PrepareFitData(PRawRunData* runData, const unsigned int hi
double normalizer = 1.0; double normalizer = 1.0;
// data start at data_start-t0 // data start at data_start-t0
// time shifted so that packing is included correctly, i.e. t0 == t0 after packing // time shifted so that packing is included correctly, i.e. t0 == t0 after packing
fData.fDataTimeStart = fTimeResolution*((double)start-(double)t0+(double)(fRunInfo->fPacking-1)/2.0); fData.SetDataTimeStart(fTimeResolution*((double)start-(double)t0+(double)(fRunInfo->fPacking-1)/2.0));
fData.fDataTimeStep = fTimeResolution*fRunInfo->fPacking; fData.SetDataTimeStep(fTimeResolution*fRunInfo->fPacking);
for (int i=start; i<end; i++) { for (int i=start; i<end; i++) {
if (fRunInfo->fPacking == 1) { if (fRunInfo->fPacking == 1) {
value = runData->fDataBin[histoNo][i]; value = runData->GetDataBin(histoNo)->at(i);
normalizer = fRunInfo->fPacking * (fTimeResolution * 1e3); // fTimeResolution us->ns normalizer = fRunInfo->fPacking * (fTimeResolution * 1e3); // fTimeResolution us->ns
value /= normalizer; value /= normalizer;
fData.fValue.push_back(value); fData.AppendValue(value);
if (value == 0.0) if (value == 0.0)
fData.fError.push_back(1.0); fData.AppendErrorValue(1.0);
else else
fData.fError.push_back(TMath::Sqrt(value)); fData.AppendErrorValue(TMath::Sqrt(value));
} else { // packed data, i.e. fRunInfo->fPacking > 1 } else { // packed data, i.e. fRunInfo->fPacking > 1
if (((i-start) % fRunInfo->fPacking == 0) && (i != start)) { // fill data if (((i-start) % fRunInfo->fPacking == 0) && (i != start)) { // fill data
// in order that after rebinning the fit does not need to be redone (important for plots) // in order that after rebinning the fit does not need to be redone (important for plots)
// the value is normalize to per 1 nsec // the value is normalize to per 1 nsec
normalizer = fRunInfo->fPacking * (fTimeResolution * 1e3); // fTimeResolution us->ns normalizer = fRunInfo->fPacking * (fTimeResolution * 1e3); // fTimeResolution us->ns
value /= normalizer; value /= normalizer;
fData.fValue.push_back(value); fData.AppendValue(value);
if (value == 0.0) if (value == 0.0)
fData.fError.push_back(1.0); fData.AppendErrorValue(1.0);
else else
fData.fError.push_back(TMath::Sqrt(value/normalizer)); fData.AppendErrorValue(TMath::Sqrt(value/normalizer));
// reset values // reset values
value = 0.0; value = 0.0;
} }
value += runData->fDataBin[histoNo][i]; value += runData->GetDataBin(histoNo)->at(i);
} }
} }
// count the number of bins to be fitted // count the number of bins to be fitted
fNoOfFitBins=0; fNoOfFitBins=0;
double time; double time;
//cout << endl << ">> size=" << fData.fValue.size() << ", fDataTimeStart=" << fData.fDataTimeStart << ", fDataTimeStep=" << fData.fDataTimeStep << ", fFitStartTime=" << fFitStartTime << ", fFitStopTime=" << fFitStopTime; //cout << endl << ">> size=" << fData.GetValue()->size() << ", fDataTimeStart=" << fData.GetDataTimeStart() << ", fDataTimeStep=" << fData.GetDataTimeStep() << ", fFitStartTime=" << fFitStartTime << ", fFitStopTime=" << fFitStopTime;
for (unsigned int i=0; i<fData.fValue.size(); i++) { for (unsigned int i=0; i<fData.GetValue()->size(); i++) {
time = fData.fDataTimeStart + (double)i*fData.fDataTimeStep; time = fData.GetDataTimeStart() + (double)i*fData.GetDataTimeStep();
if ((time >= fFitStartTime) && (time <= fFitStopTime)) if ((time >= fFitStartTime) && (time <= fFitStopTime))
fNoOfFitBins++; fNoOfFitBins++;
} }
@ -559,7 +559,7 @@ bool PRunSingleHisto::PrepareRawViewData(PRawRunData* runData, const unsigned in
// start = the first bin which is a multiple of packing backward from first good data bin // start = the first bin which is a multiple of packing backward from first good data bin
int start = fRunInfo->fDataRange[0] - (fRunInfo->fDataRange[0]/packing)*packing; int start = fRunInfo->fDataRange[0] - (fRunInfo->fDataRange[0]/packing)*packing;
// end = last bin starting from start which is a multipl of packing and still within the data // end = last bin starting from start which is a multipl of packing and still within the data
int end = start + ((runData->fDataBin[histoNo].size()-start)/packing)*packing; int end = start + ((runData->GetDataBin(histoNo)->size()-start)/packing)*packing;
// check if start, end, and t0 make any sense // check if start, end, and t0 make any sense
// 1st check if start and end are in proper order // 1st check if start and end are in proper order
if (end < start) { // need to swap them if (end < start) { // need to swap them
@ -568,12 +568,12 @@ bool PRunSingleHisto::PrepareRawViewData(PRawRunData* runData, const unsigned in
start = keep; start = keep;
} }
// 2nd check if start is within proper bounds // 2nd check if start is within proper bounds
if ((start < 0) || (start > (int)runData->fDataBin[histoNo].size())) { if ((start < 0) || (start > (int)runData->GetDataBin(histoNo)->size())) {
cout << endl << "PRunSingleHisto::PrepareRawViewData(): **ERROR** start data bin doesn't make any sense!"; cout << endl << "PRunSingleHisto::PrepareRawViewData(): **ERROR** start data bin doesn't make any sense!";
return false; return false;
} }
// 3rd check if end is within proper bounds // 3rd check if end is within proper bounds
if ((end < 0) || (end > (int)runData->fDataBin[histoNo].size())) { if ((end < 0) || (end > (int)runData->GetDataBin(histoNo)->size())) {
cout << endl << "PRunSingleHisto::PrepareRawViewData(): **ERROR** end data bin doesn't make any sense!"; cout << endl << "PRunSingleHisto::PrepareRawViewData(): **ERROR** end data bin doesn't make any sense!";
return false; return false;
} }
@ -583,13 +583,13 @@ bool PRunSingleHisto::PrepareRawViewData(PRawRunData* runData, const unsigned in
double value = 0.0; double value = 0.0;
// data start at data_start-t0 // data start at data_start-t0
// time shifted so that packing is included correctly, i.e. t0 == t0 after packing // time shifted so that packing is included correctly, i.e. t0 == t0 after packing
fData.fDataTimeStart = fTimeResolution*((double)start-(double)t0+(double)(packing-1)/2.0); fData.SetDataTimeStart(fTimeResolution*((double)start-(double)t0+(double)(packing-1)/2.0));
fData.fDataTimeStep = fTimeResolution*packing; fData.SetDataTimeStep(fTimeResolution*packing);
/* /*
cout << endl << ">> time resolution = " << fTimeResolution; cout << endl << ">> time resolution = " << fTimeResolution;
cout << endl << ">> start = " << start << ", t0 = " << t0 << ", packing = " << packing; cout << endl << ">> start = " << start << ", t0 = " << t0 << ", packing = " << packing;
cout << endl << ">> data start time = " << fData.fDataTimeStart; cout << endl << ">> data start time = " << fData.GetDataTimeStart();
*/ */
double normalizer = 1.0; double normalizer = 1.0;
@ -599,23 +599,23 @@ cout << endl << ">> data start time = " << fData.fDataTimeStart;
// the value is normalize to per 1 nsec // the value is normalize to per 1 nsec
normalizer = packing * (fTimeResolution * 1e3); // fTimeResolution us->ns normalizer = packing * (fTimeResolution * 1e3); // fTimeResolution us->ns
value /= normalizer; value /= normalizer;
fData.fValue.push_back(value); fData.AppendValue(value);
if (value == 0.0) if (value == 0.0)
fData.fError.push_back(1.0); fData.AppendErrorValue(1.0);
else else
fData.fError.push_back(TMath::Sqrt(value/normalizer)); fData.AppendErrorValue(TMath::Sqrt(value/normalizer));
// reset values // reset values
value = 0.0; value = 0.0;
} }
value += runData->fDataBin[histoNo][i]; value += runData->GetDataBin(histoNo)->at(i);
} }
// count the number of bins // count the number of bins
fNoOfFitBins=0; fNoOfFitBins=0;
double time; double time;
for (unsigned int i=0; i<fData.fValue.size(); i++) { for (unsigned int i=0; i<fData.GetValue()->size(); i++) {
time = fData.fDataTimeStart + (double)i*fData.fDataTimeStep; time = fData.GetDataTimeStart() + (double)i*fData.GetDataTimeStep();
if ((time >= fFitStartTime) && (time <= fFitStopTime)) if ((time >= fFitStartTime) && (time <= fFitStopTime))
fNoOfFitBins++; fNoOfFitBins++;
} }
@ -666,23 +666,23 @@ cout << endl << ">> data start time = " << fData.fDataTimeStart;
} }
// calculate theory // calculate theory
unsigned int size = runData->fDataBin[histoNo].size(); unsigned int size = runData->GetDataBin(histoNo)->size();
double factor = 1.0; double factor = 1.0;
if (fData.fValue.size() * 10 > runData->fDataBin[histoNo].size()) { if (fData.GetValue()->size() * 10 > runData->GetDataBin(histoNo)->size()) {
size = fData.fValue.size() * 10; size = fData.GetValue()->size() * 10;
factor = (double)runData->fDataBin[histoNo].size() / (double)size; factor = (double)runData->GetDataBin(histoNo)->size() / (double)size;
} }
//cout << endl << ">> runData->fDataBin[histoNo].size() = " << runData->fDataBin[histoNo].size() << ", fData.fValue.size() * 10 = " << fData.fValue.size() * 10 << ", size = " << size << ", factor = " << factor << endl; //cout << endl << ">> runData->GetDataBin(histoNo).size() = " << runData->GetDataBin(histoNo)->size() << ", fData.GetValue()->size() * 10 = " << fData.GetValue()->size() * 10 << ", size = " << size << ", factor = " << factor << endl;
double theoryValue; double theoryValue;
fData.fTheoryTimeStart = fData.fDataTimeStart; fData.SetTheoryTimeStart(fData.GetDataTimeStart());
fData.fTheoryTimeStep = fTimeResolution*factor; fData.SetTheoryTimeStep(fTimeResolution*factor);
for (unsigned int i=0; i<size; i++) { for (unsigned int i=0; i<size; i++) {
time = fData.fTheoryTimeStart + i*fData.fTheoryTimeStep; time = fData.GetTheoryTimeStart() + i*fData.GetTheoryTimeStep();
theoryValue = fTheory->Func(time, par, fFuncValues); theoryValue = fTheory->Func(time, par, fFuncValues);
if (fabs(theoryValue) > 10.0) { // dirty hack needs to be fixed!! if (fabs(theoryValue) > 10.0) { // dirty hack needs to be fixed!!
theoryValue = 0.0; theoryValue = 0.0;
} }
fData.fTheory.push_back(N0*TMath::Exp(-time/tau)*(1+theoryValue)+bkg); fData.AppendTheoryValue(N0*TMath::Exp(-time/tau)*(1+theoryValue)+bkg);
} }
// clean up // clean up
@ -721,7 +721,7 @@ bool PRunSingleHisto::PrepareViewData(PRawRunData* runData, const unsigned int h
// start = the first bin which is a multiple of packing backward from first good data bin // start = the first bin which is a multiple of packing backward from first good data bin
int start = fRunInfo->fDataRange[0] - (fRunInfo->fDataRange[0]/packing)*packing; int start = fRunInfo->fDataRange[0] - (fRunInfo->fDataRange[0]/packing)*packing;
// end = last bin starting from start which is a multiple of packing and still within the data // end = last bin starting from start which is a multiple of packing and still within the data
int end = start + ((runData->fDataBin[histoNo].size()-start)/packing)*packing; int end = start + ((runData->GetDataBin(histoNo)->size()-start)/packing)*packing;
// check if start, end, and t0 make any sense // check if start, end, and t0 make any sense
// 1st check if start and end are in proper order // 1st check if start and end are in proper order
@ -731,12 +731,12 @@ bool PRunSingleHisto::PrepareViewData(PRawRunData* runData, const unsigned int h
start = keep; start = keep;
} }
// 2nd check if start is within proper bounds // 2nd check if start is within proper bounds
if ((start < 0) || (start > (int)runData->fDataBin[histoNo].size())) { if ((start < 0) || (start > (int)runData->GetDataBin(histoNo)->size())) {
cout << endl << "PRunSingleHisto::PrepareViewData(): **ERROR** start data bin doesn't make any sense!"; cout << endl << "PRunSingleHisto::PrepareViewData(): **ERROR** start data bin doesn't make any sense!";
return false; return false;
} }
// 3rd check if end is within proper bounds // 3rd check if end is within proper bounds
if ((end < 0) || (end > (int)runData->fDataBin[histoNo].size())) { if ((end < 0) || (end > (int)runData->GetDataBin(histoNo)->size())) {
cout << endl << "PRunSingleHisto::PrepareViewData(): **ERROR** end data bin doesn't make any sense!"; cout << endl << "PRunSingleHisto::PrepareViewData(): **ERROR** end data bin doesn't make any sense!";
return false; return false;
} }
@ -788,11 +788,11 @@ bool PRunSingleHisto::PrepareViewData(PRawRunData* runData, const unsigned int h
double time; double time;
// data start at data_start-t0 shifted by (pack-1)/2 // data start at data_start-t0 shifted by (pack-1)/2
fData.fDataTimeStart = fTimeResolution*((double)start-(double)t0+(double)(packing-1)/2.0); fData.SetDataTimeStart(fTimeResolution*((double)start-(double)t0+(double)(packing-1)/2.0));
fData.fDataTimeStep = fTimeResolution*packing; fData.SetDataTimeStep(fTimeResolution*packing);
/* /*
cout << endl << ">> start time = " << fData.fDataTimeStart << ", step = " << fData.fDataTimeStep; cout << endl << ">> start time = " << fData.GetDataTimeStart() << ", step = " << fData.GetDataTimeStep();
cout << endl << ">> start = " << start << ", end = " << end; cout << endl << ">> start = " << start << ", end = " << end;
cout << endl << "--------------------------------" << endl; cout << endl << "--------------------------------" << endl;
*/ */
@ -806,19 +806,19 @@ cout << endl << "--------------------------------" << endl;
value /= normalizer; value /= normalizer;
time = (((double)i-(double)(packing-1)/2.0)-t0)*fTimeResolution; time = (((double)i-(double)(packing-1)/2.0)-t0)*fTimeResolution;
expval = TMath::Exp(+time/tau)/N0; expval = TMath::Exp(+time/tau)/N0;
fData.fValue.push_back(-1.0+expval*(value-bkg)); fData.AppendValue(-1.0+expval*(value-bkg));
//cout << endl << ">> i=" << i << ",t0=" << t0 << ",time=" << time << ",expval=" << expval << ",value=" << value << ",bkg=" << bkg << ",expval*(value-bkg)-1=" << expval*(value-bkg)-1.0; //cout << endl << ">> i=" << i << ",t0=" << t0 << ",time=" << time << ",expval=" << expval << ",value=" << value << ",bkg=" << bkg << ",expval*(value-bkg)-1=" << expval*(value-bkg)-1.0;
fData.fError.push_back(expval*TMath::Sqrt(value/normalizer)); fData.AppendErrorValue(expval*TMath::Sqrt(value/normalizer));
//cout << endl << ">> " << time << ", " << expval << ", " << -1.0+expval*(value-bkg) << ", " << expval*TMath::Sqrt(value/packing); //cout << endl << ">> " << time << ", " << expval << ", " << -1.0+expval*(value-bkg) << ", " << expval*TMath::Sqrt(value/packing);
value = 0.0; value = 0.0;
} }
value += runData->fDataBin[histoNo][i]; value += runData->GetDataBin(histoNo)->at(i);
} }
// count the number of bins to be fitted // count the number of bins to be fitted
fNoOfFitBins=0; fNoOfFitBins=0;
for (unsigned int i=0; i<fData.fValue.size(); i++) { for (unsigned int i=0; i<fData.GetValue()->size(); i++) {
time = fData.fDataTimeStart + (double)i*fData.fDataTimeStep; time = fData.GetDataTimeStart() + (double)i*fData.GetDataTimeStep();
if ((time >= fFitStartTime) && (time <= fFitStopTime)) if ((time >= fFitStartTime) && (time <= fFitStopTime))
fNoOfFitBins++; fNoOfFitBins++;
} }
@ -830,23 +830,23 @@ cout << endl << "--------------------------------" << endl;
// calculate theory // calculate theory
double theoryValue; double theoryValue;
unsigned int size = runData->fDataBin[histoNo].size(); unsigned int size = runData->GetDataBin(histoNo)->size();
double factor = 1.0; double factor = 1.0;
if (fData.fValue.size() * 10 > runData->fDataBin[histoNo].size()) { if (fData.GetValue()->size() * 10 > runData->GetDataBin(histoNo)->size()) {
size = fData.fValue.size() * 10; size = fData.GetValue()->size() * 10;
factor = (double)runData->fDataBin[histoNo].size() / (double)size; factor = (double)runData->GetDataBin(histoNo)->size() / (double)size;
} }
//cout << endl << ">> runData->fDataBin[histoNo].size() = " << runData->fDataBin[histoNo].size() << ", fData.fValue.size() * 10 = " << fData.fValue.size() * 10 << ", size = " << size << ", factor = " << factor << endl; //cout << endl << ">> runData->GetDataBin(histoNo).size() = " << runData->GetDataBin(histoNo).size() << ", fData.GetValue()->size() * 10 = " << fData.GetValue()->size() * 10 << ", size = " << size << ", factor = " << factor << endl;
fData.fTheoryTimeStart = fData.fDataTimeStart; fData.SetTheoryTimeStart(fData.GetDataTimeStart());
fData.fTheoryTimeStep = fTimeResolution*factor; fData.SetTheoryTimeStep(fTimeResolution*factor);
//cout << endl << ">> size=" << size << ", startTime=" << startTime << ", fTimeResolution=" << fTimeResolution; //cout << endl << ">> size=" << size << ", startTime=" << startTime << ", fTimeResolution=" << fTimeResolution;
for (unsigned int i=0; i<size; i++) { for (unsigned int i=0; i<size; i++) {
time = fData.fTheoryTimeStart + (double)i*fData.fTheoryTimeStep; time = fData.GetTheoryTimeStart() + (double)i*fData.GetTheoryTimeStep();
theoryValue = fTheory->Func(time, par, fFuncValues); theoryValue = fTheory->Func(time, par, fFuncValues);
if (fabs(theoryValue) > 10.0) { // dirty hack needs to be fixed!! if (fabs(theoryValue) > 10.0) { // dirty hack needs to be fixed!!
theoryValue = 0.0; theoryValue = 0.0;
} }
fData.fTheory.push_back(theoryValue); fData.AppendTheoryValue(theoryValue);
} }
// clean up // clean up
@ -899,17 +899,17 @@ bool PRunSingleHisto::EstimateBkg(unsigned int histoNo)
PRawRunData* runData = fRawData->GetRunData(fRunInfo->fRunName[0]); PRawRunData* runData = fRawData->GetRunData(fRunInfo->fRunName[0]);
// check if start is within histogram bounds // check if start is within histogram bounds
if ((start < 0) || (start >= runData->fDataBin[histoNo].size())) { if ((start < 0) || (start >= runData->GetDataBin(histoNo)->size())) {
cout << endl << "PRunSingleHisto::EstimatBkg(): background bin values out of bound!"; cout << endl << "PRunSingleHisto::EstimatBkg(): background bin values out of bound!";
cout << endl << " histo lengths = " << runData->fDataBin[histoNo].size(); cout << endl << " histo lengths = " << runData->GetDataBin(histoNo)->size();
cout << endl << " background start = " << start; cout << endl << " background start = " << start;
return false; return false;
} }
// check if end is within histogram bounds // check if end is within histogram bounds
if ((end < 0) || (end >= runData->fDataBin[histoNo].size())) { if ((end < 0) || (end >= runData->GetDataBin(histoNo)->size())) {
cout << endl << "PRunSingleHisto::EstimatBkg(): background bin values out of bound!"; cout << endl << "PRunSingleHisto::EstimatBkg(): background bin values out of bound!";
cout << endl << " histo lengths = " << runData->fDataBin[histoNo].size(); cout << endl << " histo lengths = " << runData->GetDataBin(histoNo)->size();
cout << endl << " background end = " << end; cout << endl << " background end = " << end;
return false; return false;
} }
@ -920,7 +920,7 @@ bool PRunSingleHisto::EstimateBkg(unsigned int histoNo)
// forward // forward
//cout << endl << ">> bkg start=" << start << ", end=" << end; //cout << endl << ">> bkg start=" << start << ", end=" << end;
for (unsigned int i=start; i<end; i++) for (unsigned int i=start; i<end; i++)
bkg += runData->fDataBin[histoNo][i]; bkg += runData->GetDataBin(histoNo)->at(i);
bkg /= static_cast<double>(end - start + 1); bkg /= static_cast<double>(end - start + 1);
fBackground = bkg / (fTimeResolution * 1e3); // keep background (per 1 nsec) for chisq, max.log.likelihood, fTimeResolution us->ns fBackground = bkg / (fTimeResolution * 1e3); // keep background (per 1 nsec) for chisq, max.log.likelihood, fTimeResolution us->ns

View File

@ -725,7 +725,7 @@ void PTheory::MakeCleanAndTidyTheoryBlock(PMsrLines *fullTheoryBlock)
TString str, tidy; TString str, tidy;
char substr[256]; char substr[256];
TObjArray *tokens = 0; TObjArray *tokens = 0;
TObjString *ostr; TObjString *ostr = 0;
int idx = THEORY_UNDEFINED; int idx = THEORY_UNDEFINED;
for (unsigned int i=1; i<fullTheoryBlock->size(); i++) { for (unsigned int i=1; i<fullTheoryBlock->size(); i++) {
@ -791,13 +791,14 @@ void PTheory::MakeCleanAndTidyTheoryBlock(PMsrLines *fullTheoryBlock)
} }
// write tidy string back into theory block // write tidy string back into theory block
(*fullTheoryBlock)[i].fLine = tidy; (*fullTheoryBlock)[i].fLine = tidy;
// clean up
if (tokens) {
delete tokens;
tokens = 0;
}
} }
// clean up
if (tokens) {
delete tokens;
tokens = 0;
}
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------

View File

@ -11,7 +11,7 @@
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007 by Andreas Suter * * Copyright (C) 2007 by Andreas Suter *
* andreas.suter@psi.c * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by * * it under the terms of the GNU General Public License as published by *
@ -62,6 +62,9 @@ using namespace std;
// used to filter post pileup correct data histos from root files // used to filter post pileup correct data histos from root files
#define POST_PILEUP_HISTO_OFFSET 20 #define POST_PILEUP_HISTO_OFFSET 20
// defines a value for 'undefined values'
#define PMUSR_UNDEFINED -9.9e99
//------------------------------------------------------------- //-------------------------------------------------------------
// msr block header tags // msr block header tags
#define MSR_TAG_TITLE 0 #define MSR_TAG_TITLE 0
@ -123,7 +126,13 @@ typedef vector<Int_t> PIntVector;
/** /**
* <p> * <p>
*/ */
typedef vector< pair<Int_t, Int_t> > PIntPairVector; typedef pair<Int_t, Int_t> PIntPair;
//-------------------------------------------------------------
/**
* <p>
*/
typedef vector<PIntPair> PIntPairVector;
//------------------------------------------------------------- //-------------------------------------------------------------
/** /**
@ -157,54 +166,146 @@ enum EPMusrHandleTag { kEmpty, kFit, kView };
//------------------------------------------------------------- //-------------------------------------------------------------
/** /**
* <p> Predominantly used in PRunBase. * <p>Holds the data which will be fitted, i.e. packed, background corrected, ...
*/ */
typedef struct { class PRunData {
// data related info public:
Double_t fDataTimeStart; PRunData();
Double_t fDataTimeStep; virtual ~PRunData();
PDoubleVector fX; // only used for non-muSR
PDoubleVector fValue; virtual Double_t GetDataTimeStart() { return fDataTimeStart; }
PDoubleVector fError; virtual Double_t GetDataTimeStep() { return fDataTimeStep; }
// theory related info virtual Double_t GetTheoryTimeStart() { return fTheoryTimeStart; }
Double_t fTheoryTimeStart; virtual Double_t GetTheoryTimeStep() { return fTheoryTimeStep; }
Double_t fTheoryTimeStep;
PDoubleVector fXTheory; // only used for non-muSR virtual const PDoubleVector* GetX() { return &fX; }
PDoubleVector fTheory; virtual const PDoubleVector* GetValue() { return &fValue; }
} PRunData; virtual const PDoubleVector* GetError() { return &fError; }
virtual const PDoubleVector* GetXTheory() { return &fXTheory; }
virtual const PDoubleVector* GetTheory() { return &fTheory; }
virtual void SetDataTimeStart(Double_t dval) { fDataTimeStart = dval; }
virtual void SetDataTimeStep(Double_t dval) { fDataTimeStep = dval; }
virtual void SetTheoryTimeStart(Double_t dval) { fTheoryTimeStart = dval; }
virtual void SetTheoryTimeStep(Double_t dval) { fTheoryTimeStep = dval; }
virtual void AppendXValue(Double_t dval) { fX.push_back(dval); }
virtual void AppendValue(Double_t dval) { fValue.push_back(dval); }
virtual void AppendErrorValue(Double_t dval) { fError.push_back(dval); }
virtual void AppendXTheoryValue(Double_t dval) { fXTheory.push_back(dval); }
virtual void AppendTheoryValue(Double_t dval) { fTheory.push_back(dval); }
private:
// data related info
Double_t fDataTimeStart;
Double_t fDataTimeStep;
PDoubleVector fX; // only used for non-muSR
PDoubleVector fValue;
PDoubleVector fError;
// theory related info
Double_t fTheoryTimeStart;
Double_t fTheoryTimeStep;
PDoubleVector fXTheory; // only used for non-muSR
PDoubleVector fTheory;
};
//------------------------------------------------------------- //-------------------------------------------------------------
/** /**
* <p> * <p>Non-Musr raw data.
*/ */
typedef struct { class PNonMusrRawRunData {
Bool_t fFromAscii; ///< if true: data file was an ascii input file, otherwise it is a db input file public:
PStringVector fLabels; ///< vector of all labels (used for x-, y-axis title in view) PNonMusrRawRunData();
PStringVector fDataTags; ///< vector of all data tags virtual ~PNonMusrRawRunData();
vector<PDoubleVector> fData; ///< vector of all data
vector<PDoubleVector> fErrData; ///< vector of all data errors virtual Bool_t FromAscii() { return fFromAscii; }
} PNonMusrRawRunData; virtual const PStringVector* GetLabels() { return &fLabels; }
virtual const PStringVector* GetDataTags() { return &fDataTags; }
virtual const vector<PDoubleVector>* GetData() { return &fData; }
virtual const vector<PDoubleVector>* GetErrData() { return &fErrData; }
virtual void SetFromAscii(const Bool_t bval) { fFromAscii = bval; }
virtual void AppendLabel(const TString str) { fLabels.push_back(str); }
virtual void SetLabel(const UInt_t idx, const TString str);
virtual void AppendDataTag(const TString str) { fDataTags.push_back(str); }
virtual void AppendData(const PDoubleVector &data) { fData.push_back(data); }
virtual void AppendErrData(const PDoubleVector &data) { fErrData.push_back(data); }
virtual void AppendSubData(const UInt_t idx, const Double_t dval);
virtual void AppendSubErrData(const UInt_t idx, const Double_t dval);
private:
Bool_t fFromAscii; ///< if true: data file was an ascii input file, otherwise it is a db input file
PStringVector fLabels; ///< vector of all labels (used for x-, y-axis title in view)
PStringVector fDataTags; ///< vector of all data tags
vector<PDoubleVector> fData; ///< vector of all data
vector<PDoubleVector> fErrData; ///< vector of all data errors
};
//------------------------------------------------------------- //-------------------------------------------------------------
/** /**
* <p> * <p>Histogram raw muSR data.
*/ */
typedef struct { class PRawRunData {
TString fRunName; ///< name of the run public:
TString fRunTitle; ///< run title PRawRunData();
TString fSetup; ///< description of the setup of this run virtual ~PRawRunData();
Double_t fField; ///< magnetic field value
PDoublePairVector fTemp; ///< measured temperatures and standard deviations during the run virtual const TString* GetRunName() { return &fRunName; }
Double_t fEnergy; ///< implantation energy of the muon virtual const TString* GetRunTitle() { return &fRunTitle; }
Double_t fTransport; ///< LEM transport settings (Moderator HV) virtual const TString* GetSetup() { return &fSetup; }
PDoubleVector fRingAnode; ///< LEM ring anode HVs (L,R[,T,B]) virtual const Double_t GetField() { return fField; }
Double_t fTimeResolution; ///< time resolution of the run virtual const UInt_t GetNoOfTemperatures() { return fTemp.size(); }
PIntVector fT0s; ///< vector of t0's of a run virtual const PDoublePairVector GetTemperature() { return fTemp; }
PIntPairVector fBkgBin; ///< background bins (first/last) virtual const Double_t GetTemperature(const UInt_t idx);
PIntPairVector fGoodDataBin; ///< data bins (first/last) virtual const Double_t GetTempError(const UInt_t idx);
vector<PDoubleVector> fDataBin; ///< vector of all histos of a run virtual const Double_t GetEnergy() { return fEnergy; }
PNonMusrRawRunData fDataNonMusr; ///< keeps all ascii- or db-file info in case of nonMusr fit virtual const Double_t GetTransport() { return fTransport; }
} PRawRunData; virtual const PDoubleVector GetRingAnode() { return fRingAnode; }
virtual const Double_t GetRingAnode(const UInt_t idx);
virtual const Double_t GetTimeResolution() { return fTimeResolution; }
virtual const PIntVector GetT0s() { return fT0s; }
virtual const Int_t GetT0(const UInt_t idx);
virtual const PIntPair GetBkgBin(const UInt_t idx);
virtual const PIntPair GetGoodDataBin(const UInt_t idx);
virtual const UInt_t GetNoOfHistos() { return fDataBin.size(); }
virtual const PDoubleVector* GetDataBin(const UInt_t idx);
virtual const PNonMusrRawRunData* GetDataNonMusr() { return &fDataNonMusr; }
virtual void SetRunName(const TString &str) { fRunName = str; }
virtual void SetRunTitle(const TString str) { fRunTitle = str; }
virtual void SetSetup(const TString str) { fSetup = str; }
virtual void SetField(const Double_t dval) { fField = dval; }
virtual void ClearTemperature() { fTemp.clear(); }
virtual void SetTemperature(const UInt_t idx, const Double_t temp, const Double_t errTemp);
virtual void SetTempError(const UInt_t idx, const Double_t errTemp);
virtual void SetEnergy(const Double_t dval) { fEnergy = dval; }
virtual void SetTransport(const Double_t dval) { fTransport = dval; }
virtual void SetRingAnode(const UInt_t idx, const Double_t dval);
virtual void SetTimeResolution(const Double_t dval) { fTimeResolution = dval; }
virtual void AppendT0(const Int_t ival) { fT0s.push_back(ival); }
virtual void AppendBkgBin(PIntPair pair) { fBkgBin.push_back(pair); }
virtual void AppendGoodDataBin(PIntPair pair) { fGoodDataBin.push_back(pair); }
virtual void AppendDataBin(PDoubleVector data) { fDataBin.push_back(data); }
virtual void SetDataBin(const UInt_t histoNo, const UInt_t bin, const Double_t dval);
virtual void AddDataBin(const UInt_t histoNo, const UInt_t bin, const Double_t dval);
PNonMusrRawRunData fDataNonMusr; ///< keeps all ascii- or db-file info in case of nonMusr fit
private:
TString fRunName; ///< name of the run
TString fRunTitle; ///< run title
TString fSetup; ///< description of the setup of this run
Double_t fField; ///< magnetic field value
PDoublePairVector fTemp; ///< measured temperatures and standard deviations during the run
Double_t fEnergy; ///< implantation energy of the muon
Double_t fTransport; ///< LEM transport settings (Moderator HV)
PDoubleVector fRingAnode; ///< LEM ring anode HVs (L,R[,T,B])
Double_t fTimeResolution; ///< time resolution of the run
PIntVector fT0s; ///< vector of t0's of a run
PIntPairVector fBkgBin; ///< background bins (first/last)
PIntPairVector fGoodDataBin; ///< data bins (first/last)
vector<PDoubleVector> fDataBin; ///< vector of all histos of a run
};
//------------------------------------------------------------- //-------------------------------------------------------------
/** /**

View File

@ -11,7 +11,7 @@
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007 by Andreas Suter * * Copyright (C) 2007 by Andreas Suter *
* andreas.suter@psi.c * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by * * it under the terms of the GNU General Public License as published by *

View File

@ -11,7 +11,7 @@
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007 by Andreas Suter * * Copyright (C) 2007 by Andreas Suter *
* andreas.suter@psi.c * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by * * it under the terms of the GNU General Public License as published by *
@ -74,7 +74,7 @@ class PRunDataHandler
virtual Bool_t IsWhitespace(const char *str); virtual Bool_t IsWhitespace(const char *str);
virtual Double_t ToDouble(TString &str, Bool_t &ok); virtual Double_t ToDouble(TString &str, Bool_t &ok);
virtual Int_t ToInt(TString &str, Bool_t &ok); virtual Int_t ToInt(TString &str, Bool_t &ok);
virtual Int_t GetDataTagIndex(TString &str, PStringVector &fLabels); virtual Int_t GetDataTagIndex(TString &str, const PStringVector* fLabels);
}; };
#endif // _PRUNDATAHANDLER_H_ #endif // _PRUNDATAHANDLER_H_

View File

@ -110,12 +110,12 @@ void musrfit_write_ascii(TString fln, PRunData *data, int runCounter)
} }
// dump data // dump data
f << "% number of data values = " << data->fValue.size() << endl; f << "% number of data values = " << data->GetValue()->size() << endl;
f << "% time (us), value, error, theory" << endl; f << "% time (us), value, error, theory" << endl;
double time; double time;
for (unsigned int i=0; i<data->fValue.size(); i++) { for (unsigned int i=0; i<data->GetValue()->size(); i++) {
time = data->fDataTimeStart + (double)i*data->fDataTimeStep; time = data->GetDataTimeStart() + (double)i*data->GetDataTimeStep();
f << time << ", " << data->fValue[i] << ", " << data->fError[i] << ", " << data->fTheory[i] << endl; f << time << ", " << data->GetValue()->at(i) << ", " << data->GetError()->at(i) << ", " << data->GetTheory()->at(i) << endl;
} }
// close file // close file
@ -213,17 +213,17 @@ void musrfit_write_root(TFile &f, TString fln, PRunData *data, int runCounter)
TCanvas *c = new TCanvas(name, title.Data(), 10, 10, 800, 600); TCanvas *c = new TCanvas(name, title.Data(), 10, 10, 800, 600);
// create histos // create histos
Double_t diff = data->fDataTimeStep; Double_t diff = data->GetDataTimeStep();
Double_t start = -diff/2.0; Double_t start = -diff/2.0;
Double_t end = data->fDataTimeStep*data->fValue.size(); Double_t end = data->GetDataTimeStep()*data->GetValue()->size();
TH1F *hdata = new TH1F("hdata", "run data", data->fValue.size(), start, end); TH1F *hdata = new TH1F("hdata", "run data", data->GetValue()->size(), start, end);
TH1F *htheo = new TH1F("htheo", "run theory", data->fValue.size(), start, end); TH1F *htheo = new TH1F("htheo", "run theory", data->GetValue()->size(), start, end);
// fill data // fill data
for (unsigned int i=0; i<data->fValue.size(); i++) { for (unsigned int i=0; i<data->GetValue()->size(); i++) {
hdata->SetBinContent(i+1, data->fValue[i]); hdata->SetBinContent(i+1, data->GetValue()->at(i));
hdata->SetBinError(i+1, data->fError[i]); hdata->SetBinError(i+1, data->GetError()->at(i));
htheo->SetBinContent(i+1, data->fTheory[i]); htheo->SetBinContent(i+1, data->GetTheory()->at(i));
} }
hdata->SetMarkerStyle(20); hdata->SetMarkerStyle(20);
@ -319,6 +319,8 @@ void musrfit_dump_root(char *fileName, PRunListCollection *runList)
} }
} }
} }
f.Close("R");
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
@ -400,7 +402,6 @@ int main(int argc, char *argv[])
} }
} }
// read startup file // read startup file
char startup_path_name[128]; char startup_path_name[128];
TSAXParser *saxParser = new TSAXParser(); TSAXParser *saxParser = new TSAXParser();
@ -457,8 +458,8 @@ int main(int argc, char *argv[])
if (title_from_data_file) { if (title_from_data_file) {
PMsrRunList *rl = msrHandler->GetMsrRunList(); PMsrRunList *rl = msrHandler->GetMsrRunList();
PRawRunData *rrd = dataHandler->GetRunData(rl->at(0).fRunName[0]); PRawRunData *rrd = dataHandler->GetRunData(rl->at(0).fRunName[0]);
if (rrd->fRunTitle.Length() > 0) if (rrd->GetRunTitle()->Length() > 0)
msrHandler->SetMsrTitle(rrd->fRunTitle); msrHandler->SetMsrTitle(*rrd->GetRunTitle());
} }
// generate the necessary fit histogramms for the fit // generate the necessary fit histogramms for the fit

View File

@ -82,7 +82,7 @@ bool musrt0_item(TApplication &app, PMsrHandler *msrHandler, PRawRunData *rawRun
if (musrT0 == 0) { if (musrT0 == 0) {
cout << endl << "**ERROR** Couldn't invoke musrT0 ..."; cout << endl << "**ERROR** Couldn't invoke musrT0 ...";
cout << endl << " run name " << rawRunData->fRunName.Data(); cout << endl << " run name " << rawRunData->GetRunName()->Data();
cout << endl << " histo No " << histoNo; cout << endl << " histo No " << histoNo;
cout << endl; cout << endl;
return false; return false;

View File

@ -152,17 +152,15 @@ int main(int argc, char *argv[])
if (status) { // error if (status) { // error
cout << endl << "**WARNING** reading/parsing musrfit_startup.xml failed."; cout << endl << "**WARNING** reading/parsing musrfit_startup.xml failed.";
cout << endl; cout << endl;
/*
// clean up // clean up
if (saxParser) {
delete saxParser;
saxParser = 0;
}
if (startupHandler) { if (startupHandler) {
delete startupHandler; delete startupHandler;
startupHandler = 0; startupHandler = 0;
} }
*/ if (saxParser) {
delete saxParser;
saxParser = 0;
}
} }
startupHandler->CheckLists(); startupHandler->CheckLists();