-
-ClassImp(TMusrRunPhysicalQuantity)
-
-//--------------------------------------------------------------------------
-// Constructor
-//--------------------------------------------------------------------------
-/**
- * Constructor.
- */
-TMusrRunPhysicalQuantity::TMusrRunPhysicalQuantity()
-{
- fLabel = "n/a";
- fDemand = MRH_UNDEFINED;
- fValue = MRH_UNDEFINED;
- fError = MRH_UNDEFINED;
- fUnit = "n/a";
- fDescription = "n/a";
-}
-
-//--------------------------------------------------------------------------
-// Constructor
-//--------------------------------------------------------------------------
-/**
- *
Constructor.
- *
- * \param label of the physical quantity, e.g. 'Sample Temperature'
- * \param demand value of the physical quantity
- * \param value measured value of the physical quantity
- * \param error estimated error of the physical quantity
- * \param unit of the physical quantity, e.g. 'K'.
- * \param description additional more detailed description of the physical quantity
- */
-TMusrRunPhysicalQuantity::TMusrRunPhysicalQuantity(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;
-}
-
-//--------------------------------------------------------------------------
-// Constructor
-//--------------------------------------------------------------------------
-/**
- *
Constructor.
- *
- * \param label of the physical quantity, e.g. 'Sample Temperature'
- * \param demand value of the physical quantity
- * \param value measured value of the physical quantity
- * \param unit of the physical quantity, e.g. 'K'.
- * \param description additional more detailed description of the physical quantity
- */
-TMusrRunPhysicalQuantity::TMusrRunPhysicalQuantity(TString label, Double_t demand, Double_t value, TString unit, TString description) :
- fLabel(label), fDemand(demand), fValue(value), fUnit(unit)
-{
- fError = MRH_UNDEFINED;
- if (description.IsWhitespace())
- fDescription = "n/a";
- else
- fDescription = description;
-}
-
-//--------------------------------------------------------------------------
-// Constructor
-//--------------------------------------------------------------------------
-/**
- *
Constructor.
- *
- * \param label of the physical quantity, e.g. 'Sample Temperature'
- * \param value measured value of the physical quantity
- * \param unit of the physical quantity, e.g. 'K'.
- * \param description additional more detailed description of the physical quantity
- */
-TMusrRunPhysicalQuantity::TMusrRunPhysicalQuantity(TString label, Double_t value, TString unit, TString description) :
- fLabel(label), fValue(value), fUnit(unit)
-{
- fDemand = MRH_UNDEFINED;
- fError = MRH_UNDEFINED;
- if (description.IsWhitespace())
- fDescription = "n/a";
- else
- fDescription = description;
-}
-
-//--------------------------------------------------------------------------
-// Set (public)
-//--------------------------------------------------------------------------
-/**
- *
set a physical quantity.
- *
- * \param label of the physical quantity, e.g. 'Sample Temperature'
- * \param demand value of the physical quantity
- * \param value measured value of the physical quantity
- * \param error estimated error of the physical quantity
- * \param unit of the physical quantity, e.g. 'K'.
- * \param description additional more detailed description of the physical quantity
- */
-void TMusrRunPhysicalQuantity::Set(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;
-}
-
-//--------------------------------------------------------------------------
-// Set (public)
-//--------------------------------------------------------------------------
-/**
- *
set a physical quantity.
- *
- * \param label of the physical quantity, e.g. 'Sample Temperature'
- * \param demand value of the physical quantity
- * \param value measured value of the physical quantity
- * \param unit of the physical quantity, e.g. 'K'.
- * \param description additional more detailed description of the physical quantity
- */
-void TMusrRunPhysicalQuantity::Set(TString label, Double_t demand, Double_t value, TString unit, TString description)
-{
- fLabel = label;
- fDemand = demand;
- fValue = value;
- fError = MRH_UNDEFINED;
- fUnit = unit;
- if (description.IsWhitespace())
- fDescription = "n/a";
- else
- fDescription = description;
-}
-
-//--------------------------------------------------------------------------
-// Set (public)
-//--------------------------------------------------------------------------
-/**
- *
set a physical quantity.
- *
- * \param label of the physical quantity, e.g. 'Sample Temperature'
- * \param value measured value of the physical quantity
- * \param unit of the physical quantity, e.g. 'K'.
- * \param description additional more detailed description of the physical quantity
- */
-void TMusrRunPhysicalQuantity::Set(TString label, Double_t value, TString unit, TString description)
-{
- fLabel = label;
- fDemand = MRH_UNDEFINED;
- fValue = value;
- fError = MRH_UNDEFINED;
- fUnit = unit;
- if (description.IsWhitespace())
- fDescription = "n/a";
- else
- fDescription = description;
-}
-
-//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
-ClassImp(TMusrRunHeader)
-
-//--------------------------------------------------------------------------
-// Constructor
-//--------------------------------------------------------------------------
-/**
- *
Constructor.
- *
- * \param quite if set to true, warnings will be omited. Default is false.
- */
-TMusrRunHeader::TMusrRunHeader(bool quite) : fQuite(quite)
-{
- Init();
-}
-
-//--------------------------------------------------------------------------
-// Constructor
-//--------------------------------------------------------------------------
-/**
- *
Constructor.
- *
- * \param fileName file name of the MusrRoot file.
- * \param quite if set to true, warnings will be omited. Default is false.
- */
-TMusrRunHeader::TMusrRunHeader(const char *fileName, bool quite)
-{
- fQuite = quite;
- Init(TString(fileName));
-}
-
-//--------------------------------------------------------------------------
-// Init (private)
-//--------------------------------------------------------------------------
-/**
- *
Initializer
- *
- * \param fileName file name of the caller.
- */
-void TMusrRunHeader::Init(TString fileName)
-{
- fFileName = fileName;
- fVersion = TString("$Id$");
- Set("RunInfo/Version", fVersion);
- Set("RunInfo/Generic Validator URL", "http://lmu.web.psi.ch/facilities/software/MusrRoot/validation/MusrRoot.xsd");
- Set("DetectorInfo/Detector000/Name", "n/a");
- Set("SampleEnvironmentInfo/Cryo", "n/a");
- Set("MagneticFieldEnvironmentInfo/Magnet Name", "n/a");
- Set("BeamlineInfo/Name", "n/a");
-}
-
-//--------------------------------------------------------------------------
-// Destructor
-//--------------------------------------------------------------------------
-/**
- *
Destructor.
- */
-TMusrRunHeader::~TMusrRunHeader()
-{
- CleanUp();
-}
-
-//--------------------------------------------------------------------------
-// CleanUp (private)
-//--------------------------------------------------------------------------
-/**
- *
Clean up internal stuff.
- */
-void TMusrRunHeader::CleanUp()
-{
- fStringObj.clear();
- fIntObj.clear();
- fDoubleObj.clear();
- fMusrRunPhysQuantityObj.clear();
- fStringVectorObj.clear();
- fIntVectorObj.clear();
- fDoubleVectorObj.clear();
-
- fPathNameOrder.clear();
-}
-
-//--------------------------------------------------------------------------
-// FillFolder (public)
-//--------------------------------------------------------------------------
-/**
- *
Fills the RunHeader folder. This is needed to write it to a ROOT file.
- * It walks through all information and attaches it to the folder or replaces
- * it, if it is already present.
- *
- * \param folder to be filled
- */
-Bool_t TMusrRunHeader::FillFolder(TFolder *folder)
-{
- TObjArray *oarray;
- TObjString ostr, *p_ostr;
- TString path, name, str;
- Ssiz_t pos=0;
- bool found=false;
-
- if (folder == 0) {
- cerr << endl << ">> TMusrRunHeader::FillFolder(): **ERROR** folder == 0!!" << endl;
- return false;
- }
-
- folder->SetOwner(); // folder takes ownership of all added objects! This means that the folder object does the cleanup
-
- // update/generate tree structure in folder
- for (UInt_t i=0; i> TMusrRunHeader::FillFolder(): **ERROR** somethig is wrong with the path=" << path << " !!" << endl;
- return false;
- }
- path.Remove(pos); // remove the value from the path
-
- oarray = (TObjArray*)FindObject(folder, path);
- if (!oarray) {
- cerr << endl << ">> TMusrRunHeader::FillFolder(): **ERROR** couldn't create header structure!!" << endl;
- return false;
- }
-
- // check if is already found in oarray
- ostr = GetHeaderString(i); // encode the string for the MusrRoot file
- name = ostr.GetString(); // convert to TString
- str = GetFirst(name, ':'); // get the first part of the encoded string, i.e. -
- found = false;
- for (Int_t j=0; jGetEntriesFast(); j++) {
- p_ostr = (TObjString*) oarray->At(j);
- if (p_ostr->GetString().BeginsWith(str)) { // present hence replace
- oarray->AddAt(ostr.Clone(), j);
- found = true;
- break;
- }
- }
- if (!found) {
- oarray->AddLast(ostr.Clone());
- }
- }
-
- return true;
-}
-
-//--------------------------------------------------------------------------
-// GetValue (public)
-//--------------------------------------------------------------------------
-/**
- * Get TString 'value'.
- *
- * \param pathName path/name within the header, e.g. RunInfo/Run Title
- * \param value TString return value
- * \param ok flag telling if the TString value was found
- */
-void TMusrRunHeader::GetValue(TString pathName, TString &value, Bool_t &ok)
-{
- ok = false;
-
- for (UInt_t i=0; iGet Int_t 'value'.
- *
- * \param pathName path/name within the header, e.g. RunInfo/Run Number
- * \param value Int_t return value
- * \param ok flag telling if the Int_t value was found
- */
-void TMusrRunHeader::GetValue(TString pathName, Int_t &value, Bool_t &ok)
-{
- ok = false;
-
- for (UInt_t i=0; iGet Double_t 'value'.
- *
- * \param pathName path/name within the header, e.g. RunInfo/Time Zero Bin
- * \param value Double_t return value
- * \param ok flag telling if the Double_t value was found
- */
-void TMusrRunHeader::GetValue(TString pathName, Double_t &value, Bool_t &ok)
-{
- ok = false;
-
- for (UInt_t i=0; iGet TMusrRunPhysicalQuantity 'value'.
- *
- * \param pathName path/name within the header, e.g. RunInfo/Run Title
- * \param value TMusrRunPhysicalQuantity return value
- * \param ok flag telling if the TMusrRunPhysicalQuantity value was found
- */
-void TMusrRunHeader::GetValue(TString pathName, TMusrRunPhysicalQuantity &value, Bool_t &ok)
-{
- ok = false;
-
- for (UInt_t i=0; iGet TStringVector 'value'.
- *
- * \param pathName path/name within the header, e.g. RunInfo/Run Title
- * \param value TStringVector return value
- * \param ok flag telling if the TStringVector value was found
- */
-void TMusrRunHeader::GetValue(TString pathName, TStringVector &value, Bool_t &ok)
-{
- ok = false;
-
- for (UInt_t i=0; iGet TIntVector 'value'.
- *
- * \param pathName path/name within the header, e.g. RunInfo/Run Title
- * \param value TIntVector return value
- * \param ok flag telling if the TIntVector value was found
- */
-void TMusrRunHeader::GetValue(TString pathName, TIntVector &value, Bool_t &ok)
-{
- ok = false;
-
- for (UInt_t i=0; iGet TDoubleVector 'value'.
- *
- * \param pathName path/name within the header, e.g. RunInfo/Run Title
- * \param value TDoubleVector return value
- * \param ok flag telling if the TDoubleVector value was found
- */
-void TMusrRunHeader::GetValue(TString pathName, TDoubleVector &value, Bool_t &ok)
-{
- ok = false;
-
- for (UInt_t i=0; iSet TString 'value'.
- *
- * \param pathName path/name within the header, e.g. RunInfo/Run Title
- * \param value of the entry
- */
-void TMusrRunHeader::Set(TString pathName, TString value)
-{
- // check if pathName is already set, if not add it as a new entry, otherwise replace it
- UInt_t i=0;
- for (i=0; i> **WARNING** " << pathName.Data() << " already exists, will replace it." << endl;
- fStringObj[i].SetType("TString");
- fStringObj[i].SetValue(value);
- break;
- }
- }
-
- // if not found in the previous loop, it is a new object
- if (i == fStringObj.size()) {
- // feed object
- TMusrRunObject obj(pathName, "TString", value);
- fStringObj.push_back(obj);
-
- // feed path-name to keep track of the order
- fPathNameOrder.push_back(pathName);
- }
-}
-
-//--------------------------------------------------------------------------
-// Set (public)
-//--------------------------------------------------------------------------
-/**
- * Set Int_t 'value'.
- *
- * \param pathName path/name within the header, e.g. RunInfo/Run number
- * \param value of the entry
- */
-void TMusrRunHeader::Set(TString pathName, Int_t value)
-{
- // check if pathName is already set, if not add it as a new entry, otherwise replace it
- UInt_t i=0;
- for (i=0; i> **WARNING** " << pathName.Data() << " already exists, will replace it." << endl;
- fIntObj[i].SetType("Int_t");
- fIntObj[i].SetValue(value);
- break;
- }
- }
-
- // if not found in the previous loop, it is a new object
- if (i == fIntObj.size()) {
- // feed object
- TMusrRunObject obj(pathName, "Int_t", value);
- fIntObj.push_back(obj);
-
- // feed path-name to keep track of the order
- fPathNameOrder.push_back(pathName);
- }
-}
-
-//--------------------------------------------------------------------------
-// Set (public)
-//--------------------------------------------------------------------------
-/**
- * Set Double_t 'value'.
- *
- * \param pathName path/name within the header, e.g. RunInfo/DoubleValue
- * \param value of the entry
- */
-void TMusrRunHeader::Set(TString pathName, Double_t value)
-{
- // check if pathName is already set, if not add it as a new entry, otherwise replace it
- UInt_t i=0;
- for (i=0; i> **WARNING** " << pathName.Data() << " already exists, will replace it." << endl;
- fDoubleObj[i].SetType("Double_t");
- fDoubleObj[i].SetValue(value);
- break;
- }
- }
-
- // if not found in the previous loop, it is a new object
- if (i == fDoubleObj.size()) {
- // feed object
- TMusrRunObject obj(pathName, "Double_t", value);
- fDoubleObj.push_back(obj);
-
- // feed path-name to keep track of the order
- fPathNameOrder.push_back(pathName);
- }
-}
-
-//--------------------------------------------------------------------------
-// Set (public)
-//--------------------------------------------------------------------------
-/**
- * Set TMusrRunPhysicalQuantity 'value'.
- *
- * \param pathName path/name within the header, e.g. RunInfo/Muon Beam Momentum
- * \param value of the entry
- */
-void TMusrRunHeader::Set(TString pathName, TMusrRunPhysicalQuantity value)
-{
- // check if pathName is already set, if not add it as a new entry, otherwise replace it
- UInt_t i=0;
- for (i=0; i> **WARNING** " << pathName.Data() << " already exists, will replace it." << endl;
- fMusrRunPhysQuantityObj[i].SetType("TMusrRunHeader");
- fMusrRunPhysQuantityObj[i].SetValue(value);
- break;
- }
- }
-
- // if not found in the previous loop, it is a new object
- if (i == fMusrRunPhysQuantityObj.size()) {
- // feed object
- TMusrRunObject obj(pathName, "TMusrRunPhysicalQuantity", value);
- fMusrRunPhysQuantityObj.push_back(obj);
-
- // feed path-name to keep track of the order
- fPathNameOrder.push_back(pathName);
- }
-}
-
-//--------------------------------------------------------------------------
-// Set (public)
-//--------------------------------------------------------------------------
-/**
- * Set TStringVector 'value'.
- *
- * \param pathName path/name within the header, e.g. RunInfo/Histo names
- * \param value of the entry
- */
-void TMusrRunHeader::Set(TString pathName, TStringVector value)
-{
- // check if pathName is already set, if not add it as a new entry, otherwise replace it
- UInt_t i=0;
- for (i=0; i> **WARNING** " << pathName.Data() << " already exists, will replace it." << endl;
- fStringVectorObj[i].SetType("TStringVector");
- fStringVectorObj[i].SetValue(value);
- break;
- }
- }
-
- // if not found in the previous loop, it is a new object
- if (i == fStringVectorObj.size()) {
- // feed object
- TMusrRunObject obj(pathName, "TStringVector", value);
- fStringVectorObj.push_back(obj);
-
- // feed path-name to keep track of the order
- fPathNameOrder.push_back(pathName);
- }
-}
-
-//--------------------------------------------------------------------------
-// Set (public)
-//--------------------------------------------------------------------------
-/**
- * Set TIntVector 'value'.
- *
- * \param pathName path/name within the header, e.g. RunInfo/Time Zero Bin
- * \param value of the entry
- */
-void TMusrRunHeader::Set(TString pathName, TIntVector value)
-{
- // check if pathName is already set, if not add it as a new entry, otherwise replace it
- UInt_t i=0;
- for (i=0; i> **WARNING** " << pathName.Data() << " already exists, will replace it." << endl;
- fIntVectorObj[i].SetType("TIntVector");
- fIntVectorObj[i].SetValue(value);
- break;
- }
- }
-
- // if not found in the previous loop, it is a new object
- if (i == fIntVectorObj.size()) {
- // feed object
- TMusrRunObject obj(pathName, "TIntVector", value);
- fIntVectorObj.push_back(obj);
-
- // feed path-name to keep track of the order
- fPathNameOrder.push_back(pathName);
- }
-}
-
-//--------------------------------------------------------------------------
-// Set (public)
-//--------------------------------------------------------------------------
-/**
- * Set TDoubleVector 'value'.
- *
- * \param pathName path/name within the header, e.g. RunInfo/Time Zero Bin
- * \param value of the entry
- */
-void TMusrRunHeader::Set(TString pathName, TDoubleVector value)
-{
- // check if pathName is already set, if not add it as a new entry, otherwise replace it
- UInt_t i=0;
- for (i=0; i> **WARNING** " << pathName.Data() << " already exists, will replace it." << endl;
- fDoubleVectorObj[i].SetType("TDoubleVector");
- fDoubleVectorObj[i].SetValue(value);
- break;
- }
- }
-
- // if not found in the previous loop, it is a new object
- if (i == fDoubleVectorObj.size()) {
- // feed object
- TMusrRunObject obj(pathName, "TDoubleVector", value);
- fDoubleVectorObj.push_back(obj);
-
- // feed path-name to keep track of the order
- fPathNameOrder.push_back(pathName);
- }
-}
-
-
-//--------------------------------------------------------------------------
-// ExtractAll (public)
-//--------------------------------------------------------------------------
-/**
- * Reads all data from an open ROOT-file structure and feeds all the necessary
- * internal data objects.
- *
- * \param folder
- */
-Bool_t TMusrRunHeader::ExtractAll(TFolder *folder)
-{
- TIter next(folder->GetListOfFolders());
- TObjArray* entry;
-
- // clean up all internal structures - just in case this is called multiple times
- CleanUp();
-
- while ((entry = (TObjArray*)next())) {
- ExtractHeaderInformation(entry, entry->GetName());
- }
- return true;
-}
-
-//--------------------------------------------------------------------------
-// ExtractHeaderInformation (public)
-//--------------------------------------------------------------------------
-/**
- *
- *
- * \param headerInfo
- * \param requestedPath
- */
-Bool_t TMusrRunHeader::ExtractHeaderInformation(TObjArray *headerInfo, TString requestedPath)
-{
- TString label(""), path(""), pathName(""), str(""), strValue(""), type("");
- TObjString *ostr = 0;
- TObjArray *tokens = 0;
- Ssiz_t idx1;
- Int_t intValue;
- Double_t dval;
-
- // go through all entries of this header information from the MUSR-ROOT file
- for (Int_t i=0; iGetEntries(); i++) {
- // check if entry is a TObjArray, i.e. a sub tree
- str = TString(headerInfo->At(i)->ClassName());
- if (str == "TObjArray") { // sub tree
- path = requestedPath + "/" + TString(headerInfo->At(i)->GetName());
- ExtractHeaderInformation((TObjArray*)headerInfo->At(i), path);
- } else { // handle all the rest, i.e. already data
-
- ostr = dynamic_cast(headerInfo->At(i));
- str = ostr->GetString();
-
- // get the run header label
- label = GetLabel(str);
- if (label == "n/a")
- return false;
-
- // get the run header 'value'
- strValue = GetStrValue(str);
- if (strValue == "n/a")
- return false;
-
- // construct path name
- pathName = requestedPath + TString("/") + label;
-
- // get type from map
- type = GetType(str);
-
- if (type == "TString") {
- Set(pathName, strValue);
- } else if (type == "Int_t") {
- intValue = strValue.Atoi();
- Set(pathName, intValue);
- } else if (type == "Double_t") {
- dval = strValue.Atof();
- Set(pathName, dval);
- } else if (type == "TMusrRunPhysicalQuantity") {
- TMusrRunPhysicalQuantity prop;
- prop.SetLabel(label);
-
- // 1st get the description if present
- tokens = strValue.Tokenize(";");
- if (tokens == 0) {
- cerr << endl << ">> **ERROR** Couldn't tokenize entry in Bool_t TMusrRunHeader::ExtractHeaderInformation(TObjArray *headerInfo, TString requestedPath)" << endl;
- return false;
- }
-
- switch (tokens->GetEntries()) {
- case 2:
- ostr = dynamic_cast(tokens->At(1));
- str = ostr->GetString();
- if (!str.Contains("SP:")) { // make sure that it is not a demand value token
- prop.SetDescription(str);
- }
- break;
- case 3:
- ostr = dynamic_cast(tokens->At(2));
- str = ostr->GetString();
- break;
- default:
- break;
- }
-
- if (tokens) {
- delete tokens;
- tokens = 0;
- }
-
- // 2nd collect all the other properties, this is easier when first a potential description is removed
- idx1 = strValue.Last(';');
- if (idx1 > 0) {
- TString last("");
- for (Int_t i=idx1+2; i or SP:
- if (!last.Contains("SP:")) {
- str = "";
- for (Int_t i=0; i> **ERROR** Couldn't tokenize entry in Bool_t TMusrRunHeader::ExtractHeaderInformation(TObjArray *headerInfo, TString requestedPath)" << endl;
- return false;
- }
-
- switch (tokens->GetEntries()) {
- case 2: //
- ostr = dynamic_cast(tokens->At(0));
- str = ostr->GetString();
- prop.SetValue(str.Atof());
- ostr = dynamic_cast(tokens->At(1));
- str = ostr->GetString();
- prop.SetUnit(str);
- break;
- case 4: // +- , or ; SP:
- ostr = dynamic_cast(tokens->At(0));
- str = ostr->GetString();
- prop.SetValue(str.Atof());
- ostr = dynamic_cast(tokens->At(1));
- str = ostr->GetString();
- if (str == "-") { // +-
- ostr = dynamic_cast(tokens->At(2));
- str = ostr->GetString();
- prop.SetError(str.Atof());
- ostr = dynamic_cast(tokens->At(3));
- str = ostr->GetString();
- prop.SetUnit(str);
- } else { // ; SP:
- prop.SetUnit(str);
- ostr = dynamic_cast(tokens->At(3));
- str = ostr->GetString();
- prop.SetDemand(str.Atof());
- }
- break;
- case 6: // +- ; SP:
- ostr = dynamic_cast(tokens->At(0));
- str = ostr->GetString();
- prop.SetValue(str.Atof());
- ostr = dynamic_cast(tokens->At(2));
- str = ostr->GetString();
- prop.SetError(str.Atof());
- ostr = dynamic_cast(tokens->At(3));
- str = ostr->GetString();
- prop.SetUnit(str);
- ostr = dynamic_cast(tokens->At(5));
- str = ostr->GetString();
- prop.SetDemand(str.Atof());
- break;
- default:
- break;
- }
-
- if (tokens) {
- delete tokens;
- tokens = 0;
- }
-
- Set(pathName, prop);
- } else if (type == "TStringVector") {
- TStringVector svec;
- tokens = strValue.Tokenize(";");
- if (tokens == 0) {
- cerr << endl << ">> **ERROR** Couldn't tokenize entry in Bool_t TMusrRunHeader::ExtractHeaderInformation(TObjArray *headerInfo, TString requestedPath)" << endl;
- return false;
- }
- for (Int_t i=0; iGetEntries(); i++) {
- ostr = dynamic_cast(tokens->At(i));
- str = ostr->GetString();
- str.Remove(TString::kBoth, ' ');
- svec.push_back(str);
- }
- if (tokens) {
- delete tokens;
- tokens = 0;
- }
- Set(pathName, svec);
- } else if (type == "TIntVector") {
- TIntVector ivec;
- tokens = strValue.Tokenize(";");
- if (tokens == 0) {
- cerr << endl << ">> **ERROR** Couldn't tokenize entry in Bool_t TMusrRunHeader::ExtractHeaderInformation(TObjArray *headerInfo, TString requestedPath)" << endl;
- return false;
- }
- for (Int_t i=0; iGetEntries(); i++) {
- ostr = dynamic_cast(tokens->At(i));
- ivec.push_back(ostr->GetString().Atoi());
- }
- if (tokens) {
- delete tokens;
- tokens = 0;
- }
- Set(pathName, ivec);
- } else if (type == "TDoubleVector") {
- TDoubleVector dvec;
- tokens = strValue.Tokenize(";");
- if (tokens == 0) {
- cerr << endl << ">> **ERROR** Couldn't tokenize entry in Bool_t TMusrRunHeader::ExtractHeaderInformation(TObjArray *headerInfo, TString requestedPath)" << endl;
- return false;
- }
- for (Int_t i=0; iGetEntries(); i++) {
- ostr = dynamic_cast(tokens->At(i));
- dvec.push_back(ostr->GetString().Atoi());
- }
- if (tokens) {
- delete tokens;
- tokens = 0;
- }
- Set(pathName, dvec);
- }
- }
- }
-
- return true;
-}
-
-//--------------------------------------------------------------------------
-// DumpHeader (public)
-//--------------------------------------------------------------------------
-/**
- *
- */
-void TMusrRunHeader::DumpHeader()
-{
- cout << endl << "***************************************";
- cout << endl << "header info of file : " << fFileName;
- cout << endl << "***************************************";
-
- TString str(""), tstr(""), fmt(""), path(""), name(""), currentPath("");
- TMusrRunPhysicalQuantity prop;
-
- for (UInt_t i=0; i +- ; SP: [; ]
- digit = GetDecimalPlace(prop.GetError());
- digit_d = GetLeastSignificantDigit(prop.GetDemand());
- if (prop.GetDescription() != "n/a") {
- fmt.Form("%%s: %%.%dlf +- %%.%dlf %%s; SP: %%.%dlf; %%s", digit, digit, digit_d);
-
- tstr.Form(fmt, prop.GetLabel().Data(), prop.GetValue(), prop.GetError(), prop.GetUnit().Data(), prop.GetDemand(), prop.GetDescription().Data());
- } else {
- fmt.Form("%%s: %%.%dlf +- %%.%dlf %%s; SP: %%.%dlf", digit, digit, digit_d);
- tstr.Form(fmt, prop.GetLabel().Data(), prop.GetValue(), prop.GetError(), prop.GetUnit().Data(), prop.GetDemand());
- }
- } else if ((prop.GetDemand() == MRH_UNDEFINED) && (prop.GetValue() != MRH_UNDEFINED) && (prop.GetError() != MRH_UNDEFINED) &&
- (prop.GetUnit() != "n/a")) { // +- [; ]
- digit = GetDecimalPlace(prop.GetError());
- if (prop.GetDescription() != "n/a") {
- fmt.Form("%%s: %%.%dlf +- %%.%dlf %%s; %%s", digit, digit);
- tstr.Form(fmt, prop.GetLabel().Data(), prop.GetValue(), prop.GetError(), prop.GetUnit().Data(), prop.GetDescription().Data());
- } else {
- fmt.Form("%%s: %%.%dlf +- %%.%dlf %%s", digit, digit);
- tstr.Form(fmt, prop.GetLabel().Data(), prop.GetValue(), prop.GetError(), prop.GetUnit().Data());
- }
- } else if ((prop.GetDemand() == MRH_UNDEFINED) && (prop.GetValue() != MRH_UNDEFINED) && (prop.GetError() == MRH_UNDEFINED) &&
- (prop.GetUnit() != "n/a")) { // [; ]
- digit = GetLeastSignificantDigit(prop.GetValue());
- if (prop.GetDescription() != "n/a") {
- fmt.Form("%%s: %%.%dlf %%s; %%s", digit);
- tstr.Form(fmt, prop.GetLabel().Data(), prop.GetValue(), prop.GetUnit().Data(), prop.GetDescription().Data());
- } else {
- fmt.Form("%%s: %%.%dlf %%s", digit);
- tstr.Form(fmt, prop.GetLabel().Data(), prop.GetValue(), prop.GetUnit().Data());
- }
- } else if ((prop.GetDemand() != MRH_UNDEFINED) && (prop.GetValue() != MRH_UNDEFINED) && (prop.GetError() == MRH_UNDEFINED) &&
- (prop.GetUnit() != "n/a")) { // ; SP: [; ]
- digit = GetLeastSignificantDigit(prop.GetValue());
- digit_d = GetLeastSignificantDigit(prop.GetDemand());
- if (prop.GetDescription() != "n/a") {
- fmt.Form("%%s: %%.%dlf %%s; SP: %%.%dlf; %%s", digit, digit_d);
- tstr.Form(fmt, prop.GetLabel().Data(), prop.GetValue(), prop.GetUnit().Data(), prop.GetDemand(), prop.GetDescription().Data());
- } else {
- fmt.Form("%%s: %%.%dlf %%s; SP: %%.%dlf", digit, digit_d);
- tstr.Form(fmt, prop.GetLabel().Data(), prop.GetValue(), prop.GetUnit().Data(), prop.GetDemand());
- }
- }
- str.Form(" %03d - %s -@%d", i, tstr.Data(), MRH_TMUSR_RUN_PHYSICAL_QUANTITY);
- cout << endl << str;
- }
- }
- // 5th check TStringVector
- for (UInt_t j=0; j
- */
-void TMusrRunHeader::DrawHeader()
-{
- TPaveText *pt;
- TCanvas *ca;
-
- ca = new TCanvas("MusrRoot RunHeader","MusrRoot RunHeader", 147,37,699,527);
- ca->Range(0., 0., 100., 100.);
-
- pt = new TPaveText(10.,10.,90.,90.,"br");
- pt->SetFillColor(19);
- pt->SetTextAlign(12);
-
- pt->Draw();
-
- ca->Modified(kTRUE);
-}
-
-//--------------------------------------------------------------------------
-// GetDecimalPlace (private)
-//--------------------------------------------------------------------------
-/**
- * Check decimal place of val. If val > 1.0, the function will return 0, otherwise
- * the first decimal place found will be returned.
- *
- * \param val value from which the first significant digit shall be determined
- */
-UInt_t TMusrRunHeader::GetDecimalPlace(Double_t val)
-{
- UInt_t digit = 0;
-
- if (val < 1.0) {
- UInt_t count=1;
- do {
- val *= 10.0;
- if (val > 1.0)
- digit = count;
- count++;
- } while ((digit == 0) && (count < 20));
- }
-
- return digit;
-}
-
-//--------------------------------------------------------------------------
-// GetLeastSignificantDigit (private)
-//--------------------------------------------------------------------------
-/**
- *
returns the number of significant digits
- *
- * \param val value from which the lowest significant digit shall be determined
- */
-UInt_t TMusrRunHeader::GetLeastSignificantDigit(Double_t val) const
-{
- char cstr[1024];
- snprintf(cstr, sizeof(cstr), "%.10lf", val);
-
- int i=0, j=0;
- for (i=strlen(cstr)-1; i>=0; i--) {
- if (cstr[i] != '0')
- break;
- }
-
- for (j=strlen(cstr)-1; j>=0; j--) {
- if (cstr[j] == '.')
- break;
- }
- if (j==0) // no decimal point present, e.g. 321
- j=i;
-
- return i-j;
-}
-
-//--------------------------------------------------------------------------
-// SplitPathName (private)
-//--------------------------------------------------------------------------
-/**
- *
splits a path name string into the path and the name.
- *
- * \param pathName path name to be split
- * \param path of pathName
- * \param name of pathName
- */
-void TMusrRunHeader::SplitPathName(TString pathName, TString &path, TString &name)
-{
- path = TString("");
- name = TString("");
- Ssiz_t idx = pathName.Last('/');
-
- for (Int_t i=0; iextracts form the run header line, as written to the MusrROOT file, the run header label, e.g. Run Number.
- *
- * \param str runHeader string as written to the MusrROOT file.
- */
-TString TMusrRunHeader::GetLabel(TString str)
-{
- // get run header label
- // the string 'str' should have the structure
- // - : -@
-
- TString label = TString("n/a");
- Ssiz_t idx1 = str.First('-');
- Ssiz_t idx2 = str.First(':');
- if ((idx1 == -1) || (idx2 == -1)) {
- cerr << endl << ">> TMusrRunHeader::GetLabel(): **ERROR** str='" << str << "', seems not correctly encoded." << endl;
- return label;
- }
-
- label = TString("");
- for (Int_t j=idx1+2; jextracts form the run header line, as written to the MusrROOT file, the run header str value, e.g. 557 (for Run Number).
- *
- * \param str runHeader string as written to the MusrROOT file.
- */
-TString TMusrRunHeader::GetStrValue(TString str)
-{
- // get run header string value
- // the string 'str' should have the structure
- // - : -@
-
- TString strValue = TString("n/a");
- Ssiz_t idx1 = str.First(':');
- Ssiz_t idx2 = str.Last('-');
- if ((idx1 == -1) || (idx2 == -1)) {
- cerr << endl << ">> TMusrRunHeader::GetStrValue(): **ERROR** str='" << str << "', seems not correctly encoded." << endl;
- return strValue;
- }
-
- strValue = TString("");
- for (Int_t j=idx1+2; jextracts form the run header line, as written to the MusrROOT file, the encoded type and retruns it.
- *
- * \param str runHeader string with encoded type
- */
-TString TMusrRunHeader::GetType(TString str)
-{
- TString result = "n/a";
-
- // the string 'str' should have the structure
- // - : -@
- Ssiz_t pos = str.Last('@');
-
- if (pos == -1) { // i.e. NOT found
- cerr << endl << ">> TMusrRunHeader::GetType(): **ERROR** str=" << str << " seems to be an invalid MusrROOT run header string." << endl;
- return result;
- }
-
- // filter out the encoded type declaration, i.e. -@, where is the encoded type
- TString typeStr(str);
- typeStr.Remove(0, pos+1);
- Int_t typeVal;
- if (!typeStr.IsDigit()) {
- cerr << endl << ">> TMusrRunHeader::GetType(): **ERROR** typeStr=" << typeStr << " is not supported." << endl;
- return result;
- }
-
- typeVal = typeStr.Atoi();
-
- switch (typeVal) {
- case MRH_TSTRING:
- result = "TString";
- break;
- case MRH_INT:
- result = "Int_t";
- break;
- case MRH_DOUBLE:
- result = "Double_t";
- break;
- case MRH_TMUSR_RUN_PHYSICAL_QUANTITY:
- result = "TMusrRunPhysicalQuantity";
- break;
- case MRH_TSTRING_VECTOR:
- result = "TStringVector";
- break;
- case MRH_INT_VECTOR:
- result = "TIntVector";
- break;
- case MRH_DOUBLE_VECTOR:
- result = "TDoubleVector";
- break;
- default:
- cerr << endl << ">> TMusrRunHeader::GetType(): **ERROR** found unsupport type encoded with: " << typeVal << "." << endl;
- break;
- }
-
- return result;
-}
-
-//--------------------------------------------------------------------------
-// UpdateFolder (private)
-//--------------------------------------------------------------------------
-/**
- * Update folder structure
- *
- *
return:
- * - true if everything is all right
- * - false otherwise
- *
- * \param treeObj to be updated
- * \param path to be added within 'treeObj'
- */
-bool TMusrRunHeader::UpdateFolder(TObject *treeObj, TString path)
-{
- if (path.First('/') == -1) // only value element left, hence nothing to be done
- return true;
-
- TString str = GetFirst(path, '/');
-
- TObject *obj = treeObj->FindObject(str);
-
- // remove the first path element
- if (!RemoveFirst(path, '/')) {
- cerr << endl << ">> TMusrRunHeader::FillFolder(): **ERROR** couldn't tokenize path!!" << endl;
- return false;
- }
-
- if (!obj) { // required object not present, create it
- TObjArray *oarray = new TObjArray();
- if (!oarray) {
- cerr << endl << ">> TMusrRunHeader::FillFolder(): **ERROR** couldn't create header structure!!" << endl;
- return false;
- }
- // set the name of the new TObjArray
- oarray->SetName(str);
-
- if (!strcmp(treeObj->ClassName(), "TFolder"))
- ((TFolder*)treeObj)->Add(oarray);
- else // it is a TObjArray
- ((TObjArray*)treeObj)->AddLast(oarray);
-
- return UpdateFolder(oarray, path);
- } else { // object present, hence check rest of the path
- return UpdateFolder(obj, path);
- }
-}
-
-//--------------------------------------------------------------------------
-// FindObject (private)
-//--------------------------------------------------------------------------
-/**
- *
Check if 'path' is present in 'treeObj'
- *
- *
return:
- * - pointer to the 'path' object if present
- * - otherwise return 0
- *
- * \param treeObj to be searched
- * \param path searched for within 'treeObj'
- */
-TObject* TMusrRunHeader::FindObject(TObject *treeObj, TString path)
-{
- Ssiz_t pos;
- TObject *obj=0;
-
- // make sure that treeObj is either TFolder or TObjArray
- if (strcmp(treeObj->ClassName(), "TFolder") && strcmp(treeObj->ClassName(), "TObjArray"))
- return obj;
-
- pos = path.First('/');
- if (pos == -1) { // i.e. no sub-paths anymore
- obj = treeObj->FindObject(path);
- return obj;
- } else { // sub-paths present
- TString objName = GetFirst(path, '/'); // get first token of the path //.../
- obj = treeObj->FindObject(objName);
- if (obj) { // object found, check for subPath object
- RemoveFirst(path, '/'); // remove first tokens of the path
- return FindObject(obj, path);
- } else { // object not found
- return obj;
- }
- }
-}
-
-//--------------------------------------------------------------------------
-// GetHeaderString (private)
-//--------------------------------------------------------------------------
-/**
- *
- *
- * \param pathName
- */
-TObjString TMusrRunHeader::GetHeaderString(UInt_t idx)
-{
- TObjString tostr("n/a");
-
- TString str(""), path(""), name(""), fmt(""), tstr("");
- TMusrRunPhysicalQuantity prop;
-
- // go through all objects and try to find it
- // 1st check TString
- for (UInt_t j=0; j +- ; SP: [; ]
- digit = GetDecimalPlace(prop.GetError());
- digit_d = GetLeastSignificantDigit(prop.GetDemand());
- if (prop.GetDescription() != "n/a") {
- fmt.Form("%%s: %%.%dlf +- %%.%dlf %%s; SP: %%.%dlf; %%s", digit, digit, digit_d);
-
- tstr.Form(fmt, prop.GetLabel().Data(), prop.GetValue(), prop.GetError(), prop.GetUnit().Data(), prop.GetDemand(), prop.GetDescription().Data());
- } else {
- fmt.Form("%%s: %%.%dlf +- %%.%dlf %%s; SP: %%.%dlf", digit, digit, digit_d);
- tstr.Form(fmt, prop.GetLabel().Data(), prop.GetValue(), prop.GetError(), prop.GetUnit().Data(), prop.GetDemand());
- }
- } else if ((prop.GetDemand() == MRH_UNDEFINED) && (prop.GetValue() != MRH_UNDEFINED) && (prop.GetError() != MRH_UNDEFINED) &&
- (prop.GetUnit() != "n/a")) { // +- [; ]
- digit = GetDecimalPlace(prop.GetError());
- if (prop.GetDescription() != "n/a") {
- fmt.Form("%%s: %%.%dlf +- %%.%dlf %%s; %%s", digit, digit);
- tstr.Form(fmt, prop.GetLabel().Data(), prop.GetValue(), prop.GetError(), prop.GetUnit().Data(), prop.GetDescription().Data());
- } else {
- fmt.Form("%%s: %%.%dlf +- %%.%dlf %%s", digit, digit);
- tstr.Form(fmt, prop.GetLabel().Data(), prop.GetValue(), prop.GetError(), prop.GetUnit().Data());
- }
- } else if ((prop.GetDemand() == MRH_UNDEFINED) && (prop.GetValue() != MRH_UNDEFINED) && (prop.GetError() == MRH_UNDEFINED) &&
- (prop.GetUnit() != "n/a")) { // [; ]
- digit = GetLeastSignificantDigit(prop.GetValue());
- if (prop.GetDescription() != "n/a") {
- fmt.Form("%%s: %%.%dlf %%s; %%s", digit);
- tstr.Form(fmt, prop.GetLabel().Data(), prop.GetValue(), prop.GetUnit().Data(), prop.GetDescription().Data());
- } else {
- fmt.Form("%%s: %%.%dlf %%s", digit);
- tstr.Form(fmt, prop.GetLabel().Data(), prop.GetValue(), prop.GetUnit().Data());
- }
- } else if ((prop.GetDemand() != MRH_UNDEFINED) && (prop.GetValue() != MRH_UNDEFINED) && (prop.GetError() == MRH_UNDEFINED) &&
- (prop.GetUnit() != "n/a")) { // ; SP: [; ]
- digit = GetLeastSignificantDigit(prop.GetValue());
- digit_d = GetLeastSignificantDigit(prop.GetDemand());
- if (prop.GetDescription() != "n/a") {
- fmt.Form("%%s: %%.%dlf %%s; SP: %%.%dlf; %%s", digit, digit_d);
- tstr.Form(fmt, prop.GetLabel().Data(), prop.GetValue(), prop.GetUnit().Data(), prop.GetDemand(), prop.GetDescription().Data());
- } else {
- fmt.Form("%%s: %%.%dlf %%s; SP: %%.%dlf", digit, digit_d);
- tstr.Form(fmt, prop.GetLabel().Data(), prop.GetValue(), prop.GetUnit().Data(), prop.GetDemand());
- }
- }
- str.Form("%03d - %s -@%d", idx, tstr.Data(), MRH_TMUSR_RUN_PHYSICAL_QUANTITY);
- tostr.SetString(str);
- }
- }
- // 5th check TStringVector
- for (UInt_t j=0; jRemoves the first junk of a string up to 'splitter'. If 'splitter' is
- * NOT present in the string, the string stays untouched and the routine
- * returns false.
- *
- * \param str string to be truncated
- * \param splitter the start of the string up to the splitter character removed
- */
-bool TMusrRunHeader::RemoveFirst(TString &str, const char splitter)
-{
- Ssiz_t idx = str.First(splitter);
- if (idx == -1)
- return false;
-
- str.Remove(0, idx+1);
-
- return true;
-}
-
-//--------------------------------------------------------------------------
-// GetFirst (private)
-//--------------------------------------------------------------------------
-/**
- * Assuming a string built like 'this/is/a/string:with:diffrent:splitters'.
- * Using as splitter '/', this routine would return 'this', it means get from str
- * everything up to the first occurance of splitter. If splitter would be ':'
- * in this example, the return string would be 'this/is/a/string'.
- *
- *
If splitter is not present in str the original str is returned.
- *
- *
return: first part of up to the splitter in struct
- *
- * \param str
- * \param splitter
- */
-TString TMusrRunHeader::GetFirst(TString &str, const char splitter)
-{
- TString result = str;
-
- Ssiz_t idx = str.First(splitter);
- if (idx != -1)
- result.Remove(idx, str.Length());
-
- return result;
-}
-
-// end ---------------------------------------------------------------------
diff --git a/src/tests/MusrRoot/TMusrRunHeader.h b/src/tests/MusrRoot/TMusrRunHeader.h
deleted file mode 100644
index d997c253..00000000
--- a/src/tests/MusrRoot/TMusrRunHeader.h
+++ /dev/null
@@ -1,196 +0,0 @@
-/***************************************************************************
-
- TMusrRunHeader.h
-
- Author: Andreas Suter
- e-mail: andreas.suter@psi.ch
-
- $Id$
-
-***************************************************************************/
-
-/***************************************************************************
- * Copyright (C) 2007-2012 by Andreas Suter *
- * andreas.suter@psi.ch *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- ***************************************************************************/
-
-#ifndef TMUSRRUNHEADER_H
-#define TMUSRRUNHEADER_H
-
-#include
-using namespace std;
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-#define MRH_UNDEFINED -9.99e99
-
-#define MRH_DOUBLE_PREC 6
-
-#define MRH_TSTRING 0
-#define MRH_INT 1
-#define MRH_DOUBLE 2
-#define MRH_TMUSR_RUN_PHYSICAL_QUANTITY 3
-#define MRH_TSTRING_VECTOR 4
-#define MRH_INT_VECTOR 5
-#define MRH_DOUBLE_VECTOR 6
-
-typedef vector TIntVector;
-typedef vector TDoubleVector;
-typedef vector TStringVector;
-
-//-------------------------------------------------------------------------
-template class TMusrRunObject : public TObject
-{
-public:
- TMusrRunObject() { fPathName = "n/a"; fType = "n/a"; }
- TMusrRunObject(TString pathName, TString type, T value) : fPathName(pathName), fType(type), fValue(value) {}
- virtual ~TMusrRunObject() {}
-
- 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 TMusrRunPhysicalQuantity : public TObject
-{
-public:
- TMusrRunPhysicalQuantity();
- TMusrRunPhysicalQuantity(TString label, Double_t demand, Double_t value, Double_t error, TString unit, TString description = TString("n/a"));
- TMusrRunPhysicalQuantity(TString label, Double_t demand, Double_t value, TString unit, TString description = TString("n/a"));
- TMusrRunPhysicalQuantity(TString label, Double_t value, TString unit, TString description = TString("n/a"));
- virtual ~TMusrRunPhysicalQuantity() {}
-
- virtual TString GetLabel() const { return fLabel; }
- virtual Double_t GetDemand() const { return fDemand; }
- virtual Double_t GetValue() const { return fValue; }
- virtual Double_t GetError() const { return fError; }
- virtual TString GetUnit() const { return fUnit; }
- virtual TString GetDescription() const { return fDescription; }
-
- virtual void Set(TString label, Double_t demand, Double_t value, Double_t error, TString unit, TString description = TString("n/a"));
- virtual void Set(TString label, Double_t demand, Double_t value, TString unit, TString description = TString("n/a"));
- virtual void Set(TString label, Double_t value, TString unit, TString description = TString("n/a"));
- virtual void SetLabel(TString &label) { fLabel = label; }
- virtual void SetLabel(const char *label) { fLabel = label; }
- virtual void SetDemand(Double_t val) { fDemand = val; }
- virtual void SetValue(Double_t val) { fValue = val; }
- virtual void SetError(Double_t err) { fError = err; }
- virtual void SetUnit(TString &unit) { fUnit = unit; }
- virtual void SetUnit(const char *unit) { fUnit = unit; }
- virtual void SetDescription(TString &str) { fDescription = str; }
- virtual void SetDescription(const char *str) { fDescription = str; }
-
-private:
- TString fLabel; ///< property label, like ’Sample Temperature’ etc.
- Double_t fDemand; ///< demand value of the physical quantity, e.g. temperature setpoint
- Double_t fValue; ///< measured value of the physical quantity
- Double_t fError; ///< estimated error (standard deviation) of the measured value
- TString fUnit; ///< unit of the physical quantity
- TString fDescription; ///< a more detailed description of the physical quantity
-
- ClassDef(TMusrRunPhysicalQuantity, 1)
-};
-
-//-------------------------------------------------------------------------
-class TMusrRunHeader : public TObject
-{
-public:
- TMusrRunHeader(bool quite=false);
- TMusrRunHeader(const char *fileName, bool quite=false);
- virtual ~TMusrRunHeader();
-
- virtual TString GetFileName() { return fFileName; }
-
- virtual Bool_t FillFolder(TFolder *folder);
-
- virtual Bool_t ExtractAll(TFolder *folder);
- virtual Bool_t ExtractHeaderInformation(TObjArray *headerInfo, TString path);
-
- virtual void GetValue(TString pathName, TString &value, Bool_t &ok);
- virtual void GetValue(TString pathName, Int_t &value, Bool_t &ok);
- virtual void GetValue(TString pathName, Double_t &value, Bool_t &ok);
- virtual void GetValue(TString pathName, TMusrRunPhysicalQuantity &value, Bool_t &ok);
- virtual void GetValue(TString pathName, TStringVector &value, Bool_t &ok);
- virtual void GetValue(TString pathName, TIntVector &value, Bool_t &ok);
- virtual void GetValue(TString pathName, TDoubleVector &value, Bool_t &ok);
-
- virtual void SetFileName(TString fln) { fFileName = fln; }
-
- virtual void Set(TString pathName, TString value);
- virtual void Set(TString pathName, Int_t value);
- virtual void Set(TString pathName, Double_t value);
- virtual void Set(TString pathName, TMusrRunPhysicalQuantity value);
- virtual void Set(TString pathName, TStringVector value);
- virtual void Set(TString pathName, TIntVector value);
- virtual void Set(TString pathName, TDoubleVector value);
-
- virtual void DumpHeader();
- virtual void DrawHeader();
-
-private:
- bool fQuite;
- TString fFileName;
- TString fVersion;
-
- vector< TMusrRunObject > fStringObj;
- vector< TMusrRunObject > fIntObj;
- vector< TMusrRunObject > fDoubleObj;
- vector< TMusrRunObject > fMusrRunPhysQuantityObj;
- vector< TMusrRunObject > fStringVectorObj;
- vector< TMusrRunObject > fIntVectorObj;
- vector< TMusrRunObject > fDoubleVectorObj;
-
- vector< TString > fPathNameOrder; ///< keeps the path-name as they were created in ordered to keep ordering
-
- virtual void Init(TString str="n/a");
- virtual void CleanUp();
-
- virtual UInt_t GetDecimalPlace(Double_t val);
- virtual UInt_t GetLeastSignificantDigit(Double_t val) const;
- virtual void SplitPathName(TString pathName, TString &path, TString &name);
-
- virtual TString GetLabel(TString str);
- virtual TString GetStrValue(TString str);
- virtual TString GetType(TString str);
-
- virtual bool UpdateFolder(TObject *treeObj, TString path);
- virtual TObject* FindObject(TObject *treeObj, TString path);
- virtual TObjString GetHeaderString(UInt_t idx);
-
- virtual bool RemoveFirst(TString &str, const char splitter);
- virtual TString GetFirst(TString &str, const char splitter);
-
- ClassDef(TMusrRunHeader, 1)
-};
-
-#endif // TMUSRRUNHEADER_H
diff --git a/src/tests/MusrRoot/TMusrRunHeaderLinkDef.h b/src/tests/MusrRoot/TMusrRunHeaderLinkDef.h
deleted file mode 100644
index 1594ae91..00000000
--- a/src/tests/MusrRoot/TMusrRunHeaderLinkDef.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/***************************************************************************
-
- TMusrRunHeaderLinkDef.h
-
- Author: Andreas Suter
- e-mail: andreas.suter@psi.ch
-
- $Id$
-
-***************************************************************************/
-
-/***************************************************************************
- * Copyright (C) 2007-2012 by Andreas Suter *
- * andreas.suter@psi.ch *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- ***************************************************************************/
-
-#ifdef __CINT__
-
-#pragma link off all globals;
-#pragma link off all classes;
-#pragma link off all functions;
-
-#pragma link C++ class TMusrRunPhysicalQuantity+;
-#pragma link C++ class TMusrRunHeader+;
-
-#endif
diff --git a/src/tests/MusrRoot/musrRoot_runHeader_test.cpp b/src/tests/MusrRoot/musrRoot_runHeader_test.cpp
deleted file mode 100644
index 73b9c9bc..00000000
--- a/src/tests/MusrRoot/musrRoot_runHeader_test.cpp
+++ /dev/null
@@ -1,158 +0,0 @@
-/***************************************************************************
-
- musrRoot_runHeader_test.cpp
-
- Author: Andreas Suter
- e-mail: andreas.suter@psi.ch
-
- $Id$
-
-***************************************************************************/
-
-/***************************************************************************
- * Copyright (C) 2007-2012 by Andreas Suter *
- * andreas.suter@psi.ch *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- ***************************************************************************/
-
-#include
-using namespace std;
-
-#include
-#include
-#include
-
-#include "TMusrRunHeader.h"
-
-void musrRoot_runHeader_test_syntax()
-{
- cout << endl << "usage: musrRoot_runHeader_test ";
- cout << endl << " is the file name including the extention root, e.g. test.root";
- cout << endl << endl;
-}
-
-int main(int argc, char *argv[])
-{
- if (argc != 2) {
- musrRoot_runHeader_test_syntax();
- return 1;
- }
-
- // read the file and extract the header info
- TFile *f = new TFile(argv[1], "READ", "musrRoot_runHeader_test");
- if (f->IsZombie()) {
- delete f;
- return -1;
- }
-
- TFolder *runHeader = 0;
- f->GetObject("RunHeader", runHeader);
- if (runHeader == 0) {
- cerr << endl << ">> **ERROR** Couldn't get top folder RunHeader";
- f->Close();
- return -1;
- }
-
- // MusrRoot Run Header object
- TMusrRunHeader *header = new TMusrRunHeader(argv[1]);
- header->ExtractAll(runHeader);
-
- f->Close();
- delete f;
-
- header->DumpHeader();
-
- // get some information from the read file
- cout << endl << "++++++++++++++++++++++++++++";
- cout << endl << ">> get header infos " << argv[1];
- cout << endl << "++++++++++++++++++++++++++++" << endl;
-
- TString str("");
- TStringVector strVec;
- Int_t ival;
- Double_t dval;
- TDoubleVector dvec;
- TMusrRunPhysicalQuantity prop;
- Bool_t ok;
-
- header->GetValue("RunInfo/Run Title", str, ok);
- if (ok)
- cout << endl << "Run Title: " << str.Data();
- else
- cout << endl << "**ERROR** Couldn't obtain the 'Run Title'.";
-
- header->GetValue("RunInfo/Run Number", ival, ok);
- if (ok)
- cout << endl << "Run Number: " << ival;
- else
- cout << endl << "**ERROR** Couldn't obtain the 'Run Number'.";
-
- header->GetValue("RunInfo/Sample Temperature", prop, ok);
- if (ok) {
- cout << endl << "Sample Temperature: " << prop.GetValue() << " +- " << prop.GetError() << " " << prop.GetUnit().Data() << "; SP: " << prop.GetDemand() << "; " << prop.GetDescription().Data();
- } else {
- cout << endl << "**ERROR** Couldn't obtain the 'Sample Temperature'.";
- }
-
- header->GetValue("DetectorInfo/Detector000/Name", str, ok);
- if (ok) {
- cout << endl << "DetectorInfo/Detector000: Name=" << str;
- } else {
- cout << endl << "**ERROR** Couldn't obtain 'Detector/Detector000/Name'.";
- }
-
- header->GetValue("DetectorInfo/Detector000/Histo Number", ival, ok);
- if (ok) {
- cout << endl << "DetectorInfo/Detector000: Histo Number=" << ival;
- } else {
- cout << endl << "**ERROR** Couldn't obtain 'Detector/Detector000/Histo Number'.";
- }
-
- header->GetValue("DetectorInfo/Detector000/Histo Length", ival, ok);
- if (ok) {
- cout << endl << "DetectorInfo/Detector000: Histo Length=" << ival;
- } else {
- cout << endl << "**ERROR** Couldn't obtain 'Detector/Detector000/Histo Length'.";
- }
-
- header->GetValue("DetectorInfo/Detector000/Time Zero Bin", dval, ok);
- if (ok) {
- cout << endl << "DetectorInfo/Detector000: Time Zero Bin=" << dval;
- } else {
- cout << endl << "**ERROR** Couldn't obtain 'Detector/Detector000/Time Zero Bin'.";
- }
-
- header->GetValue("DetectorInfo/Detector000/First Good Bin", ival, ok);
- if (ok) {
- cout << endl << "DetectorInfo/Detector000: First Good Bin=" << ival;
- } else {
- cout << endl << "**ERROR** Couldn't obtain 'Detector/Detector000/First Good Bin'.";
- }
-
- header->GetValue("DetectorInfo/Detector000/Last Good Bin", ival, ok);
- if (ok) {
- cout << endl << "DetectorInfo/Detector000: Last Good Bin=" << ival;
- } else {
- cout << endl << "**ERROR** Couldn't obtain 'Detector/Detector000/Last Good Bin'.";
- }
-
- cout << endl << endl;
-
- delete header;
-
- return 0;
-}
diff --git a/src/tests/MusrRoot/read_musrRoot_runHeader.cpp b/src/tests/MusrRoot/read_musrRoot_runHeader.cpp
deleted file mode 100644
index d54a3927..00000000
--- a/src/tests/MusrRoot/read_musrRoot_runHeader.cpp
+++ /dev/null
@@ -1,97 +0,0 @@
-/***************************************************************************
-
- read_musrRoot_runHeader.cpp
-
- Author: Andreas Suter
- e-mail: andreas.suter@psi.ch
-
- $Id$
-
-***************************************************************************/
-
-/***************************************************************************
- * Copyright (C) 2007-2012 by Andreas Suter *
- * andreas.suter@psi.ch *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- ***************************************************************************/
-
-#include
-using namespace std;
-
-#include
-#include
-#include
-
-#include "TMusrRunHeader.h"
-
-void closeFile(TFile *f)
-{
- if (f == 0)
- return;
-
- f->Close();
- delete f;
-}
-
-void read_musrRoot_runHeader_syntax()
-{
- cout << endl << "usage: read_musrRoot_runHeader ";
- cout << endl << " is the file name including the extention root, e.g. test.root";
- cout << endl << endl;
-}
-
-int main(int argc, char *argv[])
-{
- if (argc != 2) {
- read_musrRoot_runHeader_syntax();
- return 1;
- }
-
- // read the file back and extract the header info
- TFile *f = new TFile(argv[1], "READ", "read_musrRoot_runHeader");
- if (f->IsZombie()) {
- delete f;
- return -1;
- }
-
- TFolder *runHeader = 0;
- f->GetObject("RunHeader", runHeader);
- if (runHeader == 0) {
- cerr << endl << ">> **ERROR** Couldn't get top folder RunHeader";
- closeFile(f);
- return -1;
- }
-
- TMusrRunHeader *header = new TMusrRunHeader(argv[1]);
-
- if (!header->ExtractAll(runHeader)) {
- cerr << endl << ">> **ERROR** couldn't extract all RunHeader information :-(" << endl << endl;
- closeFile(f);
- return -1;
- }
-
- f->Close();
- delete f;
-
- header->DumpHeader();
-
- delete header;
-
- cout << endl << endl;
-
- return 0;
-}
diff --git a/src/tests/MusrRoot/root2xml.C b/src/tests/MusrRoot/root2xml.C
deleted file mode 100644
index 09584f93..00000000
--- a/src/tests/MusrRoot/root2xml.C
+++ /dev/null
@@ -1,318 +0,0 @@
-// quick and dirty ROOT -> XML converter for MusrRoot
-// needs to be rewritten as proper program.
-//
-// Andreas Suter
-//
-// $Id$
-
-vector xml_data;
-
-enum EFolderTag {eUnkown, eDecayAnaModule, eSlowControlAnaModule};
-enum ERunHeaderTag {eUnkown, eRunInfo, eSampleEnvironmentInfo, eMagneticFieldEnvironmentInfo, eBeamlineInfo, eScalerInfo};
-EFolderTag folderTag = eUnkown;
-ERunHeaderTag runHeaderTag = eUnkown;
-
-void root2xml(const char *filename, const char *xmlFilename)
-{
- TFile f(filename);
-
- if (f.IsZombie()) {
- cout << endl << "**ERROR** couldn't open file " << filename << endl;
- return;
- }
-
- xml_data.clear();
-
- xml_data.push_back("");
- xml_data.push_back("");
-
- TIter next = f.GetListOfKeys();
- TKey *key;
- TFolder *folder;
- TString str, tag;
-
- UInt_t offset = 2;
-
- while (key = (TKey*) next()) {
- cout << endl << "name: " << key->GetName() << ", class name: " << key->GetClassName();
- str = key->GetClassName();
- if (str == "TFolder") {
- folder = (TFolder*)key->ReadObj();
- checkClass(folder, str, offset);
- }
- }
- cout << endl;
-
- f.Close();
-
- xml_data.push_back("");
-
- // the sort_histo_folders is needed since XML-Schema is not flexible enough to handle
- // histos -|
- // |- DecayAnaModule
- // ... (any other analyzer module sub-folder
- // |- SCAnaModule
- // Hence SCAnaModule has artificially moved up, just to follow DecayAnaModule
- sort_histo_folders();
-
- ofstream fout(xmlFilename);
-
- for (UInt_t i=0; i temp_xml_data;
-
- // first make a copy of the original xml_data
- for (unsigned int i=0; i") != string::npos)
- start = i;
- if (temp_xml_data[i].find("") != string::npos)
- end = i+1;
- }
- if ((start > 0) && (end > 0))
- temp_xml_data.erase(temp_xml_data.begin()+start, temp_xml_data.begin()+end);
- else // no SCAnaModule present, hence nothing to be done
- return;
-
- // insert SCAnaModule just after DecayAnaModule
- // 1st find end of DecayAnaModule
- unsigned int pos = 0;
- for (unsigned int i=0; i") != string::npos) {
- pos = i+1;
- break;
- }
- }
- if (pos == 0) // something is wrong, hence to not do anything
- return;
- temp_xml_data.insert(temp_xml_data.begin()+pos, xml_data.begin()+start, xml_data.begin()+end);
-
- // copy temp_xml_data back into xml_data
- xml_data.clear();
- for (unsigned int i=0; iGetListOfFolders();
- TObject *obj;
- TString str;
- while (obj = (TObject*) next()) {
- cout << endl << offsetStr << "name: " << obj->GetName() << ", class name: " << obj->ClassName();
- str = obj->ClassName();
- checkClass(obj, str, offset);
- }
-
-}
-
-void dumpObjArray(TObjArray *obj, UInt_t offset)
-{
- TString offsetStr="";
- for (UInt_t i=0; iGetName());
- if (xmlLabel.BeginsWith("Detector")) {
- xmlLabel.Remove(0, 8); // remove 'Detector'
- if (xmlLabel.IsDigit())
- xmlLabel = "Detector";
- else
- xmlLabel = TString(obj->GetName());
- }
-
- cout << endl << offsetStr << obj->GetName() << " (# " << obj->GetEntries() << ")";
-
- xmlStr = offsetStr + "<" + xmlLabel + ">";
- xml_data.push_back(xmlStr.Data());
-
- for (UInt_t i=0; iGetEntries(); i++) {
- // check if entry is a TObjArray
- type = obj->At(i)->ClassName();
- if (type == "TObjArray") {
- dumpObjArray((TObjArray*)(obj->At(i)), offset+2);
- } else { // not a TObjArray
- tstr = (TObjString*) obj->At(i);
- str = tstr->GetString();
- str.Remove(TString::kTrailing, '\n');
-
- getType(str, type);
- getLabel(str, label);
-
- cout << endl << offsetStr << i << ": " << str;
-
- xmlStr = offsetStr + " " + "<" + label + ">" + type + "" + label + ">" ;
- xml_data.push_back(xmlStr.Data());
- }
- }
-
- xmlStr = offsetStr + "" + xmlLabel + ">";
- xml_data.push_back(xmlStr.Data());
-}
-
-void dumpEntry(TObject *obj, UInt_t offset)
-{
- TString offsetStr="";
- for (UInt_t i=0; i";
- str += obj->GetName();
- str += "" + nameTag + ">";
- xml_data.push_back(str.Data());
-
- str = offsetStr + "<" + typeTag + ">";
- str += obj->ClassName();
- str += "" + typeTag + ">";
- xml_data.push_back(str.Data());
-}
-
-void checkClass(TObject *obj, TString str, UInt_t offset)
-{
- TString offsetStr="";
- for (UInt_t i=0; iGetName()));
-
- // set folder tag
- if (!xmlTagName.CompareTo("DecayAnaModule"))
- folderTag = eDecayAnaModule;
- else if (!xmlTagName.CompareTo("SCAnaModule"))
- folderTag = eSlowControlAnaModule;
- else if (!xmlTagName.CompareTo("SCAnaModule"))
- folderTag = eSlowControlAnaModule;
- else
- folderTag = eUnkown;
-
- offset += 2;
- str = offsetStr + "<" + xmlTagName + ">";
- xml_data.push_back(str.Data());
-
- dumpFolder((TFolder*)obj, offset);
-
- str = offsetStr + "" + xmlTagName + ">";
- xml_data.push_back(str.Data());
- } else if (str == "TObjArray") {
- offset += 2;
- dumpObjArray((TObjArray*)obj, offset);
- } else {
- // filter out the proper entry tag
- TString entryTag("");
- switch (folderTag) {
- case eDecayAnaModule:
- entryTag = TString("DecayHistoEntry");
- break;
- case eSlowControlAnaModule:
- entryTag = TString("SlowControlHistoEntry");
- break;
- case eUnkown:
- default:
- entryTag = TString("Entry");
- break;
- }
-
- offset += 2;
- str = offsetStr + "<" + entryTag + ">";
- xml_data.push_back(str.Data());
- dumpEntry((TObjArray*)obj, offset);
- str = offsetStr + "" + entryTag + ">";
- xml_data.push_back(str.Data());
- }
-}
-
-void getType(TString entry, TString &type)
-{
- if (entry.Contains("-@0")) {
- type = "TString";
- } else if (entry.Contains("-@1")) {
- type = "Int_t";
- } else if (entry.Contains("-@2")) {
- type = "Double_t";
- } else if (entry.Contains("-@3")) {
- type = "TMusrRunPhysicalQuantity";
- } else if (entry.Contains("-@4")) {
- type = "TStringVector";
- } else if (entry.Contains("-@5")) {
- type = "TIntVector";
- } else if (entry.Contains("-@6")) {
- type = "TDoubleVector";
- } else {
- type = "TString";
- }
-
-}
-
-void getLabel(TString entry, TString &label)
-{
- label="no_idea";
-
- Ssiz_t start = entry.First('-');
- Ssiz_t end = entry.First(':');
-
- if ((start == -1) || (end == -1))
- return;
-
- if (end - start < 2)
- return;
-
- // check that '-@' is present in the string, otherwise it is NOT a known label
- Ssiz_t pos = entry.First('@');
- if (pos < 1)
- return;
- if (entry(pos-1) != '-')
- return;
-
- // cut out value
- label = entry;
- label.Remove(0, start+2);
- label.Remove(end-start-2, label.Length());
-
- label.ReplaceAll(' ', '_'); // replace spaces through underscores
- label.ReplaceAll('(', '_'); // replace '(' through underscores
- label.ReplaceAll(')', '_'); // replace ')' through underscores
- label.ReplaceAll('[', '_'); // replace '[' through underscores
- label.ReplaceAll(']', '_'); // replace ']' through underscores
- label.ReplaceAll('{', '_'); // replace '[' through underscores
- label.ReplaceAll('}', '_'); // replace ']' through underscores
-}
diff --git a/src/tests/MusrRoot/write_musrRoot_runHeader.cpp b/src/tests/MusrRoot/write_musrRoot_runHeader.cpp
deleted file mode 100644
index b9592349..00000000
--- a/src/tests/MusrRoot/write_musrRoot_runHeader.cpp
+++ /dev/null
@@ -1,236 +0,0 @@
-/***************************************************************************
-
- write_musrRoot_runHeader.cpp
-
- Author: Andreas Suter
- e-mail: andreas.suter@psi.ch
-
- $Id$
-
-***************************************************************************/
-
-/***************************************************************************
- * Copyright (C) 2007-2012 by Andreas Suter *
- * andreas.suter@psi.ch *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- ***************************************************************************/
-
-#include
-#include
-#include
-
-#include
-using namespace std;
-
-#include
-#include
-#include
-
-#include "TMusrRunHeader.h"
-
-void write_musrRoot_runHeader_syntax()
-{
- cout << endl << "usage: write_musrRoot_runHeader ";
- cout << endl << " is the file name including the extention root, e.g. test.root";
- cout << endl << endl;
-}
-
-int main(int argc, char *argv[])
-{
- if (argc != 2) {
- write_musrRoot_runHeader_syntax();
- return 1;
- }
-
- // MusrRoot Run Header object
- TMusrRunHeader *header = new TMusrRunHeader(argv[1]);
- TMusrRunPhysicalQuantity prop;
-
- // run info
- header->Set("RunInfo/Generic Validator URL", "http://lmu.web.psi.ch/facilities/software/MusrRoot/Validation/MusrRoot.xsd");
- header->Set("RunInfo/Specific Validator URL", "http://lmu.web.psi.ch/facilities/software/MusrRoot/Validation/MusrRootGPS.xsd");
- header->Set("RunInfo/Generator", "any2many");
- header->Set("RunInfo/File Name", "deltat_tdc_gps_2871.root");
- header->Set("RunInfo/Run Title", "here comes the run title");
- header->Set("RunInfo/Run Number", 2871);
-
- // run info - start/stop time and duration
- TString startTime("2012-04-19 14:25:22"), stopTime("2012-04-19 19:13:47");
- struct tm tm_start, tm_stop;
- header->Set("RunInfo/Run Start Time", startTime);
- header->Set("RunInfo/Run Stop Time", stopTime);
- // calculate run duration
- memset(&tm_start, 0, sizeof(tm_start));
- strptime(startTime.Data(), "%Y-%m-%d %H:%M:%S", &tm_start);
- memset(&tm_stop, 0, sizeof(tm_stop));
- strptime(stopTime.Data(), "%Y-%m-%d %H:%M:%S", &tm_stop);
- Double_t duration = difftime(mktime(&tm_stop), mktime(&tm_start));
- prop.Set("Run Duration", (Int_t)duration, "sec");
- header->Set("RunInfo/Run Duration", prop);
-
- header->Set("RunInfo/Laboratory", "PSI");
- header->Set("RunInfo/Instrument", "GPS");
-
- prop.Set("Muon Beam Momentum", 28.1, "MeV/c");
- header->Set("RunInfo/Muon Beam Momentum", prop);
-
- header->Set("RunInfo/Muon Species", "positive muon");
- header->Set("RunInfo/Muon Source", "target M");
- header->Set("RunInfo/Setup", "a very special setup with Heliox");
- header->Set("RunInfo/Comment", "nothing more to be said");
- header->Set("RunInfo/Sample Name", "the best ever");
-
- prop.Set("Sample Temperature", 3.2, 3.21, 0.05, "K", "CF1");
- header->Set("RunInfo/Sample Temperature", prop);
-
- prop.Set("Sample Magnetic Field", 350.0, 350.002, 0.005, "G", "WXY");
- header->Set("RunInfo/Sample Magnetic Field", prop);
-
- header->Set("RunInfo/No of Histos", 4);
-
- prop.Set("Time Resolution", 0.1953125, "ns", "TDC 9999");
- header->Set("RunInfo/Time Resolution", prop);
-
- header->Set("DetectorInfo/Detector000/Name", "Left - NPP");
- header->Set("DetectorInfo/Detector000/Histo Number", 0);
- header->Set("DetectorInfo/Detector000/Histo Length", 66661);
- header->Set("DetectorInfo/Detector000/Time Zero Bin", 3419.0);
- header->Set("DetectorInfo/Detector000/First Good Bin", 3419);
- header->Set("DetectorInfo/Detector000/Last Good Bin", 66661);
-
- header->Set("DetectorInfo/Detector001/Name", "Top - NPP");
- header->Set("DetectorInfo/Detector001/Histo Number", 1);
- header->Set("DetectorInfo/Detector001/Histo Length", 66661);
- header->Set("DetectorInfo/Detector001/Time Zero Bin", 3419.0);
- header->Set("DetectorInfo/Detector001/First Good Bin", 3419);
- header->Set("DetectorInfo/Detector001/Last Good Bin", 66661);
-
- header->Set("DetectorInfo/Detector002/Name", "Right - NPP");
- header->Set("DetectorInfo/Detector002/Histo Number", 2);
- header->Set("DetectorInfo/Detector002/Histo Length", 66661);
- header->Set("DetectorInfo/Detector002/Time Zero Bin", 3419.0);
- header->Set("DetectorInfo/Detector002/First Good Bin", 3419);
- header->Set("DetectorInfo/Detector002/Last Good Bin", 66661);
-
- header->Set("DetectorInfo/Detector003/Name", "Bottom - NPP");
- header->Set("DetectorInfo/Detector003/Histo Number", 3);
- header->Set("DetectorInfo/Detector003/Histo Length", 66661);
- header->Set("DetectorInfo/Detector003/Time Zero Bin", 3419.0);
- header->Set("DetectorInfo/Detector003/First Good Bin", 3419);
- header->Set("DetectorInfo/Detector003/Last Good Bin", 66661);
-
- header->Set("DetectorInfo/Detector004/Name", "Left - PPC");
- header->Set("DetectorInfo/Detector004/Histo Number", 20);
- header->Set("DetectorInfo/Detector004/Histo Length", 66661);
- header->Set("DetectorInfo/Detector004/Time Zero Bin", 3419.0);
- header->Set("DetectorInfo/Detector004/First Good Bin", 3419);
- header->Set("DetectorInfo/Detector004/Last Good Bin", 66661);
-
- header->Set("DetectorInfo/Detector005/Name", "Top - PPC");
- header->Set("DetectorInfo/Detector005/Histo Number", 21);
- header->Set("DetectorInfo/Detector005/Histo Length", 66661);
- header->Set("DetectorInfo/Detector005/Time Zero Bin", 3419.0);
- header->Set("DetectorInfo/Detector005/First Good Bin", 3419);
- header->Set("DetectorInfo/Detector005/Last Good Bin", 66661);
-
- header->Set("DetectorInfo/Detector006/Name", "Right - PPC");
- header->Set("DetectorInfo/Detector006/Histo Number", 22);
- header->Set("DetectorInfo/Detector006/Histo Length", 66661);
- header->Set("DetectorInfo/Detector006/Time Zero Bin", 3419.0);
- header->Set("DetectorInfo/Detector006/First Good Bin", 3419);
- header->Set("DetectorInfo/Detector006/Last Good Bin", 66661);
-
- header->Set("DetectorInfo/Detector007/Name", "Bottom - PPC");
- header->Set("DetectorInfo/Detector007/Histo Number", 23);
- header->Set("DetectorInfo/Detector007/Histo Length", 66661);
- header->Set("DetectorInfo/Detector007/Time Zero Bin", 3419.0);
- header->Set("DetectorInfo/Detector007/First Good Bin", 3419);
- header->Set("DetectorInfo/Detector007/Last Good Bin", 66661);
-
- TStringVector scHistoNames;
- scHistoNames.push_back("Sample Temperature");
- scHistoNames.push_back("Sample Magnetic Field");
- header->Set("RunInfo/Slow Control Histo Names", scHistoNames);
-
- TStringVector dummyTest;
- dummyTest.push_back("dummy1");
- dummyTest.push_back("dummy2");
- dummyTest.push_back("dummy3");
- header->Set("RunInfo/Dummy Test", dummyTest);
-
- // sample environment
- header->Set("SampleEnvironmentInfo/Cryo", "Konti-1");
- header->Set("SampleEnvironmentInfo/Insert", "X123");
- header->Set("SampleEnvironmentInfo/Orientation", "c-axis perp spin, perp field. spin perp field");
-
- prop.Set("CF2", 3.2, 3.22, 0.04, "K");
- header->Set("SampleEnvironmentInfo/CF2", prop);
-
- prop.Set("CF3", MRH_UNDEFINED, 3.27, 0.09, "K", "strange temperature");
- header->Set("SampleEnvironmentInfo/CF3", prop);
-
- prop.Set("CF4", 3.25, 3.28, "K");
- header->Set("SampleEnvironmentInfo/CF4", prop);
-
- prop.Set("CF5", 3.26, 3.29, "K", "another strange temperature");
- header->Set("SampleEnvironmentInfo/CF5", prop);
-
- prop.Set("Dummy Prop", -2.0, -2.001, 0.002, "SI-unit");
- header->Set("SampleEnvironmentInfo/Dummy Prop", prop);
-
- // magnetic field environment
- header->Set("MagneticFieldEnvironmentInfo/Magnet Name", "Bpar");
- prop.Set("Current", 1.34, "A");
- header->Set("MagneticFieldEnvironmentInfo/Current", prop);
-
- // beamline
- header->Set("BeamlineInfo/Name", "piM3.2");
- header->Set("BeamlineInfo/WSX61a", "DAC = 3289, ADC = 0.800");
-
- TIntVector dummyInt;
- for (UInt_t i=0; i<3; i++) dummyInt.push_back(i+1000);
- header->Set("BeamlineInfo/Dummy Int", dummyInt);
-
-
- // scaler
- header->Set("ScalerInfo/Ip", 12332123);
-
- // funny sub/sub/../sub-structure
- header->Set("aa/bb/cc/dd/ee/ff/name", "funny");
- header->Set("aa/bb/cc/dd/ee/ff/gg/xyz", 123);
-
- TFile *f = new TFile(argv[1], "RECREATE", "write_musrRoot_runHeader");
- if (f->IsZombie()) {
- delete f;
- return -1;
- }
-
- // root file header related things
- TFolder *runHeader = new TFolder("RunHeader", "MusrRoot Run Header Info");
-
- if (header->FillFolder(runHeader)) {
- runHeader->Write();
- }
-
- f->Close();
-
- // clean up
- delete f;
- delete header;
-
- return 0;
-}