forward/backward accept now not only c0 c1 c2 ... cn, but also c0-cn cm-cp, or c0 c1-cn cm cx-cy, etc. (MUSR-201, improvement whish)

This commit is contained in:
nemu 2011-09-09 11:30:13 +00:00
parent 7cedf2eb14
commit ad14d62117
6 changed files with 227 additions and 54 deletions

View File

@ -6,6 +6,7 @@
changes since 0.9.0
===================================
NEW forward/backward accept now not only c0 c1 c2 ... cn, but also c0-cn cm-cp, or c0 c1-cn cm cx-cy, etc. (MUSR-201, improvement whish).
NEW added minimal NeXus IDF 2 support.
NEW Added the online documentation to the repository. It can be found under "doc/html".
NEW added chisq per run block information (all fit types). The same output rules as for the expected chisq are in place.

View File

@ -0,0 +1,57 @@
nc-ZnO T=80 F=69
###############################################################
FITPARAMETER
# No Name Value Step Pos_Error Boundaries
1 alpha 0.88008 -0.00063 0.00063
2 asym 0.1708 -0.0017 0.0017 0 0.3
3 phase 3.90 -0.38 0.38 0 100
4 field 71.003 -0.036 0.036 0 none
5 rate 0.1526 -0.0024 0.0024 0 100
6 beta 1.231 -0.046 0.047
###############################################################
THEORY
asymmetry 2
TFieldCos 3 fun1 (phase frequency)
generExpo 5 6 (rate exponent)
###############################################################
FUNCTIONS
fun1 = gamma_mu * par4
###############################################################
RUN data/emu00005989_v2 EMU ISIS NEXUS (name beamline institute data-file-format)
fittype 2 (asymmetry fit)
alpha 1
map 0 0 0 0 0 0 0 0 0 0
forward 1-16
backward 17-32
backgr.fix 0 0
data 40 1500 40 1500
fit 0.2 14
packing 1
###############################################################
COMMANDS
MINIMIZE
MINOS
SAVE
###############################################################
FOURIER
units Gauss # units either 'Gauss', 'MHz', or 'Mc/s'
fourier_power 10
apodization STRONG # NONE, WEAK, MEDIUM, STRONG
plot REAL # REAL, IMAG, REAL_AND_IMAG, POWER, PHASE
range 0 100
phase par2
###############################################################
PLOT 2 (asymmetry plot)
runs 1
range 0 14 -0.22 0.22
view_packing 5
###############################################################
STATISTIC --- 2011-09-09 13:24:40
chisq = 796.7, NDF = 846, chisq/NDF = 0.941749

View File

