newly added. Not for productive used yetsvn diff | grep Index:

This commit is contained in:
nemu
2008-01-08 08:31:58 +00:00
commit c6cc508aaf
85 changed files with 14397 additions and 0 deletions

97
src/include/PFitter.h Normal file
View File

@@ -0,0 +1,97 @@
/***************************************************************************
PFitter.h
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
$Id$
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007 by Andreas Suter *
* andreas.suter@psi.c *
* *
* 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. *
***************************************************************************/
#ifndef _PFITTER_H_
#define _PFITTER_H_
#include "Minuit2/MnUserParameters.h"
#include "Minuit2/FunctionMinimum.h"
#include "PMsrHandler.h"
#include "PRunListCollection.h"
#include "PFitterFcn.h"
/*
Will handle all the possible minuit commands and actually do things ...
*/
#define PMN_INTERACTIVE 0
#define PMN_CONTOURS 1
#define PMN_EIGEN 2
#define PMN_HESSE 3
#define PMN_MACHINE_PRECISION 4
#define PMN_MIGRAD 5
#define PMN_MINIMIZE 6
#define PMN_MINOS 7
#define PMN_PLOT 8
#define PMN_SAVE 9
#define PMN_SCAN 10
#define PMN_SIMPLEX 12
#define PMN_STRATEGY 13
#define PMN_USER_COVARIANCE 14
#define PMN_USER_PARAM_STATE 15
#define PMN_PRINT 16
class PFitter
{
public:
PFitter(PMsrHandler *runInfo, PRunListCollection *runListCollection);
virtual ~PFitter();
bool IsValid() { return fIsValid; }
bool DoFit();
private:
bool fIsValid;
bool fUseChi2;
PMsrHandler *fRunInfo;
PMsrParamList fParams; ///< msr-file parameters
PMsrLines fCmdLines; ///< all the Minuit commands from the msr-file
PIntVector fCmdList; ///< command list
PFitterFcn *fFitterFcn;
ROOT::Minuit2::MnUserParameters fMnUserParams; ///< minuit2 input parameter list
ROOT::Minuit2::FunctionMinimum *fFcnMin; ///<
bool CheckCommands();
bool SetParameters();
bool ExecuteMigrad();
bool ExecuteMinimize();
bool ExecuteMinos();
bool ExecuteSave();
bool ExecuteSimplex();
};
#endif // _PFITTER_H_

58
src/include/PFitterFcn.h Normal file
View File

@@ -0,0 +1,58 @@
/***************************************************************************
PFitterFcn.h
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
$Id$
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007 by Andreas Suter *
* andreas.suter@psi.c *
* *
* 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. *
***************************************************************************/
#ifndef _PFITTERFCN_H_
#define _PFITTERFCN_H_
#include <vector>
#include "Minuit2/FCNBase.h"
#include "PRunListCollection.h"
class PFitterFcn : public ROOT::Minuit2::FCNBase
{
public:
PFitterFcn(PRunListCollection *runList, bool useChi2);
~PFitterFcn();
double Up() const { return fUp; }
double operator()(const std::vector<double>&) const;
unsigned int GetTotalNoOfFittedBins() { return fRunListCollection->GetTotalNoOfBinsFitted(); }
private:
double fUp;
bool fUseChi2;
PRunListCollection *fRunListCollection;
};
#endif // _PFITTERFCN_H_

114
src/include/PFunction.h Normal file
View File

@@ -0,0 +1,114 @@
/***************************************************************************
PFunction.h
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
$Id$
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007 by Andreas Suter *
* andreas.suter@psi.c *
* *
* 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. *
***************************************************************************/
#ifndef _PFUNCTION_H_
#define _PFUNCTION_H_
#include <vector>
#include <boost/spirit/tree/ast.hpp>
using namespace boost::spirit;
#include <TString.h>
#include "PFunctionGrammar.h"
//----------------------------------------------------------------------------
#define OP_ADD 0
#define OP_SUB 1
#define OP_MUL 2
#define OP_DIV 3
#define FUN_COS 0
#define FUN_SIN 1
#define FUN_TAN 2
#define FUN_COSH 3
#define FUN_SINH 4
#define FUN_TANH 5
#define FUN_ACOS 6
#define FUN_ASIN 7
#define FUN_ATAN 8
#define FUN_ACOSH 9
#define FUN_ASINH 10
#define FUN_ATANH 11
#define FUN_LOG 12
#define FUN_LN 13
#define FUN_EXP 14
//----------------------------------------------------------------------------
typedef struct func_tree_node {
int fID; ///< tag showing what tree element this is
int fOperatorTag; ///< tag for '+', '-', '*', '/'
int fFunctionTag; ///< tag got "cos", "sin", ...
int fIvalue; ///< for parameter numbers and maps
double fDvalue; ///< for numbers
vector<func_tree_node> children; ///< holding sub-tree
} PFuncTreeNode;
//----------------------------------------------------------------------------
class PFunction {
public:
PFunction(tree_parse_info<> info);
virtual ~PFunction();
virtual bool IsValid() { return fValid; }
virtual int GetFuncNo() { return fFuncNo; }
virtual bool CheckMapAndParamRange(unsigned int mapSize, unsigned int paramSize);
virtual double Eval(vector<double> param);
virtual void SetMap(vector<int> map) { fMap = map; }
virtual TString* GetFuncString() { return &fFuncString; }
protected:
virtual bool SetFuncNo();
virtual bool FindAndCheckMapAndParamRange(PFuncTreeNode &node, unsigned int mapSize, unsigned int paramSize);
virtual bool GenerateFuncEvalTree();
virtual void FillFuncEvalTree(iter_t const& i, PFuncTreeNode &node);
virtual double EvalNode(PFuncTreeNode &node);
virtual void CleanupFuncEvalTree();
virtual void CleanupNode(PFuncTreeNode &node);
private:
tree_parse_info<> fInfo;
vector<double> fParam;
vector<int> fMap;
PFuncTreeNode fFunc;
bool fValid; ///< flag showing if the function is valid
int fFuncNo; ///< function number, i.e. FUNx with x the function number
virtual void EvalTreeForString(tree_parse_info<> info);
virtual void EvalTreeForStringExpression(iter_t const& i);
TString fFuncString; ///< clear text representation of the function
};
#endif // _PFUNCTION_H_

