From fce17b8385fadcc7c9d0588c481d51216d70f886 Mon Sep 17 00:00:00 2001 From: nemu Date: Fri, 16 Sep 2011 10:20:00 +0000 Subject: [PATCH] complete new concept for PSI-ROOT (XML validation) --- src/tests/PsiRoot/Makefile | 3 +- src/tests/PsiRoot/Makefile.TPsiRunHeader | 8 + src/tests/PsiRoot/TPsiRunHeader.cpp | 2503 ++++++++-------------- src/tests/PsiRoot/TPsiRunHeader.h | 228 +- src/tests/PsiRoot/TPsiRunHeaderLinkDef.h | 3 +- src/tests/PsiRoot/psi_root.xml | 85 + src/tests/PsiRoot/psi_runHeader_test.cpp | 172 +- 7 files changed, 1158 insertions(+), 1844 deletions(-) create mode 100644 src/tests/PsiRoot/psi_root.xml diff --git a/src/tests/PsiRoot/Makefile b/src/tests/PsiRoot/Makefile index fe0dc482..a58f77ba 100644 --- a/src/tests/PsiRoot/Makefile +++ b/src/tests/PsiRoot/Makefile @@ -75,8 +75,7 @@ all: $(EXEC) $(EXEC): $(OBJS) @echo "---> Building $(EXEC) ..." - /bin/rm -f $(SHLIB) - $(LD) $(OBJS) -o $(EXEC) $(PSILIBS) $(GLIBS) + $(LD) $(OBJS) -o $(EXEC) $(GLIBS) $(PSILIBS) @echo "done" # clean up: remove all object file (and core files) diff --git a/src/tests/PsiRoot/Makefile.TPsiRunHeader b/src/tests/PsiRoot/Makefile.TPsiRunHeader index 067e7f14..9307f4a2 100644 --- a/src/tests/PsiRoot/Makefile.TPsiRunHeader +++ b/src/tests/PsiRoot/Makefile.TPsiRunHeader @@ -89,6 +89,10 @@ ifeq ($(ARCH),linux) cp -pv $(MYLIBS)/$(TLRHSO) $(ROOTSYS)/lib cp -pv $(MYINCLUDES)/$(TNAME).h $(ROOTSYS)/include endif +ifeq ($(ARCH),linuxx8664gcc) + cp -pv $(MYLIBS)/$(TLRHSO) $(ROOTSYS)/lib + cp -pv $(MYINCLUDES)/$(TNAME).h $(ROOTSYS)/include +endif ifeq ($(ARCH),win32gcc) cp -pv $(MYLIBS)/$(TLRHSO) $(ROOTSYS)/bin ln -sf $(ROOTSYS)/bin/$(TLRHSO) $(ROOTSYS)/lib/$(TLRHSO) @@ -100,6 +104,10 @@ ifeq ($(ARCH),linux) rm $(ROOTSYS)/lib/$(TLRHSO) rm $(ROOTSYS)/include/$(TNAME).h endif +ifeq ($(ARCH),linuxx8664gcc) + rm $(ROOTSYS)/lib/$(TLRHSO) + rm $(ROOTSYS)/include/$(TNAME).h +endif ifeq ($(ARCH),win32gcc) rm $(ROOTSYS)/lib/$(TLRHSO) rm $(ROOTSYS)/include/$(TNAME).h diff --git a/src/tests/PsiRoot/TPsiRunHeader.cpp b/src/tests/PsiRoot/TPsiRunHeader.cpp index a6da4032..9ec7113b 100644 --- a/src/tests/PsiRoot/TPsiRunHeader.cpp +++ b/src/tests/PsiRoot/TPsiRunHeader.cpp @@ -29,6 +29,7 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +#include #include #include #include @@ -41,6 +42,9 @@ using namespace std; #include #include #include +#include +#include +#include ClassImp(TPsiRunProperty) @@ -52,13 +56,34 @@ ClassImp(TPsiRunProperty) */ TPsiRunProperty::TPsiRunProperty() { - fLabel = "n/a"; - fDemand = 0.0; - fValue = 0.0; - fError = 0.0; - fUnit = "n/a"; + fLabel = "n/a"; + fDemand = PRH_UNDEFINED; + fValue = PRH_UNDEFINED; + fError = PRH_UNDEFINED; + fUnit = "n/a"; fDescription = "n/a"; - fPath = "n/a"; +} + +//-------------------------------------------------------------------------- +// Constructor +//-------------------------------------------------------------------------- +/** + *

Constructor. + * + * \param name + * \param demand + * \param value + * \param error + * \param unit + * \param description + */ +TPsiRunProperty::TPsiRunProperty(TString label, Double_t demand, Double_t value, Double_t error, TString unit, TString description) : + fLabel(label), fDemand(demand), fValue(value), fError(error), fUnit(unit) +{ + if (description.IsWhitespace()) + fDescription = "n/a"; + else + fDescription = description; } //-------------------------------------------------------------------------- @@ -69,22 +94,221 @@ TPsiRunProperty::TPsiRunProperty() * * \param name * \param value - * \param error * \param unit */ -TPsiRunProperty::TPsiRunProperty(TString &label, Double_t demand, Double_t value, Double_t error, TString &unit, TString &description, TString &path) : - fLabel(label), fDemand(demand), fValue(value), fError(error), fUnit(unit) +TPsiRunProperty::TPsiRunProperty(TString label, Double_t value, TString unit) : + fLabel(label), fValue(value), fUnit(unit) { - if (description.IsWhitespace()) - fDescription = "n/a"; - else - fDescription = description; - - fPath = path; - if (path.IsWhitespace()) - fPath = "/"; + fDemand = PRH_UNDEFINED; + fError = PRH_UNDEFINED; + fDescription = "n/a"; } +//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +ClassImp(TPsiStartupHandler) + +//-------------------------------------------------------------------------- +// Constructor +//-------------------------------------------------------------------------- +/** + *

Constructor. + */ +TPsiStartupHandler::TPsiStartupHandler() +{ + fKey = eEmpty; +} + +//-------------------------------------------------------------------------- +// Destructor +//-------------------------------------------------------------------------- +/** + *

Destructor. + */ +TPsiStartupHandler::~TPsiStartupHandler() +{ + fFolder.clear(); + fEntry.clear(); +} + +//-------------------------------------------------------------------------- +// OnStartDocument +//-------------------------------------------------------------------------- +/** + *

Called on start of the XML file reading. Initializes all necessary variables. + */ +void TPsiStartupHandler::OnStartDocument() +{ + fKey = eEmpty; + fGroupKey = eEmpty; +} + +//-------------------------------------------------------------------------- +// OnEndDocument +//-------------------------------------------------------------------------- +/** + *

Called on end of XML file reading. + */ +void TPsiStartupHandler::OnEndDocument() +{ + +} + +//-------------------------------------------------------------------------- +// OnStartElement +//-------------------------------------------------------------------------- +/** + *

Called when a XML start element is found. Filters out the needed elements + * and sets a proper key. + * + * \param str XML element name + * \param attributes not used + */ +void TPsiStartupHandler::OnStartElement(const Char_t *str, const TList *attributes) +{ + if (!strcmp(str, "folder")) { + fGroupKey = eFolder; + } else if (!strcmp(str, "entry")) { + fGroupKey = eEntry; + } else if (!strcmp(str, "name")) { + fKey = eName; + } else if (!strcmp(str, "type")) { + fKey = eType; + } +} + +//-------------------------------------------------------------------------- +// OnEndElement +//-------------------------------------------------------------------------- +/** + *

Called when a XML end element is found. Resets the handler key. + * + * \param str not used + */ +void TPsiStartupHandler::OnEndElement(const Char_t *str) +{ + if (!strcmp(str, "folder") || !strcmp(str, "entry")) + fGroupKey = eEmpty; + fKey = eEmpty; +} + +//-------------------------------------------------------------------------- +// OnCharacters +//-------------------------------------------------------------------------- +/** + *

Content of a given XML element. Filters out the data and feeds them to + * the internal variables. + * + * \param str XML element string + */ +void TPsiStartupHandler::OnCharacters(const Char_t *str) +{ + static TPsiEntry entry; + static Int_t code = 0; + + switch (fGroupKey) { + case eFolder: + switch (fKey) { + case eName: + fFolder.push_back(str); + break; + default: + break; + } + break; + case eEntry: + switch (fKey) { + case eName: + entry.SetPathName(str); + code |= 1; + break; + case eType: + entry.SetType(str); + code |= 2; + break; + default: + break; + } + if (code == 3) { + fEntry.push_back(entry); + code = 0; + } + break; + default: + break; + } +} + +//-------------------------------------------------------------------------- +// OnComment +//-------------------------------------------------------------------------- +/** + *

