Added the musrfit --title-from-data-file option to msr2data (-t) and made TFitPofB compilable with g++-4.4

This commit is contained in:
Bastian M. Wojek 2009-06-25 18:32:56 +00:00
parent 622a1d704d
commit e1d077050e
9 changed files with 212 additions and 11 deletions

View File

@ -220,7 +220,7 @@ AC_SUBST(ROOT_CFLAGS)
# It should be checked properly for -lMinuit2 -- at the moment we simply look if a header file is present in the include directory:
AC_CHECK_FILE([${ROOTINCDIR}/../include/Minuit2/MnMinimize.h], AC_MSG_RESULT([Minuit2 headers found... OK]),
AC_MSG_ERROR([Minuit2 headers not found... Please check!]))
AC_MSG_WARN([Minuit2 headers not found... Please check!]))
dnl -----------------------------------------------

View File

@ -6,14 +6,14 @@ ROOTCFLAGS = $(shell $(ROOTSYS)/bin/root-config --cflags)
#---------------------------------------------------
OS = LINUX
CXX = g++-4.2.4
CXX = g++-4.4.0
CXXFLAGS = -O3 -Wall -fopenmp -Wno-trigraphs -fPIC
MUSRFITINCLUDE = ../../../include
#MUSRFITINCLUDE = /home/l_wojek/rep/analysis/musrfit/src/include
LOCALINCLUDE = ../include
ROOTINCLUDE = $(ROOTSYS)/include
INCLUDES = -I$(LOCALINCLUDE) -I$(MUSRFITINCLUDE) -I$(ROOTINCLUDE)
LD = g++-4.2.4
LD = g++-4.4.0
LDFLAGS = -O3
SOFLAGS = -O3 -shared -fopenmp -lfftw3_threads -lfftw3 -lm -lpthread

View File

@ -33,6 +33,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <cstdlib>
#include <iostream>
using namespace std;

View File