View File

@@ -0,0 +1,142 @@
/***************************************************************************
PFunctionGrammer.h
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
$Id$
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007 by Andreas Suter *
* andreas.suter@psi.c *
* *
* 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. *
***************************************************************************/
#ifndef _PFUNCTIONGRAMMAR_H_
#define _PFUNCTIONGRAMMAR_H_
#include <iostream>
using namespace std;
//#define BOOST_SPIRIT_DEBUG
#include <boost/spirit/core.hpp>
#include <boost/spirit/tree/ast.hpp>
using namespace boost::spirit;
typedef char const* iterator_t;
typedef tree_match<iterator_t> parse_tree_match_t;
typedef parse_tree_match_t::tree_iterator iter_t;
//--------------------------------------------------------------------------
/**
*
*/
struct PFunctionGrammar : public grammar<PFunctionGrammar>
{
static const int realID = 1;
static const int funLabelID = 2;
static const int parameterID = 3;
static const int mapID = 4;
static const int functionID = 5;
static const int factorID = 6;
static const int termID = 7;
static const int expressionID = 8;
static const int assignmentID = 9;
template <typename ScannerT>
struct definition
{
definition(PFunctionGrammar const& /*self*/)
{
// Start grammar definition
real = leaf_node_d[ real_p ];
fun_label = leaf_node_d[ ( lexeme_d[ "FUN" >> +digit_p ] ) ];
parameter = leaf_node_d[ ( lexeme_d[ "PAR" >> +digit_p ] ) ];
map = leaf_node_d[ ( lexeme_d[ "MAP" >> +digit_p ] ) ];
function = str_p("COS") >> ch_p('(') >> expression >> ch_p(')')
| str_p("SIN") >> ch_p('(') >> expression >> ch_p(')')
| str_p("TAN") >> ch_p('(') >> expression >> ch_p(')')
| str_p("COSH") >> ch_p('(') >> expression >> ch_p(')')
| str_p("SINH") >> ch_p('(') >> expression >> ch_p(')')
| str_p("TANH") >> ch_p('(') >> expression >> ch_p(')')
| str_p("ACOS") >> ch_p('(') >> expression >> ch_p(')')
| str_p("ASIN") >> ch_p('(') >> expression >> ch_p(')')
| str_p("ATAN") >> ch_p('(') >> expression >> ch_p(')')
| str_p("ACOSH") >> ch_p('(') >> expression >> ch_p(')')
| str_p("ASINH") >> ch_p('(') >> expression >> ch_p(')')
| str_p("ATANH") >> ch_p('(') >> expression >> ch_p(')')
| str_p("LOG") >> ch_p('(') >> expression >> ch_p(')')
| str_p("LN") >> ch_p('(') >> expression >> ch_p(')')
| str_p("EXP") >> ch_p('(') >> expression >> ch_p(')')
;
factor = real
| parameter
| map
| function
| inner_node_d[ch_p('(') >> expression >> ch_p(')')]
;
term = factor >>
*( (root_node_d[ch_p('*')] >> factor)
| (root_node_d[ch_p('/')] >> factor)
);
expression = term >>
*( (root_node_d[ch_p('+')] >> term)
| (root_node_d[ch_p('-')] >> term)
);
assignment = (fun_label >> ch_p('=') >> expression);
// End grammar definition
// turn on the debugging info.
BOOST_SPIRIT_DEBUG_RULE(real);
BOOST_SPIRIT_DEBUG_RULE(fun_label);
BOOST_SPIRIT_DEBUG_RULE(parameter);
BOOST_SPIRIT_DEBUG_RULE(map);
BOOST_SPIRIT_DEBUG_RULE(function);
BOOST_SPIRIT_DEBUG_RULE(factor);
BOOST_SPIRIT_DEBUG_RULE(term);
BOOST_SPIRIT_DEBUG_RULE(expression);
BOOST_SPIRIT_DEBUG_RULE(assignment);
}
rule<ScannerT, parser_context<>, parser_tag<assignmentID> > assignment;
rule<ScannerT, parser_context<>, parser_tag<expressionID> > expression;
rule<ScannerT, parser_context<>, parser_tag<termID> > term;
rule<ScannerT, parser_context<>, parser_tag<factorID> > factor;
rule<ScannerT, parser_context<>, parser_tag<functionID> > function;
rule<ScannerT, parser_context<>, parser_tag<mapID> > map;
rule<ScannerT, parser_context<>, parser_tag<parameterID> > parameter;
rule<ScannerT, parser_context<>, parser_tag<funLabelID> > fun_label;
rule<ScannerT, parser_context<>, parser_tag<realID> > real;
rule<ScannerT, parser_context<>, parser_tag<assignmentID> > const&
start() const { return assignment; }
};
};
#endif // _PFUNCTIONGRAMMAR_H_