Called when a XML comment is found. Not used. + * + * \param str not used. + */ +void TPsiStartupHandler::OnComment(const Char_t *str) +{ + // nothing to be done for now +} + +//-------------------------------------------------------------------------- +// OnWarning +//-------------------------------------------------------------------------- +/** + *

Called when the XML parser emits a warning. + * + * \param str warning string + */ +void TPsiStartupHandler::OnWarning(const Char_t *str) +{ + cerr << endl << ">> TPsiStartupHandler **WARNING** " << str; + cerr << endl; +} + +//-------------------------------------------------------------------------- +// OnError +//-------------------------------------------------------------------------- +/** + *

Called when the XML parser emits an error. + * + * \param str error string + */ +void TPsiStartupHandler::OnError(const Char_t *str) +{ + cerr << endl << ">> TPsiStartupHandler **ERROR** " << str; + cerr << endl; +} + +//-------------------------------------------------------------------------- +// OnFatalError +//-------------------------------------------------------------------------- +/** + *

Called when the XML parser emits a fatal error. + * + * \param str fatal error string + */ +void TPsiStartupHandler::OnFatalError(const Char_t *str) +{ + cerr << endl << ">> TPsiStartupHandler **FATAL ERROR** " << str; + cerr << endl; +} + +//-------------------------------------------------------------------------- +// OnCdataBlock +//-------------------------------------------------------------------------- +/** + *

Not used. + * + * \param str not used + * \param len not used + */ +void TPsiStartupHandler::OnCdataBlock(const Char_t *str, Int_t len) +{ + // nothing to be done for now +} + + //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ClassImp(TPsiRunHeader) @@ -97,33 +321,28 @@ ClassImp(TPsiRunHeader) */ TPsiRunHeader::TPsiRunHeader() { - fVersion = TString("$Id$"); - fGenerator = TString("n/a"); - fFileName = TString("n/a"); - fRunTitle = TString("n/a"); - fRunNumber = -1; - fStartTime = TDatime("1995-01-01 00:00:00"); - fStopTime = TDatime("1995-01-01 00:00:00"); - fLaboratory = TString("n/a"); - fArea = TString("n/a"); - fInstrument = TString("n/a"); - fMuonSpecies = TString("n/a"); - fSetup = TString("n/a"); - fComment = TString("n/a"); - fSample = TString("n/a"); - fOrientation = TString("n/a"); - fSampleCryo = TString("n/a"); - fSampleCryoInsert = TString("n/a"); - fMagnetName = TString("n/a"); - fNoOfHistos = -1; - fHistoLength = -1; - fTimeResolution = 0.0; + TSAXParser *saxParser = new TSAXParser(); + TPsiStartupHandler *startupHandler = new TPsiStartupHandler(); - fHeader.Expand(0); // init to size 0 - fSampleEnv.Expand(0); // init to size 0 - fMagFieldEnv.Expand(0); // init to size 0 - fBeamline.Expand(0); // init to size 0 - fScalers.Expand(0); // init to size 0 + saxParser->ConnectToHandler("TPsiStartupHandler", startupHandler); + Int_t status = saxParser->ParseFile("./psi_root.xml"); + + if (status) { // error + // not clear what to do yet ... + } else { + fFolder = startupHandler->GetFolders(); + fEntry = startupHandler->GetEntries(); + } + + if (startupHandler) { + delete startupHandler; + startupHandler = 0; + } + + if (saxParser) { + delete saxParser; + saxParser = 0; + } } //-------------------------------------------------------------------------- @@ -134,18 +353,14 @@ TPsiRunHeader::TPsiRunHeader() */ TPsiRunHeader::~TPsiRunHeader() { - fHistoName.clear(); - fTimeZeroBin.clear(); - fFirstGoodBin.clear(); - fLastGoodBin.clear(); - fRedGreenOffset.clear(); - fRedGreenDescription.clear(); - fProperties.clear(); - fHeader.Delete(); - fSampleEnv.Delete(); - fMagFieldEnv.Delete(); - fBeamline.Delete(); - fScalers.Delete(); + fStringObj.clear(); + fIntObj.clear(); + fPsiRunPropertyObj.clear(); + fStringVectorObj.clear(); + fIntVectorObj.clear(); + + fFolder.clear(); + fEntry.clear(); } //-------------------------------------------------------------------------- @@ -163,1566 +378,667 @@ TPsiRunHeader::~TPsiRunHeader() */ Bool_t TPsiRunHeader::IsValid(Bool_t strict) { - TString startTime = TString(fStartTime.AsSQLString()); - TString stopTime = TString(fStopTime.AsSQLString()); + Bool_t result = true; + Int_t count = 0; - if (strict) { - if (!fGenerator.CompareTo("n/a", TString::kIgnoreCase)) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): 'Generator' not set." << endl; - return false; - } else if (!fFileName.CompareTo("n/a", TString::kIgnoreCase)) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): 'File Name' not set." << endl; - return false; - } else if (!fRunTitle.CompareTo("n/a", TString::kIgnoreCase)) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): 'Run Title' not set." << endl; - return false; - } else if (fRunNumber == -1) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): 'Run Number' not set." << endl; - return false; - } else if (!startTime.CompareTo("1995-01-01 00:00:00", TString::kIgnoreCase)) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): 'Run Start Times' not set." << endl; - return false; - } else if (!stopTime.CompareTo("1995-01-01 00:00:00", TString::kIgnoreCase)) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): 'Run Stop Times' not set." << endl; - return false; - } else if (!fLaboratory.CompareTo("n/a", TString::kIgnoreCase)) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): 'Laboratory' not set." << endl; - return false; - } else if (!fArea.CompareTo("n/a", TString::kIgnoreCase)) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): 'Area' not set." << endl; - return false; - } else if (!fInstrument.CompareTo("n/a", TString::kIgnoreCase)) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): 'Instrument' not set." << endl; - return false; - } else if (!fMuonSpecies.CompareTo("n/a", TString::kIgnoreCase)) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): 'Muon Species' not set." << endl; - return false; - } else if (!fSetup.CompareTo("n/a", TString::kIgnoreCase)) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): 'Setup' not set." << endl; - return false; - } else if (!fComment.CompareTo("n/a", TString::kIgnoreCase)) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): 'Comment' not set." << endl; - return false; - } else if (!fSample.CompareTo("n/a", TString::kIgnoreCase)) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): 'Sample' not set." << endl; - return false; - } else if (!fOrientation.CompareTo("n/a", TString::kIgnoreCase)) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): 'SampleEnv/Orientation' not set." << endl; - return false; - } else if (!fSampleCryo.CompareTo("n/a", TString::kIgnoreCase)) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): 'SampleEnv/Cryo' not set." << endl; - return false; - } else if (!fSampleCryoInsert.CompareTo("n/a", TString::kIgnoreCase)) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): 'SampleEnv/Insert' not set." << endl; - return false; - } else if (!fMagnetName.CompareTo("n/a", TString::kIgnoreCase)) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): 'MagFieldEnv/Name' not set." << endl; - return false; - } else if (fNoOfHistos == -1) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): 'No of Histos' not set." << endl; - return false; - } else if (fHistoName.size() == 0) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): 'Histo Names' not set." << endl; - return false; - } else if ((Int_t)fHistoName.size() != fNoOfHistos) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): No of 'Histo Names' != 'No of Histos'!" << endl; - return false; - } else if (fHistoLength == -1) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): 'Histo Length' not set." << endl; - return false; - } else if (fTimeResolution == 0.0) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): 'Time Resolution' not set." << endl; - return false; - } else if (fTimeZeroBin.size() == 0) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): 'Time Zero Bin' not set." << endl; - return false; - } else if ((Int_t)fTimeZeroBin.size() != fNoOfHistos) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): No of 'Time Zero Bin' != 'No Of Histos'." << endl; - return false; - } else if (fFirstGoodBin.size() == 0) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): 'First Good Bin' not set." << endl; - return false; - } else if ((Int_t)fFirstGoodBin.size() != fNoOfHistos) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): No of 'First Good Bin' != 'No Of Histos'." << endl; - return false; - } else if (fLastGoodBin.size() == 0) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): 'Last Good Bin' not set." << endl; - return false; - } else if ((Int_t)fLastGoodBin.size() != fNoOfHistos) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): No of 'Last Good Bin' != 'No Of Histos'." << endl; - return false; - } else if (fRedGreenOffset.size() != fRedGreenDescription.size()) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): No of 'Red/Green offsets' != 'Red/Green descriptions'." << endl; - return false; + for (UInt_t i=0; i> **ERROR** found entry: " << fEntry[i].GetPathName() << " should be a 'TString' but is defined as " << fEntry[i].GetType().Data() << endl; + return false; + } + } } - - // check all the required physical properties - - // check 'Sample Temperature' - if (GetProperty("Muon Beam Momentum") == 0) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): 'Muon Beam Momentum' not set." << endl; - return false; - } else if (GetProperty("Sample Temperature") == 0) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): 'Sample Temperature' not set." << endl; - return false; - } else if (GetProperty("Sample Magnetic Field") == 0) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): 'Sample Magnetic Field' not set." << endl; - return false; - } else if (GetProperty("Current") == 0) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): 'MagFieldEnv/Current' not set." << endl; - return false; + for (UInt_t j=0; j> **ERROR** found entry: " << fEntry[i].GetPathName() << " should be a 'Int_t' but is defined as " << fEntry[i].GetType().Data() << endl; + return false; + } + } } - } else { // not quite so strict - if (!fGenerator.CompareTo("n/a", TString::kIgnoreCase)) { - cerr << endl << ">> **WARNING** TPsiRunHeader::IsValid(): 'Generator' not set." << endl; + for (UInt_t j=0; j> **ERROR** found entry: " << fEntry[i].GetPathName() << " should be a 'TPsiRunProperty' but is defined as " << fEntry[i].GetType().Data() << endl; + return false; + } + } } - if (!fFileName.CompareTo("n/a", TString::kIgnoreCase)) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): 'File Name' not set." << endl; - return false; + for (UInt_t j=0; j> **ERROR** found entry: " << fEntry[i].GetPathName() << " should be a 'TStringVector' but is defined as " << fEntry[i].GetType().Data() << endl; + return false; + } + } } - if (!fRunTitle.CompareTo("n/a", TString::kIgnoreCase)) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): 'Run Title' not set." << endl; - return false; - } - if (fRunNumber == -1) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): 'Run Number' not set." << endl; - return false; - } - if (!startTime.CompareTo("1995-01-01 00:00:00", TString::kIgnoreCase)) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): 'Run Start Times' not set." << endl; - return false; - } - if (!stopTime.CompareTo("1995-01-01 00:00:00", TString::kIgnoreCase)) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): 'Run Stop Times' not set." << endl; - return false; - } - if (!fLaboratory.CompareTo("n/a", TString::kIgnoreCase)) { - cerr << endl << ">> **WARNING** TPsiRunHeader::IsValid(): 'Laboratory' not set." << endl; - } - if (!fArea.CompareTo("n/a", TString::kIgnoreCase)) { - cerr << endl << ">> **WARNING** TPsiRunHeader::IsValid(): 'Area' not set." << endl; - } - if (!fInstrument.CompareTo("n/a", TString::kIgnoreCase)) { - cerr << endl << ">> **WARNING** TPsiRunHeader::IsValid(): 'Instrument' not set." << endl; - } - if (!fMuonSpecies.CompareTo("n/a", TString::kIgnoreCase)) { - cerr << endl << ">> **WARNING** TPsiRunHeader::IsValid(): 'Muon Species' not set." << endl; - } - if (!fSetup.CompareTo("n/a", TString::kIgnoreCase)) { - cerr << endl << ">> **WARNING** TPsiRunHeader::IsValid(): 'Setup' not set." << endl; - } - if (!fComment.CompareTo("n/a", TString::kIgnoreCase)) { - cerr << endl << ">> **WARNING** TPsiRunHeader::IsValid(): 'Comment' not set." << endl; - } - if (!fSample.CompareTo("n/a", TString::kIgnoreCase)) { - cerr << endl << ">> **WARNING** TPsiRunHeader::IsValid(): 'Sample' not set." << endl; - } - if (!fOrientation.CompareTo("n/a", TString::kIgnoreCase)) { - cerr << endl << ">> **WARNING** TPsiRunHeader::IsValid(): 'SampleEnv/Orientation' not set." << endl; - } - if (!fSampleCryo.CompareTo("n/a", TString::kIgnoreCase)) { - cerr << endl << ">> **WARNING** TPsiRunHeader::IsValid(): 'SampleEnv/Cryo' not set." << endl; - } - if (!fSampleCryoInsert.CompareTo("n/a", TString::kIgnoreCase)) { - cerr << endl << ">> **WARNING** TPsiRunHeader::IsValid(): 'SampleEnv/Insert' not set." << endl; - } - if (!fMagnetName.CompareTo("n/a", TString::kIgnoreCase)) { - cerr << endl << ">> **WARNING** TPsiRunHeader::IsValid(): 'MagFieldEnv/Name' not set." << endl; - } - if (fNoOfHistos == -1) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): 'No of Histos' not set." << endl; - return false; - } - if (fHistoName.size() == 0) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): 'Histo Names' not set." << endl; - return false; - } - if ((Int_t)fHistoName.size() != fNoOfHistos) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): No of 'Histo Names' != 'No of Histos'!" << endl; - return false; - } - if (fHistoLength == -1) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): 'Histo Length' not set." << endl; - return false; - } - if (fTimeResolution == 0.0) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): 'Time Resolution' not set." << endl; - return false; - } - if (fTimeZeroBin.size() == 0) { - cerr << endl << ">> **WARNING** TPsiRunHeader::IsValid(): 'Time Zero Bin' not set." << endl; - } - if ((fTimeZeroBin.size() > 0) && ((Int_t)fTimeZeroBin.size() != fNoOfHistos)) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): No of 'Time Zero Bin' != 'No Of Histos'." << endl; - return false; - } - if (fFirstGoodBin.size() == 0) { - cerr << endl << ">> **WARNING** TPsiRunHeader::IsValid(): 'First Good Bin' not set." << endl; - } - if ((fFirstGoodBin.size() > 0) && ((Int_t)fFirstGoodBin.size() != fNoOfHistos)) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): No of 'First Good Bin' != 'No Of Histos'." << endl; - return false; - } - if (fLastGoodBin.size() == 0) { - cerr << endl << ">> **WARNING** TPsiRunHeader::IsValid(): 'Last Good Bin' not set." << endl; - } - if ((fLastGoodBin.size() > 0) && ((Int_t)fLastGoodBin.size() != fNoOfHistos)) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): No of 'Last Good Bin' != 'No Of Histos'." << endl; - return false; - } - if (fRedGreenOffset.size() != fRedGreenDescription.size()) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): No of 'Red/Green offsets' != 'Red/Green descriptions'." << endl; - return false; - } - - // check all the required physical properties - - // check 'Sample Temperature' - if (GetProperty("Muon Beam Momentum") == 0) { - cerr << endl << ">> **WARNING** TPsiRunHeader::IsValid(): 'Muon Beam Momentum' not set." << endl; - } - if (GetProperty("Sample Temperature") == 0) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): 'Sample Temperature' not set." << endl; - return false; - } - if (GetProperty("Sample Magnetic Field") == 0) { - cerr << endl << ">> **ERROR** TPsiRunHeader::IsValid(): 'Sample Magnetic Field' not set." << endl; - return false; - } - if (GetProperty("Current") == 0) { - cerr << endl << ">> **WARNING** TPsiRunHeader::IsValid(): 'MagFieldEnv/Current' not set." << endl; + for (UInt_t j=0; j> **ERROR** found entry: " << fEntry[i].GetPathName() << " should be a 'TIntVector' but is defined as " << fEntry[i].GetType().Data() << endl; + return false; + } + } } } - - return true; -} - - -//-------------------------------------------------------------------------- -// GetHistoName (public) -//-------------------------------------------------------------------------- -/** - *

returns the run duration, i.e. run stop - run start time in seconds. - */ -Int_t TPsiRunHeader::GetRunDuration() const -{ - return fStopTime.Convert() - fStartTime.Convert(); -} - -//-------------------------------------------------------------------------- -// GetHistoName (public) -//-------------------------------------------------------------------------- -/** - *

returns the histogram name at index 'idx'. If 'idx' is out of range, - * an empty string is returned and 'ok' is set to false. - * - * \param idx index for which the histogram name is whished - * \param ok true, if a valid name was found, false otherwise - */ -TString TPsiRunHeader::GetHistoName(UInt_t idx, Bool_t &ok) const -{ - if (idx >= fHistoName.size()) { - ok = false; - return TString(""); - } - - ok = true; - return fHistoName[idx]; -} - -//-------------------------------------------------------------------------- -// GetTimeResolution (public) -//-------------------------------------------------------------------------- -/** - *

returns the time resolution in the requested 'units'. Allowed 'units' - * are: fs, ps, ns, us - * - * \param units in which the time resolution shall be returned. - */ -Double_t TPsiRunHeader::GetTimeResolution(const char *units) const -{ - Double_t factor = 1.0; - TString str(units); - - if (!str.CompareTo("fs", TString::kIgnoreCase)) - factor = 1.0e3; - else if (!str.CompareTo("ps", TString::kIgnoreCase)) - factor = 1.0; - else if (!str.CompareTo("ns", TString::kIgnoreCase)) - factor = 1.0e-3; - else if (!str.CompareTo("us", TString::kIgnoreCase)) - factor = 1.0e-6; - else - factor = 0.0; - - return factor*fTimeResolution; -} - -//-------------------------------------------------------------------------- -// GetTimeZeroBin (public) -//-------------------------------------------------------------------------- -/** - *

returns the time zero bin of index 'idx'. If 'idx' is out of range, - * 'ok' is set to false. - * - * \param idx index for which time zero bin shall be returned - * \param ok flag showing if the returned value is valid - */ -UInt_t TPsiRunHeader::GetTimeZeroBin(UInt_t idx, Bool_t &ok) const -{ - if (idx >= fTimeZeroBin.size()) { - ok = false; - return 0; - } - - ok = true; - return fTimeZeroBin[idx]; -} - -//-------------------------------------------------------------------------- -// GetFirstGoodBin (public) -//-------------------------------------------------------------------------- -/** - *

returns the first good bin of index 'idx'. If 'idx' is out of range, - * 'ok' is set to false. - * - * \param idx index for which first good bin shall be returned - * \param ok flag showing if the returned value is valid - */ -UInt_t TPsiRunHeader::GetFirstGoodBin(UInt_t idx, Bool_t &ok) const -{ - if (idx >= fFirstGoodBin.size()) { - ok = false; - return 0; - } - - ok = true; - return fFirstGoodBin[idx]; -} - -//-------------------------------------------------------------------------- -// GetLastGoodBin (public) -//-------------------------------------------------------------------------- -/** - *

returns the last good bin of index 'idx'. If 'idx' is out of range, - * 'ok' is set to false. - * - * \param idx index for which last good bin shall be returned - * \param ok flag showing if the returned value is valid - */ -UInt_t TPsiRunHeader::GetLastGoodBin(UInt_t idx, Bool_t &ok) const -{ - if (idx >= fLastGoodBin.size()) { - ok = false; - return 0; - } - - ok = true; - return fLastGoodBin[idx]; -} - -//-------------------------------------------------------------------------- -// GetRedGreenHistoOffset (public) -//-------------------------------------------------------------------------- -/** - *

returns the red/green mode histogram offset at index 'idx'. If 'idx' is out of range, - * 'ok' is set to false. - * - * \param idx index for which red/green mode histogram offset shall be returned - * \param ok flag showing if the returned value is valid - */ -UInt_t TPsiRunHeader::GetRedGreenHistoOffset(UInt_t idx, Bool_t &ok) const -{ - if (idx >= fRedGreenOffset.size()) { - ok = false; - return 0; - } - - ok = true; - return fRedGreenOffset[idx]; -} - -//-------------------------------------------------------------------------- -// GetRedGreenHistoDescription (public) -//-------------------------------------------------------------------------- -/** - *

returns the red/green mode description at index 'idx'. If 'idx' is out of range, - * 'ok' is set to false. - * - * \param idx index for which red/green mode description shall be returned - * \param ok flag showing if the returned value is valid - */ -TString TPsiRunHeader::GetRedGreenHistoDescription(UInt_t idx, Bool_t &ok) const -{ - if (idx >= fRedGreenDescription.size()) { - ok = false; - return TString(""); - } - - ok = true; - return fRedGreenDescription[idx]; -} - -//-------------------------------------------------------------------------- -// GetProperty (public) -//-------------------------------------------------------------------------- -/** - *

Searches the property given by 'name'. If it is found, this property is - * returned, otherwise 0 is returned. - * - * \param name property name to look for. - */ -const TPsiRunProperty* TPsiRunHeader::GetProperty(TString name) const -{ - UInt_t i=0; - - for (i=0; i - * - */ -TObjArray* TPsiRunHeader::GetHeader(UInt_t &count) -{ - // make sure that previous header is removed - fHeader.Delete(); - fHeader.Expand(0); - - TString str, fmt; - TObjString *tostr; - const TPsiRunProperty *prop; - UInt_t digit=0, digit_d=0; - - // add version - str.Form("%03d - Version: %s", count++, fVersion.Data()); - tostr = new TObjString(str); - fHeader.AddLast(tostr); - - // add generator - str.Form("%03d - Generator: %s", count++, fGenerator.Data()); - tostr = new TObjString(str); - fHeader.AddLast(tostr); - - // add file name - str.Form("%03d - File Name: %s", count++, fFileName.Data()); - tostr = new TObjString(str); - fHeader.AddLast(tostr); - - // add run title - str.Form("%03d - Run Title: %s", count++, fRunTitle.Data()); - tostr = new TObjString(str); - fHeader.AddLast(tostr); - - // add run number - str.Form("%03d - Run Number: %d", count++, fRunNumber); - tostr = new TObjString(str); - fHeader.AddLast(tostr); - - // add run start time - str.Form("%03d - Run Start Time: %s", count++, fStartTime.AsSQLString()); - tostr = new TObjString(str); - fHeader.AddLast(tostr); - - // add run stop time - str.Form("%03d - Run Stop Time: %s", count++, fStopTime.AsSQLString()); - tostr = new TObjString(str); - fHeader.AddLast(tostr); - - // add run duration - str.Form("%03d - Run Duration: %d sec", count++, GetRunDuration()); - tostr = new TObjString(str); - fHeader.AddLast(tostr); - - // add laboratory - str.Form("%03d - Laboratory: %s", count++, fLaboratory.Data()); - tostr = new TObjString(str); - fHeader.AddLast(tostr); - - // add area - str.Form("%03d - Area: %s", count++, fArea.Data()); - tostr = new TObjString(str); - fHeader.AddLast(tostr); - - // add instrument - str.Form("%03d - Instrument: %s", count++, fInstrument.Data()); - tostr = new TObjString(str); - fHeader.AddLast(tostr); - - // add muon momentum - prop = GetProperty("Muon Beam Momentum"); - if (prop) { - digit = GetDecimalPlace(prop->GetError()); - digit_d = GetLeastSignificantDigit(prop->GetDemand()); - if (prop->GetDescription().CompareTo("n/a")) { - fmt.Form("%%03d - %%s: %%.%dlf +- %%.%dlf %%s; SP: %%.%dlf; %%s", digit, digit, digit_d); - str.Form(fmt.Data(), count++, prop->GetLabel().Data(), prop->GetValue(), prop->GetError(), - prop->GetUnit().Data(), prop->GetDemand(), prop->GetDescription().Data()); + if (count != (Int_t)fEntry.size()) { + if (strict) { + result = false; + cerr << endl << ">> **ERROR** only found " << count << " entries. " << fEntry.size() << " are required!" << endl; } else { - fmt.Form("%%03d - %%s: %%.%dlf +- %%.%dlf %%s; SP: %%.%dlf", digit, digit, digit_d); - str.Form(fmt.Data(), count++, prop->GetLabel().Data(), prop->GetValue(), prop->GetError(), - prop->GetUnit().Data(), prop->GetDemand()); + cerr << endl << ">> **WARNING** only found " << count << " entries. " << fEntry.size() << " are required!" << endl; } - tostr = new TObjString(str); - fHeader.AddLast(tostr); } - // add muon species - str.Form("%03d - Muon Species: %s", count++, fMuonSpecies.Data()); - tostr = new TObjString(str); - fHeader.AddLast(tostr); - - - // add setup - str.Form("%03d - Setup: %s", count++, fSetup.Data()); - tostr = new TObjString(str); - fHeader.AddLast(tostr); - - // add comment - str.Form("%03d - Comment: %s", count++, fComment.Data()); - tostr = new TObjString(str); - fHeader.AddLast(tostr); - - // add sample - str.Form("%03d - Sample: %s", count++, fSample.Data()); - tostr = new TObjString(str); - fHeader.AddLast(tostr); - - // add sample temperature - prop = GetProperty("Sample Temperature"); - if (prop) { - digit = GetDecimalPlace(prop->GetError()); - digit_d = GetLeastSignificantDigit(prop->GetDemand()); - if (prop->GetDescription().CompareTo("n/a")) { - fmt.Form("%%03d - %%s: %%.%dlf +- %%.%dlf %%s; SP: %%.%dlf; %%s", digit, digit, digit_d); - str.Form(fmt.Data(), count++, prop->GetLabel().Data(), prop->GetValue(), prop->GetError(), - prop->GetUnit().Data(), prop->GetDemand(), prop->GetDescription().Data()); - } else { - fmt.Form("%%03d - %%s: %%.%dlf +- %%.%dlf %%s; SP: %%.%dlf", digit, digit, digit_d); - str.Form(fmt.Data(), count++, prop->GetLabel().Data(), prop->GetValue(), prop->GetError(), - prop->GetUnit().Data(), prop->GetDemand()); - } - tostr = new TObjString(str); - fHeader.AddLast(tostr); - } - - // add sample magnetic field - prop = GetProperty("Sample Magnetic Field"); - if (prop) { - digit = GetDecimalPlace(prop->GetError()); - digit_d = GetLeastSignificantDigit(prop->GetDemand()); - if (prop->GetDescription().CompareTo("n/a")) { - fmt.Form("%%03d - %%s: %%.%dlf +- %%.%dlf %%s; SP: %%.%dlf; %%s", digit, digit, digit_d); - str.Form(fmt.Data(), count++, prop->GetLabel().Data(), prop->GetValue(), prop->GetError(), - prop->GetUnit().Data(), prop->GetDemand(), prop->GetDescription().Data()); - } else { - fmt.Form("%%03d - %%s: %%.%dlf +- %%.%dlf %%s; SP: %%.%dlf", digit, digit, digit_d); - str.Form(fmt.Data(), count++, prop->GetLabel().Data(), prop->GetValue(), prop->GetError(), - prop->GetUnit().Data(), prop->GetDemand()); - } - tostr = new TObjString(str); - fHeader.AddLast(tostr); - } - - // add number of histograms - str.Form("%03d - No of Histos: %d", count++, fNoOfHistos); - tostr = new TObjString(str); - fHeader.AddLast(tostr); - - // add histogram names - str.Form("%03d - Histo Names: ", count++); - for (UInt_t i=0; i 0) { - str.Form("%03d - Red/Green offsets: ", count++); - for (UInt_t i=0; i 0) { - str.Form("%03d - Red/Green description: ", count++); - for (UInt_t i=0; i - * - */ -TObjArray* TPsiRunHeader::GetSampleEnv(UInt_t &count) + *

Get PSI-ROOT header information of 'path'. + * + * \param requestedPath of the PSI-ROOT header, e.g. RunInfo + * \param content of the requested PSI-ROOT header. + */ +void TPsiRunHeader::Get(TString requestedPath, TObjArray &content) { - // make sure that previous sample environment info is removed - fSampleEnv.Delete(); - fSampleEnv.Expand(0); + // make sure content is initialized + content.Delete(); + content.Expand(0); - TString str, fmt; + static UInt_t count = 1; + TString str(""), path(""), name(""), fmt(""), tstr(""); TObjString *tostr; - UInt_t digit=0, digit_d=0; - - // add cryo - str.Form("%03d - Cryo: %s", count++, fSampleCryo.Data()); - tostr = new TObjString(str); - fSampleEnv.AddLast(tostr); - - // add insert - str.Form("%03d - Insert: %s", count++, fSampleCryoInsert.Data()); - tostr = new TObjString(str); - fSampleEnv.AddLast(tostr); - - // add orientation - str.Form("%03d - Orientation: %s", count++, fOrientation.Data()); - tostr = new TObjString(str); - fSampleEnv.AddLast(tostr); - - // check if there are additional physical properties present - for (UInt_t i=0; i - * - */ -TObjArray* TPsiRunHeader::GetMagFieldEnv(UInt_t &count) -{ - // make sure that previous sample magnetic field environment info is removed - fMagFieldEnv.Delete(); - fMagFieldEnv.Expand(0); - - TString str, fmt; - TObjString *tostr; - UInt_t digit=0, digit_d=0; - - // add version - str.Form("%03d - Magnet Name: %s", count++, fMagnetName.Data()); - tostr = new TObjString(str); - fMagFieldEnv.AddLast(tostr); - - // check if there are additional physical properties present - for (UInt_t i=0; i - * - */ -TObjArray* TPsiRunHeader::GetBeamline(UInt_t &count) -{ - // make sure that previous beamline info is removed - fBeamline.Delete(); - fBeamline.Expand(0); - - TString str, fmt; - TObjString *tostr; - - // add version - str.Form("%03d - To Be Defined Yet.", count++); - tostr = new TObjString(str); - fBeamline.AddLast(tostr); - - fBeamline.SetName("Beamline"); - - return &fBeamline; -} - -//-------------------------------------------------------------------------- -// GetScaler (public) -//-------------------------------------------------------------------------- -/** - *

- * - */ -TObjArray* TPsiRunHeader::GetScaler(UInt_t &count) -{ - // make sure that previous scaler info is removed - fScalers.Delete(); - fScalers.Expand(0); - - TString str, fmt; - TObjString *tostr; - - // add version - str.Form("%03d - To Be Defined Yet.", count++); - tostr = new TObjString(str); - fScalers.AddLast(tostr); - - fScalers.SetName("Scalers"); - - return &fScalers; -} - -//-------------------------------------------------------------------------- -// ExtractHeaderInformation (public) -//-------------------------------------------------------------------------- -/** - *

Extracts from an array of TObjStrings containing the header information - * all the necessary parameters. - * - * \param headerInfo an array of TObjStrings containing the header information - * \param path - */ -Bool_t TPsiRunHeader::ExtractHeaderInformation(TObjArray *headerInfo, TString path) -{ - // check if there is an object pointer is present - if (headerInfo == 0) { - cerr << endl << ">> TPsiRunHeader::ExtractHeaderInformation(..) **ERROR** headerInfo object pointer is 0" << endl << endl; - return false; - } - - // start extracting entries - TObjArray *tokens, *tokens1; - TObjString *ostr; - TString str(""); - Int_t idx; - Double_t dval; - - // not TPsiRunProperty header variables - for (Int_t i=0; iGetEntries(); i++) { - ostr = dynamic_cast(headerInfo->At(i)); - str = ostr->GetString(); - - if (str.Contains("- Version: ")) { - idx = str.Index(":"); - str.Remove(0, idx+2); - fVersion = str; - } else if (str.Contains("- Generator: ")) { - idx = str.Index(":"); - str.Remove(0, idx+2); - fGenerator = str; - } else if (str.Contains("- File Name: ")) { - idx = str.Index(":"); - str.Remove(0, idx+2); - fFileName = str; - } else if (str.Contains("- Run Title: ")) { - idx = str.Index(":"); - str.Remove(0, idx+2); - fRunTitle = str; - } else if (str.Contains("- Run Number: ")) { - tokens = str.Tokenize(":"); - if (tokens->GetEntries() < 2) { - cerr << endl << ">> TPsiRunHeader::ExtractHeaderInformation(..) **ERROR** '" << str.Data() << "' couldn't tokenize it." << endl << endl; - return false; - } - ostr = dynamic_cast(tokens->At(1)); - if (!ostr->GetString().IsDigit()) { - cerr << endl << ">> TPsiRunHeader::ExtractHeaderInformation(..) **ERROR** '" << str.Data() << "' doesn't contain a valid run number" << endl << endl; - return false; - } - fRunNumber = ostr->GetString().Atoi(); - // clean up - CleanUp(tokens); - } else if (str.Contains("- Run Start Time: ")) { - idx = str.Index(":"); - str.Remove(0, idx+2); - fStartTime = TDatime(str); - } else if (str.Contains("- Run Stop Time: ")) { - idx = str.Index(":"); - str.Remove(0, idx+2); - fStopTime = TDatime(str); - } else if (str.Contains("- Laboratory: ")) { - idx = str.Index(":"); - str.Remove(0, idx+2); - fLaboratory = str; - } else if (str.Contains("- Area: ")) { - idx = str.Index(":"); - str.Remove(0, idx+2); - fArea = str; - } else if (str.Contains("- Instrument: ")) { - idx = str.Index(":"); - str.Remove(0, idx+2); - fInstrument = str; - } else if (str.Contains("- Muon Species: ")) { - idx = str.Index(":"); - str.Remove(0, idx+2); - fMuonSpecies = str; - } else if (str.Contains("- Setup: ")) { - idx = str.Index(":"); - str.Remove(0, idx+2); - fSetup = str; - } else if (str.Contains("- Comment: ")) { - idx = str.Index(":"); - str.Remove(0, idx+2); - fComment = str; - } else if (str.Contains("- Sample: ")) { - idx = str.Index(":"); - str.Remove(0, idx+2); - fSample = str; - } else if (str.Contains("- Cryo: ")) { - idx = str.Index(":"); - str.Remove(0, idx+2); - fSampleCryo = str; - } else if (str.Contains("- Orientation: ")) { - idx = str.Index(":"); - str.Remove(0, idx+2); - fOrientation = str; - } else if (str.Contains("- Insert: ")) { - idx = str.Index(":"); - str.Remove(0, idx+2); - fSampleCryoInsert = str; - } else if (str.Contains("- Magnet Name: ")) { - idx = str.Index(":"); - str.Remove(0, idx+2); - fMagnetName = str; - } else if (str.Contains("- No of Histos: ")) { - tokens = str.Tokenize(":"); - if (tokens->GetEntries() < 2) { - cerr << endl << ">> TPsiRunHeader::ExtractHeaderInformation(..) **ERROR** " << str.Data() << " couldn't tokenize it." << endl << endl; - // clean up - CleanUp(tokens); - return false; - } - ostr = dynamic_cast(tokens->At(1)); - if (!ostr->GetString().IsDigit()) { - cerr << endl << ">> TPsiRunHeader::ExtractHeaderInformation(..) **ERROR** " << str.Data() << " doesn't contain a valid number" << endl << endl; - return false; - } - fNoOfHistos = ostr->GetString().Atoi(); - // clean up - CleanUp(tokens); - } else if (str.Contains("- Histo Names: ")) { - tokens = str.Tokenize(":"); - if (tokens->GetEntries() < 2) { - cerr << endl << ">> TPsiRunHeader::ExtractHeaderInformation(..) **ERROR** " << str.Data() << " couldn't tokenize it." << endl << endl; - // clean up - CleanUp(tokens); - return false; - } - ostr = dynamic_cast(tokens->At(1)); - tokens1 = ostr->GetString().Tokenize(";"); - for (Int_t i=0; iGetEntries(); i++) { - ostr = dynamic_cast(tokens1->At(i)); - str = ostr->GetString(); - str.Remove(TString::kBoth, ' '); - fHistoName.push_back(str); - } - // clean up - CleanUp(tokens1); - CleanUp(tokens); - } else if (str.Contains("- Histo Length: ")) { - tokens = str.Tokenize(":"); - if (tokens->GetEntries() < 2) { - cerr << endl << ">> TPsiRunHeader::ExtractHeaderInformation(..) **ERROR** " << str.Data() << " couldn't tokenize it." << endl << endl; - // clean up - CleanUp(tokens); - return false; - } - ostr = dynamic_cast(tokens->At(1)); - if (!ostr->GetString().IsDigit()) { - cerr << endl << ">> TPsiRunHeader::ExtractHeaderInformation(..) **ERROR** " << str.Data() << " doesn't contain a valid number" << endl << endl; - return false; - } - fHistoLength = ostr->GetString().Atoi(); - // clean up - CleanUp(tokens); - } else if (str.Contains("- Time Resolution: ")) { - tokens = str.Tokenize(":"); - if (tokens->GetEntries() < 2) { - cerr << endl << ">> TPsiRunHeader::ExtractHeaderInformation(..) **ERROR** " << str.Data() << " couldn't tokenize it." << endl << endl; - // clean up - CleanUp(tokens); - return false; - } - ostr = dynamic_cast(tokens->At(1)); // - tokens1 = ostr->GetString().Tokenize(" "); - if (tokens1->GetEntries() < 2) { - cerr << endl << ">> TPsiRunHeader::ExtractHeaderInformation(..) **ERROR** " << str.Data() << " couldn't tokenize it." << endl << endl; - // clean up - CleanUp(tokens1); - CleanUp(tokens); - return false; - } - ostr = dynamic_cast(tokens1->At(0)); // - if (!ostr->GetString().IsFloat()) { - cerr << endl << ">> TPsiRunHeader::ExtractHeaderInformation(..) **ERROR** " << str.Data() << " seems not be a valid time resolution." << endl << endl; - // clean up - CleanUp(tokens1); - CleanUp(tokens); - return false; - } - dval = ostr->GetString().Atof(); - ostr = dynamic_cast(tokens1->At(1)); // - SetTimeResolution(dval, ostr->GetString()); - // clean up - CleanUp(tokens1); - CleanUp(tokens); - } else if (str.Contains("- Time Zero Bin: ")) { - tokens = str.Tokenize(":"); - if (tokens->GetEntries() < 2) { - cerr << endl << ">> TPsiRunHeader::ExtractHeaderInformation(..) **ERROR** " << str.Data() << " couldn't tokenize it." << endl << endl; - // clean up - CleanUp(tokens); - return false; - } - ostr = dynamic_cast(tokens->At(1)); - tokens1 = ostr->GetString().Tokenize(";"); - for (Int_t i=0; iGetEntries(); i++) { - ostr = dynamic_cast(tokens1->At(i)); - fTimeZeroBin.push_back(ostr->GetString().Atoi()); - } - // clean up - CleanUp(tokens1); - CleanUp(tokens); - } else if (str.Contains("- First Good Bin: ")) { - tokens = str.Tokenize(":"); - if (tokens->GetEntries() < 2) { - cerr << endl << ">> TPsiRunHeader::ExtractHeaderInformation(..) **ERROR** " << str.Data() << " couldn't tokenize it." << endl << endl; - // clean up - CleanUp(tokens); - return false; - } - ostr = dynamic_cast(tokens->At(1)); - tokens1 = ostr->GetString().Tokenize(";"); - for (Int_t i=0; iGetEntries(); i++) { - ostr = dynamic_cast(tokens1->At(i)); - fFirstGoodBin.push_back(ostr->GetString().Atoi()); - } - // clean up - CleanUp(tokens1); - CleanUp(tokens); - } else if (str.Contains("- Last Good Bin: ")) { - tokens = str.Tokenize(":"); - if (tokens->GetEntries() < 2) { - cerr << endl << ">> TPsiRunHeader::ExtractHeaderInformation(..) **ERROR** " << str.Data() << " couldn't tokenize it." << endl << endl; - // clean up - CleanUp(tokens); - return false; - } - ostr = dynamic_cast(tokens->At(1)); - tokens1 = ostr->GetString().Tokenize(";"); - for (Int_t i=0; iGetEntries(); i++) { - ostr = dynamic_cast(tokens1->At(i)); - fLastGoodBin.push_back(ostr->GetString().Atoi()); - } - // clean up - CleanUp(tokens1); - CleanUp(tokens); - } else if (str.Contains("- Red/Green offsets: ")) { - tokens = str.Tokenize(":"); - if (tokens->GetEntries() < 2) { - cerr << endl << ">> TPsiRunHeader::ExtractHeaderInformation(..) **ERROR** " << str.Data() << " couldn't tokenize it." << endl << endl; - // clean up - CleanUp(tokens); - return false; - } - ostr = dynamic_cast(tokens->At(1)); - tokens1 = ostr->GetString().Tokenize(";"); - for (Int_t i=0; iGetEntries(); i++) { - ostr = dynamic_cast(tokens1->At(i)); - fRedGreenOffset.push_back(ostr->GetString().Atoi()); - } - // clean up - CleanUp(tokens1); - CleanUp(tokens); - } else if (str.Contains("- Red/Green description: ")) { - tokens = str.Tokenize(":"); - if (tokens->GetEntries() < 2) { - cerr << endl << ">> TPsiRunHeader::ExtractHeaderInformation(..) **ERROR** " << str.Data() << " couldn't tokenize it." << endl << endl; - // clean up - CleanUp(tokens); - return false; - } - ostr = dynamic_cast(tokens->At(1)); - tokens1 = ostr->GetString().Tokenize(";"); - for (Int_t i=0; iGetEntries(); i++) { - ostr = dynamic_cast(tokens1->At(i)); - str = ostr->GetString(); - str.Remove(TString::kBoth, ' '); - fRedGreenDescription.push_back(str); - } - // clean up - CleanUp(tokens1); - CleanUp(tokens); - } - } - - // TPsiRunProperty header variables TPsiRunProperty prop; - for (Int_t i=0; iGetEntries(); i++) { - ostr = dynamic_cast(headerInfo->At(i)); - if (ostr->GetString().Contains("+-")) { - if (DecodePhyscialPorperty(ostr, prop, path)) { - AddProperty(prop); - } else { - return false; + + // go first through all objects defined in psi_root.xml + for (UInt_t i=0; iSets the run start time. It validates that the 'startTime' is a ISO 8601 - * time/date. If 'startTime' is not ISO 8601 compatible, an error message is - * sent to stderr but the run start time is not set. - * - * \param startTime ISO 8601 run start time - */ -void TPsiRunHeader::SetStartTime(TString startTime) -{ - // check that startTime is ISO 8601 compatible - struct tm tm; - memset(&tm, 0, sizeof(tm)); - strptime(startTime.Data(), "%Y-%m-%d %H:%M:S", &tm); - if (tm.tm_year == 0) - strptime(startTime.Data(), "%Y-%m-%dT%H:%M:S", &tm); - if (tm.tm_year == 0) { - cerr << endl << ">> **ERRO** TPsiRunHeader::SetStartTime(): " << startTime.Data() << " is not a ISO 8601 compatible date/time. Will not set it." << endl; - return; + // go through all objects **NOT** defined in psi_root.xml + // this is needed if a less strict validation is wanted + for (UInt_t i=0; iSets the run stop time. It validates that the 'stopTime' is a ISO 8601 - * time/date. If 'stopTime' is not ISO 8601 compatible, an error message is - * sent to stderr but the run stop time is not set. + *

Set TString 'value'. * - * \param stopTime ISO 8601 run stop time + * \param pathName path/name within the header, e.g. RunInfo/Run Title + * \param type of the object + * \param value of the entry */ -void TPsiRunHeader::SetStopTime(TString stopTime) +void TPsiRunHeader::Set(TString pathName, TString type, TString value) { - // check that stopTime is ISO 8601 compatible - struct tm tm; - memset(&tm, 0, sizeof(tm)); - strptime(stopTime.Data(), "%Y-%m-%d %H:%M:S", &tm); - if (tm.tm_year == 0) - strptime(stopTime.Data(), "%Y-%m-%dT%H:%M:S", &tm); - if (tm.tm_year == 0) { - cerr << endl << ">> **ERRO** TPsiRunHeader::SetStopTime(): " << stopTime.Data() << " is not a ISO 8601 compatible date/time. Will not set it." << endl; - return; + // check if pathName is already set, and if not add it as a new entry + UInt_t i=0; + for (i=0; i> **WARNING** " << pathName.Data() << " already exists, will replace it." << endl; + fStringObj[i].SetType(type); + fStringObj[i].SetValue(value); + break; + } } - fStopTime.Set(stopTime); -} - -//-------------------------------------------------------------------------- -// SetHistoName (public) -//-------------------------------------------------------------------------- -/** - *

Set the histogram name at index 'idx'. If 'idx' == -1, the name is appended. - * - * \param name histogram name - * \param idx histogram index - */ -void TPsiRunHeader::SetHistoName(TString name, Int_t idx) -{ - if (idx == -1) { - fHistoName.push_back(name); - } else if (idx >= (Int_t)fHistoName.size()) { - fHistoName.resize(idx+1); - fHistoName[idx] = name; - } else { - fHistoName[idx] = name; + // if not found in the previous loop, it is a new object + if (i == fStringObj.size()) { + TPsiRunObject obj(pathName, type, value); + fStringObj.push_back(obj); } } //-------------------------------------------------------------------------- -// SetTimeResolution (public) +// Set (public) //-------------------------------------------------------------------------- /** - *

Set the time resolution. 'value' is given in 'units'. Allowed 'units' - * are fs, ps, ns, us. + *

Set Int_t 'value'. * - * \param value time resolution value - * \param unit time resolution units + * \param pathName path/name within the header, e.g. RunInfo/Run number + * \param type of the object + * \param value of the entry */ -void TPsiRunHeader::SetTimeResolution(Double_t value, TString units) +void TPsiRunHeader::Set(TString pathName, TString type, Int_t value) { - Double_t factor = 0.0; - - if (!units.CompareTo("fs", TString::kIgnoreCase)) { - factor = 1.0e-3; - } else if (!units.CompareTo("ps", TString::kIgnoreCase)) { - factor = 1.0; - } else if (!units.CompareTo("ns", TString::kIgnoreCase)) { - factor = 1.0e3; - } else if (!units.CompareTo("us", TString::kIgnoreCase)) { - factor = 1.0e6; - } else { - factor = 0.0; + // check if pathName is already set, and if not add it as a new entry + UInt_t i=0; + for (i=0; i> **WARNING** " << pathName.Data() << " already exists, will replace it." << endl; + fIntObj[i].SetType(type); + fIntObj[i].SetValue(value); + break; + } } - fTimeResolution = factor * value; -} - -//-------------------------------------------------------------------------- -// SetTimeZeroBin (public) -//-------------------------------------------------------------------------- -/** - *

Set the time zero bin at index 'idx'. If 'idx' == -1, the time zero bin is appended. - * - * \param timeZeroBin time zero bin - * \param idx histogram index - */ -void TPsiRunHeader::SetTimeZeroBin(UInt_t timeZeroBin, Int_t idx) -{ - if (idx == -1) { - fTimeZeroBin.push_back(timeZeroBin); - } else if (idx >= (Int_t)fTimeZeroBin.size()) { - fTimeZeroBin.resize(idx+1); - fTimeZeroBin[idx] = timeZeroBin; - } else { - fTimeZeroBin[idx] = timeZeroBin; + // if not found in the previous loop, it is a new object + if (i == fIntObj.size()) { + TPsiRunObject obj(pathName, type, value); + fIntObj.push_back(obj); } } //-------------------------------------------------------------------------- -// SetFirstGoodBin (public) +// Set (public) //-------------------------------------------------------------------------- /** - *

Set the first good bin at index 'idx'. If 'idx' == -1, the first good bin is appended. + *

Set TPsiRunProperty 'value'. * - * \param fgb first good bin - * \param idx histogram index + * \param pathName path/name within the header, e.g. RunInfo/Muon Beam Momentum + * \param type of the object + * \param value of the entry */ -void TPsiRunHeader::SetFirstGoodBin(UInt_t fgb, Int_t idx) +void TPsiRunHeader::Set(TString pathName, TString type, TPsiRunProperty value) { - if (idx == -1) { - fFirstGoodBin.push_back(fgb); - } else if (idx >= (Int_t)fFirstGoodBin.size()) { - fFirstGoodBin.resize(idx+1); - fFirstGoodBin[idx] = fgb; - } else { - fFirstGoodBin[idx] = fgb; + // check if pathName is already set, and if not add it as a new entry + UInt_t i=0; + for (i=0; i> **WARNING** " << pathName.Data() << " already exists, will replace it." << endl; + fPsiRunPropertyObj[i].SetType(type); + fPsiRunPropertyObj[i].SetValue(value); + break; + } + } + + // if not found in the previous loop, it is a new object + if (i == fPsiRunPropertyObj.size()) { + TPsiRunObject obj(pathName, type, value); + fPsiRunPropertyObj.push_back(obj); } } //-------------------------------------------------------------------------- -// SetLastGoodBin (public) +// Set (public) //-------------------------------------------------------------------------- /** - *

Set the last good bin at index 'idx'. If 'idx' == -1, the last good bin is appended. + *

Set TStringVector 'value'. * - * \param lgb last good bin - * \param idx histogram index + * \param pathName path/name within the header, e.g. RunInfo/Histo names + * \param type of the object + * \param value of the entry */ -void TPsiRunHeader::SetLastGoodBin(UInt_t lgb, Int_t idx) +void TPsiRunHeader::Set(TString pathName, TString type, TStringVector value) { - if (idx == -1) { - fLastGoodBin.push_back(lgb); - } else if (idx >= (Int_t)fLastGoodBin.size()) { - fLastGoodBin.resize(idx+1); - fLastGoodBin[idx] = lgb; - } else { - fLastGoodBin[idx] = lgb; + // check if pathName is already set, and if not add it as a new entry + UInt_t i=0; + for (i=0; i> **WARNING** " << pathName.Data() << " already exists, will replace it." << endl; + fStringVectorObj[i].SetType(type); + fStringVectorObj[i].SetValue(value); + break; + } + } + + // if not found in the previous loop, it is a new object + if (i == fStringVectorObj.size()) { + TPsiRunObject obj(pathName, type, value); + fStringVectorObj.push_back(obj); } } //-------------------------------------------------------------------------- -// SetRedGreenHistogramOffset (public) +// Set (public) //-------------------------------------------------------------------------- /** - *

Set the red/green mode histogram offset at index 'idx'. If 'idx' == -1, the red/green mode histogram offset is appended. + *

Set TIntVector 'value'. * - * \param offset red/green mode histogram offset - * \param idx histogram index + * \param pathName path/name within the header, e.g. RunInfo/Time Zero Bin + * \param type of the object + * \param value of the entry */ -void TPsiRunHeader::SetRedGreenHistogramOffset(UInt_t offset, Int_t idx) +void TPsiRunHeader::Set(TString pathName, TString type, TIntVector value) { - if (idx == -1) { - fRedGreenOffset.push_back(offset); - } else if (idx >= (Int_t)fRedGreenOffset.size()) { - fRedGreenOffset.resize(idx+1); - fRedGreenOffset[idx] = offset; - } else { - fRedGreenOffset[idx] = offset; + // check if pathName is already set, and if not add it as a new entry + UInt_t i=0; + for (i=0; i> **WARNING** " << pathName.Data() << " already exists, will replace it." << endl; + fIntVectorObj[i].SetType(type); + fIntVectorObj[i].SetValue(value); + break; + } } -} -//-------------------------------------------------------------------------- -// SetRedGreenDescription (public) -//-------------------------------------------------------------------------- -/** - *

Set the red/green mode description at index 'idx'. If 'idx' == -1, the red/green mode description is appended. - * - * \param description red/green mode description - * \param idx histogram index - */ -void TPsiRunHeader::SetRedGreenDescription(TString description, Int_t idx) -{ - if (idx == -1) { - fRedGreenDescription.push_back(description); - } else if (idx >= (Int_t)fRedGreenDescription.size()) { - fRedGreenDescription.resize(idx+1); - fRedGreenDescription[idx] = description; - } else { - fRedGreenDescription[idx] = description; + // if not found in the previous loop, it is a new object + if (i == fIntVectorObj.size()) { + TPsiRunObject obj(pathName, type, value); + fIntVectorObj.push_back(obj); } } -//-------------------------------------------------------------------------- -// AddProperty (public) -//-------------------------------------------------------------------------- -/** - *

- * - * \param property - */ -void TPsiRunHeader::AddProperty(TPsiRunProperty &property) -{ - fProperties.push_back(property); -} - -//-------------------------------------------------------------------------- -// AddProperty (public) -//-------------------------------------------------------------------------- -/** - *

- * - * \param name - * \param value - * \param error - * \param unit - */ -void TPsiRunHeader::AddProperty(TString name, Double_t demand, Double_t value, Double_t error, TString unit, TString description, TString path) -{ - TPsiRunProperty prop(name, demand, value, error, unit, description, path); - fProperties.push_back(prop); -} - //-------------------------------------------------------------------------- // DumpHeader (public) //-------------------------------------------------------------------------- /** *

*/ -void TPsiRunHeader::DumpHeader() const +void TPsiRunHeader::DumpHeader() { - const TPsiRunProperty *prop; + TString tstr(""), tstr1(""), fmt(""), path(""), name(""); + TPsiRunProperty prop; - int old_width = cout.width(); - - // get maximal length of the property names - int name_width = 8; // init to max. length of fixed names like: version, etc. - for (UInt_t i=0; i name_width) - name_width = fProperties[i].GetLabel().Length(); - } - name_width++; - - // write SVN versions - cout << endl << setw(name_width) << left << "Version" << setw(old_width) << ": " << GetVersion().Data(); - - // write generator - cout << endl << setw(name_width) << left << "Generator" << setw(old_width) << ": " << GetGenerator().Data(); - - // write file name - cout << endl << setw(name_width) << left << "File Name" << setw(old_width) << ": " << GetFileName().Data(); - - // write run title - cout << endl << setw(name_width) << left << "Run Title" << setw(old_width) << ": " << GetRunTitle().Data(); - - // write run number - cout << endl << setw(name_width) << left << "Run Number" << setw(old_width) << ": " << GetRunNumber(); - - // write start time - cout << endl << setw(name_width) << left << "Run Start Time" << setw(old_width) << ": " << GetStartTimeString(); - - // write stop time - cout << endl << setw(name_width) << left << "Run Stop Time" << setw(old_width) << ": " << GetStopTimeString(); - - // write run duration - cout << endl << setw(name_width) << left << "Run Duration" << setw(old_width) << ": " << GetRunDuration() << " sec"; - - // write laboratory - cout << endl << setw(name_width) << left << "Laboratory" << setw(old_width) << ": " << GetLaboratory().Data(); - - // write area - cout << endl << setw(name_width) << left << "Area" << setw(old_width) << ": " << GetArea().Data(); - - // write instrument - cout << endl << setw(name_width) << left << "Instrument" << setw(old_width) << ": " << GetInstrument().Data(); - - // write muon momentum - prop = GetProperty("Muon Beam Momentum"); - if (prop != 0) { - cout << endl << setw(name_width) << left << prop->GetLabel().Data() << setw(old_width) << ": " << prop->GetValue() << " +- " << prop->GetError() << " " << prop->GetUnit().Data(); - cout << "; SP: " << prop->GetDemand(); - if (prop->GetDescription().CompareTo("n/a", TString::kIgnoreCase)) { - cout << "; " << prop->GetDescription().Data(); - } - } - - // write muon species - cout << endl << setw(name_width) << left << "Muon Species" << setw(old_width) << ": " << GetMuonSpecies().Data(); - - // write setup - cout << endl << setw(name_width) << left << "Setup" << setw(old_width) << ": " << GetSetup().Data(); - - // write comment - cout << endl << setw(name_width) << left << "Comment" << setw(old_width) << ": " << GetComment().Data(); - - // write sample - cout << endl << setw(name_width) << left << "Sample" << setw(old_width) << ": " << GetSample().Data(); - - // write sample temperature - prop = GetProperty("Sample Temperature"); - if (prop != 0) { - cout << endl << setw(name_width) << left << prop->GetLabel().Data() << setw(old_width) << ": " << prop->GetValue() << " +- " << prop->GetError() << " " << prop->GetUnit().Data(); - cout << "; SP: " << prop->GetDemand(); - if (prop->GetDescription().CompareTo("n/a", TString::kIgnoreCase)) { - cout << "; " << prop->GetDescription().Data(); - } - } - - // write sample magnetic field - prop = GetProperty("Sample Magnetic Field"); - if (prop != 0) { - cout << endl << setw(name_width) << left << prop->GetLabel().Data() << setw(old_width) << ": " << prop->GetValue() << " +- " << prop->GetError() << " " << prop->GetUnit().Data(); - cout << "; SP: " << prop->GetDemand(); - if (prop->GetDescription().CompareTo("n/a", TString::kIgnoreCase)) { - cout << "; " << prop->GetDescription().Data(); - } - } - - // write number of histograms - cout << endl << setw(name_width) << left << "No of Histos" << setw(old_width) << ": " << GetNoOfHistos(); - - // write histogram names - if (fHistoName.size() > 0) { - cout << endl << setw(name_width) << left << "Histo Names" << setw(old_width) << ": "; - for (UInt_t i=0; i 0) { - cout << endl << setw(name_width) << left << "Time Zero Bin" << setw(old_width) << ": "; - for (UInt_t i=0; i 0) { - cout << endl << setw(name_width) << left << "First Good Bin" << setw(old_width) << ": "; - for (UInt_t i=0; i 0) { - cout << endl << setw(name_width) << left << "Last Good Bin" << setw(old_width) << ": "; - for (UInt_t i=0; i 0) { - cout << endl << setw(name_width) << left << "Red/Green offsets" << setw(old_width) << ": "; - for (UInt_t i=0; i 0) { - cout << endl << setw(name_width) << left << "Red/Green description" << setw(old_width) << ": "; - for (UInt_t i=0; i */ -void TPsiRunHeader::DrawHeader() const +void TPsiRunHeader::DrawHeader() { TPaveText *pt; TCanvas *ca; @@ -1749,120 +1065,6 @@ void TPsiRunHeader::DrawHeader() const ca->Modified(kTRUE); } -//-------------------------------------------------------------------------- -// DecodePhyscialPorperty (private) -//-------------------------------------------------------------------------- -/** - *

- * - * \param ostr - * \param prop - * \param path - */ -Bool_t TPsiRunHeader::DecodePhyscialPorperty(TObjString *oprop, TPsiRunProperty &prop, TString &path) -{ - TObjArray *tokens = oprop->GetString().Tokenize("-:"); - TObjArray *tokens1 = 0; - TObjString *ostr = 0; - TString str(""); - - if (tokens == 0) { - cerr << endl << ">> **ERROR** Couldn't tokenize physical property string '" << ostr->GetString().Data() << "' (1)." << endl; - return false; - } - - // get property name - ostr = dynamic_cast(tokens->At(1)); - str = ostr->GetString(); - str.Remove(TString::kLeading, ' '); - prop.SetLabel(str); - - CleanUp(tokens); - - // get measured value - tokens = oprop->GetString().Tokenize(":"); - if (tokens == 0) { - cerr << endl << ">> **ERROR** Couldn't tokenize physical property string '" << ostr->GetString().Data() << "' (2)." << endl; - return false; - } - ostr = dynamic_cast(tokens->At(1)); - str = ostr->GetString(); - tokens1 = str.Tokenize(" ;"); - if (tokens1 == 0) { - cerr << endl << ">> **ERROR** Couldn't tokenize physical property string '" << ostr->GetString().Data() << "' (3)." << endl; - CleanUp(tokens); - return false; - } - if (tokens1->GetEntries() < 4) { - cerr << endl << ">> **ERROR** not enough tokens from physical property string '" << ostr->GetString().Data() << "' (4)." << endl; - CleanUp(tokens1); - CleanUp(tokens); - return false; - } - - // get measured value - ostr = dynamic_cast(tokens1->At(0)); - if (ostr->GetString().IsFloat()) { - prop.SetValue(ostr->GetString().Atof()); - } else { - cerr << endl << ">> **ERROR** unexpected measured value. Found " << ostr->GetString().Data() << ", expected float." << endl; - CleanUp(tokens); - return false; - } - - // get estimated err - ostr = dynamic_cast(tokens1->At(2)); - if (ostr->GetString().IsFloat()) { - prop.SetError(ostr->GetString().Atof()); - } else { - cerr << endl << ">> **ERROR** unexpected estimated error. Found " << ostr->GetString().Data() << ", expected float." << endl; - CleanUp(tokens); - return false; - } - - // get unit - ostr = dynamic_cast(tokens1->At(3)); - str = ostr->GetString(); - str.Remove(TString::kLeading, ' '); - prop.SetUnit(str); - - CleanUp(tokens1); - - ostr = dynamic_cast(tokens->At(2)); - str = ostr->GetString(); - tokens1 = str.Tokenize(";"); - if (tokens1 == 0) { - cerr << endl << ">> **ERROR** Couldn't tokenize physical property string '" << ostr->GetString().Data() << "' (4)." << endl; - CleanUp(tokens); - return false; - } - - // get demand value - ostr = dynamic_cast(tokens1->At(0)); - if (ostr->GetString().IsFloat()) { - prop.SetDemand(ostr->GetString().Atof()); - } else { - cerr << endl << ">> **ERROR** unexpected demand value. Found " << ostr->GetString().Data() << ", expected float." << endl; - CleanUp(tokens); - return false; - } - - if (tokens1->GetEntries() > 1) { // with description - ostr = dynamic_cast(tokens1->At(1)); - str = ostr->GetString(); - str.Remove(TString::kLeading, ' '); - prop.SetDescription(str); - } - - prop.SetPath(path); - - // clean up - CleanUp(tokens1); - CleanUp(tokens); - - return true; -} - //-------------------------------------------------------------------------- // GetDecimalPlace (private) //-------------------------------------------------------------------------- @@ -1883,7 +1085,7 @@ UInt_t TPsiRunHeader::GetDecimalPlace(Double_t val) if (val > 1.0) digit = count; count++; - } while ((digit == 0) || (count > 20)); + } while ((digit == 0) && (count < 20)); } return digit; @@ -1900,7 +1102,7 @@ UInt_t TPsiRunHeader::GetDecimalPlace(Double_t val) UInt_t TPsiRunHeader::GetLeastSignificantDigit(Double_t val) const { char cstr[1024]; - snprintf(cstr, sizeof(cstr), "%.20lf", val); + snprintf(cstr, sizeof(cstr), "%.10lf", val); int i=0, j=0; for (i=strlen(cstr)-1; i>=0; i--) { @@ -1919,17 +1121,28 @@ UInt_t TPsiRunHeader::GetLeastSignificantDigit(Double_t val) const } //-------------------------------------------------------------------------- -// CleanUp (private) +// SplitPathName (private) //-------------------------------------------------------------------------- /** - *

Cleans up ROOT objects. + *

splits a path name string into the path and the name. * - * \param obj pointer to the object to be cleaned up. + * \param pathName path name to be split + * \param path of pathName + * \param name of pathName */ -void TPsiRunHeader::CleanUp(TObject *obj) +void TPsiRunHeader::SplitPathName(TString pathName, TString &path, TString &name) { - if (obj) { - delete obj; - obj = 0; - } + path = TString(""); + name = TString(""); + Ssiz_t idx = pathName.Last('/'); + + for (Int_t i=0; i #include +#include #include #include +#include +#define PRH_UNDEFINED -9.99e99 + +typedef vector TIntVector; +typedef vector TStringVector; + +//------------------------------------------------------------------------- +template class TPsiRunObject : public TObject +{ +public: + TPsiRunObject() { fPathName = "n/a"; fType = "n/a"; } + TPsiRunObject(TString pathName, TString type, T value) : fPathName(pathName), fType(type), fValue(value) {} + virtual ~TPsiRunObject() {} + + virtual TString GetPathName() { return fPathName; } + virtual TString GetType() { return fType; } + virtual T GetValue() { return fValue; } + + virtual void SetPathName(TString pathName) { fPathName = pathName; } + virtual void SetType(TString type) { fType = type; } + virtual void SetValue(T value) { fValue = value; } + +private: + TString fPathName; ///< path name of the variable, e.g. 'RunInfo/Run Number' + TString fType; ///< type of value, e.g. TString, or Int_t, etc. + T fValue; ///< value itself +}; + +//------------------------------------------------------------------------- class TPsiRunProperty : public TObject { public: TPsiRunProperty(); - TPsiRunProperty(TString &name, Double_t demand, Double_t value, Double_t error, TString &unit, TString &description, TString &path); + TPsiRunProperty(TString name, Double_t demand, Double_t value, Double_t error, TString unit, TString description = TString("n/a")); + TPsiRunProperty(TString name, Double_t value, TString unit); virtual ~TPsiRunProperty() {} virtual TString GetLabel() const { return fLabel; } @@ -50,7 +81,6 @@ public: virtual Double_t GetError() const { return fError; } virtual TString GetUnit() const { return fUnit; } virtual TString GetDescription() const { return fDescription; } - virtual TString GetPath() const { return fPath; } virtual void SetLabel(TString &label) { fLabel = label; } virtual void SetLabel(const char *label) { fLabel = label; } @@ -61,8 +91,6 @@ public: virtual void SetUnit(const char *unit) { fUnit = unit; } virtual void SetDescription(TString &str) { fDescription = str; } virtual void SetDescription(const char *str) { fDescription = str; } - virtual void SetPath(TString &str) { fPath = str; } - virtual void SetPath(const char *str) { fPath = str; } private: TString fLabel; ///< property label, like ’Sample Temperature’ etc. @@ -71,11 +99,62 @@ private: Double_t fError; ///< estimated error (standard deviation) of the measured property value TString fUnit; ///< unit of the property TString fDescription; ///< a more detailed description of the property - TString fPath; ///< ROOT file path where to place the physical property ClassDef(TPsiRunProperty, 1) }; +//------------------------------------------------------------------------- +class TPsiEntry +{ +public: + TPsiEntry() { fPathName = "n/a"; fType = "n/a"; } + TPsiEntry(TString pathName, TString type) : fPathName(pathName), fType(type) {} + virtual ~TPsiEntry() {} + + virtual TString GetPathName() { return fPathName; } + virtual TString GetType() { return fType; } + + virtual void SetPathName(TString pathName) { fPathName = pathName; } + virtual void SetType(TString type) { fType = type; } + +private: + TString fPathName; + TString fType; +}; + +//------------------------------------------------------------------------- +class TPsiStartupHandler : public TObject, public TQObject +{ +public: + TPsiStartupHandler(); + virtual ~TPsiStartupHandler(); + + virtual void OnStartDocument(); // SLOT + virtual void OnEndDocument(); // SLOT + virtual void OnStartElement(const Char_t*, const TList*); // SLOT + virtual void OnEndElement(const Char_t*); // SLOT + virtual void OnCharacters(const Char_t*); // SLOT + virtual void OnComment(const Char_t*); // SLOT + virtual void OnWarning(const Char_t*); // SLOT + virtual void OnError(const Char_t*); // SLOT + virtual void OnFatalError(const Char_t*); // SLOT + virtual void OnCdataBlock(const Char_t*, Int_t); // SLOT + + virtual TStringVector GetFolders() { return fFolder; } + virtual vector GetEntries() { return fEntry; } + +private: + enum EKeyWords {eEmpty, eFolder, eEntry, eName, eType}; + + EKeyWords fKey, fGroupKey; ///< xml filter key + + TStringVector fFolder; + vector fEntry; + + ClassDef(TPsiStartupHandler, 1) +}; + +//------------------------------------------------------------------------- class TPsiRunHeader : public TObject { public: @@ -84,137 +163,32 @@ public: virtual Bool_t IsValid(Bool_t strict = false); - virtual TString GetVersion() const { return fVersion; } - virtual TString GetGenerator() const { return fGenerator; } - virtual TString GetFileName() const { return fFileName; } - virtual TString GetRunTitle() const { return fRunTitle; } - virtual Int_t GetRunNumber() const { return fRunNumber; } - virtual TDatime GetStartTime() const { return fStartTime; } - virtual const char* GetStartTimeString() const { return fStartTime.AsSQLString(); } - virtual TDatime GetStopTime() const { return fStopTime; } - virtual const char* GetStopTimeString() const { return fStopTime.AsSQLString(); } - virtual Int_t GetRunDuration() const; - virtual TString GetLaboratory() const { return fLaboratory; } - virtual TString GetArea() const { return fArea; } - virtual TString GetInstrument() const { return fInstrument; } - virtual TString GetMuonSpecies() const { return fMuonSpecies; } - virtual TString GetSetup() const { return fSetup; } - virtual TString GetComment() const { return fComment; } - virtual TString GetSample() const { return fSample; } - virtual TString GetOrientation() const { return fOrientation; } - virtual TString GetSampleCryo() const { return fSampleCryo; } - virtual TString GetSampleCryoInsert() const { return fSampleCryoInsert; } - virtual TString GetSampleMagnetName() const { return fMagnetName; } - virtual Int_t GetNoOfHistos() const { return fNoOfHistos; } - virtual UInt_t GetNoOfHistoNames() const { return fHistoName.size(); } - virtual const vector* GetHistoNames() const { return &fHistoName; } - virtual TString GetHistoName(UInt_t idx, Bool_t &ok) const; - virtual Int_t GetHistoLength() const { return fHistoLength; } - virtual Double_t GetTimeResolution(const char *units) const; - virtual UInt_t GetNoOfTimeZeroBins() const { return fTimeZeroBin.size(); } - virtual const vector* GetTimeZeroBins() const { return &fTimeZeroBin; } - virtual UInt_t GetTimeZeroBin(UInt_t idx, Bool_t &ok) const; - virtual const vector* GetFirstGoodBins() const { return &fFirstGoodBin;} - virtual UInt_t GetFirstGoodBin(UInt_t idx, Bool_t &ok) const; - virtual const vector* GetLastGoodBins() const { return &fLastGoodBin;} - virtual UInt_t GetLastGoodBin(UInt_t idx, Bool_t &ok) const; - virtual UInt_t GetNoOfRedGreenHistoOffsets() const { return fRedGreenOffset.size(); } - virtual const vector* GetRedGreenHistoOffsets() const { return &fRedGreenOffset; } - virtual UInt_t GetRedGreenHistoOffset(UInt_t idx, Bool_t &ok) const; - virtual const vector* GetRedGreenHistoDescriptions() const { return &fRedGreenDescription; } - virtual TString GetRedGreenHistoDescription(UInt_t idx, Bool_t &ok) const; - virtual const TPsiRunProperty* GetProperty(TString name) const; - virtual const vector *GetProperties() const { return &fProperties; } + virtual void Get(TString path, TObjArray &content); - virtual TObjArray *GetHeader(UInt_t &count); - virtual TObjArray *GetSampleEnv(UInt_t &count); - virtual TObjArray *GetMagFieldEnv(UInt_t &count); - virtual TObjArray *GetBeamline(UInt_t &count); - virtual TObjArray *GetScaler(UInt_t &count); + virtual void Set(TString pathName, TString type, TString value); + virtual void Set(TString pathName, TString type, Int_t value); + virtual void Set(TString pathName, TString type, TPsiRunProperty value); + virtual void Set(TString pathName, TString type, TStringVector value); + virtual void Set(TString pathName, TString type, TIntVector value); - virtual Bool_t ExtractHeaderInformation(TObjArray *headerInfo, TString path="/"); + virtual Bool_t ExtractHeaderInformation(TObjArray *headerInfo, TString path) { return true; } - virtual void SetGenerator(TString generator) { fGenerator = generator; } - virtual void SetFileName(TString fileName) { fFileName = fileName; } - virtual void SetRunTitle(TString runTitle) { fRunTitle = runTitle; } - virtual void SetRunNumber(Int_t runNumber) { fRunNumber = runNumber; } - virtual void SetStartTime(TString startTime); - virtual void SetStopTime(TString stopTime); - virtual void SetLaboratory(TString lab) { fLaboratory = lab; } - virtual void SetArea(TString area) { fArea = area;} - virtual void SetInstrument(TString insturment) { fInstrument = insturment; } - virtual void SetMuonSpecies(TString muonSpecies) { fMuonSpecies = muonSpecies; } - virtual void SetSetup(TString setup) { fSetup = setup; } - virtual void SetComment(TString comment) { fComment = comment; } - virtual void SetSample(TString sample) { fSample = sample; } - virtual void SetOrientation(TString orientation) { fOrientation = orientation; } - virtual void SetSampleCryo(TString cryoName) { fSampleCryo = cryoName; } - virtual void SetSampleCryoInsert(TString cryoInsert) { fSampleCryoInsert = cryoInsert; } - virtual void SetSampleMagnetName(TString name) { fMagnetName = name; } - virtual void SetNoOfHistos(UInt_t noHistos) { fNoOfHistos = noHistos; } - virtual void SetHistoNames(vector names) { fHistoName = names; } - virtual void SetHistoName(TString name, Int_t idx=-1); - virtual void SetHistoLength(UInt_t length) { fHistoLength = (Int_t)length; } - virtual void SetTimeResolution(Double_t value, TString units); - virtual void SetTimeZeroBins(vector timeZeroBins) { fTimeZeroBin = timeZeroBins; } - virtual void SetTimeZeroBin(UInt_t timeZeroBin, Int_t idx=-1); - virtual void SetFirstGoodBins(vector fgb) { fFirstGoodBin = fgb; } - virtual void SetFirstGoodBin(UInt_t fgb, Int_t idx=-1); - virtual void SetLastGoodBins(vector lgb) { fLastGoodBin = lgb; } - virtual void SetLastGoodBin(UInt_t lgb, Int_t idx=-1); - virtual void SetRedGreenHistogramOffsets(vector offsets) { fRedGreenOffset = offsets; } - virtual void SetRedGreenHistogramOffset(UInt_t offset, Int_t idx=-1); - virtual void SetRedGreenDescriptions(vector description) { fRedGreenDescription = description; } - virtual void SetRedGreenDescription(TString description, Int_t idx=-1); - virtual void AddProperty(TPsiRunProperty &property); - virtual void AddProperty(TString name, Double_t demand, Double_t value, Double_t error, TString unit, TString desciption=TString(""), TString path=TString("/")); - - - virtual void DumpHeader() const; - virtual void DrawHeader() const; + virtual void DumpHeader(); + virtual void DrawHeader(); private: - TString fVersion; ///< SVN version of the TPsiRunHeader - TString fGenerator; ///< program which generated the PSI-ROOT file - TString fFileName; ///< file name of the PSI-ROOT file - TString fRunTitle; ///< run title - Int_t fRunNumber; ///< run number - TDatime fStartTime; ///< run start time - TDatime fStopTime; ///< run stop time - TString fLaboratory; ///< laboratory: PSI - TString fArea; ///< secondary beamline label, e.g. piM3.2 - TString fInstrument; ///< instrument name like: GPS, LEM, .... - TString fMuonSpecies; ///< postive muon or negative muon - TString fSetup; ///< setup - TString fComment; ///< additional comment - TString fSample; ///< sample name - TString fOrientation; ///< sample orientation - TString fSampleCryo; ///< sample cryo - TString fSampleCryoInsert; ///< sample cryo insert - TString fMagnetName; ///< name of the magnet used - Int_t fNoOfHistos; ///< number of histos - vector fHistoName; ///< names of the individual histograms - Int_t fHistoLength; ///< length of the histograms in bins - Double_t fTimeResolution; ///< time resolution in ps - vector fTimeZeroBin; ///< time zero bins - vector fFirstGoodBin; ///< first good bins - vector fLastGoodBin; ///< last good bins - vector fRedGreenOffset; ///< red/green mode histogram offsets - vector fRedGreenDescription; ///< red/green mode description - vector fProperties; + vector< TPsiRunObject > fStringObj; + vector< TPsiRunObject > fIntObj; + vector< TPsiRunObject > fPsiRunPropertyObj; + vector< TPsiRunObject > fStringVectorObj; + vector< TPsiRunObject > fIntVectorObj; - TObjArray fHeader; ///< header as TObjString array for dumping into a ROOT file - TObjArray fSampleEnv; ///< sample environment as TObjString array for dumping into a ROOT file - TObjArray fMagFieldEnv; ///< sample magnetic field environment as TObjString array for dumping into a ROOT file - TObjArray fBeamline; ///< beamline info as TObjString array for dumping into a ROOT file - TObjArray fScalers; ///< scaler info as TObjString array for dumping into a ROOT file - - virtual Bool_t DecodePhyscialPorperty(TObjString *ostr, TPsiRunProperty &prop, TString &path); + TStringVector fFolder; + vector fEntry; virtual UInt_t GetDecimalPlace(Double_t val); virtual UInt_t GetLeastSignificantDigit(Double_t val) const; - - virtual void CleanUp(TObject *obj); + virtual void SplitPathName(TString pathName, TString &path, TString &name); ClassDef(TPsiRunHeader, 1) }; diff --git a/src/tests/PsiRoot/TPsiRunHeaderLinkDef.h b/src/tests/PsiRoot/TPsiRunHeaderLinkDef.h index 7f39ce39..546fbc2b 100644 --- a/src/tests/PsiRoot/TPsiRunHeaderLinkDef.h +++ b/src/tests/PsiRoot/TPsiRunHeaderLinkDef.h @@ -1,6 +1,6 @@ /*************************************************************************** - TPsiRunHeaderLinkDef.h + TPsiRunHeader2LinkDef.h Author: Andreas Suter e-mail: andreas.suter@psi.ch @@ -36,6 +36,7 @@ #pragma link off all functions; #pragma link C++ class TPsiRunProperty+; +#pragma link C++ class TPsiStartupHandler+; #pragma link C++ class TPsiRunHeader+; #endif diff --git a/src/tests/PsiRoot/psi_root.xml b/src/tests/PsiRoot/psi_root.xml new file mode 100644 index 00000000..aff18bd2 --- /dev/null +++ b/src/tests/PsiRoot/psi_root.xml @@ -0,0 +1,85 @@ + + + + This is the generic PSI-ROOT header definition. + $Id$ + + + + + RunInfo + + + SampleEnv + + + MagFieldEnv + + + Beamline + + + Scaler + + + + + + RunInfo/Version + TString + + + RunInfo/Generator + TString + + + RunInfo/File Name + TString + + + RunInfo/Run Title + TString + + + RunInfo/Run Number + Int_t + + + RunInfo/Sample Temperature + TPsiRunProperty + + + RunInfo/Time Resolution + TPsiRunProperty + + + RunInfo/Muon Beam Momentum + TPsiRunProperty + + + RunInfo/Histo Names + TStringVector + + + RunInfo/Time Zero Bin + TIntVector + + + SampleEnv/Cryo + TString + + + SampleEnv/CF2 + TPsiRunProperty + + + MagFieldEnv/Name + TString + + + MagFieldEnv/Current + TPsiRunProperty + + + + diff --git a/src/tests/PsiRoot/psi_runHeader_test.cpp b/src/tests/PsiRoot/psi_runHeader_test.cpp index 1c8a4268..808186ff 100644 --- a/src/tests/PsiRoot/psi_runHeader_test.cpp +++ b/src/tests/PsiRoot/psi_runHeader_test.cpp @@ -54,57 +54,74 @@ int main(int argc, char *argv[]) // PSI Run Header object TPsiRunHeader *header = new TPsiRunHeader(); + TPsiRunProperty *prop; - header->SetGenerator("psi_runHeader_test"); - header->SetFileName(argv[1]); - header->SetRunTitle("This is a run title"); - header->SetRunNumber(12345); - header->SetStartTime("2011-08-31 08:03:23"); - header->SetStopTime("2011-08-31 10:46:48"); - header->SetLaboratory("PSI"); - header->SetInstrument("LEM"); - header->SetArea("muE4"); - header->AddProperty("Muon Beam Momentum", 28.0, 28.0, 0.7, "MeV/c"); - header->SetMuonSpecies("positive Muon"); - header->SetSetup("Konti-4, WEW"); - header->SetComment("This is a comment"); - header->SetSample("Eu2CuO4 MOD thin film"); - header->AddProperty("Sample Temperature", 30.0, 30.01, 0.05, "K"); - header->AddProperty("Sample Magnetic Field", 3.0, 3.0003, 0.000025, "T"); - header->SetOrientation("c-axis perp to spin"); - header->AddProperty("T1", 30.0, 30.003, 0.003, "K", "sample stick temperature", "/SampleEnv/"); - header->SetSampleCryo("Konti-4"); - header->SetSampleCryoInsert("n/a"); - header->SetSampleMagnetName("Bpar"); - header->AddProperty("Current", 1.54, 1.54, 0.003, "A", "Danfysik", "/MagFieldEnv/"); + // run info + header->Set("RunInfo/Version", "TString", "$Id$"); + header->Set("RunInfo/Generator", "TString", "any2many"); + header->Set("RunInfo/File Name", "TString", "thisIsAFileName"); + header->Set("RunInfo/Run Title", "TString", "here comes the run title"); + header->Set("RunInfo/Run Number", "Int_t", 576); + header->Set("RunInfo/Run Number", "Int_t", 577); + header->Set("RunInfo/Run Start Time", "TString", "2011-04-19 14:25:22"); + header->Set("RunInfo/Run Stop Time", "TString", "2011-04-19 19:13:47"); - header->SetNoOfHistos(8); - header->SetHistoName("left/forward"); - header->SetHistoName("top/forward"); - header->SetHistoName("right/forward"); - header->SetHistoName("bottom/forward"); - header->SetHistoName("left/backward"); - header->SetHistoName("top/backward"); - header->SetHistoName("right/backward"); - header->SetHistoName("bottom/backward"); - header->SetHistoLength(66601); - header->SetTimeResolution(0.1953125, "ns"); + prop = new TPsiRunProperty("Time Resolution", 0.193525, "ns"); + header->Set("RunInfo/Time Resolution", "TPsiRunProperty", *prop); - for (Int_t i=0; iGetNoOfHistos(); i++) { - header->SetTimeZeroBin(3419); - header->SetFirstGoodBin(3419); - header->SetLastGoodBin(65000); - } + prop = new TPsiRunProperty("Sample Temperature", 3.2, 3.20, 0.05, "K", "CF1"); + header->Set("RunInfo/Sample Temperature", "TPsiRunProperty", *prop); - header->SetRedGreenHistogramOffset(0); - header->SetRedGreenHistogramOffset(20); - header->SetRedGreenDescription("NPP"); - header->SetRedGreenDescription("PPC"); + prop = new TPsiRunProperty("Muon Beam Momentum", PRH_UNDEFINED, 28.1, PRH_UNDEFINED, "MeV/c"); + header->Set("RunInfo/Muon Beam Momentum", "TPsiRunProperty", *prop); + + TStringVector detectorName; + detectorName.push_back("left_down"); + detectorName.push_back("left_up"); + detectorName.push_back("top_down"); + detectorName.push_back("top_up"); + detectorName.push_back("right_down"); + detectorName.push_back("right_up"); + detectorName.push_back("bottom_down"); + detectorName.push_back("bottom_up"); + header->Set("RunInfo/Histo Names", "TStringVector", detectorName); + + TIntVector t0; + for (UInt_t i=0; i<8; i++) t0.push_back(3419); + header->Set("RunInfo/Time Zero Bin", "TIntVector", t0); + + TStringVector dummyTest; + dummyTest.push_back("dummy1"); + dummyTest.push_back("dummy2"); + dummyTest.push_back("dummy3"); + header->Set("RunInfo/Dummy Test", "TStringVector", dummyTest); + + // sample environment + header->Set("SampleEnv/Cryo", "TString", "Konti-1"); + prop = new TPsiRunProperty("CF2", 3.2, 3.22, 0.04, "A"); + header->Set("SampleEnv/CF2", "TPsiRunProperty", *prop); + + prop = new TPsiRunProperty("Dummy Prop", -2.0, -2.001, 0.002, "SI unit"); + header->Set("SampleEnv/Dummy Prop", "TPsiRunProperty", *prop); + + // magnetic field environment + header->Set("MagFieldEnv/Name", "TString", "Bpar"); + prop = new TPsiRunProperty("Current", 1.34, "A"); + header->Set("MagFieldEnv/Current", "TPsiRunProperty", *prop); + + // beamline + header->Set("Beamline/WSX61a", "TString", "DAC = 3289, ADC = 0.800"); + + TIntVector dummyInt; + for (UInt_t i=0; i<3; i++) dummyInt.push_back(i+1000); + header->Set("Beamline/Dummy Int", "TIntVector", dummyInt); + + + // scaler + header->Set("Scaler/Ip", "Int_t", 12332123); if (!header->IsValid()) { - cerr << endl << ">> **ERROR** PSI-ROOT run header is not valid/complete." << endl; - delete header; - return -1; + cerr << endl << ">> **ERROR** run header validation failed." << endl; } TFile *f = new TFile(argv[1], "RECREATE", "psi_runHeader_test"); @@ -114,15 +131,30 @@ int main(int argc, char *argv[]) } // root file header related things - UInt_t count = 1; - TFolder *runInfo = gROOT->GetRootFolder()->AddFolder("RunInfo", "PSI RunInfo"); - gROOT->GetListOfBrowsables()->Add(runInfo, "RunInfo"); - runInfo->Add(header->GetHeader(count)); - runInfo->Add(header->GetSampleEnv(count)); - runInfo->Add(header->GetMagFieldEnv(count)); - runInfo->Add(header->GetBeamline(count)); - runInfo->Add(header->GetScaler(count)); - runInfo->Write(); + TFolder *runHeader = gROOT->GetRootFolder()->AddFolder("RunHeaderInfo", "PSI Run Header Info"); + gROOT->GetListOfBrowsables()->Add(runHeader, "RunHeaderInfo"); + + TObjArray runInfo; + header->Get("RunInfo", runInfo); + runHeader->Add(&runInfo); + + TObjArray sampleEnv; + header->Get("SampleEnv", sampleEnv); + runHeader->Add(&sampleEnv); + + TObjArray magFieldEnv; + header->Get("MagFieldEnv", magFieldEnv); + runHeader->Add(&magFieldEnv); + + TObjArray beamline; + header->Get("Beamline", beamline); + runHeader->Add(&beamline); + + TObjArray scaler; + header->Get("Scaler", scaler); + runHeader->Add(&scaler); + + runHeader->Write(); f->Close(); @@ -134,7 +166,9 @@ int main(int argc, char *argv[]) delete header; header = 0; - cout << endl << ">> read back " << argv[1] << endl; + cout << endl << "++++++++++++++++++++++++++++"; + cout << endl << ">> read back " << argv[1]; + cout << endl << "++++++++++++++++++++++++++++" << endl; // read the file back and extract the header info f = new TFile(argv[1], "READ", "psi_runHeader_test"); @@ -144,9 +178,9 @@ int main(int argc, char *argv[]) } runInfo = 0; - f->GetObject("RunInfo", runInfo); - if (runInfo == 0) { - cerr << endl << ">> **ERROR** Couldn't get top folder RunInfo"; + f->GetObject("RunHeaderInfo", runHeader); + if (runHeader == 0) { + cerr << endl << ">> **ERROR** Couldn't get top folder RunHeaderInfo"; f->Close(); return -1; } @@ -155,39 +189,39 @@ int main(int argc, char *argv[]) header = new TPsiRunHeader(); // get RunHeader - oarray = (TObjArray*) runInfo->FindObjectAny("RunHeader"); + oarray = (TObjArray*) runHeader->FindObjectAny("RunInfo"); if (oarray == 0) { cerr << endl << ">> **ERROR** Couldn't get RunHeader" << endl; } - header->ExtractHeaderInformation(oarray); + header->ExtractHeaderInformation(oarray, "RunInfo"); // get SampleEnv - oarray = (TObjArray*) runInfo->FindObjectAny("SampleEnv"); + oarray = (TObjArray*) runHeader->FindObjectAny("SampleEnv"); if (oarray == 0) { cerr << endl << ">> **ERROR** Couldn't get SampleEnv" << endl; } - header->ExtractHeaderInformation(oarray, "/SampleEnv/"); + header->ExtractHeaderInformation(oarray, "SampleEnv"); // get MagFieldEnv - oarray = (TObjArray*) runInfo->FindObjectAny("MagFieldEnv"); + oarray = (TObjArray*) runHeader->FindObjectAny("MagFieldEnv"); if (oarray == 0) { cerr << endl << ">> **ERROR** Couldn't get MagFieldEnv" << endl; } - header->ExtractHeaderInformation(oarray, "/MagFieldEnv/"); + header->ExtractHeaderInformation(oarray, "MagFieldEnv"); // get Beamline - oarray = (TObjArray*) runInfo->FindObjectAny("Beamline"); + oarray = (TObjArray*) runHeader->FindObjectAny("Beamline"); if (oarray == 0) { cerr << endl << ">> **ERROR** Couldn't get Beamline" << endl; } - header->ExtractHeaderInformation(oarray, "/Beamline/"); + header->ExtractHeaderInformation(oarray, "Beamline"); // get Scaler - oarray = (TObjArray*) runInfo->FindObjectAny("Scalers"); + oarray = (TObjArray*) runHeader->FindObjectAny("Scaler"); if (oarray == 0) { - cerr << endl << ">> **ERROR** Couldn't get Scalers" << endl; + cerr << endl << ">> **ERROR** Couldn't get Scaler" << endl; } - header->ExtractHeaderInformation(oarray, "/Scalers/"); + header->ExtractHeaderInformation(oarray, "Scaler"); header->DumpHeader();