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