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 \
PMsrHandler.cpp \
PMusrCanvas.cpp \
PMusr.cpp \
PMusrT0.cpp \
PRunAsymmetry.cpp \
PRunBase.cpp \

View File

@ -37,7 +37,7 @@ using namespace std;
#include "TH1F.h"
#include "TF1.h"
#include "TFile.h"
//#include "TFile.h"
#include "PMusr.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());
PRawRunData *rawRunData(fDataHandler->GetRunData((*msrRunList)[0].fRunName[0]));
switch (rawRunData->fTemp.size()) {
switch (rawRunData->GetNoOfTemperatures()) {
case 1:
dataParamNames.push_back("dataT");
dataParamLabels.push_back("T (K)");
dataParam.push_back(rawRunData->fTemp[0].first);
dataParamErr.push_back(rawRunData->fTemp[0].second);
dataParam.push_back(rawRunData->GetTemperature(0));
dataParamErr.push_back(rawRunData->GetTempError(0));
break;
default:
ostringstream oss;
for (unsigned int i(0); i<rawRunData->fTemp.size(); i++) {
for (unsigned int i(0); i<rawRunData->GetNoOfTemperatures(); i++) {
oss << "dataT" << i;
dataParamNames.push_back(oss.str());
oss.str("");
oss << "T" << i << " (K)";
dataParamLabels.push_back(oss.str());
oss.str("");
dataParam.push_back(rawRunData->fTemp[i].first);
dataParamErr.push_back(rawRunData->fTemp[i].second);
dataParam.push_back(rawRunData->GetTemperature(i));
dataParamErr.push_back(rawRunData->GetTempError(i));
}
break;
}
double value;
value = rawRunData->fField;
if (value != -9.9e99) {
value = rawRunData->GetField();
if (value != PMUSR_UNDEFINED) {
dataParamNames.push_back("dataB");
dataParamLabels.push_back("mu0 H (G)");
dataParam.push_back(value);
}
value = rawRunData->fEnergy;
if (value != -999.0) {
value = rawRunData->GetEnergy();
if (value != PMUSR_UNDEFINED) {
dataParamNames.push_back("dataE");
dataParamLabels.push_back("Implantation Energy (keV)");
dataParam.push_back(value);
}
value = rawRunData->fTransport;
if (value != -999.0) {
value = rawRunData->GetTransport();
if (value != PMUSR_UNDEFINED) {
dataParamNames.push_back("dataTr");
dataParamLabels.push_back("Transport (kV)");
dataParam.push_back(value);
}
vector<double> ra(rawRunData->fRingAnode);
PDoubleVector ra(rawRunData->GetRingAnode());
if (ra.size() > 1) {
dataParamNames.push_back("dataRALRAR");
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
vector<double> indVarValues;
PDoubleVector indVarValues;
if (fRunListFile) {
string line;

View File

@ -11,7 +11,7 @@
/***************************************************************************
* 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 *
* 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;
string line;
TString str, sstr;
TObjArray *tokens;
TObjString *ostr;
TObjArray *tokens = 0;
TObjString *ostr = 0;
bool found = false;
bool statisticBlockFound = false;
bool partialStatisticBlockFound = true;
@ -468,6 +468,8 @@ int PMsrHandler::WriteMsrLogFile(const bool messages)
} else { // not a parameter, hence just copy it
fout << str.Data() << endl;
}
// clean up tokens
delete tokens;
}
break;
case MSR_TAG_THEORY:
@ -1177,8 +1179,8 @@ bool PMsrHandler::HandleFitParameterEntry(PMsrLines &lines)
PMsrLines::iterator iter;
TObjArray *tokens;
TObjString *ostr;
TObjArray *tokens = 0;
TObjString *ostr = 0;
TString str;
// fill param structure
@ -1420,8 +1422,8 @@ bool PMsrHandler::HandleRunEntry(PMsrLines &lines)
bool error = false;
TString str;
TObjString *ostr;
TObjArray *tokens;
TObjArray *tokens = 0;
TObjString *ostr = 0;
// init some stuff
param.fXYDataIndex[0] = -1;
@ -2068,8 +2070,8 @@ bool PMsrHandler::HandleFourierEntry(PMsrLines &lines)
PMsrLines::iterator iter;
TObjArray *tokens;
TObjString *ostr;
TObjArray *tokens = 0;
TObjString *ostr = 0;
TString str;
int ival;
@ -2247,6 +2249,13 @@ bool PMsrHandler::HandleFourierEntry(PMsrLines &lines)
}
}
// clean up
if (tokens) {
delete tokens;
tokens = 0;
}
++iter;
}
@ -2291,9 +2300,9 @@ bool PMsrHandler::HandlePlotEntry(PMsrLines &lines)
PMsrLines::iterator iter1;
PMsrLines::iterator iter2;
TObjArray *tokens;
TObjArray *tokens2;
TObjString *ostr;
TObjArray *tokens = 0;
TObjArray *tokens2 = 0;
TObjString *ostr = 0;
TString str;
TString str2;

View File

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

View File

@ -11,7 +11,7 @@
/***************************************************************************
* 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 *
* 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
fAlphaBetaTag = 4;
//cout << endl << ">> PRunAsymmetry::PRunAsymmetry(): fAlphaBetaTag = " << fAlphaBetaTag;
//cout << endl << ">> PRunAsymmetry::PRunAsymmetry(): fAlphaBetaTag = " << fAlphaBetaTag << endl;
// calculate fData
if (!PrepareData())
@ -154,8 +154,8 @@ double PRunAsymmetry::CalcChiSquare(const std::vector<double>& par)
// calculate chisq
double time;
for (unsigned int i=0; i<fData.fValue.size(); i++) {
time = fData.fDataTimeStart + (double)i*fData.fDataTimeStep;
for (unsigned int i=0; i<fData.GetValue()->size(); i++) {
time = fData.GetDataTimeStart() + (double)i*fData.GetDataTimeStep();
if ((time>=fFitStartTime) && (time<=fFitStopTime)) {
switch (fAlphaBetaTag) {
case 1: // alpha == 1, beta == 1
@ -181,8 +181,8 @@ double PRunAsymmetry::CalcChiSquare(const std::vector<double>& par)
break;
}
//if (i==0) cout << endl << "A(0) = " << asymFcnValue;
diff = fData.fValue[i] - asymFcnValue;
chisq += diff*diff / (fData.fError[i]*fData.fError[i]);
diff = fData.GetValue()->at(i) - asymFcnValue;
chisq += diff*diff / (fData.GetError()->at(i)*fData.GetError()->at(i));
}
}
@ -230,8 +230,8 @@ void PRunAsymmetry::CalcTheory()
double asymFcnValue = 0.0;
double a, b, f;
double time;
for (unsigned int i=0; i<fData.fValue.size(); i++) {
time = fData.fDataTimeStart + (double)i*fData.fDataTimeStep;
for (unsigned int i=0; i<fData.GetValue()->size(); i++) {
time = fData.GetDataTimeStart() + (double)i*fData.GetDataTimeStep();
switch (fAlphaBetaTag) {
case 1: // alpha == 1, beta == 1
asymFcnValue = fTheory->Func(time, par, fFuncValues);
@ -256,7 +256,7 @@ void PRunAsymmetry::CalcTheory()
asymFcnValue = 0.0;
break;
}
fData.fTheory.push_back(asymFcnValue);
fData.AppendTheoryValue(asymFcnValue);
}
// clean up
@ -276,7 +276,7 @@ void PRunAsymmetry::CalcTheory()
*/
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 the correct run
@ -287,41 +287,41 @@ bool PRunAsymmetry::PrepareData()
}
// keep the time resolution in (us)
fTimeResolution = runData->fTimeResolution/1.0e3;
fTimeResolution = runData->GetTimeResolution()/1.0e3;
// keep start/stop time for fit
fFitStartTime = fRunInfo->fFitRange[0];
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
if (fRunInfo->fT0.size() == 0) { // t0's are NOT in the msr-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
// fForwardHistoNo starts with 1 not with 0 etc. ;-)
fT0s.push_back(runData->fT0s[fRunInfo->fForwardHistoNo-1]); // forward t0
fT0s.push_back(runData->fT0s[fRunInfo->fBackwardHistoNo-1]); // backward t0
fT0s.push_back(runData->GetT0(fRunInfo->fForwardHistoNo-1)); // forward 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!
cout << endl << "PRunAsymmetry::PrepareData(): NO t0's found, neither in the run data nor in the msr-file!";
return false;
}
} else { // t0's in the msr-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
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 << " 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;
}
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 << " 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;
}
@ -335,21 +335,21 @@ bool PRunAsymmetry::PrepareData()
histoNo[0] = fRunInfo->fForwardHistoNo-1;
histoNo[1] = fRunInfo->fBackwardHistoNo-1;
// first check if forward/backward given in the msr-file are valid
if ((runData->fDataBin.size() < histoNo[0]+1) || (histoNo[0] < 0) ||
(runData->fDataBin.size() < histoNo[1]+1) || (histoNo[1] < 0)) {
if ((runData->GetNoOfHistos() < histoNo[0]+1) || (histoNo[0] < 0) ||
(runData->GetNoOfHistos() < histoNo[1]+1) || (histoNo[1] < 0)) {
cout << endl << "PRunAsymmetry::PrepareData(): **PANIC ERROR**:";
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;
return false;
}
// get raw forward/backward histo data
for (unsigned int i=0; i<runData->fDataBin[histoNo[0]].size(); i++) {
fForward.push_back(runData->fDataBin[histoNo[0]][i]);
fBackward.push_back(runData->fDataBin[histoNo[1]][i]);
}
fForward.resize(runData->GetDataBin(histoNo[0])->size());
fBackward.resize(runData->GetDataBin(histoNo[0])->size());
fForward = *runData->GetDataBin(histoNo[0]);
fBackward = *runData->GetDataBin(histoNo[1]);
// check if addrun's are present, and if yes add data
// 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
if (i >= fRunInfo->fT0.size()) { // t0's are NOT in the msr-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
// fForwardHistoNo starts with 1 not with 0 etc. ;-)
t0Add[0] = addRunData->fT0s[fRunInfo->fForwardHistoNo-1]; // forward t0
t0Add[1] = addRunData->fT0s[fRunInfo->fBackwardHistoNo-1]; // backward t0
t0Add[0] = addRunData->GetT0(fRunInfo->fForwardHistoNo-1); // forward 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!
cout << endl << "PRunAsymmetry::PrepareData(): NO t0's found, neither in the addrun (" << fRunInfo->fRunName[i].Data() << ") data nor in the msr-file!";
return false;
@ -391,20 +391,20 @@ bool PRunAsymmetry::PrepareData()
t0Add[0] = fRunInfo->fT0[0];
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
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 << " 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 << " addrun: " << fRunInfo->fRunName[i].Data();
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 << " 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 << " addrun: " << fRunInfo->fRunName[i].Data();
cout << endl;
@ -413,18 +413,20 @@ bool PRunAsymmetry::PrepareData()
}
// add forward run
for (unsigned int j=0; j<runData->fDataBin[histoNo[0]].size(); j++) {
// 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())) {
fForward[j] += addRunData->fDataBin[histoNo[0]][j-t0Add[0]+fT0s[0]];
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
if ((j-t0Add[0]+fT0s[0] >= 0) && (j-t0Add[0]+fT0s[0] < addRunSize)) {
fForward[j] += addRunData->GetDataBin(histoNo[0])->at(j-t0Add[0]+fT0s[0]);
}
}
// 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
if ((j-t0Add[1]+fT0s[1] >= 0) && (j-t0Add[1]+fT0s[1] < addRunData->fDataBin[histoNo[1]].size())) {
fBackward[j] += addRunData->fDataBin[histoNo[1]][j-t0Add[1]+fT0s[1]];
if ((j-t0Add[1]+fT0s[1] >= 0) && (j-t0Add[1]+fT0s[1] < addRunSize)) {
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;
}
// 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!";
return false;
}
// 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!";
return false;
}
// 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!";
return false;
}
@ -643,18 +645,18 @@ bool PRunAsymmetry::PrepareFitData(PRawRunData* runData, unsigned int histoNo[2]
// forward
for (int i=start[0]; i<end[0]; i++) {
if (fRunInfo->fPacking == 1) {
forwardPacked.fValue.push_back(fForward[i]);
forwardPacked.fError.push_back(fForwardErr[i]);
forwardPacked.AppendValue(fForward[i]);
forwardPacked.AppendErrorValue(fForwardErr[i]);
} else { // packed data, i.e. fRunInfo->fPacking > 1
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)
// the value is normalize to per bin
value /= fRunInfo->fPacking;
forwardPacked.fValue.push_back(value);
forwardPacked.AppendValue(value);
if (value == 0.0)
forwardPacked.fError.push_back(1.0);
forwardPacked.AppendErrorValue(1.0);
else
forwardPacked.fError.push_back(TMath::Sqrt(error)/fRunInfo->fPacking);
forwardPacked.AppendErrorValue(TMath::Sqrt(error)/fRunInfo->fPacking);
value = 0.0;
error = 0.0;
}
@ -665,18 +667,18 @@ bool PRunAsymmetry::PrepareFitData(PRawRunData* runData, unsigned int histoNo[2]
// backward
for (int i=start[1]; i<end[1]; i++) {
if (fRunInfo->fPacking == 1) {
backwardPacked.fValue.push_back(fBackward[i]);
backwardPacked.fError.push_back(fBackwardErr[i]);
backwardPacked.AppendValue(fBackward[i]);
backwardPacked.AppendErrorValue(fBackwardErr[i]);
} else { // packed data, i.e. fRunInfo->fPacking > 1
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)
// the value is normalize to per bin
value /= fRunInfo->fPacking;
backwardPacked.fValue.push_back(value);
backwardPacked.AppendValue(value);
if (value == 0.0)
backwardPacked.fError.push_back(1.0);
backwardPacked.AppendErrorValue(1.0);
else
backwardPacked.fError.push_back(TMath::Sqrt(error)/fRunInfo->fPacking);
backwardPacked.AppendErrorValue(TMath::Sqrt(error)/fRunInfo->fPacking);
value = 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
unsigned int noOfBins = forwardPacked.fValue.size();
if (forwardPacked.fValue.size() != backwardPacked.fValue.size()) {
if (forwardPacked.fValue.size() > backwardPacked.fValue.size())
noOfBins = backwardPacked.fValue.size();
unsigned int noOfBins = forwardPacked.GetValue()->size();
if (forwardPacked.GetValue()->size() != backwardPacked.GetValue()->size()) {
if (forwardPacked.GetValue()->size() > backwardPacked.GetValue()->size())
noOfBins = backwardPacked.GetValue()->size();
}
// form asymmetry including error propagation
@ -697,42 +699,38 @@ bool PRunAsymmetry::PrepareFitData(PRawRunData* runData, unsigned int histoNo[2]
double f, b, ef, eb;
// fill data time start, and step
// 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.fDataTimeStep = fTimeResolution*(double)fRunInfo->fPacking;
fData.SetDataTimeStart(fTimeResolution*((double)start[0]-t0[0]+(double)(fRunInfo->fPacking-1)/2.0));
fData.SetDataTimeStep(fTimeResolution*(double)fRunInfo->fPacking);
for (unsigned int i=0; i<noOfBins; i++) {
// to make the formulae more readable
f = forwardPacked.fValue[i];
b = backwardPacked.fValue[i];
ef = forwardPacked.fError[i];
eb = backwardPacked.fError[i];
f = forwardPacked.GetValue()->at(i);
b = backwardPacked.GetValue()->at(i);
ef = forwardPacked.GetError()->at(i);
eb = backwardPacked.GetError()->at(i);
// check that there are indeed bins
if (f+b != 0.0)
asym = (f-b) / (f+b);
else
asym = 0.0;
fData.fValue.push_back(asym);
fData.AppendValue(asym);
// calculate the error
if (f+b != 0.0)
error = 2.0/((f+b)*(f+b))*TMath::Sqrt(b*b*ef*ef+eb*eb*f*f);
else
error = 1.0;
fData.fError.push_back(error);
fData.AppendErrorValue(error);
}
// count the number of bins to be fitted
double time;
fNoOfFitBins=0;
for (unsigned int i=0; i<fData.fValue.size(); i++) {
time = fData.fDataTimeStart + (double)i * fData.fDataTimeStep;
for (unsigned int i=0; i<fData.GetValue()->size(); i++) {
time = fData.GetDataTimeStart() + (double)i * fData.GetDataTimeStep();
if ((time >= fFitStartTime) && (time <= fFitStopTime))
fNoOfFitBins++;
}
// clean up
forwardPacked.fValue.clear();
forwardPacked.fError.clear();
backwardPacked.fValue.clear();
backwardPacked.fError.clear();
fForward.clear();
fForwardErr.clear();
fBackward.clear();
@ -782,8 +780,8 @@ cout << endl;
*/
// 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 noOfBins1 = (runData->fDataBin[histoNo[1]].size()-start[1])/packing;
unsigned int noOfBins0 = (runData->GetDataBin(histoNo[0])->size()-start[0])/packing;
unsigned int noOfBins1 = (runData->GetDataBin(histoNo[1])->size()-start[1])/packing;
if (noOfBins0 > noOfBins1)
noOfBins0 = noOfBins1;
end[0] = start[0] + noOfBins0 * packing;
@ -798,17 +796,17 @@ cout << endl;
start[i] = keep;
}
// 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!";
return false;
}
// 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!";
return false;
}
// 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!";
return false;
}
@ -822,18 +820,18 @@ cout << endl;
// forward
for (int i=start[0]; i<end[0]; i++) {
if (packing == 1) {
forwardPacked.fValue.push_back(fForward[i]);
forwardPacked.fError.push_back(fForwardErr[i]);
forwardPacked.AppendValue(fForward[i]);
forwardPacked.AppendErrorValue(fForwardErr[i]);
} else { // packed data, i.e. packing > 1
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)
// the value is normalize to per bin
value /= packing;
forwardPacked.fValue.push_back(value);
forwardPacked.AppendValue(value);
if (value == 0.0)
forwardPacked.fError.push_back(1.0);
forwardPacked.AppendErrorValue(1.0);
else
forwardPacked.fError.push_back(TMath::Sqrt(error)/packing);
forwardPacked.AppendErrorValue(TMath::Sqrt(error)/packing);
value = 0.0;
error = 0.0;
}
@ -844,18 +842,18 @@ cout << endl;
// backward
for (int i=start[1]; i<end[1]; i++) {
if (packing == 1) {
backwardPacked.fValue.push_back(fBackward[i]);
backwardPacked.fError.push_back(fBackwardErr[i]);
backwardPacked.AppendValue(fBackward[i]);
backwardPacked.AppendErrorValue(fBackwardErr[i]);
} else { // packed data, i.e. packing > 1
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)
// the value is normalize to per bin
value /= packing;
backwardPacked.fValue.push_back(value);
backwardPacked.AppendValue(value);
if (value == 0.0)
backwardPacked.fError.push_back(1.0);
backwardPacked.AppendErrorValue(1.0);
else
backwardPacked.fError.push_back(TMath::Sqrt(error)/packing);
backwardPacked.AppendErrorValue(TMath::Sqrt(error)/packing);
value = 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
unsigned int noOfBins = forwardPacked.fValue.size();
if (forwardPacked.fValue.size() != backwardPacked.fValue.size()) {
if (forwardPacked.fValue.size() > backwardPacked.fValue.size())
noOfBins = backwardPacked.fValue.size();
unsigned int noOfBins = forwardPacked.GetValue()->size();
if (forwardPacked.GetValue()->size() != backwardPacked.GetValue()->size()) {
if (forwardPacked.GetValue()->size() > backwardPacked.GetValue()->size())
noOfBins = backwardPacked.GetValue()->size();
}
// form asymmetry including error propagation
@ -876,11 +874,11 @@ cout << endl;
double f, b, ef, eb, alpha = 1.0, beta = 1.0;
// fill data time start, and step
// data start at data_start-t0
fData.fDataTimeStart = fTimeResolution*((double)start[0]-t0[0]+(double)(packing-1)/2.0);
fData.fDataTimeStep = fTimeResolution*(double)packing;
fData.SetDataTimeStart(fTimeResolution*((double)start[0]-t0[0]+(double)(packing-1)/2.0));
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;
*/
@ -907,40 +905,36 @@ cout << endl << "--------------------------------" << endl;
}
//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
f = forwardPacked.fValue[i];
b = backwardPacked.fValue[i];
ef = forwardPacked.fError[i];
eb = backwardPacked.fError[i];
f = forwardPacked.GetValue()->at(i);
b = backwardPacked.GetValue()->at(i);
ef = forwardPacked.GetError()->at(i);
eb = backwardPacked.GetError()->at(i);
// check that there are indeed bins
if (f+b != 0.0)
asym = (alpha*f-b) / (alpha*beta*f+b);
else
asym = 0.0;
fData.fValue.push_back(asym);
fData.AppendValue(asym);
// calculate the error
if (f+b != 0.0)
error = 2.0/((f+b)*(f+b))*TMath::Sqrt(b*b*ef*ef+eb*eb*f*f);
else
error = 1.0;
fData.fError.push_back(error);
fData.AppendErrorValue(error);
}
// count the number of bins to be fitted
double time;
fNoOfFitBins=0;
for (unsigned int i=0; i<fData.fValue.size(); i++) {
time = fData.fDataTimeStart + (double)i * fData.fDataTimeStep;
for (unsigned int i=0; i<fData.GetValue()->size(); i++) {
time = fData.GetDataTimeStart() + (double)i * fData.GetDataTimeStep();
if ((time >= fFitStartTime) && (time <= fFitStopTime))
fNoOfFitBins++;
}
// clean up
forwardPacked.fValue.clear();
forwardPacked.fError.clear();
backwardPacked.fValue.clear();
backwardPacked.fError.clear();
fForward.clear();
fForwardErr.clear();
fBackward.clear();
@ -953,22 +947,22 @@ cout << endl << "--------------------------------" << endl;
}
// calculate theory
unsigned int size = runData->fDataBin[histoNo[0]].size();
unsigned int size = runData->GetDataBin(histoNo[0])->size();
double factor = 1.0;
if (fData.fValue.size() * 10 > runData->fDataBin[histoNo[0]].size()) {
size = fData.fValue.size() * 10;
factor = (double)runData->fDataBin[histoNo[0]].size() / (double)size;
if (fData.GetValue()->size() * 10 > runData->GetDataBin(histoNo[0])->size()) {
size = fData.GetValue()->size() * 10;
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;
fData.fTheoryTimeStart = fData.fDataTimeStart;
fData.fTheoryTimeStep = fTimeResolution*factor;
//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.SetTheoryTimeStart(fData.GetDataTimeStart());
fData.SetTheoryTimeStep(fTimeResolution*factor);
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);
if (fabs(value) > 10.0) { // dirty hack needs to be fixed!!
value = 0.0;
}
fData.fTheory.push_back(value);
fData.AppendTheoryValue(value);
}
// clean up

View File

@ -11,7 +11,7 @@
/***************************************************************************
* 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 *
* it under the terms of the GNU General Public License as published by *
@ -36,7 +36,7 @@
#include <TString.h>
#include <TObjArray.h>
#include <TObjString.h>
#include <TFile.h>
//#include <TFile.h>
#include <TFolder.h>
#include "TLemRunHeader.h"
@ -126,10 +126,6 @@ PRunBase::~PRunBase()
{
fParamNo.clear();
fData.fValue.clear();
fData.fError.clear();
fData.fTheory.clear();
fT0s.clear();
fFuncValues.clear();
@ -144,7 +140,6 @@ PRunBase::~PRunBase()
*/
void PRunBase::CleanUp()
{
//cout << endl << "PRunBase::CleanUp() ..." << endl;
if (fTheory) {
delete fTheory;
fTheory = 0;

View File

@ -11,7 +11,7 @@
/***************************************************************************
* 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 *
* 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()
{
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();
}
@ -116,7 +111,7 @@ PRawRunData* PRunDataHandler::GetRunData(const TString &runName)
UInt_t 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;
}
@ -193,7 +188,7 @@ Bool_t PRunDataHandler::ReadFile()
Bool_t PRunDataHandler::FileAlreadyRead(TString runName)
{
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;
}
}
@ -393,27 +388,26 @@ Bool_t PRunDataHandler::ReadRootFile(Bool_t notPostPileup)
// get run title
TObjString ostr = runHeader->GetRunTitle();
runData.fRunTitle = ostr.GetString();
runData.SetRunTitle(ostr.GetString());
// get temperature
runData.fTemp.resize(1);
runData.fTemp[0].first = runHeader->GetSampleTemperature();
runData.fTemp[0].second = runHeader->GetSampleTemperatureError();
runData.ClearTemperature();
runData.SetTemperature(0, runHeader->GetSampleTemperature(), runHeader->GetSampleTemperatureError());
// get field
runData.fField = runHeader->GetSampleBField();
runData.SetField(runHeader->GetSampleBField());
// get implantation energy
runData.fEnergy = runHeader->GetImpEnergy();
runData.SetEnergy(runHeader->GetImpEnergy());
// get moderator HV
runData.fTransport = runHeader->GetModeratorHV();
runData.SetTransport(runHeader->GetModeratorHV());
// get setup
runData.fSetup = runHeader->GetLemSetup().GetString();
runData.SetSetup(runHeader->GetLemSetup().GetString());
// get time resolution
runData.fTimeResolution = runHeader->GetTimeResolution();
runData.SetTimeResolution(runHeader->GetTimeResolution());
// get number of histogramms
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
// copy t0's so they are not lost
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
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
} 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
@ -442,21 +436,19 @@ Bool_t PRunDataHandler::ReadRootFile(Bool_t notPostPileup)
TObjString *os(dynamic_cast<TObjString*>(summIter.Next()));
TObjArray *oa(0);
TObjString *objTok(0);
while(os != 0){
while (os != 0) {
s = os->GetString();
// 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(runData.fRingAnode.empty() || runData.fRingAnode.size() == 2)
runData.fRingAnode.resize(2);
if (s.Contains("RA-L")) {
oa = s.Tokenize(" ");
TObjArrayIter lineIter(oa);
objTok = dynamic_cast<TObjString*>(lineIter.Next());
while (objTok != 0){
if(!objTok->GetString().CompareTo("RA-L")){
while (objTok != 0) {
if (!objTok->GetString().CompareTo("RA-L")) {
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
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;
}
}
@ -464,18 +456,16 @@ Bool_t PRunDataHandler::ReadRootFile(Bool_t notPostPileup)
}
}
if(s.Contains("RA-R")){
if(runData.fRingAnode.empty() || runData.fRingAnode.size() == 2)
runData.fRingAnode.resize(2);
if (s.Contains("RA-R")) {
oa = s.Tokenize(" ");
TObjArrayIter lineIter(oa);
objTok = dynamic_cast<TObjString*>(lineIter.Next());
while (objTok != 0){
if(!objTok->GetString().CompareTo("RA-R")){
if (!objTok->GetString().CompareTo("RA-R")) {
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
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;
}
}
@ -483,18 +473,16 @@ Bool_t PRunDataHandler::ReadRootFile(Bool_t notPostPileup)
}
}
if(s.Contains("RA-T")){
if(runData.fRingAnode.empty() || runData.fRingAnode.size() == 2)
runData.fRingAnode.resize(4);
if (s.Contains("RA-T")) {
oa = s.Tokenize(" ");
TObjArrayIter lineIter(oa);
objTok = dynamic_cast<TObjString*>(lineIter.Next());
while (objTok != 0){
if(!objTok->GetString().CompareTo("RA-T")){
if (!objTok->GetString().CompareTo("RA-T")) {
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
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;
}
}
@ -502,18 +490,16 @@ Bool_t PRunDataHandler::ReadRootFile(Bool_t notPostPileup)
}
}
if(s.Contains("RA-B")){
if(runData.fRingAnode.empty() || runData.fRingAnode.size() == 2)
runData.fRingAnode.resize(4);
if (s.Contains("RA-B")) {
oa = s.Tokenize(" ");
TObjArrayIter lineIter(oa);
objTok = dynamic_cast<TObjString*>(lineIter.Next());
while (objTok != 0){
if(!objTok->GetString().CompareTo("RA-B")){
if (!objTok->GetString().CompareTo("RA-B")) {
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
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;
}
}
@ -547,7 +533,7 @@ Bool_t PRunDataHandler::ReadRootFile(Bool_t notPostPileup)
for (Int_t j=1; j<histo->GetNbinsX(); j++)
histoData.push_back(histo->GetBinContent(j));
// store them in runData vector
runData.fDataBin.push_back(histoData);
runData.AppendDataBin(histoData);
// clear histoData for the next histo
histoData.clear();
}
@ -563,7 +549,7 @@ Bool_t PRunDataHandler::ReadRootFile(Bool_t notPostPileup)
for (Int_t j=1; j<histo->GetNbinsX(); j++)
histoData.push_back(histo->GetBinContent(j));
// store them in runData vector
runData.fDataBin.push_back(histoData);
runData.AppendDataBin(histoData);
// clear histoData for the next histo
histoData.clear();
}
@ -572,18 +558,11 @@ Bool_t PRunDataHandler::ReadRootFile(Bool_t notPostPileup)
f.Close();
// keep run name
runData.fRunName = fRunName;
runData.SetRunName(fRunName);
// add run to the run list
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;
}
@ -616,17 +595,6 @@ Bool_t PRunDataHandler::ReadWkmFile()
PDoubleVector histoData;
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
ifstream f;
@ -666,7 +634,7 @@ Bool_t PRunDataHandler::ReadWkmFile()
idx = line.Index(":");
line.Replace(0, idx+1, 0, 0); // remove 'Title:'
StripWhitespace(line);
runData.fRunTitle = line;
runData.SetRunTitle(line);
} else if (line.Contains("Field")) {
idx = line.Index(":");
line.Replace(0, idx+1, 0, 0); // remove 'Field:'
@ -676,12 +644,12 @@ Bool_t PRunDataHandler::ReadWkmFile()
line.Resize(idx);
dval = ToDouble(line, ok);
if (ok)
runData.fField = dval;
runData.SetField(dval);
} else if (line.Contains("Setup")) {
idx = line.Index(":");
line.Replace(0, idx+1, 0, 0); // remove 'Setup:'
StripWhitespace(line);
runData.fSetup = line;
runData.SetSetup(line);
} else if (line.Contains("Temp:") || line.Contains("Temp(meas1):")) {
linecp = line;
idx = line.Index(":");
@ -694,17 +662,15 @@ Bool_t PRunDataHandler::ReadWkmFile()
if (idx > 0)
line.Resize(idx);
dval = ToDouble(line, ok);
if (ok){
runData.fTemp.resize(1);
runData.fTemp[0].first = dval;
runData.fTemp[0].second = 0.0;
if (ok) {
runData.SetTemperature(0, dval, 0.0);
}
idx = linecp.Index("+/-"); // get the error
linecp.Replace(0, idx+3, 0, 0);
StripWhitespace(linecp);
dval = ToDouble(linecp, ok);
if (ok && !runData.fTemp.empty()){
runData.fTemp[0].second = dval;
if (ok) {
runData.SetTempError(0, dval);
}
} else if (line.Contains("Temp(meas2):")) {
linecp = line;
@ -718,17 +684,15 @@ Bool_t PRunDataHandler::ReadWkmFile()
if (idx > 0)
line.Resize(idx);
dval = ToDouble(line, ok);
if (ok){
runData.fTemp.resize(2);
runData.fTemp[1].first = dval;
runData.fTemp[1].second = 0.0;
if (ok) {
runData.SetTemperature(1, dval, 0.0);
}
idx = linecp.Index("+/-"); // get the error
linecp.Replace(0, idx+3, 0, 0);
StripWhitespace(linecp);
dval = ToDouble(linecp, ok);
if (ok && runData.fTemp.size() > 1){
runData.fTemp[1].second = dval;
if (ok) {
runData.SetTempError(1, dval);
}
} else if (line.Contains("Groups")) {
idx = line.Index(":");
@ -750,7 +714,7 @@ Bool_t PRunDataHandler::ReadWkmFile()
StripWhitespace(line);
dval = ToDouble(line, 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));
} 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 << " >> groups = " << groups;
cerr << endl << " >> channels = " << channels;
cerr << endl << " >> time resolution = " << runData.fTimeResolution;
cerr << endl << " >> time resolution = " << runData.GetTimeResolution();
cerr << endl;
f.close();
return false;
@ -777,7 +741,7 @@ Bool_t PRunDataHandler::ReadWkmFile()
do {
// check if empty line, i.e. new group
if (IsWhitespace(instr)) {
runData.fDataBin.push_back(histoData);
runData.AppendDataBin(histoData);
histoData.clear();
group_counter++;
} else {
@ -792,10 +756,6 @@ Bool_t PRunDataHandler::ReadWkmFile()
if (!tokens) { // no tokens found
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;
}
for (Int_t i=0; i<tokens->GetEntries(); i++) {
@ -807,9 +767,6 @@ Bool_t PRunDataHandler::ReadWkmFile()
} else {
cerr << endl << "PRunDataHandler::ReadWkmFile(): **ERROR** while reading data: data line contains non-integer values.";
// clean up
for (UInt_t i=0; i<group_counter; i++)
runData.fDataBin[i].clear();
runData.fDataBin.clear();
delete tokens;
return false;
}
@ -832,10 +789,6 @@ Bool_t PRunDataHandler::ReadWkmFile()
tokens = line.Tokenize(" ");
if (!tokens) { // no tokens found
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;
}
for (Int_t i=0; i<tokens->GetEntries(); i++) {
@ -847,9 +800,6 @@ Bool_t PRunDataHandler::ReadWkmFile()
} else {
cerr << endl << "PRunDataHandler::ReadWkmFile(): **ERROR** while reading data: data line contains non-integer values.";
// clean up
for (UInt_t i=0; i<group_counter; i++)
runData.fDataBin[i].clear();
runData.fDataBin.clear();
delete tokens;
return false;
}
@ -863,7 +813,7 @@ Bool_t PRunDataHandler::ReadWkmFile()
// save the last histo if not empty
if (histoData.size() > 0) {
runData.fDataBin.push_back(histoData);
runData.AppendDataBin(histoData);
histoData.clear();
}
@ -871,40 +821,27 @@ Bool_t PRunDataHandler::ReadWkmFile()
f.close();
// 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 << " expected " << groups << " histos, but found " << runData.fDataBin.size();
// clean up
for (UInt_t i=0; i<runData.fDataBin.size(); i++)
runData.fDataBin[i].clear();
runData.fDataBin.clear();
cerr << endl << " expected " << groups << " histos, but found " << runData.GetNoOfHistos();
return false;
}
// check if all groups have enough channels
for (UInt_t i=0; i<runData.fDataBin.size(); i++) {
if ((Int_t) runData.fDataBin[i].size() != channels) {
for (UInt_t i=0; i<runData.GetNoOfHistos(); i++) {
if ((Int_t) runData.GetDataBin(i)->size() != channels) {
cerr << endl << "PRunDataHandler::ReadWkmFile(): **ERROR**";
cerr << endl << " expected " << channels << " bins in histo " << i << ", but found " << runData.fDataBin[i].size();
// clean up
for (UInt_t j=0; j<runData.fDataBin.size(); j++)
runData.fDataBin[j].clear();
runData.fDataBin.clear();
cerr << endl << " expected " << channels << " bins in histo " << i << ", but found " << runData.GetDataBin(i)->size();
return false;
}
}
// keep run name
runData.fRunName = fRunName;
runData.SetRunName(fRunName);
// add run to the run list
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;
}
@ -963,42 +900,37 @@ Bool_t PRunDataHandler::ReadPsiBinFile()
PRawRunData runData;
Double_t dval;
// keep run name
runData.fRunName = fRunName;
runData.SetRunName(fRunName);
// 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
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...
runData.fEnergy = -999.0;
runData.fTransport = -999.0;
runData.fRingAnode.clear();
runData.SetEnergy(PMUSR_UNDEFINED);
runData.SetTransport(PMUSR_UNDEFINED);
// get field
status = sscanf(psiBin.get_field().c_str(), "%lfG", &dval);
if (status == 1)
runData.fField = dval;
runData.SetField(dval);
// get temperature
PDoubleVector tempVec(psiBin.get_temperatures_vector());
PDoubleVector tempDevVec(psiBin.get_devTemperatures_vector());
if(tempVec.size() > 1 && tempDevVec.size() > 1 && tempVec[0] && tempVec[1]) {
runData.fTemp.resize(2);
if ((tempVec.size() > 1) && (tempDevVec.size() > 1) && tempVec[0] && tempVec[1]) {
// 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..."
for (UInt_t i(0); i<2; i++){
runData.fTemp[i].first = tempVec[i];
runData.fTemp[i].second = tempDevVec[i];
for (UInt_t i(0); i<2; i++) {
runData.SetTemperature(i, tempVec[i], tempDevVec[i]);
}
tempVec.clear();
tempDevVec.clear();
} else {
status = sscanf(psiBin.get_temp().c_str(), "%lfK", &dval);
if (status == 1)
runData.fTemp.resize(1);
runData.fTemp[0].first = dval;
runData.fTemp[0].second = 0.0;
runData.SetTemperature(0, dval, 0.0);
}
// get time resolution (ns)
runData.fTimeResolution = psiBin.get_binWidth_ns();
runData.SetTimeResolution(psiBin.get_binWidth_ns());
// get t0's
ivec = psiBin.get_t0_vector();
if (ivec.empty()) {
@ -1007,7 +939,7 @@ Bool_t PRunDataHandler::ReadPsiBinFile()
return false;
}
for (UInt_t i=0; i<ivec.size(); i++)
runData.fT0s.push_back(ivec[i]);
runData.AppendT0(ivec[i]);
// fill raw data
PDoubleVector histoData;
@ -1018,19 +950,13 @@ Bool_t PRunDataHandler::ReadPsiBinFile()
histoData.push_back(histo[j]);
}
delete histo;
runData.fDataBin.push_back(histoData);
runData.AppendDataBin(histoData);
histoData.clear();
}
// add run to the run list
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;
}
@ -1062,7 +988,7 @@ Bool_t PRunDataHandler::ReadMudFile()
// read necessary header information
// keep run name
runData.fRunName = fRunName;
runData.SetRunName(fRunName);
// get run title
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;
}
runData.fRunTitle = TString(str);
runData.SetRunTitle(TString(str));
// get setup
TString setup;
success = MUD_getLab( fh, str, sizeof(str) );
if (success) {
runData.fSetup = TString(str) + TString("/");
setup = TString(str) + TString("/");
}
success = MUD_getArea( fh, str, sizeof(str) );
if (success) {
runData.fSetup += TString(str) + TString("/");
setup += TString(str) + TString("/");
}
success = MUD_getApparatus( fh, str, sizeof(str) );
if (success) {
runData.fSetup += TString(str) + TString("/");
setup += TString(str) + TString("/");
}
success = MUD_getSample( fh, str, sizeof(str) );
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...
runData.fEnergy = -999.0;
runData.fTransport = -999.0;
runData.fRingAnode.clear();
runData.SetEnergy(PMUSR_UNDEFINED);
runData.SetTransport(PMUSR_UNDEFINED);
// get field
success = MUD_getField( fh, str, sizeof(str) );
if (success) {
success = sscanf(str, "%lf G", &dval);
if (success == 1) {
runData.fField = dval;
runData.SetField(dval);
} else {
runData.fField = -9.9e99;
runData.SetField(PMUSR_UNDEFINED);
}
} else {
runData.fField = -9.9e99;
runData.SetField(PMUSR_UNDEFINED);
}
// get temperature
success = MUD_getTemperature( fh, str, sizeof(str) );
if (success) {
runData.fTemp.resize(1);
success = sscanf(str, "%lf K", &dval);
if (success == 1) {
runData.fTemp[0].first = dval;
runData.fTemp[0].second = 0.0;
runData.SetTemperature(0, dval, 0.0);
} else {
runData.fTemp[0].first = -9.9e99;
runData.fTemp[0].second = 0.0;
runData.SetTemperature(0, PMUSR_UNDEFINED, 0.0);
}
} else {
runData.fTemp[0].first = -9.9e99;
runData.fTemp[0].second = 0.0;
runData.SetTemperature(0, PMUSR_UNDEFINED, 0.0);
}
// 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
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;
}
runData.fT0s.push_back((Int_t)val);
runData.AppendT0((Int_t)val);
// get bkg bins
success = MUD_getHistBkgd1( fh, i, &val );
@ -1199,9 +1122,7 @@ Bool_t PRunDataHandler::ReadMudFile()
valPair.second = (Int_t)val;
if ((valPair.first != -1) && (valPair.second != -1)) { // bkg bin1 && bkg bin2 found
runData.fBkgBin.push_back(valPair);
} else {
runData.fBkgBin.clear();
runData.AppendBkgBin(valPair);
}
// get good data bins
@ -1223,9 +1144,7 @@ Bool_t PRunDataHandler::ReadMudFile()
valPair.second = (Int_t)val;
if ((valPair.first != -1) && (valPair.second != -1)) { // good bin1 && good bin2 found
runData.fGoodDataBin.push_back(valPair);
} else {
runData.fGoodDataBin.clear();
runData.AppendGoodDataBin(valPair);
}
// get number of bins
@ -1261,7 +1180,7 @@ Bool_t PRunDataHandler::ReadMudFile()
for (UInt_t j=0; j<noOfBins; j++) {
histoData.push_back(pData[j]);
}
runData.fDataBin.push_back(histoData);
runData.AppendDataBin(histoData);
histoData.clear();
free(pData);
@ -1289,12 +1208,6 @@ cout << endl;
// add run to the run list
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;
}
@ -1353,11 +1266,11 @@ Bool_t PRunDataHandler::ReadAsciiFile()
PRawRunData runData;
// init some stuff
runData.fDataNonMusr.fFromAscii = true;
runData.fDataNonMusr.fLabels.push_back("??"); // x default label
runData.fDataNonMusr.fLabels.push_back("??"); // y default label
runData.fDataNonMusr.SetFromAscii(true);
runData.fDataNonMusr.AppendLabel("??"); // x 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;
Char_t instr[512];
@ -1400,9 +1313,9 @@ Bool_t PRunDataHandler::ReadAsciiFile()
workStr = line;
workStr.Remove(TString::kLeading, ' '); // remove spaces from the beining
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)) {
runData.fSetup = TString(workStr.Data()+workStr.First(":")+2);
runData.SetSetup(TString(workStr.Data()+workStr.First(":")+2));
} else if (workStr.BeginsWith("field:", TString::kIgnoreCase)) {
workStr = TString(workStr.Data()+workStr.First(":")+2);
if (!workStr.IsFloat()) {
@ -1411,11 +1324,11 @@ Bool_t PRunDataHandler::ReadAsciiFile()
success = false;
break;
}
runData.fField = workStr.Atof();
runData.SetField(workStr.Atof());
} 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)) {
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)) {
workStr = TString(workStr.Data()+workStr.First(":")+2);
if (!workStr.IsFloat()) {
@ -1424,9 +1337,7 @@ Bool_t PRunDataHandler::ReadAsciiFile()
success = false;
break;
}
runData.fTemp.resize(1);
runData.fTemp[0].first = workStr.Atof();
runData.fTemp[0].second = 0.0;
runData.SetTemperature(0, workStr.Atof(), 0.0);
} else if (workStr.BeginsWith("energy:", TString::kIgnoreCase)) {
workStr = TString(workStr.Data()+workStr.First(":")+2);
if (!workStr.IsFloat()) {
@ -1435,9 +1346,8 @@ Bool_t PRunDataHandler::ReadAsciiFile()
success = false;
break;
}
runData.fEnergy = workStr.Atof();
runData.fTransport = -999.0; // just to initialize the variables to some "meaningful" value
runData.fRingAnode.clear();
runData.SetEnergy(workStr.Atof());
runData.SetTransport(PMUSR_UNDEFINED); // just to initialize the variables to some "meaningful" value
} else { // error
cerr << endl << "PRunDataHandler::ReadAsciiFile **ERROR** line no " << lineNo << ", illegal header line.";
cerr << endl;
@ -1516,10 +1426,10 @@ Bool_t PRunDataHandler::ReadAsciiFile()
f.close();
// keep values
runData.fDataNonMusr.fData.push_back(xVec);
runData.fDataNonMusr.fErrData.push_back(exVec);
runData.fDataNonMusr.fData.push_back(yVec);
runData.fDataNonMusr.fErrData.push_back(eyVec);
runData.fDataNonMusr.AppendData(xVec);
runData.fDataNonMusr.AppendErrData(exVec);
runData.fDataNonMusr.AppendData(yVec);
runData.fDataNonMusr.AppendErrData(eyVec);
fData.push_back(runData);
@ -1528,8 +1438,6 @@ Bool_t PRunDataHandler::ReadAsciiFile()
exVec.clear();
yVec.clear();
eyVec.clear();
runData.fDataNonMusr.fData.clear();
runData.fDataNonMusr.fErrData.clear();
return success;
}
@ -1660,7 +1568,7 @@ Bool_t PRunDataHandler::ReadDBFile()
PRawRunData runData;
runData.fDataNonMusr.fFromAscii = false;
runData.fDataNonMusr.SetFromAscii(false);
Int_t lineNo = 0;
Int_t idx;
@ -1712,7 +1620,7 @@ Bool_t PRunDataHandler::ReadDBFile()
tokens = workStr.Tokenize(" ,\t");
for (Int_t i=1; i<tokens->GetEntries(); i++) {
ostr = dynamic_cast<TObjString*>(tokens->At(i));
runData.fDataNonMusr.fDataTags.push_back(ostr->GetString());
runData.fDataNonMusr.AppendDataTag(ostr->GetString());
}
// clean up tokens
@ -1725,7 +1633,7 @@ Bool_t PRunDataHandler::ReadDBFile()
switch (dbTag) {
case 0: // TITLE
runData.fRunTitle = workStr;
runData.SetRunTitle(workStr);
break;
case 1: // ABSTRACT
// nothing to be done for now
@ -1734,7 +1642,7 @@ Bool_t PRunDataHandler::ReadDBFile()
// nothing to be done for now
break;
case 3: // LABEL
runData.fDataNonMusr.fLabels.push_back(workStr);
runData.fDataNonMusr.AppendLabel(workStr);
break;
case 4: // DATA
// filter out potential start data tag
@ -1763,9 +1671,9 @@ Bool_t PRunDataHandler::ReadDBFile()
// prepare data vector for use
PDoubleVector dummy;
for (UInt_t i=0; i<runData.fDataNonMusr.fDataTags.size(); i++) {
runData.fDataNonMusr.fData.push_back(dummy);
runData.fDataNonMusr.fErrData.push_back(dummy);
for (UInt_t i=0; i<runData.fDataNonMusr.GetDataTags()->size(); i++) {
runData.fDataNonMusr.AppendData(dummy);
runData.fDataNonMusr.AppendErrData(dummy);
}
firstData = false;
@ -1776,7 +1684,7 @@ Bool_t PRunDataHandler::ReadDBFile()
const Char_t *str = workStr.Data();
if (isdigit(str[0])) { // run line
TString run("run");
idx = GetDataTagIndex(run, runData.fDataNonMusr.fDataTags);
idx = GetDataTagIndex(run, runData.fDataNonMusr.GetDataTags());
if (idx == -1) {
cerr << endl << "PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo << ":";
cerr << endl << ">> " << workStr.Data();
@ -1796,8 +1704,8 @@ Bool_t PRunDataHandler::ReadDBFile()
return false;
}
val = tstr.Atof();
runData.fDataNonMusr.fData[idx].push_back(val);
runData.fDataNonMusr.fErrData[idx].push_back(1.0);
runData.fDataNonMusr.AppendSubData(idx, val);
runData.fDataNonMusr.AppendSubErrData(idx, 1.0);
} else { // tag = data line
// remove all possible spaces
workStr.ReplaceAll(" ", "");
@ -1812,7 +1720,7 @@ Bool_t PRunDataHandler::ReadDBFile()
}
ostr = dynamic_cast<TObjString*>(tokens->At(0));
tstr = ostr->GetString();
idx = GetDataTagIndex(tstr, runData.fDataNonMusr.fDataTags);
idx = GetDataTagIndex(tstr, runData.fDataNonMusr.GetDataTags());
if (idx == -1) {
cerr << endl << "PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo << ":";
cerr << endl << ">> " << workStr.Data();
@ -1834,8 +1742,8 @@ Bool_t PRunDataHandler::ReadDBFile()
return false;
}
val = tstr.Atof();
runData.fDataNonMusr.fData[idx].push_back(val);
runData.fDataNonMusr.fErrData[idx].push_back(1.0);
runData.fDataNonMusr.AppendSubData(idx, val);
runData.fDataNonMusr.AppendSubErrData(idx, 1.0);
break;
case 4: // tag = val,err,,
case 5: // tag = val,err1,err2,
@ -1851,7 +1759,7 @@ Bool_t PRunDataHandler::ReadDBFile()
return false;
}
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)
ostr = dynamic_cast<TObjString*>(tokens->At(2));
tstr = ostr->GetString();
@ -1864,7 +1772,7 @@ Bool_t PRunDataHandler::ReadDBFile()
return false;
}
val = tstr.Atof();
runData.fDataNonMusr.fErrData[idx].push_back(val);
runData.fDataNonMusr.AppendSubErrData(idx, val);
break;
default:
cerr << endl << "PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo << ":";
@ -1879,11 +1787,11 @@ Bool_t PRunDataHandler::ReadDBFile()
} else { // handle row formated data
// split string in tokens
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 << ">> " << workStr.Data();
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,...";
delete tokens;
return false;
@ -1902,15 +1810,15 @@ Bool_t PRunDataHandler::ReadDBFile()
delete tokens;
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)
ostr = dynamic_cast<TObjString*>(tokens->At(i+1));
tstr = ostr->GetString();
if (tstr.IsWhitespace()) {
runData.fDataNonMusr.fErrData[j].push_back(1.0);
runData.fDataNonMusr.AppendSubErrData(j, 1.0);
} else if (tstr.IsFloat()) {
runData.fDataNonMusr.fErrData[j].push_back(tstr.Atof());
runData.fDataNonMusr.AppendSubErrData(j, tstr.Atof());
} else {
cerr << endl << "PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo << ":";
cerr << endl << ">> " << workStr.Data();
@ -1931,10 +1839,10 @@ Bool_t PRunDataHandler::ReadDBFile()
f.close();
// 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 << ">> number of LABELS found = " << runData.fDataNonMusr.fLabels.size();
cerr << endl << ">> number of Data tags found = " << runData.fDataNonMusr.fDataTags.size();
cerr << endl << ">> number of LABELS found = " << runData.fDataNonMusr.GetLabels()->size();
cerr << endl << ">> number of Data tags found = " << runData.fDataNonMusr.GetDataTags()->size();
cerr << endl << ">> They have to be equal!!";
if (tokens) {
delete tokens;
@ -1944,19 +1852,19 @@ Bool_t PRunDataHandler::ReadDBFile()
}
// check if all vectors have the same size
for (UInt_t i=1; i<runData.fDataNonMusr.fData.size(); i++) {
if (runData.fDataNonMusr.fData[i].size() != runData.fDataNonMusr.fData[i-1].size()) {
for (UInt_t i=1; i<runData.fDataNonMusr.GetData()->size(); i++) {
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 << ">> label: " << runData.fDataNonMusr.fDataTags[i-1].Data() << ", number data elements = " << runData.fDataNonMusr.fData[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-1).Data() << ", number data elements = " << runData.fDataNonMusr.GetData()->at(i-1).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!!";
success = false;
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 << ">> label: " << runData.fDataNonMusr.fDataTags[i-1].Data() << ", number data elements = " << runData.fDataNonMusr.fData[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-1).Data() << ", number data elements = " << runData.fDataNonMusr.GetData()->at(i-1).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!!";
success = false;
break;
@ -1970,7 +1878,7 @@ Bool_t PRunDataHandler::ReadDBFile()
}
// keep run name
runData.fRunName = fRunName;
runData.SetRunName(fRunName);
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
*/
Int_t PRunDataHandler::GetDataTagIndex(TString &str, PStringVector &dataTags)
Int_t PRunDataHandler::GetDataTagIndex(TString &str, const PStringVector* dataTags)
{
Int_t result = -1;
// check all the other possible data tags
for (UInt_t i=0; i<dataTags.size(); i++) {
if (!dataTags[i].CompareTo(str, TString::kIgnoreCase)) {
for (UInt_t i=0; i<dataTags->size(); i++) {
if (!dataTags->at(i).CompareTo(str, TString::kIgnoreCase)) {
result = i;
break;
}

View File

@ -441,9 +441,9 @@ PRunData* PRunListCollection::GetNonMusr(unsigned int index, EDataSwitch tag)
*
* \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
{
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
{
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
{
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;
if (runData->fDataNonMusr.fFromAscii) {
result = runData->fDataNonMusr.fLabels[0].Data();
if (runData->fDataNonMusr.FromAscii()) {
result = runData->fDataNonMusr.GetLabels()->at(0).Data();
} else {
for (unsigned int i=0; i<fRunNonMusrList.size(); i++) {
if (fRunNonMusrList[i]->GetRunNo() == idx) {
int index = fRunNonMusrList[i]->GetXIndex();
result = runData->fDataNonMusr.fLabels[index].Data();
result = runData->fDataNonMusr.GetLabels()->at(index).Data();
break;
}
}
@ -537,13 +537,13 @@ const char* PRunListCollection::GetYAxisTitle(const TString &runName, const unsi
const char *result = 0;
if (runData->fDataNonMusr.fFromAscii) {
result = runData->fDataNonMusr.fLabels[1].Data();
if (runData->fDataNonMusr.FromAscii()) {
result = runData->fDataNonMusr.GetLabels()->at(1).Data();
} else {
for (unsigned int i=0; i<fRunNonMusrList.size(); i++) {
if (fRunNonMusrList[i]->GetRunNo() == idx) {
int index = fRunNonMusrList[i]->GetYIndex();
result = runData->fDataNonMusr.fLabels[index].Data();
result = runData->fDataNonMusr.GetLabels()->at(index).Data();
break;
}
}

View File

@ -11,7 +11,7 @@
/***************************************************************************
* 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 *
* 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
double x;
for (unsigned int i=0; i<fData.fValue.size(); i++) {
x = fData.fX[i];
for (unsigned int i=0; i<fData.GetValue()->size(); i++) {
x = fData.GetX()->at(i);
if ((x>=fFitStartTime) && (x<=fFitStopTime)) {
diff = fData.fValue[i] - fTheory->Func(x, par, fFuncValues);
chisq += diff*diff / (fData.fError[i]*fData.fError[i]);
diff = fData.GetValue()->at(i) - fTheory->Func(x, par, fFuncValues);
chisq += diff*diff / (fData.GetError()->at(i)*fData.GetError()->at(i));
}
}
@ -195,24 +195,24 @@ bool PRunNonMusr::PrepareFitData()
double value = 0.0;
double err = 0.0;
// 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;
if (fRunInfo->fPacking == 1) {
fData.fX.push_back(fRawRunData->fDataNonMusr.fData[xIndex][i]);
fData.fValue.push_back(fRawRunData->fDataNonMusr.fData[yIndex][i]);
fData.fError.push_back(fRawRunData->fDataNonMusr.fErrData[yIndex][i]);
fData.AppendXValue(fRawRunData->fDataNonMusr.GetData()->at(xIndex).at(i));
fData.AppendValue(fRawRunData->fDataNonMusr.GetData()->at(yIndex).at(i));
fData.AppendErrorValue(fRawRunData->fDataNonMusr.GetErrData()->at(yIndex).at(i));
} else { // packed data, i.e. fRunInfo->fPacking > 1
if ((i % fRunInfo->fPacking == 0) && (i != 0)) { // fill data
// 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.fValue.push_back(value);
fData.fError.push_back(TMath::Sqrt(err));
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.AppendValue(value);
fData.AppendErrorValue(TMath::Sqrt(err));
value = 0.0;
err = 0.0;
}
// sum raw data values
value += fRawRunData->fDataNonMusr.fData[yIndex][i];
err += fRawRunData->fDataNonMusr.fErrData[yIndex][i]*fRawRunData->fDataNonMusr.fErrData[yIndex][i];
value += fRawRunData->fDataNonMusr.GetData()->at(yIndex).at(i);
err += fRawRunData->fDataNonMusr.GetErrData()->at(yIndex).at(i)*fRawRunData->fDataNonMusr.GetErrData()->at(yIndex).at(i);
}
}
// cout << endl << ">> fData.fValue.size()=" << fData.fValue.size();
@ -220,8 +220,8 @@ bool PRunNonMusr::PrepareFitData()
// count the number of bins to be fitted
fNoOfFitBins=0;
double x;
for (unsigned int i=0; i<fData.fValue.size(); i++) {
x = fData.fX[i];
for (unsigned int i=0; i<fData.GetValue()->size(); i++) {
x = fData.GetX()->at(i);
if ((x >= fFitStartTime) && (x <= fFitStopTime))
fNoOfFitBins++;
}
@ -253,30 +253,30 @@ bool PRunNonMusr::PrepareViewData()
double value = 0.0;
double err = 0.0;
// 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;
if (fRunInfo->fPacking == 1) {
fData.fX.push_back(fRawRunData->fDataNonMusr.fData[xIndex][i]);
fData.fValue.push_back(fRawRunData->fDataNonMusr.fData[yIndex][i]);
fData.fError.push_back(fRawRunData->fDataNonMusr.fErrData[yIndex][i]);
fData.AppendXValue(fRawRunData->fDataNonMusr.GetData()->at(xIndex).at(i));
fData.AppendValue(fRawRunData->fDataNonMusr.GetData()->at(yIndex).at(i));
fData.AppendErrorValue(fRawRunData->fDataNonMusr.GetErrData()->at(yIndex).at(i));
} else { // packed data, i.e. fRunInfo->fPacking > 1
if ((i % fRunInfo->fPacking == 0) && (i != 0)) { // fill data
// 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.fValue.push_back(value);
fData.fError.push_back(TMath::Sqrt(err));
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.AppendValue(value);
fData.AppendErrorValue(TMath::Sqrt(err));
value = 0.0;
err = 0.0;
}
// sum raw data values
value += fRawRunData->fDataNonMusr.fData[yIndex][i];
err += fRawRunData->fDataNonMusr.fErrData[yIndex][i]*fRawRunData->fDataNonMusr.fErrData[yIndex][i];
value += fRawRunData->fDataNonMusr.GetData()->at(yIndex).at(i);
err += fRawRunData->fDataNonMusr.GetErrData()->at(yIndex).at(i)*fRawRunData->fDataNonMusr.GetErrData()->at(yIndex).at(i);
}
}
// cout << endl << ">> fData.fValue.size()=" << fData.fValue.size();
// count the number of bins to be fitted
fNoOfFitBins = fData.fValue.size();
fNoOfFitBins = fData.GetValue()->size();
// cout << endl << ">> fNoOfFitBins=" << fNoOfFitBins;
// 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
double xStep;
if (fData.fX.size() > 1000.0)
xStep = (xMax-xMin)/fData.fX.size();
if (fData.GetX()->size() > 1000.0)
xStep = (xMax-xMin)/fData.GetX()->size();
else
xStep = (xMax-xMin)/1000.0;
double xx = xAbsMin;
do {
// fill x-vector
fData.fXTheory.push_back(xx);
fData.AppendXTheoryValue(xx);
// fill y-vector
fData.fTheory.push_back(fTheory->Func(xx, par, fFuncValues));
fData.AppendTheoryValue(fTheory->Func(xx, par, fFuncValues));
// calculate next xx
xx += xStep;
} while (xx < xAbsMax);
@ -375,7 +375,7 @@ unsigned int PRunNonMusr::GetXIndex()
bool found = false;
//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";
index = 0;
found = true;
@ -387,8 +387,8 @@ unsigned int PRunNonMusr::GetXIndex()
found = true;
} else { // xy-data data tags which needs to be converted to an index
//cout << endl << ">> fDataTags.size()=" << fRawRunData->fDataNonMusr.fDataTags.size();
for (unsigned int i=0; i<fRawRunData->fDataNonMusr.fDataTags.size(); i++) {
if (fRawRunData->fDataNonMusr.fDataTags[i].CompareTo(fRunInfo->fXYDataLabel[0]) == 0) {
for (unsigned int i=0; i<fRawRunData->fDataNonMusr.GetDataTags()->size(); i++) {
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 << ">> fRunInfo->fXYDataLabel[0]=" << fRunInfo->fXYDataLabel[0].Data();
index = i;
@ -421,7 +421,7 @@ unsigned int PRunNonMusr::GetYIndex()
bool found = false;
// cout << endl << ">> PRunNonMusr::GetYIndex:";
if (fRawRunData->fDataNonMusr.fFromAscii) { // ascii-file format
if (fRawRunData->fDataNonMusr.FromAscii()) { // ascii-file format
index = 1;
found = true;
} else { // db-file format
@ -429,8 +429,8 @@ unsigned int PRunNonMusr::GetYIndex()
index = fRunInfo->fXYDataIndex[1]-1; // since xy-data start with 1 ...
found = true;
} else { // xy-data data tags which needs to be converted to an index
for (unsigned int i=0; i<fRawRunData->fDataNonMusr.fDataTags.size(); i++) {
if (fRawRunData->fDataNonMusr.fDataTags[i].CompareTo(fRunInfo->fXYDataLabel[1]) == 0) {
for (unsigned int i=0; i<fRawRunData->fDataNonMusr.GetDataTags()->size(); i++) {
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 << ">> fRunInfo->fXYDataLabel[1]=" << fRunInfo->fXYDataLabel[1].Data();
index = i;

View File

@ -11,7 +11,7 @@
/***************************************************************************
* 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 *
* 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
double time;
for (unsigned int i=0; i<fData.fValue.size(); i++) {
time = fData.fDataTimeStart + (double)i*fData.fDataTimeStep;
for (unsigned int i=0; i<fData.GetValue()->size(); i++) {
time = fData.GetDataTimeStart() + (double)i*fData.GetDataTimeStep();
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);
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;
if (firstTime < 4) {
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 << "----";
}
@ -212,14 +212,14 @@ double PRunSingleHisto::CalcMaxLikelihood(const std::vector<double>& par)
double theo;
double data;
double time;
for (unsigned int i=0; i<fData.fValue.size(); i++) {
time = fData.fDataTimeStart + (double)i*fData.fDataTimeStep;
for (unsigned int i=0; i<fData.GetValue()->size(); i++) {
time = fData.GetDataTimeStart() + (double)i*fData.GetDataTimeStep();
if ((time>=fFitStartTime) && (time<=fFitStopTime)) {
// calculate theory for the given parameter set
theo = N0*TMath::Exp(-time/tau)*(1+fTheory->Func(time, par, fFuncValues))+bkg;
// check if data value is not too small
if (fData.fValue[i] > 1.0e-9)
data = fData.fValue[i];
if (fData.GetValue()->at(i) > 1.0e-9)
data = fData.GetValue()->at(i);
else
data = 1.0e-9;
// add maximum log likelihood contribution of bin i
@ -282,13 +282,13 @@ void PRunSingleHisto::CalcTheory()
}
// calculate theory
unsigned int size = fData.fValue.size();
double start = fData.fDataTimeStart;
double resolution = fData.fDataTimeStep;
unsigned int size = fData.GetValue()->size();
double start = fData.GetDataTimeStart();
double resolution = fData.GetDataTimeStep();
double time;
for (unsigned int i=0; i<size; i++) {
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
@ -318,9 +318,9 @@ bool PRunSingleHisto::PrepareData()
unsigned int histoNo;
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 << " 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;
return false;
@ -329,10 +329,10 @@ bool PRunSingleHisto::PrepareData()
// check if the t0's are given 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
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
// 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!
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();
@ -340,12 +340,12 @@ bool PRunSingleHisto::PrepareData()
}
} else { // t0's in the msr-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
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 << " 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;
}
@ -355,7 +355,7 @@ bool PRunSingleHisto::PrepareData()
// check if t0 is within proper bounds
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!";
return false;
}
@ -377,10 +377,10 @@ bool PRunSingleHisto::PrepareData()
// check if the t0's are given 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
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
// 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!
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();
@ -388,12 +388,12 @@ bool PRunSingleHisto::PrepareData()
}
} else { // t0's in the msr-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
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 << " 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 << " addrun: " << fRunInfo->fRunName[i].Data();
cout << endl;
@ -412,17 +412,17 @@ bool PRunSingleHisto::PrepareData()
}
// 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
if ((j-t0Add+t0 >= 0) && (j-t0Add+t0 < addRunData->fDataBin[histoNo].size())) {
runData->fDataBin[histoNo][j] += addRunData->fDataBin[histoNo][j-t0Add+t0];
if ((j-t0Add+t0 >= 0) && (j-t0Add+t0 < addRunData->GetDataBin(histoNo)->size())) {
runData->AddDataBin(histoNo, j, addRunData->GetDataBin(histoNo)->at(j-t0Add+t0));
}
}
}
}
// keep the time resolution in (us)
fTimeResolution = runData->fTimeResolution/1.0e3;
fTimeResolution = runData->GetTimeResolution()/1.0e3;
if (fHandleTag == kFit)
success = PrepareFitData(runData, histoNo);
@ -466,12 +466,12 @@ bool PRunSingleHisto::PrepareFitData(PRawRunData* runData, const unsigned int hi
start = keep;
}
// 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!";
return false;
}
// 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!";
return false;
}
@ -497,42 +497,42 @@ bool PRunSingleHisto::PrepareFitData(PRawRunData* runData, const unsigned int hi
double normalizer = 1.0;
// data start at data_start-t0
// 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.fDataTimeStep = fTimeResolution*fRunInfo->fPacking;
fData.SetDataTimeStart(fTimeResolution*((double)start-(double)t0+(double)(fRunInfo->fPacking-1)/2.0));
fData.SetDataTimeStep(fTimeResolution*fRunInfo->fPacking);
for (int i=start; i<end; i++) {
if (fRunInfo->fPacking == 1) {
value = runData->fDataBin[histoNo][i];
value = runData->GetDataBin(histoNo)->at(i);
normalizer = fRunInfo->fPacking * (fTimeResolution * 1e3); // fTimeResolution us->ns
value /= normalizer;
fData.fValue.push_back(value);
fData.AppendValue(value);
if (value == 0.0)
fData.fError.push_back(1.0);
fData.AppendErrorValue(1.0);
else
fData.fError.push_back(TMath::Sqrt(value));
fData.AppendErrorValue(TMath::Sqrt(value));
} else { // packed data, i.e. fRunInfo->fPacking > 1
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)
// the value is normalize to per 1 nsec
normalizer = fRunInfo->fPacking * (fTimeResolution * 1e3); // fTimeResolution us->ns
value /= normalizer;
fData.fValue.push_back(value);
fData.AppendValue(value);
if (value == 0.0)
fData.fError.push_back(1.0);
fData.AppendErrorValue(1.0);
else
fData.fError.push_back(TMath::Sqrt(value/normalizer));
fData.AppendErrorValue(TMath::Sqrt(value/normalizer));
// reset values
value = 0.0;
}
value += runData->fDataBin[histoNo][i];
value += runData->GetDataBin(histoNo)->at(i);
}
}
// count the number of bins to be fitted
fNoOfFitBins=0;
double time;
//cout << endl << ">> size=" << fData.fValue.size() << ", fDataTimeStart=" << fData.fDataTimeStart << ", fDataTimeStep=" << fData.fDataTimeStep << ", fFitStartTime=" << fFitStartTime << ", fFitStopTime=" << fFitStopTime;
for (unsigned int i=0; i<fData.fValue.size(); i++) {
time = fData.fDataTimeStart + (double)i*fData.fDataTimeStep;
//cout << endl << ">> size=" << fData.GetValue()->size() << ", fDataTimeStart=" << fData.GetDataTimeStart() << ", fDataTimeStep=" << fData.GetDataTimeStep() << ", fFitStartTime=" << fFitStartTime << ", fFitStopTime=" << fFitStopTime;
for (unsigned int i=0; i<fData.GetValue()->size(); i++) {
time = fData.GetDataTimeStart() + (double)i*fData.GetDataTimeStep();
if ((time >= fFitStartTime) && (time <= fFitStopTime))
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
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
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
// 1st check if start and end are in proper order
if (end < start) { // need to swap them
@ -568,12 +568,12 @@ bool PRunSingleHisto::PrepareRawViewData(PRawRunData* runData, const unsigned in
start = keep;
}
// 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!";
return false;
}
// 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!";
return false;
}
@ -583,13 +583,13 @@ bool PRunSingleHisto::PrepareRawViewData(PRawRunData* runData, const unsigned in
double value = 0.0;
// data start at data_start-t0
// 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.fDataTimeStep = fTimeResolution*packing;
fData.SetDataTimeStart(fTimeResolution*((double)start-(double)t0+(double)(packing-1)/2.0));
fData.SetDataTimeStep(fTimeResolution*packing);
/*
cout << endl << ">> time resolution = " << fTimeResolution;
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;
@ -599,23 +599,23 @@ cout << endl << ">> data start time = " << fData.fDataTimeStart;
// the value is normalize to per 1 nsec
normalizer = packing * (fTimeResolution * 1e3); // fTimeResolution us->ns
value /= normalizer;
fData.fValue.push_back(value);
fData.AppendValue(value);
if (value == 0.0)
fData.fError.push_back(1.0);
fData.AppendErrorValue(1.0);
else
fData.fError.push_back(TMath::Sqrt(value/normalizer));
fData.AppendErrorValue(TMath::Sqrt(value/normalizer));
// reset values
value = 0.0;
}
value += runData->fDataBin[histoNo][i];
value += runData->GetDataBin(histoNo)->at(i);
}
// count the number of bins
fNoOfFitBins=0;
double time;
for (unsigned int i=0; i<fData.fValue.size(); i++) {
time = fData.fDataTimeStart + (double)i*fData.fDataTimeStep;
for (unsigned int i=0; i<fData.GetValue()->size(); i++) {
time = fData.GetDataTimeStart() + (double)i*fData.GetDataTimeStep();
if ((time >= fFitStartTime) && (time <= fFitStopTime))
fNoOfFitBins++;
}
@ -666,23 +666,23 @@ cout << endl << ">> data start time = " << fData.fDataTimeStart;
}
// calculate theory
unsigned int size = runData->fDataBin[histoNo].size();
unsigned int size = runData->GetDataBin(histoNo)->size();
double factor = 1.0;
if (fData.fValue.size() * 10 > runData->fDataBin[histoNo].size()) {
size = fData.fValue.size() * 10;
factor = (double)runData->fDataBin[histoNo].size() / (double)size;
if (fData.GetValue()->size() * 10 > runData->GetDataBin(histoNo)->size()) {
size = fData.GetValue()->size() * 10;
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;
fData.fTheoryTimeStart = fData.fDataTimeStart;
fData.fTheoryTimeStep = fTimeResolution*factor;
fData.SetTheoryTimeStart(fData.GetDataTimeStart());
fData.SetTheoryTimeStep(fTimeResolution*factor);
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);
if (fabs(theoryValue) > 10.0) { // dirty hack needs to be fixed!!
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
@ -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
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
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
// 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;
}
// 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!";
return false;
}
// 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!";
return false;
}
@ -788,11 +788,11 @@ bool PRunSingleHisto::PrepareViewData(PRawRunData* runData, const unsigned int h
double time;
// data start at data_start-t0 shifted by (pack-1)/2
fData.fDataTimeStart = fTimeResolution*((double)start-(double)t0+(double)(packing-1)/2.0);
fData.fDataTimeStep = fTimeResolution*packing;
fData.SetDataTimeStart(fTimeResolution*((double)start-(double)t0+(double)(packing-1)/2.0));
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 << "--------------------------------" << endl;
*/
@ -806,19 +806,19 @@ cout << endl << "--------------------------------" << endl;
value /= normalizer;
time = (((double)i-(double)(packing-1)/2.0)-t0)*fTimeResolution;
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;
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);
value = 0.0;
}
value += runData->fDataBin[histoNo][i];
value += runData->GetDataBin(histoNo)->at(i);
}
// count the number of bins to be fitted
fNoOfFitBins=0;
for (unsigned int i=0; i<fData.fValue.size(); i++) {
time = fData.fDataTimeStart + (double)i*fData.fDataTimeStep;
for (unsigned int i=0; i<fData.GetValue()->size(); i++) {
time = fData.GetDataTimeStart() + (double)i*fData.GetDataTimeStep();
if ((time >= fFitStartTime) && (time <= fFitStopTime))
fNoOfFitBins++;
}
@ -830,23 +830,23 @@ cout << endl << "--------------------------------" << endl;
// calculate theory
double theoryValue;
unsigned int size = runData->fDataBin[histoNo].size();
unsigned int size = runData->GetDataBin(histoNo)->size();
double factor = 1.0;
if (fData.fValue.size() * 10 > runData->fDataBin[histoNo].size()) {
size = fData.fValue.size() * 10;
factor = (double)runData->fDataBin[histoNo].size() / (double)size;
if (fData.GetValue()->size() * 10 > runData->GetDataBin(histoNo)->size()) {
size = fData.GetValue()->size() * 10;
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;
fData.fTheoryTimeStart = fData.fDataTimeStart;
fData.fTheoryTimeStep = fTimeResolution*factor;
//cout << endl << ">> runData->GetDataBin(histoNo).size() = " << runData->GetDataBin(histoNo).size() << ", fData.GetValue()->size() * 10 = " << fData.GetValue()->size() * 10 << ", size = " << size << ", factor = " << factor << endl;
fData.SetTheoryTimeStart(fData.GetDataTimeStart());
fData.SetTheoryTimeStep(fTimeResolution*factor);
//cout << endl << ">> size=" << size << ", startTime=" << startTime << ", fTimeResolution=" << fTimeResolution;
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);
if (fabs(theoryValue) > 10.0) { // dirty hack needs to be fixed!!
theoryValue = 0.0;
}
fData.fTheory.push_back(theoryValue);
fData.AppendTheoryValue(theoryValue);
}
// clean up
@ -899,17 +899,17 @@ bool PRunSingleHisto::EstimateBkg(unsigned int histoNo)
PRawRunData* runData = fRawData->GetRunData(fRunInfo->fRunName[0]);
// 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 << " histo lengths = " << runData->fDataBin[histoNo].size();
cout << endl << " histo lengths = " << runData->GetDataBin(histoNo)->size();
cout << endl << " background start = " << start;
return false;
}
// 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 << " histo lengths = " << runData->fDataBin[histoNo].size();
cout << endl << " histo lengths = " << runData->GetDataBin(histoNo)->size();
cout << endl << " background end = " << end;
return false;
}
@ -920,7 +920,7 @@ bool PRunSingleHisto::EstimateBkg(unsigned int histoNo)
// forward
//cout << endl << ">> bkg start=" << start << ", end=" << end;
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);
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;
char substr[256];
TObjArray *tokens = 0;
TObjString *ostr;
TObjString *ostr = 0;
int idx = THEORY_UNDEFINED;
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
(*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 *
* andreas.suter@psi.c *
* andreas.suter@psi.ch *
* *
* 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 *
@ -62,6 +62,9 @@ using namespace std;
// used to filter post pileup correct data histos from root files
#define POST_PILEUP_HISTO_OFFSET 20
// defines a value for 'undefined values'
#define PMUSR_UNDEFINED -9.9e99
//-------------------------------------------------------------
// msr block header tags
#define MSR_TAG_TITLE 0
@ -123,7 +126,13 @@ typedef vector<Int_t> PIntVector;
/**
* <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 {
// 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;
} PRunData;
class PRunData {
public:
PRunData();
virtual ~PRunData();
virtual Double_t GetDataTimeStart() { return fDataTimeStart; }
virtual Double_t GetDataTimeStep() { return fDataTimeStep; }
virtual Double_t GetTheoryTimeStart() { return fTheoryTimeStart; }
virtual Double_t GetTheoryTimeStep() { return fTheoryTimeStep; }
virtual const PDoubleVector* GetX() { return &fX; }
virtual const PDoubleVector* GetValue() { return &fValue; }
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 {
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
} PNonMusrRawRunData;
class PNonMusrRawRunData {
public:
PNonMusrRawRunData();
virtual ~PNonMusrRawRunData();
virtual Bool_t FromAscii() { return fFromAscii; }
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 {
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
PNonMusrRawRunData fDataNonMusr; ///< keeps all ascii- or db-file info in case of nonMusr fit
} PRawRunData;
class PRawRunData {
public:
PRawRunData();
virtual ~PRawRunData();
virtual const TString* GetRunName() { return &fRunName; }
virtual const TString* GetRunTitle() { return &fRunTitle; }
virtual const TString* GetSetup() { return &fSetup; }
virtual const Double_t GetField() { return fField; }
virtual const UInt_t GetNoOfTemperatures() { return fTemp.size(); }
virtual const PDoublePairVector GetTemperature() { return fTemp; }
virtual const Double_t GetTemperature(const UInt_t idx);
virtual const Double_t GetTempError(const UInt_t idx);
virtual const Double_t GetEnergy() { return fEnergy; }
virtual const Double_t GetTransport() { return fTransport; }
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 *
* andreas.suter@psi.c *
* andreas.suter@psi.ch *
* *
* 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 *

View File

@ -11,7 +11,7 @@
/***************************************************************************
* 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 *
* 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 Double_t ToDouble(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_

View File

@ -110,12 +110,12 @@ void musrfit_write_ascii(TString fln, PRunData *data, int runCounter)
}
// 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;
double time;
for (unsigned int i=0; i<data->fValue.size(); i++) {
time = data->fDataTimeStart + (double)i*data->fDataTimeStep;
f << time << ", " << data->fValue[i] << ", " << data->fError[i] << ", " << data->fTheory[i] << endl;
for (unsigned int i=0; i<data->GetValue()->size(); i++) {
time = data->GetDataTimeStart() + (double)i*data->GetDataTimeStep();
f << time << ", " << data->GetValue()->at(i) << ", " << data->GetError()->at(i) << ", " << data->GetTheory()->at(i) << endl;
}
// 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);
// create histos
Double_t diff = data->fDataTimeStep;
Double_t diff = data->GetDataTimeStep();
Double_t start = -diff/2.0;
Double_t end = data->fDataTimeStep*data->fValue.size();
TH1F *hdata = new TH1F("hdata", "run data", data->fValue.size(), start, end);
TH1F *htheo = new TH1F("htheo", "run theory", data->fValue.size(), start, end);
Double_t end = data->GetDataTimeStep()*data->GetValue()->size();
TH1F *hdata = new TH1F("hdata", "run data", data->GetValue()->size(), start, end);
TH1F *htheo = new TH1F("htheo", "run theory", data->GetValue()->size(), start, end);
// fill data
for (unsigned int i=0; i<data->fValue.size(); i++) {
hdata->SetBinContent(i+1, data->fValue[i]);
hdata->SetBinError(i+1, data->fError[i]);
htheo->SetBinContent(i+1, data->fTheory[i]);
for (unsigned int i=0; i<data->GetValue()->size(); i++) {
hdata->SetBinContent(i+1, data->GetValue()->at(i));
hdata->SetBinError(i+1, data->GetError()->at(i));
htheo->SetBinContent(i+1, data->GetTheory()->at(i));
}
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
char startup_path_name[128];
TSAXParser *saxParser = new TSAXParser();
@ -457,14 +458,14 @@ int main(int argc, char *argv[])
if (title_from_data_file) {
PMsrRunList *rl = msrHandler->GetMsrRunList();
PRawRunData *rrd = dataHandler->GetRunData(rl->at(0).fRunName[0]);
if (rrd->fRunTitle.Length() > 0)
msrHandler->SetMsrTitle(rrd->fRunTitle);
if (rrd->GetRunTitle()->Length() > 0)
msrHandler->SetMsrTitle(*rrd->GetRunTitle());
}
// generate the necessary fit histogramms for the fit
PRunListCollection *runListCollection = 0;
if (success) {
// feed all the necessary histogramms for the fit
// feed all the necessary histogramms for the fit
runListCollection = new PRunListCollection(msrHandler, dataHandler);
for (unsigned int i=0; i < msrHandler->GetMsrRunList()->size(); i++) {
success = runListCollection->Add(i, kFit);

View File

@ -82,7 +82,7 @@ bool musrt0_item(TApplication &app, PMsrHandler *msrHandler, PRawRunData *rawRun
if (musrT0 == 0) {
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;
return false;

View File

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