Merged muonspin/musrfit into master

This commit is contained in:
Zaher Salman 2015-02-17 17:08:05 +01:00
commit ee02450af4
8 changed files with 184 additions and 103 deletions

View File

@ -200,6 +200,23 @@ void PFourier::Transform(UInt_t apodizationTag)
}
}
//--------------------------------------------------------------------------
// GetMaxFreq
//--------------------------------------------------------------------------
/**
* <p>returns the maximal frequency in units choosen, i.e. Gauss, Tesla, MHz, Mc/s
*/
Double_t PFourier::GetMaxFreq()
{
UInt_t noOfFourierBins = 0;
if (fNoOfBins % 2 == 0)
noOfFourierBins = fNoOfBins/2;
else
noOfFourierBins = (fNoOfBins+1)/2;
return fResolution*noOfFourierBins;
}
//--------------------------------------------------------------------------
// GetRealFourier
//--------------------------------------------------------------------------

View File

@ -43,8 +43,8 @@ using namespace std;
#define YINFO 0.2
#define YTITLE 0.95
static const char *gFiletypes[] = { "All files", "*",
"Data files", "*.dat",
static const char *gFiletypes[] = { "Data files", "*.dat",
"All files", "*",
0, 0 };
ClassImpQ(PFourierCanvas)
@ -119,7 +119,7 @@ PFourierCanvas::PFourierCanvas(vector<PFourier*> &fourier, const Char_t* title,
CreateXaxisTitle();
CreateStyle();
InitFourierDataSets();
InitFourierCanvas(title, wtopx, wtopy, ww, wh);
InitFourierCanvas(fTitle, wtopx, wtopy, ww, wh);
gStyle->SetHistMinimumZero(kTRUE); // needed to enforce proper bar option handling
}
@ -163,7 +163,7 @@ PFourierCanvas::PFourierCanvas(vector<PFourier*> &fourier, const Char_t* title,
CreateXaxisTitle();
CreateStyle();
InitFourierDataSets();
InitFourierCanvas(title, wtopx, wtopy, ww, wh);
InitFourierCanvas(fTitle, wtopx, wtopy, ww, wh);
gStyle->SetHistMinimumZero(kTRUE); // needed to enforce proper bar option handling
}
@ -856,7 +856,7 @@ void PFourierCanvas::InitFourierCanvas(const Char_t* title, Int_t wtopx, Int_t w
if (!fBatchMode) {
fImp = (TRootCanvas*)fMainCanvas->GetCanvasImp();
fBar = fImp->GetMenuBar();
fPopupMain = fBar->AddPopup("&MusrFT");
fPopupMain = fBar->AddPopup("MusrFT");
fPopupFourier = new TGPopupMenu();
@ -918,7 +918,7 @@ void PFourierCanvas::InitFourierCanvas(const Char_t* title, Int_t wtopx, Int_t w
fTitlePad->Draw();
// fourier pad
fFourierPad = new TPad("fourierPad", "fourierPad", 0.0, YINFO, 1.0, YTITLE);
fFourierPad = new TPad("fFourierPad", "fFourierPad", 0.0, YINFO, 1.0, YTITLE);
if (fFourierPad == 0) {
cerr << endl << "PFourierCanvas::PFourierCanvas: **PANIC ERROR**: Couldn't invoke fFourierPad";
cerr << endl;
@ -1345,8 +1345,8 @@ void PFourierCanvas::DecrementFourierPhase()
if ((fFourierHistos[i].dataFourierRe != 0) && (fFourierHistos[i].dataFourierIm != 0)) {
for (Int_t j=0; j<fFourierHistos[i].dataFourierRe->GetNbinsX(); j++) { // loop over a fourier data set
// calculate new fourier data set value
re = fFourierHistos[i].dataFourierRe->GetBinContent(j) * cp + fFourierHistos[i].dataFourierIm->GetBinContent(j) * sp;
im = fFourierHistos[i].dataFourierIm->GetBinContent(j) * cp - fFourierHistos[i].dataFourierRe->GetBinContent(j) * sp;
re = fFourierHistos[i].dataFourierRe->GetBinContent(j) * cp - fFourierHistos[i].dataFourierIm->GetBinContent(j) * sp;
im = fFourierHistos[i].dataFourierIm->GetBinContent(j) * cp + fFourierHistos[i].dataFourierRe->GetBinContent(j) * sp;
// overwrite fourier data set value
fFourierHistos[i].dataFourierRe->SetBinContent(j, re);
fFourierHistos[i].dataFourierIm->SetBinContent(j, im);

View File

@ -5054,7 +5054,7 @@ Bool_t PMsrHandler::CheckRunBlockIntegrity()
cerr << endl << ">> forward parameter number not defined. Necessary for single histogram fits." << endl;
return false;
}
if (fRuns[i].GetNormParamNo() > static_cast<Int_t>(fParam.size())) {
if ((fRuns[i].GetNormParamNo() > static_cast<Int_t>(fParam.size())) && !fFourierOnly) {
// check if forward histogram number is a function
if (fRuns[i].GetNormParamNo() - MSR_PARAM_FUN_OFFSET > static_cast<Int_t>(fParam.size())) {
cerr << endl << ">> PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1;
@ -5338,6 +5338,9 @@ Bool_t PMsrHandler::CheckFuncs()
{
Bool_t result = true;
if (fFourierOnly)
return result;
PIntVector funVec;
PIntVector funBlock;
PIntVector funLineBlockNo;

View File

@ -3793,7 +3793,7 @@ void PMusrCanvas::HandleAverage()
for (Int_t i=0; i<fData[0].data->GetNbinsX(); i++) {
dval = 0.0;
for (UInt_t j=0; j<fData.size(); j++) {
dval += GetInterpolatedValue(fData[j].data, fData[0].data->GetBinContent(i));
dval += GetInterpolatedValue(fData[j].data, fData[0].data->GetBinCenter(i));
}
fDataAvg.data->SetBinContent(i, dval/fData.size());
}
@ -3807,7 +3807,7 @@ void PMusrCanvas::HandleAverage()
for (Int_t i=0; i<fData[0].dataFourierRe->GetNbinsX(); i++) {
dval = 0.0;
for (UInt_t j=0; j<fData.size(); j++) {
dval += GetInterpolatedValue(fData[j].dataFourierRe, fData[0].dataFourierRe->GetBinContent(i));
dval += GetInterpolatedValue(fData[j].dataFourierRe, fData[0].dataFourierRe->GetBinCenter(i));
}
fDataAvg.dataFourierRe->SetBinContent(i, dval/fData.size());
}
@ -3821,7 +3821,7 @@ void PMusrCanvas::HandleAverage()
for (Int_t i=0; i<fData[0].dataFourierIm->GetNbinsX(); i++) {
dval = 0.0;
for (UInt_t j=0; j<fData.size(); j++) {
dval += GetInterpolatedValue(fData[j].dataFourierIm, fData[0].dataFourierIm->GetBinContent(i));
dval += GetInterpolatedValue(fData[j].dataFourierIm, fData[0].dataFourierIm->GetBinCenter(i));
}
fDataAvg.dataFourierIm->SetBinContent(i, dval/fData.size());
}
@ -3835,7 +3835,7 @@ void PMusrCanvas::HandleAverage()
for (Int_t i=0; i<fData[0].dataFourierPwr->GetNbinsX(); i++) {
dval = 0.0;
for (UInt_t j=0; j<fData.size(); j++) {
dval += GetInterpolatedValue(fData[j].dataFourierPwr, fData[0].dataFourierPwr->GetBinContent(i));
dval += GetInterpolatedValue(fData[j].dataFourierPwr, fData[0].dataFourierPwr->GetBinCenter(i));
}
fDataAvg.dataFourierPwr->SetBinContent(i, dval/fData.size());
}
@ -3849,7 +3849,7 @@ void PMusrCanvas::HandleAverage()
for (Int_t i=0; i<fData[0].dataFourierPhase->GetNbinsX(); i++) {
dval = 0.0;
for (UInt_t j=0; j<fData.size(); j++) {
dval += GetInterpolatedValue(fData[j].dataFourierPhase, fData[0].dataFourierPhase->GetBinContent(i));
dval += GetInterpolatedValue(fData[j].dataFourierPhase, fData[0].dataFourierPhase->GetBinCenter(i));
}
fDataAvg.dataFourierPhase->SetBinContent(i, dval/fData.size());
}
@ -3863,7 +3863,7 @@ void PMusrCanvas::HandleAverage()
for (Int_t i=0; i<fData[0].theory->GetNbinsX(); i++) {
dval = 0.0;
for (UInt_t j=0; j<fData.size(); j++) {
dval += GetInterpolatedValue(fData[j].theory, fData[0].theory->GetBinContent(i));
dval += GetInterpolatedValue(fData[j].theory, fData[0].theory->GetBinCenter(i));
}
fDataAvg.theory->SetBinContent(i, dval/fData.size());
}
@ -3873,7 +3873,7 @@ void PMusrCanvas::HandleAverage()
for (Int_t i=0; i<fData[0].theoryFourierRe->GetNbinsX(); i++) {
dval = 0.0;
for (UInt_t j=0; j<fData.size(); j++) {
dval += GetInterpolatedValue(fData[j].theoryFourierRe, fData[0].theoryFourierRe->GetBinContent(i));
dval += GetInterpolatedValue(fData[j].theoryFourierRe, fData[0].theoryFourierRe->GetBinCenter(i));
}
fDataAvg.theoryFourierRe->SetBinContent(i, dval/fData.size());
}
@ -3887,7 +3887,7 @@ void PMusrCanvas::HandleAverage()
for (Int_t i=0; i<fData[0].theoryFourierIm->GetNbinsX(); i++) {
dval = 0.0;
for (UInt_t j=0; j<fData.size(); j++) {
dval += GetInterpolatedValue(fData[j].theoryFourierIm, fData[0].theoryFourierIm->GetBinContent(i));
dval += GetInterpolatedValue(fData[j].theoryFourierIm, fData[0].theoryFourierIm->GetBinCenter(i));
}
fDataAvg.theoryFourierIm->SetBinContent(i, dval/fData.size());
}
@ -3901,7 +3901,7 @@ void PMusrCanvas::HandleAverage()
for (Int_t i=0; i<fData[0].theoryFourierPwr->GetNbinsX(); i++) {
dval = 0.0;
for (UInt_t j=0; j<fData.size(); j++) {
dval += GetInterpolatedValue(fData[j].theoryFourierPwr, fData[0].theoryFourierPwr->GetBinContent(i));
dval += GetInterpolatedValue(fData[j].theoryFourierPwr, fData[0].theoryFourierPwr->GetBinCenter(i));
}
fDataAvg.theoryFourierPwr->SetBinContent(i, dval/fData.size());
}
@ -3915,7 +3915,7 @@ void PMusrCanvas::HandleAverage()
for (Int_t i=0; i<fData[0].theoryFourierPhase->GetNbinsX(); i++) {
dval = 0.0;
for (UInt_t j=0; j<fData.size(); j++) {
dval += GetInterpolatedValue(fData[j].theoryFourierPhase, fData[0].theoryFourierPhase->GetBinContent(i));
dval += GetInterpolatedValue(fData[j].theoryFourierPhase, fData[0].theoryFourierPhase->GetBinCenter(i));
}
fDataAvg.theoryFourierPhase->SetBinContent(i, dval/fData.size());
}
@ -3929,7 +3929,7 @@ void PMusrCanvas::HandleAverage()
for (Int_t i=0; i<fData[0].diff->GetNbinsX(); i++) {
dval = 0.0;
for (UInt_t j=0; j<fData.size(); j++) {
dval += GetInterpolatedValue(fData[j].diff, fData[0].diff->GetBinContent(i));
dval += GetInterpolatedValue(fData[j].diff, fData[0].diff->GetBinCenter(i));
}
fDataAvg.diff->SetBinContent(i, dval/fData.size());
}
@ -3943,7 +3943,7 @@ void PMusrCanvas::HandleAverage()
for (Int_t i=0; i<fData[0].diffFourierRe->GetNbinsX(); i++) {
dval = 0.0;
for (UInt_t j=0; j<fData.size(); j++) {
dval += GetInterpolatedValue(fData[j].diffFourierRe, fData[0].diffFourierRe->GetBinContent(i));
dval += GetInterpolatedValue(fData[j].diffFourierRe, fData[0].diffFourierRe->GetBinCenter(i));
}
fDataAvg.diffFourierRe->SetBinContent(i, dval/fData.size());
}
@ -3957,7 +3957,7 @@ void PMusrCanvas::HandleAverage()
for (Int_t i=0; i<fData[0].diffFourierIm->GetNbinsX(); i++) {
dval = 0.0;
for (UInt_t j=0; j<fData.size(); j++) {
dval += GetInterpolatedValue(fData[j].diffFourierIm, fData[0].diffFourierIm->GetBinContent(i));
dval += GetInterpolatedValue(fData[j].diffFourierIm, fData[0].diffFourierIm->GetBinCenter(i));
}
fDataAvg.diffFourierIm->SetBinContent(i, dval/fData.size());
}
@ -3971,7 +3971,7 @@ void PMusrCanvas::HandleAverage()
for (Int_t i=0; i<fData[0].diffFourierPwr->GetNbinsX(); i++) {
dval = 0.0;
for (UInt_t j=0; j<fData.size(); j++) {
dval += GetInterpolatedValue(fData[j].diffFourierPwr, fData[0].diffFourierPwr->GetBinContent(i));
dval += GetInterpolatedValue(fData[j].diffFourierPwr, fData[0].diffFourierPwr->GetBinCenter(i));
}
fDataAvg.diffFourierPwr->SetBinContent(i, dval/fData.size());
}
@ -3985,7 +3985,7 @@ void PMusrCanvas::HandleAverage()
for (Int_t i=0; i<fData[0].diffFourierPhase->GetNbinsX(); i++) {
dval = 0.0;
for (UInt_t j=0; j<fData.size(); j++) {
dval += GetInterpolatedValue(fData[j].diffFourierPhase, fData[0].diffFourierPhase->GetBinContent(i));
dval += GetInterpolatedValue(fData[j].diffFourierPhase, fData[0].diffFourierPhase->GetBinCenter(i));
}
fDataAvg.diffFourierPhase->SetBinContent(i, dval/fData.size());
}

View File

@ -50,10 +50,11 @@ PPrepFourier::PPrepFourier()
/**
* <p>Constructor.
*/
PPrepFourier::PPrepFourier(const Int_t *bkgRange, const Int_t packing) :
PPrepFourier::PPrepFourier(const Int_t packing, const Int_t *bkgRange, PDoubleVector bkg) :
fPacking(packing)
{
SetBkgRange(bkgRange);
SetBkg(bkg);
}
//--------------------------------------------------------------------------
@ -114,6 +115,20 @@ void PPrepFourier::SetBkgRange(const Int_t *bkgRange)
}
}
//--------------------------------------------------------------------------
// SetBkgRange
//--------------------------------------------------------------------------
/**
* <p>set the background values for all the histos.
*
* \param bkg vector
*/
void PPrepFourier::SetBkg(PDoubleVector bkg)
{
for (unsigned int i=0; i<bkg.size(); i++)
fBkg.push_back(bkg[i]);
}
//--------------------------------------------------------------------------
// SetPacking
//--------------------------------------------------------------------------
@ -159,10 +174,11 @@ void PPrepFourier::DoBkgCorrection()
}
// if no bkg-range is given, nothing needs to be done
if ((fBkgRange[0] == -1) && (fBkgRange[1] == -1)) {
if ((fBkgRange[0] == -1) && (fBkgRange[1] == -1) && (fBkg.size() == 0)) {
return;
}
if ((fBkgRange[0] != -1) && (fBkgRange[1] != -1)) { // background range is given
// 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())) {
@ -178,11 +194,27 @@ void PPrepFourier::DoBkgCorrection()
bkg += fRawData[i].rawData[j];
}
bkg /= (fBkgRange[1]-fBkgRange[0]+1);
cout << "debug> background " << i << ": " << bkg << endl;
// correct data
for (unsigned int j=0; j<fData[i].size(); j++)
fData[i][j] -= bkg;
}
} else { // there might be an explicit background list
// check if there is a background list
if (fBkg.size() == 0)
return;
// check if there are as many background values than data values
if (fBkg.size() != fData.size()) {
cerr << endl << "PPrepFourier::DoBkgCorrection() **ERROR** #bkg values != #histos. Will do nothing here." << endl;
return;
}
for (unsigned int i=0; i<fData.size(); i++)
for (unsigned int j=0; j<fData[i].size(); j++)
fData[i][j] -= fBkg[i];
}
}
//--------------------------------------------------------------------------
@ -220,20 +252,6 @@ void PPrepFourier::DoPacking()
}
}
//--------------------------------------------------------------------------
// 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
//--------------------------------------------------------------------------
@ -419,7 +437,7 @@ TH1F *PPrepFourier::GetData(const UInt_t idx)
}
//--------------------------------------------------------------------------
// InitData
// InitData (private)
//--------------------------------------------------------------------------
/**
* <p>Copy raw-data to internal data from t0 to the size of raw-data.

View File

@ -55,6 +55,7 @@ class PFourier
virtual const char* GetDataTitle() { return fData->GetTitle(); }
virtual const Int_t GetUnitTag() { return fUnitTag; }
virtual Double_t GetResolution() { return fResolution; }
virtual Double_t GetMaxFreq();
virtual TH1F* GetRealFourier(const Double_t scale = 1.0);
virtual TH1F* GetImaginaryFourier(const Double_t scale = 1.0);
virtual TH1F* GetPowerFourier(const Double_t scale = 1.0);

View File

@ -34,7 +34,8 @@
#include <vector>
using namespace std;
#include "TH1F.h"
#include <TH1F.h>
#include <TMath.h>
#include "PMusr.h"
@ -59,16 +60,16 @@ typedef struct {
class PPrepFourier {
public:
PPrepFourier();
PPrepFourier(const Int_t *bkgRange, const Int_t packing);
PPrepFourier(const Int_t packing, const Int_t *bkgRange, PDoubleVector bkg);
virtual ~PPrepFourier();
void SetBkgRange(const Int_t *bkgRange);
void SetPacking(const Int_t packing);
void AddData(musrFT_data &data);
void DoBkgCorrection();
void DoPacking();
void DoFiltering();
void DoLifeTimeCorrection(Double_t fudge);
virtual void SetBkgRange(const Int_t *bkgRange);
virtual void SetBkg(PDoubleVector bkg);
virtual void SetPacking(const Int_t packing);
virtual void AddData(musrFT_data &data);
virtual void DoBkgCorrection();
virtual void DoPacking();
virtual void DoLifeTimeCorrection(Double_t fudge);
TString GetInfo(const UInt_t idx);
UInt_t GetNoOfData() { return fRawData.size(); }
@ -79,9 +80,10 @@ class PPrepFourier {
vector<musrFT_data> fRawData;
vector<PDoubleVector>fData;
Int_t fBkgRange[2];
PDoubleVector fBkg;
Int_t fPacking;
void InitData();
virtual void InitData();
};
#endif // _PPREPFOURIER_H_

View File

@ -65,7 +65,8 @@ typedef struct {
TString graphicFormat; ///< format for the graphical output dump
TString dumpFln; ///< dump file name for Fourier data output
TString msrFlnOut; ///< dump file name for msr-file generation
int bkg[2]; ///< background range
int bkg_range[2]; ///< background range
vector<double> bkg; ///< background value
TString fourierOpt; ///< Fourier options, i.e. real, imag, power, phase
TString apodization; ///< apodization setting: none, weak, medium, strong
int fourierPower; ///< Fourier power for zero padding, i.e. 2^fourierPower points
@ -95,7 +96,7 @@ void musrFT_syntax()
cout << endl << " -df, --data-file <data-file> : This allows to feed only muSR data file(s) to";
cout << endl << " perform the Fourier transform. Since the extended <msr-file> information";
cout << endl << " are missing, they will need to be provided by to options, or musrFT";
cout << endl << " tries to guess, based on musrFT_startup.xml settings.";
cout << endl << " tries to guess, based on musrfit_startup.xml settings.";
cout << endl << " Options: ";
cout << endl << " --help : display this help and exit";
cout << endl << " --version : output version information and exit";
@ -106,13 +107,13 @@ void musrFT_syntax()
cout << endl << " Supported graphic-format-extension: eps, pdf, gif, jpg, png, svg, xpm, root";
cout << endl << " --dump <fln> : rather than starting a root session and showing Fourier graphs of the data,";
cout << endl << " it will output the Fourier data in an ascii file <fln>.";
cout << endl << " --filter : filter and filter-specific-information -- ***TO BE WRITTEN YET***.";
cout << endl << " -b, --background <start> <end>: background interval used to estimate the backround to be";
cout << endl << " -br, --background-range <start> <end>: background interval used to estimate the background to be";
cout << endl << " subtracted before the Fourier transform. <start>, <end> to be given in bins.";
cout << endl << " -bg, --background <list> : gives the background explicit for each histogram.";
cout << endl << " -fo, --fourier-option <fopt>: <fopt> can be 'real', 'imag', 'real+imag', 'power', or 'phase'.";
cout << endl << " If this is not defined (neither on the command line nor in the musrFT_startup.xml),";
cout << endl << " If this is not defined (neither on the command line nor in the musrfit_startup.xml),";
cout << endl << " default will be 'power'.";
cout << endl << " -apod, --apodization <val> : <val> can be either 'none', 'weak', 'medium', 'strong'.";
cout << endl << " -ap, --apodization <val> : <val> can be either 'none', 'weak', 'medium', 'strong'.";
cout << endl << " Default will be 'none'.";
cout << endl << " -fp, --fourier-power <N> : <N> being the Fourier power, i.e. 2^<N> used for zero padding.";
cout << endl << " Default is -1, i.e. no zero padding will be performed.";
@ -132,9 +133,10 @@ void musrFT_syntax()
cout << endl << " E.g. musrFT -df lem15_his_01234.root --histo 1 3, will only be needed together with";
cout << endl << " the option --data-file. If multiple data file are given, <list> will apply";
cout << endl << " to all data-files given. If --histo is not given, all histos of a data file will be used.";
cout << endl << " <list> can be anything like: 2 3 6, or 2-17, or 1-6 9, etc.";
cout << endl << " -a, --average : show the average of all Fourier transformed data.";
cout << endl << " --t0 <list> : A list of t0's can be provided. This in conjunction with --data-file and";
cout << endl << " --fourier-option real allows to get the proper inital phase if t0's are known.";
cout << endl << " --fourier-option real allows to get the proper initial phase if t0's are known.";
cout << endl << " If a single t0 for multiple histos is given, it is assume, that this t0 is common";
cout << endl << " to all histos.";
cout << endl << " Example: musrFT -df lem15_his_01234.root -fo real --t0 2750 --histo 1 3";
@ -160,8 +162,8 @@ void musrFT_init(musrFT_startup_param &startupParam)
startupParam.graphicFormat = TString("");
startupParam.dumpFln = TString("");
startupParam.msrFlnOut = TString("");
startupParam.bkg[0] = -1;
startupParam.bkg[1] = -1;
startupParam.bkg_range[0] = -1;
startupParam.bkg_range[1] = -1;
startupParam.fourierOpt = TString("??");
startupParam.apodization = TString("none");
startupParam.fourierPower = -1;
@ -321,27 +323,44 @@ int musrFT_parse_options(int argc, char *argv[], musrFT_startup_param &startupPa
}
startupParam.dumpFln = argv[i+1];
i++;
} else if (tstr.Contains("--filter")) {
cout << endl << "debug> found option filter. NOT YET ANY FUNCTIONALITY." << endl;
} else if (tstr.Contains("-b") || tstr.Contains("--background")) {
} else if (tstr.Contains("-br") || tstr.Contains("--background-range")) {
if (i+2 >= argc) { // something is wrong since there needs to be two arguments here
cerr << endl << ">> musrFT **ERROR** found option --background with wrong number of arguments." << endl;
cerr << endl << ">> musrFT **ERROR** found option --background-range with wrong number of arguments." << endl;
return 2;
}
TString bkg[2];
bkg[0] = argv[i+1];
bkg[1] = argv[i+2];
if (!bkg[0].IsDigit()) {
cerr << endl << ">> musrFT **ERROR** <start> bin of option --background is NOT an int-number! ('" << bkg[0] << "')." << endl;
TString bkgRange[2];
bkgRange[0] = argv[i+1];
bkgRange[1] = argv[i+2];
if (!bkgRange[0].IsDigit()) {
cerr << endl << ">> musrFT **ERROR** <start> bin of option --background-range is NOT an int-number! ('" << bkgRange[0] << "')." << endl;
return 2;
}
if (!bkg[1].IsDigit()) {
cerr << endl << ">> musrFT **ERROR** <end> bin of option --background is NOT an int-number! ('" << bkg[1] << "')." << endl;
if (!bkgRange[1].IsDigit()) {
cerr << endl << ">> musrFT **ERROR** <end> bin of option --background-range is NOT an int-number! ('" << bkgRange[1] << "')." << endl;
return 2;
}
startupParam.bkg[0] = bkg[0].Atoi();
startupParam.bkg[1] = bkg[1].Atoi();
startupParam.bkg_range[0] = bkgRange[0].Atoi();
startupParam.bkg_range[1] = bkgRange[1].Atoi();
i += 2;
} else if (tstr.BeginsWith("-bg") || !tstr.CompareTo("--background")) {
TString topt("");
while (++i < argc) {
if (argv[i][0] == '-') {
--i;
break;
} else {
topt = argv[i];
if (!topt.IsFloat()) {
cerr << endl << ">> musrFT **ERROR** found option --background='" << topt << "' which is not a float" << endl;
return 2;
}
startupParam.bkg.push_back(topt.Atoi());
}
}
if (startupParam.bkg.size() == 0) { // something is wrong since there needs to be an argument here
cerr << endl << ">> musrFT **ERROR** found option --background without argument!" << endl;
return 2;
}
} else if (tstr.BeginsWith("-fo") || tstr.BeginsWith("--fourier-option")) {
if (i+1 >= argc) { // something is wrong since there needs to be two arguments here
cerr << endl << ">> musrFT **ERROR** found option --fourier-option without arguments." << endl;
@ -354,7 +373,7 @@ int musrFT_parse_options(int argc, char *argv[], musrFT_startup_param &startupPa
}
startupParam.fourierOpt = topt;
i++;
} else if (tstr.BeginsWith("-apod") || tstr.BeginsWith("--apodization")) {
} else if (tstr.BeginsWith("-ap") || tstr.BeginsWith("--apodization")) {
if (i+1 >= argc) { // something is wrong since there needs to be two arguments here
cerr << endl << ">> musrFT **ERROR** found option --apodization without arguments." << endl;
return 2;
@ -453,7 +472,7 @@ int musrFT_parse_options(int argc, char *argv[], musrFT_startup_param &startupPa
startupParam.t0.push_back(topt.Atoi());
}
}
if (startupParam.dataFln.size() == 0) { // something is wrong since there needs to be an argument here
if (startupParam.t0.size() == 0) { // something is wrong since there needs to be an argument here
cerr << endl << ">> musrFT **ERROR** found option --t0 without argument!" << endl;
return 2;
}
@ -550,11 +569,11 @@ int musrFT_parse_options(int argc, char *argv[], musrFT_startup_param &startupPa
cerr << endl << ">> musrFT **ERROR** neither <msr-file> nor <data-file> defined." << endl;
return 2;
}
if (startupParam.bkg[0] > startupParam.bkg[1]) {
cerr << endl << ">> musrFT **WARNING** in --background, start=" << startupParam.bkg[0] << " > end=" << startupParam.bkg[1] << ", will swap them." << endl;
double swap = startupParam.bkg[0];
startupParam.bkg[0] = startupParam.bkg[1];
startupParam.bkg[1] = swap;
if (startupParam.bkg_range[0] > startupParam.bkg_range[1]) {
cerr << endl << ">> musrFT **WARNING** in --background-range, start=" << startupParam.bkg_range[0] << " > end=" << startupParam.bkg_range[1] << ", will swap them." << endl;
double swap = startupParam.bkg_range[0];
startupParam.bkg_range[0] = startupParam.bkg_range[1];
startupParam.bkg_range[1] = swap;
}
if (startupParam.fourierRange[0] > startupParam.fourierRange[1]) {
cerr << endl << ">> musrFT **WARNING** in --fourier-range, start=" << startupParam.fourierRange[0] << " > end=" << startupParam.fourierRange[1] << ", will swap them." << endl;
@ -875,8 +894,8 @@ void musrFT_dumpMsrFile(musrFT_startup_param &param)
if ((param.t0.size() > 1) && (j < param.t0.size())) {
fout << "t0 " << param.t0[j] << endl;
}
if ((param.bkg[0] > -1) && (param.bkg[1] > -1))
fout << "background " << param.bkg[0] << " " << param.bkg[1] << endl;
if ((param.bkg_range[0] > -1) && (param.bkg_range[1] > -1))
fout << "background " << param.bkg_range[0] << " " << param.bkg_range[1] << endl;
fout << "#--------------------------------------------------------------" << endl;
}
}
@ -1027,7 +1046,7 @@ int main(int argc, char *argv[])
startupHandler->SetStartupOptions(startup_options);
// defines the raw time-domain data vector
PPrepFourier data(startupParam.bkg, startupParam.packing);
PPrepFourier data(startupParam.packing, startupParam.bkg_range, startupParam.bkg);
// load msr-file(s)
vector<PMsrHandler*> msrHandler;
@ -1146,6 +1165,24 @@ int main(int argc, char *argv[])
if (fourierBlock->fFourierBlockPresent) {
// get units
unitTag = fourierBlock->fUnits;
if (startupParam.fourierUnits.BeginsWith("??")) {
switch (unitTag) {
case FOURIER_UNIT_GAUSS:
startupParam.fourierUnits = TString("Gauss");
break;
case FOURIER_UNIT_TESLA:
startupParam.fourierUnits = TString("Tesla");
break;
case FOURIER_UNIT_FREQ:
startupParam.fourierUnits = TString("MHz");
break;
case FOURIER_UNIT_CYCLES:
startupParam.fourierUnits = TString("Mc/s");
break;
default:
break;
}
}
// get fourier power
if (startupParam.fourierPower == -1) { // no Fourier power given from the command line, hence check FOURIER block
if (fourierBlock->fFourierPower > 1)
@ -1277,9 +1314,6 @@ int main(int argc, char *argv[])
// calculate background levels and subtract them from the data
data.DoBkgCorrection();
// do the time domain filtering now
data.DoFiltering();
// do lifetime correction
if (startupParam.lifetimecorrection != 0.0)
data.DoLifeTimeCorrection(startupParam.lifetimecorrection);
@ -1321,7 +1355,13 @@ int main(int argc, char *argv[])
fourier[i]->Transform(apodTag);
}
double end = millitime();
cout << endl << "debug> after FFT. calculation time: " << (end-start)/1.0e3 << " (sec)." << endl;
cout << endl << "info> after FFT. calculation time: " << (end-start)/1.0e3 << " (sec)." << endl;
// make sure that a Fourier range is provided, if not calculate one
if ((startupParam.fourierRange[0] == -1.0) && (startupParam.fourierRange[1] == -1.0)) {
startupParam.fourierRange[0] = 0.0;
startupParam.fourierRange[1] = fourier[0]->GetMaxFreq();
}
PFourierCanvas *fourierCanvas = 0;