some more self-consistency checks with RRF.

This commit is contained in:
suter_a 2015-12-19 20:32:07 +01:00
parent c3b5a52519
commit 99864b2b82
4 changed files with 177 additions and 1 deletions

View File

@ -311,6 +311,11 @@ Int_t PMsrHandler::ReadMsrFile()
if (!CheckAddRunParameters())
result = PMUSR_MSR_SYNTAX_ERROR;
// check that if RRF settings are present, the RUN block settings do correspond
if (result == PMUSR_SUCCESS)
if (!CheckRRFSettings())
result = PMUSR_MSR_SYNTAX_ERROR;
if (result == PMUSR_SUCCESS) {
CheckMaxLikelihood(); // check if the user wants to use max likelihood with asymmetry/non-muSR fit (which is not implemented)
CheckLegacyLifetimecorrection(); // check if lifetimecorrection is found in RUN blocks, if yes transfer it to PLOT blocks
@ -629,7 +634,23 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages)
}
} else if (sstr.BeginsWith("rrf_freq", TString::kIgnoreCase) && (fGlobal.GetFitType() == MSR_FITTYPE_SINGLE_HISTO_RRF)) {
fout.width(16);
fout << left << "rrf_freq";
fout << left << "rrf_freq ";
fout.width(8);
fout << left << fGlobal.GetRRFFreq(fGlobal.GetRRFUnit().Data());
fout << " " << fGlobal.GetRRFUnit();
fout << endl;
} else if (sstr.BeginsWith("rrf_phase", TString::kIgnoreCase) && (fGlobal.GetFitType() == MSR_FITTYPE_SINGLE_HISTO_RRF)) {
fout.width(16);
fout << "rrf_phase ";
fout.width(8);
fout << left << fGlobal.GetRRFPhase();
fout << endl;
} else if (sstr.BeginsWith("rrf_packing", TString::kIgnoreCase) && (fGlobal.GetFitType() == MSR_FITTYPE_SINGLE_HISTO_RRF)) {
fout.width(16);
fout << "rrf_packing ";
fout.width(8);
fout << left << fGlobal.GetRRFPacking();
fout << endl;
} else if (sstr.BeginsWith("data")) {
fout.width(16);
fout << left << "data";
@ -1624,6 +1645,30 @@ Int_t PMsrHandler::WriteMsrFile(const Char_t *filename, map<UInt_t, TString> *co
}
}
// RRF related stuff
if ((fGlobal.GetRRFFreq(fGlobal.GetRRFUnit().Data()) > 0.0) && (fGlobal.GetFitType() == MSR_FITTYPE_SINGLE_HISTO_RRF)) {
fout.width(16);
fout << left << "rrf_freq ";
fout.width(8);
fout << left << fGlobal.GetRRFFreq(fGlobal.GetRRFUnit().Data());
fout << " " << fGlobal.GetRRFUnit();
fout << endl;
}
if ((fGlobal.GetRRFPhase() != 0.0) && (fGlobal.GetFitType() == MSR_FITTYPE_SINGLE_HISTO_RRF)) {
fout.width(16);
fout << "rrf_phase ";
fout.width(8);
fout << left << fGlobal.GetRRFPhase();
fout << endl;
}
if ((fGlobal.GetRRFPacking() != -1) && (fGlobal.GetFitType() == MSR_FITTYPE_SINGLE_HISTO_RRF)) {
fout.width(16);
fout << "rrf_packing ";
fout.width(8);
fout << left << fGlobal.GetRRFPacking();
fout << endl;
}
// data range
if ((fGlobal.GetDataRange(0) != -1) || (fGlobal.GetDataRange(1) != -1) || (fGlobal.GetDataRange(2) != -1) || (fGlobal.GetDataRange(3) != -1)) {
fout.width(16);
@ -3169,6 +3214,7 @@ Bool_t PMsrHandler::HandleRunEntry(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)) {
@ -5249,6 +5295,9 @@ Bool_t PMsrHandler::CheckRunBlockIntegrity()
fRuns[i].SetPacking(1);
}
break;
case PRUN_SINGLE_HISTO_RRF:
// STILL MISSING
break;
case PRUN_ASYMMETRY:
// check alpha
if ((fRuns[i].GetAlphaParamNo() == -1) && !fFourierOnly) {
@ -5687,6 +5736,93 @@ void PMsrHandler::CheckMaxLikelihood()
}
}
//--------------------------------------------------------------------------
// CheckRRFSettings (public)
//--------------------------------------------------------------------------
/**
* <p>Make sure that if RRF settings are found in the GLOBAL section, the fit types
* in the RUN blocks correspond.
*/
Bool_t PMsrHandler::CheckRRFSettings()
{
Bool_t result = true;
Int_t fittype = fGlobal.GetFitType();
// first set of tests: if RRF parameters are set, check if RRF fit is chosen.
if (fGlobal.GetRRFFreq(fGlobal.GetRRFUnit().Data()) != 0.0) {
if (fittype != -1) { // check if GLOBAL fittype is set
if (fittype != MSR_FITTYPE_SINGLE_HISTO_RRF) {
cerr << endl << ">> PMsrHandler::CheckRRFSettings: **ERROR** found GLOBAL fittype " << fittype << " and";
cerr << endl << ">> RRF settings in the GLOBAL section. This is NOT compatible. Fix it first.";
result = false;
}
} else { // GLOBAL fittype is NOT set
for (UInt_t i=0; i<fRuns.size(); i++) {
fittype = fRuns[i].GetFitType();
if (fittype != MSR_FITTYPE_SINGLE_HISTO_RRF) {
cerr << endl << ">> PMsrHandler::CheckRRFSettings: **ERROR** found RUN with fittype " << fittype << " and";
cerr << endl << ">> RRF settings in the GLOBAL section. This is NOT compatible. Fix it first.";
result = false;
break;
}
}
}
} else {
if (fGlobal.GetRRFPacking() != -1) {
cerr << endl << ">> PMsrHandler::CheckRRFSettings: **WARNING** found in the GLOBAL section rrf_packing, without";
cerr << endl << ">> rrf_freq. Doesn't make any sense. Will drop rrf_packing";
cerr << endl << endl;
fGlobal.SetRRFPacking(-1);
}
if (fGlobal.GetRRFPhase() != 0.0) {
cerr << endl << ">> PMsrHandler::CheckRRFSettings: **WARNING** found in the GLOBAL section rrf_phase, without";
cerr << endl << ">> rrf_freq. Doesn't make any sense. Will drop rrf_phase";
cerr << endl << endl;
fGlobal.SetRRFPhase(0.0);
}
}
// second set of tests: if RRF fit is chosen, do I find the necessary RRF parameters?
fittype = fGlobal.GetFitType();
if (fittype == MSR_FITTYPE_SINGLE_HISTO_RRF) { // make sure RRF freq and RRF packing are set
if (fGlobal.GetRRFFreq(fGlobal.GetRRFUnit().Data()) == 0.0) {
cerr << endl << ">> PMsrHandler::CheckRRFSettings: **ERROR** RRF fit chosen, but";
cerr << endl << ">> no RRF frequency found in the GLOBAL section! Fix it.";
return false;
}
if (fGlobal.GetRRFPacking() == -1) {
cerr << endl << ">> PMsrHandler::CheckRRFSettings: **ERROR** RRF fit chosen, but";
cerr << endl << ">> no RRF packing found in the GLOBAL section! Fix it.";
return false;
}
} else {
UInt_t rrfFitCounter = 0;
for (UInt_t i=0; i<fRuns.size(); i++) {
fittype = fRuns[i].GetFitType();
if (fittype == MSR_FITTYPE_SINGLE_HISTO_RRF) { // make sure RRF freq and RRF packing are set
rrfFitCounter++;
}
}
if (rrfFitCounter != fRuns.size()) {
cerr << endl << ">> PMsrHandler::CheckRRFSettings: **ERROR** #Runs (" << fRuns.size() << ") != # RRF fits found (" << rrfFitCounter << ")";
cerr << endl << ">> This is currently not supported.";
return false;
}
if (fGlobal.GetRRFFreq(fGlobal.GetRRFUnit().Data()) == 0.0) {
cerr << endl << ">> PMsrHandler::CheckRRFSettings: **ERROR** RRF fit chosen, but";
cerr << endl << ">> no RRF frequency found in the GLOBAL section! Fix it.";
return false;
}
if (fGlobal.GetRRFPacking() == -1) {
cerr << endl << ">> PMsrHandler::CheckRRFSettings: **ERROR** RRF fit chosen, but";
cerr << endl << ">> no RRF packing found in the GLOBAL section! Fix it.";
return false;
}
}
return result;
}
//--------------------------------------------------------------------------
// GetGroupingString (public)
//--------------------------------------------------------------------------

View File

@ -802,6 +802,43 @@ void PMsrGlobalBlock::SetRRFFreq(Double_t freq, const char *unit)
fRRFUnitTag = unitTag;
}
//--------------------------------------------------------------------------
// GetRRFUnit (public)
//--------------------------------------------------------------------------
/**
* <p> returns RRF frequency unit.
*/
TString PMsrGlobalBlock::GetRRFUnit()
{
TString unit;
switch (fRRFUnitTag) {
case RRF_UNIT_UNDEF:
unit = TString("??");
break;
case RRF_UNIT_kHz:
unit = TString("kHz");
break;
case RRF_UNIT_MHz:
unit = TString("MHz");
break;
case RRF_UNIT_Mcs:
unit = TString("Mc");
break;
case RRF_UNIT_G:
unit = TString("G");
break;
case RRF_UNIT_T:
unit = TString("T");
break;
default:
unit = TString("??");
break;
}
return unit;
}
//--------------------------------------------------------------------------
// SetRRFPacking (public)
//--------------------------------------------------------------------------

View File

@ -102,6 +102,7 @@ class PMsrHandler
virtual Bool_t CheckFuncs();
virtual Bool_t CheckHistoGrouping();
virtual Bool_t CheckAddRunParameters();
virtual Bool_t CheckRRFSettings();
virtual void CheckMaxLikelihood();
virtual void GetGroupingString(Int_t runNo, TString detector, TString &groupingStr);

View File

@ -546,6 +546,8 @@ class PMsrGlobalBlock {
virtual Bool_t IsPresent() { return fGlobalPresent; }
virtual Double_t GetRRFFreq(const char *unit);
virtual TString GetRRFUnit();
virtual Int_t GetRRFUnitTag() { return fRRFUnitTag; }
virtual Double_t GetRRFPhase() { return fRRFPhase; }
virtual Int_t GetRRFPacking() { return fRRFPacking; }
virtual Int_t GetFitType() { return fFitType; }