a mockup PSI Run Header without custom class objects in the root file
This commit is contained in:
parent
a9ceae63a0
commit
2951d2fad2
@ -59,7 +59,7 @@ ClassImp(TPsiRunProperty)
|
|||||||
*/
|
*/
|
||||||
TPsiRunProperty::TPsiRunProperty()
|
TPsiRunProperty::TPsiRunProperty()
|
||||||
{
|
{
|
||||||
fName = "n/a";
|
fLabel = "n/a";
|
||||||
fValue = 0.0;
|
fValue = 0.0;
|
||||||
fError = 0.0;
|
fError = 0.0;
|
||||||
fUnit = "n/a";
|
fUnit = "n/a";
|
||||||
@ -76,23 +76,8 @@ TPsiRunProperty::TPsiRunProperty()
|
|||||||
* \param error
|
* \param error
|
||||||
* \param unit
|
* \param unit
|
||||||
*/
|
*/
|
||||||
TPsiRunProperty::TPsiRunProperty(TObjString &name, Double_t value, Double_t error, TObjString &unit) :
|
TPsiRunProperty::TPsiRunProperty(TString &label, Double_t value, Double_t error, TString &unit) :
|
||||||
fName(name), fValue(value), fError(error), fUnit(unit)
|
fLabel(label), fValue(value), fError(error), fUnit(unit)
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
// Constructor
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* <p>Constructor.
|
|
||||||
*
|
|
||||||
* \param name
|
|
||||||
* \param value
|
|
||||||
* \param error
|
|
||||||
* \param unit
|
|
||||||
*/
|
|
||||||
TPsiRunProperty::TPsiRunProperty(TString &name, Double_t value, Double_t error, TString &unit) : fName(name), fValue(value), fError(error), fUnit(unit)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,16 +103,16 @@ ClassImp(TPsiRunHeader)
|
|||||||
*/
|
*/
|
||||||
TPsiRunHeader::TPsiRunHeader()
|
TPsiRunHeader::TPsiRunHeader()
|
||||||
{
|
{
|
||||||
fVersion.SetString("00 - version: $Id$");
|
fVersion = TString("$Id$");
|
||||||
fRunTitle.SetString("01 - run title: n/a");
|
fRunTitle = TString("n/a");
|
||||||
fRunNumber.SetString("02 - run number: -1");
|
fRunNumber = -1;
|
||||||
fLaboratory.SetString("03 - laboratory: n/a");
|
fLaboratory = TString("n/a");
|
||||||
fInstrument.SetString("04 - instrument: n/a");
|
fInstrument = TString("n/a");
|
||||||
fSetup.SetString("05 - setup: n/a");
|
fSetup = TString("n/a");
|
||||||
fSample.SetString("06 - sample: n/a");
|
fSample = TString("n/a");
|
||||||
fOrientation.SetString("07 - orientation: n/a");
|
fOrientation = TString("n/a");
|
||||||
fPropertiesList.Expand(0); // init to size 0
|
|
||||||
fProperties.Expand(0); // init to size 0
|
fHeader.Expand(0); // init to size 0
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
@ -138,238 +123,83 @@ TPsiRunHeader::TPsiRunHeader()
|
|||||||
*/
|
*/
|
||||||
TPsiRunHeader::~TPsiRunHeader()
|
TPsiRunHeader::~TPsiRunHeader()
|
||||||
{
|
{
|
||||||
fPropertiesList.Delete();
|
fProperties.clear();
|
||||||
fProperties.Delete();
|
fHeader.Delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
// GetVersion (public)
|
// GetHeader (public)
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
*/
|
|
||||||
TString TPsiRunHeader::GetVersion() const
|
|
||||||
{
|
|
||||||
TString str("??");
|
|
||||||
|
|
||||||
Int_t idx = fVersion.GetString().First(":");
|
|
||||||
if ((idx < 0) || (idx+2 > fVersion.GetString().Length()))
|
|
||||||
return str;
|
|
||||||
|
|
||||||
str = fVersion.GetString();
|
|
||||||
str.Replace(0, idx+2, 0, 0);
|
|
||||||
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
// GetRunTitle (public)
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
*/
|
|
||||||
TString TPsiRunHeader::GetRunTitle() const
|
|
||||||
{
|
|
||||||
return GetInfoString(fRunTitle);
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
// SetRunTitle (public)
|
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* \param runTitle
|
|
||||||
*/
|
*/
|
||||||
void TPsiRunHeader::SetRunTitle(TString runTitle)
|
TObjArray* TPsiRunHeader::GetHeader()
|
||||||
{
|
{
|
||||||
char str[1024];
|
// make sure that previous header is removed
|
||||||
sprintf(str, "%02d - run title: %s", TPRH_RUN_TITLE_IDX, runTitle.Data());
|
fHeader.Expand(0);
|
||||||
|
|
||||||
fRunTitle.SetString(str);
|
char str[1024], fmt[1024];
|
||||||
}
|
TObjString *tostr;
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
// add version
|
||||||
// GetRunNumber (public)
|
sprintf(str, "%02d - Version: %s", TPRH_VERSION_IDX+1, fVersion.Data());
|
||||||
//--------------------------------------------------------------------------
|
tostr = new TObjString(str);
|
||||||
/**
|
fHeader.AddLast(tostr);
|
||||||
* <p>
|
|
||||||
*/
|
|
||||||
Int_t TPsiRunHeader::GetRunNumber() const
|
|
||||||
{
|
|
||||||
TObjArray *tokens = 0;
|
|
||||||
TObjString *ostr = 0;
|
|
||||||
TString str("");
|
|
||||||
Int_t ival=-999;
|
|
||||||
|
|
||||||
tokens = fRunNumber.GetString().Tokenize(":");
|
// add run title
|
||||||
if (!tokens) { // couldn't get tokens
|
sprintf(str, "%02d - Run Title: %s", TPRH_RUN_TITLE_IDX+1, fRunTitle.Data());
|
||||||
return ival;
|
tostr = new TObjString(str);
|
||||||
}
|
fHeader.AddLast(tostr);
|
||||||
if (tokens->GetEntries() != 2) { // wrong number of tokens
|
|
||||||
delete tokens;
|
// add run number
|
||||||
return ival;
|
sprintf(str, "%02d - Run Number: %d", TPRH_RUN_NUMBER_IDX+1, fRunNumber);
|
||||||
|
tostr = new TObjString(str);
|
||||||
|
fHeader.AddLast(tostr);
|
||||||
|
|
||||||
|
// add laboratory
|
||||||
|
sprintf(str, "%02d - Laboratory: %s", TPRH_LABORATORY_IDX+1, fLaboratory.Data());
|
||||||
|
tostr = new TObjString(str);
|
||||||
|
fHeader.AddLast(tostr);
|
||||||
|
|
||||||
|
// add instrument
|
||||||
|
sprintf(str, "%02d - Instrument: %s", TPRH_INSTRUMENT_IDX+1, fInstrument.Data());
|
||||||
|
tostr = new TObjString(str);
|
||||||
|
fHeader.AddLast(tostr);
|
||||||
|
|
||||||
|
// add setup
|
||||||
|
sprintf(str, "%02d - Setup: %s", TPRH_SETUP_IDX+1, fSetup.Data());
|
||||||
|
tostr = new TObjString(str);
|
||||||
|
fHeader.AddLast(tostr);
|
||||||
|
|
||||||
|
// add sample
|
||||||
|
sprintf(str, "%02d - Sample: %s", TPRH_SAMPLE_IDX+1, fSample.Data());
|
||||||
|
tostr = new TObjString(str);
|
||||||
|
fHeader.AddLast(tostr);
|
||||||
|
|
||||||
|
// add orientation
|
||||||
|
sprintf(str, "%02d - Orientation: %s", TPRH_ORIENTATION_IDX+1, fOrientation.Data());
|
||||||
|
tostr = new TObjString(str);
|
||||||
|
fHeader.AddLast(tostr);
|
||||||
|
|
||||||
|
// add properties
|
||||||
|
UInt_t digit=0;
|
||||||
|
for (UInt_t i=0; i<fProperties.size(); i++) {
|
||||||
|
digit = GetDecimalPlace(fProperties[i].GetError());
|
||||||
|
if (fProperties[i].GetUnit().CompareTo("n/a", TString::kIgnoreCase)) {
|
||||||
|
sprintf(fmt, "%%02d - %%s: %%.%dlf +- (%%.%dlf) %%s", digit, digit);
|
||||||
|
sprintf(str, fmt, TPRH_OFFSET+i, fProperties[i].GetLabel().Data(), fProperties[i].GetValue(), fProperties[i].GetError(), fProperties[i].GetUnit().Data());
|
||||||
|
} else {
|
||||||
|
sprintf(fmt, "%%02d - %%s: %%.%dlf +- (%%.%dlf)", digit, digit);
|
||||||
|
sprintf(str, fmt, TPRH_OFFSET+i, fProperties[i].GetLabel().Data(), fProperties[i].GetValue(), fProperties[i].GetError());
|
||||||
|
}
|
||||||
|
tostr = new TObjString(str);
|
||||||
|
fHeader.AddLast(tostr);
|
||||||
}
|
}
|
||||||
|
|
||||||
ostr = dynamic_cast<TObjString*>(tokens->At(1));
|
fHeader.SetName("RunHeader");
|
||||||
str = ostr->GetString();
|
|
||||||
if (str.IsDigit())
|
|
||||||
ival = str.Atoi();
|
|
||||||
|
|
||||||
delete tokens;
|
return &fHeader;
|
||||||
|
|
||||||
return ival;
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
// SetRunNumber (public)
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
*
|
|
||||||
* \param runNumber
|
|
||||||
*/
|
|
||||||
void TPsiRunHeader::SetRunNumber(Int_t runNumber)
|
|
||||||
{
|
|
||||||
char str[1024];
|
|
||||||
sprintf(str, "%02d - run number: %06d", TPRH_RUN_NUMBER_IDX, runNumber);
|
|
||||||
|
|
||||||
fRunNumber.SetString(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
// GetLab (public)
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
*/
|
|
||||||
TString TPsiRunHeader::GetLab() const
|
|
||||||
{
|
|
||||||
return GetInfoString(fLaboratory);
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
// SetLab (public)
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
*
|
|
||||||
* \param lab
|
|
||||||
*/
|
|
||||||
void TPsiRunHeader::SetLab(TString lab)
|
|
||||||
{
|
|
||||||
char str[1024];
|
|
||||||
sprintf(str, "%02d - laboratory: %s", TPRH_LABORATORY_IDX, lab.Data());
|
|
||||||
|
|
||||||
fLaboratory.SetString(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
// GetInstrument (public)
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
*/
|
|
||||||
TString TPsiRunHeader::GetInstrument() const
|
|
||||||
{
|
|
||||||
return GetInfoString(fInstrument);
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
// SetInstrument (public)
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
*
|
|
||||||
* \param instrument
|
|
||||||
*/
|
|
||||||
void TPsiRunHeader::SetInstrument(TString instrument)
|
|
||||||
{
|
|
||||||
char str[1024];
|
|
||||||
sprintf(str, "%02d - instrument: %s", TPRH_INSTRUMENT_IDX, instrument.Data());
|
|
||||||
|
|
||||||
fInstrument.SetString(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
// GetSetup (public)
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
*/
|
|
||||||
TString TPsiRunHeader::GetSetup() const
|
|
||||||
{
|
|
||||||
return GetInfoString(fSetup);
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
// SetSetup (public)
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
*
|
|
||||||
* \param setup
|
|
||||||
*/
|
|
||||||
void TPsiRunHeader::SetSetup(TString setup)
|
|
||||||
{
|
|
||||||
char str[1024];
|
|
||||||
sprintf(str, "%02d - setup: %s", TPRH_SETUP_IDX, setup.Data());
|
|
||||||
|
|
||||||
fSetup.SetString(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
// GetSample (public)
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
*/
|
|
||||||
TString TPsiRunHeader::GetSample() const
|
|
||||||
{
|
|
||||||
return GetInfoString(fSample);
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
// SetSample (public)
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
*
|
|
||||||
* \param sample
|
|
||||||
*/
|
|
||||||
void TPsiRunHeader::SetSample(TString sample)
|
|
||||||
{
|
|
||||||
char str[1024];
|
|
||||||
sprintf(str, "%02d - sample: %s", TPRH_SAMPLE_IDX, sample.Data());
|
|
||||||
|
|
||||||
fSample.SetString(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
// GetOrientation (public)
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
*/
|
|
||||||
TString TPsiRunHeader::GetOrientation() const
|
|
||||||
{
|
|
||||||
return GetInfoString(fOrientation);
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
// SetOrientation (public)
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
*
|
|
||||||
* \param orientation
|
|
||||||
*/
|
|
||||||
void TPsiRunHeader::SetOrientation(TString orientation)
|
|
||||||
{
|
|
||||||
char str[1024];
|
|
||||||
sprintf(str, "%02d - orientation: %s", TPRH_ORIENTATION_IDX, orientation.Data());
|
|
||||||
|
|
||||||
fOrientation.SetString(str);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
@ -382,15 +212,7 @@ void TPsiRunHeader::SetOrientation(TString orientation)
|
|||||||
*/
|
*/
|
||||||
void TPsiRunHeader::AddProperty(TPsiRunProperty &property)
|
void TPsiRunHeader::AddProperty(TPsiRunProperty &property)
|
||||||
{
|
{
|
||||||
TPsiRunProperty *prop = (TPsiRunProperty*) property.Clone();
|
fProperties.push_back(property);
|
||||||
fProperties.AddLast(prop);
|
|
||||||
|
|
||||||
char str[1024];
|
|
||||||
TObjString *tostr;
|
|
||||||
sprintf(str, "%02d - %s: %lf +- %lf (%s)", TPRH_OFFSET+fPropertiesList.GetLast(),
|
|
||||||
prop->GetName().GetString().Data(), prop->GetValue(), prop->GetError(), prop->GetUnit().GetString().Data());
|
|
||||||
tostr = new TObjString(str);
|
|
||||||
fPropertiesList.AddLast(tostr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
@ -406,17 +228,8 @@ void TPsiRunHeader::AddProperty(TPsiRunProperty &property)
|
|||||||
*/
|
*/
|
||||||
void TPsiRunHeader::AddProperty(TString name, Double_t value, Double_t error, TString unit)
|
void TPsiRunHeader::AddProperty(TString name, Double_t value, Double_t error, TString unit)
|
||||||
{
|
{
|
||||||
TPsiRunProperty prop(name, value, error, unit);
|
TPsiRunProperty property(name, value, error, unit);
|
||||||
TPsiRunProperty *p_prop = (TPsiRunProperty*) prop.Clone();
|
fProperties.push_back(property);
|
||||||
|
|
||||||
fProperties.AddLast(p_prop);
|
|
||||||
|
|
||||||
char str[1024];
|
|
||||||
TObjString *tostr;
|
|
||||||
sprintf(str, "%02d - %s: %lf +- %lf (%s)", TPRH_OFFSET+fPropertiesList.GetLast(),
|
|
||||||
name.Data(), value, error, unit.Data());
|
|
||||||
tostr = new TObjString(str);
|
|
||||||
fPropertiesList.AddLast(tostr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
@ -428,46 +241,43 @@ void TPsiRunHeader::AddProperty(TString name, Double_t value, Double_t error, TS
|
|||||||
void TPsiRunHeader::DumpHeader() const
|
void TPsiRunHeader::DumpHeader() const
|
||||||
{
|
{
|
||||||
int old_width = cout.width();
|
int old_width = cout.width();
|
||||||
TPsiRunProperty *prop;
|
|
||||||
|
|
||||||
// get maximal length of the property names
|
// get maximal length of the property names
|
||||||
int name_width = 8; // init to max. length of fixed names like: version, etc.
|
int name_width = 8; // init to max. length of fixed names like: version, etc.
|
||||||
for (Int_t i=0; i<=fProperties.GetLast(); i++) {
|
for (UInt_t i=0; i<fProperties.size(); i++) {
|
||||||
prop = (TPsiRunProperty*)(fProperties[i]);
|
if (fProperties[i].GetLabel().Length() > name_width)
|
||||||
if (prop->GetName().GetString().Length() > name_width)
|
name_width = fProperties[i].GetLabel().Length();
|
||||||
name_width = prop->GetName().GetString().Length();
|
|
||||||
}
|
}
|
||||||
name_width++;
|
name_width++;
|
||||||
|
|
||||||
// write SVN versions
|
// write SVN versions
|
||||||
cout << endl << setw(name_width) << left << "version" << setw(old_width) << ": " << GetVersion().Data();
|
cout << endl << setw(name_width) << left << "Version" << setw(old_width) << ": " << GetVersion().Data();
|
||||||
|
|
||||||
// write run title
|
// write run title
|
||||||
cout << endl << setw(name_width) << left << "run title" << setw(old_width) << ": " << GetRunTitle().Data();
|
cout << endl << setw(name_width) << left << "Run Title" << setw(old_width) << ": " << GetRunTitle().Data();
|
||||||
|
|
||||||
// write run number
|
// write run number
|
||||||
cout << endl << setw(name_width) << left << "run number" << setw(old_width) << ": " << GetRunNumber();
|
cout << endl << setw(name_width) << left << "Run Number" << setw(old_width) << ": " << GetRunNumber();
|
||||||
|
|
||||||
// write laboratory
|
// write laboratory
|
||||||
cout << endl << setw(name_width) << left << "laboratory" << setw(old_width) << ": " << GetLab().Data();
|
cout << endl << setw(name_width) << left << "Laboratory" << setw(old_width) << ": " << GetLab().Data();
|
||||||
|
|
||||||
// write instrument
|
// write instrument
|
||||||
cout << endl << setw(name_width) << left << "instrument" << setw(old_width) << ": " << GetInstrument().Data();
|
cout << endl << setw(name_width) << left << "Instrument" << setw(old_width) << ": " << GetInstrument().Data();
|
||||||
|
|
||||||
// write setup
|
// write setup
|
||||||
cout << endl << setw(name_width) << left << "setup" << setw(old_width) << ": " << GetSetup().Data();
|
cout << endl << setw(name_width) << left << "Setup" << setw(old_width) << ": " << GetSetup().Data();
|
||||||
|
|
||||||
// write sample
|
// write sample
|
||||||
cout << endl << setw(name_width) << left << "sample" << setw(old_width) << ": " << GetSample().Data();
|
cout << endl << setw(name_width) << left << "Sample" << setw(old_width) << ": " << GetSample().Data();
|
||||||
|
|
||||||
// write orientation
|
// write orientation
|
||||||
cout << endl << setw(name_width) << left << "orientation" << setw(old_width) << ": " << GetOrientation().Data();
|
cout << endl << setw(name_width) << left << "Orientation" << setw(old_width) << ": " << GetOrientation().Data();
|
||||||
|
|
||||||
for (Int_t i=0; i<=fProperties.GetLast(); i++) {
|
for (UInt_t i=0; i<fProperties.size(); i++) {
|
||||||
prop = (TPsiRunProperty*)(fProperties[i]);
|
cout << endl << setw(name_width) << left << fProperties[i].GetLabel().Data() << setw(old_width) << ": " << fProperties[i].GetValue() << " +- " << fProperties[i].GetError();
|
||||||
cout << endl << setw(name_width) << left << prop->GetName().GetString().Data() << setw(old_width) << ": " << prop->GetValue() << " +- " << prop->GetError();
|
if (fProperties[i].GetUnit().CompareTo("n/a", TString::kIgnoreCase)) {
|
||||||
if (prop->GetUnit().GetString().CompareTo("n/a", TString::kIgnoreCase)) {
|
cout << " " << fProperties[i].GetUnit().Data();
|
||||||
cout << " " << prop->GetUnit().GetString().Data();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cout << endl << endl;
|
cout << endl << endl;
|
||||||
@ -497,33 +307,27 @@ void TPsiRunHeader::DrawHeader() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
// GetInfoString (private)
|
// GetDecimalPlace (private)
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>Check decimal place of val. If val > 1.0, the function will return 0, otherwise
|
||||||
|
* the first decimal place found will be returned.
|
||||||
*
|
*
|
||||||
* \param tostr a TObjString with a content structure "%s: %s".
|
* \param val value from which the first significant digit shall be determined
|
||||||
*/
|
*/
|
||||||
TString TPsiRunHeader::GetInfoString(const TObjString &tostr) const
|
UInt_t TPsiRunHeader::GetDecimalPlace(Double_t val)
|
||||||
{
|
{
|
||||||
TObjArray *tokens = 0;
|
UInt_t digit = 0;
|
||||||
TObjString *ostr = 0;
|
|
||||||
TString str("??");
|
|
||||||
|
|
||||||
tokens = tostr.GetString().Tokenize(":");
|
if (val < 1.0) {
|
||||||
if (!tokens) { // couldn't get tokens
|
UInt_t count=1;
|
||||||
return str;
|
do {
|
||||||
}
|
val *= 10.0;
|
||||||
if (tokens->GetEntries() != 2) { // wrong number of tokens
|
if (val > 1.0)
|
||||||
delete tokens;
|
digit = count;
|
||||||
return str;
|
count++;
|
||||||
|
} while ((digit == 0) || (count > 20));
|
||||||
}
|
}
|
||||||
|
|
||||||
ostr = dynamic_cast<TObjString*>(tokens->At(1));
|
return digit;
|
||||||
str = ostr->GetString();
|
|
||||||
str.Remove(TString::kLeading, ' ');
|
|
||||||
|
|
||||||
delete tokens;
|
|
||||||
|
|
||||||
return str;
|
|
||||||
}
|
}
|
||||||
|
@ -40,29 +40,26 @@ class TPsiRunProperty : public TObject
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TPsiRunProperty();
|
TPsiRunProperty();
|
||||||
TPsiRunProperty(TObjString &name, Double_t value, Double_t error, TObjString &unit);
|
|
||||||
TPsiRunProperty(TString &name, Double_t value, Double_t error, TString &unit);
|
TPsiRunProperty(TString &name, Double_t value, Double_t error, TString &unit);
|
||||||
virtual ~TPsiRunProperty();
|
virtual ~TPsiRunProperty();
|
||||||
|
|
||||||
virtual TObjString GetName() { return fName; }
|
virtual TString GetLabel() const { return fLabel; }
|
||||||
virtual Double_t GetValue() { return fValue; }
|
virtual Double_t GetValue() const { return fValue; }
|
||||||
virtual Double_t GetError() { return fError; }
|
virtual Double_t GetError() const { return fError; }
|
||||||
virtual TObjString GetUnit() { return fUnit; }
|
virtual TString GetUnit() const { return fUnit; }
|
||||||
|
|
||||||
virtual void SetName(TObjString &name) { fName = name; }
|
virtual void SetLabel(TString &label) { fLabel = label; }
|
||||||
virtual void SetName(TString &name) { fName = name.Data(); }
|
virtual void SetLabel(const char *label) { fLabel = label; }
|
||||||
virtual void SetName(const char *name) { fName = name; }
|
|
||||||
virtual void SetValue(Double_t val) { fValue = val; }
|
virtual void SetValue(Double_t val) { fValue = val; }
|
||||||
virtual void SetError(Double_t err) { fError = err; }
|
virtual void SetError(Double_t err) { fError = err; }
|
||||||
virtual void SetUnit(TObjString &unit) { fUnit = unit; }
|
|
||||||
virtual void SetUnit(TString &unit) { fUnit = unit.Data(); }
|
virtual void SetUnit(TString &unit) { fUnit = unit.Data(); }
|
||||||
virtual void SetUnit(const char *unit) { fUnit = unit; }
|
virtual void SetUnit(const char *unit) { fUnit = unit; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TObjString fName;
|
TString fLabel;
|
||||||
Double_t fValue;
|
Double_t fValue;
|
||||||
Double_t fError;
|
Double_t fError;
|
||||||
TObjString fUnit;
|
TString fUnit;
|
||||||
|
|
||||||
ClassDef(TPsiRunProperty, 1)
|
ClassDef(TPsiRunProperty, 1)
|
||||||
};
|
};
|
||||||
@ -73,42 +70,46 @@ public:
|
|||||||
TPsiRunHeader();
|
TPsiRunHeader();
|
||||||
virtual ~TPsiRunHeader();
|
virtual ~TPsiRunHeader();
|
||||||
|
|
||||||
virtual TString GetVersion() const;
|
virtual TString GetVersion() const { return fVersion; }
|
||||||
virtual TString GetRunTitle() const;
|
virtual TString GetRunTitle() const { return fRunTitle; }
|
||||||
virtual Int_t GetRunNumber() const;
|
virtual Int_t GetRunNumber() const { return fRunNumber; }
|
||||||
virtual TString GetLab() const;
|
virtual TString GetLab() const { return fLaboratory; }
|
||||||
virtual TString GetInstrument() const;
|
virtual TString GetInstrument() const { return fInstrument; }
|
||||||
virtual TString GetSetup() const;
|
virtual TString GetSetup() const { return fSetup; }
|
||||||
virtual TString GetSample() const;
|
virtual TString GetSample() const { return fSample; }
|
||||||
virtual TString GetOrientation() const;
|
virtual TString GetOrientation() const { return fOrientation; }
|
||||||
virtual TObjArray *GetProperties() { return &fProperties; }
|
virtual vector<TPsiRunProperty> *GetProperties() { return &fProperties; }
|
||||||
|
|
||||||
virtual void SetRunTitle(TString runTitle);
|
virtual TObjArray *GetHeader();
|
||||||
virtual void SetRunNumber(Int_t runNumber);
|
|
||||||
virtual void SetLab(TString lab);
|
virtual void SetRunTitle(TString runTitle) { fRunTitle = runTitle; }
|
||||||
virtual void SetInstrument(TString insturment);
|
virtual void SetRunNumber(Int_t runNumber) { fRunNumber = runNumber; }
|
||||||
virtual void SetSetup(TString setup);
|
virtual void SetLab(TString lab) { fLaboratory = lab; }
|
||||||
virtual void SetSample(TString sample);
|
virtual void SetInstrument(TString insturment) { fInstrument = insturment; }
|
||||||
virtual void SetOrientation(TString setup);
|
virtual void SetSetup(TString setup) { fSetup = setup; }
|
||||||
|
virtual void SetSample(TString sample) { fSample = sample; }
|
||||||
|
virtual void SetOrientation(TString orientation) { fOrientation = orientation; }
|
||||||
virtual void AddProperty(TPsiRunProperty &property);
|
virtual void AddProperty(TPsiRunProperty &property);
|
||||||
virtual void AddProperty(TString name, Double_t value, Double_t error, TString unit);
|
virtual void AddProperty(TString name, Double_t value, Double_t error, TString unit);
|
||||||
|
|
||||||
|
|
||||||
virtual void DumpHeader() const;
|
virtual void DumpHeader() const;
|
||||||
virtual void DrawHeader() const;
|
virtual void DrawHeader() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TObjString fVersion; /// SVN version of the TPsiRunHeader
|
TString fVersion; /// SVN version of the TPsiRunHeader
|
||||||
TObjString fRunTitle; /// run title
|
TString fRunTitle; /// run title
|
||||||
TObjString fRunNumber; /// run number
|
Int_t fRunNumber; /// run number
|
||||||
TObjString fLaboratory; /// laboratory: PSI
|
TString fLaboratory; /// laboratory: PSI
|
||||||
TObjString fInstrument; /// instrument name like: GPS, LEM, ....
|
TString fInstrument; /// instrument name like: GPS, LEM, ....
|
||||||
TObjString fSetup; /// setup
|
TString fSetup; /// setup
|
||||||
TObjString fSample; /// sample name
|
TString fSample; /// sample name
|
||||||
TObjString fOrientation; /// sample orientation
|
TString fOrientation; /// sample orientation
|
||||||
TObjArray fPropertiesList;
|
vector<TPsiRunProperty> fProperties;
|
||||||
TObjArray fProperties;
|
|
||||||
|
|
||||||
virtual TString GetInfoString(const TObjString &tostr) const;
|
TObjArray fHeader; /// header as TObjString array for dumping into a ROOT file
|
||||||
|
|
||||||
|
UInt_t GetDecimalPlace(Double_t val);
|
||||||
|
|
||||||
ClassDef(TPsiRunHeader, 1)
|
ClassDef(TPsiRunHeader, 1)
|
||||||
};
|
};
|
||||||
|
@ -52,21 +52,10 @@ int main(int argc, char *argv[])
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
TFile *f = new TFile(argv[1], "RECREATE", "psi_runHeader_test");
|
// PSI Run Header object
|
||||||
if (f->IsZombie()) {
|
|
||||||
delete f;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// root file header related things
|
|
||||||
TFolder *runInfo = gROOT->GetRootFolder()->AddFolder("RunInfo", "PSI RunInfo");
|
|
||||||
gROOT->GetListOfBrowsables()->Add(runInfo, "RunInfo");
|
|
||||||
|
|
||||||
TPsiRunHeader *header = new TPsiRunHeader();
|
TPsiRunHeader *header = new TPsiRunHeader();
|
||||||
|
|
||||||
runInfo->Add(header); // add header to RunInfo folder
|
header->SetRunTitle("This is a run title");
|
||||||
|
|
||||||
header->SetRunTitle("This is a run title");
|
|
||||||
header->SetRunNumber(12345);
|
header->SetRunNumber(12345);
|
||||||
header->SetLab("PSI");
|
header->SetLab("PSI");
|
||||||
header->SetInstrument("LEM");
|
header->SetInstrument("LEM");
|
||||||
@ -76,12 +65,21 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
header->AddProperty("T0", 30.01, 0.05, "K");
|
header->AddProperty("T0", 30.01, 0.05, "K");
|
||||||
header->AddProperty("T1", 30.03, 0.03, "K");
|
header->AddProperty("T1", 30.03, 0.03, "K");
|
||||||
header->AddProperty("Field", 3.03, 0.03, "T");
|
header->AddProperty("Field", 3.00003, 0.0003, "T");
|
||||||
|
header->AddProperty("BigError", 13.2, 1.2, "Something");
|
||||||
header->AddProperty("ThisIsAVeryLongPropertyName", 3.03, 0.03, "SI-Unit");
|
header->AddProperty("ThisIsAVeryLongPropertyName", 3.03, 0.03, "SI-Unit");
|
||||||
|
|
||||||
header->DumpHeader();
|
header->DumpHeader();
|
||||||
|
|
||||||
runInfo->Write();
|
TFile *f = new TFile(argv[1], "RECREATE", "psi_runHeader_test");
|
||||||
|
if (f->IsZombie()) {
|
||||||
|
delete f;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
f->mkdir("RunHeader");
|
||||||
|
f->cd("RunHeader");
|
||||||
|
header->GetHeader()->Write();
|
||||||
|
|
||||||
f->Close();
|
f->Close();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user