work in the direction of MusrROOT data file format. Use XSD instead of XML to validate. Work in progress ...

This commit is contained in:
suter_a 2012-01-12 09:55:19 +00:00
parent d2e6eacad2
commit 634077d772
12 changed files with 1519 additions and 2184 deletions

View File

@ -61,36 +61,36 @@ LIBS = $(ROOTLIBS) -lXMLParser
GLIBS = $(ROOTGLIBS) -lXMLParser
# PSI libs
PSILIBS = -lTPsiRunHeader
PSILIBS = -lTMusrRunHeader
EXEC =
EXEC += psi_runHeader_test
EXEC += write_psi_runHeader
EXEC += read_psi_runHeader
EXEC += musrRoot_runHeader_test
EXEC += write_musrRoot_runHeader
EXEC += read_musrRoot_runHeader
# some definitions: headers (used to generate *Dict* stuff), sources, objects,...
OBJS =
OBJS += psi_runHeader_test.o
OBJS += write_psi_runHeader.o
OBJS += read_psi_runHeader.o
OBJS += musrRoot_runHeader_test.o
OBJS += write_musrRoot_runHeader.o
OBJS += read_musrRoot_runHeader.o
# make the executable:
#
all: $(EXEC)
psi_runHeader_test: psi_runHeader_test.o
@echo "---> Building psi_runHeader_test ..."
$(LD) psi_runHeader_test.o -o psi_runHeader_test $(GLIBS) $(PSILIBS)
musrRoot_runHeader_test: musrRoot_runHeader_test.o
@echo "---> Building musrRoot_runHeader_test ..."
$(LD) musrRoot_runHeader_test.o -o musrRoot_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)
write_musrRoot_runHeader: write_musrRoot_runHeader.o
@echo "---> Building write_musrRoot_runHeader ..."
$(LD) write_musrRoot_runHeader.o -o write_musrRoot_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)
read_musrRoot_runHeader: read_musrRoot_runHeader.o
@echo "---> Building read_musrRoot_runHeader ..."
$(LD) read_musrRoot_runHeader.o -o read_musrRoot_runHeader $(GLIBS) $(PSILIBS)
@echo "done"
# clean up: remove all object file (and core files)

View File

@ -1,18 +1,18 @@
# Makefile for TPH1F
# Makefile for TMusrRunHeader
#
# Copyright (c) 2000 Rene Brun and Fons Rademakers
#
# Author: Fons Rademakers, 29/2/2000
#
# modified: Andreas Suter, 14/04/2004
# modified: Thomas Prokscha, 30/01/2007
# modified: Andreas Suter, 12/01/2012
#
# $Id$
#
include Makefile.arch
#------------------------------------------------------------------------------
# TPsiRunHeader
TNAME = TPsiRunHeader
# TMusrRunHeader
TNAME = TMusrRunHeader
TLRHO = $(TNAME).$(ObjSuf) $(TNAME)Dict.$(ObjSuf)
TLRHS = $(TNAME).$(SrcSuf) $(TNAME)Dict.$(SrcSuf)
TLRHSO = lib$(TNAME).$(DllSuf)
@ -84,7 +84,7 @@ distclean: clean
@rm -rf cxx_repository
-@cd RootShower && $(MAKE) distclean
install:
install: $(TLRHS) $(TLRHSO)
ifeq ($(ARCH),linux)
cp -pv $(MYLIBS)/$(TLRHSO) $(ROOTSYS)/lib
cp -pv $(MYINCLUDES)/$(TNAME).h $(ROOTSYS)/include

View File

@ -10,7 +10,7 @@ ARCH := $(shell root-config --arch)
CXX =
ObjSuf = o
SrcSuf = cxx
SrcSuf = cpp
ExeSuf =
DllSuf = so
OutPutOpt = -o # keep whitespace after "-o"

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
/***************************************************************************
TPsiRunHeader.h
TMusrRunHeader.h
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
@ -10,7 +10,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2011 by Andreas Suter *
* Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
@ -29,28 +29,30 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef TPSIRUNHEADER_H
#define TPSIRUNHEADER_H
#ifndef TMUSRRUNHEADER_H
#define TMUSRRUNHEADER_H
#include <TDatime.h>
#include <TObject.h>
#include <TQObject.h>
#include <TObjString.h>
#include <TObjArray.h>
#include <TMap.h>
#include <TSAXParser.h>
#define PRH_UNDEFINED -9.99e99
#define MRRH_UNDEFINED -9.99e99
typedef vector<Int_t> TIntVector;
typedef vector<Double_t> TDoubleVector;
typedef vector<TString> TStringVector;
//-------------------------------------------------------------------------
template <class T> class TPsiRunObject : public TObject
template <class T> class TMusrRunObject : 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() {}
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; }
@ -67,14 +69,14 @@ private:
};
//-------------------------------------------------------------------------
class TPsiRunProperty : public TObject
class TMusrRunPhysicalQuantity : public TObject
{
public:
TPsiRunProperty();
TPsiRunProperty(TString label, 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, TString unit, TString description = TString("n/a"));
TPsiRunProperty(TString label, Double_t value, TString unit, TString description = TString("n/a"));
virtual ~TPsiRunProperty() {}
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; }
@ -98,88 +100,47 @@ public:
private:
TString fLabel; ///< property label, like Sample Temperature etc.
Double_t fDemand; ///< demand value of the property, e.g. temperature setpoint
Double_t fValue; ///< measured value of the property
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
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(TPsiRunProperty, 1)
ClassDef(TMusrRunPhysicalQuantity, 1)
};
//-------------------------------------------------------------------------
class TPsiEntry
class TMusrRunHeader : public TObject
{
public:
TPsiEntry() { fPathName = "n/a"; fType = "n/a"; }
TPsiEntry(TString pathName, TString type) : fPathName(pathName), fType(type) {}
virtual ~TPsiEntry() {}
TMusrRunHeader();
TMusrRunHeader(const char *fileName);
virtual ~TMusrRunHeader();
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:
TPsiRunHeader(const char *headerDefinition);
virtual ~TPsiRunHeader();
virtual Bool_t IsValid(Bool_t strict = false);
virtual TString GetFileName() { return fFileName; }
virtual void GetHeaderInfo(TString path, TObjArray &content);
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, TPsiRunProperty &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 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 TMap* GetMap() { return &fMap; }
virtual void SetFileName(TString fln) { fFileName = fln; }
virtual void SetMap(TMap* map);
virtual void Set(TString pathName, TString value, Bool_t addMap=true);
virtual void Set(TString pathName, Int_t value, Bool_t addMap=true);
virtual void Set(TString pathName, Double_t value, Bool_t addMap=true);
virtual void Set(TString pathName, TMusrRunPhysicalQuantity value, Bool_t addMap=true);
virtual void Set(TString pathName, TStringVector value, Bool_t addMap=true);
virtual void Set(TString pathName, TIntVector value, Bool_t addMap=true);
virtual void Set(TString pathName, TDoubleVector value, Bool_t addMap=true);
virtual Bool_t ExtractHeaderInformation(TObjArray *headerInfo, TString path);
@ -187,22 +148,27 @@ public:
virtual void DrawHeader();
private:
TString fHeaderDefinition;
TString fFileName;
vector< TPsiRunObject<TString> > fStringObj;
vector< TPsiRunObject<Int_t> > fIntObj;
vector< TPsiRunObject<TPsiRunProperty> > fPsiRunPropertyObj;
vector< TPsiRunObject<TStringVector> > fStringVectorObj;
vector< TPsiRunObject<TIntVector> > fIntVectorObj;
vector< TMusrRunObject<TString> > fStringObj;
vector< TMusrRunObject<Int_t> > fIntObj;
vector< TMusrRunObject<Double_t> > fDoubleObj;
vector< TMusrRunObject<TMusrRunPhysicalQuantity> > fMusrRunPhysQuantityObj;
vector< TMusrRunObject<TStringVector> > fStringVectorObj;
vector< TMusrRunObject<TIntVector> > fIntVectorObj;
vector< TMusrRunObject<TDoubleVector> > fDoubleVectorObj;
TStringVector fFolder;
vector<TPsiEntry> fEntry;
TMap fMap; ///< maps run header label to its root type, e.g. 'Run Number' -> 'Int_t' or 'Time Resolution' -> 'TMusrRunPhysicalQuantity'
virtual void Init();
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 Bool_t FolderPresent(TString &path);
ClassDef(TPsiRunHeader, 1)
ClassDef(TMusrRunHeader, 1)
};
#endif // TPSIRUNHEADER_H
#endif // TMUSRRUNHEADER_H

View File

@ -1,6 +1,6 @@
/***************************************************************************
TPsiRunHeader2LinkDef.h
TMusrRunHeaderLinkDef.h
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
@ -10,7 +10,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2011 by Andreas Suter *
* Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
@ -35,8 +35,7 @@
#pragma link off all classes;
#pragma link off all functions;
#pragma link C++ class TPsiRunProperty+;
#pragma link C++ class TPsiStartupHandler+;
#pragma link C++ class TPsiRunHeader+;
#pragma link C++ class TMusrRunPhysicalQuantity+;
#pragma link C++ class TMusrRunHeader+;
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
/***************************************************************************
psi_runHeader_test.cpp
musrRoot_runHeader_test.cpp
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
@ -10,7 +10,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2011 by Andreas Suter *
* Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
@ -36,39 +36,31 @@ using namespace std;
#include <TFile.h>
#include <TFolder.h>
#include "TPsiRunHeader.h"
#include "TMusrRunHeader.h"
void psi_runHeader_test_syntax()
void musrRoot_runHeader_test_syntax()
{
cout << endl << "usage: psi_runHeader_test <fileName> <headerDefinition> [<strict>]";
cout << endl << "usage: musrRoot_runHeader_test <fileName>";
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)) {
psi_runHeader_test_syntax();
if (argc != 2) {
musrRoot_runHeader_test_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;
// MusrRoot Run Header object
TMusrRunHeader *header = new TMusrRunHeader(argv[1]);
TMusrRunPhysicalQuantity 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 Title", "here comes the run title");
header->Set("RunInfo/Run Number", 576);
header->Set("RunInfo/Run Number", 577);
header->Set("RunInfo/Run Start Time", "2011-04-19 14:25:22");
@ -80,7 +72,7 @@ int main(int argc, char *argv[])
prop.Set("Sample Temperature", 3.2, 3.21, 0.05, "K", "CF1");
header->Set("RunInfo/Sample Temperature", prop);
prop.Set("Muon Beam Momentum", PRH_UNDEFINED, 28.1, PRH_UNDEFINED, "MeV/c");
prop.Set("Muon Beam Momentum", MRRH_UNDEFINED, 28.1, MRRH_UNDEFINED, "MeV/c");
header->Set("RunInfo/Muon Beam Momentum", prop);
TStringVector detectorName;
@ -94,8 +86,8 @@ int main(int argc, char *argv[])
detectorName.push_back("bottom_up");
header->Set("RunInfo/Histo Names", detectorName);
TIntVector t0;
for (UInt_t i=0; i<8; i++) t0.push_back(3419);
TDoubleVector t0;
for (UInt_t i=0; i<8; i++) t0.push_back(3419.0);
header->Set("RunInfo/Time Zero Bin", t0);
TStringVector dummyTest;
@ -110,7 +102,7 @@ int main(int argc, char *argv[])
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");
prop.Set("CF3", MRRH_UNDEFINED, 3.27, 0.09, "K", "strange temperature");
header->Set("SampleEnv/CF3", prop);
prop.Set("CF4", 3.25, 3.28, "K");
@ -134,26 +126,17 @@ int main(int argc, char *argv[])
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");
TFile *f = new TFile(argv[1], "RECREATE", "musrRoot_runHeader_test");
if (f->IsZombie()) {
delete f;
return -1;
}
// root file header related things
TFolder *runHeader = gROOT->GetRootFolder()->AddFolder("RunHeader", "PSI Run Header Info");
TFolder *runHeader = gROOT->GetRootFolder()->AddFolder("RunHeader", "MusrRoot Run Header Info");
gROOT->GetListOfBrowsables()->Add(runHeader, "RunHeader");
TObjArray runInfo;
@ -176,6 +159,9 @@ int main(int argc, char *argv[])
header->GetHeaderInfo("Scaler", scaler);
runHeader->Add(&scaler);
TMap *map = header->GetMap();
runHeader->Add(map);
runHeader->Write();
f->Close();
@ -193,7 +179,7 @@ int main(int argc, char *argv[])
cout << endl << "++++++++++++++++++++++++++++" << endl;
// read the file back and extract the header info
f = new TFile(argv[1], "READ", "psi_runHeader_test");
f = new TFile(argv[1], "READ", "musrRoot_runHeader_test");
if (f->IsZombie()) {
delete f;
return -1;
@ -208,7 +194,15 @@ int main(int argc, char *argv[])
}
TObjArray *oarray = 0;
header = new TPsiRunHeader(argv[2]);
header = new TMusrRunHeader(argv[1]);
map = (TMap*) runHeader->FindObjectAny("__map");
if (map == 0) {
cerr << endl << ">> **ERROR** couldn't find required __map :-(" << endl;
f->Close();
return -1;
}
header->SetMap(map);
// get RunHeader
oarray = (TObjArray*) runHeader->FindObjectAny("RunInfo");
@ -248,14 +242,6 @@ int main(int argc, char *argv[])
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();
// get some information from the read file
@ -266,8 +252,8 @@ int main(int argc, char *argv[])
TString str("");
TStringVector strVec;
Int_t ival;
TIntVector ivec;
TPsiRunProperty prop1;
TDoubleVector dvec;
TMusrRunPhysicalQuantity prop1;
Bool_t ok;
header->GetValue("RunInfo/Run Title", str, ok);
@ -293,13 +279,13 @@ int main(int argc, char *argv[])
cout << endl << "**ERROR** Couldn't obtain the 'Histo Names'.";
}
header->GetValue("RunInfo/Time Zero Bin", ivec, ok);
header->GetValue("RunInfo/Time Zero Bin", dvec, ok);
if (ok) {
cout << endl << "Time Zero Bin: ";
for (UInt_t i=0; i<ivec.size()-1; i++) {
cout << ivec[i] << ", ";
for (UInt_t i=0; i<dvec.size()-1; i++) {
cout << dvec[i] << ", ";
}
cout << ivec[ivec.size()-1];
cout << dvec[dvec.size()-1];
} else {
cout << endl << "**ERROR** Couldn't obtain the 'Time Zero Bin'.";
}

View File

@ -1,165 +0,0 @@
<?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/Run Start Time</name>
<type>TString</type>
</entry>
<entry>
<name>RunInfo/Run Stop Time</name>
<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>
<name>RunInfo/Muon Beam Momentum</name>
<type>TPsiRunProperty</type>
</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>
<name>RunInfo/Histo Names</name>
<type>TStringVector</type>
</entry>
<entry>
<name>RunInfo/Histo Length</name>
<type>Int_t</type>
</entry>
<entry>
<name>RunInfo/Time Resolution</name>
<type>TPsiRunProperty</type>
</entry>
<entry>
<name>RunInfo/Time Zero Bin</name>
<type>TIntVector</type>
</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>
<name>RunInfo/Slow Control Histo Names</name>
<type>TStringVector</type>
</entry>
<entry>
<name>SampleEnv/Cryo</name>
<type>TString</type>
</entry>
<entry>
<name>SampleEnv/Insert</name>
<type>TString</type>
</entry>
<entry>
<name>SampleEnv/Orientation</name>
<type>TString</type>
</entry>
<entry>
<name>MagFieldEnv/Name</name>
<type>TString</type>
</entry>
<entry>
<name>MagFieldEnv/Current</name>
<type>TPsiRunProperty</type>
</entry>
<entry>
<name>Scaler/Ip</name>
<type>Int_t</type>
</entry>
</header_info>
</psi_root>

View File

@ -1,85 +0,0 @@
<?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>

View File

@ -1,6 +1,6 @@
/***************************************************************************
read_psi_runHeader.cpp
read_musrRoot_runHeader.cpp
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
@ -10,7 +10,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2011 by Andreas Suter *
* Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
@ -36,32 +36,24 @@ using namespace std;
#include <TFile.h>
#include <TFolder.h>
#include "TPsiRunHeader.h"
#include "TMusrRunHeader.h"
void read_psi_runHeader_syntax()
void read_musrRoot_runHeader_syntax()
{
cout << endl << "usage: read_psi_runHeader <fileName> <headerDefinition> [<strict>]";
cout << endl << "usage: read_musrRoot_runHeader <fileName>";
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();
if (argc != 2) {
read_musrRoot_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");
TFile *f = new TFile(argv[1], "READ", "read_musrRoot_runHeader");
if (f->IsZombie()) {
delete f;
return -1;
@ -76,54 +68,56 @@ int main(int argc, char *argv[])
}
TObjArray *oarray = 0;
TPsiRunHeader *header = new TPsiRunHeader(argv[2]);
TMusrRunHeader *header = new TMusrRunHeader(argv[1]);
// first read map!!
TMap *map = (TMap*) runHeader->FindObjectAny("__map");
if (map == 0) {
cerr << endl << ">> **ERROR** couldn't find required __map :-(" << endl;
f->Close();
return -1;
}
header->SetMap(map);
// get RunHeader
oarray = (TObjArray*) runHeader->FindObjectAny("RunInfo");
if (oarray == 0) {
cerr << endl << ">> **ERROR** Couldn't get RunInfo" << endl;
}
header->ExtractHeaderInformation(oarray, "RunInfo");
if (!header->ExtractHeaderInformation(oarray, "RunInfo")) return -1;
// get SampleEnv
oarray = (TObjArray*) runHeader->FindObjectAny("SampleEnv");
if (oarray == 0) {
cerr << endl << ">> **ERROR** Couldn't get SampleEnv" << endl;
}
header->ExtractHeaderInformation(oarray, "SampleEnv");
if (!header->ExtractHeaderInformation(oarray, "SampleEnv")) return -1;
// get MagFieldEnv
oarray = (TObjArray*) runHeader->FindObjectAny("MagFieldEnv");
if (oarray == 0) {
cerr << endl << ">> **ERROR** Couldn't get MagFieldEnv" << endl;
}
header->ExtractHeaderInformation(oarray, "MagFieldEnv");
if (!header->ExtractHeaderInformation(oarray, "MagFieldEnv")) return -1;
// get Beamline
oarray = (TObjArray*) runHeader->FindObjectAny("Beamline");
if (oarray == 0) {
cerr << endl << ">> **ERROR** Couldn't get Beamline" << endl;
}
header->ExtractHeaderInformation(oarray, "Beamline");
if (!header->ExtractHeaderInformation(oarray, "Beamline")) return -1;
// get Scaler
oarray = (TObjArray*) runHeader->FindObjectAny("Scaler");
if (oarray == 0) {
cerr << endl << ">> **ERROR** Couldn't get Scaler" << endl;
}
header->ExtractHeaderInformation(oarray, "Scaler");
if (!header->ExtractHeaderInformation(oarray, "Scaler")) return -1;
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;

View File

@ -1,6 +1,6 @@
/***************************************************************************
write_runHeader.cpp
write_musrRoot_runHeader.cpp
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
@ -10,7 +10,7 @@
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2011 by Andreas Suter *
* Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
@ -40,33 +40,25 @@ using namespace std;
#include <TFile.h>
#include <TFolder.h>
#include "TPsiRunHeader.h"
#include "TMusrRunHeader.h"
void write_psi_runHeader_syntax()
void write_musrRoot_runHeader_syntax()
{
cout << endl << "usage: write_psi_runHeader <fileName> <headerDefinition> [<strict>]";
cout << endl << "usage: write_musrRoot_runHeader <fileName>";
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();
if (argc != 2) {
write_musrRoot_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;
// MusrRoot Run Header object
TMusrRunHeader *header = new TMusrRunHeader(argv[1]);
TMusrRunPhysicalQuantity prop;
// run info
header->Set("RunInfo/Version", "$Id$");
@ -161,7 +153,7 @@ int main(int argc, char *argv[])
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");
prop.Set("CF3", MRRH_UNDEFINED, 3.27, 0.09, "K", "strange temperature");
header->Set("SampleEnv/CF3", prop);
prop.Set("CF4", 3.25, 3.28, "K");
@ -189,22 +181,14 @@ int main(int argc, char *argv[])
// 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");
TFile *f = new TFile(argv[1], "RECREATE", "write_musrRoot_runHeader");
if (f->IsZombie()) {
delete f;
return -1;
}
// root file header related things
TFolder *runHeader = gROOT->GetRootFolder()->AddFolder("RunHeader", "PSI Run Header Info");
TFolder *runHeader = gROOT->GetRootFolder()->AddFolder("RunHeader", "MusrRoot Run Header Info");
gROOT->GetListOfBrowsables()->Add(runHeader, "RunHeader");
TObjArray runInfo;
@ -227,6 +211,9 @@ int main(int argc, char *argv[])
header->GetHeaderInfo("Scaler", scaler);
runHeader->Add(&scaler);
TMap *map = header->GetMap();
runHeader->Add(map);
runHeader->Write();
f->Close();