on the way to handle db-files ...
This commit is contained in:
parent
09a52aeac2
commit
2a65b0cad7
17
src/ToDo.txt
17
src/ToDo.txt
@ -73,6 +73,23 @@ short term:
|
|||||||
|
|
||||||
* nonMusr: check why in nonMusr view there is NO legend??
|
* nonMusr: check why in nonMusr view there is NO legend??
|
||||||
|
|
||||||
|
* PRawRunData needs to be changed for nonMusr: ascii and db handling should be on the
|
||||||
|
same footing. Since db handles vectors of data, PRawRunData should handle it as the
|
||||||
|
db-format and ascii should follow that philosophy even though ascii will only contain
|
||||||
|
one x- and one y-vector.
|
||||||
|
fXAxisTitle and fYAxisTitle should be removed and being replaced by a fDataLabel vector.
|
||||||
|
fXData, fYData, and fErrYData should be removed and being fDataBin and fErrDataBin vectors.
|
||||||
|
|
||||||
|
* nonMusr: db-file format should be added. That this is going to work, in the
|
||||||
|
RUN block part, a new entry is needed, namely
|
||||||
|
xy-data. Indices or label are used to pick to proper data
|
||||||
|
from the db-file.
|
||||||
|
xy-data T asym <- labels
|
||||||
|
or
|
||||||
|
xy-data 3 6 <- indices
|
||||||
|
|
||||||
|
* musrparam should be extended that is also can produce a db-file output.
|
||||||
|
|
||||||
* implement FFT with msr-interface
|
* implement FFT with msr-interface
|
||||||
|
|
||||||
---------------------
|
---------------------
|
||||||
|
@ -1043,6 +1043,12 @@ bool PMsrHandler::HandleRunEntry(PMsrLines &lines)
|
|||||||
TObjString *ostr;
|
TObjString *ostr;
|
||||||
TObjArray *tokens;
|
TObjArray *tokens;
|
||||||
|
|
||||||
|
// init some stuff
|
||||||
|
param.fXYDataIndex[0] = -1;
|
||||||
|
param.fXYDataIndex[1] = -1;
|
||||||
|
param.fXYDataLabel[0] = TString("");
|
||||||
|
param.fXYDataLabel[1] = TString("");
|
||||||
|
|
||||||
iter = lines.begin();
|
iter = lines.begin();
|
||||||
while ((iter != lines.end()) && !error) {
|
while ((iter != lines.end()) && !error) {
|
||||||
// tokenize line
|
// tokenize line
|
||||||
@ -1428,6 +1434,30 @@ bool PMsrHandler::HandleRunEntry(PMsrLines &lines)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// xy-data -----------------------------------------------
|
||||||
|
if (iter->fLine.BeginsWith("xy-data", TString::kIgnoreCase)) {
|
||||||
|
if (tokens->GetEntries() != 3) { // xy-data x-label y-label
|
||||||
|
error = true;
|
||||||
|
} else {
|
||||||
|
ostr = dynamic_cast<TObjString*>(tokens->At(1));
|
||||||
|
str = ostr->GetString();
|
||||||
|
if (str.IsDigit()) { // xy-data indices given
|
||||||
|
param.fXYDataIndex[0] = str.Atoi(); // x-index
|
||||||
|
ostr = dynamic_cast<TObjString*>(tokens->At(2));
|
||||||
|
str = ostr->GetString();
|
||||||
|
if (str.IsDigit())
|
||||||
|
param.fXYDataIndex[1] = str.Atoi(); // y-index
|
||||||
|
else
|
||||||
|
error = true;
|
||||||
|
} else { // xy-data labels given
|
||||||
|
param.fXYDataLabel[0] = str; // x-label
|
||||||
|
ostr = dynamic_cast<TObjString*>(tokens->At(2));
|
||||||
|
str = ostr->GetString();
|
||||||
|
param.fXYDataLabel[1] = str; // y-label
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// clean up
|
// clean up
|
||||||
if (tokens) {
|
if (tokens) {
|
||||||
delete tokens;
|
delete tokens;
|
||||||
|
@ -174,6 +174,8 @@ bool PRunDataHandler::ReadFile()
|
|||||||
success = ReadNemuFile();
|
success = ReadNemuFile();
|
||||||
else if (!run_it->fFileFormat.CompareTo("ascii"))
|
else if (!run_it->fFileFormat.CompareTo("ascii"))
|
||||||
success = ReadAsciiFile();
|
success = ReadAsciiFile();
|
||||||
|
else if (!run_it->fFileFormat.CompareTo("db"))
|
||||||
|
success = ReadDBFile();
|
||||||
else
|
else
|
||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
@ -235,6 +237,8 @@ bool PRunDataHandler::FileExistsCheck(PMsrRunStructure &runInfo)
|
|||||||
ext = TString("nemu");
|
ext = TString("nemu");
|
||||||
else if (!runInfo.fFileFormat.CompareTo("ascii"))
|
else if (!runInfo.fFileFormat.CompareTo("ascii"))
|
||||||
ext = TString("dat");
|
ext = TString("dat");
|
||||||
|
else if (!runInfo.fFileFormat.CompareTo("db"))
|
||||||
|
ext = TString("db");
|
||||||
else
|
else
|
||||||
success = false;
|
success = false;
|
||||||
|
|
||||||
@ -251,6 +255,7 @@ bool PRunDataHandler::FileExistsCheck(PMsrRunStructure &runInfo)
|
|||||||
cout << endl << " MUD -> triumf mud file format";
|
cout << endl << " MUD -> triumf mud file format";
|
||||||
cout << endl << " NEMU -> lem ascii file format";
|
cout << endl << " NEMU -> lem ascii file format";
|
||||||
cout << endl << " ASCII -> column like file format";
|
cout << endl << " ASCII -> column like file format";
|
||||||
|
cout << endl << " DB -> triumf db file \"format\"";
|
||||||
cout << endl;
|
cout << endl;
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
@ -853,8 +858,10 @@ bool PRunDataHandler::ReadAsciiFile()
|
|||||||
PRawRunData runData;
|
PRawRunData runData;
|
||||||
|
|
||||||
// init some stuff
|
// init some stuff
|
||||||
runData.fXAxisTitle = "??";
|
runData.fDataNonMusr.fXIndex = 0;
|
||||||
runData.fYAxisTitle = "??";
|
runData.fDataNonMusr.fYIndex = 1;
|
||||||
|
runData.fDataNonMusr.fLabels.push_back("??"); // x default label
|
||||||
|
runData.fDataNonMusr.fLabels.push_back("??"); // y default label
|
||||||
|
|
||||||
runData.fRunName = fRunName; // keep the run name
|
runData.fRunName = fRunName; // keep the run name
|
||||||
|
|
||||||
@ -864,6 +871,7 @@ bool PRunDataHandler::ReadAsciiFile()
|
|||||||
bool headerTag = false;
|
bool headerTag = false;
|
||||||
bool dataTag = false;
|
bool dataTag = false;
|
||||||
double x, y, ey;
|
double x, y, ey;
|
||||||
|
PDoubleVector xVec, exVec, yVec, eyVec;
|
||||||
|
|
||||||
while (!f.eof()) {
|
while (!f.eof()) {
|
||||||
f.getline(instr, sizeof(instr));
|
f.getline(instr, sizeof(instr));
|
||||||
@ -876,7 +884,7 @@ bool PRunDataHandler::ReadAsciiFile()
|
|||||||
|
|
||||||
// check if header tag
|
// check if header tag
|
||||||
workStr = line;
|
workStr = line;
|
||||||
workStr.Remove(TString::kLeading, ' '); // remove spaces from the beining
|
workStr.Remove(TString::kLeading, ' '); // remove spaces from the begining
|
||||||
if (workStr.BeginsWith("header", TString::kIgnoreCase)) {
|
if (workStr.BeginsWith("header", TString::kIgnoreCase)) {
|
||||||
headerTag = true;
|
headerTag = true;
|
||||||
dataTag = false;
|
dataTag = false;
|
||||||
@ -911,9 +919,9 @@ bool PRunDataHandler::ReadAsciiFile()
|
|||||||
}
|
}
|
||||||
runData.fField = workStr.Atof();
|
runData.fField = workStr.Atof();
|
||||||
} else if (workStr.BeginsWith("x-axis-title:", TString::kIgnoreCase)) {
|
} else if (workStr.BeginsWith("x-axis-title:", TString::kIgnoreCase)) {
|
||||||
runData.fXAxisTitle = TString(workStr.Data()+workStr.First(":")+2);
|
runData.fDataNonMusr.fLabels[0] = TString(workStr.Data()+workStr.First(":")+2);
|
||||||
} else if (workStr.BeginsWith("y-axis-title:", TString::kIgnoreCase)) {
|
} else if (workStr.BeginsWith("y-axis-title:", TString::kIgnoreCase)) {
|
||||||
runData.fYAxisTitle = TString(workStr.Data()+workStr.First(":")+2);
|
runData.fDataNonMusr.fLabels[1] = TString(workStr.Data()+workStr.First(":")+2);
|
||||||
} else if (workStr.BeginsWith("temp:", TString::kIgnoreCase)) {
|
} else if (workStr.BeginsWith("temp:", TString::kIgnoreCase)) {
|
||||||
workStr = TString(workStr.Data()+workStr.First(":")+2);
|
workStr = TString(workStr.Data()+workStr.First(":")+2);
|
||||||
if (!workStr.IsFloat()) {
|
if (!workStr.IsFloat()) {
|
||||||
@ -994,9 +1002,12 @@ bool PRunDataHandler::ReadAsciiFile()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// keep values
|
// keep values
|
||||||
runData.fXData.push_back(x);
|
xVec.push_back(x);
|
||||||
runData.fYData.push_back(y);
|
exVec.push_back(1.0);
|
||||||
runData.fErrYData.push_back(ey);
|
yVec.push_back(y);
|
||||||
|
eyVec.push_back(ey);
|
||||||
|
cout << endl << ">> (x/y/ey) = (" << x << "/" << y << "/" << ey << ")";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
cout << endl << "PRunDataHandler::ReadAsciiFile **ERROR** line no " << lineNo << " neither header nor data line. No idea how to handle it!";
|
cout << endl << "PRunDataHandler::ReadAsciiFile **ERROR** line no " << lineNo << " neither header nor data line. No idea how to handle it!";
|
||||||
cout << endl;
|
cout << endl;
|
||||||
@ -1007,6 +1018,232 @@ bool PRunDataHandler::ReadAsciiFile()
|
|||||||
|
|
||||||
f.close();
|
f.close();
|
||||||
|
|
||||||
|
// keep values
|
||||||
|
runData.fDataNonMusr.fData.push_back(xVec);
|
||||||
|
runData.fDataNonMusr.fErrData.push_back(exVec);
|
||||||
|
runData.fDataNonMusr.fData.push_back(yVec);
|
||||||
|
runData.fDataNonMusr.fErrData.push_back(eyVec);
|
||||||
|
|
||||||
|
fData.push_back(runData);
|
||||||
|
|
||||||
|
// clean up
|
||||||
|
xVec.clear();
|
||||||
|
exVec.clear();
|
||||||
|
yVec.clear();
|
||||||
|
eyVec.clear();
|
||||||
|
runData.fDataNonMusr.fData.clear();
|
||||||
|
runData.fDataNonMusr.fErrData.clear();
|
||||||
|
|
||||||
|
cout << endl << ">> end of ReadAsciiFile()";
|
||||||
|
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------
|
||||||
|
// ReadDBFile
|
||||||
|
//--------------------------------------------------------------------------
|
||||||
|
/**
|
||||||
|
* <p>Reads triumf db-files. Intended for the nonMuSR data.
|
||||||
|
*
|
||||||
|
* <p>The file format definition is:
|
||||||
|
* The following is a description of the features of the TRIUMF .db file format that are
|
||||||
|
* currently recognized by musrfit/musrview. The available commands include: title, abstract,
|
||||||
|
* comments, labels, and data.
|
||||||
|
*
|
||||||
|
* \verbatim
|
||||||
|
* TITLE
|
||||||
|
* The following line must contain the title.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* ABSTRACT
|
||||||
|
* The abstract is read in starting with the following line until an empty line is reached.
|
||||||
|
*
|
||||||
|
* COMMENTS
|
||||||
|
* The comments are read in starting with the following line until an empty line is reached.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* LABELS
|
||||||
|
* One label must occupy each subsequent line until an empty line is reached. The number
|
||||||
|
* of labels should preferably match the number of variables in the data.
|
||||||
|
*
|
||||||
|
* DATA
|
||||||
|
* On the same line as the DATA command, there must appear a comma-delimited list of variable
|
||||||
|
* names. These names should be kept short (some applications truncate to 4 characters). The
|
||||||
|
* numerical data is read in beginning with the following line until an empty line is reached.
|
||||||
|
*
|
||||||
|
* In every line, there must appear exactly 3 comma-delimited fields for each specified name.
|
||||||
|
* The first field is the value, the second is the positive error, and the third is the negative
|
||||||
|
* error. If you leave the last field blank (the comma is still required), then the positive error
|
||||||
|
* will be interpreted as a symmetric error. If you include only the value, then the errors will be
|
||||||
|
* set to zero.
|
||||||
|
*
|
||||||
|
* To reiterate, if you provide a DATA command with 2 names, e.g. "DATA 1st, 2nd", then every subsequent
|
||||||
|
* line must contain 2*3 - 1 = 5 commas. If you give 3 names, then there must be 3*3 - 1 = 8 commas.
|
||||||
|
*
|
||||||
|
* Example
|
||||||
|
* TITLE
|
||||||
|
* Most Excellent Fake Data
|
||||||
|
*
|
||||||
|
* ABSTRACT
|
||||||
|
* This data was collected over
|
||||||
|
* many minutes of light work
|
||||||
|
* that was required to make it up.
|
||||||
|
*
|
||||||
|
* COMMENTS
|
||||||
|
* This data was generated using C++.
|
||||||
|
* The file was formatted with Emacs.
|
||||||
|
*
|
||||||
|
* LABEL
|
||||||
|
* Randomized Linear
|
||||||
|
* Randomized Gaussian
|
||||||
|
* Randomized Lorentzian
|
||||||
|
* Run
|
||||||
|
*
|
||||||
|
* DATA line, gauss, lrntz, run
|
||||||
|
* -1.966, -0.168, -0.106, 0.048, 0.002, 0.005, 0.184, 0.010, 0.017, 1001,,, run 1001 title
|
||||||
|
* -1.895, -0.151, -0.128, 0.014, 0.001, 0.001, 0.259, 0.017, 0.015, 1002,,, run 1002 title
|
||||||
|
* -1.836, -0.127, -0.184, 0.013, 0.001, 0.001, 0.202, 0.017, 0.020, 1003,,, run 1003 title
|
||||||
|
* -1.739, -0.064, -0.166, 0.057, 0.003, 0.004, 0.237, 0.016, 0.018, 1004,,, run 1004 title
|
||||||
|
* -1.601, -0.062, -0.147, 0.104, 0.008, 0.006, 0.271, 0.012, 0.025, 1005,,, run 1005 title
|
||||||
|
* . . . . . . . . .
|
||||||
|
* . . . . . . . . .
|
||||||
|
* . . . . . . . . .
|
||||||
|
* Alternatively, the data often utilizes the continuation character ('\') and is labelled like so...
|
||||||
|
* DATA line, gauss, lrntz
|
||||||
|
* linear = -1.966, -0.168, -0.106, \
|
||||||
|
* gaussn = 0.048, 0.002, 0.005, \
|
||||||
|
* lorntz = 0.184, 0.010, 0.017, \
|
||||||
|
* 1001,,, run 1001 title
|
||||||
|
* linear = -1.895, -0.151, -0.128, \
|
||||||
|
* gaussn = 0.014, 0.001, 0.001, \
|
||||||
|
* lorntz = 0.259, 0.017, 0.015, |
|
||||||
|
* 1002,,, run 1002 title
|
||||||
|
* linear = -1.836, -0.127, -0.184, \
|
||||||
|
* gaussn = 0.013, 0.001, 0.001, \
|
||||||
|
* lorntz = 0.202, 0.017, 0.020, |
|
||||||
|
* 1003,,, run 1003 title
|
||||||
|
* . . . .
|
||||||
|
* . . . .
|
||||||
|
* . . . .
|
||||||
|
* If there is a run line as in the above examples, it must be at the end of the data and given
|
||||||
|
* in this just slight odd manner (do not blame me, I haven't invented this format ;-) ).
|
||||||
|
* \endverbatim
|
||||||
|
*
|
||||||
|
* <p>Some db-files do have a '\-e' or '\e' label just between the DATA tag line and the real data.
|
||||||
|
* This tag will just be ignored.
|
||||||
|
*/
|
||||||
|
bool PRunDataHandler::ReadDBFile()
|
||||||
|
{
|
||||||
|
bool success = true;
|
||||||
|
|
||||||
|
cout << endl << "not implemented yet ...";
|
||||||
|
|
||||||
|
// open file
|
||||||
|
ifstream f;
|
||||||
|
|
||||||
|
// open db-file
|
||||||
|
f.open(fRunPathName.Data(), ifstream::in);
|
||||||
|
if (!f.is_open()) {
|
||||||
|
cout << endl << "Couldn't open data file (" << fRunPathName.Data() << ") for reading, sorry ...";
|
||||||
|
cout << endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
PRawRunData runData;
|
||||||
|
|
||||||
|
int lineNo = 0;
|
||||||
|
int dbTag = -1;
|
||||||
|
char instr[512];
|
||||||
|
TString line, workStr;
|
||||||
|
double x, y, ey;
|
||||||
|
bool firstData = true; // needed as a switch to check in which format the data are given.
|
||||||
|
bool labelledFormat = true; // flag showing if the data are given in row format, or as labelled format (see description above, default is labelled format)
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
// check for db specific tags
|
||||||
|
workStr = line;
|
||||||
|
workStr.Remove(TString::kLeading, ' '); // remove spaces from the begining
|
||||||
|
if (workStr.BeginsWith("title", TString::kIgnoreCase)) {
|
||||||
|
cout << endl << ">> TITLE line found ...";
|
||||||
|
dbTag = 0;
|
||||||
|
continue;
|
||||||
|
} else if (workStr.BeginsWith("abstract", TString::kIgnoreCase)) {
|
||||||
|
cout << endl << ">> ABSTRACT line found ...";
|
||||||
|
dbTag = 1;
|
||||||
|
continue;
|
||||||
|
} else if (workStr.BeginsWith("comments", TString::kIgnoreCase)) {
|
||||||
|
cout << endl << ">> COMMENTS line found ...";
|
||||||
|
dbTag = 2;
|
||||||
|
continue;
|
||||||
|
} else if (workStr.BeginsWith("label", TString::kIgnoreCase)) {
|
||||||
|
cout << endl << ">> LABEL line found ...";
|
||||||
|
dbTag = 3;
|
||||||
|
continue;
|
||||||
|
} else if (workStr.BeginsWith("data", TString::kIgnoreCase)) {
|
||||||
|
cout << endl << ">> DATA line found ...";
|
||||||
|
dbTag = 4;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (dbTag) {
|
||||||
|
case 0: // TITLE
|
||||||
|
runData.fRunTitle = workStr;
|
||||||
|
break;
|
||||||
|
case 1: // ABSTRACT
|
||||||
|
// nothing to be done for now
|
||||||
|
break;
|
||||||
|
case 2: // COMMENTS
|
||||||
|
// nothing to be done for now
|
||||||
|
break;
|
||||||
|
case 3: // LABEL
|
||||||
|
// cout << endl << ">> label: " << workStr.Data();
|
||||||
|
runData.fDataNonMusr.fLabels.push_back(workStr);
|
||||||
|
break;
|
||||||
|
case 4: // DATA
|
||||||
|
// filter out potential start data tag
|
||||||
|
if (workStr.BeginsWith("\\-e", TString::kIgnoreCase) ||
|
||||||
|
workStr.BeginsWith("\\e", TString::kIgnoreCase) ||
|
||||||
|
workStr.BeginsWith("/-e", TString::kIgnoreCase) ||
|
||||||
|
workStr.BeginsWith("/e", TString::kIgnoreCase)) {
|
||||||
|
cout << endl << ">> \\-e like tag found ...";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// check if data are given just as rows are as labelled columns (see description above)
|
||||||
|
if (firstData) {
|
||||||
|
if (workStr.Contains("=")) {
|
||||||
|
labelledFormat = true;
|
||||||
|
cout << endl << ">> data give in labelled format ...";
|
||||||
|
} else {
|
||||||
|
labelledFormat = false;
|
||||||
|
cout << endl << ">> data give in row format ...";
|
||||||
|
}
|
||||||
|
firstData = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
f.close();
|
||||||
|
|
||||||
|
cout << endl << ">> run title: '" << runData.fRunTitle.Data() << "'";
|
||||||
|
cout << endl;
|
||||||
|
assert(0);
|
||||||
|
|
||||||
fData.push_back(runData);
|
fData.push_back(runData);
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
|
@ -488,7 +488,10 @@ const char* PRunListCollection::GetSetup(TString &runName)
|
|||||||
*/
|
*/
|
||||||
const char* PRunListCollection::GetXAxisTitle(TString &runName)
|
const char* PRunListCollection::GetXAxisTitle(TString &runName)
|
||||||
{
|
{
|
||||||
return fData->GetRunData(runName)->fXAxisTitle.Data();
|
PRawRunData *runData = fData->GetRunData(runName);
|
||||||
|
int index = fData->GetRunData(runName)->fDataNonMusr.fXIndex;
|
||||||
|
|
||||||
|
return runData->fDataNonMusr.fLabels[index].Data();
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
@ -501,6 +504,9 @@ const char* PRunListCollection::GetXAxisTitle(TString &runName)
|
|||||||
*/
|
*/
|
||||||
const char* PRunListCollection::GetYAxisTitle(TString &runName)
|
const char* PRunListCollection::GetYAxisTitle(TString &runName)
|
||||||
{
|
{
|
||||||
return fData->GetRunData(runName)->fYAxisTitle.Data();
|
PRawRunData *runData = fData->GetRunData(runName);
|
||||||
|
int index = fData->GetRunData(runName)->fDataNonMusr.fYIndex;
|
||||||
|
|
||||||
|
return runData->fDataNonMusr.fLabels[index].Data();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,28 +180,32 @@ bool PRunNonMusr::PrepareFitData()
|
|||||||
fFitStartTime = fRunInfo->fFitRange[0];
|
fFitStartTime = fRunInfo->fFitRange[0];
|
||||||
fFitStopTime = fRunInfo->fFitRange[1];
|
fFitStopTime = fRunInfo->fFitRange[1];
|
||||||
|
|
||||||
|
// get x-, y-index
|
||||||
|
unsigned int xIndex = GetXIndex(runData);
|
||||||
|
unsigned int yIndex = GetYIndex(runData);
|
||||||
|
|
||||||
// pack the raw data
|
// pack the raw data
|
||||||
double value = 0.0;
|
double value = 0.0;
|
||||||
double err = 0.0;
|
double err = 0.0;
|
||||||
cout << endl << ">> runData->fXData.size()=" << runData->fXData.size();
|
cout << endl << ">> runData->fDataNonMusr.fData[" << xIndex << "].size()=" << runData->fDataNonMusr.fData[xIndex].size();
|
||||||
for (unsigned int i=0; i<runData->fXData.size(); i++) {
|
for (unsigned int i=0; i<runData->fDataNonMusr.fData[xIndex].size(); i++) {
|
||||||
cout << endl << ">> i=" << i << ", packing=" << fRunInfo->fPacking;
|
cout << endl << ">> i=" << i << ", packing=" << fRunInfo->fPacking;
|
||||||
if (fRunInfo->fPacking == 1) {
|
if (fRunInfo->fPacking == 1) {
|
||||||
fData.fX.push_back(runData->fXData[i]);
|
fData.fX.push_back(runData->fDataNonMusr.fData[xIndex][i]);
|
||||||
fData.fValue.push_back(runData->fYData[i]);
|
fData.fValue.push_back(runData->fDataNonMusr.fData[yIndex][i]);
|
||||||
fData.fError.push_back(runData->fErrYData[i]);
|
fData.fError.push_back(runData->fDataNonMusr.fErrData[yIndex][i]);
|
||||||
} else { // packed data, i.e. fRunInfo->fPacking > 1
|
} else { // packed data, i.e. fRunInfo->fPacking > 1
|
||||||
if ((i % fRunInfo->fPacking == 0) && (i != 0)) { // fill data
|
if ((i % fRunInfo->fPacking == 0) && (i != 0)) { // fill data
|
||||||
cout << endl << "-> i=" << i;
|
cout << endl << "-> i=" << i;
|
||||||
fData.fX.push_back(runData->fXData[i]-(runData->fXData[i]-runData->fXData[i-fRunInfo->fPacking])/2.0);
|
fData.fX.push_back(runData->fDataNonMusr.fData[xIndex][i]-(runData->fDataNonMusr.fData[xIndex][i]-runData->fDataNonMusr.fData[xIndex][i-fRunInfo->fPacking])/2.0);
|
||||||
fData.fValue.push_back(value);
|
fData.fValue.push_back(value);
|
||||||
fData.fError.push_back(TMath::Sqrt(err));
|
fData.fError.push_back(TMath::Sqrt(err));
|
||||||
value = 0.0;
|
value = 0.0;
|
||||||
err = 0.0;
|
err = 0.0;
|
||||||
}
|
}
|
||||||
// sum raw data values
|
// sum raw data values
|
||||||
value += runData->fYData[i];
|
value += runData->fDataNonMusr.fData[yIndex][i];
|
||||||
err += runData->fErrYData[i]*runData->fErrYData[i];
|
err += runData->fDataNonMusr.fErrData[yIndex][i]*runData->fDataNonMusr.fErrData[yIndex][i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cout << endl << ">> fData.fValue.size()=" << fData.fValue.size();
|
cout << endl << ">> fData.fValue.size()=" << fData.fValue.size();
|
||||||
@ -237,29 +241,33 @@ bool PRunNonMusr::PrepareViewData()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get x-, y-index
|
||||||
|
unsigned int xIndex = GetXIndex(runData);
|
||||||
|
unsigned int yIndex = GetYIndex(runData);
|
||||||
|
|
||||||
// fill data histo
|
// fill data histo
|
||||||
// pack the raw data
|
// pack the raw data
|
||||||
double value = 0.0;
|
double value = 0.0;
|
||||||
double err = 0.0;
|
double err = 0.0;
|
||||||
cout << endl << ">> runData->fXData.size()=" << runData->fXData.size();
|
cout << endl << ">> runData->fDataNonMusr.fData[" << xIndex << "].size()=" << runData->fDataNonMusr.fData[xIndex].size();
|
||||||
for (unsigned int i=0; i<runData->fXData.size(); i++) {
|
for (unsigned int i=0; i<runData->fDataNonMusr.fData[xIndex].size(); i++) {
|
||||||
cout << endl << ">> i=" << i << ", packing=" << fRunInfo->fPacking;
|
cout << endl << ">> i=" << i << ", packing=" << fRunInfo->fPacking;
|
||||||
if (fRunInfo->fPacking == 1) {
|
if (fRunInfo->fPacking == 1) {
|
||||||
fData.fX.push_back(runData->fXData[i]);
|
fData.fX.push_back(runData->fDataNonMusr.fData[xIndex][i]);
|
||||||
fData.fValue.push_back(runData->fYData[i]);
|
fData.fValue.push_back(runData->fDataNonMusr.fData[yIndex][i]);
|
||||||
fData.fError.push_back(runData->fErrYData[i]);
|
fData.fError.push_back(runData->fDataNonMusr.fErrData[yIndex][i]);
|
||||||
} else { // packed data, i.e. fRunInfo->fPacking > 1
|
} else { // packed data, i.e. fRunInfo->fPacking > 1
|
||||||
if ((i % fRunInfo->fPacking == 0) && (i != 0)) { // fill data
|
if ((i % fRunInfo->fPacking == 0) && (i != 0)) { // fill data
|
||||||
cout << endl << "-> i=" << i;
|
cout << endl << "-> i=" << i;
|
||||||
fData.fX.push_back(runData->fXData[i]-(runData->fXData[i]-runData->fXData[i-fRunInfo->fPacking])/2.0);
|
fData.fX.push_back(runData->fDataNonMusr.fData[xIndex][i]-(runData->fDataNonMusr.fData[xIndex][i]-runData->fDataNonMusr.fData[xIndex][i-fRunInfo->fPacking])/2.0);
|
||||||
fData.fValue.push_back(value);
|
fData.fValue.push_back(value);
|
||||||
fData.fError.push_back(TMath::Sqrt(err));
|
fData.fError.push_back(TMath::Sqrt(err));
|
||||||
value = 0.0;
|
value = 0.0;
|
||||||
err = 0.0;
|
err = 0.0;
|
||||||
}
|
}
|
||||||
// sum raw data values
|
// sum raw data values
|
||||||
value += runData->fYData[i];
|
value += runData->fDataNonMusr.fData[yIndex][i];
|
||||||
err += runData->fErrYData[i]*runData->fErrYData[i];
|
err += runData->fDataNonMusr.fErrData[yIndex][i]*runData->fDataNonMusr.fErrData[yIndex][i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cout << endl << ">> fData.fValue.size()=" << fData.fValue.size();
|
cout << endl << ">> fData.fValue.size()=" << fData.fValue.size();
|
||||||
@ -344,3 +352,81 @@ cout << endl << ">> after the xmin/xmax loop." << endl;
|
|||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------
|
||||||
|
// GetXIndex
|
||||||
|
//--------------------------------------------------------------------------
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* \param runData
|
||||||
|
*/
|
||||||
|
unsigned int PRunNonMusr::GetXIndex(PRawRunData* runData)
|
||||||
|
{
|
||||||
|
unsigned int index = 0;
|
||||||
|
bool found = false;
|
||||||
|
|
||||||
|
if (runData->fDataNonMusr.fXIndex >= 0) { // ascii-file format
|
||||||
|
index = runData->fDataNonMusr.fXIndex;
|
||||||
|
found = true;
|
||||||
|
} else { // db-file format
|
||||||
|
if (fRunInfo->fXYDataIndex[0] > 0) { // xy-data already indices
|
||||||
|
index = fRunInfo->fXYDataIndex[0]-1; // since xy-data start with 1 ...
|
||||||
|
found = true;
|
||||||
|
} else { // xy-data data tags which needs to be converted to an index
|
||||||
|
for (unsigned int i=0; i<runData->fDataNonMusr.fDataTags.size(); i++) {
|
||||||
|
if (runData->fDataNonMusr.fDataTags[i].CompareTo(fRunInfo->fXYDataLabel[0]) == 0) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found) {
|
||||||
|
cout << endl << "PRunNonMusr::GetXIndex(): **ERROR** Couldn't obtain x-data index!";
|
||||||
|
cout << endl;
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------
|
||||||
|
// GetYIndex
|
||||||
|
//--------------------------------------------------------------------------
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* \param runData
|
||||||
|
*/
|
||||||
|
unsigned int PRunNonMusr::GetYIndex(PRawRunData* runData)
|
||||||
|
{
|
||||||
|
unsigned int index = 0;
|
||||||
|
bool found = false;
|
||||||
|
|
||||||
|
if (runData->fDataNonMusr.fYIndex >= 0) { // ascii-file format
|
||||||
|
index = runData->fDataNonMusr.fYIndex;
|
||||||
|
found = true;
|
||||||
|
} else { // db-file format
|
||||||
|
if (fRunInfo->fXYDataIndex[1] > 0) { // xy-data already indices
|
||||||
|
index = fRunInfo->fXYDataIndex[1]-1; // since xy-data start with 1 ...
|
||||||
|
found = true;
|
||||||
|
} else { // xy-data data tags which needs to be converted to an index
|
||||||
|
for (unsigned int i=0; i<runData->fDataNonMusr.fDataTags.size(); i++) {
|
||||||
|
if (runData->fDataNonMusr.fDataTags[i].CompareTo(fRunInfo->fXYDataLabel[1]) == 0) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found) {
|
||||||
|
cout << endl << "PRunNonMusr::GetYIndex(): **ERROR** Couldn't obtain y-data index!";
|
||||||
|
cout << endl;
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
@ -140,6 +140,19 @@ typedef struct {
|
|||||||
PDoubleVector fTheory;
|
PDoubleVector fTheory;
|
||||||
} PRunData;
|
} PRunData;
|
||||||
|
|
||||||
|
//-------------------------------------------------------------
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
int fXIndex; ///< index for the x-data vector
|
||||||
|
int fYIndex; ///< index for the y-data vector
|
||||||
|
PStringVector fLabels; ///< vector of all labels (used for x-, y-axis title in view)
|
||||||
|
PStringVector fDataTags; ///< vector of all data tags
|
||||||
|
vector<PDoubleVector> fData; ///< vector of all data
|
||||||
|
vector<PDoubleVector> fErrData; ///< vector of all data errors
|
||||||
|
} PNonMusrRawRunData;
|
||||||
|
|
||||||
//-------------------------------------------------------------
|
//-------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@ -147,8 +160,6 @@ typedef struct {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
TString fRunName; ///< name of the run
|
TString fRunName; ///< name of the run
|
||||||
TString fRunTitle; ///< run title
|
TString fRunTitle; ///< run title
|
||||||
TString fXAxisTitle; ///< x-axis title for noMusr view
|
|
||||||
TString fYAxisTitle; ///< x-axis title for noMusr view
|
|
||||||
TString fSetup; ///< description of the setup of this run
|
TString fSetup; ///< description of the setup of this run
|
||||||
double fField; ///< magnetic field value
|
double fField; ///< magnetic field value
|
||||||
double fTemp; ///< temperature during the run
|
double fTemp; ///< temperature during the run
|
||||||
@ -156,9 +167,7 @@ typedef struct {
|
|||||||
double fTimeResolution; ///< time resolution of the run
|
double fTimeResolution; ///< time resolution of the run
|
||||||
PDoubleVector fT0s; ///< vector of t0's of a run
|
PDoubleVector fT0s; ///< vector of t0's of a run
|
||||||
vector<PDoubleVector> fDataBin; ///< vector of all histos of a run
|
vector<PDoubleVector> fDataBin; ///< vector of all histos of a run
|
||||||
PDoubleVector fXData; ///< vector of all x-data if noMuSR fit
|
PNonMusrRawRunData fDataNonMusr; ///< keeps all ascii- or db-file info in case of nonMusr fit
|
||||||
PDoubleVector fYData; ///< vector of all x-data if noMuSR fit
|
|
||||||
PDoubleVector fErrYData; ///< vector of all x-data if noMuSR fit
|
|
||||||
} PRawRunData;
|
} PRawRunData;
|
||||||
|
|
||||||
//-------------------------------------------------------------
|
//-------------------------------------------------------------
|
||||||
@ -213,7 +222,7 @@ typedef struct {
|
|||||||
TString fRunName; ///< name of the run file
|
TString fRunName; ///< name of the run file
|
||||||
TString fBeamline; ///< e.g. mue4, mue1, pim3, emu, m15, ... (former: run type)
|
TString fBeamline; ///< e.g. mue4, mue1, pim3, emu, m15, ... (former: run type)
|
||||||
TString fInstitute; ///< e.g. psi, ral, triumf (former: run format)
|
TString fInstitute; ///< e.g. psi, ral, triumf (former: run format)
|
||||||
TString fFileFormat; ///< e.g. root, nexus, psi-bin, mud
|
TString fFileFormat; ///< e.g. root, nexus, psi-bin, mud, ascii, db
|
||||||
int fFitType; ///< fit type: 0=single histo fit, 2=asymmetry fit, 4=asymmetry in RRF, 8=non muSR
|
int fFitType; ///< fit type: 0=single histo fit, 2=asymmetry fit, 4=asymmetry in RRF, 8=non muSR
|
||||||
int fAlphaParamNo; ///< alpha
|
int fAlphaParamNo; ///< alpha
|
||||||
int fBetaParamNo; ///<
|
int fBetaParamNo; ///<
|
||||||
@ -237,6 +246,8 @@ typedef struct {
|
|||||||
int fBeta2ParamNo; ///<
|
int fBeta2ParamNo; ///<
|
||||||
int fRightHistoNo; ///<
|
int fRightHistoNo; ///<
|
||||||
int fLeftHistoNo; ///<
|
int fLeftHistoNo; ///<
|
||||||
|
int fXYDataIndex[2]; ///< used to get the data indices when using db-files
|
||||||
|
TString fXYDataLabel[2]; ///< used to get the indices via labels when using db-files
|
||||||
} PMsrRunStructure;
|
} PMsrRunStructure;
|
||||||
|
|
||||||
//-------------------------------------------------------------
|
//-------------------------------------------------------------
|
||||||
|
@ -68,6 +68,7 @@ class PRunDataHandler
|
|||||||
virtual bool ReadPsiBinFile();
|
virtual bool ReadPsiBinFile();
|
||||||
virtual bool ReadMudFile();
|
virtual bool ReadMudFile();
|
||||||
virtual bool ReadAsciiFile();
|
virtual bool ReadAsciiFile();
|
||||||
|
virtual bool ReadDBFile();
|
||||||
|
|
||||||
virtual bool StripWhitespace(TString &str);
|
virtual bool StripWhitespace(TString &str);
|
||||||
virtual bool IsWhitespace(const char *str);
|
virtual bool IsWhitespace(const char *str);
|
||||||
|
@ -56,6 +56,9 @@ class PRunNonMusr : public PRunBase
|
|||||||
double fFitStartTime;
|
double fFitStartTime;
|
||||||
double fFitStopTime;
|
double fFitStopTime;
|
||||||
unsigned int fNoOfFitBins;
|
unsigned int fNoOfFitBins;
|
||||||
|
|
||||||
|
unsigned int GetXIndex(PRawRunData* runData);
|
||||||
|
unsigned int GetYIndex(PRawRunData* runData);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _PRUNNONMUSR_H_
|
#endif // _PRUNNONMUSR_H_
|
||||||
|
Loading…
x
Reference in New Issue
Block a user