some improvement on new PSI-ROOT header
This commit is contained in:
@ -63,19 +63,34 @@ GLIBS = $(ROOTGLIBS) -lXMLParser
|
|||||||
# PSI libs
|
# PSI libs
|
||||||
PSILIBS = -lTPsiRunHeader
|
PSILIBS = -lTPsiRunHeader
|
||||||
|
|
||||||
EXEC = psi_runHeader_test
|
EXEC =
|
||||||
|
EXEC += psi_runHeader_test
|
||||||
|
EXEC += write_psi_runHeader
|
||||||
|
EXEC += read_psi_runHeader
|
||||||
|
|
||||||
# some definitions: headers (used to generate *Dict* stuff), sources, objects,...
|
# some definitions: headers (used to generate *Dict* stuff), sources, objects,...
|
||||||
OBJS =
|
OBJS =
|
||||||
OBJS += $(EXEC).o
|
OBJS += psi_runHeader_test.o
|
||||||
|
OBJS += write_psi_runHeader.o
|
||||||
|
OBJS += read_psi_runHeader.o
|
||||||
|
|
||||||
# make the executable:
|
# make the executable:
|
||||||
#
|
#
|
||||||
all: $(EXEC)
|
all: $(EXEC)
|
||||||
|
|
||||||
$(EXEC): $(OBJS)
|
psi_runHeader_test: psi_runHeader_test.o
|
||||||
@echo "---> Building $(EXEC) ..."
|
@echo "---> Building psi_runHeader_test ..."
|
||||||
$(LD) $(OBJS) -o $(EXEC) $(GLIBS) $(PSILIBS)
|
$(LD) psi_runHeader_test.o -o psi_runHeader_test $(GLIBS) $(PSILIBS)
|
||||||
|
@echo "done"
|
||||||
|
|
||||||
|
write_psi_runHeader: write_psi_runHeader.o
|
||||||
|
@echo "---> Building write_psi_runHeader ..."
|
||||||
|
$(LD) write_psi_runHeader.o -o write_psi_runHeader $(GLIBS) $(PSILIBS)
|
||||||
|
@echo "done"
|
||||||
|
|
||||||
|
read_psi_runHeader: read_psi_runHeader.o
|
||||||
|
@echo "---> Building read_psi_runHeader ..."
|
||||||
|
$(LD) read_psi_runHeader.o -o read_psi_runHeader $(GLIBS) $(PSILIBS)
|
||||||
@echo "done"
|
@echo "done"
|
||||||
|
|
||||||
# clean up: remove all object file (and core files)
|
# clean up: remove all object file (and core files)
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -71,8 +71,9 @@ class TPsiRunProperty : public TObject
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TPsiRunProperty();
|
TPsiRunProperty();
|
||||||
TPsiRunProperty(TString name, Double_t demand, Double_t value, Double_t error, TString unit, TString description = TString("n/a"));
|
TPsiRunProperty(TString label, Double_t demand, Double_t value, Double_t error, TString unit, TString description = TString("n/a"));
|
||||||
TPsiRunProperty(TString name, Double_t value, TString unit);
|
TPsiRunProperty(TString label, Double_t demand, Double_t value, TString unit, TString description = TString("n/a"));
|
||||||
|
TPsiRunProperty(TString label, Double_t value, TString unit, TString description = TString("n/a"));
|
||||||
virtual ~TPsiRunProperty() {}
|
virtual ~TPsiRunProperty() {}
|
||||||
|
|
||||||
virtual TString GetLabel() const { return fLabel; }
|
virtual TString GetLabel() const { return fLabel; }
|
||||||
@ -82,6 +83,9 @@ public:
|
|||||||
virtual TString GetUnit() const { return fUnit; }
|
virtual TString GetUnit() const { return fUnit; }
|
||||||
virtual TString GetDescription() const { return fDescription; }
|
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(TString &label) { fLabel = label; }
|
||||||
virtual void SetLabel(const char *label) { fLabel = label; }
|
virtual void SetLabel(const char *label) { fLabel = label; }
|
||||||
virtual void SetDemand(Double_t val) { fDemand = val; }
|
virtual void SetDemand(Double_t val) { fDemand = val; }
|
||||||
@ -158,25 +162,33 @@ private:
|
|||||||
class TPsiRunHeader : public TObject
|
class TPsiRunHeader : public TObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TPsiRunHeader();
|
TPsiRunHeader(const char *headerDefinition);
|
||||||
virtual ~TPsiRunHeader();
|
virtual ~TPsiRunHeader();
|
||||||
|
|
||||||
virtual Bool_t IsValid(Bool_t strict = false);
|
virtual Bool_t IsValid(Bool_t strict = false);
|
||||||
|
|
||||||
virtual void Get(TString path, TObjArray &content);
|
virtual void GetHeaderInfo(TString path, TObjArray &content);
|
||||||
|
|
||||||
virtual void Set(TString pathName, TString type, TString value);
|
virtual void GetValue(TString pathName, TString &value, Bool_t &ok);
|
||||||
virtual void Set(TString pathName, TString type, Int_t value);
|
virtual void GetValue(TString pathName, Int_t &value, Bool_t &ok);
|
||||||
virtual void Set(TString pathName, TString type, TPsiRunProperty value);
|
virtual void GetValue(TString pathName, TPsiRunProperty &value, Bool_t &ok);
|
||||||
virtual void Set(TString pathName, TString type, TStringVector value);
|
virtual void GetValue(TString pathName, TStringVector &value, Bool_t &ok);
|
||||||
virtual void Set(TString pathName, TString type, TIntVector value);
|
virtual void GetValue(TString pathName, TIntVector &value, Bool_t &ok);
|
||||||
|
|
||||||
virtual Bool_t ExtractHeaderInformation(TObjArray *headerInfo, TString path) { return true; }
|
virtual void Set(TString pathName, TString value);
|
||||||
|
virtual void Set(TString pathName, Int_t value);
|
||||||
|
virtual void Set(TString pathName, TPsiRunProperty value);
|
||||||
|
virtual void Set(TString pathName, TStringVector value);
|
||||||
|
virtual void Set(TString pathName, TIntVector value);
|
||||||
|
|
||||||
|
virtual Bool_t ExtractHeaderInformation(TObjArray *headerInfo, TString path);
|
||||||
|
|
||||||
virtual void DumpHeader();
|
virtual void DumpHeader();
|
||||||
virtual void DrawHeader();
|
virtual void DrawHeader();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
TString fHeaderDefinition;
|
||||||
|
|
||||||
vector< TPsiRunObject<TString> > fStringObj;
|
vector< TPsiRunObject<TString> > fStringObj;
|
||||||
vector< TPsiRunObject<Int_t> > fIntObj;
|
vector< TPsiRunObject<Int_t> > fIntObj;
|
||||||
vector< TPsiRunObject<TPsiRunProperty> > fPsiRunPropertyObj;
|
vector< TPsiRunObject<TPsiRunProperty> > fPsiRunPropertyObj;
|
||||||
|
@ -45,32 +45,104 @@
|
|||||||
<type>Int_t</type>
|
<type>Int_t</type>
|
||||||
</entry>
|
</entry>
|
||||||
<entry>
|
<entry>
|
||||||
<name>RunInfo/Sample Temperature</name>
|
<name>RunInfo/Run Start Time</name>
|
||||||
<type>TPsiRunProperty</type>
|
<type>TString</type>
|
||||||
</entry>
|
</entry>
|
||||||
<entry>
|
<entry>
|
||||||
<name>RunInfo/Time Resolution</name>
|
<name>RunInfo/Run Stop Time</name>
|
||||||
<type>TPsiRunProperty</type>
|
<type>TString</type>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<name>RunInfo/Run Duration</name>
|
||||||
|
<type>Int_t</type>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<name>RunInfo/Laboratory</name>
|
||||||
|
<type>TString</type>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<name>RunInfo/Area</name>
|
||||||
|
<type>TString</type>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<name>RunInfo/Instrument</name>
|
||||||
|
<type>TString</type>
|
||||||
</entry>
|
</entry>
|
||||||
<entry>
|
<entry>
|
||||||
<name>RunInfo/Muon Beam Momentum</name>
|
<name>RunInfo/Muon Beam Momentum</name>
|
||||||
<type>TPsiRunProperty</type>
|
<type>TPsiRunProperty</type>
|
||||||
</entry>
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<name>RunInfo/Muon Species</name>
|
||||||
|
<type>TString</type>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<name>RunInfo/Setup</name>
|
||||||
|
<type>TString</type>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<name>RunInfo/Comment</name>
|
||||||
|
<type>TString</type>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<name>RunInfo/Sample Name</name>
|
||||||
|
<type>TString</type>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<name>RunInfo/Sample Temperature</name>
|
||||||
|
<type>TPsiRunProperty</type>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<name>RunInfo/Sample Magnetic Field</name>
|
||||||
|
<type>TPsiRunProperty</type>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<name>RunInfo/No of Histos</name>
|
||||||
|
<type>Int_t</type>
|
||||||
|
</entry>
|
||||||
<entry>
|
<entry>
|
||||||
<name>RunInfo/Histo Names</name>
|
<name>RunInfo/Histo Names</name>
|
||||||
<type>TStringVector</type>
|
<type>TStringVector</type>
|
||||||
</entry>
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<name>RunInfo/Histo Length</name>
|
||||||
|
<type>Int_t</type>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<name>RunInfo/Time Resolution</name>
|
||||||
|
<type>TPsiRunProperty</type>
|
||||||
|
</entry>
|
||||||
<entry>
|
<entry>
|
||||||
<name>RunInfo/Time Zero Bin</name>
|
<name>RunInfo/Time Zero Bin</name>
|
||||||
<type>TIntVector</type>
|
<type>TIntVector</type>
|
||||||
</entry>
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<name>RunInfo/First Good Bin</name>
|
||||||
|
<type>TIntVector</type>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<name>RunInfo/Last Good Bin</name>
|
||||||
|
<type>TIntVector</type>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<name>RunInfo/Red-Green Offsets</name>
|
||||||
|
<type>TIntVector</type>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<name>RunInfo/Red-Green Description</name>
|
||||||
|
<type>TStringVector</type>
|
||||||
|
</entry>
|
||||||
<entry>
|
<entry>
|
||||||
<name>SampleEnv/Cryo</name>
|
<name>SampleEnv/Cryo</name>
|
||||||
<type>TString</type>
|
<type>TString</type>
|
||||||
</entry>
|
</entry>
|
||||||
<entry>
|
<entry>
|
||||||
<name>SampleEnv/CF2</name>
|
<name>SampleEnv/Insert</name>
|
||||||
<type>TPsiRunProperty</type>
|
<type>TString</type>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<name>SampleEnv/Orientation</name>
|
||||||
|
<type>TString</type>
|
||||||
</entry>
|
</entry>
|
||||||
<entry>
|
<entry>
|
||||||
<name>MagFieldEnv/Name</name>
|
<name>MagFieldEnv/Name</name>
|
||||||
@ -80,6 +152,10 @@
|
|||||||
<name>MagFieldEnv/Current</name>
|
<name>MagFieldEnv/Current</name>
|
||||||
<type>TPsiRunProperty</type>
|
<type>TPsiRunProperty</type>
|
||||||
</entry>
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<name>Scaler/Ip</name>
|
||||||
|
<type>Int_t</type>
|
||||||
|
</entry>
|
||||||
</header_info>
|
</header_info>
|
||||||
</psi_root>
|
</psi_root>
|
||||||
|
|
||||||
|
85
src/tests/PsiRoot/psi_root_test.xml
Normal file
85
src/tests/PsiRoot/psi_root_test.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 a test 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>
|
||||||
|
|
@ -40,40 +40,48 @@ using namespace std;
|
|||||||
|
|
||||||
void psi_runHeader_test_syntax()
|
void psi_runHeader_test_syntax()
|
||||||
{
|
{
|
||||||
cout << endl << "usage: psi_runHeader_test <fileName>";
|
cout << endl << "usage: psi_runHeader_test <fileName> <headerDefinition> [<strict>]";
|
||||||
cout << endl << " <fileName> is the file name including the extention root, e.g. test.root";
|
cout << endl << " <fileName> is the file name including the extention root, e.g. test.root";
|
||||||
|
cout << endl << " <headerDefinition> is the header definition XML-file.";
|
||||||
|
cout << endl << " <strict> 'strict'=strict validation; otherwise=less strict validation.";
|
||||||
cout << endl << endl;
|
cout << endl << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
if (argc != 2) {
|
if ((argc != 3) && (argc != 4)) {
|
||||||
psi_runHeader_test_syntax();
|
psi_runHeader_test_syntax();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Bool_t strict = false;
|
||||||
|
if (argc == 4) {
|
||||||
|
if (!strcmp(argv[3], "strict"))
|
||||||
|
strict = true;
|
||||||
|
}
|
||||||
|
|
||||||
// PSI Run Header object
|
// PSI Run Header object
|
||||||
TPsiRunHeader *header = new TPsiRunHeader();
|
TPsiRunHeader *header = new TPsiRunHeader(argv[2]);
|
||||||
TPsiRunProperty *prop;
|
TPsiRunProperty prop;
|
||||||
|
|
||||||
// run info
|
// run info
|
||||||
header->Set("RunInfo/Version", "TString", "$Id$");
|
header->Set("RunInfo/Version", "$Id$");
|
||||||
header->Set("RunInfo/Generator", "TString", "any2many");
|
header->Set("RunInfo/Generator", "any2many");
|
||||||
header->Set("RunInfo/File Name", "TString", "thisIsAFileName");
|
header->Set("RunInfo/File Name", "thisIsAFileName");
|
||||||
header->Set("RunInfo/Run Title", "TString", "here comes the run title");
|
// header->Set("RunInfo/Run Title", "here comes the run title");
|
||||||
header->Set("RunInfo/Run Number", "Int_t", 576);
|
header->Set("RunInfo/Run Number", 576);
|
||||||
header->Set("RunInfo/Run Number", "Int_t", 577);
|
header->Set("RunInfo/Run Number", 577);
|
||||||
header->Set("RunInfo/Run Start Time", "TString", "2011-04-19 14:25:22");
|
header->Set("RunInfo/Run Start Time", "2011-04-19 14:25:22");
|
||||||
header->Set("RunInfo/Run Stop Time", "TString", "2011-04-19 19:13:47");
|
header->Set("RunInfo/Run Stop Time", "2011-04-19 19:13:47");
|
||||||
|
|
||||||
prop = new TPsiRunProperty("Time Resolution", 0.193525, "ns");
|
prop.Set("Time Resolution", 0.193525, "ns", "TDC 9999");
|
||||||
header->Set("RunInfo/Time Resolution", "TPsiRunProperty", *prop);
|
header->Set("RunInfo/Time Resolution", prop);
|
||||||
|
|
||||||
prop = new TPsiRunProperty("Sample Temperature", 3.2, 3.20, 0.05, "K", "CF1");
|
prop.Set("Sample Temperature", 3.2, 3.21, 0.05, "K", "CF1");
|
||||||
header->Set("RunInfo/Sample Temperature", "TPsiRunProperty", *prop);
|
header->Set("RunInfo/Sample Temperature", prop);
|
||||||
|
|
||||||
prop = new TPsiRunProperty("Muon Beam Momentum", PRH_UNDEFINED, 28.1, PRH_UNDEFINED, "MeV/c");
|
prop.Set("Muon Beam Momentum", PRH_UNDEFINED, 28.1, PRH_UNDEFINED, "MeV/c");
|
||||||
header->Set("RunInfo/Muon Beam Momentum", "TPsiRunProperty", *prop);
|
header->Set("RunInfo/Muon Beam Momentum", prop);
|
||||||
|
|
||||||
TStringVector detectorName;
|
TStringVector detectorName;
|
||||||
detectorName.push_back("left_down");
|
detectorName.push_back("left_down");
|
||||||
@ -84,44 +92,58 @@ int main(int argc, char *argv[])
|
|||||||
detectorName.push_back("right_up");
|
detectorName.push_back("right_up");
|
||||||
detectorName.push_back("bottom_down");
|
detectorName.push_back("bottom_down");
|
||||||
detectorName.push_back("bottom_up");
|
detectorName.push_back("bottom_up");
|
||||||
header->Set("RunInfo/Histo Names", "TStringVector", detectorName);
|
header->Set("RunInfo/Histo Names", detectorName);
|
||||||
|
|
||||||
TIntVector t0;
|
TIntVector t0;
|
||||||
for (UInt_t i=0; i<8; i++) t0.push_back(3419);
|
for (UInt_t i=0; i<8; i++) t0.push_back(3419);
|
||||||
header->Set("RunInfo/Time Zero Bin", "TIntVector", t0);
|
header->Set("RunInfo/Time Zero Bin", t0);
|
||||||
|
|
||||||
TStringVector dummyTest;
|
TStringVector dummyTest;
|
||||||
dummyTest.push_back("dummy1");
|
dummyTest.push_back("dummy1");
|
||||||
dummyTest.push_back("dummy2");
|
dummyTest.push_back("dummy2");
|
||||||
dummyTest.push_back("dummy3");
|
dummyTest.push_back("dummy3");
|
||||||
header->Set("RunInfo/Dummy Test", "TStringVector", dummyTest);
|
header->Set("RunInfo/Dummy Test", dummyTest);
|
||||||
|
|
||||||
// sample environment
|
// sample environment
|
||||||
header->Set("SampleEnv/Cryo", "TString", "Konti-1");
|
header->Set("SampleEnv/Cryo", "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");
|
prop.Set("CF2", 3.2, 3.22, 0.04, "K");
|
||||||
header->Set("SampleEnv/Dummy Prop", "TPsiRunProperty", *prop);
|
header->Set("SampleEnv/CF2", prop);
|
||||||
|
|
||||||
|
prop.Set("CF3", PRH_UNDEFINED, 3.27, 0.09, "K", "strange temperature");
|
||||||
|
header->Set("SampleEnv/CF3", prop);
|
||||||
|
|
||||||
|
prop.Set("CF4", 3.25, 3.28, "K");
|
||||||
|
header->Set("SampleEnv/CF4", prop);
|
||||||
|
|
||||||
|
prop.Set("CF5", 3.26, 3.29, "K", "another strange temperature");
|
||||||
|
header->Set("SampleEnv/CF5", prop);
|
||||||
|
|
||||||
|
prop.Set("Dummy Prop", -2.0, -2.001, 0.002, "SI-unit");
|
||||||
|
header->Set("SampleEnv/Dummy Prop", prop);
|
||||||
|
|
||||||
// magnetic field environment
|
// magnetic field environment
|
||||||
header->Set("MagFieldEnv/Name", "TString", "Bpar");
|
header->Set("MagFieldEnv/Name", "Bpar");
|
||||||
prop = new TPsiRunProperty("Current", 1.34, "A");
|
prop.Set("Current", 1.34, "A");
|
||||||
header->Set("MagFieldEnv/Current", "TPsiRunProperty", *prop);
|
header->Set("MagFieldEnv/Current", prop);
|
||||||
|
|
||||||
// beamline
|
// beamline
|
||||||
header->Set("Beamline/WSX61a", "TString", "DAC = 3289, ADC = 0.800");
|
header->Set("Beamline/WSX61a", "DAC = 3289, ADC = 0.800");
|
||||||
|
|
||||||
TIntVector dummyInt;
|
TIntVector dummyInt;
|
||||||
for (UInt_t i=0; i<3; i++) dummyInt.push_back(i+1000);
|
for (UInt_t i=0; i<3; i++) dummyInt.push_back(i+1000);
|
||||||
header->Set("Beamline/Dummy Int", "TIntVector", dummyInt);
|
header->Set("Beamline/Dummy Int", dummyInt);
|
||||||
|
|
||||||
|
|
||||||
// scaler
|
// scaler
|
||||||
header->Set("Scaler/Ip", "Int_t", 12332123);
|
header->Set("Scaler/Ip", 12332123);
|
||||||
|
|
||||||
if (!header->IsValid()) {
|
if (!header->IsValid(strict)) {
|
||||||
cerr << endl << ">> **ERROR** run header validation failed." << endl;
|
cerr << endl << ">> **ERROR** run header validation failed." << endl;
|
||||||
|
if (strict) { // clean up and quit
|
||||||
|
delete header;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TFile *f = new TFile(argv[1], "RECREATE", "psi_runHeader_test");
|
TFile *f = new TFile(argv[1], "RECREATE", "psi_runHeader_test");
|
||||||
@ -135,23 +157,23 @@ int main(int argc, char *argv[])
|
|||||||
gROOT->GetListOfBrowsables()->Add(runHeader, "RunHeaderInfo");
|
gROOT->GetListOfBrowsables()->Add(runHeader, "RunHeaderInfo");
|
||||||
|
|
||||||
TObjArray runInfo;
|
TObjArray runInfo;
|
||||||
header->Get("RunInfo", runInfo);
|
header->GetHeaderInfo("RunInfo", runInfo);
|
||||||
runHeader->Add(&runInfo);
|
runHeader->Add(&runInfo);
|
||||||
|
|
||||||
TObjArray sampleEnv;
|
TObjArray sampleEnv;
|
||||||
header->Get("SampleEnv", sampleEnv);
|
header->GetHeaderInfo("SampleEnv", sampleEnv);
|
||||||
runHeader->Add(&sampleEnv);
|
runHeader->Add(&sampleEnv);
|
||||||
|
|
||||||
TObjArray magFieldEnv;
|
TObjArray magFieldEnv;
|
||||||
header->Get("MagFieldEnv", magFieldEnv);
|
header->GetHeaderInfo("MagFieldEnv", magFieldEnv);
|
||||||
runHeader->Add(&magFieldEnv);
|
runHeader->Add(&magFieldEnv);
|
||||||
|
|
||||||
TObjArray beamline;
|
TObjArray beamline;
|
||||||
header->Get("Beamline", beamline);
|
header->GetHeaderInfo("Beamline", beamline);
|
||||||
runHeader->Add(&beamline);
|
runHeader->Add(&beamline);
|
||||||
|
|
||||||
TObjArray scaler;
|
TObjArray scaler;
|
||||||
header->Get("Scaler", scaler);
|
header->GetHeaderInfo("Scaler", scaler);
|
||||||
runHeader->Add(&scaler);
|
runHeader->Add(&scaler);
|
||||||
|
|
||||||
runHeader->Write();
|
runHeader->Write();
|
||||||
@ -177,7 +199,7 @@ int main(int argc, char *argv[])
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
runInfo = 0;
|
runHeader = 0;
|
||||||
f->GetObject("RunHeaderInfo", runHeader);
|
f->GetObject("RunHeaderInfo", runHeader);
|
||||||
if (runHeader == 0) {
|
if (runHeader == 0) {
|
||||||
cerr << endl << ">> **ERROR** Couldn't get top folder RunHeaderInfo";
|
cerr << endl << ">> **ERROR** Couldn't get top folder RunHeaderInfo";
|
||||||
@ -186,7 +208,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
TObjArray *oarray = 0;
|
TObjArray *oarray = 0;
|
||||||
header = new TPsiRunHeader();
|
header = new TPsiRunHeader(argv[2]);
|
||||||
|
|
||||||
// get RunHeader
|
// get RunHeader
|
||||||
oarray = (TObjArray*) runHeader->FindObjectAny("RunInfo");
|
oarray = (TObjArray*) runHeader->FindObjectAny("RunInfo");
|
||||||
@ -223,10 +245,73 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
header->ExtractHeaderInformation(oarray, "Scaler");
|
header->ExtractHeaderInformation(oarray, "Scaler");
|
||||||
|
|
||||||
header->DumpHeader();
|
|
||||||
|
|
||||||
f->Close();
|
f->Close();
|
||||||
delete f;
|
delete f;
|
||||||
|
|
||||||
|
if (!header->IsValid(strict)) {
|
||||||
|
cerr << endl << ">> **ERROR** run header validation failed." << endl;
|
||||||
|
if (strict) { // clean up and quit
|
||||||
|
delete header;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
TIntVector ivec;
|
||||||
|
TPsiRunProperty prop1;
|
||||||
|
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/Histo Names", strVec, ok);
|
||||||
|
if (ok) {
|
||||||
|
cout << endl << "Histo Names: ";
|
||||||
|
for (UInt_t i=0; i<strVec.size()-1; i++) {
|
||||||
|
cout << strVec[i].Data() << ", ";
|
||||||
|
}
|
||||||
|
cout << strVec[strVec.size()-1].Data();
|
||||||
|
} else {
|
||||||
|
cout << endl << "**ERROR** Couldn't obtain the 'Histo Names'.";
|
||||||
|
}
|
||||||
|
|
||||||
|
header->GetValue("RunInfo/Time Zero Bin", ivec, ok);
|
||||||
|
if (ok) {
|
||||||
|
cout << endl << "Time Zero Bin: ";
|
||||||
|
for (UInt_t i=0; i<ivec.size()-1; i++) {
|
||||||
|
cout << ivec[i] << ", ";
|
||||||
|
}
|
||||||
|
cout << ivec[ivec.size()-1];
|
||||||
|
} else {
|
||||||
|
cout << endl << "**ERROR** Couldn't obtain the 'Time Zero Bin'.";
|
||||||
|
}
|
||||||
|
|
||||||
|
header->GetValue("RunInfo/Sample Temperature", prop1, ok);
|
||||||
|
if (ok) {
|
||||||
|
cout << endl << "Sample Temperature: " << prop1.GetValue() << " +- " << prop1.GetError() << " " << prop1.GetUnit().Data() << "; SP: " << prop1.GetDemand() << "; " << prop1.GetDescription().Data();
|
||||||
|
} else {
|
||||||
|
cout << endl << "**ERROR** Couldn't obtain the 'Sample Temperature'.";
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << endl << endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
132
src/tests/PsiRoot/read_psi_runHeader.cpp
Normal file
132
src/tests/PsiRoot/read_psi_runHeader.cpp
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
|
||||||
|
read_psi_runHeader.cpp
|
||||||
|
|
||||||
|
Author: Andreas Suter
|
||||||
|
e-mail: andreas.suter@psi.ch
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* Copyright (C) 2007-2011 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 <iostream>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
#include <TROOT.h>
|
||||||
|
#include <TFile.h>
|
||||||
|
#include <TFolder.h>
|
||||||
|
|
||||||
|
#include "TPsiRunHeader.h"
|
||||||
|
|
||||||
|
void read_psi_runHeader_syntax()
|
||||||
|
{
|
||||||
|
cout << endl << "usage: read_psi_runHeader <fileName> <headerDefinition> [<strict>]";
|
||||||
|
cout << endl << " <fileName> is the file name including the extention root, e.g. test.root";
|
||||||
|
cout << endl << " <headerDefinition> is the header definition XML-file.";
|
||||||
|
cout << endl << " <strict> 'strict'=strict validation; otherwise=less strict validation.";
|
||||||
|
cout << endl << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
if ((argc != 3) && (argc != 4)) {
|
||||||
|
read_psi_runHeader_syntax();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Bool_t strict = false;
|
||||||
|
if (argc == 4) {
|
||||||
|
if (!strcmp(argv[3], "strict"))
|
||||||
|
strict = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// read the file back and extract the header info
|
||||||
|
TFile *f = new TFile(argv[1], "READ", "read_psi_runHeader");
|
||||||
|
if (f->IsZombie()) {
|
||||||
|
delete f;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
TFolder *runHeader = 0;
|
||||||
|
f->GetObject("RunHeaderInfo", runHeader);
|
||||||
|
if (runHeader == 0) {
|
||||||
|
cerr << endl << ">> **ERROR** Couldn't get top folder RunHeaderInfo";
|
||||||
|
f->Close();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
TObjArray *oarray = 0;
|
||||||
|
TPsiRunHeader *header = new TPsiRunHeader(argv[2]);
|
||||||
|
|
||||||
|
// get RunHeader
|
||||||
|
oarray = (TObjArray*) runHeader->FindObjectAny("RunInfo");
|
||||||
|
if (oarray == 0) {
|
||||||
|
cerr << endl << ">> **ERROR** Couldn't get RunInfo" << endl;
|
||||||
|
}
|
||||||
|
header->ExtractHeaderInformation(oarray, "RunInfo");
|
||||||
|
|
||||||
|
// get SampleEnv
|
||||||
|
oarray = (TObjArray*) runHeader->FindObjectAny("SampleEnv");
|
||||||
|
if (oarray == 0) {
|
||||||
|
cerr << endl << ">> **ERROR** Couldn't get SampleEnv" << endl;
|
||||||
|
}
|
||||||
|
header->ExtractHeaderInformation(oarray, "SampleEnv");
|
||||||
|
|
||||||
|
// get MagFieldEnv
|
||||||
|
oarray = (TObjArray*) runHeader->FindObjectAny("MagFieldEnv");
|
||||||
|
if (oarray == 0) {
|
||||||
|
cerr << endl << ">> **ERROR** Couldn't get MagFieldEnv" << endl;
|
||||||
|
}
|
||||||
|
header->ExtractHeaderInformation(oarray, "MagFieldEnv");
|
||||||
|
|
||||||
|
// get Beamline
|
||||||
|
oarray = (TObjArray*) runHeader->FindObjectAny("Beamline");
|
||||||
|
if (oarray == 0) {
|
||||||
|
cerr << endl << ">> **ERROR** Couldn't get Beamline" << endl;
|
||||||
|
}
|
||||||
|
header->ExtractHeaderInformation(oarray, "Beamline");
|
||||||
|
|
||||||
|
// get Scaler
|
||||||
|
oarray = (TObjArray*) runHeader->FindObjectAny("Scaler");
|
||||||
|
if (oarray == 0) {
|
||||||
|
cerr << endl << ">> **ERROR** Couldn't get Scaler" << endl;
|
||||||
|
}
|
||||||
|
header->ExtractHeaderInformation(oarray, "Scaler");
|
||||||
|
|
||||||
|
f->Close();
|
||||||
|
delete f;
|
||||||
|
|
||||||
|
if (!header->IsValid(strict)) {
|
||||||
|
cerr << endl << ">> **ERROR** run header validation failed." << endl;
|
||||||
|
if (strict) { // clean up and quit
|
||||||
|
delete header;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
header->DumpHeader();
|
||||||
|
|
||||||
|
cout << endl << endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
233
src/tests/PsiRoot/write_psi_runHeader.cpp
Normal file
233
src/tests/PsiRoot/write_psi_runHeader.cpp
Normal file
@ -0,0 +1,233 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
|
||||||
|
write_runHeader.cpp
|
||||||
|
|
||||||
|
Author: Andreas Suter
|
||||||
|
e-mail: andreas.suter@psi.ch
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* Copyright (C) 2007-2011 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 <cstdlib>
|
||||||
|
#include <ctime>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
#include <TROOT.h>
|
||||||
|
#include <TFile.h>
|
||||||
|
#include <TFolder.h>
|
||||||
|
|
||||||
|
#include "TPsiRunHeader.h"
|
||||||
|
|
||||||
|
void write_psi_runHeader_syntax()
|
||||||
|
{
|
||||||
|
cout << endl << "usage: write_psi_runHeader <fileName> <headerDefinition> [<strict>]";
|
||||||
|
cout << endl << " <fileName> is the file name including the extention root, e.g. test.root";
|
||||||
|
cout << endl << " <headerDefinition> is the header definition XML-file.";
|
||||||
|
cout << endl << " <strict> 'strict'=strict validation; otherwise=less strict validation.";
|
||||||
|
cout << endl << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
if ((argc != 3) && (argc != 4)) {
|
||||||
|
write_psi_runHeader_syntax();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Bool_t strict = false;
|
||||||
|
if (argc == 4) {
|
||||||
|
if (!strcmp(argv[3], "strict"))
|
||||||
|
strict = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// PSI Run Header object
|
||||||
|
TPsiRunHeader *header = new TPsiRunHeader(argv[2]);
|
||||||
|
TPsiRunProperty prop;
|
||||||
|
|
||||||
|
// run info
|
||||||
|
header->Set("RunInfo/Version", "$Id$");
|
||||||
|
header->Set("RunInfo/Generator", "any2many");
|
||||||
|
header->Set("RunInfo/File Name", "thisIsAFileName");
|
||||||
|
header->Set("RunInfo/Run Title", "here comes the run title");
|
||||||
|
header->Set("RunInfo/Run Number", 577);
|
||||||
|
|
||||||
|
// run info - start/stop time and duration
|
||||||
|
TString startTime("2011-04-19 14:25:22"), stopTime("2011-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));
|
||||||
|
header->Set("RunInfo/Run Duration", (Int_t)duration);
|
||||||
|
|
||||||
|
header->Set("RunInfo/Laboratory", "PSI");
|
||||||
|
header->Set("RunInfo/Area", "piM3.2");
|
||||||
|
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/Setup", "a very special setup");
|
||||||
|
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);
|
||||||
|
|
||||||
|
TStringVector detectorName;
|
||||||
|
detectorName.push_back("forward");
|
||||||
|
detectorName.push_back("top");
|
||||||
|
detectorName.push_back("backward");
|
||||||
|
detectorName.push_back("bottom");
|
||||||
|
header->Set("RunInfo/Histo Names", detectorName);
|
||||||
|
|
||||||
|
header->Set("RunInfo/Histo Length", 8192);
|
||||||
|
|
||||||
|
prop.Set("Time Resolution", 0.193525, "ns", "TDC 9999");
|
||||||
|
header->Set("RunInfo/Time Resolution", prop);
|
||||||
|
|
||||||
|
TIntVector t0;
|
||||||
|
for (UInt_t i=0; i<4; i++) t0.push_back(215+(Int_t)(5.0*(Double_t)rand()/(Double_t)RAND_MAX));
|
||||||
|
header->Set("RunInfo/Time Zero Bin", t0);
|
||||||
|
for (UInt_t i=0; i<4; i++) t0[i] += 12;
|
||||||
|
header->Set("RunInfo/First Good Bin", t0);
|
||||||
|
for (UInt_t i=0; i<4; i++) t0[i] = 8191;
|
||||||
|
header->Set("RunInfo/Last Good Bin", t0);
|
||||||
|
|
||||||
|
TIntVector readGreenOffset;
|
||||||
|
readGreenOffset.push_back(0);
|
||||||
|
readGreenOffset.push_back(10);
|
||||||
|
readGreenOffset.push_back(20);
|
||||||
|
readGreenOffset.push_back(30);
|
||||||
|
header->Set("RunInfo/Red-Green Offsets", readGreenOffset);
|
||||||
|
|
||||||
|
TStringVector redGreenDescription;
|
||||||
|
redGreenDescription.push_back("E-field/light off/off");
|
||||||
|
redGreenDescription.push_back("E-field/light on/off");
|
||||||
|
redGreenDescription.push_back("E-field/light off/on");
|
||||||
|
redGreenDescription.push_back("E-field/light on/on");
|
||||||
|
header->Set("RunInfo/Red-Green Description", redGreenDescription);
|
||||||
|
|
||||||
|
TStringVector dummyTest;
|
||||||
|
dummyTest.push_back("dummy1");
|
||||||
|
dummyTest.push_back("dummy2");
|
||||||
|
dummyTest.push_back("dummy3");
|
||||||
|
header->Set("RunInfo/Dummy Test", dummyTest);
|
||||||
|
|
||||||
|
// sample environment
|
||||||
|
header->Set("SampleEnv/Cryo", "Konti-1");
|
||||||
|
header->Set("SampleEnv/Insert", "X123");
|
||||||
|
header->Set("SampleEnv/Orientation", "c-axis perp spin, perp field. spin perp field");
|
||||||
|
|
||||||
|
prop.Set("CF2", 3.2, 3.22, 0.04, "K");
|
||||||
|
header->Set("SampleEnv/CF2", prop);
|
||||||
|
|
||||||
|
prop.Set("CF3", PRH_UNDEFINED, 3.27, 0.09, "K", "strange temperature");
|
||||||
|
header->Set("SampleEnv/CF3", prop);
|
||||||
|
|
||||||
|
prop.Set("CF4", 3.25, 3.28, "K");
|
||||||
|
header->Set("SampleEnv/CF4", prop);
|
||||||
|
|
||||||
|
prop.Set("CF5", 3.26, 3.29, "K", "another strange temperature");
|
||||||
|
header->Set("SampleEnv/CF5", prop);
|
||||||
|
|
||||||
|
prop.Set("Dummy Prop", -2.0, -2.001, 0.002, "SI-unit");
|
||||||
|
header->Set("SampleEnv/Dummy Prop", prop);
|
||||||
|
|
||||||
|
// magnetic field environment
|
||||||
|
header->Set("MagFieldEnv/Name", "Bpar");
|
||||||
|
prop.Set("Current", 1.34, "A");
|
||||||
|
header->Set("MagFieldEnv/Current", prop);
|
||||||
|
|
||||||
|
// beamline
|
||||||
|
header->Set("Beamline/WSX61a", "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", dummyInt);
|
||||||
|
|
||||||
|
|
||||||
|
// scaler
|
||||||
|
header->Set("Scaler/Ip", 12332123);
|
||||||
|
|
||||||
|
if (!header->IsValid(strict)) {
|
||||||
|
cerr << endl << ">> **ERROR** run header validation failed." << endl;
|
||||||
|
if (strict) { // clean up and quit
|
||||||
|
delete header;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TFile *f = new TFile(argv[1], "RECREATE", "psi_runHeader_test");
|
||||||
|
if (f->IsZombie()) {
|
||||||
|
delete f;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// root file header related things
|
||||||
|
TFolder *runHeader = gROOT->GetRootFolder()->AddFolder("RunHeaderInfo", "PSI Run Header Info");
|
||||||
|
gROOT->GetListOfBrowsables()->Add(runHeader, "RunHeaderInfo");
|
||||||
|
|
||||||
|
TObjArray runInfo;
|
||||||
|
header->GetHeaderInfo("RunInfo", runInfo);
|
||||||
|
runHeader->Add(&runInfo);
|
||||||
|
|
||||||
|
TObjArray sampleEnv;
|
||||||
|
header->GetHeaderInfo("SampleEnv", sampleEnv);
|
||||||
|
runHeader->Add(&sampleEnv);
|
||||||
|
|
||||||
|
TObjArray magFieldEnv;
|
||||||
|
header->GetHeaderInfo("MagFieldEnv", magFieldEnv);
|
||||||
|
runHeader->Add(&magFieldEnv);
|
||||||
|
|
||||||
|
TObjArray beamline;
|
||||||
|
header->GetHeaderInfo("Beamline", beamline);
|
||||||
|
runHeader->Add(&beamline);
|
||||||
|
|
||||||
|
TObjArray scaler;
|
||||||
|
header->GetHeaderInfo("Scaler", scaler);
|
||||||
|
runHeader->Add(&scaler);
|
||||||
|
|
||||||
|
runHeader->Write();
|
||||||
|
|
||||||
|
f->Close();
|
||||||
|
|
||||||
|
delete f;
|
||||||
|
f = 0;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Reference in New Issue
Block a user