added code to get WKM ascii file format backward compatibility

This commit is contained in:
nemu
2009-01-27 12:15:56 +00:00
parent 1307a37db4
commit 93abe979ba
6 changed files with 117 additions and 48 deletions

View File

@@ -109,6 +109,10 @@ short term:
* implement FFT with msr-interface * implement FFT with msr-interface
**DONE** 2009-01 **DONE** 2009-01
* implement dynamic LF-KT by using the integral equation representation (Volterra Eq) and an optimzed
implementation of the gauss * sine integral
**START** 2009-01-13
--------------------- ---------------------
intermediate term: intermediate term:
--------------------- ---------------------
@@ -124,7 +128,6 @@ long term:
* implement ROOT based wkmview, i.e. all the graphical stuff needed * implement ROOT based wkmview, i.e. all the graphical stuff needed
including event handler, etc. including event handler, etc.
* implement FFT with msr-interface
* switch from make to cmake * switch from make to cmake
* add the possibility for cuts to db-files * add the possibility for cuts to db-files
* add the possibility for variable transformations to db-files * add the possibility for variable transformations to db-files

View File

@@ -340,12 +340,12 @@ bool PRunAsymmetry::PrepareData()
histoNo[1] = fRunInfo->fBackwardHistoNo-1; histoNo[1] = fRunInfo->fBackwardHistoNo-1;
} }
// first check if forward/backward given in the msr-file are valid // first check if forward/backward given in the msr-file are valid
if ((runData->fDataBin.size() < histoNo[0]) || (histoNo[0] < 0) || if ((runData->fDataBin.size() < histoNo[0]+1) || (histoNo[0] < 0) ||
(runData->fDataBin.size() < histoNo[1]) || (histoNo[1] < 0)) { (runData->fDataBin.size() < histoNo[1]+1) || (histoNo[1] < 0)) {
cout << endl << "PRunAsymmetry::PrepareData(): PANIC ERROR:"; cout << endl << "PRunAsymmetry::PrepareData(): **PANIC ERROR**:";
cout << endl << " forward/backward histo no found = " << histoNo[0]; cout << endl << " forward/backward histo no found = " << histoNo[0]+1;
cout << ", " << histoNo[1] << ", but there are only " << runData->fDataBin.size() << " runs!?!?"; cout << ", " << histoNo[1]+1 << ", but there are only " << runData->fDataBin.size() << " histo sets!?!?";
cout << endl << " Will quite :-("; cout << endl << " Will quit :-(";
cout << endl; cout << endl;
return false; return false;
} }

View File

@@ -170,8 +170,8 @@ bool PRunDataHandler::ReadFile()
success = ReadPsiBinFile(); success = ReadPsiBinFile();
else if (!run_it->fFileFormat.CompareTo("mud")) else if (!run_it->fFileFormat.CompareTo("mud"))
success = ReadMudFile(); success = ReadMudFile();
else if (!run_it->fFileFormat.CompareTo("nemu")) else if (!run_it->fFileFormat.CompareTo("wkm"))
success = ReadNemuFile(); success = ReadWkmFile();
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")) else if (!run_it->fFileFormat.CompareTo("db"))
@@ -233,8 +233,12 @@ bool PRunDataHandler::FileExistsCheck(PMsrRunStructure &runInfo)
ext = TString("bin"); ext = TString("bin");
else if (!runInfo.fFileFormat.CompareTo("mud")) else if (!runInfo.fFileFormat.CompareTo("mud"))
ext = TString("mud"); ext = TString("mud");
else if (!runInfo.fFileFormat.CompareTo("nemu")) else if (!runInfo.fFileFormat.CompareTo("wkm")) {
ext = TString("nemu"); if (!runInfo.fBeamline.CompareTo("mue4"))
ext = TString("nemu");
else
ext = runInfo.fBeamline;
}
else if (!runInfo.fFileFormat.CompareTo("ascii")) else if (!runInfo.fFileFormat.CompareTo("ascii"))
ext = TString("dat"); ext = TString("dat");
else if (!runInfo.fFileFormat.CompareTo("db")) else if (!runInfo.fFileFormat.CompareTo("db"))
@@ -253,7 +257,7 @@ bool PRunDataHandler::FileExistsCheck(PMsrRunStructure &runInfo)
cout << endl << " NEXUS -> nexus file format"; cout << endl << " NEXUS -> nexus file format";
cout << endl << " PSI-BIN -> psi bin file format"; cout << endl << " PSI-BIN -> psi bin file format";
cout << endl << " MUD -> triumf mud file format"; cout << endl << " MUD -> triumf mud file format";
cout << endl << " NEMU -> lem ascii file format"; cout << endl << " WKM -> wkm 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 << " DB -> triumf db file \"format\"";
cout << endl; cout << endl;
@@ -479,15 +483,15 @@ bool PRunDataHandler::ReadNexusFile()
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
// ReadNemuFile // ReadWkmFile
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
/** /**
* <p> * <p>
* *
*/ */
bool PRunDataHandler::ReadNemuFile() bool PRunDataHandler::ReadWkmFile()
{ {
// cout << endl << "PRunDataHandler::ReadNemuFile(): Sorry, not yet implemented ..."; // cout << endl << "PRunDataHandler::ReadWkmFile(): Sorry, not yet implemented ...";
PDoubleVector histoData; PDoubleVector histoData;
PRawRunData runData; PRawRunData runData;
@@ -533,10 +537,10 @@ bool PRunDataHandler::ReadNemuFile()
Ssiz_t idx; Ssiz_t idx;
do { do {
line = TString(instr); line = TString(instr);
if (line.IsWhitespace()) { // end of header reached if (line.IsDigit()) { // end of header reached
headerInfo = false; headerInfo = false;
} else { // real stuff, hence filter data } else { // real stuff, hence filter data
if (line.Contains("Title")) { if (line.Contains("Title") || line.Contains("Titel")) {
idx = line.Index(":"); idx = line.Index(":");
line.Replace(0, idx+1, 0, 0); // remove 'Title:' line.Replace(0, idx+1, 0, 0); // remove 'Title:'
StripWhitespace(line); StripWhitespace(line);
@@ -545,6 +549,9 @@ bool PRunDataHandler::ReadNemuFile()
idx = line.Index(":"); idx = line.Index(":");
line.Replace(0, idx+1, 0, 0); // remove 'Field:' line.Replace(0, idx+1, 0, 0); // remove 'Field:'
StripWhitespace(line); StripWhitespace(line);
idx = line.Index("G"); // check if unit is given
if (idx > 0) // unit is indeed given
line.Resize(idx);
dval = ToDouble(line, ok); dval = ToDouble(line, ok);
if (ok) if (ok)
runData.fField = dval; runData.fField = dval;
@@ -557,6 +564,12 @@ bool PRunDataHandler::ReadNemuFile()
idx = line.Index(":"); idx = line.Index(":");
line.Replace(0, idx+1, 0, 0); // remove 'Temp:' line.Replace(0, idx+1, 0, 0); // remove 'Temp:'
StripWhitespace(line); StripWhitespace(line);
idx = line.Index("+-"); // remove "+- ..." part
if (idx > 0)
line.Resize(idx);
idx = line.Index("K"); // remove "K ..." part
if (idx > 0)
line.Resize(idx);
dval = ToDouble(line, ok); dval = ToDouble(line, ok);
if (ok) if (ok)
runData.fTemp = dval; runData.fTemp = dval;
@@ -583,11 +596,17 @@ bool PRunDataHandler::ReadNemuFile()
runData.fTimeResolution = dval * 1000.0; runData.fTimeResolution = dval * 1000.0;
} }
} }
f.getline(instr, sizeof(instr));
if (headerInfo)
f.getline(instr, sizeof(instr));
} while (headerInfo && !f.eof()); } while (headerInfo && !f.eof());
if ((groups == 0) || (channels == 0) || runData.fTimeResolution == 0.0) { if ((groups == 0) || (channels == 0) || runData.fTimeResolution == 0.0) {
cout << endl << "PRunDataHandler::ReadNemuFile(): essential header informations are missing!"; cout << endl << "PRunDataHandler::ReadWkmFile(): **ERROR** essential header informations are missing!";
cout << endl << " >> groups = " << groups;
cout << endl << " >> channels = " << channels;
cout << endl << " >> time resolution = " << runData.fTimeResolution;
cout << endl;
f.close(); f.close();
return false; return false;
} }
@@ -602,9 +621,11 @@ cout << endl << ">> time resolution : " << runData.fTimeResolution;
*/ */
// read data --------------------------------------------------------- // read data ---------------------------------------------------------
int status;
unsigned int group_counter = 0; unsigned int group_counter = 0;
int val[10]; int val;
TObjArray *tokens;
TObjString *ostr;
TString str;
do { do {
// check if empty line, i.e. new group // check if empty line, i.e. new group
if (IsWhitespace(instr)) { if (IsWhitespace(instr)) {
@@ -613,21 +634,43 @@ cout << endl << ">> time resolution : " << runData.fTimeResolution;
group_counter++; group_counter++;
} else { } else {
// extract values // extract values
status = sscanf(instr, "%d %d %d %d %d %d %d %d %d %d", line = TString(instr);
&val[0], &val[1], &val[2], &val[3], &val[4], // check if line starts with character. Needed for RAL WKM format
&val[5], &val[6], &val[7], &val[8], &val[9]); if (!line.IsDigit()) {
// no values found: error f.getline(instr, sizeof(instr));
if (status == 0) { continue;
cout << endl << "PRunDataHandler::ReadNemuFile(): **ERROR** while reading data ..."; }
tokens = line.Tokenize(" ");
if (!tokens) { // no tokens found
cout << endl << "PRunDataHandler::ReadWkmFile(): **ERROR** while reading data: coulnd't tokenize run data.";
// clean up // clean up
for (unsigned int i=0; i<group_counter; i++) for (unsigned int i=0; i<group_counter; i++)
runData.fDataBin[i].clear(); runData.fDataBin[i].clear();
runData.fDataBin.clear(); runData.fDataBin.clear();
return false; return false;
} }
// feed data for (int i=0; i<tokens->GetEntries(); i++) {
for (int i=0; i<status; i++) ostr = dynamic_cast<TObjString*>(tokens->At(i));
histoData.push_back(val[i]); str = ostr->GetString();
val = ToInt(str, ok);
if (ok) {
histoData.push_back(val);
} else {
cout << endl << "PRunDataHandler::ReadWkmFile(): **ERROR** while reading data: data line contains non-integer values.";
// clean up
for (unsigned int i=0; i<group_counter; i++)
runData.fDataBin[i].clear();
runData.fDataBin.clear();
delete tokens;
return false;
}
}
// clean up
if (tokens) {
delete tokens;
tokens = 0;
}
} }
f.getline(instr, sizeof(instr)); f.getline(instr, sizeof(instr));
@@ -637,13 +680,36 @@ cout << endl << ">> time resolution : " << runData.fTimeResolution;
// handle last line if present // handle last line if present
if (strlen(instr) != 0) { if (strlen(instr) != 0) {
// extract values // extract values
status = sscanf(instr, "%d %d %d %d %d %d %d %d %d %d", line = TString(instr);
&val[0], &val[1], &val[2], &val[3], &val[4], tokens = line.Tokenize(" ");
&val[5], &val[6], &val[7], &val[8], &val[9]); if (!tokens) { // no tokens found
if (status > 0) { cout << endl << "PRunDataHandler::ReadWkmFile(): **ERROR** while reading data: coulnd't tokenize run data.";
// feed data // clean up
for (int i=0; i<status; i++) for (unsigned int i=0; i<group_counter; i++)
histoData.push_back(val[i]); runData.fDataBin[i].clear();
runData.fDataBin.clear();
return false;
}
for (int i=0; i<tokens->GetEntries(); i++) {
ostr = dynamic_cast<TObjString*>(tokens->At(i));
str = ostr->GetString();
val = ToInt(str, ok);
if (ok) {
histoData.push_back(val);
} else {
cout << endl << "PRunDataHandler::ReadWkmFile(): **ERROR** while reading data: data line contains non-integer values.";
// clean up
for (unsigned int i=0; i<group_counter; i++)
runData.fDataBin[i].clear();
runData.fDataBin.clear();
delete tokens;
return false;
}
}
// clean up
if (tokens) {
delete tokens;
tokens = 0;
} }
} }
@@ -658,7 +724,7 @@ cout << endl << ">> time resolution : " << runData.fTimeResolution;
// check if all groups are found // check if all groups are found
if ((int) runData.fDataBin.size() != groups) { if ((int) runData.fDataBin.size() != groups) {
cout << endl << "PRunDataHandler::ReadNemuFile(): **ERROR**"; cout << endl << "PRunDataHandler::ReadWkmFile(): **ERROR**";
cout << endl << " expected " << groups << " histos, but found " << runData.fDataBin.size(); cout << endl << " expected " << groups << " histos, but found " << runData.fDataBin.size();
// clean up // clean up
for (unsigned int i=0; i<runData.fDataBin.size(); i++) for (unsigned int i=0; i<runData.fDataBin.size(); i++)
@@ -670,7 +736,7 @@ cout << endl << ">> time resolution : " << runData.fTimeResolution;
// check if all groups have enough channels // check if all groups have enough channels
for (unsigned int i=0; i<runData.fDataBin.size(); i++) { for (unsigned int i=0; i<runData.fDataBin.size(); i++) {
if ((int) runData.fDataBin[i].size() != channels) { if ((int) runData.fDataBin[i].size() != channels) {
cout << endl << "PRunDataHandler::ReadNemuFile(): **ERROR**"; cout << endl << "PRunDataHandler::ReadWkmFile(): **ERROR**";
cout << endl << " expected " << channels << " bins in histo " << i << ", but found " << runData.fDataBin[i].size(); cout << endl << " expected " << channels << " bins in histo " << i << ", but found " << runData.fDataBin[i].size();
// clean up // clean up
for (unsigned int j=0; j<runData.fDataBin.size(); j++) for (unsigned int j=0; j<runData.fDataBin.size(); j++)
@@ -1188,7 +1254,7 @@ bool PRunDataHandler::ReadDBFile()
// variables needed to tokenize strings // variables needed to tokenize strings
TString tstr; TString tstr;
TObjString *ostr; TObjString *ostr;
TObjArray *tokens; TObjArray *tokens = 0;
while (!f.eof()) { while (!f.eof()) {
// get next line from file // get next line from file

View File

@@ -396,17 +396,17 @@ void PStartupHandler::CheckLists()
// check if anything was set, and if not set some default stuff // check if anything was set, and if not set some default stuff
// check if any data path is given // check if any data path is given
cout << endl << ">> check data path list ..."; //cout << endl << ">> check data path list ...";
if (fDataPathList.size() == 0) { if (fDataPathList.size() == 0) {
cout << endl << ">> data path list empty, will set default ones"; //cout << endl << ">> data path list empty, will set default ones";
fDataPathList.push_back(TString("/mnt/data/nemu/his")); fDataPathList.push_back(TString("/mnt/data/nemu/his"));
fDataPathList.push_back(TString("/mnt/data/nemu/wkm")); fDataPathList.push_back(TString("/mnt/data/nemu/wkm"));
} }
// check if any markers are given // check if any markers are given
cout << endl << ">> check marker list ..."; //cout << endl << ">> check marker list ...";
if (fMarkerList.size() == 0) { if (fMarkerList.size() == 0) {
cout << endl << ">> marker list empty, will set default ones"; //cout << endl << ">> marker list empty, will set default ones";
fMarkerList.push_back(24); // open circle fMarkerList.push_back(24); // open circle
fMarkerList.push_back(25); // open square fMarkerList.push_back(25); // open square
fMarkerList.push_back(26); // open triangle fMarkerList.push_back(26); // open triangle
@@ -424,9 +424,9 @@ cout << endl << ">> marker list empty, will set default ones";
} }
// check if any colors are given // check if any colors are given
cout << endl << ">> check color list ..."; //cout << endl << ">> check color list ...";
if (fColorList.size() == 0) { if (fColorList.size() == 0) {
cout << endl << ">> color list empty, will set default ones"; //cout << endl << ">> color list empty, will set default ones";
fColorList.push_back(TColor::GetColor(0, 0, 0)); // kBlack fColorList.push_back(TColor::GetColor(0, 0, 0)); // kBlack
fColorList.push_back(TColor::GetColor(255, 0, 0)); // kRed fColorList.push_back(TColor::GetColor(255, 0, 0)); // kRed
fColorList.push_back(TColor::GetColor(0, 255, 0)); // kGreen fColorList.push_back(TColor::GetColor(0, 255, 0)); // kGreen

View File

@@ -64,7 +64,7 @@ class PRunDataHandler
virtual bool FileExistsCheck(PMsrRunStructure &runInfo); virtual bool FileExistsCheck(PMsrRunStructure &runInfo);
virtual bool ReadRootFile(bool notPostPileup); virtual bool ReadRootFile(bool notPostPileup);
virtual bool ReadNexusFile(); virtual bool ReadNexusFile();
virtual bool ReadNemuFile(); virtual bool ReadWkmFile();
virtual bool ReadPsiBinFile(); virtual bool ReadPsiBinFile();
virtual bool ReadMudFile(); virtual bool ReadMudFile();
virtual bool ReadAsciiFile(); virtual bool ReadAsciiFile();

View File

@@ -97,7 +97,7 @@ bool msr2msr_run(char *str)
if (run.Contains("NEMU")) { if (run.Contains("NEMU")) {
ostr[0] = dynamic_cast<TObjString*>(tokens->At(1)); // file name ostr[0] = dynamic_cast<TObjString*>(tokens->At(1)); // file name
sprintf(str, "RUN %s MUE4 PSI NEMU (name beamline institute data-file-format)", ostr[0]->GetString().Data()); sprintf(str, "RUN %s MUE4 PSI WKM (name beamline institute data-file-format)", ostr[0]->GetString().Data());
} else if (run.Contains("PSI")) { } else if (run.Contains("PSI")) {
ostr[0] = dynamic_cast<TObjString*>(tokens->At(1)); // file name ostr[0] = dynamic_cast<TObjString*>(tokens->At(1)); // file name
ostr[1] = dynamic_cast<TObjString*>(tokens->At(2)); // beamline ostr[1] = dynamic_cast<TObjString*>(tokens->At(2)); // beamline