View File

@@ -0,0 +1,68 @@
/***************************************************************************
PFunctionHandler.h
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
$Id$
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007 by Andreas Suter *
* andreas.suter@psi.c *
* *
* 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. *
***************************************************************************/
#ifndef _PFUNCTIONHANDLER_H_
#define _PFUNCTIONHANDLER_H_
#include <iostream>
#include <vector>
using namespace std;
#include <TString.h>
#include "PMusr.h"
#include "PFunctionGrammar.h"
#include "PFunction.h"
class PFunctionHandler
{
public:
PFunctionHandler(PMsrLines lines);
virtual ~PFunctionHandler();
virtual bool IsValid() { return fValid; }
virtual bool DoParse();
virtual bool CheckMapAndParamRange(unsigned int mapSize, unsigned int paramSize);
virtual double Eval(int funNo, vector<int> map, vector<double> param);
virtual int GetFuncNo(unsigned int idx);
virtual int GetFuncIndex(int funcNo);
virtual unsigned int GetNoOfFuncs() { return fFuncs.size(); }
virtual TString* GetFuncString(unsigned int idx);
private:
bool fValid;
PMsrLines fLines;
vector<PFunction> fFuncs;
};
#endif // _PFUNCTIONHANDLER_H_

114
src/include/PMsrHandler.h Normal file
View File

@@ -0,0 +1,114 @@
/***************************************************************************
PMsrHandler.h
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
$Id$
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007 by Andreas Suter *
* andreas.suter@psi.c *
* *
* 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. *
***************************************************************************/
#ifndef _PMSRHANDLER_H_
#define _PMSRHANDLER_H_
/*
#include <vector>
using namespace std;
*/
#include <TString.h>
#include <TComplex.h>
#include "PMusr.h"
#include "PFunctionHandler.h"
#include "PFunctionGrammar.h"
#include "PFunction.h"
//-------------------------------------------------------------
/**
* <p>
*/
class PMsrHandler
{
public:
PMsrHandler(char *fileName);
virtual ~PMsrHandler();
virtual int ReadMsrFile();
virtual int WriteMsrLogFile();
virtual TString* GetMsrTitle() { return &fTitle; }
virtual PMsrParamList* GetMsrParamList() { return &fParam; }
virtual PMsrLines* GetMsrTheory() { return &fTheory; }
virtual PMsrLines* GetMsrFunctions() { return &fFunctions; }
virtual PMsrRunList* GetMsrRunList() { return &fRuns; }
virtual PMsrLines* GetMsrCommands() { return &fCommands; }
virtual PMsrPlotList* GetMsrPlotList() { return &fPlots; }
virtual PMsrStatisticStructure* GetMsrStatistic() { return &fStatistic; }
virtual unsigned int GetNoOfParams() { return fParam.size(); }
virtual bool SetMsrParamValue(unsigned int i, double value);
virtual bool SetMsrParamStep(unsigned int i, double value);
virtual bool SetMsrParamPosError(unsigned int i, double value);
virtual void SetMsrStatisticMin(double min) { fStatistic.fMin = min; }
virtual void SetMsrStatisticNdf(unsigned int ndf) { fStatistic.fNdf = ndf; }
virtual int GetNoOfFuncs() { return fFuncHandler->GetNoOfFuncs(); }
virtual unsigned int GetFuncNo(int idx) { return fFuncHandler->GetFuncNo(idx); }
virtual unsigned int GetFuncIndex(int funNo) { return fFuncHandler->GetFuncIndex(funNo); }
virtual bool CheckMapAndParamRange(unsigned int mapSize, unsigned int paramSize)
{ return fFuncHandler->CheckMapAndParamRange(mapSize, paramSize); }
virtual double EvalFunc(unsigned int i, vector<int> map, vector<double> param)
{ return fFuncHandler->Eval(i,map,param); }
private:
TString fFileName;
TString fTitle; ///< holds the title string of the msr-file
PMsrParamList fParam; ///< holds a list of the fit parameters
PMsrLines fTheory; ///< holds the theory definition
PMsrLines fFunctions; ///< holds the user defined functions
PMsrRunList fRuns; ///< holds a list of run information
PMsrLines fCommands; ///< holds a list of the minuit commands
PMsrPlotList fPlots; ///< holds a list of the plot input parameters
PMsrStatisticStructure fStatistic; ///< holds the statistic info
int fMsrBlockCounter; ///< used to select the proper msr-block
PFunctionHandler *fFuncHandler; ///< needed to parse functions
virtual bool HandleFitParameterEntry(PMsrLines &line);
virtual bool HandleTheoryEntry(PMsrLines &line);
virtual bool HandleFunctionsEntry(PMsrLines &line);
virtual bool HandleRunEntry(PMsrLines &line);
virtual bool HandleCommandsEntry(PMsrLines &line);
virtual bool HandlePlotEntry(PMsrLines &line);
virtual bool HandleStatisticEntry(PMsrLines &line);
virtual void InitRunParameterStructure(PMsrRunStructure &param);
virtual bool FilterFunMapNumber(TString str, const char *filter, int &no);
};
#endif // _PMSRHANDLER_H_

253
src/include/PMusr.h Normal file
View File

