start working on RRF. For now only work on the msr-file side is done.

This commit is contained in:
suter_a 2015-12-18 15:34:18 +01:00
parent 18c90fef99
commit c3b5a52519
3 changed files with 188 additions and 19 deletions

View File

@ -612,6 +612,9 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages)
case MSR_FITTYPE_SINGLE_HISTO:
fout << left << "fittype" << MSR_FITTYPE_SINGLE_HISTO << " (single histogram fit)" << endl;
break;
case MSR_FITTYPE_SINGLE_HISTO_RRF:
fout << left << "fittype" << MSR_FITTYPE_SINGLE_HISTO_RRF << " (single histogram RRF fit)" << endl;
break;
case MSR_FITTYPE_ASYM:
fout << left << "fittype" << MSR_FITTYPE_ASYM << " (asymmetry fit)" << endl ;
break;
@ -624,6 +627,9 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages)
default:
break;
}
} else if (sstr.BeginsWith("rrf_freq", TString::kIgnoreCase) && (fGlobal.GetFitType() == MSR_FITTYPE_SINGLE_HISTO_RRF)) {
fout.width(16);
fout << left << "rrf_freq";
} else if (sstr.BeginsWith("data")) {
fout.width(16);
fout << left << "data";
@ -2796,8 +2802,8 @@ Bool_t PMsrHandler::HandleGlobalEntry(PMsrLines &lines)
TString str;
TObjArray *tokens = 0;
TObjString *ostr = 0;
Int_t ival;
Double_t dval;
Int_t ival = 0;
Double_t dval = 0.0;
UInt_t addT0Counter = 0;
// since this routine is called, a GLOBAL block is present
@ -2828,6 +2834,7 @@ Bool_t PMsrHandler::HandleGlobalEntry(PMsrLines &lines)
if (str.IsDigit()) {
Int_t fittype = str.Atoi();
if ((fittype == MSR_FITTYPE_SINGLE_HISTO) ||
(fittype == MSR_FITTYPE_SINGLE_HISTO_RRF) ||
(fittype == MSR_FITTYPE_ASYM) ||
(fittype == MSR_FITTYPE_MU_MINUS) ||
(fittype == MSR_FITTYPE_NON_MUSR)) {
@ -2839,6 +2846,55 @@ Bool_t PMsrHandler::HandleGlobalEntry(PMsrLines &lines)
error = true;
}
}
} else if (iter->fLine.BeginsWith("rrf_freq", TString::kIgnoreCase)) {
if (tokens->GetEntries() < 3) {
error = true;
} else {
ostr = dynamic_cast<TObjString*>(tokens->At(1));
str = ostr->GetString();
if (str.IsFloat()) {
dval = str.Atof();
if (dval <= 0.0)
error = true;
}
if (!error) {
ostr = dynamic_cast<TObjString*>(tokens->At(2));
str = ostr->GetString();
global.SetRRFFreq(dval, str.Data());
if (global.GetRRFFreq(str.Data()) == 0.0)
error = true;
}
}
} else if (iter->fLine.BeginsWith("rrf_packing", TString::kIgnoreCase)) {
if (tokens->GetEntries() < 2) {
error = true;
} else {
ostr = dynamic_cast<TObjString*>(tokens->At(1));
str = ostr->GetString();
if (str.IsDigit()) {
ival = str.Atoi();
if (ival > 0) {
global.SetRRFPacking(ival);
} else {
error = true;
}
} else {
error = true;
}
}
} else if (iter->fLine.BeginsWith("rrf_phase", TString::kIgnoreCase)) {
if (tokens->GetEntries() < 2) {
error = true;
} else {
ostr = dynamic_cast<TObjString*>(tokens->At(1));
str = ostr->GetString();
if (str.IsFloat()) {
dval = str.Atof();
global.SetRRFPhase(dval);
} else {
error = true;
}
}
} else if (iter->fLine.BeginsWith("data", TString::kIgnoreCase)) { // data
if (tokens->GetEntries() < 3) {
error = true;

View File

@ -34,6 +34,8 @@ using namespace std;
#include <boost/algorithm/string.hpp>
using namespace boost;
#include "TMath.h"
#include "PMusr.h"
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@ -708,6 +710,10 @@ void PRawRunData::SetTempError(const UInt_t idx, const Double_t errTemp)
PMsrGlobalBlock::PMsrGlobalBlock()
{
fGlobalPresent = false;
fRRFFreq = 0.0; // rotating reference frequency in units given by fRRFUnitTag. Only needed for fittype 1
fRRFUnitTag = RRF_UNIT_MHz; // RRF unit tag. Default: MHz
fRRFPhase = 0.0;
fRRFPacking = -1; // undefined RRF packing/rebinning
fFitType = -1; // undefined fit type
for (UInt_t i=0; i<4; i++) {
fDataRange[i] = -1; // undefined data bin range
@ -720,6 +726,100 @@ PMsrGlobalBlock::PMsrGlobalBlock()
fPacking = -1; // undefined packing/rebinning
}
//--------------------------------------------------------------------------
// GetRRFFreq (public)
//--------------------------------------------------------------------------
/**
* <p> get RRF frequency value in specific units. If units is unknown, 0.0 will be returned.
*
* \param unit unit string in which the units shall be given
*/
Double_t PMsrGlobalBlock::GetRRFFreq(const char *unit)
{
Double_t freq = 0.0;
// check that the units given make sense
TString unitStr = unit;
Int_t unitTag = RRF_UNIT_UNDEF;
if (!unitStr.CompareTo("MHz", TString::kIgnoreCase))
unitTag = RRF_UNIT_MHz;
else if (!unitStr.CompareTo("Mc", TString::kIgnoreCase))
unitTag = RRF_UNIT_Mcs;
else if (!unitStr.CompareTo("T", TString::kIgnoreCase))
unitTag = RRF_UNIT_T;
else {
cerr << endl << ">> PMsrGlobalBlock::GetRRFFreq: **ERROR** found undefined RRF unit '" << unit << "'!" << endl;
return freq;
}
// calc the conversion factor
if (unitTag == fRRFUnitTag)
freq = fRRFFreq;
else if ((unitTag == RRF_UNIT_MHz) && (fRRFUnitTag == RRF_UNIT_Mcs))
freq = fRRFFreq/TMath::TwoPi();
else if ((unitTag == RRF_UNIT_MHz) && (fRRFUnitTag == RRF_UNIT_T))
freq = fRRFFreq*GAMMA_BAR_MUON;
else if ((unitTag == RRF_UNIT_Mcs) && (fRRFUnitTag == RRF_UNIT_MHz))
freq = fRRFFreq*TMath::TwoPi();
else if ((unitTag == RRF_UNIT_Mcs) && (fRRFUnitTag == RRF_UNIT_T))
freq = fRRFFreq*TMath::TwoPi()*GAMMA_BAR_MUON;
else if ((unitTag == RRF_UNIT_T) && (fRRFUnitTag == RRF_UNIT_MHz))
freq = fRRFFreq/GAMMA_BAR_MUON;
else if ((unitTag == RRF_UNIT_T) && (fRRFUnitTag == RRF_UNIT_Mcs))
freq = fRRFFreq/(TMath::TwoPi()*GAMMA_BAR_MUON);
return freq;
}
//--------------------------------------------------------------------------
// SetRRFFreq (public)
//--------------------------------------------------------------------------
/**
* <p> set RRF frequency value in specific units. If units is unknown, 0.0 will be set.
*
* \param RRF frequency value
* \param unit unit string in which the units shall be given
*/
void PMsrGlobalBlock::SetRRFFreq(Double_t freq, const char *unit)
{
// check that the units given make sense
TString unitStr = unit;
Int_t unitTag = RRF_UNIT_UNDEF;
if (!unitStr.CompareTo("MHz", TString::kIgnoreCase))
unitTag = RRF_UNIT_MHz;
else if (!unitStr.CompareTo("Mc", TString::kIgnoreCase))
unitTag = RRF_UNIT_Mcs;
else if (!unitStr.CompareTo("T", TString::kIgnoreCase))
unitTag = RRF_UNIT_T;
else {
cerr << endl << ">> PMsrGlobalBlock::SetRRFFreq: **ERROR** found undefined RRF unit '" << unit << "'!";
cerr << endl << ">> Will set RRF frequency to 0.0." << endl;
fRRFFreq = 0.0;
fRRFUnitTag = RRF_UNIT_UNDEF;
}
fRRFFreq = freq;
fRRFUnitTag = unitTag;
}
//--------------------------------------------------------------------------
// SetRRFPacking (public)
//--------------------------------------------------------------------------
/**
* <p> set RRF packing.
*
* \param RRF packing
*/
void PMsrGlobalBlock::SetRRFPacking(Int_t pack)
{
if (pack <= 0) {
cerr << endl << "PMsrGlobalBlock::SetRRFPacking: **WARNING** found RRF packing <= 0. Likely doesn't make any sense." << endl;
fRRFPacking = -1; // set to undefined
}
fRRFPacking = pack;
}
//--------------------------------------------------------------------------
// GetDataRange (public)
//--------------------------------------------------------------------------

View File

@ -52,10 +52,11 @@ typedef struct { char a[7]; } __float128; // needed since cint doesn't know it
#define PMUSR_MSR_FILE_WRITE_ERROR -7
#define PMUSR_DATA_FILE_READ_ERROR -8
#define PRUN_SINGLE_HISTO 0
#define PRUN_ASYMMETRY 2
#define PRUN_MU_MINUS 4
#define PRUN_NON_MUSR 8
#define PRUN_SINGLE_HISTO 0
#define PRUN_SINGLE_HISTO_RRF 1
#define PRUN_ASYMMETRY 2
#define PRUN_MU_MINUS 4
#define PRUN_NON_MUSR 8
// muon life time in (us), see PRL99, 032001 (2007)
#define PMUON_LIFETIME 2.197019
@ -92,10 +93,11 @@ typedef struct { char a[7]; } __float128; // needed since cint doesn't know it
//-------------------------------------------------------------
// msr fit type tags
#define MSR_FITTYPE_SINGLE_HISTO 0
#define MSR_FITTYPE_ASYM 2
#define MSR_FITTYPE_MU_MINUS 4
#define MSR_FITTYPE_NON_MUSR 8
#define MSR_FITTYPE_SINGLE_HISTO 0
#define MSR_FITTYPE_SINGLE_HISTO_RRF 1
#define MSR_FITTYPE_ASYM 2
#define MSR_FITTYPE_MU_MINUS 4
#define MSR_FITTYPE_NON_MUSR 8
//-------------------------------------------------------------
// msr plot type tags
@ -133,11 +135,12 @@ typedef struct { char a[7]; } __float128; // needed since cint doesn't know it
//-------------------------------------------------------------
// RRF related tags
#define RRF_UNIT_kHz 0
#define RRF_UNIT_MHz 1
#define RRF_UNIT_Mcs 2
#define RRF_UNIT_G 3
#define RRF_UNIT_T 4
#define RRF_UNIT_UNDEF -1
#define RRF_UNIT_kHz 0
#define RRF_UNIT_MHz 1
#define RRF_UNIT_Mcs 2
#define RRF_UNIT_G 3
#define RRF_UNIT_T 4
//-------------------------------------------------------------
/**
@ -542,6 +545,9 @@ class PMsrGlobalBlock {
virtual ~PMsrGlobalBlock() {}
virtual Bool_t IsPresent() { return fGlobalPresent; }
virtual Double_t GetRRFFreq(const char *unit);
virtual Double_t GetRRFPhase() { return fRRFPhase; }
virtual Int_t GetRRFPacking() { return fRRFPacking; }
virtual Int_t GetFitType() { return fFitType; }
virtual Int_t GetDataRange(UInt_t idx);
virtual UInt_t GetT0BinSize() { return fT0.size(); }
@ -555,6 +561,9 @@ class PMsrGlobalBlock {
virtual Int_t GetPacking() { return fPacking; }
virtual void SetGlobalPresent(Bool_t bval) { fGlobalPresent = bval; }
virtual void SetRRFFreq(Double_t freq, const char *unit);
virtual void SetRRFPhase(Double_t phase) { fRRFPhase = phase; }
virtual void SetRRFPacking(Int_t pack);
virtual void SetFitType(Int_t ival) { fFitType = ival; }
virtual void SetDataRange(Int_t ival, Int_t idx);
virtual void SetT0Bin(Double_t dval, Int_t idx=-1);
@ -566,10 +575,14 @@ class PMsrGlobalBlock {
private:
Bool_t fGlobalPresent; ///< flag showing if a GLOBAL block is present at all.
Int_t fFitType; ///< fit type: 0=single histo fit, 2=asymmetry fit, 4=mu^- single histo fit, 8=non muSR fit
Int_t fDataRange[4]; ///< data bin range (fit type 0, 2, 4)
PDoubleVector fT0; ///< t0 bins (fit type 0, 2, 4). if fit type 0 -> f0, f1, f2, ...; if fit type 2, 4 -> f0, b0, f1, b1, ...
vector<PDoubleVector> fAddT0; ///< addt0 bins (fit type 0, 2, 4). if fit type 0 -> f0, f1, f2, ...; if fit type 2, 4 -> f0, b0, f1, b1, ...
Double_t fRRFFreq; ///< RRF frequency given in units of (MHz, Mc, T)
Int_t fRRFUnitTag; ///< RRF unit tag
Double_t fRRFPhase; ///< RRF phase in (°)
Int_t fRRFPacking; ///< RRF packing
Int_t fFitType; ///< fit type: 0=single histo fit, 1=single histo RRF fit, 2=asymmetry fit, 4=mu^- single histo fit, 8=non muSR fit
Int_t fDataRange[4]; ///< data bin range (fit type 0, 1, 2, 4)
PDoubleVector fT0; ///< t0 bins (fit type 0, 1, 2, 4). if fit type 0 -> f0, f1, f2, ...; if fit type 2, 4 -> f0, b0, f1, b1, ...
vector<PDoubleVector> fAddT0; ///< addt0 bins (fit type 0, 1, 2, 4). if fit type 0 -> f0, f1, f2, ...; if fit type 2, 4 -> f0, b0, f1, b1, ...
Bool_t fFitRangeInBins; ///< flag telling if fit range is given in time or in bins
Double_t fFitRange[2]; ///< fit range in (us)
Int_t fFitRangeOffset[2]; ///< if fit range is given in bins it can have the form fit fgb+n0 lgb-n1. This variable holds the n0 and n1.