some more work towards a full encapsulation

This commit is contained in:
nemu 2009-11-04 11:42:51 +00:00
parent 73b70defaa
commit 15ddd28644
8 changed files with 247 additions and 100 deletions

View File

@ -622,11 +622,11 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages)
} else if (sstr.BeginsWith("forward")) {
fout.width(16);
fout << left << "forward";
fout << fRuns[runNo].fForwardHistoNo << endl;
fout << fRuns[runNo].GetForwardHistoNo() << endl;
} else if (sstr.BeginsWith("backward")) {
fout.width(16);
fout << left << "backward";
fout << fRuns[runNo].fBackwardHistoNo << endl;
fout << fRuns[runNo].GetBackwardHistoNo() << endl;
} else if (sstr.BeginsWith("right")) {
fout.width(16);
fout << left << "right";
@ -638,26 +638,26 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages)
} else if (sstr.BeginsWith("backgr.fix")) {
fout.width(15);
fout << left << "backgr.fix";
for (UInt_t j=0; j<fRuns[runNo].fBkgFix.size(); j++) {
for (UInt_t j=0; j<fRuns[runNo].GetBkgsFix().size(); j++) {
fout.precision(prec);
fout.width(12);
fout << left << fRuns[runNo].fBkgFix[j];
fout << left << fRuns[runNo].GetBkgFix(j);
}
fout << endl;
} else if (sstr.BeginsWith("background")) {
fout.width(16);
fout << left << "background";
for (UInt_t j=0; j<fRuns[runNo].fBkgRange.size(); j++) {
for (UInt_t j=0; j<fRuns[runNo].GetBkgRanges().size(); j++) {
fout.width(8);
fout << left << fRuns[runNo].fBkgRange[j];
fout << left << fRuns[runNo].GetBkgRange(j);
}
fout << endl;
} else if (sstr.BeginsWith("data")) {
fout.width(16);
fout << left << "data";
for (UInt_t j=0; j<fRuns[runNo].fDataRange.size(); j++) {
for (UInt_t j=0; j<fRuns[runNo].GetDataRanges().size(); j++) {
fout.width(8);
fout << left << fRuns[runNo].fDataRange[j];
fout << left << fRuns[runNo].GetDataRange(j);
}
fout << endl;
} else if (sstr.BeginsWith("t0")) {
@ -1114,13 +1114,13 @@ void PMsrHandler::SetMsrDataRangeEntry(UInt_t runNo, UInt_t idx, Int_t bin)
return;
}
if ((idx < 0) || (idx > fRuns[runNo].fDataRange.size())) { // error
cerr << endl << "PMsrHandler::SetMsrDataRangeEntry: **ERROR** idx = " << idx << ", is out of valid range 0.." << fRuns[runNo].fDataRange.size();
if ((idx < 0) || (idx > fRuns[runNo].GetDataRanges().size())) { // error
cerr << endl << "PMsrHandler::SetMsrDataRangeEntry: **ERROR** idx = " << idx << ", is out of valid range 0.." << fRuns[runNo].GetDataRanges().size();
cerr << endl;
return;
}
fRuns[runNo].fDataRange[idx] = bin;
fRuns[runNo].SetDataRange(bin, idx);
}
//--------------------------------------------------------------------------
@ -1141,13 +1141,13 @@ void PMsrHandler::SetMsrBkgRangeEntry(UInt_t runNo, UInt_t idx, Int_t bin)
return;
}
if ((idx < 0) || (idx > fRuns[runNo].fBkgRange.size())) { // error
cerr << endl << "PMsrHandler::SetMsrBkgRangeEntry: idx = " << idx << ", is out of valid range 0.." << fRuns[runNo].fBkgRange.size();
if ((idx < 0) || (idx > fRuns[runNo].GetBkgRanges().size())) { // error
cerr << endl << "PMsrHandler::SetMsrBkgRangeEntry: idx = " << idx << ", is out of valid range 0.." << fRuns[runNo].GetBkgRanges().size();
cerr << endl;
return;
}
fRuns[runNo].fBkgRange[idx] = bin;
fRuns[runNo].SetBkgRange(bin, idx);
}
//--------------------------------------------------------------------------
@ -1650,7 +1650,7 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines)
ostr = dynamic_cast<TObjString*>(tokens->At(1));
str = ostr->GetString();
if (str.IsDigit())
param.fForwardHistoNo = str.Atoi();
param.SetForwardHistoNo(str.Atoi());
else
error = true;
}
@ -1664,7 +1664,7 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines)
ostr = dynamic_cast<TObjString*>(tokens->At(1));
str = ostr->GetString();
if (str.IsDigit())
param.fBackwardHistoNo = str.Atoi();
param.SetBackwardHistoNo(str.Atoi());
else
error = true;
}
@ -1679,7 +1679,7 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines)
ostr = dynamic_cast<TObjString*>(tokens->At(i));
str = ostr->GetString();
if (str.IsFloat())
param.fBkgFix.push_back(str.Atof());
param.AppendBkgFix(str.Atof());
else
error = true;
}
@ -1695,7 +1695,7 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines)
ostr = dynamic_cast<TObjString*>(tokens->At(i));
str = ostr->GetString();
if (str.IsDigit())
param.fBkgRange.push_back(str.Atoi());
param.AppendBkgRange(str.Atoi());
else
error = true;
}
@ -1711,7 +1711,7 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines)
ostr = dynamic_cast<TObjString*>(tokens->At(i));
str = ostr->GetString();
if (str.IsDigit())
param.fDataRange.push_back(str.Atoi());
param.AppendDataRange(str.Atoi());
else
error = true;
}
@ -1899,15 +1899,15 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines)
Bool_t found;
if (fRuns[i].GetBkgFitParamNo() >= 0) { // check if backgr.fit is given
found = true;
} else if (fRuns[i].fBkgFix.size() > 0) { // check if backgr.fix is given
} else if (fRuns[i].GetBkgsFix().size() > 0) { // check if backgr.fix is given
found = true;
} else if (fRuns[i].fBkgRange.size() > 0) { // check if background window is given
} else if (fRuns[i].GetBkgRanges().size() > 0) { // check if background window is given
found = true;
} else {
found = false;
}
if (!found) {
cerr << endl << ">> PMsrHandler::HandleRunEntry: **ERROR** for run " << fRuns[i].GetRunName()->Data() << ", forward " << fRuns[i].fForwardHistoNo;
cerr << endl << ">> PMsrHandler::HandleRunEntry: **ERROR** for run " << fRuns[i].GetRunName()->Data() << ", forward " << fRuns[i].GetForwardHistoNo();
cerr << endl << " no background information found!";
cerr << endl << " Either of the tags 'backgr.fit', 'backgr.fix', 'background'";
cerr << endl << " with data is needed.";

View File

@ -29,6 +29,8 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <cassert>
#include <iostream>
using namespace std;
@ -697,9 +699,9 @@ Int_t PMsrRunBlock::GetMap(UInt_t i)
// SetMap
//--------------------------------------------------------------------------
/**
* <p> set file format name at position i
* <p> set map value at position i
*
* \param i index of the file format name to be set
* \param i index of the map value to be set
*/
void PMsrRunBlock::SetMap(Int_t mapVal, UInt_t idx)
{
@ -708,3 +710,103 @@ void PMsrRunBlock::SetMap(Int_t mapVal, UInt_t idx)
fMap[idx] = mapVal;
}
//--------------------------------------------------------------------------
// GetBkgFix
//--------------------------------------------------------------------------
/**
* <p> get background fixed value at position i
*
* \param i index of the background fixed value to be returned
*/
Double_t PMsrRunBlock::GetBkgFix(UInt_t i)
{
if (i>fBkgFix.size())
return PMUSR_UNDEFINED;
return fBkgFix[i];
}
//--------------------------------------------------------------------------
// SetBkgFix
//--------------------------------------------------------------------------
/**
* <p> set background fixed value at position i
*
* \param i index of the background fixed value to be set
*/
void PMsrRunBlock::SetBkgFix(Double_t dval, UInt_t idx)
{
if (idx>fBkgFix.size())
fBkgFix.resize(idx+1);
fBkgFix[idx] = dval;
}
//--------------------------------------------------------------------------
// GetBkgRange
//--------------------------------------------------------------------------
/**
* <p> get background range at position i
*
* \param i index of the background range to be returned
*/
Int_t PMsrRunBlock::GetBkgRange(UInt_t i)
{
if (i > fBkgRange.size()) {
cerr << endl << ">> PMsrRunBlock::GetBkgRange: **ERROR** index i=" << i << " out of range, fatal." << endl;
assert(0);
}
return fBkgRange[i];
}
//--------------------------------------------------------------------------
// SetBkgRange
//--------------------------------------------------------------------------
/**
* <p> set background range element at position i
*
* \param i index of the background range element to be returned
*/
void PMsrRunBlock::SetBkgRange(Int_t ival, UInt_t idx)
{
if (idx > fBkgRange.size())
fBkgRange.resize(idx+1);
fBkgRange[idx] = ival;
}
//--------------------------------------------------------------------------
// GetDataRange
//--------------------------------------------------------------------------
/**
* <p> get data range at position i
*
* \param i index of the data range to be returned
*/
Int_t PMsrRunBlock::GetDataRange(UInt_t i)
{
if (i > fDataRange.size()) {
cerr << endl << ">> PMsrRunBlock::GetDataRange: **ERROR** index i=" << i << " out of range, fatal." << endl;
assert(0);
}
return fDataRange[i];
}
//--------------------------------------------------------------------------
// SetDataRange
//--------------------------------------------------------------------------
/**
* <p> set data range element at position i
*
* \param i index of the data range element to be returned
*/
void PMsrRunBlock::SetDataRange(Int_t ival, UInt_t idx)
{
if (idx > fDataRange.size())
fDataRange.resize(idx+1);
fDataRange[idx] = ival;
}

View File

@ -536,13 +536,13 @@ void PMusrCanvas::UpdateInfoPad()
// histo info (depending on the fittype
if (runs[runNo].GetFitType() == MSR_FITTYPE_SINGLE_HISTO) {
tstr += TString("h:");
tstr += runs[runNo].fForwardHistoNo;
tstr += runs[runNo].GetForwardHistoNo();
tstr += TString(",");
} else if (runs[runNo].GetFitType() == MSR_FITTYPE_ASYM) {
tstr += TString("h:");
tstr += runs[runNo].fForwardHistoNo;
tstr += runs[runNo].GetForwardHistoNo();
tstr += TString("/");
tstr += runs[runNo].fBackwardHistoNo;
tstr += runs[runNo].GetBackwardHistoNo();
tstr += TString(",");
}
// temperature if present

View File

@ -255,12 +255,12 @@ void PMusrT0::InitDataAndBkg()
// feed data range histo
switch (fDetectorTag) {
case DETECTOR_TAG_FORWARD:
fDataRange[0] = fMsrHandler->GetMsrRunList()->at(fRunNo).fDataRange[0 + fAddRunNo * fAddRunOffset];
fDataRange[1] = fMsrHandler->GetMsrRunList()->at(fRunNo).fDataRange[1 + fAddRunNo * fAddRunOffset];
fDataRange[0] = fMsrHandler->GetMsrRunList()->at(fRunNo).GetDataRange(0 + fAddRunNo * fAddRunOffset);
fDataRange[1] = fMsrHandler->GetMsrRunList()->at(fRunNo).GetDataRange(1 + fAddRunNo * fAddRunOffset);
break;
case DETECTOR_TAG_BACKWARD:
fDataRange[0] = fMsrHandler->GetMsrRunList()->at(fRunNo).fDataRange[2 + fAddRunNo * fAddRunOffset];
fDataRange[1] = fMsrHandler->GetMsrRunList()->at(fRunNo).fDataRange[3 + fAddRunNo * fAddRunOffset];
fDataRange[0] = fMsrHandler->GetMsrRunList()->at(fRunNo).GetDataRange(2 + fAddRunNo * fAddRunOffset);
fDataRange[1] = fMsrHandler->GetMsrRunList()->at(fRunNo).GetDataRange(3 + fAddRunNo * fAddRunOffset);
break;
case DETECTOR_TAG_RIGHT:
// not clear yet what to be done
@ -289,12 +289,12 @@ void PMusrT0::InitDataAndBkg()
// feed background histo
switch (fDetectorTag) {
case DETECTOR_TAG_FORWARD:
fBkgRange[0] = fMsrHandler->GetMsrRunList()->at(fRunNo).fBkgRange[0 + fAddRunNo * fAddRunOffset];
fBkgRange[1] = fMsrHandler->GetMsrRunList()->at(fRunNo).fBkgRange[1 + fAddRunNo * fAddRunOffset];
fBkgRange[0] = fMsrHandler->GetMsrRunList()->at(fRunNo).GetBkgRange(0 + fAddRunNo * fAddRunOffset);
fBkgRange[1] = fMsrHandler->GetMsrRunList()->at(fRunNo).GetBkgRange(1 + fAddRunNo * fAddRunOffset);
break;
case DETECTOR_TAG_BACKWARD:
fBkgRange[0] = fMsrHandler->GetMsrRunList()->at(fRunNo).fBkgRange[2 + fAddRunNo * fAddRunOffset];
fBkgRange[1] = fMsrHandler->GetMsrRunList()->at(fRunNo).fBkgRange[3 + fAddRunNo * fAddRunOffset];
fBkgRange[0] = fMsrHandler->GetMsrRunList()->at(fRunNo).GetBkgRange(2 + fAddRunNo * fAddRunOffset);
fBkgRange[1] = fMsrHandler->GetMsrRunList()->at(fRunNo).GetBkgRange(3 + fAddRunNo * fAddRunOffset);
break;
case DETECTOR_TAG_RIGHT:
// not clear yet what to be done

View File

@ -305,8 +305,8 @@ Bool_t PRunAsymmetry::PrepareData()
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->GetT0(fRunInfo->fForwardHistoNo-1)); // forward t0
fT0s.push_back(runData->GetT0(fRunInfo->fBackwardHistoNo-1)); // backward t0
fT0s.push_back(runData->GetT0(fRunInfo->GetForwardHistoNo()-1)); // forward t0
fT0s.push_back(runData->GetT0(fRunInfo->GetBackwardHistoNo()-1)); // backward t0
} else { // t0's are neither in the run data nor in the msr-file -> not acceptable!
cerr << endl << "PRunAsymmetry::PrepareData(): **ERROR** NO t0's found, neither in the run data nor in the msr-file!";
cerr << endl;
@ -316,17 +316,17 @@ Bool_t PRunAsymmetry::PrepareData()
// check if t0's are given in the data file
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->GetT0(fRunInfo->fForwardHistoNo-1))>5.0) { // given in bins!!
if (fabs(fRunInfo->fT0[0]-runData->GetT0(fRunInfo->GetForwardHistoNo()-1))>5.0) { // given in bins!!
cerr << endl << "PRunAsymmetry::PrepareData(): **WARNING**: forward histo";
cerr << endl << " t0 from the msr-file is " << fRunInfo->fT0[0];
cerr << endl << " t0 from the data file is " << runData->GetT0(fRunInfo->fForwardHistoNo-1);
cerr << endl << " t0 from the data file is " << runData->GetT0(fRunInfo->GetForwardHistoNo()-1);
cerr << endl << " This is quite a deviation! Is this done intentionally??";
cerr << endl;
}
if (fabs(fRunInfo->fT0[1]-runData->GetT0(fRunInfo->fBackwardHistoNo-1))>5.0) { // given in bins!!
if (fabs(fRunInfo->fT0[1]-runData->GetT0(fRunInfo->GetBackwardHistoNo()-1))>5.0) { // given in bins!!
cerr << endl << "PRunAsymmetry::PrepareData(): **WARNING**: backward histo";
cerr << endl << " t0 from the msr-file is " << fRunInfo->fT0[1];
cerr << endl << " t0 from the data file is " << runData->GetT0(fRunInfo->fBackwardHistoNo-1);
cerr << endl << " t0 from the data file is " << runData->GetT0(fRunInfo->GetBackwardHistoNo()-1);
cerr << endl << " This is quite a deviation! Is this done intentionally??";
cerr << endl;
}
@ -337,8 +337,8 @@ Bool_t PRunAsymmetry::PrepareData()
// check if post pile up data shall be used
UInt_t histoNo[2]; // forward/backward
histoNo[0] = fRunInfo->fForwardHistoNo-1;
histoNo[1] = fRunInfo->fBackwardHistoNo-1;
histoNo[0] = fRunInfo->GetForwardHistoNo()-1;
histoNo[1] = fRunInfo->GetBackwardHistoNo()-1;
// first check if forward/backward given in the msr-file are valid
if ((runData->GetNoOfHistos() < histoNo[0]+1) || (histoNo[0] < 0) ||
(runData->GetNoOfHistos() < histoNo[1]+1) || (histoNo[1] < 0)) {
@ -377,8 +377,8 @@ Bool_t PRunAsymmetry::PrepareData()
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->GetT0(fRunInfo->fForwardHistoNo-1); // forward t0
t0Add[1] = addRunData->GetT0(fRunInfo->fBackwardHistoNo-1); // backward t0
t0Add[0] = addRunData->GetT0(fRunInfo->GetForwardHistoNo()-1); // forward t0
t0Add[1] = addRunData->GetT0(fRunInfo->GetBackwardHistoNo()-1); // backward t0
} else { // t0's are neither in the run data nor in the msr-file -> not acceptable!
cerr << endl << "PRunAsymmetry::PrepareData(): **ERROR** NO t0's found, neither in the addrun (" << fRunInfo->GetRunName(i)->Data() << ") data nor in the msr-file!";
cerr << endl;
@ -400,18 +400,18 @@ Bool_t PRunAsymmetry::PrepareData()
}
if (addRunData->GetT0s().size() != 0) {
// compare t0's of the msr-file with the one in the data file
if (fabs(t0Add[0]-addRunData->GetT0(fRunInfo->fForwardHistoNo-1))>5.0) { // given in bins!!
if (fabs(t0Add[0]-addRunData->GetT0(fRunInfo->GetForwardHistoNo()-1))>5.0) { // given in bins!!
cerr << endl << "PRunAsymmetry::PrepareData(): **WARNING**: forward histo";
cerr << endl << " t0 from the msr-file is " << fRunInfo->fT0[2*i];
cerr << endl << " t0 from the data file is " << addRunData->GetT0(fRunInfo->fForwardHistoNo-1);
cerr << endl << " t0 from the data file is " << addRunData->GetT0(fRunInfo->GetForwardHistoNo()-1);
cerr << endl << " This is quite a deviation! Is this done intentionally??";
cerr << endl << " addrun: " << fRunInfo->GetRunName(i)->Data();
cerr << endl;
}
if (fabs(t0Add[1]-addRunData->GetT0(fRunInfo->fBackwardHistoNo-1))>5.0) { // given in bins!!
if (fabs(t0Add[1]-addRunData->GetT0(fRunInfo->GetBackwardHistoNo()-1))>5.0) { // given in bins!!
cerr << endl << "PRunAsymmetry::PrepareData(): **WARNING**: backward histo";
cerr << endl << " t0 from the msr-file is " << fRunInfo->fT0[2*i+1];
cerr << endl << " t0 from the data file is " << addRunData->GetT0(fRunInfo->fBackwardHistoNo-1);
cerr << endl << " t0 from the data file is " << addRunData->GetT0(fRunInfo->GetBackwardHistoNo()-1);
cerr << endl << " This is quite a deviation! Is this done intentionally??";
cerr << endl << " addrun: " << fRunInfo->GetRunName(i)->Data();
cerr << endl;
@ -440,8 +440,8 @@ Bool_t PRunAsymmetry::PrepareData()
}
// subtract background from histogramms ------------------------------------------
if (fRunInfo->fBkgFix.size() == 0) { // no fixed background given
if (fRunInfo->fBkgRange.size() != 0) {
if (fRunInfo->GetBkgsFix().size() == 0) { // no fixed background given
if (fRunInfo->GetBkgRanges().size() != 0) {
if (!SubtractEstimatedBkg())
return false;
} else { // no background given to do the job
@ -489,10 +489,10 @@ Bool_t PRunAsymmetry::PrepareData()
Bool_t PRunAsymmetry::SubtractFixBkg()
{
for (UInt_t i=0; i<fForward.size(); i++) {
fForwardErr.push_back(TMath::Sqrt(fForward[i]+fRunInfo->fBkgFix[0] * fTimeResolution * 1.0e3));
fForward[i] -= fRunInfo->fBkgFix[0] * fTimeResolution * 1.0e3; // bkg per ns -> bkg per bin; 1.0e3: us -> ns
fBackwardErr.push_back(TMath::Sqrt(fBackward[i]+fRunInfo->fBkgFix[1] * fTimeResolution * 1.0e3));
fBackward[i] -= fRunInfo->fBkgFix[1] * fTimeResolution * 1.0e3; // bkg per ns -> bkg per bin; 1.0e3: us -> ns
fForwardErr.push_back(TMath::Sqrt(fForward[i]+fRunInfo->GetBkgFix(0) * fTimeResolution * 1.0e3));
fForward[i] -= fRunInfo->GetBkgFix(0) * fTimeResolution * 1.0e3; // bkg per ns -> bkg per bin; 1.0e3: us -> ns
fBackwardErr.push_back(TMath::Sqrt(fBackward[i]+fRunInfo->GetBkgFix(1) * fTimeResolution * 1.0e3));
fBackward[i] -= fRunInfo->GetBkgFix(1) * fTimeResolution * 1.0e3; // bkg per ns -> bkg per bin; 1.0e3: us -> ns
}
return true;
@ -530,8 +530,8 @@ Bool_t PRunAsymmetry::SubtractEstimatedBkg()
beamPeriod = 0.0;
// check if start and end are in proper order
UInt_t start[2] = {fRunInfo->fBkgRange[0], fRunInfo->fBkgRange[2]};
UInt_t end[2] = {fRunInfo->fBkgRange[1], fRunInfo->fBkgRange[3]};
UInt_t start[2] = {fRunInfo->GetBkgRange(0), fRunInfo->GetBkgRange(2)};
UInt_t end[2] = {fRunInfo->GetBkgRange(1), fRunInfo->GetBkgRange(3)};
for (UInt_t i=0; i<2; i++) {
if (end[i] < start[i]) {
cout << endl << "PRunAsymmetry::SubtractEstimatedBkg(): end = " << end[i] << " > start = " << start[i] << "! Will swap them!";
@ -549,7 +549,7 @@ Bool_t PRunAsymmetry::SubtractEstimatedBkg()
end[i] = start[i] + (UInt_t)round((Double_t)periods*beamPeriodBins);
cout << "PRunAsymmetry::SubtractEstimatedBkg(): Background " << start[i] << ", " << end[i] << endl;
if (end[i] == start[i])
end[i] = fRunInfo->fBkgRange[2*i+1];
end[i] = fRunInfo->GetBkgRange(2*i+1);
}
}
@ -616,8 +616,8 @@ Bool_t PRunAsymmetry::PrepareFitData(PRawRunData* runData, UInt_t histoNo[2])
// transform raw histo data. This is done the following way (for details see the manual):
// first rebin the data, than calculate the asymmetry
// first get start data, end data, and t0
Int_t start[2] = {fRunInfo->fDataRange[0], fRunInfo->fDataRange[2]};
Int_t end[2] = {fRunInfo->fDataRange[1], fRunInfo->fDataRange[3]};
Int_t start[2] = {fRunInfo->GetDataRange(0), fRunInfo->GetDataRange(2)};
Int_t end[2] = {fRunInfo->GetDataRange(1), fRunInfo->GetDataRange(3)};
Double_t t0[2] = {fT0s[0], fT0s[1]};
// check if start, end, and t0 make any sense
// 1st check if start and end are in proper order
@ -773,13 +773,13 @@ Bool_t PRunAsymmetry::PrepareViewData(PRawRunData* runData, UInt_t histoNo[2])
// transform raw histo data. This is done the following way (for details see the manual):
// first rebin the data, than calculate the asymmetry
// first get start data, end data, and t0
Int_t val = fRunInfo->fDataRange[0]-packing*(fRunInfo->fDataRange[0]/packing);
Int_t val = fRunInfo->GetDataRange(0)-packing*(fRunInfo->GetDataRange(0)/packing);
do {
if (fRunInfo->fDataRange[2] - fRunInfo->fDataRange[0] < 0)
if (fRunInfo->GetDataRange(2) - fRunInfo->GetDataRange(0) < 0)
val += packing;
} while (val + fRunInfo->fDataRange[2] - fRunInfo->fDataRange[0] < 0);
} while (val + fRunInfo->GetDataRange(2) - fRunInfo->GetDataRange(0) < 0);
Int_t start[2] = {val, val + fRunInfo->fDataRange[2] - fRunInfo->fDataRange[0]};
Int_t start[2] = {val, val + fRunInfo->GetDataRange(2) - fRunInfo->GetDataRange(0)};
Int_t end[2];
Double_t t0[2] = {fT0s[0], fT0s[1]};

View File

@ -120,10 +120,10 @@ Double_t PRunSingleHisto::CalcChiSquare(const std::vector<Double_t>& par)
// get background
Double_t bkg;
if (fRunInfo->GetBkgFitParamNo() == -1) { // bkg not fitted
if (fRunInfo->fBkgFix.size() == 0) { // no fixed background given (background interval)
if (fRunInfo->GetBkgsFix().size() == 0) { // no fixed background given (background interval)
bkg = fBackground;
} else { // fixed bkg given
bkg = fRunInfo->fBkgFix[0];
bkg = fRunInfo->GetBkgFix(0);
}
} else { // bkg fitted
bkg = par[fRunInfo->GetBkgFitParamNo()-1];
@ -184,10 +184,10 @@ Double_t PRunSingleHisto::CalcMaxLikelihood(const std::vector<Double_t>& par)
// get background
Double_t bkg;
if (fRunInfo->GetBkgFitParamNo() == -1) { // bkg not fitted
if (fRunInfo->fBkgFix.size() == 0) { // no fixed background given (background interval)
if (fRunInfo->GetBkgsFix().size() == 0) { // no fixed background given (background interval)
bkg = fBackground;
} else { // fixed bkg given
bkg = fRunInfo->fBkgFix[0];
bkg = fRunInfo->GetBkgFix(0);
}
} else { // bkg fitted
bkg = par[fRunInfo->GetBkgFitParamNo()-1];
@ -258,10 +258,10 @@ void PRunSingleHisto::CalcTheory()
// get background
Double_t bkg;
if (fRunInfo->GetBkgFitParamNo() == -1) { // bkg not fitted
if (fRunInfo->fBkgFix.size() == 0) { // no fixed background given (background interval)
if (fRunInfo->GetBkgsFix().size() == 0) { // no fixed background given (background interval)
bkg = fBackground;
} else { // fixed bkg given
bkg = fRunInfo->fBkgFix[0];
bkg = fRunInfo->GetBkgFix(0);
}
} else { // bkg fitted
bkg = par[fRunInfo->GetBkgFitParamNo()-1];
@ -308,7 +308,7 @@ Bool_t PRunSingleHisto::PrepareData()
// check if post pile up data shall be used
UInt_t histoNo;
histoNo = fRunInfo->fForwardHistoNo-1;
histoNo = fRunInfo->GetForwardHistoNo()-1;
if ((runData->GetNoOfHistos() < histoNo) || (histoNo < 0)) {
cerr << endl << "PRunSingleHisto::PrepareData(): **PANIC ERROR**:";
@ -324,7 +324,7 @@ Bool_t PRunSingleHisto::PrepareData()
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->GetT0(fRunInfo->fForwardHistoNo-1));
fT0s.push_back(runData->GetT0(fRunInfo->GetForwardHistoNo()-1));
} else { // t0's are neither in the run data nor in the msr-file -> not acceptable!
cerr << endl << "PRunSingleHisto::PrepareData(): **ERROR** NO t0's found, neither in the run data nor in the msr-file!";
cerr << endl << " run: " << fRunInfo->GetRunName()->Data();
@ -335,10 +335,10 @@ Bool_t PRunSingleHisto::PrepareData()
// check if t0's are given in the data file
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->GetT0(fRunInfo->fForwardHistoNo-1))>5.0) { // given in bins!!
if (fabs(fRunInfo->fT0[0]-runData->GetT0(fRunInfo->GetForwardHistoNo()-1))>5.0) { // given in bins!!
cerr << endl << "PRunSingleHisto::PrepareData(): **WARNING**:";
cerr << endl << " t0 from the msr-file is " << fRunInfo->fT0[0];
cerr << endl << " t0 from the data file is " << runData->GetT0(fRunInfo->fForwardHistoNo-1);
cerr << endl << " t0 from the data file is " << runData->GetT0(fRunInfo->GetForwardHistoNo()-1);
cerr << endl << " This is quite a deviation! Is this done intentionally??";
cerr << endl;
}
@ -375,7 +375,7 @@ Bool_t PRunSingleHisto::PrepareData()
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->GetT0(fRunInfo->fForwardHistoNo-1);
t0Add = addRunData->GetT0(fRunInfo->GetForwardHistoNo()-1);
} else { // t0's are neither in the run data nor in the msr-file -> not acceptable!
cerr << endl << "PRunSingleHisto::PrepareData(): **ERROR** NO t0's found, neither in the addrun data nor in the msr-file!";
cerr << endl << " addrun: " << fRunInfo->GetRunName(i)->Data();
@ -386,10 +386,10 @@ Bool_t PRunSingleHisto::PrepareData()
// check if t0's are given in the data file
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->GetT0(fRunInfo->fForwardHistoNo-1))>5.0) { // given in bins!!
if (fabs(fRunInfo->fT0[i]-addRunData->GetT0(fRunInfo->GetForwardHistoNo()-1))>5.0) { // given in bins!!
cerr << endl << "PRunSingleHisto::PrepareData(): **WARNING**:";
cerr << endl << " t0 from the msr-file is " << fRunInfo->fT0[i];
cerr << endl << " t0 from the data file is " << addRunData->GetT0(fRunInfo->fForwardHistoNo-1);
cerr << endl << " t0 from the data file is " << addRunData->GetT0(fRunInfo->GetForwardHistoNo()-1);
cerr << endl << " This is quite a deviation! Is this done intentionally??";
cerr << endl << " addrun: " << fRunInfo->GetRunName(i)->Data();
cerr << endl;
@ -453,8 +453,8 @@ Bool_t PRunSingleHisto::PrepareFitData(PRawRunData* runData, const UInt_t histoN
// first get start data, end data, and t0
Int_t start;
Int_t end;
start = fRunInfo->fDataRange[0];
end = fRunInfo->fDataRange[1];
start = fRunInfo->GetDataRange(0);
end = fRunInfo->GetDataRange(1);
// 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
@ -478,8 +478,8 @@ Bool_t PRunSingleHisto::PrepareFitData(PRawRunData* runData, const UInt_t histoN
// check how the background shall be handled
if (fRunInfo->GetBkgFitParamNo() == -1) { // bkg shall **NOT** be fitted
// subtract background from histogramms ------------------------------------------
if (fRunInfo->fBkgFix.size() == 0) { // no fixed background given
if (fRunInfo->fBkgRange.size() != 0) {
if (fRunInfo->GetBkgsFix().size() == 0) { // no fixed background given
if (fRunInfo->GetBkgRanges().size() != 0) {
if (!EstimateBkg(histoNo))
return false;
} else { // no background given to do the job
@ -557,7 +557,7 @@ Bool_t PRunSingleHisto::PrepareRawViewData(PRawRunData* runData, const UInt_t hi
// raw data, since PMusrCanvas is doing ranging etc.
// start = the first bin which is a multiple of packing backward from first good data bin
Int_t start = fRunInfo->fDataRange[0] - (fRunInfo->fDataRange[0]/packing)*packing;
Int_t start = fRunInfo->GetDataRange(0) - (fRunInfo->GetDataRange(0)/packing)*packing;
// end = last bin starting from start which is a multipl of packing and still within the data
Int_t end = start + ((runData->GetDataBin(histoNo)->size()-start)/packing)*packing;
// check if start, end, and t0 make any sense
@ -651,12 +651,12 @@ cout << endl << ">> data start time = " << fData.GetDataTimeStart();
// get background
Double_t bkg;
if (fRunInfo->GetBkgFitParamNo() == -1) { // bkg not fitted
if (fRunInfo->fBkgFix.size() == 0) { // no fixed background given (background interval)
if (fRunInfo->GetBkgsFix().size() == 0) { // no fixed background given (background interval)
if (!EstimateBkg(histoNo))
return false;
bkg = fBackground;
} else { // fixed bkg given
bkg = fRunInfo->fBkgFix[0];
bkg = fRunInfo->GetBkgFix(0);
}
} else { // bkg fitted
bkg = par[fRunInfo->GetBkgFitParamNo()-1];
@ -721,7 +721,7 @@ Bool_t PRunSingleHisto::PrepareViewData(PRawRunData* runData, const UInt_t histo
Int_t t0 = fT0s[0];
// start = the first bin which is a multiple of packing backward from first good data bin
Int_t start = fRunInfo->fDataRange[0] - (fRunInfo->fDataRange[0]/packing)*packing;
Int_t start = fRunInfo->GetDataRange(0) - (fRunInfo->GetDataRange(0)/packing)*packing;
// end = last bin starting from start which is a multiple of packing and still within the data
Int_t end = start + ((runData->GetDataBin(histoNo)->size()-start)/packing)*packing;
@ -776,12 +776,12 @@ Bool_t PRunSingleHisto::PrepareViewData(PRawRunData* runData, const UInt_t histo
// get background
Double_t bkg;
if (fRunInfo->GetBkgFitParamNo() == -1) { // bkg not fitted
if (fRunInfo->fBkgFix.size() == 0) { // no fixed background given (background interval)
if (fRunInfo->GetBkgsFix().size() == 0) { // no fixed background given (background interval)
if (!EstimateBkg(histoNo))
return false;
bkg = fBackground;
} else { // fixed bkg given
bkg = fRunInfo->fBkgFix[0];
bkg = fRunInfo->GetBkgFix(0);
}
} else { // bkg fitted
bkg = par[fRunInfo->GetBkgFitParamNo()-1];
@ -880,8 +880,8 @@ Bool_t PRunSingleHisto::EstimateBkg(UInt_t histoNo)
beamPeriod = 0.0;
// check if start and end are in proper order
UInt_t start = fRunInfo->fBkgRange[0];
UInt_t end = fRunInfo->fBkgRange[1];
UInt_t start = fRunInfo->GetBkgRange(0);
UInt_t end = fRunInfo->GetBkgRange(1);
if (end < start) {
cout << endl << "PRunSingleHisto::EstimatBkg(): end = " << end << " > start = " << start << "! Will swap them!";
UInt_t keep = end;
@ -896,7 +896,7 @@ Bool_t PRunSingleHisto::EstimateBkg(UInt_t histoNo)
end = start + (UInt_t)round((Double_t)periods*beamPeriodBins);
cout << endl << "PRunSingleHisto::EstimatBkg(): Background " << start << ", " << end;
if (end == start)
end = fRunInfo->fBkgRange[1];
end = fRunInfo->GetBkgRange(1);
}
// get the proper run

View File

@ -381,6 +381,27 @@ class PMsrRunBlock {
virtual Bool_t IsLifetimeCorrected() { return fLifetimeCorrection; }
virtual PIntVector* GetMap() { return &fMap; }
virtual Int_t GetMap(UInt_t idx);
virtual Int_t GetForwardHistoNo() { return fForwardHistoNo; }
virtual Int_t GetBackwardHistoNo() { return fBackwardHistoNo; }
virtual PDoubleVector GetBkgsFix() { return fBkgFix; }
virtual Double_t GetBkgFix(UInt_t i=0);
virtual PIntVector GetBkgRanges() { return fBkgRange; }
virtual Int_t GetBkgRange(UInt_t i=0);
virtual PIntVector GetDataRanges() { return fDataRange; }
virtual Int_t GetDataRange(UInt_t i=0);
// virtual Int_t GetT0(UInt_t i=0);
// virtual Double_t GetFitRangeFirst() { return fFitRange[0]; }
// virtual Double_t GetFitRangeLast() { return fFitRange[1]; }
// virtual Int_t GetPacking() { return fPacking; }
// virtual Double_t GetRRFFreq() { return fRRFFreq; }
// virtual Int_t GetAlpha2ParamNo() { return fAlpha2ParamNo; }
// virtual Int_t GetBeta2ParamNo() { return fBeta2ParamNo; }
// virtual Int_t GetRightHistoNo() { return fRightHistoNo; }
// virtual Int_t GetLeftHistoNo() { return fLeftHistoNo; }
// virtual Int_t GetXDataIndex() { return fXYDataIndex[0]; }
// virtual Int_t GetYDataIndex() { return fXYDataIndex[1]; }
// virtual TString* GetXDataLabel() { return &fXYDataLabel[0]; }
// virtual TString* GetYDataLabel() { return &fXYDataLabel[1]; }
virtual void AppendRunName(TString str) { fRunName.push_back(str); }
virtual void SetRunName(TString &str, UInt_t i);
@ -400,12 +421,29 @@ class PMsrRunBlock {
virtual void SetLifetimeCorrection(Bool_t bval) { fLifetimeCorrection = bval; }
virtual void AppendMap(Int_t ival) { fMap.push_back(ival); }
virtual void SetMap(Int_t mapVal, UInt_t idx);
virtual void SetForwardHistoNo(Int_t ival) { fForwardHistoNo = ival; }
virtual void SetBackwardHistoNo(Int_t ival) { fBackwardHistoNo = ival; }
virtual void AppendBkgFix(Double_t dval) { fBkgFix.push_back(dval); }
virtual void SetBkgFix(Double_t dval, UInt_t idx);
virtual void AppendBkgRange(Int_t ival) { fBkgRange.push_back(ival); }
virtual void SetBkgRange(Int_t ival, UInt_t idx);
virtual void AppendDataRange(Int_t ival) { fDataRange.push_back(ival); }
virtual void SetDataRange(Int_t ival, UInt_t idx);
// virtual void AppendT0(Int_t ival) { fT0.push_back(ival); }
// virtual void SetT0(Int_t ival, UInt_t idx);
// virtual void SetFitRangeFirst(Double_t dval) { fFitRange[0] = dval; }
// virtual void SetFitRangeLast(Double_t dval) { fFitRange[1] = dval; }
// virtual void SetPacking(Int_t ival) { fPacking = ival; }
// virtual void SetRRFFreq(Double_t dval) { fRRFFreq = dval; }
// virtual void SetAlpha2ParamNo(Int_t ival) { fAlpha2ParamNo = ival; }
// virtual void SetBeta2ParamNo(Int_t ival) { fBeta2ParamNo = ival; }
// virtual void SetRightHistoNo(Int_t ival) { fRightHistoNo = ival; }
// virtual void SetLeftHistoNo(Int_t ival) { fLeftHistoNo = ival; }
// virtual void SetXDataIndex(Int_t ival) { fXYDataIndex[0] = ival; }
// virtual void SetYDataIndex(Int_t ival) { fXYDataIndex[1] = ival; }
// virtual void SetXDataLabel(TString& str) { fXYDataLabel[0] = str; }
// virtual void SetYDataLabel(TString& str) { fXYDataLabel[1] = str; }
Int_t fForwardHistoNo; ///< forward histogram number (fit type 0, 2, 4)
Int_t fBackwardHistoNo; ///< backward histogram number (fit type 2, 4)
PDoubleVector fBkgFix; ///< fixed background in (1/ns) (fit type 0, 2, 4)
PIntVector fBkgRange; ///< background bin range (fit type 0, 2, 4)
PIntVector fDataRange; ///< data bin range (fit type 0, 2, 4)
PIntVector fT0; ///< t0 bins (fit type 0, 2, 4). if fit type 0 -> f0, f1, f2, ...; if fit type 2, 4 -> f0, b0, f1, b1, ...
Double_t fFitRange[2]; ///< fit range in (us)
Int_t fPacking; ///< packing/rebinning
@ -432,6 +470,13 @@ class PMsrRunBlock {
Int_t fLifetimeParamNo; ///< muon lifetime parameter number (fit type 0)
Bool_t fLifetimeCorrection; ///< lifetime correction flag for viewing (fit type 0)
PIntVector fMap; ///< map vector needed to switch parameters for different runs within a single theory
Int_t fForwardHistoNo; ///< forward histogram number (fit type 0, 2, 4)
Int_t fBackwardHistoNo; ///< backward histogram number (fit type 2, 4)
PDoubleVector fBkgFix; ///< fixed background in (1/ns) (fit type 0, 2, 4)
PIntVector fBkgRange; ///< background bin range (fit type 0, 2, 4)
PIntVector fDataRange; ///< data bin range (fit type 0, 2, 4)
// PIntVector fT0; ///< t0 bins (fit type 0, 2, 4). if fit type 0 -> f0, f1, f2, ...; if fit type 2, 4 -> f0, b0, f1, b1, ...
// PDoublePair fFitRange; ///< fit range in (us)
};
//-------------------------------------------------------------

View File

@ -246,7 +246,7 @@ int main(int argc, char *argv[])
switch (runList->at(i).GetFitType()) {
case MSR_FITTYPE_SINGLE_HISTO:
for (unsigned int j=0; j<runList->at(i).GetRunNames().size(); j++) { // necessary in case of ADDRUN
if (!musrt0_item(app, msrHandler, dataHandler->GetRunData(*(runList->at(i).GetRunName(j))), i, runList->at(i).fForwardHistoNo, 0, j)) {
if (!musrt0_item(app, msrHandler, dataHandler->GetRunData(*(runList->at(i).GetRunName(j))), i, runList->at(i).GetForwardHistoNo(), 0, j)) {
musrt0_cleanup(saxParser, startupHandler, msrHandler, dataHandler);
exit(0);
}
@ -254,11 +254,11 @@ int main(int argc, char *argv[])
break;
case MSR_FITTYPE_ASYM:
for (unsigned int j=0; j<runList->at(i).GetRunNames().size(); j++) { // necessary in case of ADDRUN
if (!musrt0_item(app, msrHandler, dataHandler->GetRunData(*(runList->at(i).GetRunName(j))), i, runList->at(i).fForwardHistoNo, 0, j)) {
if (!musrt0_item(app, msrHandler, dataHandler->GetRunData(*(runList->at(i).GetRunName(j))), i, runList->at(i).GetForwardHistoNo(), 0, j)) {
musrt0_cleanup(saxParser, startupHandler, msrHandler, dataHandler);
exit(0);
}
if (!musrt0_item(app, msrHandler, dataHandler->GetRunData(*(runList->at(i).GetRunName(j))), i, runList->at(i).fBackwardHistoNo, 1, j)) {
if (!musrt0_item(app, msrHandler, dataHandler->GetRunData(*(runList->at(i).GetRunName(j))), i, runList->at(i).GetBackwardHistoNo(), 1, j)) {
musrt0_cleanup(saxParser, startupHandler, msrHandler, dataHandler);
exit(0);
}
@ -266,11 +266,11 @@ int main(int argc, char *argv[])
break;
case MSR_FITTYPE_ASYM_RRF:
for (unsigned int j=0; j<runList->at(i).GetRunNames().size(); j++) { // necessary in case of ADDRUN
if (!musrt0_item(app, msrHandler, dataHandler->GetRunData(*(runList->at(i).GetRunName(j))), i, runList->at(i).fForwardHistoNo, 0, j)) {
if (!musrt0_item(app, msrHandler, dataHandler->GetRunData(*(runList->at(i).GetRunName(j))), i, runList->at(i).GetForwardHistoNo(), 0, j)) {
musrt0_cleanup(saxParser, startupHandler, msrHandler, dataHandler);
exit(0);
}
if (!musrt0_item(app, msrHandler, dataHandler->GetRunData(*(runList->at(i).GetRunName(j))), i, runList->at(i).fBackwardHistoNo, 1, j)) {
if (!musrt0_item(app, msrHandler, dataHandler->GetRunData(*(runList->at(i).GetRunName(j))), i, runList->at(i).GetBackwardHistoNo(), 1, j)) {
musrt0_cleanup(saxParser, startupHandler, msrHandler, dataHandler);
exit(0);
}