@@ -0,0 +1,253 @@
/***************************************************************************
PMusr.h
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
$Id$
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007 by Andreas Suter *
* andreas.suter@psi.c *
* *
* 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. *
***************************************************************************/
#ifndef _PMUSR_H_
#define _PMUSR_H_
#include <vector>
using namespace std;
#include <TComplex.h>
#include <TString.h>
#define PMUSR_SUCCESS 0
#define PMUSR_WRONG_STARTUP_SYNTAX -1
#define PMUSR_MSR_FILE_NOT_FOUND -2
#define PMUSR_MSR_ALLOCATION_ERROR -3
#define PMUSR_MSR_SYNTAX_ERROR -4
#define PMUSR_TOKENIZE_ERROR -5
#define PMUSR_MSR_LOG_FILE_WRITE_ERROR -6
#define PRUN_SINGLE_HISTO 0
#define PRUN_ASYMMETRY 2
#define PRUN_RRF 4
#define PRUN_NON_MUSR 8
// muon life time in (us)
#define PMUON_LIFETIME 2.19705
// accelerator cycles in (us), needed to determine proper background
#define ACCEL_PERIOD_PSI 0.01975
#define ACCEL_PERIOD_TRIUMF 0.04337
#define ACCEL_PERIOD_RAL 0.0
// used to filter post pileup correct data histos from root files
#define POST_PILEUP_HISTO_OFFSET 20
//-------------------------------------------------------------
// msr block header tags
#define MSR_TAG_TITLE 0
#define MSR_TAG_FITPARAMETER 1
#define MSR_TAG_THEORY 2
#define MSR_TAG_FUNCTIONS 3
#define MSR_TAG_RUN 4
#define MSR_TAG_COMMANDS 5
#define MSR_TAG_PLOT 6
#define MSR_TAG_STATISTIC 7
//-------------------------------------------------------------
// msr fit type tags
#define MSR_FITTYPE_SINGLE_HISTO 0
#define MSR_FITTYPE_ASYM 2
#define MSR_FITTYPE_ASYM_RRF 4
#define MSR_FITTYPE_NO_MUSR 8
//-------------------------------------------------------------
// msr plot type tags
#define MSR_PLOT_SINGLE_HISTO 0
#define MSR_PLOT_ASYM 2
#define MSR_PLOT_ASYM_RRF 4
#define MSR_PLOT_NO_MUSR 8
//-------------------------------------------------------------
// map and fun offsets for parameter parsing
#define MSR_PARAM_MAP_OFFSET 1000
#define MSR_PARAM_FUN_OFFSET 2000
//-------------------------------------------------------------
/**
* <p> typedef to make to code more readable.
*/
typedef vector<int> PIntVector;
//------------------------------------------------------------------------
/**
* <p>
*/
typedef vector<double> PDoubleVector;
//-------------------------------------------------------------
/**
* <p> typedef to make to code more readable.
*/
typedef vector<TComplex> PComplexVector;
//------------------------------------------------------------------------------------------
/**
* <p>Predominantly used in PRunBase.
*/
typedef struct {
vector<double> fTime;
vector<double> fValue;
vector<double> fError;
vector<double> fTheory;
} PRunData;
//------------------------------------------------------------------------
/**
* <p>
*/
typedef struct {
TString fRunName; ///< name of the run
TString fRunTitle; ///< run title
TString fSetup; ///< description of the setup of this run
double fField; ///< magnetic field value
double fTemp; ///< temperature during the run
double fTimeResolution; ///< time resolution of the run
vector<unsigned int> fT0s; ///< vector of t0's of a run
vector<PDoubleVector> fDataBin; ///< vector of all histos of a run
} PRawRunData;
//------------------------------------------------------------------------
/**
* <p>
*/
typedef vector<PRawRunData> PRawRunDataList;
//-------------------------------------------------------------
/**
* <p> Helper structure for parsing. Keeps a msr-file line string and the corresponding line number.
*/
typedef struct {
int fLineNo; ///< original line number of the msr-file
TString fLine; ///< msr-file line
} PMsrLineStructure;
//-------------------------------------------------------------
/**
* <p> typedef to make to code more readable: list of msr-file lines.
*/
typedef vector<PMsrLineStructure> PMsrLines;
//-------------------------------------------------------------
/**
* <p> Holds the information of a parameter.
*/
typedef struct {
int fNoOfParams; ///< how many parameters are given
int fNo; ///< parameter number
TString fName; ///< name
double fValue; ///< value
double fStep; ///< step / error / neg_error, depending on the situation
bool fPosErrorPresent; ///< positive error is defined (as a number)
double fPosError; ///< positive error if present
double fLowerBoundary; ///< lower boundary for the fit parameter
double fUpperBoundary; ///< upper boundary for the fit parameter
} PMsrParamStructure;
//-------------------------------------------------------------
/**
* <p> typedef to make to code more readable: vector of fit parameters.
*/
typedef vector<PMsrParamStructure> PMsrParamList;
//-------------------------------------------------------------
/**
* <p> Holds the information of a single plot block
*
*/
typedef struct {
TString fRunName; ///< name of the run file
TString fBeamline; ///< e.g. mue4, mue1, pim3, emu, m15, ... (former: run type)
TString fInstitute; ///< e.g. psi, ral, triumf (former: run format)
TString fFileFormat; ///< e.g. root, nexus, psi-bin, mud
int fFitType; ///< fit type: 0=single histo fit, 2=asymmetry fit, 4=asymmetry in RRF, 8=non muSR
int fAlphaParamNo; ///< alpha
int fBetaParamNo; ///<
int fNormParamNo; ///<
int fBkgFitParamNo; ///<
int fPhaseParamNo; ///<
int fLifetimeParamNo; ///<
bool fLifetimeCorrection; ///<
PIntVector fMap; ///<
int fForwardHistoNo; ///<
int fBackwardHistoNo; ///<
double fBkgFix[2]; ///<
int fBkgRange[4]; ///<
int fDataRange[4]; ///<
int fT0[2]; ///<
double fFitRange[2]; ///<
int fPacking; ///<
double fRRFFreq; ///< rotating reference frequency
int fRRFPacking; ///< rotating reference packing
int fAlpha2ParamNo; ///<
int fBeta2ParamNo; ///<
int fRightHistoNo; ///<
int fLeftHistoNo; ///<
} PMsrRunStructure;
//-------------------------------------------------------------
/**
* <p> typedef to make to code more readable: list of runs with its parameters.
*/
typedef vector<PMsrRunStructure> PMsrRunList;
//-------------------------------------------------------------
/**
* <p> Holds the information of a single plot block
*/
typedef struct {
int fPlotType; ///< plot type
PComplexVector fRuns; ///< list of runs to be plotted
double fTmin; ///< time minimum
double fTmax; ///< time maximum
double fYmin; ///< asymmetry/counts minimum
double fYmax; ///< asymmetry/counts maximum
} PMsrPlotStructure;
//-------------------------------------------------------------
/**
* <p> typedef to make to code more readable: list of plots.
*/
typedef vector<PMsrPlotStructure> PMsrPlotList;
//-------------------------------------------------------------
/**
* <p>
*/
typedef struct {
PMsrLines fStatLines;
bool fChisq; ///< flag telling if min = chi2 or min = max.likelyhood
double fMin; ///< chi2 or max. likelyhood
unsigned int fNdf; ///< number of degrees of freedom
} PMsrStatisticStructure;
#endif // _PMUSR_H_

