musrfit  1.9.2
PMsr2Data Class Reference

#include <PMsr2Data.h>

Public Member Functions

 PMsr2Data (const std::string &)
 
 ~PMsr2Data ()
 
int SetRunNumbers (unsigned int)
 
int SetRunNumbers (unsigned int, unsigned int)
 
int SetRunNumbers (const std::string &)
 
int SetRunNumbers (const std::vector< unsigned int > &)
 
unsigned int GetPresentRun () const
 
int DetermineRunNumberDigits (unsigned int, bool) const
 
int CheckRunNumbersInRange () const
 
int ParseXmlStartupFile ()
 
int ReadMsrFile (const std::string &) const
 
int ReadRunDataFile ()
 
bool PrepareNewInputFile (unsigned int, bool) const
 
bool PrepareGlobalInputFile (unsigned int, const std::string &, unsigned int) const
 
int WriteOutput (const std::string &, const std::vector< unsigned int > &, bool, unsigned int, bool global=false, unsigned int counter=0) const
 

Private Member Functions

bool PrepareNewSortedInputFile (unsigned int) const
 
PMsrHandlerGetSingleRunMsrFile () const
 
void WriteValue (std::fstream &outFile, const double &value, const unsigned int &width) const
 
void WriteValue (std::fstream &outFile, const double &value, const double &errValue, const unsigned int &width, const bool &db) const
 
int GetFirstSignificantDigit (const double &value) const
 
bool InParameterList (const unsigned int &paramValue, const std::vector< unsigned int > &) const
 

Private Attributes

std::string fFileExtension
 
std::vector< unsigned int > fRunVector
 
std::vector< unsigned int >::const_iterator fRunVectorIter
 
bool fRunListFile
 
std::vector< std::string > fIndVar
 
std::unique_ptr< std::ifstream > fRunListFileStream
 
std::unique_ptr< TSAXParser > fSaxParser
 
std::unique_ptr< PStartupHandlerfStartupHandler
 
std::unique_ptr< PRunDataHandlerfDataHandler
 
std::unique_ptr< PMsrHandlerfMsrHandler
 
unsigned int fNumGlobalParam
 
unsigned int fNumSpecParam
 
unsigned int fNumTempRunBlocks
 
unsigned int fRunNumberDigits
 
bool fHeaderWritten
 

Detailed Description

Class providing the necessary utilities for msr2data: generate new msr-files from a template, collect fit parameters from msr-files and write them to DB or plain ASCII files

Definition at line 51 of file PMsr2Data.h.

Constructor & Destructor Documentation

◆ PMsr2Data()

PMsr2Data::PMsr2Data ( const std::string &  ext)

Constructor

Parameters
extextension/suffix of the msr-files to be processed

Definition at line 58 of file PMsr2Data.cpp.

References fDataHandler, fMsrHandler, fRunVector, fRunVectorIter, fSaxParser, and fStartupHandler.

◆ ~PMsr2Data()

PMsr2Data::~PMsr2Data ( )

Destructor

Definition at line 72 of file PMsr2Data.cpp.

References fIndVar, fRunVector, and fRunVectorIter.

Member Function Documentation

◆ CheckRunNumbersInRange()

int PMsr2Data::CheckRunNumbersInRange ( ) const

Checks if all given run numbers are in the range covered by the number of digits used in the data file name

return:

  • 0 if everything is fine
  • -1 if a given run number is too big

Definition at line 185 of file PMsr2Data.cpp.

References fRunNumberDigits, and fRunVector.

◆ DetermineRunNumberDigits()

int PMsr2Data::DetermineRunNumberDigits ( unsigned int  runNo,
bool  normalMode 
) const

Determines the number of digits used for the run number in the data file name from the first msr-file that is processed If the specified run number is the first one of the list of runs and it cannot be opened, then the rest of the given runs is checked until an existing msr-file is found

return:

  • 0 if the number has been determined and set successfully
  • -1 in case the msr-file cannot be read
  • -2 if the msr-file-number does not match the data-file-number
  • -3 if the msr-file does not contain a RUN block
Parameters
runNorun number of an msr-file
normalModefalse for global mode

Definition at line 95 of file PMsr2Data.cpp.

References fFileExtension, fRunNumberDigits, fRunVector, and fRunVectorIter.

