musrfit  1.9.2
TMusrRunHeader.h
Go to the documentation of this file.
1 /***************************************************************************
2 
3  TMusrRunHeader.h
4 
5  Author: Andreas Suter
6  e-mail: andreas.suter@psi.ch
7 
8 ***************************************************************************/
9 
10 /***************************************************************************
11  * Copyright (C) 2007-2023 by Andreas Suter *
12  * andreas.suter@psi.ch *
13  * *
14  * This program is free software; you can redistribute it and/or modify *
15  * it under the terms of the GNU General Public License as published by *
16  * the Free Software Foundation; either version 2 of the License, or *
17  * (at your option) any later version. *
18  * *
19  * This program is distributed in the hope that it will be useful, *
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
22  * GNU General Public License for more details. *
23  * *
24  * You should have received a copy of the GNU General Public License *
25  * along with this program; if not, write to the *
26  * Free Software Foundation, Inc., *
27  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
28  ***************************************************************************/
29 
30 #ifndef TMUSRRUNHEADER_H
31 #define TMUSRRUNHEADER_H
32 
33 #include <vector>
34 
35 #include <TDatime.h>
36 #include <TObject.h>
37 #include <TQObject.h>
38 #include <TObjString.h>
39 #include <TObjArray.h>
40 #include <TFolder.h>
41 
42 #define MRH_UNDEFINED -9.99e99
43 
44 #define MRH_DOUBLE_PREC 6
45 
46 #define MRH_TSTRING 0
47 #define MRH_INT 1
48 #define MRH_DOUBLE 2
49 #define MRH_TMUSR_RUN_PHYSICAL_QUANTITY 3
50 #define MRH_TSTRING_VECTOR 4
51 #define MRH_INT_VECTOR 5
52 #define MRH_DOUBLE_VECTOR 6
53 
54 typedef std::vector<Int_t> TIntVector;
55 typedef std::vector<Double_t> TDoubleVector;
56 typedef std::vector<TString> TStringVector;
57 
58 //-------------------------------------------------------------------------
59 template <class T> class TMusrRunObject : public TObject
60 {
61 public:
62  TMusrRunObject() : TObject() { fPathName = "n/a"; fType = "n/a"; }
63  TMusrRunObject(TString pathName, TString type, T value) : TObject(), fPathName(pathName), fType(type), fValue(value) {}
64  virtual ~TMusrRunObject() {}
65 
66  virtual TString GetPathName() { return fPathName; }
67  virtual TString GetType() { return fType; }
68  virtual T GetValue() { return fValue; }
69 
70  virtual void SetPathName(TString pathName) { fPathName = pathName; }
71  virtual void SetType(TString type) { fType = type; }
72  virtual void SetValue(T value) { fValue = value; }
73 
74 private:
75  TString fPathName;
76  TString fType;
77  T fValue;
78 };
79 
80 //-------------------------------------------------------------------------
81 class TMusrRunPhysicalQuantity : public TObject
82 {
83 public:
85  TMusrRunPhysicalQuantity(TString label, Double_t demand, Double_t value, Double_t error, TString unit, TString description = TString("n/a"));
86  TMusrRunPhysicalQuantity(TString label, Double_t demand, Double_t value, TString unit, TString description = TString("n/a"));
87  TMusrRunPhysicalQuantity(TString label, Double_t value, TString unit, TString description = TString("n/a"));
89 
90  virtual TString GetLabel() const { return fLabel; }
91  virtual Double_t GetDemand() const { return fDemand; }
92  virtual Double_t GetValue() const { return fValue; }
93  virtual Double_t GetError() const { return fError; }
94  virtual TString GetUnit() const { return fUnit; }
95  virtual TString GetDescription() const { return fDescription; }
96 
97  virtual void Set(TString label, Double_t demand, Double_t value, Double_t error, TString unit, TString description = TString("n/a"));
98  virtual void Set(TString label, Double_t demand, Double_t value, TString unit, TString description = TString("n/a"));
99  virtual void Set(TString label, Double_t value, TString unit, TString description = TString("n/a"));
100  virtual void SetLabel(TString &label) { fLabel = label; }
101  virtual void SetLabel(const char *label) { fLabel = label; }
102  virtual void SetDemand(Double_t val) { fDemand = val; }
103  virtual void SetValue(Double_t val) { fValue = val; }
104  virtual void SetError(Double_t err) { fError = err; }
105  virtual void SetUnit(TString &unit) { fUnit = unit; }
106  virtual void SetUnit(const char *unit) { fUnit = unit; }
107  virtual void SetDescription(TString &str) { fDescription = str; }
108  virtual void SetDescription(const char *str) { fDescription = str; }
109 
110 private:
111  TString fLabel;
112  Double_t fDemand;
113  Double_t fValue;
114  Double_t fError;
115  TString fUnit;
116  TString fDescription;
117 
118  ClassDef(TMusrRunPhysicalQuantity, 1)
119 };
120 
121 //-------------------------------------------------------------------------
122 class TMusrRunHeader : public TObject
123 {
124 public:
125  TMusrRunHeader(bool quiet=false);
126  TMusrRunHeader(const char *fileName, bool quiet=false);
127  virtual ~TMusrRunHeader();
128 
129  virtual TString GetFileName() { return fFileName; }
130 
131  virtual Bool_t FillFolder(TFolder *folder);
132 
133  virtual Bool_t ExtractAll(TFolder *folder);
134  virtual Bool_t ExtractHeaderInformation(TObjArray *headerInfo, TString path);
135 
136  virtual TString GetTypeOfPath(TString pathName);
137 
138  virtual void Get(TString pathName, TString &value, Bool_t &ok);
139  virtual void Get(TString pathName, Int_t &value, Bool_t &ok);
140  virtual void Get(TString pathName, Double_t &value, Bool_t &ok);
141  virtual void Get(TString pathName, TMusrRunPhysicalQuantity &value, Bool_t &ok);
142  virtual void Get(TString pathName, TStringVector &value, Bool_t &ok);
143  virtual void Get(TString pathName, TIntVector &value, Bool_t &ok);
144  virtual void Get(TString pathName, TDoubleVector &value, Bool_t &ok);
145 
146  virtual void SetFileName(TString fln) { fFileName = fln; }
147 
148  virtual void Set(TString pathName, TString value);
149  virtual void Set(TString pathName, Int_t value);
150  virtual void Set(TString pathName, Double_t value);
151  virtual void Set(TString pathName, TMusrRunPhysicalQuantity value);
152  virtual void Set(TString pathName, TStringVector value);
153  virtual void Set(TString pathName, TIntVector value);
154  virtual void Set(TString pathName, TDoubleVector value);
155 
156  virtual void DumpHeader();
157  virtual void DrawHeader();
158 
159 private:
160  bool fQuiet;
161  TString fFileName;
162  TString fVersion;
163 
164  std::vector< TMusrRunObject<TString> > fStringObj;
165  std::vector< TMusrRunObject<Int_t> > fIntObj;
166  std::vector< TMusrRunObject<Double_t> > fDoubleObj;
167  std::vector< TMusrRunObject<TMusrRunPhysicalQuantity> > fMusrRunPhysQuantityObj;
168  std::vector< TMusrRunObject<TStringVector> > fStringVectorObj;
169  std::vector< TMusrRunObject<TIntVector> > fIntVectorObj;
170  std::vector< TMusrRunObject<TDoubleVector> > fDoubleVectorObj;
171 
172  std::vector< TString > fPathNameOrder;
173 
174  virtual void Init(TString str="n/a");
175  virtual void CleanUp();
176 
177  virtual UInt_t GetDecimalPlace(Double_t val);
178  virtual UInt_t GetLeastSignificantDigit(Double_t val) const;
179  virtual void SplitPathName(TString pathName, TString &path, TString &name);
180 
181  virtual TString GetLabel(TString str);
182  virtual TString GetStrValue(TString str);
183  virtual TString GetType(TString str);
184 
185  virtual bool UpdateFolder(TObject *treeObj, TString path);
186  virtual TObject* FindObject(TObject *treeObj, TString path);
187  virtual TObjString GetHeaderString(UInt_t idx);
188 
189  virtual bool RemoveFirst(TString &str, const char splitter);
190  virtual TString GetFirst(TString &str, const char splitter);
191 
192  ClassDef(TMusrRunHeader, 1)
193 };
194 
195 #endif // TMUSRRUNHEADER_H
virtual void DumpHeader()
std::vector< TString > fPathNameOrder
keeps the path-name as they were created in ordered to keep ordering
virtual TString GetPathName()
std::vector< TMusrRunObject< TStringVector > > fStringVectorObj
virtual Bool_t ExtractAll(TFolder *folder)
virtual void SetDemand(Double_t val)
virtual void Init(TString str="n/a")
std::vector< Int_t > TIntVector
virtual ~TMusrRunHeader()
std::vector< Double_t > TDoubleVector
Double_t fError
estimated error (standard deviation) of the measured value
TMusrRunHeader(bool quiet=false)
virtual ~TMusrRunObject()
virtual void SetValue(T value)
TString fDescription
a more detailed description of the physical quantity
virtual Double_t GetValue() const
std::vector< TMusrRunObject< TDoubleVector > > fDoubleVectorObj
virtual TString GetType()
virtual TObject * FindObject(TObject *treeObj, TString path)
virtual void SetError(Double_t err)
std::vector< TMusrRunObject< Int_t > > fIntObj
virtual void Set(TString pathName, TString value)
virtual Bool_t ExtractHeaderInformation(TObjArray *headerInfo, TString path)
std::vector< TMusrRunObject< TIntVector > > fIntVectorObj
virtual TString GetStrValue(TString str)
virtual TString GetDescription() const
virtual ~TMusrRunPhysicalQuantity()
virtual TString GetTypeOfPath(TString pathName)
virtual void DrawHeader()
virtual void CleanUp()
TString fUnit
unit of the physical quantity
virtual void SetValue(Double_t val)
virtual TString GetFirst(TString &str, const char splitter)
std::vector< TMusrRunObject< Double_t > > fDoubleObj
std::vector< TString > TStringVector
virtual void SetUnit(TString &unit)
T fValue
value itself
virtual TString GetUnit() const
virtual void SetLabel(const char *label)
virtual void Get(TString pathName, TString &value, Bool_t &ok)
Double_t fValue
measured value of the physical quantity
virtual TString GetFileName()
virtual Double_t GetDemand() const
virtual TString GetLabel() const
virtual UInt_t GetDecimalPlace(Double_t val)
virtual void Set(TString label, Double_t demand, Double_t value, Double_t error, TString unit, TString description=TString("n/a"))
virtual TObjString GetHeaderString(UInt_t idx)
virtual Double_t GetError() const
virtual bool UpdateFolder(TObject *treeObj, TString path)
TMusrRunObject(TString pathName, TString type, T value)
virtual void SetDescription(const char *str)
virtual void SetDescription(TString &str)
virtual void SetPathName(TString pathName)
virtual UInt_t GetLeastSignificantDigit(Double_t val) const
TString fPathName
path name of the variable, e.g. &#39;RunInfo/Run Number&#39;
virtual TString GetLabel(TString str)
virtual void SplitPathName(TString pathName, TString &path, TString &name)
virtual void SetFileName(TString fln)
std::vector< TMusrRunObject< TString > > fStringObj
virtual void SetType(TString type)
TString fLabel
property label, like ’Sample Temperature’ etc.
virtual void SetUnit(const char *unit)
virtual Bool_t FillFolder(TFolder *folder)
Double_t fDemand
demand value of the physical quantity, e.g. temperature setpoint
virtual void SetLabel(TString &label)
std::vector< TMusrRunObject< TMusrRunPhysicalQuantity > > fMusrRunPhysQuantityObj
virtual T GetValue()
virtual bool RemoveFirst(TString &str, const char splitter)
TString fType
type of value, e.g. TString, or Int_t, etc.
virtual TString GetType(TString str)