View File

@@ -0,0 +1,69 @@
/***************************************************************************
PRunAsymmetry.h
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
$Id$
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007 by Andreas Suter *
* andreas.suter@psi.c *
* *
* 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. *
***************************************************************************/
#ifndef _PRUNASYMMETRY_H_
#define _PRUNASYMMETRY_H_
#include "PRunBase.h"
class PRunAsymmetry : public PRunBase
{
public:
PRunAsymmetry();
PRunAsymmetry(PMsrHandler *msrInfo, PRunDataHandler *rawData, unsigned int runNo);
virtual ~PRunAsymmetry();
virtual double CalcChiSquare(const std::vector<double>& par);
virtual double CalcMaxLikelihood(const std::vector<double>& par);
virtual void CalcTheory();
virtual unsigned int GetNoOfFitBins() { return fNoOfFitBins; }
protected:
virtual bool PrepareData();
private:
unsigned int fAlphaBetaTag; ///< 1-> alpha = beta = 1; 2-> alpha != 1, beta = 1; 3-> alpha = 1, beta != 1; 4-> alpha != 1, beta != 1
double fFitStartTime;
double fFitStopTime;
unsigned int fNoOfFitBins;
vector<double> fForward; ///< forward histo data
vector<double> fForwardErr; ///< forward histo errors
vector<double> fBackward; ///< backward histo data
vector<double> fBackwardErr; ///< backward histo errors
bool SubtractFixBkg();
bool SubtractEstimatedBkg();
};
#endif // _PRUNASYMMETRY_H_

97
src/include/PRunBase.h Normal file
View File

@@ -0,0 +1,97 @@
/***************************************************************************
PRunBase.h
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
$Id$
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007 by Andreas Suter *
* andreas.suter@psi.c *
* *
* 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. *
***************************************************************************/
#ifndef _PRUNBASE_H_
#define _PRUNBASE_H_
#include <vector>
using namespace std;
#include <TString.h>
#include "PMusr.h"
#include "PMsrHandler.h"
#include "PRunDataHandler.h"
#include "PTheory.h"
//#include "PFunctions.h"
//------------------------------------------------------------------------------------------
/**
* brauche ich eine base class um zwischen den verschiedenen run-modi unterscheiden zu können?
* Ich meine:
* - single histogram
* - asymmetry
* - RRF
* - non muSR
*
* --> JA
*
* PTheory and PFunctions werden direkt für jeden run generiert, da man dann maps und functions
* direkt für den spezifischen run umsetzen kann (da man eliminiert alle maps und functions). Dies
* garantiert effiziente theory-Aufrufe da diese in chisq/maxlikelyhood x-fach aufgerufen werden.
*/
class PRunBase
{
public:
PRunBase();
PRunBase(PMsrHandler *msrInfo, PRunDataHandler *rawData, unsigned int runNo);
virtual ~PRunBase();
virtual double CalcChiSquare(const vector<double>& par) = 0; // pure virtual, i.e. needs to be implemented by the deriving class!!
virtual double CalcMaxLikelihood(const vector<double>& par) = 0; // pure virtual, i.e. needs to be implemented by the deriving class!!
virtual void CalcTheory() = 0; // pure virtual, i.e. needs to be implemented by the deriving class!!
virtual PRunData* GetData() { return &fData; }
virtual void CleanUp();
virtual bool IsValid() { return fValid; }
protected:
bool fValid;
unsigned int fRunNo; ///< number of the run within the msr file
PMsrHandler *fMsrInfo; ///< msr-file handler
PMsrRunStructure *fRunInfo; ///< run info used to filter out needed infos for the run
PRunDataHandler *fRawData; ///< holds the raw run data
vector<int> fParamNo; ///< vector of parameter numbers for the specifc run
PRunData fData; ///< data to be fitted
double fTimeResolution; ///< time resolution
vector<int> fT0s; ///< all t0's of a run! The derived classes will handle it
virtual bool PrepareData() = 0; // pure virtual, i.e. needs to be implemented by the deriving class!!
vector<double> fFuncValues; ///< is keeping the values of the functions from the FUNCTIONS block
PTheory *fTheory; ///< theory needed to calculate chi-square
};
#endif // _PRUNBASE_H_

View File

@@ -0,0 +1,76 @@
/***************************************************************************
PRunDataHandler.h
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
$Id$
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007 by Andreas Suter *
* andreas.suter@psi.c *
* *
* 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. *
***************************************************************************/
#ifndef _PRUNDATAHANDLER_H_
#define _PRUNDATAHANDLER_H_
#include <vector>
using namespace std;
#include <TString.h>
#include "PMusr.h"
#include "PMsrHandler.h"
class PRunDataHandler
{
public:
PRunDataHandler(PMsrHandler *msrInfo);
virtual ~PRunDataHandler();
virtual bool IsAllDataAvailable() { return fAllDataAvailable; }
virtual PRawRunData* GetRunData(TString runName);
private:
PMsrHandler *fMsrInfo;
bool fAllDataAvailable; ///< flag indicating if all data sets could be read
TString fRunName; ///< current run name
TString fRunPathName; ///< current path file name
PRawRunDataList fData; ///< keeping all the raw data
virtual bool ReadFile();
virtual bool FileAlreadyRead(PMsrRunStructure &runInfo);
virtual bool FileExistsCheck(PMsrRunStructure &runInfo);
virtual bool ReadRootFile();
virtual bool ReadNexusFile();
virtual bool ReadNemuFile();
virtual bool ReadPsiBinFile();
virtual bool ReadMudFile();
virtual bool ReadAsciiFile();
virtual bool StripWhitespace(TString &str);
virtual bool IsWhitespace(const char *str);
virtual double ToDouble(TString &str, bool &ok);
virtual int ToInt(TString &str, bool &ok);
};
#endif // _PRUNDATAHANDLER_H_

View File

@@ -0,0 +1,86 @@
/***************************************************************************
PRunListCollection.h
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
$Id$
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007 by Andreas Suter *
* andreas.suter@psi.c *
* *
* 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. *
***************************************************************************/
#ifndef _PRUNLISTCOLLECTION_H_
#define _PRUNLISTCOLLECTION_H_
#include <vector>
using namespace std;
#include "PMusr.h"
#include "PMsrHandler.h"
#include "PRunDataHandler.h"
#include "PRunSingleHisto.h"
#include "PRunAsymmetry.h"
#include "PRunRRF.h"
#include "PRunNonMusr.h"
class PRunListCollection
{
public:
PRunListCollection(PMsrHandler *msrInfo, PRunDataHandler *data);
virtual ~PRunListCollection();
virtual bool Add(int runNo);
virtual double GetSingleHistoChisq(const std::vector<double>& par);
virtual double GetAsymmetryChisq(const std::vector<double>& par);
virtual double GetRRFChisq(const std::vector<double>& par);
virtual double GetNonMusrChisq(const std::vector<double>& par);
virtual double GetSingleHistoMaximumLikelihood(const std::vector<double>& par);
virtual double GetAsymmetryMaximumLikelihood(const std::vector<double>& par);
virtual double GetRRFMaximumLikelihood(const std::vector<double>& par);
virtual double GetNonMusrMaximumLikelihood(const std::vector<double>& par);
virtual unsigned int GetTotalNoOfBinsFitted();
virtual unsigned int GetNoOfSingleHisto() { return fRunSingleHistoList.size(); }
virtual unsigned int GetNoOfAsymmetry() { return fRunAsymmetryList.size(); }
virtual unsigned int GetNoOfRRF() { return fRunRRFList.size(); }
virtual unsigned int GetNoOfNonMusr() { return fRunNonMusrList.size(); }
virtual PRunData* GetSingleHisto(unsigned int index);
virtual PRunData* GetAsymmetry(unsigned int index);
virtual PRunData* GetRRF(unsigned int index);
virtual PRunData* GetNonMusr(unsigned int index);
private:
PMsrHandler *fMsrInfo; ///< keeps all msr file info
PRunDataHandler *fData; ///< handles all raw data
vector<PRunSingleHisto*> fRunSingleHistoList;
vector<PRunAsymmetry*> fRunAsymmetryList;
vector<PRunRRF*> fRunRRFList;
vector<PRunNonMusr*> fRunNonMusrList;
};
#endif // _PRUNLISTCOLLECTION_H_

59
src/include/PRunNonMusr.h Normal file
View File

@@ -0,0 +1,59 @@
/***************************************************************************
PRunNonMusr.h
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
$Id$
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007 by Andreas Suter *
* andreas.suter@psi.c *
* *
* 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. *
***************************************************************************/
#ifndef _PRUNNONMUSR_H_
#define _PRUNNONMUSR_H_
#include "PRunBase.h"
class PRunNonMusr : public PRunBase
{
public:
PRunNonMusr();
PRunNonMusr(PMsrHandler *msrInfo, PRunDataHandler *rawData, unsigned int runNo);
virtual ~PRunNonMusr();
virtual double CalcChiSquare(const std::vector<double>& par);
virtual double CalcMaxLikelihood(const std::vector<double>& par);
virtual void CalcTheory();
virtual unsigned int GetNoOfFitBins() { return fNoOfFitBins; }
protected:
virtual bool PrepareData();
private:
double fFitStartTime;
double fFitStopTime;
unsigned int fNoOfFitBins;
};
#endif // _PRUNNONMUSR_H_

59
src/include/PRunRRF.h Normal file
View File

@@ -0,0 +1,59 @@
/***************************************************************************
PRunRRF.h
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
$Id$
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007 by Andreas Suter *
* andreas.suter@psi.c *
* *
* 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. *
***************************************************************************/
#ifndef _PRUNRRF_H_
#define _PRUNRRF_H_
#include "PRunBase.h"
class PRunRRF : public PRunBase
{
public:
PRunRRF();
PRunRRF(PMsrHandler *msrInfo, PRunDataHandler *rawData, unsigned int runNo);
virtual ~PRunRRF();
virtual double CalcChiSquare(const std::vector<double>& par);
virtual double CalcMaxLikelihood(const std::vector<double>& par);
virtual void CalcTheory();
virtual unsigned int GetNoOfFitBins() { return fNoOfFitBins; }
protected:
virtual bool PrepareData();
private:
double fFitStartTime;
double fFitStopTime;
unsigned int fNoOfFitBins;
};
#endif // _PRUNRRF_H_

View File

@@ -0,0 +1,59 @@
/***************************************************************************
PRunSingleHisto.h
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
$Id$
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007 by Andreas Suter *
* andreas.suter@psi.c *
* *
* 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. *
***************************************************************************/
#ifndef _PRUNSINGLEHISTO_H_
#define _PRUNSINGLEHISTO_H_
#include "PRunBase.h"
class PRunSingleHisto : public PRunBase
{
public:
PRunSingleHisto();
PRunSingleHisto(PMsrHandler *msrInfo, PRunDataHandler *rawData, unsigned int runNo);
virtual ~PRunSingleHisto();
virtual double CalcChiSquare(const std::vector<double>& par);
virtual double CalcMaxLikelihood(const std::vector<double>& par);
virtual void CalcTheory();
virtual unsigned int GetNoOfFitBins() { return fNoOfFitBins; }
protected:
virtual bool PrepareData();
private:
double fFitStartTime;
double fFitStopTime;
unsigned int fNoOfFitBins;
};
#endif // _PRUNSINGLEHISTO_H_

View File

@@ -0,0 +1,46 @@
/***************************************************************************
PStartupHandler.h
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
$Id$
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007 by Andreas Suter *
* andreas.suter@psi.c *
* *
* 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. *
***************************************************************************/
#ifndef _PSTARTUPHANDLER_H_
#define _PSTARTUPHANDLER_H_
#include <TSAXParser.h>
#include <TString.h>
class PStartupHandler : public TSAXParser
{
public:
PStartupHandler();
virtual ~PStartupHandler();
};
#endif // _PSTARTUPHANDLER_H_

202
src/include/PTheory.h Normal file
View File

@@ -0,0 +1,202 @@
/***************************************************************************
PTheory.h
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
$Id$
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007 by Andreas Suter *
* andreas.suter@psi.c *
* *
* 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. *
***************************************************************************/
#ifndef _PTHEORY_H_
#define _PTHEORY_H_
#include <vector>
#include <TString.h>
#include "PMsrHandler.h"
// --------------------------------------------------------
// function handling tags
// --------------------------------------------------------
// function tags
#define THEORY_UNDEFINED -1
#define THEORY_ASYMMETRY 0
#define THEORY_SIMPLE_EXP 1
#define THEORY_GENERAL_EXP 2
#define THEORY_SIMPLE_GAUSS 3
#define THEORY_STATIC_GAUSS_KT 4
#define THEORY_STATIC_KT_TABLE 5
#define THEORY_DYNAMIC_KT_TABLE 6
#define THEORY_COMBI_LGKT 7
#define THEORY_SPIN_GLASS 8
#define THEORY_RANDOM_ANISOTROPIC_HYPERFINE 9
#define THEORY_ABRAGAM 10
#define THEORY_INTERNAL_FIELD 11
#define THEORY_TF_COS 12
#define THEORY_BESSEL 13
#define THEORY_INTERNAL_BESSEL 14
#define THEORY_USER 15
// function parameter tags, i.e. how many parameters has a specific function
#define THEORY_PARAM_ASYMMETRY 1 // asymetry
#define THEORY_PARAM_SIMPLE_EXP 1 // damping
#define THEORY_PARAM_GENERAL_EXP 2 // damping, exponents
#define THEORY_PARAM_SIMPLE_GAUSS 1 // damping
#define THEORY_PARAM_STATIC_GAUSS_KT 1 // damping
#define THEORY_PARAM_STATIC_KT_TABLE 2 // frequency, damping
#define THEORY_PARAM_DYNAMIC_KT_TABLE 3 // frequency, damping, hop-rate
#define THEORY_PARAM_COMBI_LGKT 2 // Lorentz rate, Gauss rate
#define THEORY_PARAM_SPIN_GLASS 3 // rate, hop-rate, order parameter
#define THEORY_PARAM_RANDOM_ANISOTROPIC_HYPERFINE 2 // frequency, rate
#define THEORY_PARAM_ABRAGAM 2 // rate, hop-rate
#define THEORY_PARAM_INTERNAL_FIELD 4 // phase, frequency, TF damping, damping
#define THEORY_PARAM_TF_COS 2 // phase, frequency
#define THEORY_PARAM_BESSEL 2 // phase, frequency
#define THEORY_PARAM_INTERNAL_BESSEL 5 // fraction, phase, frequency, TF damping, damping
// number of available user functions
#define THEORY_MAX 15
// deg -> rad factor
#define DEG_TO_RAD 0.0174532925199432955
// 2 pi
#define TWO_PI 6.28318530717958623
class PTheory;
//--------------------------------------------------------------------------------------
/**
* <p>Structure holding the infos of a the available internally defined functions.
*/
typedef struct theo_data_base {
unsigned int fType; ///< function tag
unsigned int fNoOfParam; ///< number of parameters for this function
bool fTable; ///< table flag, indicating if the function is generate from a table
TString fName; ///< name of the function as written into the msr-file
TString fAbbrev; ///< abbreviation of the function name
TString fComment; ///< comment added in the msr-file theory block to help the used
} PTheoDataBase;
//--------------------------------------------------------------------------------------
/*!
* <p> Holds the functions available for the user.
*/
static PTheoDataBase fgTheoDataBase[THEORY_MAX] = {
{THEORY_ASYMMETRY, THEORY_PARAM_ASYMMETRY, false,
"asymmetry", "a", ""},
{THEORY_SIMPLE_EXP, THEORY_PARAM_SIMPLE_EXP, false,
"simplExpo", "se", "(rate)"},
{THEORY_GENERAL_EXP, THEORY_PARAM_GENERAL_EXP, false,
"generExpo", "ge", "(rate exponent)"},
{THEORY_SIMPLE_GAUSS, THEORY_PARAM_SIMPLE_GAUSS, false,
"simpleGss", "sg", "(rate)"},
{THEORY_STATIC_GAUSS_KT, THEORY_PARAM_STATIC_GAUSS_KT, false,
"statGssKt", "stg", "(rate)"},
{THEORY_STATIC_KT_TABLE, THEORY_PARAM_STATIC_KT_TABLE, true,
"statKTTab", "sktt", "(frequency damping table)"},
{THEORY_DYNAMIC_KT_TABLE, THEORY_PARAM_DYNAMIC_KT_TABLE, true,
"dynmKTTab", "dktt", "(frequency damping hopprate table)"},
{THEORY_COMBI_LGKT, THEORY_PARAM_COMBI_LGKT, false,
"combiLGKT", "lgkt", "(LorentzRate GaussRate)"},
{THEORY_SPIN_GLASS, THEORY_PARAM_SPIN_GLASS, false,
"spinGlass", "spg", "(rate hopprate order)"},
{THEORY_RANDOM_ANISOTROPIC_HYPERFINE, THEORY_PARAM_RANDOM_ANISOTROPIC_HYPERFINE, false,
"rdAnisoHf", "rahf", "(frequency rate)"},
{THEORY_ABRAGAM, THEORY_PARAM_ABRAGAM, false,
"abragam", "ab", "(rate hopprate)"},
{THEORY_INTERNAL_FIELD, THEORY_PARAM_INTERNAL_FIELD, false,
"internFld", "if", "(phase frequency Trate Lrate)"},
{THEORY_TF_COS, THEORY_PARAM_TF_COS, false,
"TFieldCos", "tf", "(phase frequency)"},
{THEORY_BESSEL, THEORY_PARAM_BESSEL, false,
"bessel", "b", "(phase frequency)"},
{THEORY_INTERNAL_BESSEL, THEORY_PARAM_INTERNAL_BESSEL, false,
"internBsl", "ib", "(phase frequency Trate Lrate)"}};
//--------------------------------------------------------------------------------------
/**
* <p>
*/
class PTheory
{
public:
PTheory(PMsrHandler *msrInfo, unsigned int runNo, const bool hasParent = false);
virtual ~PTheory();
virtual bool IsValid();
virtual double Func(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const;
private:
virtual unsigned int SearchDataBase(TString name);
virtual void MakeCleanAndTidyTheoryBlock(PMsrLines* fullTheoryBlock);
virtual double Asymmetry(const vector<double>& paramValues, const vector<double>& funcValues) const;
virtual double SimpleExp(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const;
virtual double GeneralExp(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const;
virtual double SimpleGauss(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const;
virtual double StaticGaussKT(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const;
virtual double StaticKTTable(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const;
virtual double DynamicKTTable(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const;
virtual double CombiLGKT(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const;
virtual double SpinGlass(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const;
virtual double RandomAnisotropicHyperfine(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const;
virtual double Abragam(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const;
virtual double InternalField(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const;
virtual double TFCos(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const;
virtual double Bessel(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const;
virtual double InternalBessel(register double t, const vector<double>& paramValues, const vector<double>& funcValues) const;
// variables
bool fValid;
unsigned int fType;
vector<unsigned int> fParamNo; ///< holds the parameter numbers for the theory (including maps and functions, see constructor desciption)
unsigned int fNoOfParam;
// PTable *fTable;
PTheory *fAdd, *fMul;
// unsigned int fTotalNoOfMsrParam;
// TString fUserFun;
// TString fUserFunPreParsed;
PMsrHandler *fMsrInfo;
};
#endif // _PTHEORY_H_