◆ GetFirstSignificantDigit()

int PMsr2Data::GetFirstSignificantDigit ( const double &  value) const
private

Determines the first significant digit of the provided number value. E.g. for value=2.03 it will return 1, for value=0.00023 it will return 4, etc.

Parameters
valuefor which the first significant digit needs to be determined.
Returns
first significant digit of the provided number value

Definition at line 2496 of file PMsr2Data.cpp.

Referenced by WriteValue().

◆ GetPresentRun()

unsigned int PMsr2Data::GetPresentRun ( ) const

Determines the current run number

return:

  • current run number
  • 0 if all runs have been processed already

Definition at line 209 of file PMsr2Data.cpp.

References fRunVector, and fRunVectorIter.

◆ GetSingleRunMsrFile()

PMsrHandler * PMsr2Data::GetSingleRunMsrFile ( ) const
private

Read in the single run msr-file corresponding to the position in the run-vector into a secondary msr-handler different from the class member

return:

  • pointer to the secondary msr-handler or 0 in case of an error

Definition at line 432 of file PMsr2Data.cpp.

References fFileExtension, fRunVectorIter, PMUSR_MSR_FILE_NOT_FOUND, PMUSR_MSR_SYNTAX_ERROR, PMUSR_SUCCESS, PMsrHandler::ReadMsrFile(), and status.

Referenced by PrepareGlobalInputFile().

◆ InParameterList()

bool PMsr2Data::InParameterList ( const unsigned int &  paramValue,
const std::vector< unsigned int > &  paramList 
) const
private

Checks paramValue is found in the paramList. If paramList is empty, ALL paramValues will be accepted, i.e. return true.

Parameters
paramValueparamValue to be checked
paramListparameter list
Returns
true if the paramValue if found in paramList, or true if paramList is empty.

Definition at line 2526 of file PMsr2Data.cpp.

Referenced by WriteOutput().

◆ ParseXmlStartupFile()

int PMsr2Data::ParseXmlStartupFile ( )

Parse the musrfit startup xml file

return:

  • 0 if everything went fine
  • return value of the parseXmlFile function otherwise

Definition at line 374 of file PMsr2Data.cpp.

References fSaxParser, fStartupHandler, parseXmlFile(), startup_path_name, and status.

◆ PrepareGlobalInputFile()

bool PMsr2Data::PrepareGlobalInputFile ( unsigned int  tempRun,
const std::string &  msrOutFile,
unsigned int  globalPlus 
) const

Generate a new global msr-file from a template

return:

  • true if everything is OK
  • false otherwise
Parameters
tempRuntemplate run number
msrOutFilename of the global msr-file to be written
globalPlustag of the global mode to be used:
  • 0: simple global mode with the same template starting parameters for each run
  • 1: global mode including single run fits and data extraction for the global msr-file (same template for all runs)
  • 2: global mode including single run fits and data extraction for the global msr-file (successive template generation)

Definition at line 633 of file PMsr2Data.cpp.

References compare_parameters(), fFileExtension, fMsrHandler, fNumGlobalParam, fNumSpecParam, fNumTempRunBlocks, fRunNumberDigits, fRunVector, fRunVectorIter, PMsrHandler::GetMsrParamList(), GetSingleRunMsrFile(), MSR_PARAM_FUN_OFFSET, PMUSR_SUCCESS, PrepareNewInputFile(), PrepareNewSortedInputFile(), ReadMsrFile(), and status.

◆ PrepareNewInputFile()

bool PMsr2Data::PrepareNewInputFile ( unsigned int  tempRun,
bool  calledFromGlobalMode 
) const

Generate a new single-run msr file from a template

return:

  • true if everything is OK
  • false otherwise
Parameters
tempRuntemplate run number
calledFromGlobalModetag specifying if the routine is called as part of the global msr-file generation

Definition at line 494 of file PMsr2Data.cpp.

References fFileExtension, fRunNumberDigits, fRunVector, and fRunVectorIter.

Referenced by PrepareGlobalInputFile().

◆ PrepareNewSortedInputFile()

bool PMsr2Data::PrepareNewSortedInputFile ( unsigned int  tempRun) const
private

Generate a new msr-file for a single run in which the parameters are sorted for a global fit An internal sorted msr-file data structure has to be present.

return:

  • true if everything is OK
  • false otherwise