@ -140,7 +140,7 @@ TLondon1D3LSub::~TLondon1D3LSub() {
// creates (a pointer to) the TPofTCalc object (with the FFT plan)
//------------------
TLondon1DHS::TLondon1DHS() : fCalcNeeded(true), fFirstCall(true), fDeadLayerChanged(true) {
TLondon1DHS::TLondon1DHS() : fCalcNeeded(true), fFirstCall(true) {
// read startup file
string startup_path_name("TFitPofB_startup.xml");
@ -618,7 +618,7 @@ TProximity1D1LHS::TProximity1D1LHS() : fCalcNeeded(true), fFirstCall(true) {
fParForPofB.push_back(startupHandler->GetDeltaB());
fParForPofB.push_back(0.0);
fParForPofB.push_back(0.0); // Bkg-Field
fParForPofB.push_back(0.005); // Bkg-width
fParForPofB.push_back(0.01); // Bkg-width
fParForPofB.push_back(0.0); // Bkg-weight
TTrimSPData *x = new TTrimSPData(rge_path, energy_vec);
@ -669,7 +669,7 @@ double TProximity1D1LHS::operator()(double t, const vector<double> &par) const {
fParForBofZ.push_back(fPar[i]);
// cout << "fParForBofZ[" << i-2 << "] = " << fParForBofZ[i-2] << endl;
}
fFirstCall=false;
fFirstCall = false;
width_changed = true;
dead_layer_changed = true;
// cout << this << endl;

View File

@ -11,6 +11,7 @@
#include "TPofTCalc.h"
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <cassert>

View File

@ -40,6 +40,7 @@
#include <cmath>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <omp.h>

View File

@ -0,0 +1,149 @@
/***************************************************************************
TSkewedGss.cpp
Author: Bastian M. Wojek
e-mail: bastian.wojek@psi.ch
2009/01/24
***************************************************************************/
#include "TSkewedGss.h"
#include <iostream>
#include <cassert>
using namespace std;
#include <TSAXParser.h>
#include "TFitPofBStartupHandler.h"
ClassImp(TSkewedGss)
//------------------
// Destructor of the TSkewedGss class -- cleaning up
//------------------
TSkewedGss::~TSkewedGss() {
fPar.clear();
fParForPofB.clear();
fParForPofT.clear();
delete fPofT;
fPofT = 0;
}
//------------------
// Constructor of the TSkewedGss class -- creates (a pointer to) the TPofTCalc object (with the FFT plan)
//------------------
TSkewedGss::TSkewedGss() : fCalcNeeded(true), fFirstCall(true) {
// read startup file
string startup_path_name("TFitPofB_startup.xml");
TSAXParser *saxParser = new TSAXParser();
TFitPofBStartupHandler *startupHandler = new TFitPofBStartupHandler();
saxParser->ConnectToHandler("TFitPofBStartupHandler", startupHandler);
int status (saxParser->ParseFile(startup_path_name.c_str()));
// check for parse errors
if (status) { // error
cout << endl << "**WARNING** reading/parsing TFitPofB_startup.xml failed." << endl;
}
fWisdom = startupHandler->GetWisdomFile();
fParForPofT.push_back(0.0); // phase
fParForPofT.push_back(startupHandler->GetDeltat());
fParForPofT.push_back(startupHandler->GetDeltaB());
fParForPofB.push_back(startupHandler->GetDeltat());
fParForPofB.push_back(startupHandler->GetDeltaB());
fParForPofB.push_back(0.0); // nu0
fParForPofB.push_back(0.0); // s-
fParForPofB.push_back(0.0); // s+
TPofTCalc *y = new TPofTCalc(fWisdom, fParForPofT);
fPofT = y;
y = 0;
delete y;
// clean up
if (saxParser) {
delete saxParser;
saxParser = 0;
}
if (startupHandler) {
delete startupHandler;
startupHandler = 0;
}
}
//------------------
// TSkewedGss-Method that calls the procedures to create p(B) and P(t)
// It finally returns P(t) for a given t.
// Parameters: all the parameters for the function to be fitted through TSkewedGss (phase,freq0,sigma-,sigma+)
//------------------
double TSkewedGss::operator()(double t, const vector<double> &par) const {
assert(par.size() == 4);
if(t<0.0)
return 1.0;
// check if the function is called the first time and if yes, read in parameters
if(fFirstCall){
fPar = par;
fFirstCall=false;
}
// check if any parameter has changed
bool par_changed(false);
bool only_phase_changed(false);
for (unsigned int i(0); i<fPar.size(); i++) {
if( fPar[i]-par[i] ) {
fPar[i] = par[i];
par_changed = true;
if (i == 0) {
only_phase_changed = true;
} else {
only_phase_changed = false;
}
}
}
if (par_changed)
fCalcNeeded = true;
// if model parameters have changed, recalculate P(B) and P(t)
if (fCalcNeeded) {
fParForPofT[0] = par[0]; // phase
if(!only_phase_changed) {
// cout << " Parameters have changed, (re-)calculating p(B) and P(t) now..." << endl;
fParForPofB[2] = par[1]; // nu0
fParForPofB[3] = par[2]; // sigma-
fParForPofB[4] = par[3]; // sigma+
TPofBCalc PofB("skg", fParForPofB);
fPofT->DoFFT(PofB);
}/* else {
cout << "Only the phase parameter has changed, (re-)calculating P(t) now..." << endl;
}*/
fPofT->CalcPol(fParForPofT);
fCalcNeeded = false;
}
return fPofT->Eval(t);
}

View File

@ -0,0 +1,39 @@
/***************************************************************************
TSkewedGss.h
Author: Bastian M. Wojek
e-mail: bastian.wojek@psi.ch
2009/01/24
***************************************************************************/
#ifndef _TSkewedGss_H_
#define _TSkewedGss_H_
#include "PUserFcnBase.h"
#include "TPofTCalc.h"
class TSkewedGss : public PUserFcnBase {
public:
// default constructor
TSkewedGss();
~TSkewedGss();
double operator()(double, const vector<double>&) const;
private:
mutable vector<double> fPar;
TPofTCalc *fPofT;
mutable bool fCalcNeeded;
mutable bool fFirstCall;
mutable vector<double> fParForPofT;
mutable vector<double> fParForPofB;
string fWisdom;
ClassDef(TSkewedGss,1)
};
#endif //_TSkewedGss_H_

View File

@ -11,11 +11,11 @@ if [ "$#" -lt 2 ] ; then
"musrfit-msr to db/dat converter"
USAGE: msr2data FIRSTRUN# LASTRUN# EXTENSION [noheader | nosummary | fit-TEMPLATERUN# | -oOUTPUT_FILE | -k | data ]
USAGE: msr2data FIRSTRUN# LASTRUN# EXTENSION [noheader | nosummary | fit-TEMPLATERUN# | -oOUTPUT_FILE | -k | -t | data ]
OR
msr2data \[SPACE SEPARATED LIST OF RUNS\] EXTENSION [noheader | nosummary | fit-TEMPLATERUN# | -oOUTPUT_FILE | -k | data ]
msr2data \[SPACE SEPARATED LIST OF RUNS\] EXTENSION [noheader | nosummary | fit-TEMPLATERUN# | -oOUTPUT_FILE | -k | -t | data ]
OR
msr2data RUNLISTFILE EXTENSION [noheader | nosummary | fit-TEMPLATERUN# | -oOUTPUT_FILE | -k | data ]
msr2data RUNLISTFILE EXTENSION [noheader | nosummary | fit-TEMPLATERUN# | -oOUTPUT_FILE | -k | -t | data ]
This small script converts subsequent musrfit msr output files into one db- or column-ASCII-file using bash/awk.
@ -61,6 +61,8 @@ template for the first musrfit input file. The results of the fits will be writt
For keeping the MINUIT2 output files after calling musrfit, i.e. invoke musrfit with the option "--keep-mn2-output" just pass the option "-k" to msr2data. If you pass this option to msr2data but do not fit any data, the option will just be ignored.
If musrfit should add the title present in the first data file mentioned in a RUN block to the title line of the mlog output file, pass the option "-t" to msr2data. Then musrfit is called with the option "--title-from-data-file". If you pass this option to msr2data but do not fit any data, the option will just be ignored.
If your musrfit output files do not have an extension as specified above like "200.msr" you have to call the script as in the following example.
Example 5:
@ -283,7 +285,15 @@ else
for PAR in "$@"
do
if [ "$PAR" == "-k" ]; then
MUSRFITPARAM="-k"
MUSRFITPARAM+=" -k"
break
fi
done
for PAR in "$@"
do
if [ "$PAR" == "-t" ]; then
MUSRFITPARAM+=" -t"
break
fi
done
@ -395,7 +405,7 @@ else
if [ "${CUR_PAR:0:2}" == "-o" ]; then
if [ "$CUR_PAR" == "-o" ]; then
if [ "$l" -ne "$LAST_OPT_PAR" ] && [ "$NEXT_PAR" != "noheader" ] && [ "$NEXT_PAR" != "nosummary" ] \
&& [ "${NEXT_PAR:0:3}" != "fit" ] && [ "$NEXT_PAR" != "-k" ]; then
&& [ "${NEXT_PAR:0:3}" != "fit" ] && [ "$NEXT_PAR" != "-k" ] && [ "$NEXT_PAR" != "-t" ]; then
OUTFILE=$NEXT_PAR
break
else