@ -1,12 +1,12 @@
Test asymmetry plot, PSI-BIN data file
FeSe 9p4 TF100 p107apr09_sample*1p02
###############################################################
FITPARAMETER
# Nr. Name Value Step Pos_Error Boundaries
1 alpha 0.954734 0 none 0 2
2 asy 0.262387 0.00144114 none 0 0.33
3 phase -0.0892349 0.327999 none
4 field 97.9113 0.0550109 none 0 none
5 rate 0.31646 0.00441463 none 0 none
2 asy 0.2624 0.0014 none 0 0.33
3 phase -0.10 0.33 none
4 field 97.912 0.055 none 0 none
5 rate 0.3164 0.0044 none 0 none
###############################################################
THEORY
@ -23,12 +23,12 @@ RUN data/deltat_pta_gpd_0423 PIE1 PSI PSI-BIN (name beamline institute data-fi
fittype 2 (asymmetry fit)
alpha 1
map 0 0 0 0 0 0 0 0 0 0 0
forward 2
backward 1
forward 2
backward 1
background 61 184 57 145
data 207 7994 167 8009
t0 202 162
fit 0.00 8.00
fit 0 8
packing 18
###############################################################
@ -44,16 +44,16 @@ units Gauss # units either 'Gauss', 'MHz', or 'Mc/s'
fourier_power 12
apodization NONE # NONE, WEAK, MEDIUM, STRONG
plot POWER # REAL, IMAG, REAL_AND_IMAG, POWER, PHASE
phase 8.50
phase 8
#range_for_phase_correction 50.0 70.0
range 0.00 200.00
range 0 200
###############################################################
PLOT 2 (asymmetry plot)
runs 1
range 0.00 8.00 -0.30 0.30
range 0 8 -0.3 0.3
view_packing 38
###############################################################
STATISTIC --- 2010-05-26 21:27:41
chisq = 545.990682, NDF = 351, chisq/NDF = 1.55552901
STATISTIC --- 2011-09-09 13:26:03
chisq = 554.2, NDF = 351, chisq/NDF = 1.578917

View File

@ -7,7 +7,7 @@ FITPARAMETER
3 field 70.996 -0.035 0.035 0 none
4 asym 0.1698 -0.0016 0.0017 0 0.3
5 rate 0.1523 -0.0023 0.0023 0 100
6 beta 1.261 -0.046 0.047
6 beta 1.261 -0.047 0.047
7 Norm_L 2409.7 -1.2 1.2
8 BG_L 0 0 none 0 none
9 Norm_R 2120.7 -1.1 1.1 0 none
@ -32,7 +32,7 @@ norm 7
backgr.fit 8
lifetimecorrection
map 1 0 0 0 0 0 0 0 0 0
forward 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
forward 1-16
data 40 1500
fit 0.2 14
packing 1
@ -43,7 +43,7 @@ norm 9
backgr.fit 10
lifetimecorrection
map 11 0 0 0 0 0 0 0 0 0
forward 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
forward 17-32
data 40 1500
fit 0.2 14
packing 1
@ -70,5 +70,5 @@ range 0 14 -0.22 0.22
view_packing 5
###############################################################
STATISTIC --- 2011-08-23 14:56:52
STATISTIC --- 2011-09-09 13:25:37
chisq = 2643.1, NDF = 1696, chisq/NDF = 1.558403

View File

@ -704,29 +704,29 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages)
cerr << endl << ">> PMsrHandler::WriteMsrLogFile: **WARNING** 'forward' tag without any data found!";
cerr << endl << ">> Something is VERY fishy, please check your msr-file carfully." << endl;
} else {
fout.width(16);
fout << left << "forward";
for (UInt_t i=0; i<fRuns[runNo].GetForwardHistoNoSize(); i++) {
fout.width(8);
fout << fRuns[runNo].GetForwardHistoNo(i);
}
fout << endl;
TString result("");
PIntVector forward;
for (UInt_t i=0; i<fRuns[runNo].GetForwardHistoNoSize(); i++)
forward.push_back(fRuns[runNo].GetForwardHistoNo(i));
MakeDetectorGroupingString("forward", forward, result);
forward.clear();
fout << result.Data() << endl;
}
} else if (sstr.BeginsWith("backward")) {
if (fRuns[runNo].GetBackwardHistoNoSize() == 0) {
cerr << endl << ">> PMsrHandler::WriteMsrLogFile: **WARNING** 'backward' tag without any data found!";
cerr << endl << ">> Something is VERY fishy, please check your msr-file carfully." << endl;
} else {
fout.width(16);
fout << left << "backward";
for (UInt_t i=0; i<fRuns[runNo].GetBackwardHistoNoSize(); i++) {
fout.width(8);
fout << fRuns[runNo].GetBackwardHistoNo(i);
}
fout << endl;
TString result("");
PIntVector backward;
for (UInt_t i=0; i<fRuns[runNo].GetBackwardHistoNoSize(); i++)
backward.push_back(fRuns[runNo].GetBackwardHistoNo(i));
MakeDetectorGroupingString("backward", backward, result);
backward.clear();
fout << result.Data() << endl;
}
} else if (sstr.BeginsWith("backgr.fix")) {
fout.width(15);
fout.width(16);
fout << left << "backgr.fix";
for (UInt_t j=0; j<2; j++) {
if (fRuns[runNo].GetBkgFix(j) != PMUSR_UNDEFINED) {
@ -2727,19 +2727,16 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines)
if (tokens->GetEntries() < 2) {
error = true;
} else {
for (Int_t i=1; i<tokens->GetEntries(); i++) {
ostr = dynamic_cast<TObjString*>(tokens->At(i));
str = ostr->GetString();
if (str.IsDigit()) {
ival = str.Atoi();
if (ival > 0)
param.SetForwardHistoNo(ival);
else
error = true;
} else {
error = true;
PIntVector group;
str = iter->fLine;
if (ParseDetectorGrouping(str, group)) {
for (UInt_t i=0; i<group.size(); i++) {
param.SetForwardHistoNo(group[i]);
}
} else {
error = true;
}
group.clear();
}
}
@ -2751,19 +2748,16 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines)
if (tokens->GetEntries() < 2) {
error = true;
} else {
for (Int_t i=1; i<tokens->GetEntries(); i++) {
ostr = dynamic_cast<TObjString*>(tokens->At(i));
str = ostr->GetString();
if (str.IsDigit()) {
ival = str.Atoi();
if (ival > 0)
param.SetBackwardHistoNo(ival);
else
error = true;
} else {
error = true;
PIntVector group;
str = iter->fLine;
if (ParseDetectorGrouping(str, group)) {
for (UInt_t i=0; i<group.size(); i++) {
param.SetBackwardHistoNo(group[i]);
}
} else {
error = true;
}
group.clear();
}
}
@ -5070,4 +5064,122 @@ UInt_t PMsrHandler::LastSignificant(Double_t dval, UInt_t precLimit)
return lastSignificant;
}
//--------------------------------------------------------------------------
// ParseDetectorGrouping (private)
//--------------------------------------------------------------------------
/**
* <p>
*
* \param str forward/backward string to be decoded
* \param group decoded detector grouping vector
*
* <b>return:</b> true if parsing was successful, false otherwise.
*/
Bool_t PMsrHandler::ParseDetectorGrouping(TString str, PIntVector &group)
{
TObjArray *tok=0, *tok1=0;
TObjString *ostr=0;
Int_t first=0, last=0;
// change cn - cm to cn-cm. Will *NOT* handle cn - cm etc
str = str.ReplaceAll(" - ", "-");
group.clear();
tok = str.Tokenize(" \t");
// check that there are indeed enough tokens
if (tok->GetEntries() < 2) {
delete tok;
return false;
}
for (Int_t i=1; i<tok->GetEntries(); i++) {
ostr = dynamic_cast<TObjString*>(tok->At(i));
if (ostr->GetString().Contains("-")) { // hopefully a cn-cm token
tok1 = ostr->GetString().Tokenize("-");
if (tok1->GetEntries() == 2) {
ostr = dynamic_cast<TObjString*>(tok1->At(0));
if (ostr->GetString().IsDigit()) {
first = ostr->GetString().Atoi();
} else {
if (tok) delete tok;
if (tok1) delete tok1;
return false;
}
ostr = dynamic_cast<TObjString*>(tok1->At(1));
if (ostr->GetString().IsDigit()) {
last = ostr->GetString().Atoi();
} else {
if (tok) delete tok;
if (tok1) delete tok1;
return false;
}
if (last < first) {
if (tok) delete tok;
return false;
}
for (Int_t i=first; i<=last; i++)
group.push_back(i);
} else {
if (tok) delete tok;
if (tok1) delete tok1;
return false;
}
} else { // hopefully a number
if (ostr->GetString().IsDigit()) {
group.push_back(ostr->GetString().Atoi());
} else {
if (tok) delete tok;
return false;
}
}
}
// clean up
if (tok) delete tok;
if (tok1) delete tok1;
return true;
}
//--------------------------------------------------------------------------
// MakeDetectorGroupingString (private)
//--------------------------------------------------------------------------
/**
* <p>encodes the detector grouping vector.
*
* \param str 'forward' or 'backward'
* \param group detector grouping vector to be encoded
* \param result encoded dtector grouping string
*/
void PMsrHandler::MakeDetectorGroupingString(TString str, PIntVector &group, TString &result)
{
result = str + TString(" ");
if (str == TString("forward"))
result += " ";
UInt_t i=0, j=0;
do {
j = i;
while (group[j]+1 == group[j+1]) {
j++;
if (j == group.size()-1)
break;
}
if (j >= i+2) {
result += group[i];
result += "-";
result += group[j];
i = j+1;
} else {
result += group[i];
i++;
}
result += " ";
} while (i<group.size());
}
// end ---------------------------------------------------------------------

View File

@ -145,6 +145,9 @@ class PMsrHandler
virtual UInt_t NeededPrecision(Double_t dval, UInt_t precLimit=13);
virtual UInt_t LastSignificant(Double_t dval, UInt_t precLimit=6);
virtual Bool_t ParseDetectorGrouping(TString str, PIntVector &group);
virtual void MakeDetectorGroupingString(TString str, PIntVector &group, TString &result);
};
#endif // _PMSRHANDLER_H_