From 928e067f36b62dc6418da8684f08c98dfcf0a12b Mon Sep 17 00:00:00 2001 From: nemu Date: Wed, 31 Aug 2011 13:19:07 +0000 Subject: [PATCH] some more work on PSI-ROOT --- src/tests/PsiRoot/TPsiRunHeader.cpp | 107 ++++++++++++++--------- src/tests/PsiRoot/TPsiRunHeader.h | 3 + src/tests/PsiRoot/psi_runHeader_test.cpp | 1 + 3 files changed, 72 insertions(+), 39 deletions(-) diff --git a/src/tests/PsiRoot/TPsiRunHeader.cpp b/src/tests/PsiRoot/TPsiRunHeader.cpp index 35ef6dfe..7ebe492b 100644 --- a/src/tests/PsiRoot/TPsiRunHeader.cpp +++ b/src/tests/PsiRoot/TPsiRunHeader.cpp @@ -109,6 +109,7 @@ TPsiRunHeader::TPsiRunHeader() 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"); @@ -199,6 +200,9 @@ Bool_t TPsiRunHeader::IsValid(Bool_t strict) } 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; @@ -307,6 +311,9 @@ Bool_t TPsiRunHeader::IsValid(Bool_t strict) 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; } @@ -587,66 +594,66 @@ TObjArray* TPsiRunHeader::GetHeader(UInt_t &count) UInt_t digit=0, digit_d=0; // add version - str.Form("%02d - Version: %s", count++, fVersion.Data()); + str.Form("%03d - Version: %s", count++, fVersion.Data()); tostr = new TObjString(str); fHeader.AddLast(tostr); // add generator - str.Form("%02d - Generator: %s", count++, fGenerator.Data()); + str.Form("%03d - Generator: %s", count++, fGenerator.Data()); tostr = new TObjString(str); fHeader.AddLast(tostr); // add file name - str.Form("%02d - File Name: %s", count++, fFileName.Data()); + str.Form("%03d - File Name: %s", count++, fFileName.Data()); tostr = new TObjString(str); fHeader.AddLast(tostr); // add run title - str.Form("%02d - Run Title: %s", count++, fRunTitle.Data()); + str.Form("%03d - Run Title: %s", count++, fRunTitle.Data()); tostr = new TObjString(str); fHeader.AddLast(tostr); // add run number - str.Form("%02d - Run Number: %d", count++, fRunNumber); + str.Form("%03d - Run Number: %d", count++, fRunNumber); tostr = new TObjString(str); fHeader.AddLast(tostr); // add run start time - str.Form("%02d - Run Start Time: %s", count++, fStartTime.AsSQLString()); + str.Form("%03d - Run Start Time: %s", count++, fStartTime.AsSQLString()); tostr = new TObjString(str); fHeader.AddLast(tostr); // add run stop time - str.Form("%02d - Run Stop Time: %s", count++, fStopTime.AsSQLString()); + str.Form("%03d - Run Stop Time: %s", count++, fStopTime.AsSQLString()); tostr = new TObjString(str); fHeader.AddLast(tostr); // add laboratory - str.Form("%02d - Laboratory: %s", count++, fLaboratory.Data()); + str.Form("%03d - Laboratory: %s", count++, fLaboratory.Data()); tostr = new TObjString(str); fHeader.AddLast(tostr); // add area - str.Form("%02d - Area: %s", count++, fArea.Data()); + str.Form("%03d - Area: %s", count++, fArea.Data()); tostr = new TObjString(str); fHeader.AddLast(tostr); // add instrument - str.Form("%02d - Instrument: %s", count++, fInstrument.Data()); + str.Form("%03d - Instrument: %s", count++, fInstrument.Data()); tostr = new TObjString(str); fHeader.AddLast(tostr); // add muon momentum - prop = GetProperty("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("%%02d - %%s: %%.%dlf +- %%.%dlf %%s; SP: %%.%dlf; %%s", digit, digit, digit_d); + 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("%%02d - %%s: %%.%dlf +- %%.%dlf %%s; SP: %%.%dlf", digit, digit, digit_d); + 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()); } @@ -655,18 +662,23 @@ TObjArray* TPsiRunHeader::GetHeader(UInt_t &count) } // add muon species - str.Form("%02d - Muon Species: %s", count++, fMuonSpecies.Data()); + str.Form("%03d - Muon Species: %s", count++, fMuonSpecies.Data()); tostr = new TObjString(str); fHeader.AddLast(tostr); // add setup - str.Form("%02d - Setup: %s", count++, fSetup.Data()); + 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("%02d - Sample: %s", count++, fSample.Data()); + str.Form("%03d - Sample: %s", count++, fSample.Data()); tostr = new TObjString(str); fHeader.AddLast(tostr); @@ -676,11 +688,11 @@ TObjArray* TPsiRunHeader::GetHeader(UInt_t &count) digit = GetDecimalPlace(prop->GetError()); digit_d = GetLeastSignificantDigit(prop->GetDemand()); if (prop->GetDescription().CompareTo("n/a")) { - fmt.Form("%%02d - %%s: %%.%dlf +- %%.%dlf %%s; SP: %%.%dlf; %%s", digit, digit, digit_d); + 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("%%02d - %%s: %%.%dlf +- %%.%dlf %%s; SP: %%.%dlf", digit, digit, digit_d); + 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()); } @@ -694,11 +706,11 @@ TObjArray* TPsiRunHeader::GetHeader(UInt_t &count) digit = GetDecimalPlace(prop->GetError()); digit_d = GetLeastSignificantDigit(prop->GetDemand()); if (prop->GetDescription().CompareTo("n/a")) { - fmt.Form("%%02d - %%s: %%.%dlf +- %%.%dlf %%s; SP: %%.%dlf; %%s", digit, digit, digit_d); + 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("%%02d - %%s: %%.%dlf +- %%.%dlf %%s; SP: %%.%dlf", digit, digit, digit_d); + 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()); } @@ -707,12 +719,12 @@ TObjArray* TPsiRunHeader::GetHeader(UInt_t &count) } // add number of histograms - str.Form("%02d - No of Histos: %d", count++, fNoOfHistos); + str.Form("%03d - No of Histos: %d", count++, fNoOfHistos); tostr = new TObjString(str); fHeader.AddLast(tostr); // add histogram names - str.Form("%02d - Histo Names: ", count++); + str.Form("%03d - Histo Names: ", count++); for (UInt_t i=0; i 0) { - str.Form("%02d - Red/Green offsets: ", count++); + str.Form("%03d - Red/Green offsets: ", count++); for (UInt_t i=0; i 0) { - str.Form("%02d - Red/Green description: ", count++); + str.Form("%03d - Red/Green description: ", count++); for (UInt_t i=0; iGetLabel().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(); diff --git a/src/tests/PsiRoot/TPsiRunHeader.h b/src/tests/PsiRoot/TPsiRunHeader.h index 761e79a3..eec6611a 100644 --- a/src/tests/PsiRoot/TPsiRunHeader.h +++ b/src/tests/PsiRoot/TPsiRunHeader.h @@ -98,6 +98,7 @@ public: 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; } @@ -143,6 +144,7 @@ public: 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; } @@ -183,6 +185,7 @@ private: 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 diff --git a/src/tests/PsiRoot/psi_runHeader_test.cpp b/src/tests/PsiRoot/psi_runHeader_test.cpp index f25d2c7c..1c8a4268 100644 --- a/src/tests/PsiRoot/psi_runHeader_test.cpp +++ b/src/tests/PsiRoot/psi_runHeader_test.cpp @@ -67,6 +67,7 @@ int main(int argc, char *argv[]) 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");