merge in master

This commit is contained in:
2015-02-14 10:27:03 +01:00
20 changed files with 4619 additions and 1136 deletions

View File

@@ -4,6 +4,7 @@ h_sources = \
../include/PFitterFcn.h \
../include/PFitter.h \
../include/PFourier.h \
../include/PFourierCanvas.h \
../include/PFunctionGrammar.h \
../include/PFunction.h \
../include/PFunctionHandler.h \
@@ -12,6 +13,7 @@ h_sources = \
../include/PMusrCanvas.h \
../include/PMusr.h \
../include/PMusrT0.h \
../include/PPrepFourier.h \
../include/PRunAsymmetry.h \
../include/PRunBase.h \
../include/PRunDataHandler.h \
@@ -26,6 +28,7 @@ h_sources_userFcn = \
../include/PUserFcnBase.h
h_linkdef = \
../include/PFourierCanvasLinkDef.h \
../include/PMusrCanvasLinkDef.h \
../include/PMusrT0LinkDef.h \
../include/PStartupHandlerLinkDef.h
@@ -34,6 +37,7 @@ h_linkdef_userFcn = \
../include/PUserFcnBaseLinkDef.h
dict_h_sources = \
PFourierCanvasDict.h \
PMusrCanvasDict.h \
PMusrT0Dict.h \
PStartupHandlerDict.h
@@ -45,6 +49,7 @@ cpp_sources = \
PFitter.cpp \
PFitterFcn.cpp \
PFourier.cpp \
PFourierCanvas.cpp \
PFunction.cpp \
PFunctionHandler.cpp \
PMsr2Data.cpp \
@@ -52,6 +57,7 @@ cpp_sources = \
PMusrCanvas.cpp \
PMusr.cpp \
PMusrT0.cpp \
PPrepFourier.cpp \
PRunAsymmetry.cpp \
PRunBase.cpp \
PRunDataHandler.cpp \
@@ -66,6 +72,7 @@ cpp_sources_userFcn = \
PUserFcnBase.cpp
dict_cpp_sources = \
PFourierCanvasDict.cpp \
PMusrCanvasDict.cpp \
PMusrT0Dict.cpp \
PStartupHandlerDict.cpp

File diff suppressed because it is too large Load Diff

View File

