Merge remote-tracking branch 'origin/depthProf' into root6
This commit is contained in:
@@ -150,6 +150,32 @@ PNonMusrRawRunData::~PNonMusrRawRunData()
|
||||
fErrData.clear();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// SetSize (public)
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>Allows to set the number of data sets before filling it. This is
|
||||
* needed when reading dat-files generated from msr2data.
|
||||
*
|
||||
* @param size number of data sets
|
||||
*/
|
||||
void PNonMusrRawRunData::SetSize(const UInt_t size)
|
||||
{
|
||||
// first clean up
|
||||
for (UInt_t i=0; i<fData.size(); i++) {
|
||||
fData[i].clear();
|
||||
}
|
||||
fData.clear();
|
||||
for (UInt_t i=0; i<fErrData.size(); i++) {
|
||||
fErrData[i].clear();
|
||||
}
|
||||
fErrData.clear();
|
||||
|
||||
// set size
|
||||
fData.resize(size);
|
||||
fErrData.resize(size);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// SetLabel (public)
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
@@ -88,7 +88,7 @@ void PXmlRgeHandler::OnEndDocument()
|
||||
* and sets a proper key.
|
||||
*
|
||||
* \param str XML element name
|
||||
* \param attributes not used
|
||||
* \param attributes used only for energy_vect
|
||||
*/
|
||||
void PXmlRgeHandler::OnStartElement(const Char_t *str, const TList *attributes)
|
||||
{
|
||||
@@ -564,15 +564,16 @@ Double_t PRgeHandler::GetZmax(const Double_t energy)
|
||||
{
|
||||
int idx=-1;
|
||||
for (int i=0; i<fData.size(); i++) {
|
||||
if (fabs(fData[i].energy-energy) < 1.0) {
|
||||
if (fabs(fData[i].energy-energy)*0.001 < 0.9){
|
||||
idx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (idx != -1)
|
||||
return GetZmax(idx);
|
||||
return GetZmax(idx);
|
||||
|
||||
return -1.0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
@@ -606,7 +607,7 @@ Double_t PRgeHandler::Get_n(const Double_t energy, const Double_t z)
|
||||
{
|
||||
int idx=-1;
|
||||
for (int i=0; i<fData.size(); i++) {
|
||||
if (fabs(fData[i].energy-energy) < 1.0) {
|
||||
if (fabs(fData[i].energy-energy)*0.001 < 0.90) {
|
||||
idx = i;
|
||||
break;
|
||||
}
|
||||
@@ -668,7 +669,7 @@ Int_t PRgeHandler::GetEnergyIndex(const Double_t energy)
|
||||
{
|
||||
int idx=-1;
|
||||
for (int i=0; i<fData.size(); i++) {
|
||||
if (fabs(fData[i].energy-energy) < 1.0) {
|
||||
if (fabs(fData[i].energy-energy)*0.001 < 0.90) {
|
||||
idx = i;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -549,6 +549,9 @@ void PRunAsymmetry::CalcTheory()
|
||||
*/
|
||||
Bool_t PRunAsymmetry::PrepareData()
|
||||
{
|
||||
if (!fValid)
|
||||
return false;
|
||||
|
||||
// keep the Global block info
|
||||
PMsrGlobalBlock *globalBlock = fMsrInfo->GetMsrGlobal();
|
||||
|
||||
|
||||
@@ -587,6 +587,9 @@ void PRunAsymmetryBNMR::CalcTheory()
|
||||
*/
|
||||
Bool_t PRunAsymmetryBNMR::PrepareData()
|
||||
{
|
||||
if (!fValid)
|
||||
return false;
|
||||
|
||||
// keep the Global block info
|
||||
PMsrGlobalBlock *globalBlock = fMsrInfo->GetMsrGlobal();
|
||||
|
||||
|
||||
@@ -531,6 +531,9 @@ void PRunAsymmetryRRF::CalcTheory()
|
||||
*/
|
||||
Bool_t PRunAsymmetryRRF::PrepareData()
|
||||
{
|
||||
if (!fValid)
|
||||
return false;
|
||||
|
||||
// keep the Global block info
|
||||
PMsrGlobalBlock *globalBlock = fMsrInfo->GetMsrGlobal();
|
||||
|
||||
|
||||
@@ -538,6 +538,8 @@ Bool_t PRunDataHandler::ReadFilesMsr()
|
||||
success = ReadAsciiFile();
|
||||
} else if (!runList->at(i).GetFileFormat(j)->CompareTo("db")) {
|
||||
success = ReadDBFile();
|
||||
} else if (!runList->at(i).GetFileFormat(j)->CompareTo("dat")) {
|
||||
success = ReadDatFile();
|
||||
} else {
|
||||
success = false;
|
||||
}
|
||||
@@ -1102,6 +1104,8 @@ Bool_t PRunDataHandler::FileExistsCheck(PMsrRunBlock &runInfo, const UInt_t idx)
|
||||
ext = TString("dat");
|
||||
else if (!runInfo.GetFileFormat(idx)->CompareTo("db"))
|
||||
ext = TString("db");
|
||||
else if (!runInfo.GetFileFormat(idx)->CompareTo("dat"))
|
||||
ext = TString("dat");
|
||||
else
|
||||
success = false;
|
||||
|
||||
@@ -1126,6 +1130,7 @@ Bool_t PRunDataHandler::FileExistsCheck(PMsrRunBlock &runInfo, const UInt_t idx)
|
||||
std::cerr << std::endl << ">> MDU-ASCII -> psi mdu ascii file format";
|
||||
std::cerr << std::endl << ">> ASCII -> column like file format";
|
||||
std::cerr << std::endl << ">> DB -> triumf db file \"format\"";
|
||||
std::cerr << std::endl << ">> DAT -> csv like file \"format\" as exported by msr2data.";
|
||||
std::cerr << std::endl;
|
||||
return success;
|
||||
}
|
||||
@@ -4345,6 +4350,154 @@ Bool_t PRunDataHandler::ReadDBFile()
|
||||
return success;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// ReadDatFile (private)
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>Reads column like data sets as generated by msr2data with the option
|
||||
* 'data'. This can be used for the 'non muSR fit' type.
|
||||
*
|
||||
* <b>return:</b>
|
||||
* - true at successful reading,
|
||||
* - otherwise false.
|
||||
*/
|
||||
Bool_t PRunDataHandler::ReadDatFile()
|
||||
{
|
||||
Bool_t success = true;
|
||||
|
||||
// open file
|
||||
std::ifstream f;
|
||||
|
||||
// open db-file
|
||||
f.open(fRunPathName.Data(), std::ifstream::in);
|
||||
if (!f.is_open()) {
|
||||
std::cerr << std::endl << ">> PRunDataHandler::ReadDatFile **ERROR** Couldn't open data file (" << fRunPathName.Data() << ") for reading, sorry ...";
|
||||
std::cerr << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
PRawRunData runData;
|
||||
runData.fDataNonMusr.SetFromAscii(false);
|
||||
|
||||
Int_t lineNo = 0;
|
||||
Char_t instr[4096];
|
||||
TString line;
|
||||
Bool_t headerInfo=true;
|
||||
|
||||
// variables needed to tokenize strings
|
||||
TString tstr;
|
||||
TObjString *ostr;
|
||||
TObjArray *tokens = nullptr;
|
||||
|
||||
UInt_t noOfDataSets = 0, noOfEntries = 0;
|
||||
PBoolVector isData;
|
||||
Double_t dval;
|
||||
|
||||
while (!f.eof()) {
|
||||
// get next line from file
|
||||
f.getline(instr, sizeof(instr));
|
||||
line = TString(instr);
|
||||
lineNo++;
|
||||
|
||||
// check if comment line
|
||||
if (line.BeginsWith("#") || line.BeginsWith("%"))
|
||||
continue;
|
||||
|
||||
// ignore empty lines
|
||||
if (line.IsWhitespace())
|
||||
continue;
|
||||
|
||||
tokens = line.Tokenize(" \t");
|
||||
if (tokens == nullptr) { // error
|
||||
std::cerr << std::endl << ">> PRunDataHandler::ReadDatFile **ERROR** couldn't tokenize the line, in lineNo: " << lineNo;
|
||||
std::cerr << std::endl << ">> line: '" << line << "'.";
|
||||
std::cerr << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// filter header information
|
||||
if (headerInfo) {
|
||||
headerInfo = false;
|
||||
|
||||
// filter out all data tags: this labels are used in the msr-file to select the proper data set
|
||||
// for the dat-files, label and dataTag are the same
|
||||
noOfEntries = tokens->GetEntries();
|
||||
for (Int_t i=0; i<noOfEntries; i++) {
|
||||
ostr = dynamic_cast<TObjString*>(tokens->At(i));
|
||||
tstr = ostr->GetString();
|
||||
if (!tstr.EndsWith("Err", TString::kExact)) {
|
||||
noOfDataSets++;
|
||||
isData.push_back(true);
|
||||
runData.fDataNonMusr.AppendDataTag(tstr);
|
||||
runData.fDataNonMusr.AppendLabel(tstr);
|
||||
} else {
|
||||
isData.push_back(false);
|
||||
}
|
||||
}
|
||||
// set the size for the data
|
||||
runData.fDataNonMusr.SetSize(noOfDataSets);
|
||||
} else { // deal with data
|
||||
if (noOfEntries == 0) {
|
||||
std::cerr << std::endl << ">> PRunDataHandler::ReadDatFile **ERROR** header information is missing.";
|
||||
std::cerr << std::endl;
|
||||
return false;
|
||||
}
|
||||
if (tokens->GetEntries() != noOfEntries) { // error
|
||||
std::cerr << std::endl << ">> PRunDataHandler::ReadDatFile **ERROR** data set with wrong number of entries: " << tokens->GetEntries() << ", should be " << noOfEntries << ".";
|
||||
std::cerr << std::endl << ">> in line: " << lineNo;
|
||||
std::cerr << std::endl << ">> line: '" << line << "'.";
|
||||
std::cerr << std::endl;
|
||||
return false;
|
||||
}
|
||||
// fill data and dataErr sets
|
||||
UInt_t idx = 0;
|
||||
for (UInt_t i=0; i<noOfEntries; i++) {
|
||||
// 1st: check that entry is indeed a number
|
||||
ostr = dynamic_cast<TObjString*>(tokens->At(i));
|
||||
tstr = ostr->GetString();
|
||||
if (!tstr.IsFloat()) { // make sure it is a number
|
||||
std::cerr << std::endl << ">> PRunDataHandler::ReadDatFile **ERROR** data set entry is not a number: " << tstr.Data();
|
||||
std::cerr << std::endl << ">> in line: " << lineNo;
|
||||
std::cerr << std::endl;
|
||||
return false;
|
||||
}
|
||||
dval = tstr.Atof();
|
||||
if (isData[i]) {
|
||||
runData.fDataNonMusr.AppendSubData(idx, dval);
|
||||
idx++;
|
||||
} else { // error value
|
||||
if (isData[i-1] == 1) { // Err or PosErr hence keep it
|
||||
runData.fDataNonMusr.AppendSubErrData(idx-1, dval);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// cleanup
|
||||
if (tokens) {
|
||||
delete tokens;
|
||||
tokens = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
f.close();
|
||||
|
||||
// got through all the data sets and if there is NO error vector set it to '0.0'
|
||||
for (UInt_t i=0; i<noOfDataSets; i++) {
|
||||
if (runData.fDataNonMusr.GetErrData()->at(i).size() == 0) {
|
||||
for (UInt_t j=0; j<runData.fDataNonMusr.GetData()->at(i).size(); j++) {
|
||||
runData.fDataNonMusr.AppendSubErrData(i, 0.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// keep run name
|
||||
runData.SetRunName(fRunName);
|
||||
|
||||
fData.push_back(runData);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// WriteMusrRootFile (private)
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
@@ -151,7 +151,7 @@ Bool_t PRunListCollection::Add(Int_t runNo, EPMusrHandleTag tag)
|
||||
success = false;
|
||||
break;
|
||||
case PRUN_NON_MUSR:
|
||||
fRunNonMusrList.push_back(new PRunNonMusr(fMsrInfo, fData, runNo, tag));
|
||||
fRunNonMusrList.push_back(new PRunNonMusr(fMsrInfo, fData, runNo, tag, fTheoAsData));
|
||||
if (!fRunNonMusrList[fRunNonMusrList.size()-1]->IsValid())
|
||||
success = false;
|
||||
break;
|
||||
|
||||
@@ -458,6 +458,9 @@ Bool_t PRunMuMinus::PrepareData()
|
||||
{
|
||||
Bool_t success = true;
|
||||
|
||||
if (!fValid)
|
||||
return false;
|
||||
|
||||
// keep the Global block info
|
||||
PMsrGlobalBlock *globalBlock = fMsrInfo->GetMsrGlobal();
|
||||
|
||||
|
||||
@@ -60,7 +60,8 @@ PRunNonMusr::PRunNonMusr() : PRunBase()
|
||||
* \param runNo number of the run within the msr-file
|
||||
* \param tag tag showing what shall be done: kFit == fitting, kView == viewing
|
||||
*/
|
||||
PRunNonMusr::PRunNonMusr(PMsrHandler *msrInfo, PRunDataHandler *rawData, UInt_t runNo, EPMusrHandleTag tag) : PRunBase(msrInfo, rawData, runNo, tag)
|
||||
PRunNonMusr::PRunNonMusr(PMsrHandler *msrInfo, PRunDataHandler *rawData, UInt_t runNo, EPMusrHandleTag tag, Bool_t theoAsData) :
|
||||
PRunBase(msrInfo, rawData, runNo, tag), fTheoAsData(theoAsData)
|
||||
{
|
||||
// get the proper run
|
||||
fRawRunData = fRawData->GetRunData(*(fRunInfo->GetRunName()));
|
||||
@@ -198,6 +199,9 @@ Bool_t PRunNonMusr::PrepareData()
|
||||
{
|
||||
Bool_t success = true;
|
||||
|
||||
if (!fValid)
|
||||
return false;
|
||||
|
||||
if (fRunInfo->GetRunNameSize() > 1) { // ADDRUN present which is not supported for NonMusr
|
||||
std::cerr << std::endl << ">> PRunNonMusr::PrepareData(): **WARNING** ADDRUN NOT SUPPORTED FOR THIS FIT TYPE, WILL IGNORE IT." << std::endl;
|
||||
}
|
||||
@@ -442,15 +446,26 @@ Bool_t PRunNonMusr::PrepareViewData()
|
||||
else
|
||||
xStep = (xMax-xMin)/1000.0;
|
||||
|
||||
Double_t xx = xMin;
|
||||
do {
|
||||
// fill x-vector
|
||||
fData.AppendXTheoryValue(xx);
|
||||
// fill y-vector
|
||||
fData.AppendTheoryValue(fTheory->Func(xx, par, fFuncValues));
|
||||
// calculate next xx
|
||||
xx += xStep;
|
||||
} while (xx < xMax);
|
||||
if (fTheoAsData) {
|
||||
Double_t xx;
|
||||
for (UInt_t i=0; i<fRawRunData->fDataNonMusr.GetData()->at(xIndex).size(); i++) {
|
||||
// fill x-vector
|
||||
xx = fRawRunData->fDataNonMusr.GetData()->at(xIndex).at(i);
|
||||
fData.AppendXTheoryValue(xx);
|
||||
// fill y-vector
|
||||
fData.AppendTheoryValue(fTheory->Func(xx, par, fFuncValues));
|
||||
}
|
||||
} else {
|
||||
Double_t xx = xMin;
|
||||
do {
|
||||
// fill x-vector
|
||||
fData.AppendXTheoryValue(xx);
|
||||
// fill y-vector
|
||||
fData.AppendTheoryValue(fTheory->Func(xx, par, fFuncValues));
|
||||
// calculate next xx
|
||||
xx += xStep;
|
||||
} while (xx < xMax);
|
||||
}
|
||||
|
||||
// clean up
|
||||
par.clear();
|
||||
|
||||
@@ -700,6 +700,9 @@ Bool_t PRunSingleHisto::PrepareData()
|
||||
{
|
||||
Bool_t success = true;
|
||||
|
||||
if (!fValid)
|
||||
return false;
|
||||
|
||||
// keep the Global block info
|
||||
PMsrGlobalBlock *globalBlock = fMsrInfo->GetMsrGlobal();
|
||||
|
||||
|
||||
@@ -431,6 +431,9 @@ Bool_t PRunSingleHistoRRF::PrepareData()
|
||||
{
|
||||
Bool_t success = true;
|
||||
|
||||
if (!fValid)
|
||||
return false;
|
||||
|
||||
// keep the Global block info
|
||||
PMsrGlobalBlock *globalBlock = fMsrInfo->GetMsrGlobal();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user