Parameters
tempRuntemplate run number

Definition at line 1516 of file PMsr2Data.cpp.

References fFileExtension, fMsrHandler, fNumGlobalParam, fNumTempRunBlocks, fRunNumberDigits, fRunVectorIter, PMUSR_SUCCESS, and status.

Referenced by PrepareGlobalInputFile().

◆ ReadMsrFile()

int PMsr2Data::ReadMsrFile ( const std::string &  infile) const

Read in a msr-file into the default structure

return:

  • PMUSR_SUCCESS if everything is OK
  • return value of the ReadMsrFile-method otherwise
Parameters
infilename of the msr-file to be read

Definition at line 402 of file PMsr2Data.cpp.

References fMsrHandler, PMUSR_MSR_FILE_NOT_FOUND, PMUSR_MSR_SYNTAX_ERROR, PMUSR_SUCCESS, and status.

Referenced by PrepareGlobalInputFile().

◆ ReadRunDataFile()

int PMsr2Data::ReadRunDataFile ( )

Read in a run data-file

return:

  • 0 if everything is OK
  • 1 otherwise

Definition at line 465 of file PMsr2Data.cpp.

References fDataHandler, fMsrHandler, and fStartupHandler.

◆ SetRunNumbers() [1/4]

int PMsr2Data::SetRunNumbers ( unsigned int  runNo)

Initialization of the internal list of runs using a single run number

return:

  • 0 if the run number is valid
  • 1 otherwise
Parameters
runNorun number

Definition at line 227 of file PMsr2Data.cpp.

References fRunVector, and fRunVectorIter.

◆ SetRunNumbers() [2/4]

int PMsr2Data::SetRunNumbers ( unsigned int  runNoStart,
unsigned int  runNoEnd 
)

Initialization of the internal list of runs using first and last run numbers

return:

  • 0 if the run numbers are valid
  • 1 otherwise
Parameters
runNoStartfirst run number
runNoEndlast run number

Definition at line 250 of file PMsr2Data.cpp.

References fRunVector, and fRunVectorIter.

◆ SetRunNumbers() [3/4]

int PMsr2Data::SetRunNumbers ( const std::string &  runListFile)

Initialization of the internal list of runs using a run list file

return:

  • -1 if the run list file cannot be opened
  • 0 if all run numbers are valid
  • 1 otherwise
Parameters
runListFilename of run list file

Definition at line 306 of file PMsr2Data.cpp.

References fIndVar, fRunListFile, fRunListFileStream, fRunVector, and fRunVectorIter.

◆ SetRunNumbers() [4/4]

int PMsr2Data::SetRunNumbers ( const std::vector< unsigned int > &  runListVector)

Initialization of the internal list of runs using explicitly specified run numbers

return:

  • -1 if the vector is empty
  • 0 if all run numbers are valid
  • 1 otherwise
Parameters
runListVectorvector containing the run numbers to be processed

Definition at line 279 of file PMsr2Data.cpp.

References fRunVector, and fRunVectorIter.

◆ WriteOutput()

int PMsr2Data::WriteOutput ( const std::string &  outfile,
const std::vector< unsigned int > &  paramList,
bool  db,
unsigned int  withHeader,
bool  global = false,
unsigned int  counter = 0 
) const

Append fit parameters of a msr file to the DB or ASCII file

return:

  • PMUSR_SUCCESS if everything is OK
  • -1 in case of a fatal error
  • -2 if a fit has not converged (and the data is not appended to the output file)
Parameters
outfilename of the DB/ASCII output file
paramListparameter list which shall be written to the output file
dbDB or plain ASCII output
withHeaderwrite output file header or not
globalglobal mode or not
countercounter used within the global mode to determine how many runs have been processed already

Definition at line 1622 of file PMsr2Data.cpp.

References fDataHandler, fHeaderWritten, fIndVar, fMsrHandler, fNumGlobalParam, fNumSpecParam, fNumTempRunBlocks, fRunListFile, fRunListFileStream, fRunNumberDigits, fRunVector, fRunVectorIter, PRawRunData::GetEnergy(), PRawRunData::GetField(), PRawRunData::GetMuonSpinAngle(), PRawRunData::GetNoOfTemperatures(), PRawRunData::GetRingAnode(), PRawRunData::GetTemperature(), PRawRunData::GetTempError(), PRawRunData::GetTransport(), InParameterList(), PMUSR_SUCCESS, PMUSR_UNDEFINED, and WriteValue().

