From e38d0793ba66330e1a43af57adb94b56c0d4dc99 Mon Sep 17 00:00:00 2001 From: nemu Date: Wed, 30 Sep 2009 13:21:49 +0000 Subject: [PATCH] a first implementation for the triumf mud-format. Start migrating towards real CERN ROOT notation int->Int_t, etc. --- src/classes/PRunDataHandler.cpp | 471 ++++++++++++++++++++++++-------- src/external/mud/src/mud.h | 9 + src/include/PMusr.h | 169 ++++++------ src/include/PRunDataHandler.h | 34 +-- src/tests/mud/mud_test.c | 1 + 5 files changed, 470 insertions(+), 214 deletions(-) diff --git a/src/classes/PRunDataHandler.cpp b/src/classes/PRunDataHandler.cpp index fd0d8caf..fdc3e079 100644 --- a/src/classes/PRunDataHandler.cpp +++ b/src/classes/PRunDataHandler.cpp @@ -92,9 +92,9 @@ PRunDataHandler::PRunDataHandler(PMsrHandler *msrInfo, const PStringVector dataP */ PRunDataHandler::~PRunDataHandler() { - for (unsigned int i=0; ireturn: true if reading was successful, false if reading failed. */ -bool PRunDataHandler::ReadFile() +Bool_t PRunDataHandler::ReadFile() { - bool success = true; + Bool_t success = true; // loop over the full RUN list to see what needs to be read PMsrRunList *runList = 0; @@ -147,8 +147,8 @@ bool PRunDataHandler::ReadFile() return false; } - for (unsigned int i=0; isize(); i++) { - for (unsigned int j=0; jat(i).fRunName.size(); j++) { + for (UInt_t i=0; isize(); i++) { + for (UInt_t j=0; jat(i).fRunName.size(); j++) { fRunName = runList->at(i).fRunName[j]; // check is file is already read if (FileAlreadyRead(runList->at(i).fRunName[j])) @@ -190,9 +190,9 @@ bool PRunDataHandler::ReadFile() * * return: true if the file has been read before, otherwise false. */ -bool PRunDataHandler::FileAlreadyRead(TString runName) +Bool_t PRunDataHandler::FileAlreadyRead(TString runName) { - for (unsigned int i=0; ireturn: true if data file exists, otherwise false. */ -bool PRunDataHandler::FileExistsCheck(PMsrRunStructure &runInfo, const unsigned int idx) +Bool_t PRunDataHandler::FileExistsCheck(PMsrRunStructure &runInfo, const UInt_t idx) { - bool success = true; + Bool_t success = true; // local init TROOT root("PRunBase", "PRunBase", 0); @@ -236,7 +236,7 @@ bool PRunDataHandler::FileExistsCheck(PMsrRunStructure &runInfo, const unsigned else if (!runInfo.fFileFormat[idx].CompareTo("psi-bin")) ext = TString("bin"); else if (!runInfo.fFileFormat[idx].CompareTo("mud")) - ext = TString("mud"); + ext = TString("msr"); else if (!runInfo.fFileFormat[idx].CompareTo("wkm")) { if (!runInfo.fBeamline[idx].CompareTo("mue4")) ext = TString("nemu"); @@ -285,7 +285,7 @@ bool PRunDataHandler::FileExistsCheck(PMsrRunStructure &runInfo, const unsigned // check if the file is found in the directory given in the startup file if (pathName.CompareTo("???") == 0) { // not found in local directory search - for (unsigned int i=0; iAccessPathName(str.Data())!=true) { // found pathName = str; @@ -295,13 +295,13 @@ bool PRunDataHandler::FileExistsCheck(PMsrRunStructure &runInfo, const unsigned } // check if the file is found in the directories given by WKMFULLDATAPATH - const char *wkmpath = gSystem->Getenv("WKMFULLDATAPATH"); + const Char_t *wkmpath = gSystem->Getenv("WKMFULLDATAPATH"); if (pathName.CompareTo("???") == 0) { // not found in local directory and xml path str = TString(wkmpath); // WKMFULLDATAPATH has the structure: path_1:path_2:...:path_n TObjArray *tokens = str.Tokenize(":"); TObjString *ostr; - for (int i=0; iGetEntries(); i++) { + for (Int_t i=0; iGetEntries(); i++) { ostr = dynamic_cast(tokens->At(i)); str = ostr->GetString() + TString("/") + runInfo.fRunName[idx] + TString(".") + ext; if (gSystem->AccessPathName(str.Data())!=true) { // found @@ -322,7 +322,7 @@ bool PRunDataHandler::FileExistsCheck(PMsrRunStructure &runInfo, const unsigned TDatime datetime; TString dt; dt += datetime.GetYear(); - for (int i=0; iGetEntries(); i++) { + for (Int_t i=0; iGetEntries(); i++) { ostr = dynamic_cast(tokens->At(i)); str = ostr->GetString() + TString("/DATA/") + runInfo.fInstitute[idx] + TString("/") + @@ -363,7 +363,7 @@ bool PRunDataHandler::FileExistsCheck(PMsrRunStructure &runInfo, const unsigned * * return: true at successful reading, otherwise false. */ -bool PRunDataHandler::ReadRootFile(bool notPostPileup) +Bool_t PRunDataHandler::ReadRootFile(Bool_t notPostPileup) { PDoubleVector histoData; PRawRunData runData; @@ -416,15 +416,15 @@ bool PRunDataHandler::ReadRootFile(bool notPostPileup) runData.fTimeResolution = runHeader->GetTimeResolution(); // get number of histogramms - int noOfHistos = runHeader->GetNHist(); + Int_t noOfHistos = runHeader->GetNHist(); // get t0's Double_t *t0 = runHeader->GetTimeZero(); // check if t0's are there if (t0[0] != -1) { // ugly, but at the moment there is no other way // copy t0's so they are not lost - for (int i=0; i(folder->FindObjectAny(histoName)); if (!histo) { @@ -544,7 +544,7 @@ bool PRunDataHandler::ReadRootFile(bool notPostPileup) return false; } // fill data - for (int j=1; jGetNbinsX(); j++) + for (Int_t j=1; jGetNbinsX(); j++) histoData.push_back(histo->GetBinContent(j)); // store them in runData vector runData.fDataBin.push_back(histoData); @@ -552,7 +552,7 @@ bool PRunDataHandler::ReadRootFile(bool notPostPileup) histoData.clear(); } } else { // read the data which ARE post pileup corrected - for (int i=0; i(folder->FindObjectAny(histoName)); if (!histo) { @@ -560,7 +560,7 @@ bool PRunDataHandler::ReadRootFile(bool notPostPileup) return false; } // fill data - for (int j=1; jGetNbinsX(); j++) + for (Int_t j=1; jGetNbinsX(); j++) histoData.push_back(histo->GetBinContent(j)); // store them in runData vector runData.fDataBin.push_back(histoData); @@ -578,7 +578,7 @@ bool PRunDataHandler::ReadRootFile(bool notPostPileup) fData.push_back(runData); // clean up - for (unsigned int i=0; ireturn: true at successful reading, otherwise false. */ -bool PRunDataHandler::ReadNexusFile() +Bool_t PRunDataHandler::ReadNexusFile() { cout << endl << "PRunDataHandler::ReadNexusFile(): Sorry, not yet implemented, ask Alex Amato ..."; return false; @@ -611,7 +611,7 @@ bool PRunDataHandler::ReadNexusFile() * * return: true at successful reading, otherwise false. */ -bool PRunDataHandler::ReadWkmFile() +Bool_t PRunDataHandler::ReadWkmFile() { PDoubleVector histoData; PRawRunData runData; @@ -639,13 +639,13 @@ bool PRunDataHandler::ReadWkmFile() } // read header - bool headerInfo = true; - char instr[512]; + Bool_t headerInfo = true; + Char_t instr[512]; TString line, linecp; - double dval; - int ival; - bool ok; - int groups = 0, channels = 0; + Double_t dval; + Int_t ival; + Bool_t ok; + Int_t groups = 0, channels = 0; // skip leading empty lines do { @@ -769,8 +769,8 @@ bool PRunDataHandler::ReadWkmFile() } // read data --------------------------------------------------------- - unsigned int group_counter = 0; - int val; + UInt_t group_counter = 0; + Int_t val; TObjArray *tokens; TObjString *ostr; TString str; @@ -793,12 +793,12 @@ bool PRunDataHandler::ReadWkmFile() if (!tokens) { // no tokens found cerr << endl << "PRunDataHandler::ReadWkmFile(): **ERROR** while reading data: coulnd't tokenize run data."; // clean up - for (unsigned int i=0; iGetEntries(); i++) { + for (Int_t i=0; iGetEntries(); i++) { ostr = dynamic_cast(tokens->At(i)); str = ostr->GetString(); val = ToInt(str, ok); @@ -807,7 +807,7 @@ bool PRunDataHandler::ReadWkmFile() } else { cerr << endl << "PRunDataHandler::ReadWkmFile(): **ERROR** while reading data: data line contains non-integer values."; // clean up - for (unsigned int i=0; iGetEntries(); i++) { + for (Int_t i=0; iGetEntries(); i++) { ostr = dynamic_cast(tokens->At(i)); str = ostr->GetString(); val = ToInt(str, ok); @@ -847,7 +847,7 @@ bool PRunDataHandler::ReadWkmFile() } else { cerr << endl << "PRunDataHandler::ReadWkmFile(): **ERROR** while reading data: data line contains non-integer values."; // clean up - for (unsigned int i=0; ireturn: true at successful reading, otherwise false. */ -bool PRunDataHandler::ReadPsiBinFile() +Bool_t PRunDataHandler::ReadPsiBinFile() { MuSR_td_PSI_bin psiBin; - int status; - bool success; + Int_t status; + Bool_t success; // read psi bin file status = psiBin.read(fRunPathName.Data()); @@ -961,7 +961,7 @@ bool PRunDataHandler::ReadPsiBinFile() // fill necessary header informations PIntVector ivec; PRawRunData runData; - double dval; + Double_t dval; // keep run name runData.fRunName = fRunName; // get run title @@ -983,7 +983,7 @@ bool PRunDataHandler::ReadPsiBinFile() runData.fTemp.resize(2); // take only the first two values for now... //maybe that's not enough - e.g. in older GPD data I saw the "correct values in the second and third entry..." - for (unsigned int i(0); i<2; i++){ + for (UInt_t i(0); i<2; i++){ runData.fTemp[i].first = tempVec[i]; runData.fTemp[i].second = tempDevVec[i]; } @@ -1006,15 +1006,15 @@ bool PRunDataHandler::ReadPsiBinFile() cerr << endl; return false; } - for (unsigned int i=0; ireturn: true at successful reading, otherwise false. */ -bool PRunDataHandler::ReadMudFile() +Bool_t PRunDataHandler::ReadMudFile() { - Int_t fh; - UINT32 type; + Int_t fh; + UINT32 type, val; + Int_t success; + Char_t str[1024]; + Double_t dval; - fh = MUD_openRead((char *)fRunPathName.Data(), &type); + PRawRunData runData; + + fh = MUD_openRead((Char_t *)fRunPathName.Data(), &type); if (fh == -1) { cerr << endl << "**ERROR** Couldn't open mud-file " << fRunPathName.Data() << ", sorry."; cerr << endl; @@ -1055,13 +1060,241 @@ bool PRunDataHandler::ReadMudFile() } // read necessary header information - // STILL MISSING + + // keep run name + runData.fRunName = fRunName; + + // get run title + success = MUD_getTitle( fh, str, sizeof(str) ); + if ( !success ) { + cerr << endl << "**WARNING** Couldn't obtain the run title of run " << fRunName.Data(); + cerr << endl; + } + runData.fRunTitle = TString(str); + + // get setup + success = MUD_getLab( fh, str, sizeof(str) ); + if (success) { + runData.fSetup = TString(str) + TString("/"); + } + success = MUD_getArea( fh, str, sizeof(str) ); + if (success) { + runData.fSetup += TString(str) + TString("/"); + } + success = MUD_getApparatus( fh, str, sizeof(str) ); + if (success) { + runData.fSetup += TString(str) + TString("/"); + } + success = MUD_getSample( fh, str, sizeof(str) ); + if (success) { + runData.fSetup += TString(str); + } + + // set LEM specific information to default value since it is not in the file and not used... + runData.fEnergy = -999.0; + runData.fTransport = -999.0; + runData.fRingAnode.clear(); + + // get field + success = MUD_getField( fh, str, sizeof(str) ); + if (success) { + success = sscanf(str, "%lf G", &dval); + if (success == 1) { + runData.fField = dval; + } else { + runData.fField = -9.9e99; + } + } else { + runData.fField = -9.9e99; + } + + // get temperature + success = MUD_getTemperature( fh, str, sizeof(str) ); + if (success) { + runData.fTemp.resize(1); + success = sscanf(str, "%lf K", &dval); + if (success == 1) { + runData.fTemp[0].first = dval; + runData.fTemp[0].second = 0.0; + } else { + runData.fTemp[0].first = -9.9e99; + runData.fTemp[0].second = 0.0; + } + } else { + runData.fTemp[0].first = -9.9e99; + runData.fTemp[0].second = 0.0; + } + + // get number of histogramms + success = MUD_getHists(fh, &type, &val); + if ( !success ) { + cerr << endl << "**ERROR** Couldn't obtain the number of histograms of run " << fRunName.Data(); + cerr << endl; + MUD_closeRead(fh); + return false; + } + Int_t noOfHistos = (Int_t)val; + + // get time resolution (ns) + // check that time resolution is identical for all histograms + // >> currently it is not forseen to handle histos with different time resolutions << + // >> perhaps this needs to be reconsidered later on << + UINT32 fsTimeResolution = 0; + for (Int_t i=1; i<=noOfHistos; i++) { + success = MUD_getHistFsPerBin( fh, i, &val ); + if (!success) { + cerr << endl << "**ERROR** Couldn't obtain the time resolution of run " << fRunName.Data(); + cerr << endl << " which is fatal, sorry."; + cerr << endl; + MUD_closeRead(fh); + return false; + } + if (i==1) { + fsTimeResolution = val; + } else { + if (val != fsTimeResolution) { + cerr << endl << "**ERROR** various time resolutions found in run " << fRunName.Data(); + cerr << endl << " this is currently not supported, sorry."; + cerr << endl; + MUD_closeRead(fh); + return false; + } + } + } + runData.fTimeResolution = (Double_t)fsTimeResolution / 1.0e6; // fs -> ns // read histograms - // STILL MISSING + pair valPair; + UINT32 *pData; // histo memory + pData = NULL; + PDoubleVector histoData; + UInt_t noOfBins; + + for (Int_t i=1; i<=noOfHistos; i++) { + + // get t0's + success = MUD_getHistT0_Bin( fh, i, &val ); + if ( !success ) { + cerr << endl << "**WARNING** Couldn't get t0 of histo " << i << " of run " << fRunName.Data(); + cerr << endl; + } + runData.fT0s.push_back((Int_t)val); + + // get bkg bins + success = MUD_getHistBkgd1( fh, i, &val ); + if ( !success ) { + cerr << endl << "**WARNING** Couldn't get bkg bin 1 of histo " << i << " of run " << fRunName.Data(); + cerr << endl; + valPair.first = -1; + } else { + valPair.first = (Int_t)val; + } + + success = MUD_getHistBkgd2( fh, i, &val ); + if ( !success ) { + cerr << endl << "**WARNING** Couldn't get bkg bin 2 of histo " << i << " of run " << fRunName.Data(); + cerr << endl; + valPair.second = -1; + } + valPair.second = (Int_t)val; + + if ((valPair.first != -1) && (valPair.second != -1)) { // bkg bin1 && bkg bin2 found + runData.fBkgBin.push_back(valPair); + } else { + runData.fBkgBin.clear(); + } + + // get good data bins + success = MUD_getHistGoodBin1( fh, i, &val ); + if ( !success ) { + cerr << endl << "**WARNING** Couldn't get good bin 1 of histo " << i << " of run " << fRunName.Data(); + cerr << endl; + valPair.first = -1; + } else { + valPair.first = (Int_t)val; + } + + success = MUD_getHistGoodBin2( fh, i, &val ); + if ( !success ) { + cerr << endl << "**WARNING** Couldn't get good bin 2 of histo " << i << " of run " << fRunName.Data(); + cerr << endl; + valPair.second = -1; + } + valPair.second = (Int_t)val; + + if ((valPair.first != -1) && (valPair.second != -1)) { // good bin1 && good bin2 found + runData.fGoodDataBin.push_back(valPair); + } else { + runData.fGoodDataBin.clear(); + } + + // get number of bins + success = MUD_getHistNumBins( fh, i, &val ); + if ( !success ) { + cerr << endl << "**ERROR** Couldn't get the number of bins of histo " << i << "."; + cerr << endl << " This is fatal, sorry."; + cerr << endl; + MUD_closeRead( fh ); + return false; + } + noOfBins = (UInt_t)val; + + pData = (UINT32*)malloc(noOfBins*sizeof(pData)); + if (pData == NULL) { + cerr << endl << "**ERROR** Couldn't allocate memory for data."; + cerr << endl << " This is fatal, sorry."; + cerr << endl; + MUD_closeRead( fh ); + return false; + } + + // get histogram + success = MUD_getHistData( fh, i, pData ); + if ( !success ) { + cerr << endl << "**ERROR** Couldn't get histo no " << i << "."; + cerr << endl << " This is fatal, sorry."; + cerr << endl; + MUD_closeRead( fh ); + return false; + } + + for (UInt_t j=0; jreturn: true at successful reading, otherwise false. */ -bool PRunDataHandler::ReadAsciiFile() +Bool_t PRunDataHandler::ReadAsciiFile() { - bool success = true; + Bool_t success = true; // open file ifstream f; @@ -1126,12 +1359,12 @@ bool PRunDataHandler::ReadAsciiFile() runData.fRunName = fRunName; // keep the run name - int lineNo = 0; - char instr[512]; + Int_t lineNo = 0; + Char_t instr[512]; TString line, workStr; - bool headerTag = false; - bool dataTag = false; - double x, y, ey; + Bool_t headerTag = false; + Bool_t dataTag = false; + Double_t x, y, ey; PDoubleVector xVec, exVec, yVec, eyVec; while (!f.eof()) { @@ -1410,9 +1643,9 @@ bool PRunDataHandler::ReadAsciiFile() *

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_t PRunDataHandler::ReadDBFile() { - bool success = true; + Bool_t success = true; // open file ifstream f; @@ -1429,14 +1662,14 @@ bool PRunDataHandler::ReadDBFile() runData.fDataNonMusr.fFromAscii = false; - int lineNo = 0; - int idx; - int dbTag = -1; - char instr[512]; + Int_t lineNo = 0; + Int_t idx; + Int_t dbTag = -1; + Char_t instr[512]; TString line, workStr; - double val; - 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) + Double_t val; + Bool_t firstData = true; // needed as a switch to check in which format the data are given. + Bool_t labelledFormat = true; // flag showing if the data are given in row format, or as labelled format (see description above, default is labelled format) // variables needed to tokenize strings TString tstr; @@ -1477,7 +1710,7 @@ bool PRunDataHandler::ReadDBFile() // filter out all data tags tokens = workStr.Tokenize(" ,\t"); - for (int i=1; iGetEntries(); i++) { + for (Int_t i=1; iGetEntries(); i++) { ostr = dynamic_cast(tokens->At(i)); runData.fDataNonMusr.fDataTags.push_back(ostr->GetString()); } @@ -1530,7 +1763,7 @@ bool PRunDataHandler::ReadDBFile() // prepare data vector for use PDoubleVector dummy; - for (unsigned int i=0; iGetEntries() != (int)(3*runData.fDataNonMusr.fDataTags.size()+1)) { + if (tokens->GetEntries() != (Int_t)(3*runData.fDataNonMusr.fDataTags.size()+1)) { cerr << endl << "PRunDataHandler::ReadDBFile **ERROR** in line no " << lineNo << ":"; cerr << endl << ">> " << workStr.Data(); cerr << endl << ">> Expected db-data line with structure: val1, err11, err12, ..., valn, errn1, errn2, runNo, , , , runTitle"; @@ -1656,8 +1889,8 @@ bool PRunDataHandler::ReadDBFile() return false; } // extract data - int j=0; - for (int i=0; iGetEntries()-1; i+=3) { + Int_t j=0; + for (Int_t i=0; iGetEntries()-1; i+=3) { // handle value ostr = dynamic_cast(tokens->At(i)); tstr = ostr->GetString(); @@ -1711,7 +1944,7 @@ bool PRunDataHandler::ReadDBFile() } // check if all vectors have the same size - for (unsigned int i=1; i> label: " << runData.fDataNonMusr.fDataTags[i-1].Data() << ", number data elements = " << runData.fDataNonMusr.fData[i-1].size(); @@ -1755,22 +1988,22 @@ bool PRunDataHandler::ReadDBFile() * * return: true at success, otherwise false. */ -bool PRunDataHandler::StripWhitespace(TString &str) +Bool_t PRunDataHandler::StripWhitespace(TString &str) { - char *s = 0; - char *subs = 0; - int i; - int start; - int end; - int size; + Char_t *s = 0; + Char_t *subs = 0; + Int_t i; + Int_t start; + Int_t end; + Int_t size; - size = (int)str.Length(); - s = new char[size+1]; + size = (Int_t)str.Length(); + s = new Char_t[size+1]; if (!s) return false; - for (int i=0; ireturn: true if string consist only of white spaces, otherwise false. */ -bool PRunDataHandler::IsWhitespace(const char *str) +Bool_t PRunDataHandler::IsWhitespace(const Char_t *str) { - unsigned int i=0; + UInt_t i=0; while (isblank(str[i]) || iscntrl(str[i])) { if (str[i] == 0) @@ -1845,23 +2078,23 @@ bool PRunDataHandler::IsWhitespace(const char *str) // ToDouble (private) //-------------------------------------------------------------------------- /** - *

Convert a string to a double. + *

Convert a string to a Double_t. * * \param str string to be converted * \param ok true on success, otherwise false. * * return: returns the converted string, or 0.0 in case of ok==false */ -double PRunDataHandler::ToDouble(TString &str, bool &ok) +Double_t PRunDataHandler::ToDouble(TString &str, Bool_t &ok) { - char *s; - double value; - int size, status; + Char_t *s; + Double_t value; + Int_t size, status; ok = true; - size = (int)str.Length(); - s = new char[size+1]; + size = (Int_t)str.Length(); + s = new Char_t[size+1]; if (!s) { ok = false; @@ -1869,7 +2102,7 @@ double PRunDataHandler::ToDouble(TString &str, bool &ok) } // copy string; stupid way but it works - for (int i=0; i Convert a string to an int. + *

Convert a string to an Int_t. * * \param str string to be converted * \param ok true on success, otherwise false. * * return: returns the converted string, or 0 in case of ok==false */ -int PRunDataHandler::ToInt(TString &str, bool &ok) +Int_t PRunDataHandler::ToInt(TString &str, Bool_t &ok) { - char *s; - int value; - int size, status; + Char_t *s; + Int_t value; + Int_t size, status; ok = true; - size = (int)str.Length(); - s = new char[size+1]; + size = (Int_t)str.Length(); + s = new Char_t[size+1]; if (!s) { ok = false; @@ -1917,7 +2150,7 @@ int PRunDataHandler::ToInt(TString &str, bool &ok) } // copy string; stupid way but it works - for (int i=0; ireturn: if found returns the data tag index (from the dataTags vector), otherwise -1 */ -int PRunDataHandler::GetDataTagIndex(TString &str, PStringVector &dataTags) +Int_t PRunDataHandler::GetDataTagIndex(TString &str, PStringVector &dataTags) { - int result = -1; + Int_t result = -1; // check all the other possible data tags - for (unsigned int i=0; i typedef to make to code more readable. */ -typedef vector PIntVector; +typedef vector PIntVector; //------------------------------------------------------------- /** *

*/ -typedef vector PDoubleVector; +typedef vector< pair > PIntPairVector; + +//------------------------------------------------------------- +/** + *

+ */ +typedef vector PDoubleVector; + +//------------------------------------------------------------- +/** + *

+ */ +typedef vector< pair > PDoublePairVector; //------------------------------------------------------------- /** @@ -149,14 +161,14 @@ enum EPMusrHandleTag { kEmpty, kFit, kView }; */ typedef struct { // data related info - double fDataTimeStart; - double fDataTimeStep; + Double_t fDataTimeStart; + Double_t fDataTimeStep; PDoubleVector fX; // only used for non-muSR PDoubleVector fValue; PDoubleVector fError; // theory related info - double fTheoryTimeStart; - double fTheoryTimeStep; + Double_t fTheoryTimeStart; + Double_t fTheoryTimeStep; PDoubleVector fXTheory; // only used for non-muSR PDoubleVector fTheory; } PRunData; @@ -166,7 +178,7 @@ typedef struct { *

*/ typedef struct { - bool fFromAscii; ///< if true: data file was an ascii input file, otherwise it is a db input file + Bool_t fFromAscii; ///< if true: data file was an ascii input file, otherwise it is a db input file PStringVector fLabels; ///< vector of all labels (used for x-, y-axis title in view) PStringVector fDataTags; ///< vector of all data tags vector fData; ///< vector of all data @@ -181,14 +193,15 @@ typedef struct { TString fRunName; ///< name of the run TString fRunTitle; ///< run title TString fSetup; ///< description of the setup of this run - double fField; ///< magnetic field value -// double fTemp; ///< temperature during the run - vector< pair > fTemp; ///< measured temperatures and standard deviations during the run - double fEnergy; ///< implantation energy of the muon - double fTransport; ///< LEM transport settings (Moderator HV) + Double_t fField; ///< magnetic field value + PDoublePairVector fTemp; ///< measured temperatures and standard deviations during the run + Double_t fEnergy; ///< implantation energy of the muon + Double_t fTransport; ///< LEM transport settings (Moderator HV) PDoubleVector fRingAnode; ///< LEM ring anode HVs (L,R[,T,B]) - double fTimeResolution; ///< time resolution of the run + Double_t fTimeResolution; ///< time resolution of the run PIntVector fT0s; ///< vector of t0's of a run + PIntPairVector fBkgBin; ///< background bins (first/last) + PIntPairVector fGoodDataBin; ///< data bins (first/last) vector fDataBin; ///< vector of all histos of a run PNonMusrRawRunData fDataNonMusr; ///< keeps all ascii- or db-file info in case of nonMusr fit } PRawRunData; @@ -204,7 +217,7 @@ typedef vector PRawRunDataList; *

Helper structure for parsing. Keeps a msr-file line string and the corresponding line number. */ typedef struct { - int fLineNo; ///< original line number of the msr-file + Int_t fLineNo; ///< original line number of the msr-file TString fLine; ///< msr-file line } PMsrLineStructure; @@ -219,17 +232,17 @@ typedef vector PMsrLines; *

Holds the information of a parameter. */ typedef struct { - int fNoOfParams; ///< how many parameters are given - int fNo; ///< parameter number - TString fName; ///< name - double fValue; ///< value - double fStep; ///< step / error / neg_error, depending on the situation - bool fPosErrorPresent; ///< positive error is defined (as a number) - double fPosError; ///< positive error if present - bool fLowerBoundaryPresent; ///< flag showing if a lower boundary is present - double fLowerBoundary; ///< lower boundary for the fit parameter - bool fUpperBoundaryPresent; ///< flag showing if an upper boundary is present - double fUpperBoundary; ///< upper boundary for the fit parameter + Int_t fNoOfParams; ///< how many parameters are given + Int_t fNo; ///< parameter number + TString fName; ///< name + Double_t fValue; ///< value + Double_t fStep; ///< step / error / neg_error, depending on the situation + Bool_t fPosErrorPresent; ///< positive error is defined (as a number) + Double_t fPosError; ///< positive error if present + Bool_t fLowerBoundaryPresent; ///< flag showing if a lower boundary is present + Double_t fLowerBoundary; ///< lower boundary for the fit parameter + Bool_t fUpperBoundaryPresent; ///< flag showing if an upper boundary is present + Double_t fUpperBoundary; ///< upper boundary for the fit parameter } PMsrParamStructure; //------------------------------------------------------------- @@ -244,35 +257,35 @@ typedef vector PMsrParamList; * */ typedef struct { - PStringVector fRunName; ///< name of the run file - PStringVector fBeamline; ///< e.g. mue4, mue1, pim3, emu, m15, ... (former: run type) - PStringVector fInstitute; ///< e.g. psi, ral, triumf (former: run format) - PStringVector 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 fAlphaParamNo; ///< alpha parameter number (fit type 2, 4) - int fBetaParamNo; ///< beta parameter number (fit type 2, 4) - int fNormParamNo; ///< N0 parameter number (fit type 0) - int fBkgFitParamNo; ///< background fit parameter number (fit type 0) - int fPhaseParamNo; ///< ??? NEEDED ??? NEEDS TO BE CHECKED !!! - int fLifetimeParamNo; ///< muon lifetime parameter number (fit type 0) - bool fLifetimeCorrection; ///< lifetime correction flag for viewing (fit type 0) - PIntVector fMap; ///< map vector needed to switch parameters for different runs within a single theory - int fForwardHistoNo; ///< forward histogram number (fit type 0, 2, 4) - int fBackwardHistoNo; ///< backward histogram number (fit type 2, 4) - PDoubleVector fBkgFix; ///< fixed background in (1/ns) (fit type 0, 2, 4) - PIntVector fBkgRange; ///< background bin range (fit type 0, 2, 4) - PIntVector fDataRange; ///< data bin range (fit type 0, 2, 4) - PIntVector fT0; ///< t0 bins (fit type 0, 2, 4). if fit type 0 -> f0, f1, f2, ...; if fit type 2, 4 -> f0, b0, f1, b1, ... - double fFitRange[2]; ///< fit range in (us) - int fPacking; ///< packing/rebinning - double fRRFFreq; ///< rotating reference frequency (fit type 4) - int fRRFPacking; ///< rotating reference packing (fit type 4) - int fAlpha2ParamNo; ///< rotating reference alpha2 (fit type 4) - int fBeta2ParamNo; ///< rotating reference beta2 (fit type 4) - int fRightHistoNo; ///< rotating reference right histogram number (fit type 4) - int fLeftHistoNo; ///< rotating reference left histogram number (fit type 4) - int fXYDataIndex[2]; ///< used to get the data indices when using db-files (fit type 8) - TString fXYDataLabel[2]; ///< used to get the indices via labels when using db-files (fit type 8) + PStringVector fRunName; ///< name of the run file + PStringVector fBeamline; ///< e.g. mue4, mue1, pim3, emu, m15, ... (former: run type) + PStringVector fInstitute; ///< e.g. psi, ral, triumf (former: run format) + PStringVector fFileFormat; ///< e.g. root, nexus, psi-bin, mud, ascii, db + Int_t fFitType; ///< fit type: 0=single histo fit, 2=asymmetry fit, 4=asymmetry in RRF, 8=non muSR + Int_t fAlphaParamNo; ///< alpha parameter number (fit type 2, 4) + Int_t fBetaParamNo; ///< beta parameter number (fit type 2, 4) + Int_t fNormParamNo; ///< N0 parameter number (fit type 0) + Int_t fBkgFitParamNo; ///< background fit parameter number (fit type 0) + Int_t fPhaseParamNo; ///< ??? NEEDED ??? NEEDS TO BE CHECKED !!! + Int_t fLifetimeParamNo; ///< muon lifetime parameter number (fit type 0) + Bool_t fLifetimeCorrection; ///< lifetime correction flag for viewing (fit type 0) + PIntVector fMap; ///< map vector needed to switch parameters for different runs within a single theory + Int_t fForwardHistoNo; ///< forward histogram number (fit type 0, 2, 4) + Int_t fBackwardHistoNo; ///< backward histogram number (fit type 2, 4) + PDoubleVector fBkgFix; ///< fixed background in (1/ns) (fit type 0, 2, 4) + PIntVector fBkgRange; ///< background bin range (fit type 0, 2, 4) + PIntVector fDataRange; ///< data bin range (fit type 0, 2, 4) + PIntVector fT0; ///< t0 bins (fit type 0, 2, 4). if fit type 0 -> f0, f1, f2, ...; if fit type 2, 4 -> f0, b0, f1, b1, ... + Double_t fFitRange[2]; ///< fit range in (us) + Int_t fPacking; ///< packing/rebinning + Double_t fRRFFreq; ///< rotating reference frequency (fit type 4) + Int_t fRRFPacking; ///< rotating reference packing (fit type 4) + Int_t fAlpha2ParamNo; ///< rotating reference alpha2 (fit type 4) + Int_t fBeta2ParamNo; ///< rotating reference beta2 (fit type 4) + Int_t fRightHistoNo; ///< rotating reference right histogram number (fit type 4) + Int_t fLeftHistoNo; ///< rotating reference left histogram number (fit type 4) + Int_t fXYDataIndex[2]; ///< used to get the data indices when using db-files (fit type 8) + TString fXYDataLabel[2]; ///< used to get the indices via labels when using db-files (fit type 8) } PMsrRunStructure; //------------------------------------------------------------- @@ -286,16 +299,16 @@ typedef vector PMsrRunList; *

Holds the information of the Fourier block */ typedef struct { - bool fFourierBlockPresent; ///< flag indicating if a Fourier block is present in the msr-file - int fUnits; ///< flag used to indicate the units. 0=field units (G); 1=frequency units (MHz); 2=Mc/s - int fFourierPower; ///< i.e. zero padding up to 2^fFourierPower, default = 0 which means NO zero padding - int fApodization; ///< tag indicating the kind of apodization wished, 0=no appodization (default), 1=weak, 2=medium, 3=strong (for details see the docu) - int fPlotTag; ///< tag used for initial plot. 0=real, 1=imaginary, 2=real & imaginary (default), 3=power, 4=phase - int fPhaseParamNo; ///< parameter number if used instead of a phase value - double fPhase; ///< phase - double fRangeForPhaseCorrection[2]; ///< field/frequency range for automatic phase correction - double fPlotRange[2]; ///< field/frequency plot range - double fPhaseIncrement; ///< phase increment for manual phase optimization + Bool_t fFourierBlockPresent; ///< flag indicating if a Fourier block is present in the msr-file + Int_t fUnits; ///< flag used to indicate the units. 0=field units (G); 1=frequency units (MHz); 2=Mc/s + Int_t fFourierPower; ///< i.e. zero padding up to 2^fFourierPower, default = 0 which means NO zero padding + Int_t fApodization; ///< tag indicating the kind of apodization wished, 0=no appodization (default), 1=weak, 2=medium, 3=strong (for details see the docu) + Int_t fPlotTag; ///< tag used for initial plot. 0=real, 1=imaginary, 2=real & imaginary (default), 3=power, 4=phase + Int_t fPhaseParamNo; ///< parameter number if used instead of a phase value + Double_t fPhase; ///< phase + Double_t fRangeForPhaseCorrection[2]; ///< field/frequency range for automatic phase correction + Double_t fPlotRange[2]; ///< field/frequency plot range + Double_t fPhaseIncrement; ///< phase increment for manual phase optimization } PMsrFourierStructure; //------------------------------------------------------------- @@ -303,16 +316,16 @@ typedef struct { *

Holds the information of a single plot block */ typedef struct { - int fPlotType; ///< plot type - bool fUseFitRanges; ///< yes -> use the fit ranges to plot the data, no (default) -> use range information if present - bool fLogX; ///< yes -> x-axis in log-scale, no (default) -> x-axis in lin-scale - bool fLogY; ///< yes -> y-axis in log-scale, no (default) -> y-axis in lin-scale - int fViewPacking; ///< -1 -> use the run packing to generate the view, otherwise is fViewPacking for the binning of ALL runs. - PComplexVector fRuns; ///< list of runs to be plotted - PDoubleVector fTmin; ///< time minimum - PDoubleVector fTmax; ///< time maximum - PDoubleVector fYmin; ///< asymmetry/counts minimum - PDoubleVector fYmax; ///< asymmetry/counts maximum + Int_t fPlotType; ///< plot type + Bool_t fUseFitRanges; ///< yes -> use the fit ranges to plot the data, no (default) -> use range information if present + Bool_t fLogX; ///< yes -> x-axis in log-scale, no (default) -> x-axis in lin-scale + Bool_t fLogY; ///< yes -> y-axis in log-scale, no (default) -> y-axis in lin-scale + Int_t fViewPacking; ///< -1 -> use the run packing to generate the view, otherwise is fViewPacking for the binning of ALL runs. + PComplexVector fRuns; ///< list of runs to be plotted + PDoubleVector fTmin; ///< time minimum + PDoubleVector fTmax; ///< time maximum + PDoubleVector fYmin; ///< asymmetry/counts minimum + PDoubleVector fYmax; ///< asymmetry/counts maximum } PMsrPlotStructure; //------------------------------------------------------------- @@ -326,12 +339,12 @@ typedef vector PMsrPlotList; *

*/ typedef struct { - bool fValid; + Bool_t fValid; PMsrLines fStatLines; TString fDate; ///< string holding fitting date and time - bool fChisq; ///< flag telling if min = chi2 or min = max.likelyhood - double fMin; ///< chi2 or max. likelyhood - unsigned int fNdf; ///< number of degrees of freedom + Bool_t fChisq; ///< flag telling if min = chi2 or min = max.likelyhood + Double_t fMin; ///< chi2 or max. likelyhood + UInt_t fNdf; ///< number of degrees of freedom } PMsrStatisticStructure; #endif // _PMUSR_H_ diff --git a/src/include/PRunDataHandler.h b/src/include/PRunDataHandler.h index 0b93b911..98f68cc9 100644 --- a/src/include/PRunDataHandler.h +++ b/src/include/PRunDataHandler.h @@ -47,34 +47,34 @@ class PRunDataHandler PRunDataHandler(PMsrHandler *msrInfo, const PStringVector dataPath); virtual ~PRunDataHandler(); - virtual bool IsAllDataAvailable() const { return fAllDataAvailable; } + virtual Bool_t IsAllDataAvailable() const { return fAllDataAvailable; } virtual PRawRunData* GetRunData(const TString &runName); private: PMsrHandler *fMsrInfo; PStringVector fDataPath; - bool fAllDataAvailable; ///< flag indicating if all data sets could be read + Bool_t fAllDataAvailable; ///< flag indicating if all data sets could be read TString fRunName; ///< current run name TString fRunPathName; ///< current path file name PRawRunDataList fData; ///< keeping all the raw data - virtual bool ReadFile(); - virtual bool FileAlreadyRead(TString runName); - virtual bool FileExistsCheck(PMsrRunStructure &runInfo, const unsigned int idx); - virtual bool ReadRootFile(bool notPostPileup); - virtual bool ReadNexusFile(); - virtual bool ReadWkmFile(); - virtual bool ReadPsiBinFile(); - virtual bool ReadMudFile(); - virtual bool ReadAsciiFile(); - virtual bool ReadDBFile(); + virtual Bool_t ReadFile(); + virtual Bool_t FileAlreadyRead(TString runName); + virtual Bool_t FileExistsCheck(PMsrRunStructure &runInfo, const UInt_t idx); + virtual Bool_t ReadRootFile(Bool_t notPostPileup); + virtual Bool_t ReadNexusFile(); + virtual Bool_t ReadWkmFile(); + virtual Bool_t ReadPsiBinFile(); + virtual Bool_t ReadMudFile(); + virtual Bool_t ReadAsciiFile(); + virtual Bool_t ReadDBFile(); - virtual bool StripWhitespace(TString &str); - virtual bool IsWhitespace(const char *str); - virtual double ToDouble(TString &str, bool &ok); - virtual int ToInt(TString &str, bool &ok); - virtual int GetDataTagIndex(TString &str, PStringVector &fLabels); + virtual Bool_t StripWhitespace(TString &str); + virtual Bool_t IsWhitespace(const char *str); + virtual Double_t ToDouble(TString &str, Bool_t &ok); + virtual Int_t ToInt(TString &str, Bool_t &ok); + virtual Int_t GetDataTagIndex(TString &str, PStringVector &fLabels); }; #endif // _PRUNDATAHANDLER_H_ diff --git a/src/tests/mud/mud_test.c b/src/tests/mud/mud_test.c index d4608e46..d43f5816 100644 --- a/src/tests/mud/mud_test.c +++ b/src/tests/mud/mud_test.c @@ -233,6 +233,7 @@ int main(int argc, char *argv[]) MUD_closeRead( fh ); + free(pData); return 1; }