@@ -269,7 +269,7 @@ Int_t PMsrHandler::ReadMsrFile()
}
// fill parameter-in-use vector
if (result == PMUSR_SUCCESS)
if ((result == PMUSR_SUCCESS) && !fFourierOnly)
FillParameterInUse(theory, functions, run);
// check that each run fulfills the minimum requirements
@@ -278,7 +278,7 @@ Int_t PMsrHandler::ReadMsrFile()
result = PMUSR_MSR_SYNTAX_ERROR;
// check that parameter names are unique
if (result == PMUSR_SUCCESS) {
if ((result == PMUSR_SUCCESS) && !fFourierOnly) {
UInt_t parX, parY;
if (!CheckUniquenessOfParamNames(parX, parY)) {
cerr << endl << ">> PMsrHandler::ReadMsrFile: **SEVERE ERROR** parameter name " << fParam[parX].fName.Data() << " is identical for parameter no " << fParam[parX].fNo << " and " << fParam[parY].fNo << "!";
@@ -290,7 +290,7 @@ Int_t PMsrHandler::ReadMsrFile()
// check that if maps are present in the theory- and/or function-block,
// that there are really present in the run block
if (result == PMUSR_SUCCESS)
if ((result == PMUSR_SUCCESS) && !fFourierOnly)
if (!CheckMaps())
result = PMUSR_MSR_SYNTAX_ERROR;
@@ -2387,6 +2387,10 @@ Int_t PMsrHandler::ParameterInUse(UInt_t paramNo)
*/
Bool_t PMsrHandler::HandleFitParameterEntry(PMsrLines &lines)
{
// If msr-file is used for musrFT only, nothing needs to be done here.
if (fFourierOnly)
return true;
PMsrParamStructure param;
Bool_t error = false;
@@ -2599,6 +2603,10 @@ Bool_t PMsrHandler::HandleFitParameterEntry(PMsrLines &lines)
*/
Bool_t PMsrHandler::HandleTheoryEntry(PMsrLines &lines)
{
// If msr-file is used for musrFT only, nothing needs to be done here.
if (fFourierOnly)
return true;
// store the theory lines
fTheory = lines;
@@ -2619,6 +2627,10 @@ Bool_t PMsrHandler::HandleTheoryEntry(PMsrLines &lines)
*/
Bool_t PMsrHandler::HandleFunctionsEntry(PMsrLines &lines)
{
// If msr-file is used for musrFT only, nothing needs to be done here.
if (fFourierOnly)
return true;
// store the functions lines
fFunctions = lines;
@@ -3157,11 +3169,13 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines)
}
}
// check map entries, i.e. if the map values are within parameter bounds
for (UInt_t i=0; i<param.GetMap()->size(); i++) {
if ((param.GetMap(i) < 0) || (param.GetMap(i) > (Int_t) fParam.size())) {
cerr << endl << ">> PMsrHandler::HandleRunEntry: **SEVERE ERROR** map value " << param.GetMap(i) << " in line " << iter->fLineNo << " is out of range!";
error = true;
break;
if (!fFourierOnly) {
for (UInt_t i=0; i<param.GetMap()->size(); i++) {
if ((param.GetMap(i) < 0) || (param.GetMap(i) > (Int_t) fParam.size())) {
cerr << endl << ">> PMsrHandler::HandleRunEntry: **SEVERE ERROR** map value " << param.GetMap(i) << " in line " << iter->fLineNo << " is out of range!";
error = true;
break;
}
}
}
}
@@ -3515,9 +3529,13 @@ Bool_t PMsrHandler::FilterNumber(TString str, const Char_t *filter, Int_t offset
*/
Bool_t PMsrHandler::HandleCommandsEntry(PMsrLines &lines)
{
// If msr-file is used for musrFT only, nothing needs to be done here.
if (fFourierOnly)
return true;
PMsrLines::iterator iter;
if (lines.empty() && !fFourierOnly) {
if (lines.empty()) {
cerr << endl << ">> PMsrHandler::HandleCommandsEntry(): **WARNING**: There is no COMMAND block! Do you really want this?";
cerr << endl;
}
@@ -4352,7 +4370,11 @@ Bool_t PMsrHandler::HandlePlotEntry(PMsrLines &lines)
*/
Bool_t PMsrHandler::HandleStatisticEntry(PMsrLines &lines)
{
if (lines.empty() && !fFourierOnly) {
// If msr-file is used for musrFT only, nothing needs to be done here.
if (fFourierOnly)
return true;
if (lines.empty()) {
cerr << endl << ">> PMsrHandler::HandleStatisticEntry: **WARNING** There is no STATISTIC block! Do you really want this?";
cerr << endl;
fStatistic.fValid = false;
@@ -5042,7 +5064,7 @@ Bool_t PMsrHandler::CheckRunBlockIntegrity()
}
}
// check fit range
if (!fRuns[i].IsFitRangeInBin()) { // fit range given as times in usec (RUN block)
if (!fRuns[i].IsFitRangeInBin() && !fFourierOnly) { // fit range given as times in usec (RUN block)
if ((fRuns[i].GetFitRange(0) == PMUSR_UNDEFINED) || (fRuns[i].GetFitRange(1) == PMUSR_UNDEFINED)) { // check fit range in RUN block
if (!fGlobal.IsFitRangeInBin()) { // fit range given as times in usec (GLOBAL block)
if ((fGlobal.GetFitRange(0) == PMUSR_UNDEFINED) || (fGlobal.GetFitRange(1) == PMUSR_UNDEFINED)) { // check fit range in GLOBAL block

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,438 @@
/***************************************************************************
PPrepFourier.cpp
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2015 by Andreas Suter *
* 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 *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "PPrepFourier.h"
//--------------------------------------------------------------------------
// Constructor
//--------------------------------------------------------------------------
/**
* <p>Constructor.
*/
PPrepFourier::PPrepFourier()
{
fBkgRange[0] = -1;
fBkgRange[1] = -1;
fPacking = 1;
}
//--------------------------------------------------------------------------
// Constructor
//--------------------------------------------------------------------------
/**
* <p>Constructor.
*/
PPrepFourier::PPrepFourier(const Int_t *bkgRange, const Int_t packing) :
fPacking(packing)
{
SetBkgRange(bkgRange);
}
//--------------------------------------------------------------------------
// Destructor
//--------------------------------------------------------------------------
/**
* <p>Destructor.
*/
PPrepFourier::~PPrepFourier()
{
fRawData.clear();
fData.clear();
}
//--------------------------------------------------------------------------
// SetBkgRange
//--------------------------------------------------------------------------
/**
* <p>set the background range.
*
* \param bkgRange array with background range
*/
void PPrepFourier::SetBkgRange(const Int_t *bkgRange)
{
int err=0;
if (bkgRange[0] >= -1) {
fBkgRange[0] = bkgRange[0];
} else {
err = 1;
}
if (bkgRange[1] >= -1) {
fBkgRange[1] = bkgRange[1];
} else {
if (err == 0)
err = 2;
else
err = 3;
}
TString errMsg("");
switch (err) {
case 1:
errMsg = TString::Format("start bkg range < 0 (given: %d), will ignore it.", bkgRange[0]);
break;
case 2:
errMsg = TString::Format("end bkg range < 0 (given: %d), will ignore it.", bkgRange[1]);
break;
case 3:
errMsg = TString::Format("start/end bkg range < 0 (given: %d/%d), will ignore it.", bkgRange[0], bkgRange[1]);
break;
default:
errMsg = TString("??");
break;
}
if (err != 0) {
cerr << endl << ">> PPrepFourier::SetBkgRange: **WARNING** " << errMsg << endl;
}
}
//--------------------------------------------------------------------------
// SetPacking
//--------------------------------------------------------------------------
/**
* <p>set the packing for the histograms.
*
* \param packing number to be used.
*/
void PPrepFourier::SetPacking(const Int_t packing)
{
if (packing > 0) {
fPacking = packing;
} else {
cerr << endl << ">> PPrepFourier::SetPacking: **WARNING** found packing=" << packing << " < 0, will ignore it." << endl;
}
}
//--------------------------------------------------------------------------
// AddData
//--------------------------------------------------------------------------
/**
* <p>add a data-set (time domain data + meta information) to the internal
* data vector.
*
* \param data set to be added
*/
void PPrepFourier::AddData(musrFT_data &data)
{
fRawData.push_back(data);
}
//--------------------------------------------------------------------------
// DoBkgCorrection
//--------------------------------------------------------------------------
/**
* <p>Correct the internal data sets according to a background interval given.
*/
void PPrepFourier::DoBkgCorrection()
{
// make sure fData are already present, and if not create the necessary data sets
if (fData.size() != fRawData.size()) {
InitData();
}
// if no bkg-range is given, nothing needs to be done
if ((fBkgRange[0] == -1) && (fBkgRange[1] == -1)) {
return;
}
// make sure that the bkg range is ok
for (unsigned int i=0; i<fRawData.size(); i++) {
if ((fBkgRange[0] >= fRawData[i].rawData.size()) || (fBkgRange[1] >= fRawData[i].rawData.size())) {
cerr << endl << "PPrepFourier::DoBkgCorrection() **ERROR** bkg-range out of data-range!";
return;
}
}
Double_t bkg=0.0;
for (unsigned int i=0; i<fRawData.size(); i++) {
// calculate the bkg for the given range
for (int j=fBkgRange[0]; j<=fBkgRange[1]; j++) {
bkg += fRawData[i].rawData[j];
}
bkg /= (fBkgRange[1]-fBkgRange[0]+1);
// correct data
for (unsigned int j=0; j<fData[i].size(); j++)
fData[i][j] -= bkg;
}
}
//--------------------------------------------------------------------------
// DoPacking
//--------------------------------------------------------------------------
/**
* <p>Rebin (pack) the internal data.
*/
void PPrepFourier::DoPacking()
{
// make sure fData are already present, and if not create the necessary data sets
if (fData.size() != fRawData.size()) {
InitData();
}
if (fPacking == 1) // nothing to be done
return;
PDoubleVector tmpData;
Double_t dval = 0.0;
for (unsigned int i=0; i<fData.size(); i++) {
tmpData.clear();
dval = 0.0;
for (unsigned int j=0; j<fData[i].size(); j++) {
if ((j % fPacking == 0) && (j != 0)) {
tmpData.push_back(dval);
dval = 0.0;
} else {
dval += fData[i][j];
}
}
// change the original data set with the packed one
fData[i].clear();
fData[i] = tmpData;
}
}
//--------------------------------------------------------------------------
// DoFiltering
//--------------------------------------------------------------------------
/**
* <p>Not implemented yet.
*/
void PPrepFourier::DoFiltering()
{
// make sure fData are already present, and if not create the necessary data sets
if (fData.size() != fRawData.size()) {
InitData();
}
}
//--------------------------------------------------------------------------
// DoLifeTimeCorrection
//--------------------------------------------------------------------------
/**
* <p>Try to do a muon life time correction. The idea is to estimate N0 without
* any theory. This will be OK for high fields (> couple kGauss) but not so good
* for low fields.
*
* \param fudge rescaling factor for the estimated N0. Should be around 1
*/
void PPrepFourier::DoLifeTimeCorrection(Double_t fudge)
{
// make sure fData are already present, and if not create the necessary data sets
if (fData.size() != fRawData.size()) {
InitData();
}
// calc exp(+t/tau)*N(t), where N(t) is already background corrected
Double_t scale;
for (unsigned int i=0; i<fData.size(); i++) {
scale = fRawData[i].timeResolution / PMUON_LIFETIME;
for (unsigned int j=0; j<fData[i].size(); j++) {
fData[i][j] *= exp(j*scale);
}
}
// calc N0
Double_t dval;
Double_t N0;
for (unsigned int i=0; i<fData.size(); i++) {
dval = 0.0;
for (unsigned int j=0; j<fData[i].size(); j++) {
dval += fData[i][j];
}
N0 = dval/fData[i].size();
N0 *= fudge;
for (unsigned int j=0; j<fData[i].size(); j++) {
fData[i][j] -= N0;
fData[i][j] /= N0;
}
}
}
//--------------------------------------------------------------------------
// GetInfo
//--------------------------------------------------------------------------
/**
* <p>Returns the meta information of a data set.
*
* \param idx index of the object
*/
TString PPrepFourier::GetInfo(const UInt_t idx)
{
TString info("");
if (idx < fRawData.size())
info = fRawData[idx].info;
return info;
}
//--------------------------------------------------------------------------
// GetData
//--------------------------------------------------------------------------
/**
* <p>Creates the requested TH1F objects and returns them. The ownership is with
* the caller.
*/
vector<TH1F*> PPrepFourier::GetData()
{
vector<TH1F*> data;
data.resize(fData.size());
// if not data are present, just return an empty vector
if (fData.size() == 0)
return data;
TString name("");
Double_t dt=0.0;
Double_t start=0.0;
Double_t end=0.0;
UInt_t size;
UInt_t startIdx;
UInt_t endIdx;
for (unsigned int i=0; i<fData.size(); i++) {
name = TString::Format("histo%2d", i);
dt = fRawData[i].timeResolution*fPacking;
start = fRawData[i].timeRange[0];
end = fRawData[i].timeRange[1];
// init size and start/end indices
size = fData[i].size();
startIdx = 1;
endIdx = size;
// time range given, hence calculate the proper size
if (start != -1.0) {
size = (UInt_t)((end-start)/dt);
if (start >= 0.0) {
startIdx = (UInt_t)(start/dt)+1;
endIdx = (UInt_t)(end/dt)+1;
} else {
cerr << endl << ">> PPrepFourier::GetData **WARNING** found start time < 0.0, will set it to 0.0" << endl;
endIdx = static_cast<UInt_t>(end/dt)+1;
}
}
if (start == -1.0) { // no time range given, hence start == 0.0 - dt/2
start = -dt/2.0;
} else { // time range given
start -= dt/2.0;
}
if (end == -1.0) { // no time range given, hence end == (fData[idx].size()-1)*dt + dt/2
end = (fData[i].size()-1)*dt+dt/2.0;
} else { // time range given
end += dt/2.0;
}
data[i] = new TH1F(name.Data(), fRawData[i].info.Data(), size, start, end);
for (unsigned int j=startIdx; j<endIdx; j++)
data[i]->SetBinContent(j-startIdx+1, fData[i][j]);
}
return data;
}
//--------------------------------------------------------------------------
// GetData
//--------------------------------------------------------------------------
/**
* <p>Creates the requested TH1F object and returns it. The ownership is with
* the caller.
*
* \param idx index of the requested histogram
*/
TH1F *PPrepFourier::GetData(const UInt_t idx)
{
if (fData.size() == 0) // no data present
return 0;
if (idx > fData.size()) // requested index out of range
return 0;
TString name = TString::Format("histo%2d", idx);
Double_t dt = fRawData[idx].timeResolution*fPacking;
Double_t start = fRawData[idx].timeRange[0];
Double_t end = fRawData[idx].timeRange[1];
UInt_t size = fData[idx].size();
UInt_t startIdx = 1;
UInt_t endIdx = size;
// time range given, hence calculate the proper size
if (start != -1.0) {
size = (UInt_t)((end-start)/dt);
if (start >= 0.0) {
startIdx = (UInt_t)(start/dt)+1;
endIdx = (UInt_t)(end/dt)+1;
} else {
cerr << endl << ">> PPrepFourier::GetData **WARNING** found start time < 0.0, will set it to 0.0" << endl;
endIdx = (UInt_t)(end/dt)+1;
}
}
if (start == -1.0) { // no time range given, hence start == 0.0 - dt/2
start = -dt/2.0;
} else { // time range given
start -= dt/2.0;
}
if (end == -1.0) { // no time range given, hence end == (fData[idx].size()-1)*dt + dt/2
end = (fData[idx].size()-1)*dt+dt/2.0;
} else { // time range given
end += dt/2.0;
}
TH1F *data = new TH1F(name.Data(), fRawData[idx].info.Data(), size, start, end);
for (unsigned int i=startIdx; i<endIdx; i++)
data->SetBinContent(i-startIdx+1, fData[idx][i]);
return data;
}
//--------------------------------------------------------------------------
// InitData
//--------------------------------------------------------------------------
/**
* <p>Copy raw-data to internal data from t0 to the size of raw-data.
*/
void PPrepFourier::InitData()
{
fData.resize(fRawData.size());
unsigned int t0;
for (unsigned int i=0; i<fRawData.size(); i++) {
if (fRawData[i].t0 >= 0)
t0 = fRawData[i].t0;
else
t0 = 0;
for (unsigned int j=t0; j<fRawData[i].rawData.size(); j++) {
fData[i].push_back(fRawData[i].rawData[j]);
}
}
}

View File

@@ -218,6 +218,7 @@ PRunDataHandler::~PRunDataHandler()
//--------------------------------------------------------------------------
/**
* <p>Checks if runName is found, and if so return these data.
* runName is as given in the msr-file.
*
* <b>return:</b>
* - if data are found: pointer to the data.
@@ -240,6 +241,26 @@ PRawRunData* PRunDataHandler::GetRunData(const TString &runName)
return &fData[i];
}
//--------------------------------------------------------------------------
// GetRunData
//--------------------------------------------------------------------------
/**
* <p>return data-set with index idx.
*
* <b>return:</b>
* - if data are found: pointer to the data.
* - otherwise the null pointer will be returned.
*
* \param idx index of the raw data set.
*/
PRawRunData* PRunDataHandler::GetRunData(const UInt_t idx)
{
if (idx >= fData.size())
return 0;
else
return &fData[idx];
}
//--------------------------------------------------------------------------
// ReadData
//--------------------------------------------------------------------------