◆ WriteValue() [1/2]

void PMsr2Data::WriteValue ( std::fstream &  outFile,
const double &  value,
const unsigned int &  width 
) const
private

Write formatted output to column-formatted ASCII output file

Parameters
outFileoutput file stream to the ASCII file
valuenumber to be written to the ASCII file
widthcolumn width of the ASCII file

Definition at line 2443 of file PMsr2Data.cpp.

Referenced by WriteOutput().

◆ WriteValue() [2/2]

void PMsr2Data::WriteValue ( std::fstream &  outFile,
const double &  value,
const double &  errValue,
const unsigned int &  width,
const bool &  db 
) const
private

Write a value to the outFile stream. The string length is determined on its error. E.g. 17.0023 +- 0.0018, or 73212.081 +- 0.033, etc.

Parameters
outFileoutput stream object
valueto be written to stream outFile
errValueerror of the value. needed to determine the needed accuracy
widthfield width for outFile for formatted output
dbtrue for db-file output, false for dat-file output. Needed to have at least on space between numbers for dat-file output

Definition at line 2463 of file PMsr2Data.cpp.

References GetFirstSignificantDigit().

Member Data Documentation

◆ fDataHandler

std::unique_ptr<PRunDataHandler> PMsr2Data::fDataHandler
mutableprivate

Definition at line 92 of file PMsr2Data.h.

Referenced by PMsr2Data(), ReadRunDataFile(), and WriteOutput().

◆ fFileExtension

std::string PMsr2Data::fFileExtension
private

◆ fHeaderWritten

bool PMsr2Data::fHeaderWritten
mutableprivate

Definition at line 98 of file PMsr2Data.h.

Referenced by WriteOutput().

◆ fIndVar

std::vector<std::string> PMsr2Data::fIndVar
private

Definition at line 88 of file PMsr2Data.h.

Referenced by SetRunNumbers(), WriteOutput(), and ~PMsr2Data().

◆ fMsrHandler

std::unique_ptr<PMsrHandler> PMsr2Data::fMsrHandler
mutableprivate

◆ fNumGlobalParam

unsigned int PMsr2Data::fNumGlobalParam
mutableprivate

Definition at line 94 of file PMsr2Data.h.

Referenced by PrepareGlobalInputFile(), PrepareNewSortedInputFile(), and WriteOutput().

◆ fNumSpecParam

unsigned int PMsr2Data::fNumSpecParam
mutableprivate

Definition at line 95 of file PMsr2Data.h.

Referenced by PrepareGlobalInputFile(), and WriteOutput().

◆ fNumTempRunBlocks

unsigned int PMsr2Data::fNumTempRunBlocks
mutableprivate

Definition at line 96 of file PMsr2Data.h.

Referenced by PrepareGlobalInputFile(), PrepareNewSortedInputFile(), and WriteOutput().

◆ fRunListFile

bool PMsr2Data::fRunListFile
private

Definition at line 87 of file PMsr2Data.h.

Referenced by SetRunNumbers(), and WriteOutput().

◆ fRunListFileStream

std::unique_ptr<std::ifstream> PMsr2Data::fRunListFileStream
private

Definition at line 89 of file PMsr2Data.h.

Referenced by SetRunNumbers(), and WriteOutput().

◆ fRunNumberDigits

unsigned int PMsr2Data::fRunNumberDigits
mutableprivate

◆ fRunVector

std::vector<unsigned int> PMsr2Data::fRunVector
private

◆ fRunVectorIter

std::vector<unsigned int>::const_iterator PMsr2Data::fRunVectorIter
mutableprivate

◆ fSaxParser

std::unique_ptr<TSAXParser> PMsr2Data::fSaxParser
private

Definition at line 90 of file PMsr2Data.h.

Referenced by ParseXmlStartupFile(), and PMsr2Data().

◆ fStartupHandler

std::unique_ptr<PStartupHandler> PMsr2Data::fStartupHandler
private

Definition at line 91 of file PMsr2Data.h.

Referenced by ParseXmlStartupFile(), PMsr2Data(), and ReadRunDataFile().


The documentation for this class was generated from the following files: