From 3c55a724753b10ab8d2df42bdb25a2248214fb36 Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Mon, 12 Nov 2018 20:35:10 +0100 Subject: [PATCH] allow to define the phase parameter lists in the Fourier block with a reference phase parameter. This means all the other phase parameters are then relative to this reference phase parameter. This is often used when analysing LEM data. --- src/classes/PMsrHandler.cpp | 84 ++++++++++++++++++++++++++++++------- src/include/PMusr.h | 3 +- 2 files changed, 71 insertions(+), 16 deletions(-) diff --git a/src/classes/PMsrHandler.cpp b/src/classes/PMsrHandler.cpp index 793a84be..2ac77c76 100644 --- a/src/classes/PMsrHandler.cpp +++ b/src/classes/PMsrHandler.cpp @@ -8,7 +8,7 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007-2016 by Andreas Suter * + * Copyright (C) 2007-2018 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * @@ -3876,6 +3876,7 @@ void PMsrHandler::InitFourierParameterStructure(PMsrFourierStructure &fourier) fourier.fDCCorrected = false; // dc-corrected FFT, default: false fourier.fApodization = FOURIER_APOD_NOT_GIVEN; // apodization, default: NOT GIVEN fourier.fPlotTag = FOURIER_PLOT_NOT_GIVEN; // initial plot tag, default: NOT GIVEN + fourier.fPhaseRef = -1; // initial phase reference -1 means: use absolute phases fourier.fPhaseParamNo.clear(); // initial phase parameter no vector is empty fourier.fPhase.clear(); // initial phase vector is empty for (UInt_t i=0; i<2; i++) { @@ -3967,8 +3968,10 @@ Bool_t PMsrHandler::ParseFourierPhaseValueVector(PMsrFourierStructure &fourier, //-------------------------------------------------------------------------- /** *

examines if str has the form 'phase parX0 [sep parX1 ... sep parXN]'. - * If this form is found, fill in parX0 ... parXN to fFourier.fPhaseParamNo - * and furthermore fill fFourier.fPhase accordingly. + * Also allowed is that instead of parXn only one of the parameters could have the + * form parRn which markes a reference phase for relative phase fittings. + * If this form is found, fill in parX0 ... parXN to fourier.fPhaseParamNo, and + * in case a parR is present, set the fourier.fPhaseRef accordingly. * * @param fourier msr-file Fourier structure * @param str string to be analyzed @@ -3979,6 +3982,7 @@ Bool_t PMsrHandler::ParseFourierPhaseValueVector(PMsrFourierStructure &fourier, Bool_t PMsrHandler::ParseFourierPhaseParVector(PMsrFourierStructure &fourier, const TString &str, Bool_t &error) { Bool_t result = true; + Int_t refCount = 0; TObjArray *tok = str.Tokenize(" ,;\t"); if (tok == 0) { @@ -4004,6 +4008,10 @@ Bool_t PMsrHandler::ParseFourierPhaseParVector(PMsrFourierStructure &fourier, co break; } + if (sstr.BeginsWith("parR")) { + refCount++; + } + // rule out par(X, offset, #Param) syntax if (sstr.BeginsWith("par(")) { result = false; @@ -4011,12 +4019,22 @@ Bool_t PMsrHandler::ParseFourierPhaseParVector(PMsrFourierStructure &fourier, co } } + if (refCount > 1) { + cerr << ">> PMsrHandler::ParseFourierPhaseParVector: **ERROR** found multiple parR's! Only one reference phase is accepted." << endl; + result = false; + } + // check that token has the form parX, where X is an int + Int_t rmNoOf = 3; if (result != false) { for (Int_t i=1; iGetEntries(); i++) { TObjString *ostr = dynamic_cast(tok->At(i)); sstr = ostr->GetString(); - sstr.Remove(0, 3); // remove 'par' part. Rest should be an integer + rmNoOf = 3; + if (sstr.BeginsWith("parR")) { + rmNoOf++; + } + sstr.Remove(0, rmNoOf); // remove 'par' of 'parR' part. Rest should be an integer if (sstr.IsDigit()) { fourier.fPhaseParamNo.push_back(sstr.Atoi()); } else { @@ -4046,9 +4064,9 @@ Bool_t PMsrHandler::ParseFourierPhaseParVector(PMsrFourierStructure &fourier, co // ParseFourierPhaseParIterVector (private) //-------------------------------------------------------------------------- /** - *

examines if str has the form 'phase par(X0, offset, #params)'. - * If this form is found, fill in parX0 ... parXN to fFourier.fPhaseParamNo - * and furthermore fill fFourier.fPhase accordingly. + *

examines if str has the form 'phase par(X0, offset, #params)' or 'phase parR(X0, offset, #params)'. + * If this form is found, fill in parX0 ... parXN to fourier.fPhaseParamNo, and + * in case of 'parR' also set the fourier.fPhaseRef accordingly. * * @param fourier msr-file Fourier structure * @param str string to be analyzed @@ -4065,12 +4083,18 @@ Bool_t PMsrHandler::ParseFourierPhaseParIterVector(PMsrFourierStructure &fourier wstr = wstr.Strip(TString::kLeading, ' '); // remove 'par(' from string if present, otherwise and error is issued - if (!wstr.BeginsWith("par(")) { - cout << ">> PMsrHandler::ParseFourierPhaseParIterVector: **ERROR** token should start with 'par(', found: '" << wstr << "' -> ERROR" << endl; + if (!wstr.BeginsWith("par(") && !wstr.BeginsWith("parR(")) { + cout << ">> PMsrHandler::ParseFourierPhaseParIterVector: **ERROR** token should start with 'par(' or 'parR(', found: '" << wstr << "' -> ERROR" << endl; error = true; return false; } - wstr.Remove(0, 4); + Int_t noOf = 4; // number of characters to be removed + Bool_t relativePhase = false; // relative phase handling wished + if (wstr.BeginsWith("parR(")) { + noOf += 1; + relativePhase = true; + } + wstr.Remove(0, noOf); // remove trailing white spaces wstr = wstr.Strip(TString::kTrailing, ' '); @@ -4133,6 +4157,12 @@ Bool_t PMsrHandler::ParseFourierPhaseParIterVector(PMsrFourierStructure &fourier return false; } + // set the reference phase parameter number for 'parR' + if (relativePhase) + fourier.fPhaseRef = x0; + else + fourier.fPhaseRef = -1; + for (Int_t i=0; i fill corresponding phase values + Double_t phaseRef = 0.0; if (fourier.fPhaseParamNo.size() > 0) { + // check if a relative parameter phase number is set + if (fourier.fPhaseRef != -1) { + phaseRef = fParam[fourier.fPhaseRef-1].fValue; + } fourier.fPhase.clear(); UInt_t idx; for (UInt_t i=0; i