From 138e7ba3697d853ae460ad21a7c425567535cdb4 Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Thu, 22 Mar 2012 07:00:34 +0000 Subject: [PATCH] first implementation of MusrRoot. Cleaner handling of Red/Green mode data. General cleanup --- ChangeLog | 8 + configure.ac | 34 +- doc/examples/test-asy-MUD.msr | 16 +- doc/examples/test-asy-NeXus2.msr | 2 +- doc/examples/test-asy-PSI-BIN.msr | 4 +- doc/examples/test-histo-NeXus.msr | 26 +- doc/examples/test-histo-NeXus2.msr | 4 +- src/Makefile.am | 16 +- src/any2many.cpp | 22 +- src/classes/Makefile.am | 4 +- src/classes/PFitter.cpp | 4 +- src/classes/PFitterFcn.cpp | 4 +- src/classes/PFourier.cpp | 4 +- src/classes/PFunction.cpp | 4 +- src/classes/PFunctionHandler.cpp | 4 +- src/classes/PMsr2Data.cpp | 2 +- src/classes/PMsrHandler.cpp | 102 +- src/classes/PMusr.cpp | 537 +++-- src/classes/PMusrCanvas.cpp | 2 +- src/classes/PMusrT0.cpp | 72 +- src/classes/PRunAsymmetry.cpp | 275 ++- src/classes/PRunBase.cpp | 2 +- src/classes/PRunDataHandler.cpp | 2060 ++++++++++++----- src/classes/PRunListCollection.cpp | 4 +- src/classes/PRunMuMinus.cpp | 4 +- src/classes/PRunNonMusr.cpp | 2 +- src/classes/PRunSingleHisto.cpp | 278 ++- src/classes/PStartupHandler.cpp | 4 +- src/classes/PTheory.cpp | 4 +- src/classes/PUserFcn.cpp | 4 +- src/classes/PUserFcnBase.cpp | 4 +- src/external/MusrRoot/Makefile.am | 40 + src/external/MusrRoot/MusrRoot.xsd | 196 ++ src/external/MusrRoot/MusrRootLEM.xsd | 222 ++ src/external/MusrRoot/TMusrRunHeader.cpp | 1691 ++++++++++++++ src/external/MusrRoot/TMusrRunHeader.h | 196 ++ src/external/MusrRoot/TMusrRunHeader.pc.in | 10 + .../external/MusrRoot/TMusrRunHeaderLinkDef.h | 24 +- src/external/MusrRoot/root2xml.C | 318 +++ src/external/nexus/PNeXus.cpp | 8 +- src/external/nexus/PNeXus.h | 2 +- src/external/scripts/msr2data | 763 ------ src/include/PFitter.h | 4 +- src/include/PFitterFcn.h | 4 +- src/include/PFourier.h | 4 +- src/include/PFunction.h | 4 +- src/include/PFunctionGrammar.h | 4 +- src/include/PFunctionHandler.h | 4 +- src/include/PMsr2Data.h | 2 +- src/include/PMsrHandler.h | 6 +- src/include/PMusr.h | 165 +- src/include/PMusrCanvas.h | 2 +- src/include/PMusrCanvasLinkDef.h | 2 +- src/include/PMusrT0.h | 20 +- src/include/PMusrT0LinkDef.h | 2 +- src/include/PRunAsymmetry.h | 4 +- src/include/PRunBase.h | 4 +- src/include/PRunDataHandler.h | 11 +- src/include/PRunListCollection.h | 4 +- src/include/PRunMuMinus.h | 4 +- src/include/PRunNonMusr.h | 4 +- src/include/PRunSingleHisto.h | 6 +- src/include/PStartupHandler.h | 4 +- src/include/PStartupHandlerLinkDef.h | 4 +- src/include/PTheory.h | 4 +- src/include/PUserFcn.h | 4 +- src/include/PUserFcnBase.h | 4 +- src/include/PUserFcnBaseLinkDef.h | 4 +- src/msr2data.cpp | 17 +- src/musrfit.cpp | 2 +- src/musrparam.cpp | 217 -- src/musrt0.cpp | 128 +- src/musrview.cpp | 2 +- src/nexus_dump.cpp | 10 +- src/read_musrRoot_runHeader.cpp | 103 + .../Makefile.PAddPoissonNoise | 0 .../PAddPoissonNoise.cpp | 0 .../PAddPoissonNoise.h | 0 .../PAddPoissonNoiseLinkDef.h | 0 src/tests/analyticFakeData/analyticFakeData.C | 266 +++ .../testPoisson.C | 0 src/tests/spirit/fcnInput.txt | 4 +- .../t0NotEqFirstGoodData.C | 164 -- src/write_musrRoot_runHeader.cpp | 242 ++ templates/h | 19 - 85 files changed, 5899 insertions(+), 2541 deletions(-) create mode 100644 src/external/MusrRoot/Makefile.am create mode 100644 src/external/MusrRoot/MusrRoot.xsd create mode 100644 src/external/MusrRoot/MusrRootLEM.xsd create mode 100644 src/external/MusrRoot/TMusrRunHeader.cpp create mode 100644 src/external/MusrRoot/TMusrRunHeader.h create mode 100644 src/external/MusrRoot/TMusrRunHeader.pc.in rename templates/cpp => src/external/MusrRoot/TMusrRunHeaderLinkDef.h (70%) mode change 100755 => 100644 create mode 100644 src/external/MusrRoot/root2xml.C delete mode 100644 src/external/scripts/msr2data delete mode 100644 src/musrparam.cpp create mode 100644 src/read_musrRoot_runHeader.cpp rename src/tests/{t0NotEqFirstGoodData => analyticFakeData}/Makefile.PAddPoissonNoise (100%) rename src/tests/{t0NotEqFirstGoodData => analyticFakeData}/PAddPoissonNoise.cpp (100%) rename src/tests/{t0NotEqFirstGoodData => analyticFakeData}/PAddPoissonNoise.h (100%) rename src/tests/{t0NotEqFirstGoodData => analyticFakeData}/PAddPoissonNoiseLinkDef.h (100%) create mode 100644 src/tests/analyticFakeData/analyticFakeData.C rename src/tests/{t0NotEqFirstGoodData => analyticFakeData}/testPoisson.C (100%) delete mode 100644 src/tests/t0NotEqFirstGoodData/t0NotEqFirstGoodData.C create mode 100644 src/write_musrRoot_runHeader.cpp delete mode 100755 templates/h diff --git a/ChangeLog b/ChangeLog index 2780af44..46a6e108 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,14 @@ # $Id$ #--------------------------------------------------------------------- +changes since 0.10.0 +=================================== +NEW 2012-03-22 added a first version of MusrRoot, the next muSR file format at PSI. At the same time a rewrite of + the low run data handling has been done which enables a proper Red/Green handling with histogram sets addressable + either via the histogram number or the index in the data vector. +CHANGED 2012-03-22 removed outdated musrparam.cpp. This program is not needed anymore since msr2data is much + more powerful and deals with all (and much more) options which where present in musrparam. + changes since 0.9.0 =================================== NEW 2011-12-22 added nexus_dump. It is used to dump nexus files in an ascii diff --git a/configure.ac b/configure.ac index 1fb1425a..bfe11f7d 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ AC_REVISION([$Id$]) AC_PREREQ(2.59) -AC_INIT(musrfit, 0.9.0, andreas.suter@psi.ch) +AC_INIT(musrfit, 0.10.0, andreas.suter@psi.ch) AC_CONFIG_AUX_DIR(admin) AC_CANONICAL_HOST #AC_MSG_RESULT([${host} ${host_cpu} ${host_vendor} ${host_os}]) @@ -21,6 +21,7 @@ dnl ----------------------------------------------- MUSR_PROGRAM_NAME=musrfit MUSR_LIBRARY_NAME=PMusr USERFCN_LIBRARY_NAME=PUserFcnBase +MUSR_ROOT_LIBRARY_NAME=TMusrRunHeader LEM_LIBRARY_NAME=TLemRunHeader PSIBIN_LIBRARY_NAME=Class_MuSR_PSI MUD_LIBRARY_NAME=mud @@ -34,9 +35,14 @@ dnl ----------------------------------------------- #release versioning MUSR_MAJOR_VERSION=0 -MUSR_MINOR_VERSION=9 +MUSR_MINOR_VERSION=10 MUSR_MICRO_VERSION=0 +#release versioning +MUSR_ROOT_MAJOR_VERSION=1 +MUSR_ROOT_MINOR_VERSION=0 +MUSR_ROOT_MICRO_VERSION=0 + #release versioning LEM_MAJOR_VERSION=1 LEM_MINOR_VERSION=5 @@ -71,6 +77,9 @@ CUBA_MICRO_VERSION=0 MUSR_API_VERSION=$MUSR_MAJOR_VERSION.$MUSR_MINOR_VERSION AC_SUBST(MUSR_API_VERSION) +MUSR_ROOT_API_VERSION=$MUSR_ROOT_MAJOR_VERSION.$MUSR_ROOT_MINOR_VERSION +AC_SUBST(MUSR_ROOT_API_VERSION) + LEM_API_VERSION=$LEM_MAJOR_VERSION.$LEM_MINOR_VERSION AC_SUBST(LEM_API_VERSION) @@ -92,6 +101,7 @@ AC_SUBST(CUBA_API_VERSION) #shared library versioning CUBA_LIBRARY_VERSION=$CUBA_MAJOR_VERSION:$CUBA_MINOR_VERSION:$CUBA_MICRO_VERSION PLUGIN_LIBRARY_VERSION=$PLUGIN_MAJOR_VERSION:$PLUGIN_MINOR_VERSION:$PLUGIN_MICRO_VERSION +MUSR_ROOT_LIBRARY_VERSION=$MUSR_ROOT_MAJOR_VERSION:$MUSR_ROOT_MINOR_VERSION:$MUSR_ROOT_MICRO_VERSION LEM_LIBRARY_VERSION=$LEM_MAJOR_VERSION:$LEM_MINOR_VERSION:$LEM_MICRO_VERSION PSIBIN_LIBRARY_VERSION=$PSIBIN_MAJOR_VERSION:$PSIBIN_MINOR_VERSION:$PSIBIN_MICRO_VERSION MUD_LIBRARY_VERSION=$MUD_MAJOR_VERSION:$MUD_MINOR_VERSION:$MUD_MICRO_VERSION @@ -113,6 +123,7 @@ MUSR_LIBRARY_VERSION=$MUSR_MAJOR_VERSION:$MUSR_MINOR_VERSION:$MUSR_MICRO_VERSION # +- increment if interfaces have been added, removed or changed AC_SUBST(MUSR_LIBRARY_VERSION) +AC_SUBST(MUSR_ROOT_LIBRARY_VERSION) AC_SUBST(LEM_LIBRARY_VERSION) AC_SUBST(PSIBIN_LIBRARY_VERSION) AC_SUBST(MUD_LIBRARY_VERSION) @@ -123,6 +134,7 @@ AC_SUBST(CUBA_LIBRARY_VERSION) PACKAGE=$MUSR_PROGRAM_NAME AC_SUBST(MUSR_LIBRARY_NAME) AC_SUBST(USERFCN_LIBRARY_NAME) +AC_SUBST(MUSR_ROOT_LIBRARY_NAME) AC_SUBST(LEM_LIBRARY_NAME) AC_SUBST(PSIBIN_LIBRARY_NAME) AC_SUBST(MUD_LIBRARY_NAME) @@ -149,6 +161,11 @@ LEM_RELEASE=$LEM_MAJOR_VERSION.$LEM_MINOR_VERSION AC_SUBST(LEM_RELEASE) AC_SUBST(LEM_VERSION) +MUSR_ROOT_VERSION=$MUSR_ROOT_MAJOR_VERSION.$MUSR_ROOT_MINOR_VERSION.$MUSR_ROOT_MICRO_VERSION +MUSR_ROOT_RELEASE=$MUSR_ROOT_MAJOR_VERSION.$MUSR_ROOT_MINOR_VERSION +AC_SUBST(MUSR_ROOT_RELEASE) +AC_SUBST(MUSR_ROOT_VERSION) + MUSR_VERSION=$MUSR_MAJOR_VERSION.$MUSR_MINOR_VERSION.$MUSR_MICRO_VERSION MUSR_RELEASE=$MUSR_MAJOR_VERSION.$MUSR_MINOR_VERSION AC_SUBST(MUSR_RELEASE) @@ -645,7 +662,7 @@ dnl ----------------------------------------------- AC_ARG_ENABLE([ASlibs], [AC_HELP_STRING([--enable-ASlibs],[build optional AS plug-ins [default=no]])],[BUILD_AS_LIBS=1], [BUILD_AS_LIBS=0]) dnl ----------------------------------------------- -dnl Set some paths and flags for PMusr, TLemRunHeader, Class_MuSR_PSI, mud, NeXus (if enabled), etc. +dnl Set some paths and flags for PMusr, MusrRoot, TLemRunHeader, Class_MuSR_PSI, mud, NeXus (if enabled), etc. dnl ----------------------------------------------- SRCDIR="$(pwd)/src" @@ -668,6 +685,12 @@ LEM_CFLAGS="-I${LEM_SRCDIR}" AC_SUBST(LEM_LIBS) AC_SUBST(LEM_CFLAGS) +MUSR_ROOT_SRCDIR="${SRCDIR}/external/MusrRoot" +MUSR_ROOT_LIBS="${MUSR_ROOT_SRCDIR}/lib${MUSR_ROOT_LIBRARY_NAME}.la" +MUSR_ROOT_CFLAGS="-I${MUSR_ROOT_SRCDIR}" +AC_SUBST(MUSR_ROOT_LIBS) +AC_SUBST(MUSR_ROOT_CFLAGS) + PMUSR_LIBS="${SRCDIR}/classes/lib${MUSR_LIBRARY_NAME}.la" PMUSR_CFLAGS="-I${SRCDIR}/include" AC_SUBST(PMUSR_LIBS) @@ -1023,6 +1046,8 @@ AC_CONFIG_FILES([Makefile \ src/classes/PMusr.pc \ src/classes/PUserFcnBase.pc \ src/external/Makefile \ + src/external/MusrRoot/Makefile \ + src/external/MusrRoot/TMusrRunHeader.pc \ src/external/TLemRunHeader/Makefile \ src/external/TLemRunHeader/TLemRunHeader.pc \ src/external/MuSR_software/Makefile \ @@ -1140,11 +1165,12 @@ echo " musrfit (including musrfit, musrview, musrt0, musrparam," echo " msr2msr, msr2data, any2many): yes" echo "" echo " Supported muSR file formats:" +echo " MusrRoot: yes" +echo " ROOT (LEM): yes" echo " MUD: yes" echo " PSI-BIN: yes" echo " PSI-MDU: yes" echo " WKM: yes" -echo " ROOT (LEM): yes" if test "${PNEXUS_ENABLED}" -eq 1; then echo " NeXus: yes" else diff --git a/doc/examples/test-asy-MUD.msr b/doc/examples/test-asy-MUD.msr index 84dc7889..8677f191 100644 --- a/doc/examples/test-asy-MUD.msr +++ b/doc/examples/test-asy-MUD.msr @@ -2,8 +2,8 @@ MgB12H12 No2 ZF T=150 ############################################################### FITPARAMETER # Nr. Name Value Step Pos_Error Boundaries - 1 alpha 1.0 0.0 none 0 2 - 2 asy 0.17503 -0.00081 0.00083 0 0.33 + 1 alpha 1 0 none 0 2 + 2 asy 0.17503 -0.00082 0.00083 0 0.33 3 rate 0.1649 -0.0016 0.0016 0 none 4 beta 0.892 -0.016 0.016 0.5 2 @@ -20,11 +20,11 @@ RUN data/000100 XXXX TRIUMF MUD (name beamline institute data-file-format) fittype 2 (asymmetry fit) alpha 1 map 0 0 0 0 0 0 0 0 0 0 0 -forward 1 -backward 2 -background 79 391 80 409 +forward 1 +backward 2 +background 79 391 80 409 # estimated bkg: 21.0224 / 17.1702 data 438 12785 436 12787 -t0 432 431 +t0 432.0 431.0 fit 0 8 packing 100 @@ -51,5 +51,5 @@ runs 1 range 0 8 0 0.25 ############################################################### -STATISTIC --- 2011-02-06 15:03:19 - chisq = 133.92904274288378, NDF = 99, chisq/NDF = 1.3528186135644826 +STATISTIC --- 2012-03-20 10:11:27 + chisq = 133.9, NDF = 99, chisq/NDF = 1.352819 diff --git a/doc/examples/test-asy-NeXus2.msr b/doc/examples/test-asy-NeXus2.msr index a4ee4e77..73b640cf 100644 --- a/doc/examples/test-asy-NeXus2.msr +++ b/doc/examples/test-asy-NeXus2.msr @@ -53,5 +53,5 @@ range 0 14 -0.22 0.22 view_packing 5 ############################################################### -STATISTIC --- 2011-09-09 13:24:40 +STATISTIC --- 2012-03-20 10:28:41 chisq = 796.7, NDF = 846, chisq/NDF = 0.941749 diff --git a/doc/examples/test-asy-PSI-BIN.msr b/doc/examples/test-asy-PSI-BIN.msr index a8294d5f..9e4cce0d 100644 --- a/doc/examples/test-asy-PSI-BIN.msr +++ b/doc/examples/test-asy-PSI-BIN.msr @@ -27,7 +27,7 @@ forward 2 backward 1 background 61 184 57 145 data 207 7994 167 8009 -t0 202 162 +t0 202.0 162.0 fit 0 8 packing 18 @@ -55,5 +55,5 @@ range 0 8 -0.3 0.3 view_packing 38 ############################################################### -STATISTIC --- 2011-09-09 13:26:03 +STATISTIC --- 2012-03-20 11:22:25 chisq = 554.2, NDF = 351, chisq/NDF = 1.578917 diff --git a/doc/examples/test-histo-NeXus.msr b/doc/examples/test-histo-NeXus.msr index ed40a448..0bdfc4d3 100644 --- a/doc/examples/test-histo-NeXus.msr +++ b/doc/examples/test-histo-NeXus.msr @@ -3,16 +3,16 @@ Temperature = 300 K, Magnetic Field = 20 Gauss, Sample = CAS FITPARAMETER # No Name Value Step Pos_Error Boundaries 1 zero 0 0 none - 2 phase 11.43 -0.35 0.34 0 100 - 3 field 20.181 -0.028 0.028 0 none - 4 asym 0.1876 -0.0010 0.0010 0 0.3 - 5 rate 0.1254 -0.0024 0.0024 0 100 + 2 phase 11.45 -0.34 0.35 0 100 + 3 field 20.179 -0.028 0.028 0 none + 4 asym 0.1877 -0.0010 0.0010 0 0.3 + 5 rate 0.1257 -0.0024 0.0023 0 100 6 beta 1 0 none - 7 Norm_L 2863.3 -1.4 1.4 - 8 BG_L 0.000000000047 -0.000000000047 0.009142577870 0 none - 9 Norm_R 2024.4 -1.1 1.2 0 none - 10 BG_R 0.0000 -0.0000 0.0017 0 none - 11 relPhase 172.23 -0.37 0.36 0 none + 7 Norm_L 2863.4 -1.4 1.4 + 8 BG_L 0 0 none + 9 Norm_R 2024.3 -1.1 1.2 0 none + 10 BG_R 0 0 none 0 none + 11 relPhase 172.25 -0.37 0.36 0 none ############################################################### THEORY @@ -32,7 +32,7 @@ norm 7 backgr.fit 8 lifetimecorrection map 1 0 0 0 0 0 0 0 0 0 -forward 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 +forward 1-16 data 40 1500 fit 0.2 20 packing 1 @@ -43,7 +43,7 @@ norm 9 backgr.fit 10 lifetimecorrection map 11 0 0 0 0 0 0 0 0 0 -forward 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 +forward 17-32 data 40 1500 fit 0.2 20 packing 1 @@ -70,5 +70,5 @@ range 0 20 -0.3 0.3 view_packing 5 ############################################################### -STATISTIC --- 2011-04-08 10:54:21 - chisq = 3051.73767, NDF = 2465, chisq/NDF = 1.23802745 +STATISTIC --- 2012-03-20 10:28:21 + chisq = 3272.6, NDF = 2469, chisq/NDF = 1.325481 diff --git a/doc/examples/test-histo-NeXus2.msr b/doc/examples/test-histo-NeXus2.msr index 8330c616..091831e6 100644 --- a/doc/examples/test-histo-NeXus2.msr +++ b/doc/examples/test-histo-NeXus2.msr @@ -3,7 +3,7 @@ nc-ZnO T=80 F=69 FITPARAMETER # No Name Value Step Pos_Error Boundaries 1 zero 0 0 none - 2 phase 2.84 -0.43 0.43 0 100 + 2 phase 2.85 -0.43 0.43 0 100 3 field 70.996 -0.035 0.035 0 none 4 asym 0.1698 -0.0016 0.0017 0 0.3 5 rate 0.1523 -0.0023 0.0023 0 100 @@ -70,5 +70,5 @@ range 0 14 -0.22 0.22 view_packing 5 ############################################################### -STATISTIC --- 2011-09-09 13:25:37 +STATISTIC --- 2012-03-20 10:28:33 chisq = 2643.1, NDF = 1696, chisq/NDF = 1.558403 diff --git a/src/Makefile.am b/src/Makefile.am index 4ed8f027..a93f0821 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -12,7 +12,8 @@ if BUILD_MUSREDIT EDITORDIR = musredit endif -SUBDIRS = external/TLemRunHeader \ +SUBDIRS = external/MusrRoot \ + external/TLemRunHeader \ external/MuSR_software \ external/mud \ $(PNEXUSDIRS) \ @@ -29,35 +30,38 @@ SUBDIRS += $(EDITORDIR) EXTRA_DIST = $(EDITORDIR)/Makefile endif -bin_PROGRAMS = musrfit musrview musrt0 musrparam msr2msr msr2data any2many +bin_PROGRAMS = musrfit musrview musrt0 msr2msr msr2data any2many if PNEXUS_ENABLED bin_PROGRAMS += nexus_dump endif +bin_PROGRAMS += read_musrRoot_runHeader write_musrRoot_runHeader musrfit_SOURCES = musrfit.cpp musrview_SOURCES = musrview.cpp musrt0_SOURCES = musrt0.cpp -musrparam_SOURCES = musrparam.cpp msr2msr_SOURCES = msr2msr.cpp msr2data_SOURCES = msr2data.cpp any2many_SOURCES = any2many.cpp if PNEXUS_ENABLED nexus_dump_SOURCES = nexus_dump.cpp endif +read_musrRoot_runHeader_SOURCES = read_musrRoot_runHeader.cpp +write_musrRoot_runHeader_SOURCES = write_musrRoot_runHeader.cpp xmldir = $(bindir) xml_DATA = musrfit_startup.xml -LIBADD = $(PMUSR_LIBS) $(LEM_LIBS) $(PSIBIN_LIBS) $(MUD_LIBS) $(PNEXUS_LIBS) +LIBADD = $(PMUSR_LIBS) $(MUSR_ROOT_LIBS) $(LEM_LIBS) $(PSIBIN_LIBS) $(MUD_LIBS) $(PNEXUS_LIBS) AM_CXXFLAGS = $(LOCAL_BIN_CXXFLAGS) AM_LDFLAGS = $(LOCAL_BIN_LDFLAGS) -INCLUDES = $(PMUSR_CFLAGS) $(FFTW3_CFLAGS) $(GSL_CFLAGS) $(BOOST_CFLAGS) $(ROOT_CFLAGS) +INCLUDES = $(MUSR_ROOT_CFLAGS) $(PMUSR_CFLAGS) $(FFTW3_CFLAGS) $(GSL_CFLAGS) $(BOOST_CFLAGS) $(ROOT_CFLAGS) if PNEXUS_ENABLED INCLUDES += $(HDF5_CFLAGS) $(NEXUS_CFLAGS) $(PNEXUS_CXXFLAGS) endif -LIBS = $(PMUSR_LIBS) $(USERFCN_LIBS) $(LEM_LIBS) $(PSIBIN_LIBS) $(MUD_LIBS) $(PNEXUS_LIBS) $(FFTW3_LIBS) $(GSL_LIBS) $(ROOT_LIBS) +LIBS = $(PMUSR_LIBS) $(USERFCN_LIBS) $(MUSR_ROOT_LIBS) $(LEM_LIBS) $(PSIBIN_LIBS) $(MUD_LIBS) $(PNEXUS_LIBS) \ + $(FFTW3_LIBS) $(GSL_LIBS) $(ROOT_LIBS) install-xmlDATA: $(xml_DATA) test -z "$(xmldir)" || $(mkdir_p) "$(DESTDIR)$(xmldir)" diff --git a/src/any2many.cpp b/src/any2many.cpp index 71a8ec36..ce520b74 100644 --- a/src/any2many.cpp +++ b/src/any2many.cpp @@ -10,7 +10,7 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007 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 * @@ -74,9 +74,9 @@ void any2many_syntax() cout << endl << " year, i.e. [yyyy] will result in something like 1999."; cout << endl << " -c : "; cout << endl << " : input data file format. Supported formats are:"; - cout << endl << " PSI-BIN, ROOT (LEM), MUD, NeXus1, NeXus2, PSI-MDU, WKM"; + cout << endl << " MusrRoot, PSI-BIN, ROOT (LEM), MUD, NeXus1, NeXus2, PSI-MDU, WKM"; cout << endl << " : ouput data file format. Supported formats are:"; - cout << endl << " PSI-BIN, ROOT (LEM), MUD, NeXus1-HDF4, NeXus1-HDF5, NeXus1-XML,"; + cout << endl << " PSI-BIN, MusrRoot, MUD, NeXus1-HDF4, NeXus1-HDF5, NeXus1-XML,"; cout << endl << " NeXus2-HDF4, NeXus2-HDF5, NeXus2-XML, WKM, ASCII"; cout << endl << " -p : where is the output path for the"; cout << endl << " converted files. If nothing is given, the current directory"; @@ -99,8 +99,8 @@ void any2many_syntax() cout << endl << " Will take the LEM ROOT file '2010/lem10_his_0123.root' rebin it with 25"; cout << endl << " and convert it to ASCII. The output file name will be"; cout << endl << " lem10_his_0123.ascii, and the file will be saved in the current directory." << endl; - cout << endl << " any2many -f 2010/lem10_his_0123.root -c ROOT NEXUS2-HDF5 -o 2010/lem10_his_0123_v2.nxs"; - cout << endl << " Will take the LEM ROOT file '2010/lem10_his_0123.root' "; + cout << endl << " any2many -f 2010/lem10_his_0123.root -c MusrRoot NEXUS2-HDF5 -o 2010/lem10_his_0123_v2.nxs"; + cout << endl << " Will take the MusrRoot file '2010/lem10_his_0123.root' "; cout << endl << " and convert it to NeXus IDF V2. The output file name will be"; cout << endl << " lem10_his_0123_v2.nxs, and the file will be saved in the current directory." << endl; cout << endl << " any2many -r 123 137 -c PSI-BIN MUD -t d[yyyy]/deltat_tdc_gps_[rrrr].bin \\"; @@ -113,12 +113,12 @@ void any2many_syntax() cout << endl << " Will take the runs 100 through 117 and convert the PSI-MDU input files to"; cout << endl << " ASCII output and instead of saving them into a file, they will be spit to"; cout << endl << " the standard output." << endl; - cout << endl << " any2many -r 100-117 -c NEXUS ROOT -t d[yyyy]/psi_gps_[rrrr].NXS \\"; + cout << endl << " any2many -r 100-117 -c NEXUS MusrRoot -t d[yyyy]/psi_gps_[rrrr].NXS \\"; cout << endl << " psi_[yyyy]_gps_[rrrr].root -z b psi_gps_run_100to117"; - cout << endl << " Will take the runs 100 through 117 and convert the PSI-NEXUS input files"; - cout << endl << " to ROOT output. Afterwards these new files will be collected in a"; + cout << endl << " Will take the runs 100 through 117 and convert the NEXUS input files"; + cout << endl << " to MusrRoot output. Afterwards these new files will be collected in a"; cout << endl << " compressed archive psi_gps_run_100to117.tar.bz2." << endl; - cout << endl << " any2many -f 2010/lem10_his_0123.root 2010/lem10_his_0012.root -c ROOT ROOT -rebin 25"; + cout << endl << " any2many -f 2010/lem10_his_0123.root 2010/lem10_his_0012.root -c MusrRoot MusrRoot -rebin 25"; cout << endl << " Will read the two files '2010/lem10_his_0123.root' and '2010/lem10_his_0012.root',"; cout << endl << " rebin them with 25 and export them as LEM ROOT files with adding rebin25 to the"; cout << endl << " name, e.g. 2010/lem10_his_0123_rebin25.root"; @@ -146,6 +146,7 @@ int main(int argc, char *argv[]) TString outputFileName = TString(""); // init inputFormat + inputFormat.push_back("musrroot"); inputFormat.push_back("psi-bin"); inputFormat.push_back("root"); inputFormat.push_back("mud"); @@ -155,6 +156,7 @@ int main(int argc, char *argv[]) // init outputFormat outputFormat.push_back("psi-bin"); + outputFormat.push_back("musrroot"); outputFormat.push_back("root"); outputFormat.push_back("mud"); outputFormat.push_back("nexus1-hdf4"); @@ -186,7 +188,7 @@ int main(int argc, char *argv[]) if (strstr(argv[1], "--h")) any2many_syntax(); else if (strstr(argv[1], "--v")) - cout << endl << "any2many version: $Id$" << endl << endl; + cout << endl << "any2many version: " << PMUSR_VERSION << " / $Id$" << endl << endl; else { any2many_syntax(); return PMUSR_WRONG_STARTUP_SYNTAX; diff --git a/src/classes/Makefile.am b/src/classes/Makefile.am index 1f5b8555..c56b1569 100644 --- a/src/classes/Makefile.am +++ b/src/classes/Makefile.am @@ -76,7 +76,7 @@ dict_cpp_sources_userFcn = \ include_HEADERS = $(h_sources) $(h_sources_userFcn) noinst_HEADERS = $(h_linkdef) $(dict_h_sources) $(h_linkdef_userFcn) $(dict_h_sources_userFcn) -INCLUDES = -I$(top_srcdir)/src/include $(PSIBIN_CFLAGS) $(MUD_CFLAGS) $(LEM_CFLAGS) $(FFTW3_CFLAGS) $(GSL_CFLAGS) $(BOOST_CFLAGS) $(ROOT_CFLAGS) $(PNEXUS_CXXFLAGS) $(NEXUS_CFLAGS) +INCLUDES = -I$(top_srcdir)/src/include $(MUSR_ROOT_CFLAGS) $(PSIBIN_CFLAGS) $(MUD_CFLAGS) $(LEM_CFLAGS) $(FFTW3_CFLAGS) $(GSL_CFLAGS) $(BOOST_CFLAGS) $(ROOT_CFLAGS) $(PNEXUS_CXXFLAGS) $(NEXUS_CFLAGS) AM_CXXFLAGS = $(LOCAL_LIB_CXXFLAGS) BUILT_SOURCES = $(dict_cpp_sources) $(dict_h_sources) $(dict_cpp_sources_userFcn) $(dict_h_sources_userFcn) @@ -93,7 +93,7 @@ libPUserFcnBase_la_LIBADD = $(ROOT_LIBS) libPUserFcnBase_la_LDFLAGS = -version-info $(MUSR_LIBRARY_VERSION) -release $(MUSR_RELEASE) $(AM_LDFLAGS) libPMusr_la_SOURCES = $(h_sources) $(cpp_sources) $(dict_h_sources) $(dict_cpp_sources) -libPMusr_la_LIBADD = libPUserFcnBase.la $(LEM_LIBS) $(PSIBIN_LIBS) $(MUD_LIBS) $(PNEXUS_LIBS) $(FFTW3_LIBS) $(GSL_LIBS) $(ROOT_LIBS) +libPMusr_la_LIBADD = libPUserFcnBase.la $(MUSR_ROOT_LIBS) $(LEM_LIBS) $(PSIBIN_LIBS) $(MUD_LIBS) $(PNEXUS_LIBS) $(FFTW3_LIBS) $(GSL_LIBS) $(ROOT_LIBS) libPMusr_la_LDFLAGS = -version-info $(MUSR_LIBRARY_VERSION) -release $(MUSR_RELEASE) $(AM_LDFLAGS) pkgconfigdir = $(libdir)/pkgconfig diff --git a/src/classes/PFitter.cpp b/src/classes/PFitter.cpp index 0c4bcf18..91da24f8 100644 --- a/src/classes/PFitter.cpp +++ b/src/classes/PFitter.cpp @@ -10,8 +10,8 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007 by Andreas Suter * - * andreas.suter@psi.c * + * Copyright (C) 2007-2012 by Andreas Suter * + * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * diff --git a/src/classes/PFitterFcn.cpp b/src/classes/PFitterFcn.cpp index 187a63d4..66239e76 100644 --- a/src/classes/PFitterFcn.cpp +++ b/src/classes/PFitterFcn.cpp @@ -10,8 +10,8 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007 by Andreas Suter * - * andreas.suter@psi.c * + * Copyright (C) 2007-2012 by Andreas Suter * + * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * diff --git a/src/classes/PFourier.cpp b/src/classes/PFourier.cpp index b65b87fa..b8f7eb24 100644 --- a/src/classes/PFourier.cpp +++ b/src/classes/PFourier.cpp @@ -10,8 +10,8 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2008 by Andreas Suter * - * andreas.suter@psi.c * + * Copyright (C) 2007-2012 by Andreas Suter * + * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * diff --git a/src/classes/PFunction.cpp b/src/classes/PFunction.cpp index 629dfc67..23b14b6d 100644 --- a/src/classes/PFunction.cpp +++ b/src/classes/PFunction.cpp @@ -10,8 +10,8 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007 by Andreas Suter * - * andreas.suter@psi.c * + * Copyright (C) 2007-2012 by Andreas Suter * + * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * diff --git a/src/classes/PFunctionHandler.cpp b/src/classes/PFunctionHandler.cpp index 802cd26e..002dc978 100644 --- a/src/classes/PFunctionHandler.cpp +++ b/src/classes/PFunctionHandler.cpp @@ -10,8 +10,8 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007 by Andreas Suter * - * andreas.suter@psi.c * + * Copyright (C) 2007-2012 by Andreas Suter * + * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * diff --git a/src/classes/PMsr2Data.cpp b/src/classes/PMsr2Data.cpp index ad1c3404..dd54fbd6 100644 --- a/src/classes/PMsr2Data.cpp +++ b/src/classes/PMsr2Data.cpp @@ -10,7 +10,7 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2009-2010 by Bastian M. Wojek / Andreas Suter * + * Copyright (C) 2009-2012 by Bastian M. Wojek / Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * diff --git a/src/classes/PMsrHandler.cpp b/src/classes/PMsrHandler.cpp index 5ac78a28..18e739af 100644 --- a/src/classes/PMsrHandler.cpp +++ b/src/classes/PMsrHandler.cpp @@ -10,7 +10,7 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007-2010 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 * @@ -360,7 +360,7 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages) PBoolVector bvec; for (UInt_t i=0; i> PMsrHandler::WriteMsrLogFile: **WARNING** 'addt0' tag without any data found!"; cerr << endl << ">> Something is VERY fishy, please check your msr-file carfully." << endl; } else { fout.width(16); fout << left << "addt0"; - for (Int_t j=0; j 0) { + // if ISIS data, do not do anything + if (t0TagMissing[runNo] && fRuns[runNo].GetInstitute()->CompareTo("isis", TString::kIgnoreCase)) { + if (fRuns[runNo].GetT0BinSize() > 0) { fout.width(16); fout << left << "t0"; - for (UInt_t j=0; j 0) { + for (UInt_t i=0; iCompareTo("isis", TString::kIgnoreCase)) { + if (fRuns[runNo].GetAddT0BinSize(i) > 0) { fout.width(16); fout << left << "addt0"; - for (Int_t j=0; j *co } // t0 - if (fRuns[i].GetT0Size() > 0) { + if (fRuns[i].GetT0BinSize() > 0) { fout.width(16); fout << left << "t0"; - for (UInt_t j=0; j 0) { + if (fRuns[i].GetAddT0BinSize(j) > 0) { fout.width(16); fout << left << "addt0"; - for (Int_t k=0; k= fRuns.size()) { // error cerr << endl << ">> PMsrHandler::SetMsrT0Entry: **ERROR** runNo = " << runNo << ", is out of valid range 0.." << fRuns.size(); @@ -2059,13 +2072,13 @@ void PMsrHandler::SetMsrT0Entry(UInt_t runNo, UInt_t idx, Int_t bin) return; } - if (idx >= fRuns[runNo].GetT0Size()) { // error - cerr << endl << ">> PMsrHandler::SetMsrT0Entry: **WARNING** idx = " << idx << ", is out of valid range 0.." << fRuns[runNo].GetT0Size(); + if (idx >= fRuns[runNo].GetT0BinSize()) { // error + cerr << endl << ">> PMsrHandler::SetMsrT0Entry: **WARNING** idx = " << idx << ", is out of valid range 0.." << fRuns[runNo].GetT0BinSize(); cerr << endl << ">> Will add it anyway."; cerr << endl; } - fRuns[runNo].SetT0(bin, idx); + fRuns[runNo].SetT0Bin(bin, idx); } //-------------------------------------------------------------------------- @@ -2079,7 +2092,7 @@ void PMsrHandler::SetMsrT0Entry(UInt_t runNo, UInt_t idx, Int_t bin) * \param histoIdx msr-file histogram index for an addrun. * \param bin t0 bin value. */ -void PMsrHandler::SetMsrAddT0Entry(UInt_t runNo, UInt_t addRunIdx, UInt_t histoIdx, Int_t bin) +void PMsrHandler::SetMsrAddT0Entry(UInt_t runNo, UInt_t addRunIdx, UInt_t histoIdx, Double_t bin) { if (runNo >= fRuns.size()) { // error cerr << endl << ">> PMsrHandler::SetMsrAddT0Entry: **ERROR** runNo = " << runNo << ", is out of valid range 0.." << fRuns.size(); @@ -2087,19 +2100,19 @@ void PMsrHandler::SetMsrAddT0Entry(UInt_t runNo, UInt_t addRunIdx, UInt_t histoI return; } - if (addRunIdx >= fRuns[runNo].GetAddT0Entries()) { // error - cerr << endl << ">> PMsrHandler::SetMsrAddT0Entry: **WARNING** addRunIdx = " << addRunIdx << ", is out of valid range 0.." << fRuns[runNo].GetAddT0Entries(); + if (addRunIdx >= fRuns[runNo].GetAddT0BinEntries()) { // error + cerr << endl << ">> PMsrHandler::SetMsrAddT0Entry: **WARNING** addRunIdx = " << addRunIdx << ", is out of valid range 0.." << fRuns[runNo].GetAddT0BinEntries(); cerr << endl << ">> Will add it anyway."; cerr << endl; } - if (static_cast(histoIdx) > fRuns[runNo].GetAddT0Size(addRunIdx)) { // error - cerr << endl << ">> PMsrHandler::SetMsrAddT0Entry: **WARNING** histoIdx = " << histoIdx << ", is out of valid range 0.." << fRuns[runNo].GetAddT0Size(addRunIdx); + if (static_cast(histoIdx) > fRuns[runNo].GetAddT0BinSize(addRunIdx)) { // error + cerr << endl << ">> PMsrHandler::SetMsrAddT0Entry: **WARNING** histoIdx = " << histoIdx << ", is out of valid range 0.." << fRuns[runNo].GetAddT0BinSize(addRunIdx); cerr << endl << ">> Will add it anyway."; cerr << endl; } - fRuns[runNo].SetAddT0(bin, addRunIdx, histoIdx); + fRuns[runNo].SetAddT0Bin(bin, addRunIdx, histoIdx); } //-------------------------------------------------------------------------- @@ -2477,6 +2490,7 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines) UInt_t addT0Counter = 0; Int_t ival; + Double_t dval; iter = lines.begin(); while ((iter != lines.end()) && !error) { @@ -2860,10 +2874,10 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines) for (Int_t i=1; iGetEntries(); i++) { ostr = dynamic_cast(tokens->At(i)); str = ostr->GetString(); - if (str.IsDigit()) { - ival = str.Atoi(); - if (ival > 0) - param.SetT0(ival); + if (str.IsFloat()) { + dval = str.Atof(); + if (dval >= 0.0) + param.SetT0Bin(dval); else error = true; } else { @@ -2884,10 +2898,10 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines) for (Int_t i=1; iGetEntries(); i++) { ostr = dynamic_cast(tokens->At(i)); str = ostr->GetString(); - if (str.IsDigit()) { - ival = str.Atoi(); - if (ival > 0) - param.SetAddT0(ival, addT0Counter, i-1); + if (str.IsFloat()) { + dval = str.Atof(); + if (dval >= 0.0) + param.SetAddT0Bin(dval, addT0Counter, i-1); else error = true; } else { @@ -4972,8 +4986,8 @@ Bool_t PMsrHandler::CheckAddRunParameters() for (UInt_t i=0; i 1) { // check concerning the addt0 tags - if (fRuns[i].GetAddT0Entries() != 0) { - if (fRuns[i].GetAddT0Entries() != fRuns[i].GetRunNameSize()-1) { + if (fRuns[i].GetAddT0BinEntries() != 0) { + if (fRuns[i].GetAddT0BinEntries() != fRuns[i].GetRunNameSize()-1) { cerr << endl << ">> PMsrHandler::CheckAddRunParameters: **ERROR** # of addt0 != # of addruns."; cerr << endl << ">> Run #" << i+1; cerr << endl; diff --git a/src/classes/PMusr.cpp b/src/classes/PMusr.cpp index 28efb7be..a5951699 100644 --- a/src/classes/PMusr.cpp +++ b/src/classes/PMusr.cpp @@ -10,7 +10,7 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007-2010 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 * @@ -209,6 +209,292 @@ void PNonMusrRawRunData::AppendSubErrData(const UInt_t idx, const Double_t dval) fErrData[idx].push_back(dval); } + +//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// implementation PRawRunDataSet +//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +//-------------------------------------------------------------------------- +// Constructor +//-------------------------------------------------------------------------- +/** + *

Constructor + */ +PRawRunDataSet::PRawRunDataSet() +{ + Clear(); +} + +//-------------------------------------------------------------------------- +// Clear (public) +//-------------------------------------------------------------------------- +/** + *

Constructor + */ +void PRawRunDataSet::Clear() +{ + fName = TString("n/a"); + fHistoNo = -1; + fTimeZeroBin = 0.0; + fTimeZeroBinEstimated = 0.0; + fFirstGoodBin = 0; + fLastGoodBin = 0; + fFirstBkgBin = 0; + fLastBkgBin = 0; + fData.clear(); +} + +//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// implementation PRawRunDataVector +//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +//-------------------------------------------------------------------------- +// IsPresent (public) +//-------------------------------------------------------------------------- +/** + *

Checks if the histogram set with histgram number histoNo is present. + * + *

return: + * - true if found + * - false otherwise + * + * \param histoNo histogram number requested + */ +Bool_t PRawRunDataVector::IsPresent(UInt_t histoNo) +{ + Bool_t found=false; + + for (UInt_t i=0; iGet the raw data set with the index idx. This routine is different to + * PRawRunDataVector::Get(UInt_t histoNo) where the internal saved histogram + * number is used. + * + *

return: + * - pointer to the raw data set if found + * - 0 otherwise + * + * \param idx data set index + */ +PRawRunDataSet* PRawRunDataVector::GetSet(UInt_t idx) +{ + PRawRunDataSet *result=0; + + if (idx >= fDataVec.size()) + return result; + + return &fDataVec[idx]; +} + +//-------------------------------------------------------------------------- +// Get (public) +//-------------------------------------------------------------------------- +/** + *

Get the raw data set with histogram number histoNo. + * + *

return: + * - pointer to the raw data set if found + * - 0 otherwise + * + * \param histoNo histogram number requested + */ +PRawRunDataSet* PRawRunDataVector::Get(UInt_t histoNo) +{ + PRawRunDataSet *result=0; + + for (UInt_t i=0; iGet the raw data set with histogram number histoNo. + * + *

return: + * - pointer to the raw data set if found + * - 0 otherwise + * + * \param histoNo histogram number requested + */ +PRawRunDataSet* PRawRunDataVector::operator[](UInt_t histoNo) +{ + return Get(histoNo); +} + +//-------------------------------------------------------------------------- +// GetData (public) +//-------------------------------------------------------------------------- +/** + *

Get the raw data set data with histogram number histoNo. + * + *

return: + * - pointer to the raw data set if found + * - 0 otherwise + * + * \param histoNo histogram number requested + */ +PDoubleVector* PRawRunDataVector::GetData(UInt_t histoNo) +{ + PDoubleVector *result=0; + + for (UInt_t i=0; iGet the T0 bin of raw run data with histogram number histoNo. + * + *

return: + * - T0 bin if found + * - PMUSR_UNDEFINED otherwise + * + * \param histoNo histogram number requested + */ +Double_t PRawRunDataVector::GetT0Bin(UInt_t histoNo) +{ + Double_t result=-1.0; // undefined + + for (UInt_t i=0; iGet the estimated T0 bin of raw run data with histogram number histoNo. + * + *

return: + * - estimated T0 bin if found + * - PMUSR_UNDEFINED otherwise + * + * \param histoNo histogram number requested + */ +Double_t PRawRunDataVector::GetT0BinEstimated(UInt_t histoNo) +{ + Double_t result=PMUSR_UNDEFINED; + + for (UInt_t i=0; iGet the background bins (start, end). + * + *

return: + * - background bins if found + * - (-1, -1) otherwise + * + * \param histoNo histogram number requested + */ +PIntPair PRawRunDataVector::GetBkgBin(UInt_t histoNo) +{ + PIntPair bkg(-1,-1); + + for (UInt_t i=0; iGet the first/last good data bin (fgb, lgb). + * + *

return: + * - good data bins if found + * - (-1, -1) otherwise + * + * \param histoNo histogram number requested + */ +PIntPair PRawRunDataVector::GetGoodDataBin(UInt_t histoNo) +{ + PIntPair gdb(-1,-1); + + for (UInt_t i=0; iSet a data set at idx. If idx == -1 append it at the end (default), + * otherwise check if idx is within bounds and if yes, place it there, + * otherwise resize the data vector and place it where requested. + * + * \param dataSet data set to be set + * \param idx index at which to place the data set. + */ +void PRawRunDataVector::Set(PRawRunDataSet dataSet, Int_t idx) +{ + if (idx == -1) { // data set to be appended + fDataVec.push_back(dataSet); + } else { + if (idx >= (Int_t)fDataVec.size()) + fDataVec.resize(idx+1); + fDataVec[idx] = dataSet; + } +} + //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // implementation PRawRunData //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -221,11 +507,19 @@ void PNonMusrRawRunData::AppendSubErrData(const UInt_t idx, const Double_t dval) */ PRawRunData::PRawRunData() { + fVersion = TString("n/a"); + fGenericValidatorURL = TString("n/a"); + fSpecificValidatorURL = TString("n/a"); + fGenerator = TString("n/a"); + fComment = TString("n/a"); + fFileName = TString("n/a"); fLaboratory = TString("n/a"); fBeamline = TString("n/a"); fInstrument = TString("n/a"); + fArea = TString("n/a"); fMuonSource = TString("n/a"); fMuonSpecies = TString("n/a"); + fMuonBeamMomentum = PMUSR_UNDEFINED; fRunName = TString("n/a"); fRunNumber = -1; fRunTitle = TString("n/a"); @@ -236,12 +530,15 @@ PRawRunData::PRawRunData() fStopTime = TString("n/a"); fStopDate = TString("n/a"); fStopDateTimeSec = 0; + fCryo = TString("n/a"); fSample = TString("n/a"); fOrientation = TString("n/a"); + fMagnet = TString("n/a"); fField = PMUSR_UNDEFINED; fEnergy = PMUSR_UNDEFINED; fTransport = PMUSR_UNDEFINED; fTimeResolution = PMUSR_UNDEFINED; + fRedGreenOffset.push_back(0); } //-------------------------------------------------------------------------- @@ -254,13 +551,7 @@ PRawRunData::~PRawRunData() { fTemp.clear(); fRingAnode.clear(); - fT0s.clear(); - fT0Estimated.clear(); - fBkgBin.clear(); - fGoodDataBin.clear(); - for (UInt_t i=0; i Returns a T0 value. - * - * return: - * - t0 value, if idx is within proper boundaries - * - -1, otherwise - * - * \param idx index of the T0 value whished - */ -const Int_t PRawRunData::GetT0(const UInt_t idx) -{ - if (idx >= fT0s.size()) { - cerr << endl << ">> PRawRunData::GetT0: **WARNING** idx=" << idx << " is out of range [0," << fT0s.size() << "[."; - cerr << endl; - return -1; - } - return fT0s[idx]; -} - -//-------------------------------------------------------------------------- -// GetT0Estimated -//-------------------------------------------------------------------------- -/** - *

Returns an estimated T0 value. - * - * return: - * - estimated t0 value, if idx is within proper boundaries - * - -1, otherwise - * - * \param idx index of the T0 value whished - */ -const Int_t PRawRunData::GetT0Estimated(const UInt_t idx) -{ - if (idx >= fT0Estimated.size()) { - cerr << endl << ">> PRawRunData::GetT0Estimated: **WARNING** idx=" << idx << " is out of range [0," << fT0Estimated.size() << "[."; - cerr << endl; - return -1; - } - return fT0Estimated[idx]; -} - -//-------------------------------------------------------------------------- -// GetBkgBin -//-------------------------------------------------------------------------- -/** - *

Returns the background bin range (start, stop) from the data file. - * Currently only used in mud-files. - * - * return: - * - (start, stop) values, if idx is within proper boundaries - * - (-1, -1), otherwise - * - * \param idx index of the background range. - */ -const PIntPair PRawRunData::GetBkgBin(const UInt_t idx) -{ - PIntPair pair(-1, -1); - - if (idx >= fBkgBin.size()) { - cerr << endl << ">> PRawRunData::GetBkgBin: **WARNING** idx=" << idx << " is out of range [0," << fBkgBin.size() << "[."; - cerr << endl; - return pair; - } - - pair.first = fBkgBin[idx].first; - pair.second = fBkgBin[idx].second; - - return pair; -} - -//-------------------------------------------------------------------------- -// GetGoodDataBin -//-------------------------------------------------------------------------- -/** - *

Returns the data range (first good bin, last good bin) from the data file. - * Currently only used in mud-files. - * - * return: - * - (first good bin, last good bin) values, if idx is within proper boundaries - * - (-1, -1), otherwise - * - * \param idx index of the data range - */ -const PIntPair PRawRunData::GetGoodDataBin(const UInt_t idx) -{ - PIntPair pair(-1, -1); - - if (idx >= fGoodDataBin.size()) { - cerr << endl << ">> PRawRunData::GetGoodDataBin: **WARNING** idx=" << idx << " is out of range [0," << fGoodDataBin.size() << "[."; - cerr << endl; - return pair; - } - - pair.first = fGoodDataBin[idx].first; - pair.second = fGoodDataBin[idx].second; - - return pair; -} - -//-------------------------------------------------------------------------- -// GetDataBin -//-------------------------------------------------------------------------- -/** - *

Returns a raw muSR run histogram. + *

Returns a raw muSR run data set. * * return: * - pointer of the data vector, if idx is within proper boundaries * - 0, otherwise * - * \param idx histo number index + * \param idx either the histogram number or the index, depending in wantHistoNo-flag + * \param wantHistoNo flag indicating if idx is the histoNo or the index. Default is wantHistoNo==true */ -const PDoubleVector* PRawRunData::GetDataBin(const UInt_t idx) +PRawRunDataSet* PRawRunData::GetDataSet(const UInt_t idx, Bool_t wantHistoNo) { - if (idx >= fDataBin.size()) { - cerr << endl << ">> PRawRunData::GetDataBin: **WARNING** idx=" << idx << " is out of range [0," << fDataBin.size() << "[."; - cerr << endl; - return 0; - } - - return &fDataBin[idx]; + if (wantHistoNo) + return fData[idx]; + else + return fData.GetSet(idx); } @@ -508,61 +695,6 @@ void PRawRunData::SetTempError(const UInt_t idx, const Double_t errTemp) fTemp[idx].second = errTemp; } -//-------------------------------------------------------------------------- -// SetDataBin -//-------------------------------------------------------------------------- -/** - *

sets a value in a data set. - * - * \param histoNo histogram number index - * \param bin number index - * \param dval value to be set - */ -void PRawRunData::SetDataBin(const UInt_t histoNo, const UInt_t bin, const Double_t dval) -{ - if (histoNo > fDataBin.size()) { - cerr << endl << ">> PRawRunData::SetDataBin: **WARNING** histoNo=" << histoNo << " is out of range [0," << fDataBin.size() << "]."; - cerr << endl; - return; - } - - if (bin > fDataBin[histoNo].size()) { - cerr << endl << ">> PRawRunData::SetDataBin: **WARNING** bin=" << bin << " is out of range [0," << fDataBin[histoNo].size() << "]."; - cerr << endl; - return; - } - - fDataBin[histoNo][bin] = dval; -} - -//-------------------------------------------------------------------------- -// AddDataBin -//-------------------------------------------------------------------------- -/** - *

add a value within a data set. - * - * \param histoNo histogram number index - * \param bin number index - * \param dval value to be set - */ -void PRawRunData::AddDataBin(const UInt_t histoNo, const UInt_t bin, const Double_t dval) -{ - if (histoNo > fDataBin.size()) { - cerr << endl << ">> PRawRunData::AddDataBin: **WARNING** histoNo=" << histoNo << " is out of range [0," << fDataBin.size() << "]."; - cerr << endl; - return; - } - - if (bin > fDataBin[histoNo].size()) { - cerr << endl << ">> PRawRunData::AddDataBin: **WARNING** bin=" << bin << " is out of range [0," << fDataBin[histoNo].size() << "]."; - cerr << endl; - return; - } - - fDataBin[histoNo][bin] += dval; -} - - //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // implementation PMsrRunBlock //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -575,7 +707,7 @@ void PRawRunData::AddDataBin(const UInt_t histoNo, const UInt_t bin, const Doubl */ PMsrRunBlock::PMsrRunBlock() { - fFitType = -1; // undefined fit type + fFitType = -1; // undefined fit type fAlphaParamNo = -1; // undefined alpha parameter number fBetaParamNo = -1; // undefined beta parameter number fNormParamNo = -1; // undefined norm parameter number @@ -1128,18 +1260,18 @@ void PMsrRunBlock::SetDataRange(Int_t ival, Int_t idx) } //-------------------------------------------------------------------------- -// GetT0 +// GetT0Bin //-------------------------------------------------------------------------- /** - *

get T0 value at position idx + *

get T0 bin at position idx * * return: - * - t0 value, if idx is within proper boundaries + * - T0 bin, if idx is within proper boundaries * - -1, otherwise * - * \param idx index of the T0 value to be returned + * \param idx index of the T0 bin to be returned */ -Int_t PMsrRunBlock::GetT0(UInt_t idx) +Double_t PMsrRunBlock::GetT0Bin(UInt_t idx) { if (idx >= fT0.size()) return -1; @@ -1148,29 +1280,29 @@ Int_t PMsrRunBlock::GetT0(UInt_t idx) } //-------------------------------------------------------------------------- -// SetT0 +// SetT0Bin //-------------------------------------------------------------------------- /** - *

set T0 value at position idx + *

set T0 bin at position idx * - * \param ival t0 value - * \param idx index of the T0 value to be set. If idx==-1, append value + * \param ival T0 bin + * \param idx index of the T0 bin to be set. If idx==-1, append value */ -void PMsrRunBlock::SetT0(Int_t ival, Int_t idx) +void PMsrRunBlock::SetT0Bin(Double_t dval, Int_t idx) { if (idx == -1) { - fT0.push_back(ival); + fT0.push_back(dval); return; } if (idx >= static_cast(fT0.size())) fT0.resize(idx+1); - fT0[idx] = ival; + fT0[idx] = dval; } //-------------------------------------------------------------------------- -// GetAddT0Size +// GetAddT0BinSize //-------------------------------------------------------------------------- /** *

get add T0 size of the addrun at index addRunIdx @@ -1181,7 +1313,7 @@ void PMsrRunBlock::SetT0(Int_t ival, Int_t idx) * * \param addRunIdx index of the addrun */ -Int_t PMsrRunBlock::GetAddT0Size(UInt_t addRunIdx) +Int_t PMsrRunBlock::GetAddT0BinSize(UInt_t addRunIdx) { if (fAddT0.empty()) return -1; @@ -1193,7 +1325,7 @@ Int_t PMsrRunBlock::GetAddT0Size(UInt_t addRunIdx) } //-------------------------------------------------------------------------- -// GetAddT0 +// GetAddT0Bin //-------------------------------------------------------------------------- /** *

get add T0 of the addrun (index addRunIdx) at index histoIdx @@ -1205,34 +1337,34 @@ Int_t PMsrRunBlock::GetAddT0Size(UInt_t addRunIdx) * \param addRunIdx index of the addrun * \param histoIdx index of the add backward histo number value */ -Int_t PMsrRunBlock::GetAddT0(UInt_t addRunIdx, UInt_t histoIdx) +Double_t PMsrRunBlock::GetAddT0Bin(UInt_t addRunIdx, UInt_t histoIdx) { if (fAddT0.empty()) - return -1; + return -1.0; if (addRunIdx >= fAddT0.size()) - return -1; + return -1.0; if (fAddT0[addRunIdx].empty()) - return -1; + return -1.0; if (histoIdx >= fAddT0[addRunIdx].size()) - return -1; + return -1.0; return fAddT0[addRunIdx][histoIdx]; } //-------------------------------------------------------------------------- -// SetAddT0 +// SetAddT0Bin //-------------------------------------------------------------------------- /** - *

set add t0 value of the addrun at index histoNoIdx + *

set add T0 bin of the addrun at index histoNoIdx * - * \param ival t0 value + * \param ival T0 bin * \param addRunIdx addrun index * \param histoNoIdx index whithin the fAddT0 vector where to set the value. */ -void PMsrRunBlock::SetAddT0(Int_t ival, UInt_t addRunIdx, UInt_t histoNoIdx) +void PMsrRunBlock::SetAddT0Bin(Double_t dval, UInt_t addRunIdx, UInt_t histoNoIdx) { if (addRunIdx >= fAddT0.size()) fAddT0.resize(addRunIdx+1); @@ -1240,8 +1372,7 @@ void PMsrRunBlock::SetAddT0(Int_t ival, UInt_t addRunIdx, UInt_t histoNoIdx) if (histoNoIdx >= fAddT0[addRunIdx].size()) fAddT0[addRunIdx].resize(histoNoIdx+1); - fAddT0[addRunIdx][histoNoIdx] = ival; - + fAddT0[addRunIdx][histoNoIdx] = dval; } //-------------------------------------------------------------------------- diff --git a/src/classes/PMusrCanvas.cpp b/src/classes/PMusrCanvas.cpp index e1002204..08c0d4f4 100644 --- a/src/classes/PMusrCanvas.cpp +++ b/src/classes/PMusrCanvas.cpp @@ -10,7 +10,7 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007 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 * diff --git a/src/classes/PMusrT0.cpp b/src/classes/PMusrT0.cpp index 7f9a757d..7d866517 100644 --- a/src/classes/PMusrT0.cpp +++ b/src/classes/PMusrT0.cpp @@ -10,7 +10,7 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2009 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 * @@ -134,7 +134,7 @@ Int_t PMusrT0Data::GetHistoNo(UInt_t idx) } //-------------------------------------------------------------------------- -// GetT0 +// GetT0Bin //-------------------------------------------------------------------------- /** *

Get t0 (in bin) of a run. @@ -145,7 +145,7 @@ Int_t PMusrT0Data::GetHistoNo(UInt_t idx) * * \param idx index of the run (msr-file). */ -Int_t PMusrT0Data::GetT0(UInt_t idx) +Int_t PMusrT0Data::GetT0Bin(UInt_t idx) { if (idx >= fT0.size()) return -1; @@ -154,7 +154,7 @@ Int_t PMusrT0Data::GetT0(UInt_t idx) } //-------------------------------------------------------------------------- -// GetAddT0Size +// GetAddT0BinSize //-------------------------------------------------------------------------- /** *

Get addt0 size of a run, i.e. the number of addt0's for a given msr-file run. @@ -165,7 +165,7 @@ Int_t PMusrT0Data::GetT0(UInt_t idx) * * \param idx index of the run (msr-file). */ -UInt_t PMusrT0Data::GetAddT0Size(UInt_t idx) +UInt_t PMusrT0Data::GetAddT0BinSize(UInt_t idx) { if (idx >= fAddT0.size()) return 0; @@ -174,7 +174,7 @@ UInt_t PMusrT0Data::GetAddT0Size(UInt_t idx) } //-------------------------------------------------------------------------- -// GetAddT0 +// GetAddT0Bin //-------------------------------------------------------------------------- /** *

Get addt0 (in bin) of a run. @@ -186,7 +186,7 @@ UInt_t PMusrT0Data::GetAddT0Size(UInt_t idx) * \param addRunIdx index of the addrun * \param idx index of the run (msr-file). */ -Int_t PMusrT0Data::GetAddT0(UInt_t addRunIdx, UInt_t idx) +Int_t PMusrT0Data::GetAddT0Bin(UInt_t addRunIdx, UInt_t idx) { if (addRunIdx >= fAddT0.size()) return -1; @@ -198,7 +198,7 @@ Int_t PMusrT0Data::GetAddT0(UInt_t addRunIdx, UInt_t idx) } //-------------------------------------------------------------------------- -// SetT0 +// SetT0Bin //-------------------------------------------------------------------------- /** *

Set t0 value. @@ -206,7 +206,7 @@ Int_t PMusrT0Data::GetAddT0(UInt_t addRunIdx, UInt_t idx) * \param val t0 value to be set * \param idx index at which t0 shall be set. */ -void PMusrT0Data::SetT0(UInt_t val, UInt_t idx) +void PMusrT0Data::SetT0Bin(UInt_t val, UInt_t idx) { if (idx >= fT0.size()) fT0.resize(idx+1); @@ -215,7 +215,7 @@ void PMusrT0Data::SetT0(UInt_t val, UInt_t idx) } //-------------------------------------------------------------------------- -// SetAddT0 +// SetAddT0Bin //-------------------------------------------------------------------------- /** *

Set addt0 value. @@ -224,7 +224,7 @@ void PMusrT0Data::SetT0(UInt_t val, UInt_t idx) * \param addRunIdx addt0 index (for each addrun, there has to be an addt0) * \param idx index at which t0 shall be set. */ -void PMusrT0Data::SetAddT0(UInt_t val, UInt_t addRunIdx, UInt_t idx) +void PMusrT0Data::SetAddT0Bin(UInt_t val, UInt_t addRunIdx, UInt_t idx) { if (addRunIdx >= fAddT0.size()) fAddT0.resize(addRunIdx+1); @@ -334,9 +334,9 @@ PMusrT0::PMusrT0(PMusrT0Data &data) : fMusrT0Data(data) fValid = false; return; } - Int_t histoNo = fMusrT0Data.GetHistoNo(fMusrT0Data.GetHistoNoIdx())-1; - if (histoNo >= (Int_t)rawRunData->GetNoOfHistos()) { - cerr << endl << ">> PMusrT0::PMusrT0: **ERROR** found histogram number " << histoNo+1 << ", but only " << rawRunData->GetNoOfHistos() << " are present."; + Int_t histoNo = fMusrT0Data.GetHistoNo(fMusrT0Data.GetHistoNoIdx()); + if (!rawRunData->IsPresent(histoNo)) { + cerr << endl << ">> PMusrT0::PMusrT0: **ERROR** found histogram number " << histoNo+1 << " which is NOT present in the data file."; cerr << endl << ">> Please try to fix this first ..." << endl; fValid = false; return; @@ -375,7 +375,7 @@ PMusrT0::PMusrT0(PMusrT0Data &data) : fMusrT0Data(data) } // get run and first histo of grouping and feed it into fHisto - Int_t histoNo = fMusrT0Data.GetHistoNo(0)-1; + Int_t histoNo = fMusrT0Data.GetHistoNo(0); Int_t noOfBins = rawRunData->GetDataBin(histoNo)->size(); Double_t start = -0.5; Double_t end = noOfBins - 0.5; // -0.5 is correct since the data start at 0.0 @@ -395,9 +395,9 @@ PMusrT0::PMusrT0(PMusrT0Data &data) : fMusrT0Data(data) factor=2; if (fMusrT0Data.GetDetectorTag() == PMUSRT0_FORWARD) - t00 = fMusrT0Data.GetT0(0); + t00 = fMusrT0Data.GetT0Bin(0); else - t00 = fMusrT0Data.GetT0(1); + t00 = fMusrT0Data.GetT0Bin(1); // check if there are addruns and grouping if ((fMusrT0Data.GetRawRunDataSize() > 1) && (fMusrT0Data.GetHistoNoSize() > 1)) { // addruns and grouping present @@ -408,13 +408,13 @@ PMusrT0::PMusrT0(PMusrT0Data &data) : fMusrT0Data(data) for (UInt_t k=0; k 0) && (i+t0-t00 < static_cast(rawRunData->GetDataBin(histoNo)->size()))) @@ -448,13 +448,13 @@ PMusrT0::PMusrT0(PMusrT0Data &data) : fMusrT0Data(data) dval = 0; - histoNo = fMusrT0Data.GetHistoNo(0)-1; + histoNo = fMusrT0Data.GetHistoNo(0); // get t0 if (fMusrT0Data.GetDetectorTag() == PMUSRT0_FORWARD) - t0 = fMusrT0Data.GetT0(0); + t0 = fMusrT0Data.GetT0Bin(0); else - t0 = fMusrT0Data.GetT0(1); + t0 = fMusrT0Data.GetT0Bin(1); // get proper rawRunData rawRunData = fMusrT0Data.GetRawRunData(0); @@ -470,9 +470,9 @@ PMusrT0::PMusrT0(PMusrT0Data &data) : fMusrT0Data(data) // get t0 if (fMusrT0Data.GetDetectorTag() == PMUSRT0_FORWARD) - t0 = fMusrT0Data.GetAddT0(j-1, 0); + t0 = fMusrT0Data.GetAddT0Bin(j-1, 0); else - t0 = fMusrT0Data.GetAddT0(j-1, 1); + t0 = fMusrT0Data.GetAddT0Bin(j-1, 1); // get bin value from addrun/grouping if ((i+t0-t00 > 0) && (i+t0-t00 < static_cast(rawRunData->GetDataBin(histoNo)->size()))) @@ -493,13 +493,13 @@ PMusrT0::PMusrT0(PMusrT0Data &data) : fMusrT0Data(data) for (UInt_t k=0; k 0) && (i+t0-t00 < static_cast(rawRunData->GetDataBin(histoNo)->size()))) @@ -724,7 +724,7 @@ void PMusrT0::SetMsrHandler(PMsrHandler *msrHandler) void PMusrT0::InitT0() { // t0 line - Int_t t0Bin = 0; + Double_t t0Bin = 0; Int_t histoIdx = fMusrT0Data.GetHistoNoIdx(); Int_t addRunIdx = fMusrT0Data.GetAddRunIdx(); UInt_t factor=1; @@ -733,15 +733,15 @@ void PMusrT0::InitT0() switch (fMusrT0Data.GetDetectorTag() ) { case PMUSRT0_FORWARD: if (addRunIdx == 0) - t0Bin = fMsrHandler->GetMsrRunList()->at(fMusrT0Data.GetRunNo()).GetT0(factor*histoIdx); + t0Bin = fMsrHandler->GetMsrRunList()->at(fMusrT0Data.GetRunNo()).GetT0Bin(factor*histoIdx); else if (addRunIdx > 0) - t0Bin = fMsrHandler->GetMsrRunList()->at(fMusrT0Data.GetRunNo()).GetAddT0(addRunIdx-1, factor*histoIdx); + t0Bin = fMsrHandler->GetMsrRunList()->at(fMusrT0Data.GetRunNo()).GetAddT0Bin(addRunIdx-1, factor*histoIdx); break; case PMUSRT0_BACKWARD: if (addRunIdx == 0) - t0Bin = fMsrHandler->GetMsrRunList()->at(fMusrT0Data.GetRunNo()).GetT0(factor*histoIdx+1); + t0Bin = fMsrHandler->GetMsrRunList()->at(fMusrT0Data.GetRunNo()).GetT0Bin(factor*histoIdx+1); else if (addRunIdx > 0) - t0Bin = fMsrHandler->GetMsrRunList()->at(fMusrT0Data.GetRunNo()).GetAddT0(addRunIdx-1, factor*histoIdx+1); + t0Bin = fMsrHandler->GetMsrRunList()->at(fMusrT0Data.GetRunNo()).GetAddT0Bin(addRunIdx-1, factor*histoIdx+1); break; default: // not clear yet what to be done @@ -861,7 +861,7 @@ void PMusrT0::InitDataAndBkg() void PMusrT0::ShowDataFileT0Channel() { // t0 line - Int_t t0Bin = fMusrT0Data.GetT0Data(); + Int_t t0Bin = fMusrT0Data.GetT0BinData(); Double_t max = fHisto->GetMaximum(); if (!fT0DataLine) { diff --git a/src/classes/PRunAsymmetry.cpp b/src/classes/PRunAsymmetry.cpp index edc7707e..d67174f1 100644 --- a/src/classes/PRunAsymmetry.cpp +++ b/src/classes/PRunAsymmetry.cpp @@ -10,7 +10,7 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007 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 * @@ -385,11 +385,11 @@ Bool_t PRunAsymmetry::PrepareData() PUIntVector forwardHistoNo; PUIntVector backwardHistoNo; for (UInt_t i=0; iGetForwardHistoNoSize(); i++) { - forwardHistoNo.push_back(fRunInfo->GetForwardHistoNo(i)-1); + forwardHistoNo.push_back(fRunInfo->GetForwardHistoNo(i)); - if (runData->GetNoOfHistos() <= forwardHistoNo[i]) { + if (!runData->IsPresent(forwardHistoNo[i])) { cerr << endl << ">> PRunAsymmetry::PrepareData(): **PANIC ERROR**:"; - cerr << endl << ">> forwardHistoNo found = " << forwardHistoNo[i]+1 << ", but there are only " << runData->GetNoOfHistos() << " runs!?!?"; + cerr << endl << ">> forwardHistoNo found = " << forwardHistoNo[i] << ", which is NOT present in the data file!?!?"; cerr << endl << ">> Will quit :-("; cerr << endl; // clean up @@ -399,11 +399,11 @@ Bool_t PRunAsymmetry::PrepareData() } } for (UInt_t i=0; iGetBackwardHistoNoSize(); i++) { - backwardHistoNo.push_back(fRunInfo->GetBackwardHistoNo(i)-1); + backwardHistoNo.push_back(fRunInfo->GetBackwardHistoNo(i)); - if (runData->GetNoOfHistos() <= backwardHistoNo[i]) { + if (!runData->IsPresent(backwardHistoNo[i])) { cerr << endl << ">> PRunAsymmetry::PrepareData(): **PANIC ERROR**:"; - cerr << endl << ">> backwardHistoNo found = " << backwardHistoNo[i]+1 << ", but there are only " << runData->GetNoOfHistos() << " runs!?!?"; + cerr << endl << ">> backwardHistoNo found = " << backwardHistoNo[i] << ", which is NOT present in the data file!?!?"; cerr << endl << ">> Will quit :-("; cerr << endl; // clean up @@ -423,75 +423,74 @@ Bool_t PRunAsymmetry::PrepareData() return false; } - // check if the t0's are given in the msr-file - if (fRunInfo->GetT0Size() == 0) { // t0's are NOT in the msr-file - // check if the t0's are in the data file - if (runData->GetT0Size() != 0) { // t0's in the run data - // keep the proper t0's. For asymmetry runs, forward/backward are holding the histo no - // fForwardHistoNo starts with 1 not with 0 etc. ;-) - for (UInt_t i=0; iGetT0(fRunInfo->GetForwardHistoNo(i)-1)); // forward t0 - fT0s.push_back(runData->GetT0(fRunInfo->GetBackwardHistoNo(i)-1)); // backward t0 - } - } else { // t0's are neither in the run data nor in the msr-file -> will try estimated ones! - for (UInt_t i=0; iGetT0Estimated(fRunInfo->GetForwardHistoNo(i)-1)); - fT0s.push_back(runData->GetT0Estimated(fRunInfo->GetBackwardHistoNo(i)-1)); - cerr << endl << ">> PRunAsymmetry::PrepareData(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!"; - cerr << endl << ">> run: " << fRunInfo->GetRunName()->Data(); - cerr << endl << ">> will try the estimated one: forward t0 = " << runData->GetT0Estimated(fRunInfo->GetForwardHistoNo(i)-1); - cerr << endl << ">> will try the estimated one: backward t0 = " << runData->GetT0Estimated(fRunInfo->GetBackwardHistoNo(i)-1); - cerr << endl << ">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; - cerr << endl; - } - } - } else { // t0's in the msr-file - for (UInt_t i=0; iGetT0Size() <= 2*i) || (fRunInfo->GetT0Size() <= 2*i+1)) { // t0 for i not present in the msr-file, i.e. #t0's != #forward histos - if (static_cast(runData->GetT0Size()) > fRunInfo->GetForwardHistoNo(i)-1) { // t0 for i present in the data file - fT0s.push_back(runData->GetT0(fRunInfo->GetForwardHistoNo(i)-1)); - } else { // t0 is neither in the run data nor in the msr-file -> will try estimated ones! - fT0s.push_back(runData->GetT0Estimated(fRunInfo->GetForwardHistoNo(i)-1)); - cerr << endl << ">> PRunSingleHisto::PrepareData(): **WARNING** NO t0's found, neither in the run data nor in the msr-file!"; - cerr << endl << ">> run: " << fRunInfo->GetRunName()->Data(); - cerr << endl << ">> will try the estimated one: t0 = " << runData->GetT0Estimated(fRunInfo->GetForwardHistoNo(i)-1); - cerr << endl << ">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; - cerr << endl; - } - if (static_cast(runData->GetT0Size()) > fRunInfo->GetBackwardHistoNo(i)-1) { // t0 for i present in the data file - fT0s.push_back(runData->GetT0(fRunInfo->GetBackwardHistoNo(i)-1)); - } else { // t0 is neither in the run data nor in the msr-file -> will try estimated ones! - fT0s.push_back(runData->GetT0Estimated(fRunInfo->GetBackwardHistoNo(i)-1)); - cerr << endl << ">> PRunSingleHisto::PrepareData(): **WARNING** NO t0's found, neither in the run data nor in the msr-file!"; - cerr << endl << ">> run: " << fRunInfo->GetRunName()->Data(); - cerr << endl << ">> will try the estimated one: t0 = " << runData->GetT0Estimated(fRunInfo->GetBackwardHistoNo(i)-1); - cerr << endl << ">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; - cerr << endl; - } - } else { // # of t0's in the msr-file == # of histos in forward - fT0s.push_back(fRunInfo->GetT0(2*i)); // forward t0 - fT0s.push_back(fRunInfo->GetT0(2*i+1)); // backward t0 + // feed all T0's + // first init T0's, T0's are stored as (forward T0, backward T0, etc.) + fT0s.clear(); + fT0s.resize(2*forwardHistoNo.size()); + for (UInt_t i=0; iGetT0Size() != 0) { - // compare t0's of the msr-file with the one in the data file - if (fabs(fRunInfo->GetT0(2*i)-runData->GetT0(fRunInfo->GetForwardHistoNo(i)-1))>5.0) { - cerr << endl << ">> PRunAsymmetry::PrepareData(): **WARNING**: forward histo #" << i+1; - cerr << endl << ">> t0 from the msr-file is " << fRunInfo->GetT0(2*i)+1; - cerr << endl << ">> t0 from the data file is " << runData->GetT0(fRunInfo->GetForwardHistoNo(i)-1); - cerr << endl << ">> This is quite a deviation! Is this done intentionally??"; - cerr << endl; - } - if (fabs(fRunInfo->GetT0(2*i+1)-runData->GetT0(fRunInfo->GetBackwardHistoNo(i)-1))>5.0) { // given in bins!! - cerr << endl << ">> PRunAsymmetry::PrepareData(): **WARNING**: backward histo #" << i+1; - cerr << endl << ">> t0 from the msr-file is " << fRunInfo->GetT0(2*i+1)+1; - cerr << endl << ">> t0 from the data file is " << runData->GetT0(fRunInfo->GetBackwardHistoNo(i)-1); - cerr << endl << ">> This is quite a deviation! Is this done intentionally??"; - cerr << endl; - } - } + // fill in the T0's from the msr-file (if present) + for (UInt_t i=0; iGetT0BinSize(); i++) { + fT0s[i] = fRunInfo->GetT0Bin(i); + } + + // fill in the T0's from the data file, if not already present in the msr-file + for (UInt_t i=0; iGetT0Bin(forwardHistoNo[i]) > 0.0) { + fT0s[2*i] = runData->GetT0Bin(forwardHistoNo[i]); + fRunInfo->SetT0Bin(fT0s[2*i], 2*i); } + } + for (UInt_t i=0; iGetT0Bin(backwardHistoNo[i]) > 0.0) { + fT0s[2*i+1] = runData->GetT0Bin(backwardHistoNo[i]); + fRunInfo->SetT0Bin(fT0s[2*i+1], 2*i+1); + } + } + + // fill in the T0's gaps, i.e. in case the T0's are NOT in the msr-file and NOT in the data file + for (UInt_t i=0; iGetT0BinEstimated(forwardHistoNo[i]); + fRunInfo->SetT0Bin(fT0s[2*i], 2*i); + + cerr << endl << ">> PRunAsymmetry::PrepareData(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!"; + cerr << endl << ">> run: " << fRunInfo->GetRunName(); + cerr << endl << ">> will try the estimated one: forward t0 = " << runData->GetT0BinEstimated(forwardHistoNo[i]); + cerr << endl << ">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; + cerr << endl; + } + } + for (UInt_t i=0; iGetT0BinEstimated(backwardHistoNo[i]); + fRunInfo->SetT0Bin(fT0s[2*i+1], 2*i+1); + + cerr << endl << ">> PRunAsymmetry::PrepareData(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!"; + cerr << endl << ">> run: " << fRunInfo->GetRunName(); + cerr << endl << ">> will try the estimated one: backward t0 = " << runData->GetT0BinEstimated(backwardHistoNo[i]); + cerr << endl << ">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; + cerr << endl; + } + } + + // check if t0 is within proper bounds + for (UInt_t i=0; i (Int_t)runData->GetDataBin(forwardHistoNo[i])->size())) { + cerr << endl << ">> PRunAsymmetry::PrepareData(): **ERROR** t0 data bin (" << fT0s[2*i] << ") doesn't make any sense!"; + cerr << endl << ">> forwardHistoNo " << forwardHistoNo[i]; + cerr << endl; + return false; + } + if ((fT0s[2*i+1] < 0) || (fT0s[2*i+1] > (Int_t)runData->GetDataBin(backwardHistoNo[i])->size())) { + cerr << endl << ">> PRunAsymmetry::PrepareData(): **ERROR** t0 data bin (" << fT0s[2*i+1] << ") doesn't make any sense!"; + cerr << endl << ">> backwardHistoNo " << backwardHistoNo[i]; + cerr << endl; + return false; } } @@ -520,66 +519,60 @@ Bool_t PRunAsymmetry::PrepareData() } // get T0's of the to be added run - PUIntVector t0Add; - // check if the t0's are given in the msr-file - if (i > fRunInfo->GetAddT0Entries()) { // t0's are NOT in the msr-file - // check if the t0's are in the data file - if (addRunData->GetT0Size() != 0) { // t0's in the run data - // keep the proper t0's. For asymmetry runs, forward/backward are holding the histo no - // fForwardHistoNo starts with 1 not with 0 etc. ;-) - for (UInt_t j=0; jGetForwardHistoNoSize(); j++) { - t0Add.push_back(addRunData->GetT0(fRunInfo->GetForwardHistoNo(j)-1)); // forward t0 - t0Add.push_back(addRunData->GetT0(fRunInfo->GetBackwardHistoNo(j)-1)); // backward t0 + PDoubleVector t0Add; + + // feed all T0's + // first init T0's, T0's are stored as (forward T0, backward T0, etc.) + t0Add.clear(); + t0Add.resize(2*forwardHistoNo.size()); + for (UInt_t j=0; jGetAddT0BinSize(i); j++) { + t0Add[j] = fRunInfo->GetAddT0Bin(i, j); + } + + // fill in the T0's from the data file, if not already present in the msr-file + for (UInt_t j=0; jGetT0Bin(forwardHistoNo[j]) > 0.0) { + t0Add[2*j] = addRunData->GetT0Bin(forwardHistoNo[j]); + fRunInfo->SetAddT0Bin(t0Add[2*j], i-1, 2*j); } - } else { // t0's are neither in the run data nor in the msr-file -> will try estimated ones! - for (UInt_t j=0; jGetForwardHistoNoSize(); j++) { - t0Add.push_back(addRunData->GetT0Estimated(fRunInfo->GetForwardHistoNo(j)-1)); - t0Add.push_back(addRunData->GetT0Estimated(fRunInfo->GetBackwardHistoNo(j)-1)); - cerr << endl << ">> PRunAsymmetry::PrepareData(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!"; - cerr << endl << ">> addRun: " << fRunInfo->GetRunName(i)->Data(); - cerr << endl << ">> will try the estimated one: forward t0 = " << addRunData->GetT0Estimated(fRunInfo->GetForwardHistoNo(j)-1); - cerr << endl << ">> will try the estimated one: backward t0 = " << addRunData->GetT0Estimated(fRunInfo->GetBackwardHistoNo(j)-1); - cerr << endl << ">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; - cerr << endl; + } + for (UInt_t j=0; jGetT0Bin(backwardHistoNo[j]) > 0.0) { + t0Add[2*j+1] = addRunData->GetT0Bin(backwardHistoNo[j]); + fRunInfo->SetAddT0Bin(t0Add[2*j+1], i-1, 2*j+1); } + } + + // fill in the T0's gaps, i.e. in case the T0's are NOT in the msr-file and NOT in the data file + for (UInt_t j=0; jGetT0BinEstimated(forwardHistoNo[j]); + fRunInfo->SetAddT0Bin(t0Add[2*j], i-1, 2*j); + + cerr << endl << ">> PRunAsymmetry::PrepareData(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!"; + cerr << endl << ">> run: " << fRunInfo->GetRunName(i); + cerr << endl << ">> will try the estimated one: forward t0 = " << addRunData->GetT0BinEstimated(forwardHistoNo[j]); + cerr << endl << ">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; + cerr << endl; } - } else { // t0's in the msr-file - for (UInt_t j=0; jGetForwardHistoNoSize(); j++) { - // check if t0's are given in the data file - if (addRunData->GetT0Size() != 0) { - // compare t0's of the msr-file with the one in the data file - if (fabs(fRunInfo->GetAddT0(i-1,2*j)-addRunData->GetT0(fRunInfo->GetForwardHistoNo(j)-1))>5.0) { // given in bins!! - cerr << endl << ">> PRunAsymmetry::PrepareData(): **WARNING**:"; - cerr << endl << ">> t0 from the msr-file is " << fRunInfo->GetAddT0(i-1,2*j)+1; // +1 since vector starts at 0 - cerr << endl << ">> t0 from the data file is " << addRunData->GetT0(fRunInfo->GetForwardHistoNo(j)-1); - cerr << endl << ">> This is quite a deviation! Is this done intentionally??"; - cerr << endl << ">> addrun: " << fRunInfo->GetRunName(i)->Data(); - cerr << endl; - } - if (fabs(fRunInfo->GetAddT0(i-1,2*j+1)-addRunData->GetT0(fRunInfo->GetBackwardHistoNo(j)-1))>5.0) { // given in bins!! - cerr << endl << ">> PRunAsymmetry::PrepareData(): **WARNING**:"; - cerr << endl << ">> t0 from the msr-file is " << fRunInfo->GetAddT0(i-1,2*j+1)+1; // +1 since vector starts at 0 - cerr << endl << ">> t0 from the data file is " << addRunData->GetT0(fRunInfo->GetBackwardHistoNo(j)-1); - cerr << endl << ">> This is quite a deviation! Is this done intentionally??"; - cerr << endl << ">> addrun: " << fRunInfo->GetRunName(i)->Data(); - cerr << endl; - } - } - if (i <= fRunInfo->GetAddT0Entries()) { - if (2*j+1 < static_cast(fRunInfo->GetAddT0Size(i-1))) { - t0Add.push_back(fRunInfo->GetAddT0(i-1,2*j)); - t0Add.push_back(fRunInfo->GetAddT0(i-1,2*j+1)); - } else { - cerr << endl << ">> PRunSingleHisto::PrepareData(): **WARNING** NO t0's found, neither in the addrun data ("; - cerr << fRunInfo->GetRunName(i)->Data(); - cerr << "), nor in the msr-file! Will try to use the T0 of the run data ("; - cerr << fRunInfo->GetRunName(i)->Data(); - cerr << ") without any warranty!"; - cerr << endl; - t0Add.push_back(fRunInfo->GetT0(2*j)); - t0Add.push_back(fRunInfo->GetT0(2*j+1)); - } - } + } + for (UInt_t j=0; jGetT0BinEstimated(backwardHistoNo[j]); + fRunInfo->SetAddT0Bin(t0Add[2*j+1], i-1, 2*j+1); + + cerr << endl << ">> PRunAsymmetry::PrepareData(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!"; + cerr << endl << ">> run: " << fRunInfo->GetRunName(i); + cerr << endl << ">> will try the estimated one: backward t0 = " << runData->GetT0BinEstimated(backwardHistoNo[j]); + cerr << endl << ">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; + cerr << endl; } } @@ -589,8 +582,8 @@ Bool_t PRunAsymmetry::PrepareData() addRunSize = addRunData->GetDataBin(forwardHistoNo[k])->size(); for (UInt_t j=0; jGetDataBin(forwardHistoNo[k])->size(); j++) { // loop over the bin indices // make sure that the index stays in the proper range - if ((j+t0Add[2*k]-fT0s[2*k] >= 0) && (j+t0Add[2*k]-fT0s[2*k] < addRunSize)) { - forward[k][j] += addRunData->GetDataBin(forwardHistoNo[k])->at(j+t0Add[2*k]-fT0s[2*k]); + if ((j+(Int_t)t0Add[2*k]-(Int_t)fT0s[2*k] >= 0) && (j+(Int_t)t0Add[2*k]-(Int_t)fT0s[2*k] < addRunSize)) { + forward[k][j] += addRunData->GetDataBin(forwardHistoNo[k])->at(j+(Int_t)t0Add[2*k]-(Int_t)fT0s[2*k]); } } } @@ -600,8 +593,8 @@ Bool_t PRunAsymmetry::PrepareData() addRunSize = addRunData->GetDataBin(backwardHistoNo[k])->size(); for (UInt_t j=0; jGetDataBin(backwardHistoNo[k])->size(); j++) { // loop over the bin indices // make sure that the index stays in the proper range - if ((j+t0Add[2*k+1]-fT0s[2*k+1] >= 0) && (j+t0Add[2*k+1]-fT0s[2*k+1] < addRunSize)) { - backward[k][j] += addRunData->GetDataBin(backwardHistoNo[k])->at(j+t0Add[2*k+1]-fT0s[2*k+1]); + if ((j+(Int_t)t0Add[2*k+1]-(Int_t)fT0s[2*k+1] >= 0) && (j+(Int_t)t0Add[2*k+1]-(Int_t)fT0s[2*k+1] < addRunSize)) { + backward[k][j] += addRunData->GetDataBin(backwardHistoNo[k])->at(j+(Int_t)t0Add[2*k+1]-(Int_t)fT0s[2*k+1]); } } } @@ -871,24 +864,28 @@ Bool_t PRunAsymmetry::PrepareFitData(PRawRunData* runData, UInt_t histoNo[2]) // check if data range has been provided, and if not try to estimate them if (start[0] < 0) { start[0] = (Int_t)t0[0]+offset; + fRunInfo->SetDataRange(start[0], 0); cerr << endl << ">> PRunAsymmetry::PrepareData(): **WARNING** data range (forward) was not provided, will try data range start = t0+" << offset << "(=10ns) = " << start[0] << "."; cerr << endl << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; cerr << endl; } if (start[1] < 0) { start[1] = (Int_t)t0[1]+offset; + fRunInfo->SetDataRange(start[1], 2); cerr << endl << ">> PRunAsymmetry::PrepareData(): **WARNING** data range (backward) was not provided, will try data range start = t0+" << offset << "(=10ns) = " << start[1] << "."; cerr << endl << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; cerr << endl; } if (end[0] < 0) { end[0] = runData->GetDataBin(histoNo[0])->size(); + fRunInfo->SetDataRange(end[0], 1); cerr << endl << ">> PRunAsymmetry::PrepareData(): **WARNING** data range (forward) was not provided, will try data range end = " << end[0] << "."; cerr << endl << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; cerr << endl; } if (end[1] < 0) { end[1] = runData->GetDataBin(histoNo[1])->size(); + fRunInfo->SetDataRange(end[1], 3); cerr << endl << ">> PRunAsymmetry::PrepareData(): **WARNING** data range (backward) was not provided, will try data range end = " << end[1] << "."; cerr << endl << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; cerr << endl; @@ -1023,14 +1020,6 @@ Bool_t PRunAsymmetry::PrepareFitData(PRawRunData* runData, UInt_t histoNo[2]) fData.AppendErrorValue(error); } -// // count the number of bins to be fitted -// Double_t time; -// fNoOfFitBins=0; -// for (UInt_t i=0; isize(); i++) { -// time = fData.GetDataTimeStart() + (Double_t)i * fData.GetDataTimeStep(); -// if ((time >= fFitStartTime) && (time <= fFitEndTime)) -// fNoOfFitBins++; -// } CalcNoOfFitBins(); // clean up diff --git a/src/classes/PRunBase.cpp b/src/classes/PRunBase.cpp index e8b23616..04e65168 100644 --- a/src/classes/PRunBase.cpp +++ b/src/classes/PRunBase.cpp @@ -10,7 +10,7 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007 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 * diff --git a/src/classes/PRunDataHandler.cpp b/src/classes/PRunDataHandler.cpp index e63663ba..16d67943 100644 --- a/src/classes/PRunDataHandler.cpp +++ b/src/classes/PRunDataHandler.cpp @@ -10,7 +10,7 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007 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 * @@ -52,6 +52,7 @@ using namespace std; #include #include +#include "TMusrRunHeader.h" #include "TLemRunHeader.h" #include "MuSR_td_PSI_bin.h" #include "mud.h" @@ -62,18 +63,21 @@ using namespace std; #include "PRunDataHandler.h" -#define ROOT_ALL 0 -#define ROOT_NPP 1 -#define ROOT_PPC 2 +#define PRH_MUSR_ROOT 0 +#define PRH_LEM_ROOT 1 + +#define PRH_NPP_OFFSET 0 +#define PRH_PPC_OFFSET 20 #define A2M_UNDEFINED 0 #define A2M_ROOT 1 -#define A2M_PSIBIN 2 -#define A2M_PSIMDU 3 -#define A2M_MUD 4 -#define A2M_NEXUS 5 -#define A2M_WKM 6 -#define A2M_ASCII 7 +#define A2M_MUSR_ROOT 2 +#define A2M_PSIBIN 3 +#define A2M_PSIMDU 4 +#define A2M_MUD 5 +#define A2M_NEXUS 6 +#define A2M_WKM 7 +#define A2M_ASCII 8 //-------------------------------------------------------------------------- // Constructor @@ -220,28 +224,49 @@ Bool_t PRunDataHandler::ReadFilesMsr() if (!FileExistsCheck(runList->at(i), j)) return false; // everything looks fine, hence try to read the data file - if (!runList->at(i).GetFileFormat(j)->CompareTo("root-npp")) // not post pile up corrected histos - success = ReadRootFile(ROOT_NPP); - else if (!runList->at(i).GetFileFormat(j)->CompareTo("root-ppc")) // post pile up corrected histos - success = ReadRootFile(ROOT_PPC); - else if (!runList->at(i).GetFileFormat(j)->CompareTo("nexus")) + if (!runList->at(i).GetFileFormat(j)->CompareTo("root-npp")) { // not post pile up corrected histos + // check if forward/backward histoNo are within proper bounds, i.e. < PRH_PPC_OFFSET + for (UInt_t k=0; kat(i).GetForwardHistoNoSize(); k++) { + if (runList->at(i).GetForwardHistoNo(k) > PRH_PPC_OFFSET) + runList->at(i).SetForwardHistoNo(runList->at(i).GetForwardHistoNo(k)-PRH_PPC_OFFSET, k); + } + for (UInt_t k=0; kat(i).GetBackwardHistoNoSize(); k++) { + if (runList->at(i).GetBackwardHistoNo(k) > PRH_PPC_OFFSET) + runList->at(i).SetBackwardHistoNo(runList->at(i).GetBackwardHistoNo(k)-PRH_PPC_OFFSET, k); + } + success = ReadRootFile(); + } else if (!runList->at(i).GetFileFormat(j)->CompareTo("root-ppc")) { // post pile up corrected histos + // check if forward/backward histoNo are within proper bounds, i.e. > PRH_PPC_OFFSET + for (UInt_t k=0; kat(i).GetForwardHistoNoSize(); k++) { + if (runList->at(i).GetForwardHistoNo(k) < PRH_PPC_OFFSET) + runList->at(i).SetForwardHistoNo(runList->at(i).GetForwardHistoNo(k)+PRH_PPC_OFFSET, k); + } + for (UInt_t k=0; kat(i).GetBackwardHistoNoSize(); k++) { + if (runList->at(i).GetBackwardHistoNo(k) < PRH_PPC_OFFSET) + runList->at(i).SetBackwardHistoNo(runList->at(i).GetBackwardHistoNo(k)+PRH_PPC_OFFSET, k); + } + success = ReadRootFile(); + } else if (!runList->at(i).GetFileFormat(j)->CompareTo("musr-root")) { // MusrRoot style file + success = ReadRootFile(); + } else if (!runList->at(i).GetFileFormat(j)->CompareTo("nexus")) { success = ReadNexusFile(); - else if (!runList->at(i).GetFileFormat(j)->CompareTo("psi-bin")) + } else if (!runList->at(i).GetFileFormat(j)->CompareTo("psi-bin")) { success = ReadPsiBinFile(); - else if (!runList->at(i).GetFileFormat(j)->CompareTo("psi-mdu")) + } else if (!runList->at(i).GetFileFormat(j)->CompareTo("psi-mdu")) { success = ReadPsiBinFile(); - else if (!runList->at(i).GetFileFormat(j)->CompareTo("mud")) + } else if (!runList->at(i).GetFileFormat(j)->CompareTo("mud")) { success = ReadMudFile(); - else if (!runList->at(i).GetFileFormat(j)->CompareTo("wkm")) + } else if (!runList->at(i).GetFileFormat(j)->CompareTo("wkm")) { success = ReadWkmFile(); - else if (!runList->at(i).GetFileFormat(j)->CompareTo("mdu-ascii")) + } else if (!runList->at(i).GetFileFormat(j)->CompareTo("mdu-ascii")) { success = ReadMduAsciiFile(); - else if (!runList->at(i).GetFileFormat(j)->CompareTo("ascii")) + } else if (!runList->at(i).GetFileFormat(j)->CompareTo("ascii")) { success = ReadAsciiFile(); - else if (!runList->at(i).GetFileFormat(j)->CompareTo("db")) + } else if (!runList->at(i).GetFileFormat(j)->CompareTo("db")) { success = ReadDBFile(); - else + } else { success = false; + } } } @@ -295,6 +320,8 @@ Bool_t PRunDataHandler::ReadWriteFilesList() Int_t outTag = A2M_UNDEFINED; if (!fAny2ManyInfo->outFormat.CompareTo("root", TString::kIgnoreCase)) outTag = A2M_ROOT; + else if (!fAny2ManyInfo->outFormat.CompareTo("musrroot", TString::kIgnoreCase)) + outTag = A2M_MUSR_ROOT; else if (!fAny2ManyInfo->outFormat.CompareTo("psi-bin", TString::kIgnoreCase)) outTag = A2M_PSIBIN; else if (!fAny2ManyInfo->outFormat.CompareTo("mud",TString::kIgnoreCase)) @@ -326,7 +353,7 @@ Bool_t PRunDataHandler::ReadWriteFilesList() Bool_t success = false; switch (inTag) { case A2M_ROOT: - success = ReadRootFile(ROOT_ALL); + success = ReadRootFile(); break; case A2M_PSIBIN: success = ReadPsiBinFile(); @@ -361,6 +388,13 @@ Bool_t PRunDataHandler::ReadWriteFilesList() else success = WriteRootFile(fAny2ManyInfo->outFileName); break; + case A2M_MUSR_ROOT: + if (fAny2ManyInfo->outFileName.Length() == 0) + success = WriteMusrRootFile(); + else + success = WriteMusrRootFile(fAny2ManyInfo->outFileName); + break; + break; case A2M_PSIBIN: if (fAny2ManyInfo->outFileName.Length() == 0) success = WritePsiBinFile(); @@ -421,7 +455,7 @@ Bool_t PRunDataHandler::ReadWriteFilesList() Bool_t success = false; switch (inTag) { case A2M_ROOT: - success = ReadRootFile(ROOT_ALL); + success = ReadRootFile(); break; case A2M_PSIBIN: success = ReadPsiBinFile(); @@ -465,6 +499,9 @@ Bool_t PRunDataHandler::ReadWriteFilesList() case A2M_ROOT: success = WriteRootFile(fln); break; + case A2M_MUSR_ROOT: + success = WriteMusrRootFile(fln); + break; case A2M_PSIBIN: success = WritePsiBinFile(fln); break; @@ -761,6 +798,8 @@ Bool_t PRunDataHandler::FileExistsCheck(PMsrRunBlock &runInfo, const UInt_t idx) ext = TString("root"); else if (!runInfo.GetFileFormat(idx)->CompareTo("root-ppc")) // post pile up corrected histos ext = TString("root"); + else if (!runInfo.GetFileFormat(idx)->CompareTo("musr-root")) // post pile up corrected histos + ext = TString("root"); else if (!runInfo.GetFileFormat(idx)->CompareTo("nexus")) ext = TString("NXS"); else if (!runInfo.GetFileFormat(idx)->CompareTo("psi-bin")) @@ -796,6 +835,7 @@ Bool_t PRunDataHandler::FileExistsCheck(PMsrRunBlock &runInfo, const UInt_t idx) cerr << endl << ">> support file formats are:"; cerr << endl << ">> ROOT-NPP -> root not post pileup corrected for lem"; cerr << endl << ">> ROOT-PPC -> root post pileup corrected for lem"; + cerr << endl << ">> MUSR-ROOT -> MusrRoot file format"; cerr << endl << ">> NEXUS -> nexus file format, HDF4, HDF5, or XML"; cerr << endl << ">> PSI-BIN -> psi bin file format"; cerr << endl << ">> PSI-MDU -> psi mdu file format (see also MDU-ASCII)"; @@ -1019,279 +1059,269 @@ Bool_t PRunDataHandler::FileExistsCheck(const Bool_t fileName, const Int_t idx) // ReadRootFile //-------------------------------------------------------------------------- /** - *

Reads the LEM-data ROOT-files. + *

Reads both, the "old" LEM-data ROOT-files with TLemRunHeader, and the more general + * new MusrRoot file. * * return: * - true at successful reading, * - otherwise false. - * - * \param tag This tag is used as a switch between "Not Post Pileup Corrected", - * "Post Pileup Corrected", and "Read All" histogramms. */ -Bool_t PRunDataHandler::ReadRootFile(UInt_t tag) +Bool_t PRunDataHandler::ReadRootFile() { - PDoubleVector histoData; - PRawRunData runData; + PDoubleVector histoData; + PRawRunData runData; + PRawRunDataSet dataSet; TFile f(fRunPathName.Data()); if (f.IsZombie()) { return false; } + UInt_t fileType = PRH_MUSR_ROOT; + TFolder *folder; - f.GetObject("RunInfo", folder); - if (!folder) { - cerr << endl << ">> PRunDataHandler::ReadRootFile: **ERROR** Couldn't obtain RunInfo from " << fRunPathName.Data() << endl; - f.Close(); - return false; - } - - // read header and check if some missing run info need to be fed - TLemRunHeader *runHeader = dynamic_cast(folder->FindObjectAny("TLemRunHeader")); - - // check if run header is valid - if (!runHeader) { - cerr << endl << ">> PRunDataHandler::ReadRootFile: **ERROR** Couldn't obtain run header info from ROOT file " << fRunPathName.Data() << endl; - f.Close(); - return false; - } - - // set laboratory / beamline / instrument - runData.SetLaboratory("PSI"); - runData.SetBeamline("muE4"); - runData.SetInstrument("LEM"); - runData.SetMuonSource("low energy muon source"); - runData.SetMuonSpecies("positive muons"); - - // get run title - TObjString ostr = runHeader->GetRunTitle(); - runData.SetRunTitle(ostr.GetString()); - - // get run number - runData.SetRunNumber((Int_t)runHeader->GetRunNumber()); - - // get temperature - runData.ClearTemperature(); - runData.SetTemperature(0, runHeader->GetSampleTemperature(), runHeader->GetSampleTemperatureError()); - - // get field - runData.SetField(runHeader->GetSampleBField()); - - // get implantation energy - runData.SetEnergy(runHeader->GetImpEnergy()); - - // get moderator HV - runData.SetTransport(runHeader->GetModeratorHV()); - - // get setup - runData.SetSetup(runHeader->GetLemSetup().GetString()); - - // get start time/date - // start date - time_t idt = (time_t)runHeader->GetStartTime(); - runData.SetStartDateTime(idt); - struct tm *dt = localtime(&idt); - char str[128]; - strftime(str, sizeof(str), "%F", dt); - TString stime(str); - runData.SetStartDate(stime); - // start time - memset(str, 0, sizeof(str)); - strftime(str, sizeof(str), "%T", dt); - stime = str; - runData.SetStartTime(stime); - - // get stop time/date - // stop date - idt = (time_t)runHeader->GetStopTime(); - runData.SetStopDateTime(idt); - dt = localtime(&idt); - memset(str, 0, sizeof(str)); - strftime(str, sizeof(str), "%F", dt); - stime = str; - runData.SetStopDate(stime); - // stop time - memset(str, 0, sizeof(str)); - strftime(str, sizeof(str), "%T", dt); - stime = str; - runData.SetStopTime(stime); - - // get time resolution - runData.SetTimeResolution(runHeader->GetTimeResolution()); - - // get number of histogramms - Int_t noOfHistos = runHeader->GetNHist(); - - // get t0's - Double_t *t0 = runHeader->GetTimeZero(); - // check if t0's are there - if (t0[0] != -1) { // ugly, but at the moment there is no other way - // copy t0's so they are not lost - for (Int_t i=0; i> PRunDataHandler::ReadRootFile: **ERROR** Couldn't neither obtain RunInfo (LEM),"; + cerr << endl << " nor RunHeader (MusrRoot) from " << fRunPathName.Data() << endl; + f.Close(); + return false; + } else { + fileType = PRH_MUSR_ROOT; } - if (tag == ROOT_ALL) { // since NPP and PPC the t0's needs to be doubled - for (Int_t i=0; i(folder->FindObjectAny("TLemRunHeader")); + + // check if run header is valid + if (!runHeader) { + cerr << endl << ">> PRunDataHandler::ReadRootFile: **ERROR** Couldn't obtain run header info from ROOT file " << fRunPathName.Data() << endl; + f.Close(); + return false; + } + + // set laboratory / beamline / instrument + runData.SetLaboratory("PSI"); + runData.SetBeamline("muE4"); + runData.SetInstrument("LEM"); + runData.SetMuonSource("low energy muon source"); + runData.SetMuonSpecies("positive muons"); + + // get run title + TObjString ostr = runHeader->GetRunTitle(); + runData.SetRunTitle(ostr.GetString()); + + // get run number + runData.SetRunNumber((Int_t)runHeader->GetRunNumber()); + + // get temperature + runData.ClearTemperature(); + runData.SetTemperature(0, runHeader->GetSampleTemperature(), runHeader->GetSampleTemperatureError()); + + // get field + runData.SetField(runHeader->GetSampleBField()); + + // get implantation energy + runData.SetEnergy(runHeader->GetImpEnergy()); + + // get moderator HV + runData.SetTransport(runHeader->GetModeratorHV()); + + // get setup + runData.SetSetup(runHeader->GetLemSetup().GetString()); + + // get start time/date + // start date + time_t idt = (time_t)runHeader->GetStartTime(); + runData.SetStartDateTime(idt); + struct tm *dt = localtime(&idt); + char str[128]; + strftime(str, sizeof(str), "%F", dt); + TString stime(str); + runData.SetStartDate(stime); + // start time + memset(str, 0, sizeof(str)); + strftime(str, sizeof(str), "%T", dt); + stime = str; + runData.SetStartTime(stime); + + // get stop time/date + // stop date + idt = (time_t)runHeader->GetStopTime(); + runData.SetStopDateTime(idt); + dt = localtime(&idt); + memset(str, 0, sizeof(str)); + strftime(str, sizeof(str), "%F", dt); + stime = str; + runData.SetStopDate(stime); + // stop time + memset(str, 0, sizeof(str)); + strftime(str, sizeof(str), "%T", dt); + stime = str; + runData.SetStopTime(stime); + + // get time resolution + runData.SetTimeResolution(runHeader->GetTimeResolution()); + + // get number of histogramms + Int_t noOfHistos = runHeader->GetNHist(); + + // get t0's there will be handled together with the data + Double_t *t0 = runHeader->GetTimeZero(); + + // read run summary to obtain ring anode HV values + TObjArray *runSummary = dynamic_cast(folder->FindObjectAny("RunSummary")); + + // check if run summary is valid + if (!runSummary) { + cout << endl << "**INFO** Couldn't obtain run summary info from ROOT file " << fRunPathName.Data() << endl; + // this is not fatal... only RA-HV values are not available + } else { // it follows a (at least) little bit strange extraction of the RA values from Thomas' TObjArray... + //streaming of a ASCII-file would be more easy + TString s; + TObjArrayIter summIter(runSummary); + TObjString *os(dynamic_cast(summIter.Next())); + TObjArray *oa(0); + TObjString *objTok(0); + while (os != 0) { + s = os->GetString(); + // will put four parallel if's since it may be that more than one RA-values are on one line + if (s.Contains("RA-L")) { + oa = s.Tokenize(" "); + TObjArrayIter lineIter(oa); + objTok = dynamic_cast(lineIter.Next()); + while (objTok != 0) { + if (!objTok->GetString().CompareTo("RA-L")) { + objTok = dynamic_cast(lineIter.Next()); // "=" + if (objTok != 0 && !objTok->GetString().CompareTo("=")) { + objTok = dynamic_cast(lineIter.Next()); // HV value + runData.SetRingAnode(0, objTok->GetString().Atof()); // fill RA-R value into the runData structure + break; + } + } + objTok = dynamic_cast(lineIter.Next()); // next token... + } + // clean up + if (oa) { + delete oa; + oa = 0; + } + } + + if (s.Contains("RA-R")) { + oa = s.Tokenize(" "); + TObjArrayIter lineIter(oa); + objTok = dynamic_cast(lineIter.Next()); + while (objTok != 0){ + if (!objTok->GetString().CompareTo("RA-R")) { + objTok = dynamic_cast(lineIter.Next()); // "=" + if (objTok != 0 && !objTok->GetString().CompareTo("=")) { + objTok = dynamic_cast(lineIter.Next()); // HV value + runData.SetRingAnode(1, objTok->GetString().Atof()); // fill RA-R value into the runData structure + break; + } + } + objTok = dynamic_cast(lineIter.Next()); // next token... + } + // clean up + if (oa) { + delete oa; + oa = 0; + } + } + + if (s.Contains("RA-T")) { + oa = s.Tokenize(" "); + TObjArrayIter lineIter(oa); + objTok = dynamic_cast(lineIter.Next()); + while (objTok != 0){ + if (!objTok->GetString().CompareTo("RA-T")) { + objTok = dynamic_cast(lineIter.Next()); // "=" + if (objTok != 0 && !objTok->GetString().CompareTo("=")) { + objTok = dynamic_cast(lineIter.Next()); // HV value + runData.SetRingAnode(2, objTok->GetString().Atof()); // fill RA-T value into the runData structure + break; + } + } + objTok = dynamic_cast(lineIter.Next()); // next token... + } + // clean up + if (oa) { + delete oa; + oa = 0; + } + } + + if (s.Contains("RA-B")) { + oa = s.Tokenize(" "); + TObjArrayIter lineIter(oa); + objTok = dynamic_cast(lineIter.Next()); + while (objTok != 0){ + if (!objTok->GetString().CompareTo("RA-B")) { + objTok = dynamic_cast(lineIter.Next()); // "=" + if (objTok != 0 && !objTok->GetString().CompareTo("=")) { + objTok = dynamic_cast(lineIter.Next()); // HV value + runData.SetRingAnode(3, objTok->GetString().Atof()); // fill RA-B value into the runData structure + break; + } + } + objTok = dynamic_cast(lineIter.Next()); // next token... + } + // clean up + if (oa) { + delete oa; + oa = 0; + } + } + + os = dynamic_cast(summIter.Next()); // next summary line... } } - } - // read run summary to obtain ring anode HV values - TObjArray *runSummary = dynamic_cast(folder->FindObjectAny("RunSummary")); + // read data --------------------------------------------------------- - // check if run summary is valid - if (!runSummary) { - cout << endl << "**INFO** Couldn't obtain run summary info from ROOT file " << fRunPathName.Data() << endl; - // this is not fatal... only RA-HV values are not available - } else { // it follows a (at least) little bit strange extraction of the RA values from Thomas' TObjArray... - //streaming of a ASCII-file would be more easy - TString s; - TObjArrayIter summIter(runSummary); - TObjString *os(dynamic_cast(summIter.Next())); - TObjArray *oa(0); - TObjString *objTok(0); - while (os != 0) { - s = os->GetString(); - // will put four parallel if's since it may be that more than one RA-values are on one line - if (s.Contains("RA-L")) { - oa = s.Tokenize(" "); - TObjArrayIter lineIter(oa); - objTok = dynamic_cast(lineIter.Next()); - while (objTok != 0) { - if (!objTok->GetString().CompareTo("RA-L")) { - objTok = dynamic_cast(lineIter.Next()); // "=" - if (objTok != 0 && !objTok->GetString().CompareTo("=")) { - objTok = dynamic_cast(lineIter.Next()); // HV value - runData.SetRingAnode(0, objTok->GetString().Atof()); // fill RA-R value into the runData structure - break; - } - } - objTok = dynamic_cast(lineIter.Next()); // next token... - } - } - - if (s.Contains("RA-R")) { - oa = s.Tokenize(" "); - TObjArrayIter lineIter(oa); - objTok = dynamic_cast(lineIter.Next()); - while (objTok != 0){ - if (!objTok->GetString().CompareTo("RA-R")) { - objTok = dynamic_cast(lineIter.Next()); // "=" - if (objTok != 0 && !objTok->GetString().CompareTo("=")) { - objTok = dynamic_cast(lineIter.Next()); // HV value - runData.SetRingAnode(1, objTok->GetString().Atof()); // fill RA-R value into the runData structure - break; - } - } - objTok = dynamic_cast(lineIter.Next()); // next token... - } - } - - if (s.Contains("RA-T")) { - oa = s.Tokenize(" "); - TObjArrayIter lineIter(oa); - objTok = dynamic_cast(lineIter.Next()); - while (objTok != 0){ - if (!objTok->GetString().CompareTo("RA-T")) { - objTok = dynamic_cast(lineIter.Next()); // "=" - if (objTok != 0 && !objTok->GetString().CompareTo("=")) { - objTok = dynamic_cast(lineIter.Next()); // HV value - runData.SetRingAnode(2, objTok->GetString().Atof()); // fill RA-T value into the runData structure - break; - } - } - objTok = dynamic_cast(lineIter.Next()); // next token... - } - } - - if (s.Contains("RA-B")) { - oa = s.Tokenize(" "); - TObjArrayIter lineIter(oa); - objTok = dynamic_cast(lineIter.Next()); - while (objTok != 0){ - if (!objTok->GetString().CompareTo("RA-B")) { - objTok = dynamic_cast(lineIter.Next()); // "=" - if (objTok != 0 && !objTok->GetString().CompareTo("=")) { - objTok = dynamic_cast(lineIter.Next()); // HV value - runData.SetRingAnode(3, objTok->GetString().Atof()); // fill RA-B value into the runData structure - break; - } - } - objTok = dynamic_cast(lineIter.Next()); // next token... - } - } - - os = dynamic_cast(summIter.Next()); // next summary line... + // check if histos folder is found + f.GetObject("histos", folder); + if (!folder) { + cerr << endl << ">> PRunDataHandler::ReadRootFile: **ERROR** Couldn't obtain histos from " << fRunPathName.Data() << endl; + f.Close(); + return false; } - } - // read data --------------------------------------------------------- - // check if histos folder is found - f.GetObject("histos", folder); - if (!folder) { - cerr << endl << ">> PRunDataHandler::ReadRootFile: **ERROR** Couldn't obtain histos from " << fRunPathName.Data() << endl; - f.Close(); - return false; - } - // get all the data - Char_t histoName[32]; - if (tag == ROOT_NPP) { // read the data which are NOT post pileup corrected + // get all the data + Char_t histoName[32]; for (Int_t i=0; i(folder->FindObjectAny(histoName)); if (!histo) { cerr << endl << ">> PRunDataHandler::ReadRootFile: **ERROR** Couldn't get histo " << histoName; cerr << endl; + f.Close(); return false; } - // keep maximum of histogram as a T0 estimate - runData.AppendT0Estimated(histo->GetMaximumBin()); + // fill data for (Int_t j=1; j<=histo->GetNbinsX(); j++) { histoData.push_back(histo->GetBinContent(j)); } - // store them in runData vector - runData.AppendDataBin(histoData); - // clear histoData for the next histo - histoData.clear(); - } - } else if (tag == ROOT_PPC) { // read the data which ARE post pileup corrected - for (Int_t i=0; i(folder->FindObjectAny(histoName)); - if (!histo) { - cerr << endl << ">> PRunDataHandler::ReadRootFile: **ERROR** Couldn't get histo " << histoName; - cerr << endl; - return false; - } - // keep maximum of histogram as a T0 estimate - runData.AppendT0Estimated(histo->GetMaximumBin()); - // fill data - for (Int_t j=1; j<=histo->GetNbinsX(); j++) - histoData.push_back(histo->GetBinContent(j)); - // store them in runData vector - runData.AppendDataBin(histoData); - // clear histoData for the next histo - histoData.clear(); - } - } else { // read PPC and NPP histos - for (Int_t i=0; i(folder->FindObjectAny(histoName)); - if (!histo) { - cerr << endl << ">> PRunDataHandler::ReadRootFile: **ERROR** Couldn't get histo " << histoName; - cerr << endl; - return false; - } - // keep maximum of histogram as a T0 estimate - runData.AppendT0Estimated(histo->GetMaximumBin()); - // fill data - for (Int_t j=1; j<=histo->GetNbinsX(); j++) { - histoData.push_back(histo->GetBinContent(j)); - } - // store them in runData vector - runData.AppendDataBin(histoData); + + // fill the data set + dataSet.Clear(); + dataSet.SetName(histo->GetTitle()); + dataSet.SetHistoNo(i+1); + dataSet.SetTimeZeroBin(t0[i]); + dataSet.SetTimeZeroBinEstimated(histo->GetMaximumBin()); + dataSet.SetFirstGoodBin(t0[i]); + dataSet.SetLastGoodBin(histo->GetNbinsX()-1); + dataSet.SetData(histoData); + runData.SetDataSet(dataSet); + // clear histoData for the next histo histoData.clear(); } @@ -1308,19 +1338,378 @@ Bool_t PRunDataHandler::ReadRootFile(UInt_t tag) if (!histo) { cerr << endl << ">> PRunDataHandler::ReadRootFile: **ERROR** Couldn't get histo " << histoName; cerr << endl; + f.Close(); return false; } - // keep maximum of histogram as a T0 estimate - runData.AppendT0Estimated(histo->GetMaximumBin()); + // fill data for (Int_t j=1; j<=histo->GetNbinsX(); j++) histoData.push_back(histo->GetBinContent(j)); - // store them in runData vector - runData.AppendDataBin(histoData); + + // fill the data set + dataSet.Clear(); + dataSet.SetName(histo->GetTitle()); + dataSet.SetHistoNo(i+1+POST_PILEUP_HISTO_OFFSET); + dataSet.SetTimeZeroBin(t0[i]); + dataSet.SetTimeZeroBinEstimated(histo->GetMaximumBin()); + dataSet.SetFirstGoodBin(t0[i]); + dataSet.SetLastGoodBin(histo->GetNbinsX()-1); + dataSet.SetData(histoData); + runData.SetDataSet(dataSet); + // clear histoData for the next histo histoData.clear(); } } + } else { // MusrRoot file + // invoke the MusrRoot header object + TMusrRunHeader *header = new TMusrRunHeader(true); // read quite + if (header == 0) { + cerr << endl << ">> PRunDataHandler::ReadRootFile: **ERROR** Couldn't invoke MusrRoot RunHeader in file:" << fRunPathName; + cerr << endl; + f.Close(); + return false; + } + + // try to populate the MusrRoot header object + if (!header->ExtractAll(folder)) { + cerr << endl << ">> PRunDataHandler::ReadRootFile: **ERROR** Couldn't invoke MusrRoot RunHeader in file:" << fRunPathName; + cerr << endl; + f.Close(); + return false; + } + + // get all the header information + Bool_t ok; + TString str, path, pathName; + Int_t ival, noOfHistos=0; + Double_t dval; + TMusrRunPhysicalQuantity prop; + PIntVector ivec, redGreenOffsets; + + header->Get("RunInfo/Version", str, ok); + if (ok) + runData.SetVersion(str); + + header->Get("RunInfo/Generic Validator URL", str, ok); + if (ok) + runData.SetGenericValidatorUrl(str); + + header->Get("RunInfo/Specific Validator URL", str, ok); + if (ok) + runData.SetSpecificValidatorUrl(str); + + header->Get("RunInfo/Generator", str, ok); + if (ok) + runData.SetGenerator(str); + + header->Get("RunInfo/File Name", str, ok); + if (ok) + runData.SetFileName(str); + + header->Get("RunInfo/Run Title", str, ok); + if (ok) + runData.SetRunTitle(str); + + header->Get("RunInfo/Run Number", ival, ok); + if (ok) + runData.SetRunNumber(ival); + + header->Get("RunInfo/Run Start Time", str, ok); + if (ok) { + Ssiz_t pos = str.Index(' '); + TString substr = str; + substr.Remove(pos, str.Length()); + runData.SetStartDate(substr); + substr = str; + substr.Remove(0, pos+1); + runData.SetStartTime(substr); + } + + header->Get("RunInfo/Run Stop Time", str, ok); + if (ok) { + Ssiz_t pos = str.Index(' '); + TString substr = str; + substr.Remove(pos, str.Length()); + runData.SetStopDate(substr); + substr = str; + substr.Remove(0, pos+1); + runData.SetStopTime(substr); + } + + header->Get("RunInfo/Laboratory", str, ok); + if (ok) + runData.SetLaboratory(str); + + header->Get("RunInfo/Area", str, ok); + if (ok) + runData.SetArea(str); + + header->Get("RunInfo/Instrument", str, ok); + if (ok) + runData.SetInstrument(str); + + header->Get("RunInfo/Muon Beam Momentum", prop, ok); + if (ok) { + if (!prop.GetUnit().CompareTo("MeV/c")) + runData.SetMuonBeamMomentum(prop.GetValue()); + } + + header->Get("RunInfo/Muon Species", str, ok); + if (ok) + runData.SetMuonSpecies(str); + + header->Get("RunInfo/Muon Source", str, ok); + if (ok) + runData.SetMuonSource(str); + + header->Get("RunInfo/Setup", str, ok); + if (ok) + runData.SetSetup(str); + + header->Get("RunInfo/Comment", str, ok); + if (ok) + runData.SetComment(str); + + header->Get("RunInfo/Sample Name", str, ok); + if (ok) + runData.SetSample(str); + + header->Get("RunInfo/Sample Temperature", prop, ok); + if (ok) + runData.SetTemperature(0, prop.GetValue(), prop.GetError()); + + header->Get("RunInfo/Sample Magnetic Field", prop, ok); + if (ok) { + dval = MRH_UNDEFINED; + if (!prop.GetUnit().CompareTo("G") || !prop.GetUnit().CompareTo("Gauss")) + dval = prop.GetValue(); + else if (!prop.GetUnit().CompareTo("T") || !prop.GetUnit().CompareTo("Tesla")) + dval = prop.GetValue() * 1.0e4; + runData.SetField(dval); + } + + header->Get("RunInfo/No of Histos", ival, ok); + if (ok) { + noOfHistos = ival; + } + + header->Get("RunInfo/Time Resolution", prop, ok); + if (ok) { + dval = -1.0; + if (!prop.GetUnit().CompareTo("ps") || !prop.GetUnit().CompareTo("picosec")) + dval = prop.GetValue()/1.0e3; + else if (!prop.GetUnit().CompareTo("ns") || !prop.GetUnit().CompareTo("nanosec")) + dval = prop.GetValue(); + else if (!prop.GetUnit().CompareTo("us") || !prop.GetUnit().CompareTo("microsec")) + dval = prop.GetValue()*1.0e3; + else + cerr << endl << "debug> Found unrecognized Time Resolution unit: " << prop.GetUnit(); + runData.SetTimeResolution(dval); + } + + header->Get("RunInfo/RedGreen Offset", ivec, ok); + if (ok) { + redGreenOffsets = ivec; + runData.SetRedGreenOffset(ivec); + } + + // check further for LEM specific stuff in RunInfo + + header->Get("RunInfo/Moderator HV", prop, ok); + if (ok) + runData.SetTransport(prop.GetValue()); + + header->Get("RunInfo/Implantation Energy", prop, ok); + if (ok) + runData.SetEnergy(prop.GetValue()); + + // read the SampleEnvironmentInfo + + header->Get("SampleEnvironmentInfo/Cryo", str, ok); + if (ok) + runData.SetCryoName(str); + + // read the MagneticFieldEnvironmentInfo + + header->Get("MagneticFieldEnvironmentInfo/Magnet Name", str, ok); + if (ok) + runData.SetMagnetName(str); + + // read the BeamlineInfo + + header->Get("BeamlineInfo/Name", str, ok); + if (ok) + runData.SetBeamline(str); + + // read run summary to obtain ring anode HV values + TObjArray *runSummary = dynamic_cast(folder->FindObjectAny("RunSummary")); + + // check if run summary is valid + if (!runSummary) { + cout << endl << "**INFO** Couldn't obtain run summary info from ROOT file " << fRunPathName.Data() << endl; + // this is not fatal... only RA-HV values are not available + } else { // it follows a (at least) little bit strange extraction of the RA values from Thomas' TObjArray... + //streaming of a ASCII-file would be more easy + TString s; + TObjArrayIter summIter(runSummary); + TObjString *os(dynamic_cast(summIter.Next())); + TObjArray *oa(0); + TObjString *objTok(0); + while (os != 0) { + s = os->GetString(); + // will put four parallel if's since it may be that more than one RA-values are on one line + if (s.Contains("RA-L")) { + oa = s.Tokenize(" "); + TObjArrayIter lineIter(oa); + objTok = dynamic_cast(lineIter.Next()); + while (objTok != 0) { + if (!objTok->GetString().CompareTo("RA-L")) { + objTok = dynamic_cast(lineIter.Next()); // "=" + if (objTok != 0 && !objTok->GetString().CompareTo("=")) { + objTok = dynamic_cast(lineIter.Next()); // HV value + runData.SetRingAnode(0, objTok->GetString().Atof()); // fill RA-R value into the runData structure + break; + } + } + objTok = dynamic_cast(lineIter.Next()); // next token... + } + // clean up + if (oa) { + delete oa; + oa = 0; + } + } + + if (s.Contains("RA-R")) { + oa = s.Tokenize(" "); + TObjArrayIter lineIter(oa); + objTok = dynamic_cast(lineIter.Next()); + while (objTok != 0){ + if (!objTok->GetString().CompareTo("RA-R")) { + objTok = dynamic_cast(lineIter.Next()); // "=" + if (objTok != 0 && !objTok->GetString().CompareTo("=")) { + objTok = dynamic_cast(lineIter.Next()); // HV value + runData.SetRingAnode(1, objTok->GetString().Atof()); // fill RA-R value into the runData structure + break; + } + } + objTok = dynamic_cast(lineIter.Next()); // next token... + } + // clean up + if (oa) { + delete oa; + oa = 0; + } + } + + if (s.Contains("RA-T")) { + oa = s.Tokenize(" "); + TObjArrayIter lineIter(oa); + objTok = dynamic_cast(lineIter.Next()); + while (objTok != 0){ + if (!objTok->GetString().CompareTo("RA-T")) { + objTok = dynamic_cast(lineIter.Next()); // "=" + if (objTok != 0 && !objTok->GetString().CompareTo("=")) { + objTok = dynamic_cast(lineIter.Next()); // HV value + runData.SetRingAnode(2, objTok->GetString().Atof()); // fill RA-T value into the runData structure + break; + } + } + objTok = dynamic_cast(lineIter.Next()); // next token... + } + // clean up + if (oa) { + delete oa; + oa = 0; + } + } + + if (s.Contains("RA-B")) { + oa = s.Tokenize(" "); + TObjArrayIter lineIter(oa); + objTok = dynamic_cast(lineIter.Next()); + while (objTok != 0){ + if (!objTok->GetString().CompareTo("RA-B")) { + objTok = dynamic_cast(lineIter.Next()); // "=" + if (objTok != 0 && !objTok->GetString().CompareTo("=")) { + objTok = dynamic_cast(lineIter.Next()); // HV value + runData.SetRingAnode(3, objTok->GetString().Atof()); // fill RA-B value into the runData structure + break; + } + } + objTok = dynamic_cast(lineIter.Next()); // next token... + } + // clean up + if (oa) { + delete oa; + oa = 0; + } + } + + os = dynamic_cast(summIter.Next()); // next summary line... + } + } + + // read data --------------------------------------------------------- + + // check if histos folder is found + f.GetObject("histos", folder); + if (!folder) { + cerr << endl << ">> PRunDataHandler::ReadRootFile: **ERROR** Couldn't obtain histos from " << fRunPathName.Data() << endl; + f.Close(); + return false; + } + + // get all the data + for (UInt_t i=0; i(folder->FindObjectAny(str.Data())); + if (!histo) { + cerr << endl << ">> PRunDataHandler::ReadRootFile: **ERROR** Couldn't get histo " << str; + cerr << endl; + f.Close(); + return false; + } + + dataSet.Clear(); + dataSet.SetName(histo->GetTitle()); + dataSet.SetHistoNo(redGreenOffsets[i]+j+1); + + // get detector info + path.Form("DetectorInfo/Detector%03d/", redGreenOffsets[i]+j+1); + pathName = path + "Time Zero Bin"; + header->Get(pathName, dval, ok); + if (ok) + dataSet.SetTimeZeroBin(dval); + pathName = path + "First Good Bin"; + header->Get(pathName, ival, ok); + if (ok) + dataSet.SetFirstGoodBin(ival); + pathName = path + "Last Good Bin"; + header->Get(pathName, ival, ok); + if (ok) + dataSet.SetLastGoodBin(ival); + dataSet.SetTimeZeroBinEstimated(histo->GetMaximumBin()); + + // fill data + for (Int_t j=1; j<=histo->GetNbinsX(); j++) { + histoData.push_back(histo->GetBinContent(j)); + } + dataSet.SetData(histoData); + runData.SetDataSet(dataSet); + + // clear histoData for the next histo + histoData.clear(); + } + } + + // clean up + if (header) { + delete header; + header=0; + } } f.Close(); @@ -1349,8 +1738,9 @@ Bool_t PRunDataHandler::ReadNexusFile() #ifdef PNEXUS_ENABLED cout << endl << ">> PRunDataHandler::ReadNexusFile(): Will read nexus file " << fRunPathName.Data() << " ..."; - PDoubleVector histoData; - PRawRunData runData; + PDoubleVector histoData; + PRawRunData runData; + PRawRunDataSet dataSet; TString str; string sstr; Double_t dval; @@ -1453,31 +1843,44 @@ Bool_t PRunDataHandler::ReadNexusFile() vector *t0 = nxs_file->GetEntryIdf1()->GetData()->GetT0s(); vector *fgb = nxs_file->GetEntryIdf1()->GetData()->GetFirstGoodBins(); vector *lgb = nxs_file->GetEntryIdf1()->GetData()->GetLastGoodBins(); - PIntPair goodDataBin; - for (UInt_t i=0; iGetEntryIdf1()->GetData()->GetNoOfHistos(); i++) { - if (isize()) { - runData.AppendT0(t0->at(i)); - } else { - runData.AppendT0(t0->at(0)); - } - if (isize()) { - goodDataBin.first = fgb->at(i); - goodDataBin.second = lgb->at(i); - } else { - goodDataBin.first = fgb->at(0); - goodDataBin.second = lgb->at(0); - } - runData.AppendGoodDataBin(goodDataBin); - } // get/set data vector *pdata; + unsigned int max=0, binMax=0; PDoubleVector data; for (UInt_t i=0; iGetEntryIdf1()->GetData()->GetNoOfHistos(); i++) { pdata = nxs_file->GetEntryIdf1()->GetData()->GetHisto(i); - for (UInt_t j=0; jsize(); j++) + for (UInt_t j=0; jsize(); j++) { data.push_back(pdata->at(j)); - runData.AppendDataBin(data); + if (pdata->at(j) > max) { + max = pdata->at(j); + binMax = j; + } + } + + // fill data set + dataSet.Clear(); + dataSet.SetHistoNo(i+1); // i.e. histo numbers start with 1 + // set time zero bin + if (isize()) + dataSet.SetTimeZeroBin(t0->at(i)); + else + dataSet.SetTimeZeroBin(t0->at(0)); + // set time zero bin estimate + dataSet.SetTimeZeroBinEstimated(binMax); + // set first good bin + if (isize()) + dataSet.SetFirstGoodBin(fgb->at(i)); + else + dataSet.SetFirstGoodBin(fgb->at(0)); + // set last good bin + if (isize()) + dataSet.SetFirstGoodBin(lgb->at(i)); + else + dataSet.SetFirstGoodBin(lgb->at(0)); + dataSet.SetData(data); + + runData.SetDataSet(dataSet); data.clear(); } @@ -1582,52 +1985,11 @@ Bool_t PRunDataHandler::ReadNexusFile() runData.SetStopDate(date); } - // get/set t0, firstGoodBin, lastGoodBin - int *t0 = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetT0s(); - int *fgb = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetFirstGoodBins(); - int *lgb = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetLastGoodBins(); - PIntPair goodDataBin; - - if (nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetT0Tag() == 3) { // t0, fgb, lgb: [][] - for (int i=0; iGetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfPeriods(); i++) { - for (int j=0; jGetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfSpectra(); j++) { - if (fgb && lgb) { - goodDataBin.first = *(fgb+i*nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfSpectra()+j); - goodDataBin.second = *(lgb+i*nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfSpectra()+j); - } - runData.AppendT0(*(t0+i*nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfSpectra()+j)); - if (fgb && lgb) { - runData.AppendGoodDataBin(goodDataBin); - } - } - } - } else if (nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetT0Tag() == 2) { // t0, fgb, lgb: [] - for (int i=0; iGetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfSpectra(); i++) { - if (fgb && lgb) { - goodDataBin.first = *(fgb+i); - goodDataBin.second = *(lgb+i); - } - runData.AppendT0(*(t0+i)); - if (fgb && lgb) { - runData.AppendGoodDataBin(goodDataBin); - } - } - } else { // t0, fgb, lgb: single numbers - if (fgb && lgb) { - goodDataBin.first = *fgb; - goodDataBin.second = *lgb; - } - for (int i=0; iGetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfPeriods(); i++) { - for (int j=0; jGetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfSpectra(); j++) { - runData.AppendT0(*t0); - if (fgb && lgb) - runData.AppendGoodDataBin(goodDataBin); - } - } - } - - // get/set data + // get/set data, t0, fgb, lgb PDoubleVector data; + PRawRunDataSet dataSet; + UInt_t histoNo = 0; + Int_t ival; int *histos = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetHistos(); if (nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfPeriods() > 0) { // counts[][][] for (int i=0; iGetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfPeriods(); i++) { @@ -1635,7 +1997,26 @@ Bool_t PRunDataHandler::ReadNexusFile() for (int k=0; kGetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfBins(); k++) { data.push_back(*(histos+i*nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfSpectra()+j*nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfBins()+k)); } - runData.AppendDataBin(data); + dataSet.Clear(); + dataSet.SetHistoNo(++histoNo); // i.e. histo numbers start with 1 + // get t0 + ival = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetT0(i,j); + if (ival == -1) // i.e. single value only + ival = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetT0(); + dataSet.SetTimeZeroBin(ival); + // get first good bin + ival = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetFirstGoodBin(i,j); + if (ival == -1) // i.e. single value only + ival = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetFirstGoodBin(); + dataSet.SetFirstGoodBin(ival); + // get last good bin + ival = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetLastGoodBin(i,j); + if (ival == -1) // i.e. single value only + ival = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetLastGoodBin(); + dataSet.SetLastGoodBin(ival); + + dataSet.SetData(data); + runData.SetDataSet(dataSet); data.clear(); } } @@ -1645,14 +2026,46 @@ Bool_t PRunDataHandler::ReadNexusFile() for (int j=0; jGetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfBins(); j++) { data.push_back(*(histos+i*nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfBins()+j)); } - runData.AppendDataBin(data); + dataSet.Clear(); + dataSet.SetHistoNo(++histoNo); // i.e. histo numbers start with 1 + // get t0 + ival = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetT0(-1,i); + if (ival == -1) // i.e. single value only + ival = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetT0(); + dataSet.SetTimeZeroBin(ival); + // get first good bin + ival = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetFirstGoodBin(-1,i); + if (ival == -1) // i.e. single value only + ival = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetFirstGoodBin(); + dataSet.SetFirstGoodBin(ival); + // get last good bin + ival = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetLastGoodBin(-1,i); + if (ival == -1) // i.e. single value only + ival = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetLastGoodBin(); + dataSet.SetLastGoodBin(ival); + + dataSet.SetData(data); + runData.SetDataSet(dataSet); data.clear(); } } else { // counts[] for (int i=0; iGetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfBins(); i++) { data.push_back(*(histos+i)); } - runData.AppendDataBin(data); + dataSet.Clear(); + dataSet.SetHistoNo(++histoNo); // i.e. histo numbers start with 1 + // get t0 + ival = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetT0(); + dataSet.SetTimeZeroBin(ival); + // get first good bin + ival = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetFirstGoodBin(); + dataSet.SetFirstGoodBin(ival); + // get last good bin + ival = nxs_file->GetEntryIdf2()->GetInstrument()->GetDetector()->GetLastGoodBin(); + dataSet.SetLastGoodBin(ival); + + dataSet.SetData(data); + runData.SetDataSet(dataSet); data.clear(); } } @@ -1843,10 +2256,15 @@ Bool_t PRunDataHandler::ReadWkmFile() TObjArray *tokens; TObjString *ostr; TString str; + UInt_t histoNo = 0; + PRawRunDataSet dataSet; do { // check if empty line, i.e. new group if (IsWhitespace(instr)) { - runData.AppendDataBin(histoData); + dataSet.Clear(); + dataSet.SetHistoNo(++histoNo); + dataSet.SetData(histoData); + // get a T0 estimate Double_t maxVal = 0.0; Int_t maxBin = 0; @@ -1856,7 +2274,10 @@ Bool_t PRunDataHandler::ReadWkmFile() maxBin = i; } } - runData.AppendT0Estimated(maxBin); + dataSet.SetTimeZeroBinEstimated(maxBin); + + runData.SetDataSet(dataSet); + histoData.clear(); group_counter++; } else { @@ -1928,7 +2349,22 @@ Bool_t PRunDataHandler::ReadWkmFile() // save the last histo if not empty if (histoData.size() > 0) { - runData.AppendDataBin(histoData); + dataSet.Clear(); + dataSet.SetHistoNo(++histoNo); + dataSet.SetData(histoData); + + // get a T0 estimate + Double_t maxVal = 0.0; + Int_t maxBin = 0; + for (UInt_t i=0; i maxVal) { + maxVal = histoData[i]; + maxBin = i; + } + } + dataSet.SetTimeZeroBinEstimated(maxBin); + + runData.SetDataSet(dataSet); histoData.clear(); } @@ -2013,10 +2449,15 @@ Bool_t PRunDataHandler::ReadPsiBinFile() return success; // fill necessary header informations - PIntVector ivec; PRawRunData runData; Double_t dval; + // set file name + Ssiz_t pos = fRunPathName.Last('/'); + TString fln(fRunPathName); + fln.Remove(0, pos+1); + runData.SetFileName(fln); + // set laboratory runData.SetLaboratory("PSI"); @@ -2071,6 +2512,8 @@ Bool_t PRunDataHandler::ReadPsiBinFile() runData.SetSample(TString(psiBin.get_sample().c_str())); // get orientation runData.SetOrientation(TString(psiBin.get_orient().c_str())); + // get comment + runData.SetComment(TString(psiBin.get_comment().c_str())); // set LEM specific information to default value since it is not in the file and not used... runData.SetEnergy(PMUSR_UNDEFINED); runData.SetTransport(PMUSR_UNDEFINED); @@ -2102,15 +2545,6 @@ Bool_t PRunDataHandler::ReadPsiBinFile() // get time resolution (ns) runData.SetTimeResolution(psiBin.get_binWidth_ns()); - // get t0's - ivec = psiBin.get_t0_vector(); - if (ivec.empty()) { - cerr << endl << ">> **ERROR** psi-bin file: couldn't obtain any t0's"; - cerr << endl; - return false; - } - for (UInt_t i=0; i sDateTime = psiBin.get_timeStart_vector(); @@ -2141,7 +2575,33 @@ Bool_t PRunDataHandler::ReadPsiBinFile() runData.SetStopTime(sDateTime[1]); sDateTime.clear(); + // get t0's + PIntVector t0 = psiBin.get_t0_vector(); + + if (t0.empty()) { + cerr << endl << ">> **ERROR** psi-bin file: couldn't obtain any t0's"; + cerr << endl; + return false; + } + + // get first good bin + PIntVector fgb = psiBin.get_firstGood_vector(); + if (fgb.empty()) { + cerr << endl << ">> **ERROR** psi-bin file: couldn't obtain any fgb's"; + cerr << endl; + return false; + } + + // get last good bin + PIntVector lgb = psiBin.get_lastGood_vector(); + if (lgb.empty()) { + cerr << endl << ">> **ERROR** psi-bin file: couldn't obtain any lgb's"; + cerr << endl; + return false; + } + // fill raw data + PRawRunDataSet dataSet; PDoubleVector histoData; Int_t *histo; for (Int_t i=0; i ns // read histograms - pair valPair; UINT32 *pData; // histo memory pData = NULL; PDoubleVector histoData; + PRawRunDataSet dataSet; UInt_t noOfBins; for (Int_t i=1; i<=noOfHistos; i++) { + dataSet.Clear(); + + dataSet.SetHistoNo(i); // get t0's success = MUD_getHistT0_Bin( fh, i, &val ); @@ -2388,51 +2865,41 @@ Bool_t PRunDataHandler::ReadMudFile() cerr << endl << ">> **WARNING** Couldn't get t0 of histo " << i << " of run " << fRunName.Data(); cerr << endl; } - runData.AppendT0((Int_t)val); + dataSet.SetTimeZeroBin((Double_t)val); // get bkg bins success = MUD_getHistBkgd1( fh, i, &val ); if ( !success ) { cerr << endl << ">> **WARNING** Couldn't get bkg bin 1 of histo " << i << " of run " << fRunName.Data(); cerr << endl; - valPair.first = -1; - } else { - valPair.first = (Int_t)val; + val = 0; } + dataSet.SetFirstBkgBin((Int_t)val); success = MUD_getHistBkgd2( fh, i, &val ); if ( !success ) { cerr << endl << ">> **WARNING** Couldn't get bkg bin 2 of histo " << i << " of run " << fRunName.Data(); cerr << endl; - valPair.second = -1; - } - valPair.second = (Int_t)val; - - if ((valPair.first != -1) && (valPair.second != -1)) { // bkg bin1 && bkg bin2 found - runData.AppendBkgBin(valPair); + val = 0; } + dataSet.SetLastBkgBin((Int_t)val); // get good data bins success = MUD_getHistGoodBin1( fh, i, &val ); if ( !success ) { cerr << endl << ">> **WARNING** Couldn't get good bin 1 of histo " << i << " of run " << fRunName.Data(); cerr << endl; - valPair.first = -1; - } else { - valPair.first = (Int_t)val; + val = 0; } + dataSet.SetFirstGoodBin((Int_t)val); success = MUD_getHistGoodBin2( fh, i, &val ); if ( !success ) { cerr << endl << ">> **WARNING** Couldn't get good bin 2 of histo " << i << " of run " << fRunName.Data(); cerr << endl; - valPair.second = -1; - } - valPair.second = (Int_t)val; - - if ((valPair.first != -1) && (valPair.second != -1)) { // good bin1 && good bin2 found - runData.AppendGoodDataBin(valPair); + val = 0; } + dataSet.SetLastGoodBin((Int_t)val); // get number of bins success = MUD_getHistNumBins( fh, i, &val ); @@ -2467,7 +2934,7 @@ Bool_t PRunDataHandler::ReadMudFile() for (UInt_t j=0; j Write the MusrRoot file format. Only the required entries will be handled. + * + * return: + * - true on successful writting, + * - otherwise false. + * + * \param fln file name. If empty, the routine will try to construct one + */ +Bool_t PRunDataHandler::WriteMusrRootFile(TString fln) +{ + // generate output file name if needed + if (!fAny2ManyInfo->useStandardOutput || (fAny2ManyInfo->compressionTag > 0)) { + if (fln.Length() == 0) { + Bool_t ok = false; + fln = GetFileName(".root", ok); + if (!ok) + return false; + } else { + fln.Prepend(fAny2ManyInfo->outPath); + } + // keep the file name if compression is whished + fAny2ManyInfo->outPathFileName.push_back(fln); + } else { + fln = fAny2ManyInfo->outPath + TString("__tmp.root"); + } + + if (!fAny2ManyInfo->useStandardOutput) + cout << endl << ">> PRunDataHandler::WriteMusrRootFile(): writing a root data file (" << fln.Data() << ") ... " << endl; + + // generate data file + TFolder *histosFolder; + TFolder *decayAnaModule; + TFolder *runHeader; + + histosFolder = gROOT->GetRootFolder()->AddFolder("histos", "Histograms"); + gROOT->GetListOfBrowsables()->Add(histosFolder, "histos"); + decayAnaModule = histosFolder->AddFolder("DecayAnaModule", "muSR decay histograms"); + + runHeader = gROOT->GetRootFolder()->AddFolder("RunHeader", "MusrRoot Run Header Info"); + gROOT->GetListOfBrowsables()->Add(runHeader, "RunHeader"); + TMusrRunHeader *header = new TMusrRunHeader(true); + gROOT->GetListOfBrowsables()->Add(runHeader, "RunHeader"); + + // feed header info + TString str, pathName; + Int_t ival; + Double_t dval[2]; + TMusrRunPhysicalQuantity prop; + + // feed RunInfo + str = fData[0].GetGenericValidatorUrl()->Copy(); + header->Set("RunInfo/Generic Validator URL", str); + str = fData[0].GetSpecificValidatorUrl()->Copy(); + header->Set("RunInfo/Specific Validator URL", str); + str = fData[0].GetGenerator()->Copy(); + header->Set("RunInfo/Generator", str); + str = fData[0].GetFileName()->Copy(); + header->Set("RunInfo/File Name", str); + str = fData[0].GetRunTitle()->Copy(); + header->Set("RunInfo/Run Title", str); + header->Set("RunInfo/Run Number", fData[0].GetRunNumber()); + str = fData[0].GetStartDate()->Copy() + " " + fData[0].GetStartTime()->Copy(); + header->Set("RunInfo/Run Start Time", str); + str = fData[0].GetStopDate()->Copy() + " " + fData[0].GetStopTime()->Copy(); + header->Set("RunInfo/Run Stop Time", str); + ival = fData[0].GetStopDateTime() - fData[0].GetStartDateTime(); + prop.Set("Run Duration", ival, "sec"); + header->Set("RunInfo/Run Duration", prop); + str = fData[0].GetLaboratory()->Copy(); + header->Set("RunInfo/Laboratory", str); + str = fData[0].GetArea()->Copy(); + header->Set("RunInfo/Area", str); + str = fData[0].GetInstrument()->Copy(); + header->Set("RunInfo/Instrument", str); + dval[0] = fData[0].GetMuonBeamMomentum(); + prop.Set("Muon Beam Momentum", dval[0], "MeV/c"); + header->Set("RunInfo/Muon Beam Momentum", prop); + str = fData[0].GetMuonSpecies()->Copy(); + header->Set("RunInfo/Muon Species", str); + str = fData[0].GetMuonSource()->Copy(); + header->Set("RunInfo/Muon Source", str); + str = fData[0].GetSetup()->Copy(); + header->Set("RunInfo/Setup", str); + str = fData[0].GetComment()->Copy(); + header->Set("RunInfo/Comment", str); + str = fData[0].GetSample()->Copy(); + header->Set("RunInfo/Sample Name", str); + dval[0] = fData[0].GetTemperature(0); + dval[1] = fData[0].GetTempError(0); + prop.Set("Sample Temperature", MRH_UNDEFINED, dval[0], dval[1], "K"); + header->Set("RunInfo/Sample Temperature", prop); + dval[0] = fData[0].GetField(); + prop.Set("Sample Magnetic Field", dval[0], "G"); + header->Set("RunInfo/Sample Magnetic Field", prop); + header->Set("RunInfo/No of Histos", (Int_t)fData[0].GetNoOfHistos()); + dval[0] = fData[0].GetTimeResolution(); + prop.Set("Time Resolution", dval[0], "ns"); + header->Set("RunInfo/Time Resolution", prop); + header->Set("RunInfo/RedGreen Offset", fData[0].GetRedGreenOffset()); + + // feed DetectorInfo + Int_t histoNo = 0; + PRawRunDataSet *dataSet; + UInt_t size = fData[0].GetNoOfHistos(); + for (UInt_t i=0; i> PRunDataHandler::WriteMusrRootFile: **ERROR** Couldn't get data set (idx=" << i << ")"; + cerr << endl << ">> something is really wrong!" << endl; + return false; + } + histoNo = dataSet->GetHistoNo(); + pathName.Form("DetectorInfo/Detector%03d/Name", histoNo); + str = dataSet->GetName(); + if (!str.CompareTo("n/a")) + str.Form("Detector%3d", histoNo); + header->Set(pathName, str); + pathName.Form("DetectorInfo/Detector%03d/Histo Number", histoNo); + header->Set(pathName, histoNo); + pathName.Form("DetectorInfo/Detector%03d/Histo Length", histoNo); + header->Set(pathName, (Int_t)(dataSet->GetData()->size()/fAny2ManyInfo->rebin)); + pathName.Form("DetectorInfo/Detector%03d/Time Zero Bin", histoNo); + header->Set(pathName, dataSet->GetTimeZeroBin()/fAny2ManyInfo->rebin); + pathName.Form("DetectorInfo/Detector%03d/First Good Bin", histoNo); + ival = dataSet->GetFirstGoodBin(); + header->Set(pathName, (Int_t)(ival/fAny2ManyInfo->rebin)); + pathName.Form("DetectorInfo/Detector%03d/Last Good Bin", histoNo); + ival = dataSet->GetLastGoodBin(); + header->Set(pathName, (Int_t)(ival/fAny2ManyInfo->rebin)); + } + + // feed SampleEnvironmentInfo + str = fData[0].GetCryoName()->Copy(); + header->Set("SampleEnvironmentInfo/Cryo", str); + + // feed MagneticFieldEnvironmentInfo + str = fData[0].GetMagnetName()->Copy(); + header->Set("MagneticFieldEnvironmentInfo/Magnet Name", str); + + // feed BeamlineInfo + str = fData[0].GetBeamline()->Copy(); + header->Set("BeamlineInfo/Name", str); + + // feed histos + vector histos; + TH1F *histo = 0; + UInt_t length = 0; + if (fAny2ManyInfo->rebin == 1) { + for (UInt_t i=0; i> PRunDataHandler::WriteMusrRootFile: **ERROR** Couldn't get data set (idx=" << i << ")"; + cerr << endl << ">> something is really wrong!" << endl; + return false; + } + str.Form("hDecay%03d", dataSet->GetHistoNo()); + length = dataSet->GetData()->size(); + histo = new TH1F(str.Data(), str.Data(), length+1, -0.5, (Double_t)length+0.5); + for (UInt_t j=0; jSetBinContent(j+1, dataSet->GetData()->at(j)); + } + histos.push_back(histo); + } + } else { // rebin > 1 + UInt_t dataRebin = 0; + UInt_t dataCount = 0; + for (UInt_t i=0; i> PRunDataHandler::WriteMusrRootFile: **ERROR** Couldn't get data set (idx=" << i << ")"; + cerr << endl << ">> something is really wrong!" << endl; + return false; + } + str.Form("hDecay%03d", dataSet->GetHistoNo()); + length = dataSet->GetData()->size(); + histo = new TH1F(str.Data(), str.Data(), (Int_t)(length/fAny2ManyInfo->rebin)+1, -0.5, (Double_t)((Int_t)(length/fAny2ManyInfo->rebin))+0.5); + dataCount = 0; + for (UInt_t j=0; j 0) && (j % fAny2ManyInfo->rebin == 0)) { + dataCount++; + histo->SetBinContent(dataCount, dataRebin); + dataRebin = 0; + } + dataRebin += static_cast(dataSet->GetData()->at(j)); + } + histos.push_back(histo); + } + } + + // add histos to the DecayAnaModule folder + for (UInt_t i=0; iAdd(histos[i]); + + // write file + TFile *fout = new TFile(fln, "RECREATE", fln); + if (fout == 0) { + cerr << endl << "PRunDataHandler::WriteMusrRootFile(): **ERROR** Couldn't create ROOT file '" << fln << "'" << endl; + return false; + } + + fout->cd(); + if (header->FillFolder(runHeader)) + runHeader->Write(); + histosFolder->Write(); + fout->Close(); + + // check if root file shall be streamed to stdout + if (fAny2ManyInfo->useStandardOutput && (fAny2ManyInfo->compressionTag == 0)) { + // stream file to stdout + ifstream is; + int length=1024; + char *buffer; + + is.open(fln.Data(), ios::binary); + if (!is.is_open()) { + cerr << endl << "PRunDataHandler::WriteMusrRootFile(): **ERROR** Couldn't open the root-file for streaming." << endl; + remove(fln.Data()); + return false; + } + + // get length of file + is.seekg(0, ios::end); + length = is.tellg(); + is.seekg(0, ios::beg); + + if (length == -1) { + cerr << endl << "PRunDataHandler::WriteMusrRootFile(): **ERROR** Couldn't determine the root-file size." << endl; + remove(fln.Data()); + return false; + } + + // allocate memory + buffer = new char [length]; + + // read data as a block + while (!is.eof()) { + is.read(buffer, length); + cout.write(buffer, length); + } + + is.close(); + + delete [] buffer; + + // delete temporary root file + remove(fln.Data()); + } + + return true; +} + //-------------------------------------------------------------------------- // WriteRootFile //-------------------------------------------------------------------------- @@ -3542,36 +4269,38 @@ Bool_t PRunDataHandler::WriteRootFile(TString fln) header->SetSampleTemperature(fData[0].GetTemperature(0), fData[0].GetTempError(0)); header->SetSampleBField(fData[0].GetField(), 0.0); header->SetTimeResolution(fData[0].GetTimeResolution()); - header->SetNChannels(static_cast(fData[0].GetDataBin(0)->size()/fAny2ManyInfo->rebin)); + PRawRunDataSet *dataSet = fData[0].GetDataSet(0, false); // i.e. the false means, that i is the index and NOT the histo number + header->SetNChannels(static_cast(dataSet->GetData()->size()/fAny2ManyInfo->rebin)); header->SetNHist(fData[0].GetNoOfHistos()); header->SetCuts("none"); header->SetModerator("none"); // feed t0's Double_t *tt0 = new Double_t[fData[0].GetNoOfHistos()]; - for (UInt_t i=0; i 0) { - for (UInt_t i=0; irebin; - } + for (UInt_t i=0; iGetTimeZeroBin()/fAny2ManyInfo->rebin; } header->SetTimeZero(tt0); - runInfo->Add(header); //add header to RunInfo folder + runInfo->Add(header); // add header to RunInfo folder // feed histos vector histos; TH1F *histo = 0; Char_t str[32]; - + UInt_t size = 0; if (fAny2ManyInfo->rebin == 1) { for (UInt_t i=0; i(fData[0].GetDataBin(0)->size())+1, -0.5, static_cast(fData[0].GetDataBin(0)->size()+0.5)); - for (UInt_t j=0; jsize(); j++) { - histo->SetBinContent(j+1, fData[0].GetDataBin(i)->at(j)); + dataSet = fData[0].GetDataSet(i, false); // i.e. the false means, that i is the index and NOT the histo number + if (dataSet == 0) { // something is really wrong + cerr << endl << ">> PRunDataHandler::WriteNexusFile: **ERROR** Couldn't get data set (idx=0" << i << ")"; + cerr << endl << ">> something is really wrong!" << endl; + return false; + } + size = dataSet->GetData()->size(); + sprintf(str, "hDecay%02d", (Int_t)i); + histo = new TH1F(str, str, size+1, -0.5, static_cast(size)+0.5); + for (UInt_t j=0; jSetBinContent(j+1, dataSet->GetData()->at(j)); } histos.push_back(histo); } @@ -3579,20 +4308,24 @@ Bool_t PRunDataHandler::WriteRootFile(TString fln) UInt_t dataRebin = 0; UInt_t dataCount = 0; for (UInt_t i=0; i(fData[0].GetDataBin(0)->size()/fAny2ManyInfo->rebin)+1, -0.5, static_cast(fData[0].GetDataBin(0)->size()/fAny2ManyInfo->rebin+0.5)); + dataSet = fData[0].GetDataSet(i, false); // i.e. the false means, that i is the index and NOT the histo number + if (dataSet == 0) { // something is really wrong + cerr << endl << ">> PRunDataHandler::WriteNexusFile: **ERROR** Couldn't get data set (idx=0" << i << ")"; + cerr << endl << ">> something is really wrong!" << endl; + return false; + } + size = dataSet->GetData()->size(); + sprintf(str, "hDecay%02d", (Int_t)i); + histo = new TH1F(str, str, (UInt_t)(size/fAny2ManyInfo->rebin)+1, -0.5, (Double_t)size/(Double_t)fAny2ManyInfo->rebin+0.5); dataCount = 0; - for (UInt_t j=0; jsize(); j++) { + for (UInt_t j=0; j 0) && (j % fAny2ManyInfo->rebin == 0)) { dataCount++; histo->SetBinContent(dataCount, dataRebin); dataRebin = 0; } - dataRebin += static_cast(fData[0].GetDataBin(i)->at(j)); - } + dataRebin += static_cast(dataSet->GetData()->at(j)); + } histos.push_back(histo); } } @@ -3681,7 +4414,6 @@ Bool_t PRunDataHandler::WriteRootFile(TString fln) */ Bool_t PRunDataHandler::WriteNexusFile(TString fln) { - #ifdef PNEXUS_ENABLED // generate output file name if (fln.Length() == 0) { @@ -3752,38 +4484,71 @@ Bool_t PRunDataHandler::WriteNexusFile(TString fln) nxs->GetEntryIdf1()->GetInstrument()->GetCollimator()->SetType("n/a"); // calculate the total number of counts double total_counts = 0; + PRawRunDataSet *dataSet = 0; for (unsigned int i=0; isize(); j++) - total_counts += fData[0].GetDataBin(i)->at(j); + dataSet = fData[0].GetDataSet(i, false); // i.e. the false means, that i is the index and NOT the histo number + if (dataSet == 0) { // something is really wrong + cerr << endl << ">> PRunDataHandler::WriteNexusFile: **ERROR** Couldn't get data set (idx=0" << i << ")"; + cerr << endl << ">> something is really wrong!" << endl; + return false; + } + for (unsigned int j=0; jGetData()->size(); j++) + total_counts += dataSet->GetData()->at(j); } double total_counts_mev = (double) total_counts / 1.0e6; nxs->GetEntryIdf1()->GetInstrument()->GetBeam()->SetTotalCounts(total_counts_mev); nxs->GetEntryIdf1()->GetInstrument()->GetBeam()->SetUnits("Mev"); - nxs->GetEntryIdf1()->GetData()->SetTimeResolution(fData[0].GetTimeResolution(), "ns"); + nxs->GetEntryIdf1()->GetData()->SetTimeResolution(fData[0].GetTimeResolution()*fAny2ManyInfo->rebin, "ns"); - // t0 - if (fData[0].GetT0(0) == -1) // t0 not povided in the raw data file header - nxs->GetEntryIdf1()->GetData()->SetT0(fData[0].GetT0Estimated(0)); // take the estimated t0 value - else - nxs->GetEntryIdf1()->GetData()->SetT0(fData[0].GetT0(0)); // this needs to be changed in the long term, since for continous sources each detector has its one t0!! - - int time_bin_offset = (int)(10.0 / fData[0].GetTimeResolution()); // 10ns time offset for fgb if not given - if (fData[0].GetGoodDataBin(0).first == -1) { - nxs->GetEntryIdf1()->GetData()->SetFirstGoodBin(nxs->GetEntryIdf1()->GetData()->GetT0(0)+time_bin_offset); - nxs->GetEntryIdf1()->GetData()->SetLastGoodBin(fData[0].GetDataBin(0)->size()-1); - } else { - nxs->GetEntryIdf1()->GetData()->SetFirstGoodBin(fData[0].GetGoodDataBin(0).first); - nxs->GetEntryIdf1()->GetData()->SetLastGoodBin(fData[0].GetGoodDataBin(0).second); + for (unsigned int i=0; iGetEntryIdf1()->GetData()->SetT0((Int_t)(dataSet->GetTimeZeroBin()/fAny2ManyInfo->rebin), i); + nxs->GetEntryIdf1()->GetData()->SetFirstGoodBin((Int_t)(dataSet->GetFirstGoodBin()/fAny2ManyInfo->rebin), i); + nxs->GetEntryIdf1()->GetData()->SetLastGoodBin((Int_t)(dataSet->GetLastGoodBin()/fAny2ManyInfo->rebin), i); } - // feed real histogram data + + // feed histos PUIntVector data; - for (UInt_t i=0; isize(); j++) { - data.push_back((UInt_t)fData[0].GetDataBin(i)->at(j)); + UInt_t size = 0; + if (fAny2ManyInfo->rebin == 1) { + for (UInt_t i=0; i> PRunDataHandler::WriteNexusFile: **ERROR** Couldn't get data set (idx=" << i << ")"; + cerr << endl << ">> something is really wrong!" << endl; + return false; + } + size = dataSet->GetData()->size(); + for (UInt_t j=0; jGetData()->at(j)); + } + nxs->GetEntryIdf1()->GetData()->SetHisto(data, i); + data.clear(); + } + } else { // rebin > 1 + UInt_t dataRebin = 0; + UInt_t dataCount = 0; + for (UInt_t i=0; i> PRunDataHandler::WriteNexusFile: **ERROR** Couldn't get data set (idx=" << i << ")"; + cerr << endl << ">> something is really wrong!" << endl; + return false; + } + size = dataSet->GetData()->size(); + dataCount = 0; + for (UInt_t j=0; j 0) && (j % fAny2ManyInfo->rebin == 0)) { + dataCount++; + data.push_back(dataRebin); + dataRebin = 0; + } + dataRebin += static_cast(dataSet->GetData()->at(j)); + } + nxs->GetEntryIdf1()->GetData()->SetHisto(data, i); + data.clear(); } - nxs->GetEntryIdf1()->GetData()->SetHisto(data, i); - data.clear(); } } else if (fAny2ManyInfo->idf == 2) { // fill necessary data structures @@ -3842,19 +4607,61 @@ Bool_t PRunDataHandler::WriteNexusFile(TString fln) nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetDescription(fData[0].GetInstrument()->Data()); // assume that this should be the instrument name nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetNoOfPeriods(0); // currently red/green is not distinguished nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetNoOfSpectra(fData[0].GetNoOfHistos()); - nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetNoOfBins(fData[0].GetDataBin(0)->size()); - nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetTimeResolution(fData[0].GetTimeResolution(), "ns"); - int *histo = new int[fData[0].GetNoOfHistos()*fData[0].GetDataBin(0)->size()]; - for (int i=0; iGetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfSpectra(); i++) { - for (unsigned int j=0; jsize(); j++) { - *(histo+i*fData[0].GetDataBin(0)->size()+j) = (int) fData[0].GetDataBin(i)->at(j); - } + PRawRunDataSet *dataSet = fData[0].GetDataSet(0, false); // i.e. the false means, that i is the index and NOT the histo number + if (dataSet == 0) { // something is really wrong + cerr << endl << ">> PRunDataHandler::WriteNeXusFile: **ERROR** Couldn't get data set (idx=0)"; + cerr << endl << ">> something is really wrong!" << endl; + return false; } - nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetHistos(histo); - // clean up - if (histo) { - delete [] histo; - histo = 0; + nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetNoOfBins((unsigned int)(dataSet->GetData()->size() / fAny2ManyInfo->rebin)); + nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetTimeResolution(fData[0].GetTimeResolution()*fAny2ManyInfo->rebin, "ns"); + int *histo = 0; + int idx = 0; + if (fAny2ManyInfo->rebin == 1) { + histo = new int[fData[0].GetNoOfHistos()*dataSet->GetData()->size()]; + idx = 0; + for (int i=0; iGetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfSpectra(); i++) { + dataSet = fData[0].GetDataSet(i, false); // i.e. the false means, that i is the index and NOT the histo number + if (dataSet == 0) { // something is really wrong + cerr << endl << ">> PRunDataHandler::WriteNeXusFile: **ERROR** Couldn't get data set (idx=" << i << ")"; + cerr << endl << ">> something is really wrong!" << endl; + return false; + } + for (unsigned int j=0; jGetData()->size(); j++) { + *(histo+idx++) = (int) dataSet->GetData()->at(j); + } + } + nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetHistos(histo); + // clean up + if (histo) { + delete [] histo; + histo = 0; + } + } else { // rebin > 1 + histo = new int[fData[0].GetNoOfHistos()*(int)(dataSet->GetData()->size()/fAny2ManyInfo->rebin)]; + int counts = 0; + idx = 0; + for (int i=0; iGetEntryIdf2()->GetInstrument()->GetDetector()->GetNoOfSpectra(); i++) { + dataSet = fData[0].GetDataSet(i, false); // i.e. the false means, that i is the index and NOT the histo number + if (dataSet == 0) { // something is really wrong + cerr << endl << ">> PRunDataHandler::WriteNeXusFile: **ERROR** Couldn't get data set (idx=" << i << ")"; + cerr << endl << ">> something is really wrong!" << endl; + return false; + } + for (unsigned int j=0; jGetData()->size(); j++) { + if ((j>0) && (j % fAny2ManyInfo->rebin == 0)) { + *(histo+idx++) = counts; + counts = 0; + } + counts += (int) dataSet->GetData()->at(j); + } + } + nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetHistos(histo); + // clean up + if (histo) { + delete [] histo; + histo = 0; + } } // handle spectrum index @@ -3862,12 +4669,13 @@ Bool_t PRunDataHandler::WriteNexusFile(TString fln) nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetSpectrumIndex(i+1); // handle histogram resolution - nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetTimeResolution(fData[0].GetTimeResolution(), "ns"); + nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetTimeResolution(fData[0].GetTimeResolution()*fAny2ManyInfo->rebin, "ns"); // handle raw time vector raw_time; - for (unsigned int i=0; isize(); i++) { - raw_time.push_back((double)i * fData[0].GetTimeResolution() * 1.0e-3); // since time resolution is given in ns, the factor 1.0e-3 is needed to convert to us + UInt_t size = (unsigned int)(dataSet->GetData()->size() / fAny2ManyInfo->rebin); + for (unsigned int i=0; irebin * 1.0e-3); // since time resolution is given in ns, the factor 1.0e-3 is needed to convert to us } nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetRawTime(raw_time); nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetRawTimeUnit("micro.second"); @@ -3877,68 +4685,31 @@ Bool_t PRunDataHandler::WriteNexusFile(TString fln) // handle t0 nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetT0Tag(2); // i.e. t0[#histo] format int *t0 = new int[fData[0].GetNoOfHistos()]; + int *fgb = new int[fData[0].GetNoOfHistos()]; + int *lgb = new int[fData[0].GetNoOfHistos()]; + if ((t0==0) || (fgb==0) || (lgb==0)) { + cerr << endl << ">> PRunDataHandler::WriteNeXusFile: **ERROR** Couldn't allocate memory for t0, fgb, lgb" << endl; + return false; + } for (unsigned int i=0; i> **WARNING** NO t0's are present in the original file, will use the estimated once, no waranty this is correct!!" << endl; - } - if (i> PRunDataHandler::WriteNeXusFile: **ERROR** Couldn't get data set (idx=0)"; + cerr << endl << ">> something is really wrong!" << endl; + return false; } + t0[i] = (int)(dataSet->GetTimeZeroBin() / fAny2ManyInfo->rebin); + fgb[i] = (int)(dataSet->GetFirstGoodBin() / fAny2ManyInfo->rebin); + lgb[i] = (int)(dataSet->GetLastGoodBin() / fAny2ManyInfo->rebin); } nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetT0(t0); - - // handle first_good_bin - int *fgb = new int[fData[0].GetNoOfHistos()]; - for (unsigned int i=0; iGetEntryIdf2()->GetInstrument()->GetDetector()->SetFirstGoodBin(fgb); - // clean up - if (fgb) { - delete [] fgb; - fgb = 0; - } - - // handle last_good_bin - int *lgb = new int[fData[0].GetNoOfHistos()]; - for (unsigned int i=0; isize() - 1; - } else { // first good bin present - if (i < fData[0].GetGoodDataBinSize()) - lgb[i] = fData[0].GetGoodDataBin(i).second; - else - lgb[i] = fData[0].GetGoodDataBin(0).second; - } - } nxs->GetEntryIdf2()->GetInstrument()->GetDetector()->SetLastGoodBin(lgb); - // clean up - if (lgb) { - delete [] lgb; - lgb = 0; - } // clean up - if (t0) { - delete [] t0; - t0 = 0; - } - + if (t0) delete [] t0; + if (fgb) delete [] fgb; + if (lgb) delete [] lgb; } else { // clean up if (nxs != 0) { @@ -4068,7 +4839,7 @@ Bool_t PRunDataHandler::WriteWkmFile(TString fln) if (lem_wkm_style) cout << endl << "TOF(M3S1): nocut"; cout << endl << "Groups: " << fData[0].GetNoOfHistos(); - cout << endl << "Channels: " << static_cast(fData[0].GetDataBin(0)->size()/fAny2ManyInfo->rebin); + cout << endl << "Channels: " << static_cast(fData[0].GetDataBin(1)->size()/fAny2ManyInfo->rebin); cout.precision(10); cout << endl << "Resolution: " << fData[0].GetTimeResolution()*fAny2ManyInfo->rebin/1.0e3; // ns->us cout.setf(ios::fixed,ios::floatfield); // floatfield set to fixed @@ -4137,8 +4908,6 @@ Bool_t PRunDataHandler::WriteWkmFile(TString fln) */ Bool_t PRunDataHandler::WritePsiBinFile(TString fln) { - cout << endl << ">> PRunDataHandler::WritePsiBinFile(): will write a psi-bin data file. Not yet implemented ... " << endl; - // generate output file name if needed if (!fAny2ManyInfo->useStandardOutput || (fAny2ManyInfo->compressionTag > 0)) { if (fln.Length() == 0) { @@ -4165,7 +4934,7 @@ Bool_t PRunDataHandler::WritePsiBinFile(TString fln) // run number psibin.put_runNumber_int(fData[0].GetRunNumber()); // length of histograms - psibin.put_histoLength_bin((int)(fData[0].GetDataBin(0)->size())); + psibin.put_histoLength_bin((int)(fData[0].GetDataBin(1)->size()/fAny2ManyInfo->rebin)); // number of histograms psibin.put_numberHisto_int((int)fData[0].GetNoOfHistos()); // run title = sample (10 char) / temp (10 char) / field (10 char) / orientation (10 char) @@ -4206,9 +4975,18 @@ Bool_t PRunDataHandler::WritePsiBinFile(TString fln) cstr[10] = '\0'; psibin.put_setup(cstr); + // handle PSI-BIN start/stop Time/Date. PSI-BIN requires: Time -> HH:MM:SS, and Date -> DD-MMM-YY + // internally given: Time -> HH:MM:SS, and Date -> YYYY-MM-DD // run start date vector svec; - strncpy(cstr, fData[0].GetStartDate()->Data(), 9); + TString str, date; + TDatime dt; + dt.Set(fData[0].GetStartDateTime()); + date.Form("%02d-", dt.GetDay()); + date.Append(GetMonth(dt.GetMonth())); + date.Append("-"); + date.Append(GetYear(dt.GetYear())); + strncpy(cstr, date.Data(), 9); cstr[9] = '\0'; svec.push_back(cstr); // run start time @@ -4219,7 +4997,12 @@ Bool_t PRunDataHandler::WritePsiBinFile(TString fln) svec.clear(); // run stop date - strncpy(cstr, fData[0].GetStopDate()->Data(), 9); + dt.Set(fData[0].GetStopDateTime()); + date.Form("%02d-", dt.GetDay()); + date.Append(GetMonth(dt.GetMonth())); + date.Append("-"); + date.Append(GetYear(dt.GetYear())); + strncpy(cstr, date.Data(), 9); cstr[9] = '\0'; svec.push_back(cstr); // run stop time @@ -4229,16 +5012,6 @@ Bool_t PRunDataHandler::WritePsiBinFile(TString fln) psibin.put_timeStop_vector(svec); svec.clear(); - // t0's - for (UInt_t i=0; iData()); - // write histogram labels - vector histoLabel; - histoLabel.resize(fData[0].GetNoOfHistos()); - char hl[32]; - for (UInt_t i=0; irebin); // write scaler dummies psibin.put_numberScaler_int(0); - // fill histograms - vector< vector > histo; - histo.resize(fData[0].GetNoOfHistos()); - for (UInt_t i=0; isize(); j++) - histo[i].push_back((Int_t)fData[0].GetDataBin(i)->at(j)); + // feed detector related info like, histogram names, t0, fgb, lgb + Int_t ival = 0; + PRawRunDataSet *dataSet; + UInt_t size = fData[0].GetNoOfHistos(); + for (UInt_t i=0; i> PRunDataHandler::WritePsiBinFile: **ERROR** Couldn't get data set (idx=" << i << ")"; + cerr << endl << ">> something is really wrong!" << endl; + return false; + } + + // detector name + str = dataSet->GetName(); + if (!str.CompareTo("n/a")) + str.Form("Detector%3d", i+1); + psibin.put_nameHisto(str.Data(), i); + // time zero bin + ival = (Int_t)(dataSet->GetTimeZeroBin()/fAny2ManyInfo->rebin); + psibin.put_t0_int(i, ival); + // first good bin + ival = (Int_t)(dataSet->GetFirstGoodBin()/fAny2ManyInfo->rebin); + psibin.put_firstGood_int(i, ival); + // last good bin + ival = (Int_t)(dataSet->GetLastGoodBin()/fAny2ManyInfo->rebin); + psibin.put_lastGood_int(i, ival); } - status = psibin.put_histo_array_int(histo); + + // feed histos + vector< vector > histos; + histos.resize(fData[0].GetNoOfHistos()); + UInt_t length = 0; + if (fAny2ManyInfo->rebin == 1) { + for (UInt_t i=0; i> PRunDataHandler::WritePsiBinFile: **ERROR** Couldn't get data set (idx=" << i << ")"; + cerr << endl << ">> something is really wrong!" << endl; + return false; + } + length = dataSet->GetData()->size(); + histos[i].resize(length); + for (UInt_t j=0; jGetData()->at(j); + } + } + } else { // rebin > 1 + UInt_t dataRebin = 0; + UInt_t dataCount = 0; + for (UInt_t i=0; i> PRunDataHandler::WritePsiBinFile: **ERROR** Couldn't get data set (idx=" << i << ")"; + cerr << endl << ">> something is really wrong!" << endl; + return false; + } + length = dataSet->GetData()->size(); + dataCount = 0; + for (UInt_t j=0; j 0) && (j % fAny2ManyInfo->rebin == 0)) { + dataCount++; + histos[i].push_back(dataRebin); + dataRebin = 0; + } + dataRebin += static_cast(dataSet->GetData()->at(j)); + } + } + } + status = psibin.put_histo_array_int(histos); if (status != 0) { cerr << endl << ">> PRunDataHandler::WritePsiBinFile(): " << psibin.ConsistencyStatus() << endl; return false; @@ -4348,17 +5172,18 @@ Bool_t PRunDataHandler::WriteMudFile(TString fln) MUD_setRunDesc(fd, MUD_SEC_GEN_RUN_DESC_ID); MUD_setExptNumber(fd, 0); MUD_setRunNumber(fd, fData[0].GetRunNumber()); - MUD_setElapsedSec(fd, 0); + Int_t ival = fData[0].GetStopDateTime()-fData[0].GetStartDateTime(); + MUD_setElapsedSec(fd, ival); MUD_setTimeBegin(fd, fData[0].GetStartDateTime()); MUD_setTimeEnd(fd, fData[0].GetStopDateTime()); MUD_setTitle(fd, (char *)fData[0].GetRunTitle()->Data()); - MUD_setLab(fd, dummy); - MUD_setArea(fd, dummy); + MUD_setLab(fd, (char *)fData[0].GetLaboratory()->Data()); + MUD_setArea(fd, (char *)fData[0].GetArea()->Data()); MUD_setMethod(fd, (char *)fData[0].GetSetup()->Data()); - MUD_setApparatus(fd, dummy); + MUD_setApparatus(fd, (char *)fData[0].GetInstrument()->Data()); MUD_setInsert(fd, dummy); - MUD_setSample(fd, dummy); - MUD_setOrient(fd, dummy); + MUD_setSample(fd, (char *)fData[0].GetSample()->Data()); + MUD_setOrient(fd, (char *)fData[0].GetOrientation()->Data()); MUD_setDas(fd, dummy); MUD_setExperimenter(fd, dummy); sprintf(info, "%lf+-%lf (K)", fData[0].GetTemperature(0), fData[0].GetTempError(0)); @@ -4369,7 +5194,7 @@ Bool_t PRunDataHandler::WriteMudFile(TString fln) // generate the histograms MUD_setHists(fd, MUD_GRP_TRI_TD_HIST_ID, fData[0].GetNoOfHistos()); - UInt_t *data, dataSize = fData[0].GetDataBin(0)->size()/fAny2ManyInfo->rebin + 1; + UInt_t *data, dataSize = fData[0].GetDataSet(0, false)->GetData()->size()/fAny2ManyInfo->rebin + 1; data = new UInt_t[dataSize]; if (data == 0) { cerr << endl << ">> PRunDataHandler::WriteMudFile(): **ERROR** couldn't allocate memory for the data ..." << endl; @@ -4377,22 +5202,30 @@ Bool_t PRunDataHandler::WriteMudFile(TString fln) return false; } - UInt_t noOfEvents = 0, ival = 0, k = 0; + UInt_t noOfEvents = 0, k = 0; + ival = 0; + PRawRunDataSet *dataSet; for (UInt_t i=0; i> PRunDataHandler::WriteMudFile: **ERROR** Couldn't get data set (idx=" << i << ")"; + cerr << endl << ">> something is really wrong!" << endl; + return false; + } // fill data for (UInt_t j=0; jsize(); j++) { + for (UInt_t j=0; jGetData()->size(); j++) { if ((j != 0) && (j % fAny2ManyInfo->rebin == 0)) { data[k] = ival; noOfEvents += ival; k++; ival = 0; } - ival += static_cast(fData[0].GetDataBin(i)->at(j)); + ival += static_cast(dataSet->GetData()->at(j)); } // feed data relevant information @@ -4402,19 +5235,14 @@ Bool_t PRunDataHandler::WriteMudFile(TString fln) MUD_setHistNumBins(fd, i+1, dataSize); MUD_setHistBytesPerBin(fd, i+1, 0); MUD_setHistFsPerBin(fd, i+1, static_cast(1.0e6*fAny2ManyInfo->rebin*fData[0].GetTimeResolution())); // time resolution is given in (ns) - if (fData[0].GetT0Size() > i) { - MUD_setHistT0_Ps(fd, i+1, static_cast(1.0e3*fData[0].GetTimeResolution()*((fData[0].GetT0(i)+fAny2ManyInfo->rebin/2)/fAny2ManyInfo->rebin))); - MUD_setHistT0_Bin(fd, i+1, static_cast(fData[0].GetT0(i)/fAny2ManyInfo->rebin)); - } else { - MUD_setHistT0_Ps(fd, i+1, 0); - MUD_setHistT0_Bin(fd, i+1, 0); - } - MUD_setHistGoodBin1(fd, i+1, 0); - MUD_setHistGoodBin2(fd, i+1, 0); + MUD_setHistT0_Ps(fd, i+1, static_cast(1.0e3*fData[0].GetTimeResolution()*((dataSet->GetTimeZeroBin()+fAny2ManyInfo->rebin/2)/fAny2ManyInfo->rebin))); + MUD_setHistT0_Bin(fd, i+1, static_cast(dataSet->GetTimeZeroBin()/fAny2ManyInfo->rebin)); + MUD_setHistGoodBin1(fd, i+1, static_cast(dataSet->GetFirstGoodBin()/fAny2ManyInfo->rebin)); + MUD_setHistGoodBin2(fd, i+1, static_cast(dataSet->GetLastGoodBin()/fAny2ManyInfo->rebin)); MUD_setHistBkgd1(fd, i+1, 0); MUD_setHistBkgd2(fd, i+1, 0); MUD_setHistNumEvents(fd, i+1, (UINT32)noOfEvents); - MUD_setHistTitle(fd, i+1, dummy); + MUD_setHistTitle(fd, i+1, (char *)dataSet->GetName().Data()); REAL64 timeResolution = (fAny2ManyInfo->rebin*fData[0].GetTimeResolution())/1.0e9; // ns -> s MUD_setHistSecondsPerBin(fd, i+1, timeResolution); @@ -4466,7 +5294,6 @@ Bool_t PRunDataHandler::WriteMudFile(TString fln) // delete temporary root file remove(fln.Data()); } - return true; } @@ -4548,49 +5375,58 @@ Bool_t PRunDataHandler::WriteAsciiFile(TString fln) cout.precision(10); cout << endl << "% time resolution : " << fData[0].GetTimeResolution()*fAny2ManyInfo->rebin << " (ns)"; cout.setf(ios::fixed,ios::floatfield); // floatfield set to fixed + } + PRawRunDataSet *dataSet; + cout << endl << "% t0 : "; + for (UInt_t i=0; i(dataSet->GetTimeZeroBin()/fAny2ManyInfo->rebin) << ", "; } - if (fData[0].GetT0Size() > 0) { - cout << endl << "% t0 : "; - for (UInt_t i=0; i(fData[0].GetT0(i)/fAny2ManyInfo->rebin) << ", "; - } - cout << fData[0].GetT0(fData[0].GetT0Size()-1)/fAny2ManyInfo->rebin; - } + dataSet = fData[0].GetDataSet(fData[0].GetNoOfHistos()-1, false); // i.e. the false means, that i is the index and NOT the histo number + cout << static_cast(dataSet->GetTimeZeroBin()/fAny2ManyInfo->rebin); + cout << endl << "% # histos : " << fData[0].GetNoOfHistos(); - cout << endl << "% # of bins : " << static_cast(fData[0].GetDataBin(0)->size()/fAny2ManyInfo->rebin); + dataSet = fData[0].GetDataSet(0, false); // i.e. the false means, that i is the index and NOT the histo number + cout << endl << "% # of bins : " << static_cast(dataSet->GetData()->size()/fAny2ManyInfo->rebin); cout << endl << "%*************************************************************************"; // write data + UInt_t length = fData[0].GetDataSet(0,false)->GetData()->size(); if (fAny2ManyInfo->rebin == 1) { - UInt_t length = fData[0].GetDataBin(0)->size(); for (UInt_t i=0; i(fData[0].GetDataBin(j)->at(i)); + cout << static_cast(dataSet->GetData()->at(i)); } } } else { PUIntVector dataRebin(fData[0].GetNoOfHistos()); - UInt_t length = fData[0].GetDataBin(0)->size(); // initialize the dataRebin vector - for (UInt_t i=0; i(fData[0].GetDataBin(i)->at(0)); + for (UInt_t i=0; i(dataSet->GetData()->at(0)); + } for (UInt_t i=0; irebin) == 0) { cout << endl; - for (UInt_t j=0; j(fData[0].GetDataBin(j)->at(i)); + for (UInt_t j=0; j(dataSet->GetData()->at(i)); + } } else { - for (UInt_t j=0; j(fData[0].GetDataBin(j)->at(i)); + for (UInt_t j=0; j(dataSet->GetData()->at(i)); + } } } } @@ -5047,3 +5883,89 @@ void PRunDataHandler::SplitTimeDate(TString timeData, TString &time, TString &da time = TString::Format("%02d:%02d:%02d", tm.tm_hour, tm.tm_min, tm.tm_sec); date = TString::Format("%04d-%02d-%02d", tm.tm_year+1900, tm.tm_mon, tm.tm_mday); } + +//-------------------------------------------------------------------------- +// GetMonth (private) +//-------------------------------------------------------------------------- +/** + *

given the month as number, convert it to a 3 character month. + * If month is out of range (i.e. not between 1 and 12) a '???' will + * be returned. + * + * \param month as number + */ +TString PRunDataHandler::GetMonth(Int_t month) +{ + TString monthString = "???"; + + switch (month) { + case 1: + monthString = "JAN"; + break; + case 2: + monthString = "FEB"; + break; + case 3: + monthString = "MAR"; + break; + case 4: + monthString = "APR"; + break; + case 5: + monthString = "MAY"; + break; + case 6: + monthString = "JUN"; + break; + case 7: + monthString = "JUL"; + break; + case 8: + monthString = "AUG"; + break; + case 9: + monthString = "SEP"; + break; + case 10: + monthString = "OCT"; + break; + case 11: + monthString = "NOV"; + break; + case 12: + monthString = "DEC"; + break; + default: + break; + } + + return monthString; +} + +//-------------------------------------------------------------------------- +// GetYear (private) +//-------------------------------------------------------------------------- +/** + *

given the year as number, convert it to a 2 character year. + * If year is out of range '??' will be returned. This routine will + * break in the year 2100 or later ;-) + * + * \param year as number + */ +TString PRunDataHandler::GetYear(Int_t year) +{ + TString yearString = "??"; + Int_t yy=0; + + if (year < 2000) { + yy = year - 1900; + if (yy > 0) + yearString.Form("%02d", yy); + } else { + yy = year - 2000; + if ((yy >= 0) && (yy <= 99)) + yearString.Form("%02d", yy); + } + + return yearString; +} diff --git a/src/classes/PRunListCollection.cpp b/src/classes/PRunListCollection.cpp index 29200912..c2d11b5e 100644 --- a/src/classes/PRunListCollection.cpp +++ b/src/classes/PRunListCollection.cpp @@ -10,8 +10,8 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007 by Andreas Suter * - * andreas.suter@psi.c * + * Copyright (C) 2007-2012 by Andreas Suter * + * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * diff --git a/src/classes/PRunMuMinus.cpp b/src/classes/PRunMuMinus.cpp index 74a4003a..be8ca14f 100644 --- a/src/classes/PRunMuMinus.cpp +++ b/src/classes/PRunMuMinus.cpp @@ -10,8 +10,8 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007 by Andreas Suter * - * andreas.suter@psi.c * + * Copyright (C) 2007-2012 by Andreas Suter * + * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * diff --git a/src/classes/PRunNonMusr.cpp b/src/classes/PRunNonMusr.cpp index fe0e1155..6460c516 100644 --- a/src/classes/PRunNonMusr.cpp +++ b/src/classes/PRunNonMusr.cpp @@ -10,7 +10,7 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007 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 * diff --git a/src/classes/PRunSingleHisto.cpp b/src/classes/PRunSingleHisto.cpp index d2d6a0c1..95567798 100644 --- a/src/classes/PRunSingleHisto.cpp +++ b/src/classes/PRunSingleHisto.cpp @@ -10,7 +10,7 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007 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 * @@ -91,6 +91,7 @@ PRunSingleHisto::PRunSingleHisto(PMsrHandler *msrInfo, PRunDataHandler *rawData, */ PRunSingleHisto::~PRunSingleHisto() { + fForward.clear(); } //-------------------------------------------------------------------------- @@ -509,13 +510,13 @@ Bool_t PRunSingleHisto::PrepareData() } // collect histogram numbers - PUIntVector histoNo; + PUIntVector histoNo; // histoNo = msr-file forward + redGreen_offset - 1 for (UInt_t i=0; iGetForwardHistoNoSize(); i++) { - histoNo.push_back(fRunInfo->GetForwardHistoNo(i)-1); + histoNo.push_back(fRunInfo->GetForwardHistoNo(i)); - if (runData->GetNoOfHistos() <= histoNo[i]) { + if (!runData->IsPresent(histoNo[i])) { cerr << endl << ">> PRunSingleHisto::PrepareData(): **PANIC ERROR**:"; - cerr << endl << ">> histoNo found = " << histoNo[i]+1 << ", but there are only " << runData->GetNoOfHistos() << " runs!?!?"; + cerr << endl << ">> histoNo found = " << histoNo[i] << ", which is NOT present in the data file!?!?"; cerr << endl << ">> Will quit :-("; cerr << endl; histoNo.clear(); @@ -523,64 +524,59 @@ Bool_t PRunSingleHisto::PrepareData() } } - // check if the t0's are given in the msr-file - if (fRunInfo->GetT0Size() == 0) { // t0's are NOT in the msr-file - // check if the t0's are in the data file - if (runData->GetT0Size() != 0) { // t0's in the run data - // keep the proper t0's. For single histo runs, forward is holding the histo no - // fForwardHistoNo starts with 1 not with 0 ;-) - for (UInt_t i=0; iGetForwardHistoNoSize(); i++) - fT0s.push_back(runData->GetT0(fRunInfo->GetForwardHistoNo(i)-1)); - } else { // t0's are neither in the run data nor in the msr-file -> will try estimated ones! - for (UInt_t i=0; iGetForwardHistoNoSize(); i++) { - fT0s.push_back(runData->GetT0Estimated(fRunInfo->GetForwardHistoNo(i)-1)); - cerr << endl << ">> PRunSingleHisto::PrepareData(): **WARNING** NO t0's found, neither in the run data nor in the msr-file!"; - cerr << endl << ">> run: " << fRunInfo->GetRunName()->Data(); - cerr << endl << ">> will try the estimated one: t0 = " << runData->GetT0Estimated(fRunInfo->GetForwardHistoNo(i)-1); - cerr << endl << ">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; - cerr << endl; - } - } - } else { // t0's in the msr-file - for (UInt_t i=0; iGetForwardHistoNoSize(); i++) { - // check if enough t0's are given in the msr-file, if not try to get the rest from the data file - if (fRunInfo->GetT0Size() <= i) { // t0 for i not present in the msr-file, i.e. #t0's != #forward histos - if (static_cast(runData->GetT0Size()) > fRunInfo->GetForwardHistoNo(i)-1) { // t0 for i present in the data file - fT0s.push_back(runData->GetT0(fRunInfo->GetForwardHistoNo(i)-1)); - } else { // t0 is neither in the run data nor in the msr-file -> will try estimated one! - fT0s.push_back(runData->GetT0Estimated(fRunInfo->GetForwardHistoNo(i)-1)); - cerr << endl << ">> PRunSingleHisto::PrepareData(): **WARNING** NO t0's found, neither in the run data nor in the msr-file!"; - cerr << endl << ">> run: " << fRunInfo->GetRunName()->Data(); - cerr << endl << ">> will try the estimated one: t0 = " << runData->GetT0Estimated(fRunInfo->GetForwardHistoNo(i)-1); - cerr << endl << ">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; - cerr << endl; - } - } else { // # of t0's in the msr-file == # of histos in forward - fT0s.push_back(fRunInfo->GetT0(i)); - // check if t0's are given in the data file - if (runData->GetT0Size() != 0) { - // compare t0's of the msr-file with the one in the data file - if (fabs(fRunInfo->GetT0(i)-runData->GetT0(fRunInfo->GetForwardHistoNo(i)-1))>5.0) { // given in bins!! - cerr << endl << ">> PRunSingleHisto::PrepareData(): **WARNING**:"; - cerr << endl << ">> t0 from the msr-file is " << fRunInfo->GetT0(i); - cerr << endl << ">> t0 from the data file is " << runData->GetT0(fRunInfo->GetForwardHistoNo(i)-1); - cerr << endl << ">> This is quite a deviation! Is this done intentionally??"; - cerr << endl; - } - } + // feed all T0's + // first init T0's, T0's are stored as (forward T0, backward T0, etc.) + fT0s.clear(); + fT0s.resize(histoNo.size()); + for (UInt_t i=0; iGetT0BinSize(); i++) { + fT0s[i] = fRunInfo->GetT0Bin(i); + } + + // fill in the T0's from the data file, if not already present in the msr-file + for (UInt_t i=0; iGetT0Bin(histoNo[i]) > 0.0) { + fT0s[i] = runData->GetT0Bin(histoNo[i]); + fRunInfo->SetT0Bin(fT0s[i], i); // keep value for the msr-file } + } + + // fill in the T0's gaps, i.e. in case the T0's are NOT in the msr-file and NOT in the data file + for (UInt_t i=0; iGetT0BinEstimated(histoNo[i]); + fRunInfo->SetT0Bin(fT0s[i], i); // keep value for the msr-file + + cerr << endl << ">> PRunSingleHisto::PrepareData(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!"; + cerr << endl << ">> run: " << fRunInfo->GetRunName(); + cerr << endl << ">> will try the estimated one: forward t0 = " << runData->GetT0BinEstimated(histoNo[i]); + cerr << endl << ">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; + cerr << endl; } } // check if t0 is within proper bounds for (UInt_t i=0; iGetForwardHistoNoSize(); i++) { if ((fT0s[i] < 0) || (fT0s[i] > (Int_t)runData->GetDataBin(histoNo[i])->size())) { - cerr << endl << ">> PRunSingleHisto::PrepareData(): **ERROR** t0 data bin doesn't make any sense!"; + cerr << endl << ">> PRunSingleHisto::PrepareData(): **ERROR** t0 data bin (" << fT0s[i] << ") doesn't make any sense!"; cerr << endl; return false; } } + // keep the histo of each group at this point (addruns handled below) + vector forward; + forward.resize(histoNo.size()); // resize to number of groups + for (UInt_t i=0; iGetDataBin(histoNo[i])->size()); + forward[i] = *runData->GetDataBin(histoNo[i]); + } + // check if there are runs to be added to the current one if (fRunInfo->GetRunNameSize() > 1) { // runs to be added present PRawRunData *addRunData; @@ -594,62 +590,59 @@ Bool_t PRunSingleHisto::PrepareData() return false; } - // get T0's of the to be added run - PUIntVector t0Add; - // check if the t0's are given in the msr-file - if (i > fRunInfo->GetAddT0Entries()) { // t0's are NOT in the msr-file - // check if the t0's are in the data file - if (addRunData->GetT0Size() != 0) { // t0's in the run data - // keep the proper t0's. For single histo runs, forward is holding the histo no - // fForwardHistoNo starts with 1 not with 0 ;-) - for (UInt_t j=0; jGetForwardHistoNoSize(); j++) - t0Add.push_back(addRunData->GetT0(fRunInfo->GetForwardHistoNo(j)-1)); - } else { // t0's are neither in the run data nor in the msr-file -> will try estimated ones! - for (UInt_t j=0; jGetForwardHistoNoSize(); j++) { - t0Add.push_back(addRunData->GetT0Estimated(fRunInfo->GetForwardHistoNo(j)-1)); - cerr << endl << ">> PRunSingleHisto::PrepareData(): **WARNING** NO t0's found, neither in the addrun data nor in the msr-file!"; - cerr << endl << ">> addrun: " << fRunInfo->GetRunName(i)->Data(); - cerr << endl << ">> will try the estimated one: t0 = " << addRunData->GetT0Estimated(fRunInfo->GetForwardHistoNo(j)-1); - cerr << endl << ">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; - cerr << endl; - } - } - } else { // t0's in the msr-file - for (UInt_t j=0; jGetForwardHistoNoSize(); j++) { - // check if t0's are given in the data file - if (addRunData->GetT0Size() != 0) { - // compare t0's of the msr-file with the one in the data file - if (fabs(fRunInfo->GetAddT0(i-1,j)-addRunData->GetT0(fRunInfo->GetForwardHistoNo(j)-1))>5.0) { // given in bins!! - cerr << endl << ">> PRunSingleHisto::PrepareData(): **WARNING**:"; - cerr << endl << ">> t0 from the msr-file is " << fRunInfo->GetAddT0(i-1,j); - cerr << endl << ">> t0 from the data file is " << addRunData->GetT0(fRunInfo->GetForwardHistoNo(j)-1); - cerr << endl << ">> This is quite a deviation! Is this done intentionally??"; - cerr << endl << ">> addrun: " << fRunInfo->GetRunName(i)->Data(); - cerr << endl; - } - } - if (i <= fRunInfo->GetAddT0Entries()) { - if (j < static_cast(fRunInfo->GetAddT0Size(i-1))) { - t0Add.push_back(fRunInfo->GetAddT0(i-1,j)); - } else { - cerr << endl << ">> PRunSingleHisto::PrepareData(): **WARNING** NO t0's found, neither in the addrun data ("; - cerr << fRunInfo->GetRunName(i)->Data(); - cerr << "), nor in the msr-file! Will try to use the T0 of the run data ("; - cerr << fRunInfo->GetRunName(i)->Data(); - cerr << ") without any warranty!"; - cerr << endl; - t0Add.push_back(fRunInfo->GetT0(j)); - } + // feed all T0's + // first init T0's, T0's are stored as (forward T0, backward T0, etc.) + PDoubleVector t0Add; + t0Add.resize(histoNo.size()); + for (UInt_t j=0; jGetT0BinSize(); j++) { + t0Add[j] = fRunInfo->GetAddT0Bin(i-1,j); // addRunIdx starts at 0 + } + + // fill in the T0's from the data file, if not already present in the msr-file + for (UInt_t j=0; jGetT0Bin(histoNo[j]) > 0.0) { + t0Add[j] = addRunData->GetT0Bin(histoNo[j]); + fRunInfo->SetAddT0Bin(t0Add[j], i-1, j); // keep value for the msr-file } + } + + // fill in the T0's gaps, i.e. in case the T0's are NOT in the msr-file and NOT in the data file + for (UInt_t j=0; jGetT0BinEstimated(histoNo[j]); + fRunInfo->SetAddT0Bin(t0Add[j], i-1, j); // keep value for the msr-file + + cerr << endl << ">> PRunSingleHisto::PrepareData(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!"; + cerr << endl << ">> run: " << fRunInfo->GetRunName(); + cerr << endl << ">> will try the estimated one: forward t0 = " << addRunData->GetT0BinEstimated(histoNo[j]); + cerr << endl << ">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; + cerr << endl; } } - // add runs - for (UInt_t k=0; kGetForwardHistoNoSize(); k++) { - for (UInt_t j=0; jGetDataBin(histoNo[k])->size(); j++) { - // make sure that the index stays within proper range - if ((j+t0Add[k]-fT0s[k] >= 0) && (j+t0Add[k]-fT0s[k] < addRunData->GetDataBin(histoNo[k])->size())) { - runData->AddDataBin(histoNo[k], j, addRunData->GetDataBin(histoNo[k])->at(j+t0Add[k]-fT0s[k])); + // check if t0 is within proper bounds + for (UInt_t j=0; jGetForwardHistoNoSize(); j++) { + if ((t0Add[j] < 0) || (t0Add[j] > (Int_t)addRunData->GetDataBin(histoNo[j])->size())) { + cerr << endl << ">> PRunSingleHisto::PrepareData(): **ERROR** addt0 data bin (" << t0Add[j] << ") doesn't make any sense!"; + cerr << endl; + return false; + } + } + + // add forward run + UInt_t addRunSize; + for (UInt_t k=0; kGetDataBin(histoNo[k])->size(); + for (UInt_t j=0; jGetDataBin(histoNo[k])->size(); j++) { // loop over the bin indices + // make sure that the index stays in the proper range + if ((j+(Int_t)t0Add[k]-(Int_t)fT0s[k] >= 0) && (j+(Int_t)t0Add[k]-(Int_t)fT0s[k] < addRunSize)) { + forward[k][j] += addRunData->GetDataBin(histoNo[k])->at(j+(Int_t)t0Add[k]-(Int_t)fT0s[k]); } } } @@ -659,12 +652,18 @@ Bool_t PRunSingleHisto::PrepareData() } } - // group histograms, add all the forward histograms to the one with histoNo[0] - for (UInt_t i=1; iGetForwardHistoNoSize(); i++) { - for (UInt_t j=0; jGetDataBin(histoNo[0])->size(); j++) { + // set forward/backward histo data of the first group + fForward.resize(forward[0].size()); + for (UInt_t i=0; iGetDataBin(histoNo[i])->size(); j++) { // loop over the bin indices // make sure that the index stays within proper range if ((j+fT0s[i]-fT0s[0] >= 0) && (j+fT0s[i]-fT0s[0] < runData->GetDataBin(histoNo[i])->size())) { - runData->AddDataBin(histoNo[0], j, runData->GetDataBin(histoNo[i])->at(j+fT0s[i]-fT0s[0])); + fForward[j] += forward[i][j+fT0s[i]-fT0s[0]]; } } } @@ -721,12 +720,14 @@ Bool_t PRunSingleHisto::PrepareFitData(PRawRunData* runData, const UInt_t histoN if (start < 0) { Int_t offset = (Int_t)(10.0e-3/fTimeResolution); start = fT0s[0]+offset; + fRunInfo->SetDataRange(start, 0); cerr << endl << ">> PRunSingleHisto::PrepareData(): **WARNING** data range was not provided, will try data range start = t0+" << offset << "(=10ns) = " << start << "."; cerr << endl << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; cerr << endl; } if (end < 0) { - end = runData->GetDataBin(histoNo)->size(); + end = fForward.size(); + fRunInfo->SetDataRange(end, 1); cerr << endl << ">> PRunSingleHisto::PrepareData(): **WARNING** data range was not provided, will try data range end = " << end << "."; cerr << endl << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; cerr << endl; @@ -740,13 +741,13 @@ Bool_t PRunSingleHisto::PrepareFitData(PRawRunData* runData, const UInt_t histoN start = keep; } // 2nd check if start is within proper bounds - if ((start < 0) || (start > (Int_t)runData->GetDataBin(histoNo)->size())) { + if ((start < 0) || (start > (Int_t)fForward.size())) { cerr << endl << ">> PRunSingleHisto::PrepareFitData(): **ERROR** start data bin doesn't make any sense!"; cerr << endl; return false; } // 3rd check if end is within proper bounds - if ((end < 0) || (end > (Int_t)runData->GetDataBin(histoNo)->size())) { + if ((end < 0) || (end > (Int_t)fForward.size())) { cerr << endl << ">> PRunSingleHisto::PrepareFitData(): **ERROR** end data bin doesn't make any sense!"; cerr << endl; return false; @@ -770,8 +771,8 @@ Bool_t PRunSingleHisto::PrepareFitData(PRawRunData* runData, const UInt_t histoN return false; } } else { // fixed background given - for (UInt_t i=0; iGetDataBin(histoNo)->size(); i++) { - runData->AddDataBin(histoNo, i, -fRunInfo->GetBkgFix(0)); + for (UInt_t i=0; iGetBkgFix(0); } } } @@ -790,7 +791,7 @@ Bool_t PRunSingleHisto::PrepareFitData(PRawRunData* runData, const UInt_t histoN fData.SetDataTimeStep(fTimeResolution*fRunInfo->GetPacking()); for (Int_t i=start; iGetPacking() == 1) { - value = runData->GetDataBin(histoNo)->at(i); + value = fForward[i]; value /= normalizer; fData.AppendValue(value); if (value == 0.0) @@ -808,7 +809,7 @@ Bool_t PRunSingleHisto::PrepareFitData(PRawRunData* runData, const UInt_t histoN // reset values value = 0.0; } - value += runData->GetDataBin(histoNo)->at(i); + value += fForward[i]; } } @@ -856,12 +857,12 @@ Bool_t PRunSingleHisto::PrepareRawViewData(PRawRunData* runData, const UInt_t hi // start = the first bin which is a multiple of packing backward from first good data bin Int_t start = fRunInfo->GetDataRange(0) - (fRunInfo->GetDataRange(0)/packing)*packing; // end = last bin starting from start which is a multipl of packing and still within the data - Int_t end = start + ((runData->GetDataBin(histoNo)->size()-start)/packing)*packing; + Int_t end = start + ((fForward.size()-start)/packing)*packing; // check if data range has been provided, and if not try to estimate them if (start < 0) { Int_t offset = (Int_t)(10.0e-3/fTimeResolution); start = (fT0s[0]+offset) - ((fT0s[0]+offset)/packing)*packing; - end = start + ((runData->GetDataBin(histoNo)->size()-start)/packing)*packing; + end = start + ((fForward.size()-start)/packing)*packing; cerr << endl << ">> PRunSingleHisto::PrepareData(): **WARNING** data range was not provided, will try data range start = " << start << "."; cerr << endl << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; cerr << endl; @@ -874,13 +875,13 @@ Bool_t PRunSingleHisto::PrepareRawViewData(PRawRunData* runData, const UInt_t hi start = keep; } // 2nd check if start is within proper bounds - if ((start < 0) || (start > (Int_t)runData->GetDataBin(histoNo)->size())) { + if ((start < 0) || (start > (Int_t)fForward.size())) { cerr << endl << ">> PRunSingleHisto::PrepareRawViewData(): **ERROR** start data bin doesn't make any sense!"; cerr << endl; return false; } // 3rd check if end is within proper bounds - if ((end < 0) || (end > (Int_t)runData->GetDataBin(histoNo)->size())) { + if ((end < 0) || (end > (Int_t)fForward.size())) { cerr << endl << ">> PRunSingleHisto::PrepareRawViewData(): **ERROR** end data bin doesn't make any sense!"; cerr << endl; return false; @@ -905,7 +906,7 @@ Bool_t PRunSingleHisto::PrepareRawViewData(PRawRunData* runData, const UInt_t hi // reset values value = 0.0; } - value += runData->GetDataBin(histoNo)->at(i); + value += fForward[i]; } CalcNoOfFitBins(); @@ -969,11 +970,11 @@ Bool_t PRunSingleHisto::PrepareRawViewData(PRawRunData* runData, const UInt_t hi } // calculate theory - UInt_t size = runData->GetDataBin(histoNo)->size(); + UInt_t size = fForward.size(); Double_t factor = 1.0; - if (fData.GetValue()->size() * 10 > runData->GetDataBin(histoNo)->size()) { + if (fData.GetValue()->size() * 10 > fForward.size()) { size = fData.GetValue()->size() * 10; - factor = (Double_t)runData->GetDataBin(histoNo)->size() / (Double_t)size; + factor = (Double_t)fForward.size() / (Double_t)size; } Double_t time; Double_t theoryValue; @@ -1051,13 +1052,13 @@ Bool_t PRunSingleHisto::PrepareViewData(PRawRunData* runData, const UInt_t histo // start = the first bin which is a multiple of packing backward from first good data bin Int_t start = fRunInfo->GetDataRange(0) - (fRunInfo->GetDataRange(0)/packing)*packing; // end = last bin starting from start which is a multiple of packing and still within the data - Int_t end = start + ((runData->GetDataBin(histoNo)->size()-start)/packing)*packing; + Int_t end = start + ((fForward.size()-start)/packing)*packing; // check if data range has been provided, and if not try to estimate them if (start < 0) { Int_t offset = (Int_t)(10.0e-3/fTimeResolution); start = (fT0s[0]+offset) - ((fT0s[0]+offset)/packing)*packing; - end = start + ((runData->GetDataBin(histoNo)->size()-start)/packing)*packing; + end = start + ((fForward.size()-start)/packing)*packing; cerr << endl << ">> PRunSingleHisto::PrepareData(): **WARNING** data range was not provided, will try data range start = " << start << "."; cerr << endl << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; cerr << endl; @@ -1071,13 +1072,13 @@ Bool_t PRunSingleHisto::PrepareViewData(PRawRunData* runData, const UInt_t histo start = keep; } // 2nd check if start is within proper bounds - if ((start < 0) || (start > (Int_t)runData->GetDataBin(histoNo)->size())) { + if ((start < 0) || (start > (Int_t)fForward.size())) { cerr << endl << ">> PRunSingleHisto::PrepareViewData(): **ERROR** start data bin doesn't make any sense!"; cerr << endl; return false; } // 3rd check if end is within proper bounds - if ((end < 0) || (end > (Int_t)runData->GetDataBin(histoNo)->size())) { + if ((end < 0) || (end > (Int_t)fForward.size())) { cerr << endl << ">> PRunSingleHisto::PrepareViewData(): **ERROR** end data bin doesn't make any sense!"; cerr << endl; return false; @@ -1157,7 +1158,7 @@ Bool_t PRunSingleHisto::PrepareViewData(PRawRunData* runData, const UInt_t histo fData.AppendErrorValue(expval*TMath::Sqrt(value*dataNorm)); value = 0.0; } - value += runData->GetDataBin(histoNo)->at(i); + value += fForward[i]; } } else { // RRF representation // check which units shall be used @@ -1194,9 +1195,9 @@ Bool_t PRunSingleHisto::PrepareViewData(PRawRunData* runData, const UInt_t histo } time = ((Double_t)i-t0)*fTimeResolution; expval = TMath::Exp(+time/tau)/N0; - rrf_val = (-1.0+expval*(runData->GetDataBin(histoNo)->at(i)*dataNorm-bkg))*TMath::Cos(wRRF * time + phaseRRF); + rrf_val = (-1.0+expval*(fForward[i]*dataNorm-bkg))*TMath::Cos(wRRF * time + phaseRRF); value += rrf_val; - error += runData->GetDataBin(histoNo)->at(i)*dataNorm; + error += fForward[i]*dataNorm; } } @@ -1209,15 +1210,15 @@ Bool_t PRunSingleHisto::PrepareViewData(PRawRunData* runData, const UInt_t histo // calculate theory Double_t theoryValue; - UInt_t size = runData->GetDataBin(histoNo)->size(); + UInt_t size = fForward.size(); Double_t factor = 1.0; UInt_t rebinRRF = 0; if (wRRF == 0) { // no RRF // check if a finer binning for the theory is needed - if (fData.GetValue()->size() * 10 > runData->GetDataBin(histoNo)->size()) { + if (fData.GetValue()->size() * 10 > fForward.size()) { size = fData.GetValue()->size() * 10; - factor = (Double_t)runData->GetDataBin(histoNo)->size() / (Double_t)size; + factor = (Double_t)fForward.size() / (Double_t)size; } fData.SetTheoryTimeStart(fData.GetDataTimeStart()); fData.SetTheoryTimeStep(fTimeResolution*factor); @@ -1316,22 +1317,19 @@ Bool_t PRunSingleHisto::EstimateBkg(UInt_t histoNo) end = fRunInfo->GetBkgRange(1); } - // get the proper run - PRawRunData* runData = fRawData->GetRunData(*fRunInfo->GetRunName()); - // check if start is within histogram bounds - if ((start < 0) || (start >= runData->GetDataBin(histoNo)->size())) { + if ((start < 0) || (start >= fForward.size())) { cerr << endl << ">> PRunSingleHisto::EstimatBkg(): **ERROR** background bin values out of bound!"; - cerr << endl << ">> histo lengths = " << runData->GetDataBin(histoNo)->size(); + cerr << endl << ">> histo lengths = " << fForward.size(); cerr << endl << ">> background start = " << start; cerr << endl; return false; } // check if end is within histogram bounds - if ((end < 0) || (end >= runData->GetDataBin(histoNo)->size())) { + if ((end < 0) || (end >= fForward.size())) { cerr << endl << ">> PRunSingleHisto::EstimatBkg(): **ERROR** background bin values out of bound!"; - cerr << endl << ">> histo lengths = " << runData->GetDataBin(histoNo)->size(); + cerr << endl << ">> histo lengths = " << fForward.size(); cerr << endl << ">> background end = " << end; cerr << endl; return false; @@ -1342,7 +1340,7 @@ Bool_t PRunSingleHisto::EstimateBkg(UInt_t histoNo) // forward for (UInt_t i=start; iGetDataBin(histoNo)->at(i); + bkg += fForward[i]; bkg /= static_cast(end - start + 1); if (fScaleN0AndBkg) diff --git a/src/classes/PStartupHandler.cpp b/src/classes/PStartupHandler.cpp index 0b3052d9..ae39386b 100644 --- a/src/classes/PStartupHandler.cpp +++ b/src/classes/PStartupHandler.cpp @@ -10,8 +10,8 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007 by Andreas Suter * - * andreas.suter@psi.c * + * Copyright (C) 2007-2012 by Andreas Suter * + * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * diff --git a/src/classes/PTheory.cpp b/src/classes/PTheory.cpp index 4b1ae7ce..926d96b2 100644 --- a/src/classes/PTheory.cpp +++ b/src/classes/PTheory.cpp @@ -10,8 +10,8 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007 by Andreas Suter * - * andreas.suter@psi.c * + * Copyright (C) 2007-2012 by Andreas Suter * + * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * diff --git a/src/classes/PUserFcn.cpp b/src/classes/PUserFcn.cpp index 5bbcc037..c520f185 100644 --- a/src/classes/PUserFcn.cpp +++ b/src/classes/PUserFcn.cpp @@ -10,8 +10,8 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007 by Andreas Suter * - * andreas.suter@psi.c * + * Copyright (C) 2007-2012 by Andreas Suter * + * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * diff --git a/src/classes/PUserFcnBase.cpp b/src/classes/PUserFcnBase.cpp index 34817cb9..5317906e 100644 --- a/src/classes/PUserFcnBase.cpp +++ b/src/classes/PUserFcnBase.cpp @@ -10,8 +10,8 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007 by Andreas Suter * - * andreas.suter@psi.c * + * Copyright (C) 2007-2012 by Andreas Suter * + * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * diff --git a/src/external/MusrRoot/Makefile.am b/src/external/MusrRoot/Makefile.am new file mode 100644 index 00000000..489c8099 --- /dev/null +++ b/src/external/MusrRoot/Makefile.am @@ -0,0 +1,40 @@ +## Process this file with automake to create Makefile.in +## $Id$ + +h_sources = \ + TMusrRunHeader.h + +h_linkdef = \ + TMusrRunHeaderLinkDef.h + +dict_h_sources = \ + TMusrRunHeaderDict.h + +cpp_sources = \ + TMusrRunHeader.cpp + +dict_cpp_sources = \ + TMusrRunHeaderDict.cpp + +include_HEADERS = $(h_sources) +noinst_HEADERS = $(h_linkdef) $(dict_h_sources) + +INCLUDES = -I. $(ROOT_CFLAGS) +AM_CXXFLAGS = $(LOCAL_LIB_CXXFLAGS) + +BUILT_SOURCES = $(dict_cpp_sources) $(dist_h_sources) +AM_LDFLAGS = $(LOCAL_LIB_LDFLAGS) -L@ROOTLIBDIR@ +CLEANFILES = *Dict.cpp *Dict.h *~ core + +%Dict.cpp %Dict.h: %.h %LinkDef.h + @ROOTCINT@ -v -f $*Dict.cpp -c -p $(INCLUDES) $^ + +lib_LTLIBRARIES = libTMusrRunHeader.la + +libTMusrRunHeader_la_SOURCES = $(h_sources) $(cpp_sources) $(dict_h_sources) $(dict_cpp_sources) +libTMusrRunHeader_la_LIBADD = $(ROOT_LIBS) +libTMusrRunHeader_la_LDFLAGS = -version-info $(MUSR_ROOT_LIBRARY_VERSION) -release $(MUSR_ROOT_RELEASE) $(AM_LDFLAGS) + +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = TMusrRunHeader.pc + diff --git a/src/external/MusrRoot/MusrRoot.xsd b/src/external/MusrRoot/MusrRoot.xsd new file mode 100644 index 00000000..781be24b --- /dev/null +++ b/src/external/MusrRoot/MusrRoot.xsd @@ -0,0 +1,196 @@ + + + + + This XSD document describes the muSR file structure for CERN/ROOT based files. + In the following it will be called MusrRoot. + It is currently the default standard for writting muSR data files at the + Paul Scherrer Institute. + + Author: Andreas Suter, andreas.suter@psi.ch + $Id: MusrRoot.xsd 5092 2012-03-13 07:47:00Z nemu $ + + + + + + + + + + + + + + + + + The histos folder is containing potentially various subfolders. + At least two subfolders, called DecayAnaModule, and SlowControlAnaModule, + which holds the muSR decay histograms, must be present. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/external/MusrRoot/MusrRootLEM.xsd b/src/external/MusrRoot/MusrRootLEM.xsd new file mode 100644 index 00000000..fabc927e --- /dev/null +++ b/src/external/MusrRoot/MusrRootLEM.xsd @@ -0,0 +1,222 @@ + + + + + This XSD document describes the muSR file structure of CERN/ROOT based files for LEM. + In the following it will be called MusrRootLEM. + It is an extension of MusrRoot.xsd and describes the additional LEM specific entries. + + Author: Andreas Suter, andreas.suter@psi.ch + $Id: MusrRootLEM.xsd 5092 2012-03-13 07:47:00Z nemu $ + + + + + + + + + + + + + + + + + The histos folder is containing potentially various subfolders. + At least two subfolders, called DecayAnaModule, and SlowControlAnaModule, + which holds the muSR decay histograms, must be present. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/external/MusrRoot/TMusrRunHeader.cpp b/src/external/MusrRoot/TMusrRunHeader.cpp new file mode 100644 index 00000000..2c58bc18 --- /dev/null +++ b/src/external/MusrRoot/TMusrRunHeader.cpp @@ -0,0 +1,1691 @@ +/*************************************************************************** + + TMusrRunHeader.cpp + + Author: Andreas Suter + e-mail: andreas.suter@psi.ch + + $Id: TMusrRunHeader.cpp 5092 2012-03-13 07:47:00Z nemu $ + +***************************************************************************/ + +/*************************************************************************** + * Copyright (C) 2007-2012 by Andreas Suter * + * andreas.suter@psi.ch * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include +#include +#include +#include +using namespace std; + +#include "TMusrRunHeader.h" + +#include +#include +#include +#include +#include +#include +#include + +ClassImp(TMusrRunPhysicalQuantity) + +//-------------------------------------------------------------------------- +// Constructor +//-------------------------------------------------------------------------- +/** + *

Constructor. + */ +TMusrRunPhysicalQuantity::TMusrRunPhysicalQuantity() +{ + fLabel = "n/a"; + fDemand = MRH_UNDEFINED; + fValue = MRH_UNDEFINED; + fError = MRH_UNDEFINED; + fUnit = "n/a"; + fDescription = "n/a"; +} + +//-------------------------------------------------------------------------- +// Constructor +//-------------------------------------------------------------------------- +/** + *

Constructor. + * + * \param label of the physical quantity, e.g. 'Sample Temperature' + * \param demand value of the physical quantity + * \param value measured value of the physical quantity + * \param error estimated error of the physical quantity + * \param unit of the physical quantity, e.g. 'K'. + * \param description additional more detailed description of the physical quantity + */ +TMusrRunPhysicalQuantity::TMusrRunPhysicalQuantity(TString label, Double_t demand, Double_t value, Double_t error, TString unit, TString description) : + fLabel(label), fDemand(demand), fValue(value), fError(error), fUnit(unit) +{ + if (description.IsWhitespace()) + fDescription = "n/a"; + else + fDescription = description; +} + +//-------------------------------------------------------------------------- +// Constructor +//-------------------------------------------------------------------------- +/** + *

Constructor. + * + * \param label of the physical quantity, e.g. 'Sample Temperature' + * \param demand value of the physical quantity + * \param value measured value of the physical quantity + * \param unit of the physical quantity, e.g. 'K'. + * \param description additional more detailed description of the physical quantity + */ +TMusrRunPhysicalQuantity::TMusrRunPhysicalQuantity(TString label, Double_t demand, Double_t value, TString unit, TString description) : + fLabel(label), fDemand(demand), fValue(value), fUnit(unit) +{ + fError = MRH_UNDEFINED; + if (description.IsWhitespace()) + fDescription = "n/a"; + else + fDescription = description; +} + +//-------------------------------------------------------------------------- +// Constructor +//-------------------------------------------------------------------------- +/** + *

Constructor. + * + * \param label of the physical quantity, e.g. 'Sample Temperature' + * \param value measured value of the physical quantity + * \param unit of the physical quantity, e.g. 'K'. + * \param description additional more detailed description of the physical quantity + */ +TMusrRunPhysicalQuantity::TMusrRunPhysicalQuantity(TString label, Double_t value, TString unit, TString description) : + fLabel(label), fValue(value), fUnit(unit) +{ + fDemand = MRH_UNDEFINED; + fError = MRH_UNDEFINED; + if (description.IsWhitespace()) + fDescription = "n/a"; + else + fDescription = description; +} + +//-------------------------------------------------------------------------- +// Set (public) +//-------------------------------------------------------------------------- +/** + *

set a physical quantity. + * + * \param label of the physical quantity, e.g. 'Sample Temperature' + * \param demand value of the physical quantity + * \param value measured value of the physical quantity + * \param error estimated error of the physical quantity + * \param unit of the physical quantity, e.g. 'K'. + * \param description additional more detailed description of the physical quantity + */ +void TMusrRunPhysicalQuantity::Set(TString label, Double_t demand, Double_t value, Double_t error, TString unit, TString description) +{ + fLabel = label; + fDemand = demand; + fValue = value; + fError = error; + fUnit = unit; + if (description.IsWhitespace()) + fDescription = "n/a"; + else + fDescription = description; +} + +//-------------------------------------------------------------------------- +// Set (public) +//-------------------------------------------------------------------------- +/** + *

set a physical quantity. + * + * \param label of the physical quantity, e.g. 'Sample Temperature' + * \param demand value of the physical quantity + * \param value measured value of the physical quantity + * \param unit of the physical quantity, e.g. 'K'. + * \param description additional more detailed description of the physical quantity + */ +void TMusrRunPhysicalQuantity::Set(TString label, Double_t demand, Double_t value, TString unit, TString description) +{ + fLabel = label; + fDemand = demand; + fValue = value; + fError = MRH_UNDEFINED; + fUnit = unit; + if (description.IsWhitespace()) + fDescription = "n/a"; + else + fDescription = description; +} + +//-------------------------------------------------------------------------- +// Set (public) +//-------------------------------------------------------------------------- +/** + *

set a physical quantity. + * + * \param label of the physical quantity, e.g. 'Sample Temperature' + * \param value measured value of the physical quantity + * \param unit of the physical quantity, e.g. 'K'. + * \param description additional more detailed description of the physical quantity + */ +void TMusrRunPhysicalQuantity::Set(TString label, Double_t value, TString unit, TString description) +{ + fLabel = label; + fDemand = MRH_UNDEFINED; + fValue = value; + fError = MRH_UNDEFINED; + fUnit = unit; + if (description.IsWhitespace()) + fDescription = "n/a"; + else + fDescription = description; +} + +//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +ClassImp(TMusrRunHeader) + +//-------------------------------------------------------------------------- +// Constructor +//-------------------------------------------------------------------------- +/** + *

Constructor. + * + * \param quite if set to true, warnings will be omited. Default is false. + */ +TMusrRunHeader::TMusrRunHeader(bool quite) : fQuite(quite) +{ + Init(); +} + +//-------------------------------------------------------------------------- +// Constructor +//-------------------------------------------------------------------------- +/** + *

Constructor. + * + * \param fileName file name of the MusrRoot file. + * \param quite if set to true, warnings will be omited. Default is false. + */ +TMusrRunHeader::TMusrRunHeader(const char *fileName, bool quite) +{ + fQuite = quite; + Init(TString(fileName)); +} + +//-------------------------------------------------------------------------- +// Init (private) +//-------------------------------------------------------------------------- +/** + *

Initializer + * + * \param fileName file name of the caller. + */ +void TMusrRunHeader::Init(TString fileName) +{ + TMusrRunPhysicalQuantity prop; + + fFileName = fileName; + fVersion = TString("$Id: TMusrRunHeader.cpp 5092 2012-03-13 07:47:00Z nemu $"); + Set("RunInfo/Version", fVersion); + Set("RunInfo/Generic Validator URL", "http://lmu.web.psi.ch/facilities/software/MusrRoot/validation/MusrRoot.xsd"); + Set("RunInfo/Specific Validator URL", "n/a"); + Set("RunInfo/Generator", "n/a"); + Set("RunInfo/File Name", "n/a"); + Set("RunInfo/Run Title", "n/a"); + Set("RunInfo/Run Number", -1); + Set("RunInfo/Run Start Time", "1970-01-01 00:00:00"); + Set("RunInfo/Run Stop Time", "1970-01-01 00:00:00"); + prop.Set("Run Duration", 0.0, "sec"); + Set("RunInfo/Run Duration", prop); + Set("RunInfo/Laboratory", "n/a"); + Set("RunInfo/Area", "n/a"); + Set("RunInfo/Instrument", "n/a"); + prop.Set("Muon Beam Momentum", 0.0, "MeV/c"); + Set("RunInfo/Muon Beam Momentum", prop); + Set("RunInfo/Muon Species", "n/a"); + Set("RunInfo/Muon Source", "n/a"); + Set("RunInfo/Setup", "n/a"); + Set("RunInfo/Comment", "n/a"); + Set("RunInfo/Sample Name", "n/a"); + prop.Set("Sample Temperature", 0.0, "K"); + Set("RunInfo/Sample Temperature", prop); + prop.Set("Sample Magnetic Field", 1000.0, "T"); + Set("RunInfo/Sample Magnetic Field", prop); + Set("RunInfo/No of Histos", 0); + prop.Set("Time Resolution", 0.0, "ns"); + Set("RunInfo/Time Resolution", prop); + vector ivec; + ivec.push_back(0); + Set("RunInfo/RedGreen Offset", ivec); + + Set("DetectorInfo/Detector001/Name", "n/a"); + Set("DetectorInfo/Detector001/Histo Number", 0); + Set("DetectorInfo/Detector001/Histo Length", 0); + Set("DetectorInfo/Detector001/Time Zero Bin", 0); + Set("DetectorInfo/Detector001/First Good Bin", 0); + Set("DetectorInfo/Detector001/Last Good Bin", 0); + + Set("SampleEnvironmentInfo/Cryo", "n/a"); + + Set("MagneticFieldEnvironmentInfo/Magnet Name", "n/a"); + + Set("BeamlineInfo/Name", "n/a"); +} + +//-------------------------------------------------------------------------- +// Destructor +//-------------------------------------------------------------------------- +/** + *

Destructor. + */ +TMusrRunHeader::~TMusrRunHeader() +{ + CleanUp(); +} + +//-------------------------------------------------------------------------- +// CleanUp (private) +//-------------------------------------------------------------------------- +/** + *

Clean up internal stuff. + */ +void TMusrRunHeader::CleanUp() +{ + fStringObj.clear(); + fIntObj.clear(); + fDoubleObj.clear(); + fMusrRunPhysQuantityObj.clear(); + fStringVectorObj.clear(); + fIntVectorObj.clear(); + fDoubleVectorObj.clear(); + + fPathNameOrder.clear(); +} + +//-------------------------------------------------------------------------- +// FillFolder (public) +//-------------------------------------------------------------------------- +/** + *

Fills the RunHeader folder. This is needed to write it to a ROOT file. + * It walks through all information and attaches it to the folder or replaces + * it, if it is already present. + * + * \param folder to be filled + */ +Bool_t TMusrRunHeader::FillFolder(TFolder *folder) +{ + TObjArray *oarray; + TObjString ostr, *p_ostr; + TString path, name, str; + Ssiz_t pos=0; + bool found=false; + + if (folder == 0) { + cerr << endl << ">> TMusrRunHeader::FillFolder(): **ERROR** folder == 0!!" << endl; + return false; + } + + folder->SetOwner(); // folder takes ownership of all added objects! This means that the folder object does the cleanup + + // update/generate tree structure in folder + for (UInt_t i=0; i> TMusrRunHeader::FillFolder(): **ERROR** somethig is wrong with the path=" << path << " !!" << endl; + return false; + } + path.Remove(pos); // remove the value from the path + + oarray = (TObjArray*)FindObject(folder, path); + if (!oarray) { + cerr << endl << ">> TMusrRunHeader::FillFolder(): **ERROR** couldn't create header structure!!" << endl; + return false; + } + + // check if is already found in oarray + ostr = GetHeaderString(i); // encode the string for the MusrRoot file + name = ostr.GetString(); // convert to TString + str = GetFirst(name, ':'); // get the first part of the encoded string, i.e. - + found = false; + for (Int_t j=0; jGetEntriesFast(); j++) { + p_ostr = (TObjString*) oarray->At(j); + if (p_ostr->GetString().BeginsWith(str)) { // present hence replace + oarray->AddAt(ostr.Clone(), j); + found = true; + break; + } + } + if (!found) { + oarray->AddLast(ostr.Clone()); + } + } + + return true; +} + +//-------------------------------------------------------------------------- +// Get (public) +//-------------------------------------------------------------------------- +/** + *

Get TString 'value'. + * + * \param pathName path/name within the header, e.g. RunInfo/Run Title + * \param value TString return value + * \param ok flag telling if the TString value was found + */ +void TMusrRunHeader::Get(TString pathName, TString &value, Bool_t &ok) +{ + ok = false; + + for (UInt_t i=0; iGet Int_t 'value'. + * + * \param pathName path/name within the header, e.g. RunInfo/Run Number + * \param value Int_t return value + * \param ok flag telling if the Int_t value was found + */ +void TMusrRunHeader::Get(TString pathName, Int_t &value, Bool_t &ok) +{ + ok = false; + + for (UInt_t i=0; iGet Double_t 'value'. + * + * \param pathName path/name within the header, e.g. RunInfo/Time Zero Bin + * \param value Double_t return value + * \param ok flag telling if the Double_t value was found + */ +void TMusrRunHeader::Get(TString pathName, Double_t &value, Bool_t &ok) +{ + ok = false; + + for (UInt_t i=0; iGet TMusrRunPhysicalQuantity 'value'. + * + * \param pathName path/name within the header, e.g. RunInfo/Run Title + * \param value TMusrRunPhysicalQuantity return value + * \param ok flag telling if the TMusrRunPhysicalQuantity value was found + */ +void TMusrRunHeader::Get(TString pathName, TMusrRunPhysicalQuantity &value, Bool_t &ok) +{ + ok = false; + + for (UInt_t i=0; iGet TStringVector 'value'. + * + * \param pathName path/name within the header, e.g. RunInfo/Run Title + * \param value TStringVector return value + * \param ok flag telling if the TStringVector value was found + */ +void TMusrRunHeader::Get(TString pathName, TStringVector &value, Bool_t &ok) +{ + ok = false; + + for (UInt_t i=0; iGet TIntVector 'value'. + * + * \param pathName path/name within the header, e.g. RunInfo/Run Title + * \param value TIntVector return value + * \param ok flag telling if the TIntVector value was found + */ +void TMusrRunHeader::Get(TString pathName, TIntVector &value, Bool_t &ok) +{ + ok = false; + + for (UInt_t i=0; iGet TDoubleVector 'value'. + * + * \param pathName path/name within the header, e.g. RunInfo/Run Title + * \param value TDoubleVector return value + * \param ok flag telling if the TDoubleVector value was found + */ +void TMusrRunHeader::Get(TString pathName, TDoubleVector &value, Bool_t &ok) +{ + ok = false; + + for (UInt_t i=0; iSet TString 'value'. + * + * \param pathName path/name within the header, e.g. RunInfo/Run Title + * \param value of the entry + */ +void TMusrRunHeader::Set(TString pathName, TString value) +{ + // check if pathName is already set, if not add it as a new entry, otherwise replace it + UInt_t i=0; + for (i=0; i> **WARNING** " << pathName.Data() << " already exists, will replace it." << endl; + fStringObj[i].SetType("TString"); + fStringObj[i].SetValue(value); + break; + } + } + + // if not found in the previous loop, it is a new object + if (i == fStringObj.size()) { + // feed object + TMusrRunObject obj(pathName, "TString", value); + fStringObj.push_back(obj); + + // feed path-name to keep track of the order + fPathNameOrder.push_back(pathName); + } +} + +//-------------------------------------------------------------------------- +// Set (public) +//-------------------------------------------------------------------------- +/** + *

Set Int_t 'value'. + * + * \param pathName path/name within the header, e.g. RunInfo/Run number + * \param value of the entry + */ +void TMusrRunHeader::Set(TString pathName, Int_t value) +{ + // check if pathName is already set, if not add it as a new entry, otherwise replace it + UInt_t i=0; + for (i=0; i> **WARNING** " << pathName.Data() << " already exists, will replace it." << endl; + fIntObj[i].SetType("Int_t"); + fIntObj[i].SetValue(value); + break; + } + } + + // if not found in the previous loop, it is a new object + if (i == fIntObj.size()) { + // feed object + TMusrRunObject obj(pathName, "Int_t", value); + fIntObj.push_back(obj); + + // feed path-name to keep track of the order + fPathNameOrder.push_back(pathName); + } +} + +//-------------------------------------------------------------------------- +// Set (public) +//-------------------------------------------------------------------------- +/** + *

Set Double_t 'value'. + * + * \param pathName path/name within the header, e.g. RunInfo/DoubleValue + * \param value of the entry + */ +void TMusrRunHeader::Set(TString pathName, Double_t value) +{ + // check if pathName is already set, if not add it as a new entry, otherwise replace it + UInt_t i=0; + for (i=0; i> **WARNING** " << pathName.Data() << " already exists, will replace it." << endl; + fDoubleObj[i].SetType("Double_t"); + fDoubleObj[i].SetValue(value); + break; + } + } + + // if not found in the previous loop, it is a new object + if (i == fDoubleObj.size()) { + // feed object + TMusrRunObject obj(pathName, "Double_t", value); + fDoubleObj.push_back(obj); + + // feed path-name to keep track of the order + fPathNameOrder.push_back(pathName); + } +} + +//-------------------------------------------------------------------------- +// Set (public) +//-------------------------------------------------------------------------- +/** + *

Set TMusrRunPhysicalQuantity 'value'. + * + * \param pathName path/name within the header, e.g. RunInfo/Muon Beam Momentum + * \param value of the entry + */ +void TMusrRunHeader::Set(TString pathName, TMusrRunPhysicalQuantity value) +{ + // check if pathName is already set, if not add it as a new entry, otherwise replace it + UInt_t i=0; + for (i=0; i> **WARNING** " << pathName.Data() << " already exists, will replace it." << endl; + fMusrRunPhysQuantityObj[i].SetType("TMusrRunHeader"); + fMusrRunPhysQuantityObj[i].SetValue(value); + break; + } + } + + // if not found in the previous loop, it is a new object + if (i == fMusrRunPhysQuantityObj.size()) { + // feed object + TMusrRunObject obj(pathName, "TMusrRunPhysicalQuantity", value); + fMusrRunPhysQuantityObj.push_back(obj); + + // feed path-name to keep track of the order + fPathNameOrder.push_back(pathName); + } +} + +//-------------------------------------------------------------------------- +// Set (public) +//-------------------------------------------------------------------------- +/** + *

Set TStringVector 'value'. + * + * \param pathName path/name within the header, e.g. RunInfo/Histo names + * \param value of the entry + */ +void TMusrRunHeader::Set(TString pathName, TStringVector value) +{ + // check if pathName is already set, if not add it as a new entry, otherwise replace it + UInt_t i=0; + for (i=0; i> **WARNING** " << pathName.Data() << " already exists, will replace it." << endl; + fStringVectorObj[i].SetType("TStringVector"); + fStringVectorObj[i].SetValue(value); + break; + } + } + + // if not found in the previous loop, it is a new object + if (i == fStringVectorObj.size()) { + // feed object + TMusrRunObject obj(pathName, "TStringVector", value); + fStringVectorObj.push_back(obj); + + // feed path-name to keep track of the order + fPathNameOrder.push_back(pathName); + } +} + +//-------------------------------------------------------------------------- +// Set (public) +//-------------------------------------------------------------------------- +/** + *

Set TIntVector 'value'. + * + * \param pathName path/name within the header, e.g. RunInfo/Time Zero Bin + * \param value of the entry + */ +void TMusrRunHeader::Set(TString pathName, TIntVector value) +{ + // check if pathName is already set, if not add it as a new entry, otherwise replace it + UInt_t i=0; + for (i=0; i> **WARNING** " << pathName.Data() << " already exists, will replace it." << endl; + fIntVectorObj[i].SetType("TIntVector"); + fIntVectorObj[i].SetValue(value); + break; + } + } + + // if not found in the previous loop, it is a new object + if (i == fIntVectorObj.size()) { + // feed object + TMusrRunObject obj(pathName, "TIntVector", value); + fIntVectorObj.push_back(obj); + + // feed path-name to keep track of the order + fPathNameOrder.push_back(pathName); + } +} + +//-------------------------------------------------------------------------- +// Set (public) +//-------------------------------------------------------------------------- +/** + *

Set TDoubleVector 'value'. + * + * \param pathName path/name within the header, e.g. RunInfo/Time Zero Bin + * \param value of the entry + */ +void TMusrRunHeader::Set(TString pathName, TDoubleVector value) +{ + // check if pathName is already set, if not add it as a new entry, otherwise replace it + UInt_t i=0; + for (i=0; i> **WARNING** " << pathName.Data() << " already exists, will replace it." << endl; + fDoubleVectorObj[i].SetType("TDoubleVector"); + fDoubleVectorObj[i].SetValue(value); + break; + } + } + + // if not found in the previous loop, it is a new object + if (i == fDoubleVectorObj.size()) { + // feed object + TMusrRunObject obj(pathName, "TDoubleVector", value); + fDoubleVectorObj.push_back(obj); + + // feed path-name to keep track of the order + fPathNameOrder.push_back(pathName); + } +} + + +//-------------------------------------------------------------------------- +// ExtractAll (public) +//-------------------------------------------------------------------------- +/** + *

Reads all data from an open ROOT-file structure and feeds all the necessary + * internal data objects. + * + * \param folder + */ +Bool_t TMusrRunHeader::ExtractAll(TFolder *folder) +{ + TIter next(folder->GetListOfFolders()); + TObjArray* entry; + + // clean up all internal structures - just in case this is called multiple times + CleanUp(); + + while ((entry = (TObjArray*)next())) { + ExtractHeaderInformation(entry, entry->GetName()); + } + return true; +} + +//-------------------------------------------------------------------------- +// ExtractHeaderInformation (public) +//-------------------------------------------------------------------------- +/** + *

+ * + * \param headerInfo + * \param requestedPath + */ +Bool_t TMusrRunHeader::ExtractHeaderInformation(TObjArray *headerInfo, TString requestedPath) +{ + TString label(""), path(""), pathName(""), str(""), strValue(""), type(""); + TObjString *ostr = 0; + TObjArray *tokens = 0; + Ssiz_t idx1; + Int_t intValue; + Double_t dval; + + // go through all entries of this header information from the MUSR-ROOT file + for (Int_t i=0; iGetEntries(); i++) { + // check if entry is a TObjArray, i.e. a sub tree + str = TString(headerInfo->At(i)->ClassName()); + if (str == "TObjArray") { // sub tree + path = requestedPath + "/" + TString(headerInfo->At(i)->GetName()); + ExtractHeaderInformation((TObjArray*)headerInfo->At(i), path); + } else { // handle all the rest, i.e. already data + + ostr = dynamic_cast(headerInfo->At(i)); + str = ostr->GetString(); + + // get the run header label + label = GetLabel(str); + if (label == "n/a") + return false; + + // get the run header 'value' + strValue = GetStrValue(str); + + // construct path name + pathName = requestedPath + TString("/") + label; + + // get type from map + type = GetType(str); + + if (type == "TString") { + Set(pathName, strValue); + } else if (type == "Int_t") { + intValue = strValue.Atoi(); + Set(pathName, intValue); + } else if (type == "Double_t") { + dval = strValue.Atof(); + Set(pathName, dval); + } else if (type == "TMusrRunPhysicalQuantity") { + TMusrRunPhysicalQuantity prop; + prop.SetLabel(label); + + // 1st get the description if present + tokens = strValue.Tokenize(";"); + if (tokens == 0) { + cerr << endl << ">> **ERROR** Couldn't tokenize entry in Bool_t TMusrRunHeader::ExtractHeaderInformation(TObjArray *headerInfo, TString requestedPath)" << endl; + return false; + } + + switch (tokens->GetEntries()) { + case 2: + ostr = dynamic_cast(tokens->At(1)); + str = ostr->GetString(); + if (!str.Contains("SP:")) { // make sure that it is not a demand value token + prop.SetDescription(str); + } + break; + case 3: + ostr = dynamic_cast(tokens->At(2)); + str = ostr->GetString(); + break; + default: + break; + } + + if (tokens) { + delete tokens; + tokens = 0; + } + + // 2nd collect all the other properties, this is easier when first a potential description is removed + idx1 = strValue.Last(';'); + if (idx1 > 0) { + TString last(""); + for (Int_t i=idx1+2; i or SP: + if (!last.Contains("SP:")) { + str = ""; + for (Int_t i=0; i> **ERROR** Couldn't tokenize entry in Bool_t TMusrRunHeader::ExtractHeaderInformation(TObjArray *headerInfo, TString requestedPath)" << endl; + return false; + } + + switch (tokens->GetEntries()) { + case 2: // + ostr = dynamic_cast(tokens->At(0)); + str = ostr->GetString(); + prop.SetValue(str.Atof()); + ostr = dynamic_cast(tokens->At(1)); + str = ostr->GetString(); + prop.SetUnit(str); + break; + case 4: // +- , or ; SP: + ostr = dynamic_cast(tokens->At(0)); + str = ostr->GetString(); + prop.SetValue(str.Atof()); + ostr = dynamic_cast(tokens->At(1)); + str = ostr->GetString(); + if (str == "-") { // +- + ostr = dynamic_cast(tokens->At(2)); + str = ostr->GetString(); + prop.SetError(str.Atof()); + ostr = dynamic_cast(tokens->At(3)); + str = ostr->GetString(); + prop.SetUnit(str); + } else { // ; SP: + prop.SetUnit(str); + ostr = dynamic_cast(tokens->At(3)); + str = ostr->GetString(); + prop.SetDemand(str.Atof()); + } + break; + case 6: // +- ; SP: + ostr = dynamic_cast(tokens->At(0)); + str = ostr->GetString(); + prop.SetValue(str.Atof()); + ostr = dynamic_cast(tokens->At(2)); + str = ostr->GetString(); + prop.SetError(str.Atof()); + ostr = dynamic_cast(tokens->At(3)); + str = ostr->GetString(); + prop.SetUnit(str); + ostr = dynamic_cast(tokens->At(5)); + str = ostr->GetString(); + prop.SetDemand(str.Atof()); + break; + default: + break; + } + + if (tokens) { + delete tokens; + tokens = 0; + } + + Set(pathName, prop); + } else if (type == "TStringVector") { + TStringVector svec; + tokens = strValue.Tokenize(";"); + if (tokens == 0) { + cerr << endl << ">> **ERROR** Couldn't tokenize entry in Bool_t TMusrRunHeader::ExtractHeaderInformation(TObjArray *headerInfo, TString requestedPath)" << endl; + return false; + } + for (Int_t i=0; iGetEntries(); i++) { + ostr = dynamic_cast(tokens->At(i)); + str = ostr->GetString(); + str.Remove(TString::kBoth, ' '); + svec.push_back(str); + } + if (tokens) { + delete tokens; + tokens = 0; + } + Set(pathName, svec); + } else if (type == "TIntVector") { + TIntVector ivec; + tokens = strValue.Tokenize(";"); + if (tokens == 0) { + cerr << endl << ">> **ERROR** Couldn't tokenize entry in Bool_t TMusrRunHeader::ExtractHeaderInformation(TObjArray *headerInfo, TString requestedPath)" << endl; + return false; + } + for (Int_t i=0; iGetEntries(); i++) { + ostr = dynamic_cast(tokens->At(i)); + ivec.push_back(ostr->GetString().Atoi()); + } + if (tokens) { + delete tokens; + tokens = 0; + } + Set(pathName, ivec); + } else if (type == "TDoubleVector") { + TDoubleVector dvec; + tokens = strValue.Tokenize(";"); + if (tokens == 0) { + cerr << endl << ">> **ERROR** Couldn't tokenize entry in Bool_t TMusrRunHeader::ExtractHeaderInformation(TObjArray *headerInfo, TString requestedPath)" << endl; + return false; + } + for (Int_t i=0; iGetEntries(); i++) { + ostr = dynamic_cast(tokens->At(i)); + dvec.push_back(ostr->GetString().Atoi()); + } + if (tokens) { + delete tokens; + tokens = 0; + } + Set(pathName, dvec); + } + } + } + + return true; +} + +//-------------------------------------------------------------------------- +// DumpHeader (public) +//-------------------------------------------------------------------------- +/** + *

+ */ +void TMusrRunHeader::DumpHeader() +{ + cout << endl << "***************************************"; + cout << endl << "header info of file : " << fFileName; + cout << endl << "***************************************"; + + TString str(""), tstr(""), fmt(""), path(""), name(""), currentPath(""); + TMusrRunPhysicalQuantity prop; + + for (UInt_t i=0; i +- ; SP: [; ] + digit = GetDecimalPlace(prop.GetError()); + digit_d = GetLeastSignificantDigit(prop.GetDemand()); + if (prop.GetDescription() != "n/a") { + fmt.Form("%%s: %%.%dlf +- %%.%dlf %%s; SP: %%.%dlf; %%s", digit, digit, digit_d); + + tstr.Form(fmt, prop.GetLabel().Data(), prop.GetValue(), prop.GetError(), prop.GetUnit().Data(), prop.GetDemand(), prop.GetDescription().Data()); + } else { + fmt.Form("%%s: %%.%dlf +- %%.%dlf %%s; SP: %%.%dlf", digit, digit, digit_d); + tstr.Form(fmt, prop.GetLabel().Data(), prop.GetValue(), prop.GetError(), prop.GetUnit().Data(), prop.GetDemand()); + } + } else if ((prop.GetDemand() == MRH_UNDEFINED) && (prop.GetValue() != MRH_UNDEFINED) && (prop.GetError() != MRH_UNDEFINED) && + (prop.GetUnit() != "n/a")) { // +- [; ] + digit = GetDecimalPlace(prop.GetError()); + if (prop.GetDescription() != "n/a") { + fmt.Form("%%s: %%.%dlf +- %%.%dlf %%s; %%s", digit, digit); + tstr.Form(fmt, prop.GetLabel().Data(), prop.GetValue(), prop.GetError(), prop.GetUnit().Data(), prop.GetDescription().Data()); + } else { + fmt.Form("%%s: %%.%dlf +- %%.%dlf %%s", digit, digit); + tstr.Form(fmt, prop.GetLabel().Data(), prop.GetValue(), prop.GetError(), prop.GetUnit().Data()); + } + } else if ((prop.GetDemand() == MRH_UNDEFINED) && (prop.GetValue() != MRH_UNDEFINED) && (prop.GetError() == MRH_UNDEFINED) && + (prop.GetUnit() != "n/a")) { // [; ] + digit = GetLeastSignificantDigit(prop.GetValue()); + if (prop.GetDescription() != "n/a") { + fmt.Form("%%s: %%.%dlf %%s; %%s", digit); + tstr.Form(fmt, prop.GetLabel().Data(), prop.GetValue(), prop.GetUnit().Data(), prop.GetDescription().Data()); + } else { + fmt.Form("%%s: %%.%dlf %%s", digit); + tstr.Form(fmt, prop.GetLabel().Data(), prop.GetValue(), prop.GetUnit().Data()); + } + } else if ((prop.GetDemand() != MRH_UNDEFINED) && (prop.GetValue() != MRH_UNDEFINED) && (prop.GetError() == MRH_UNDEFINED) && + (prop.GetUnit() != "n/a")) { // ; SP: [; ] + digit = GetLeastSignificantDigit(prop.GetValue()); + digit_d = GetLeastSignificantDigit(prop.GetDemand()); + if (prop.GetDescription() != "n/a") { + fmt.Form("%%s: %%.%dlf %%s; SP: %%.%dlf; %%s", digit, digit_d); + tstr.Form(fmt, prop.GetLabel().Data(), prop.GetValue(), prop.GetUnit().Data(), prop.GetDemand(), prop.GetDescription().Data()); + } else { + fmt.Form("%%s: %%.%dlf %%s; SP: %%.%dlf", digit, digit_d); + tstr.Form(fmt, prop.GetLabel().Data(), prop.GetValue(), prop.GetUnit().Data(), prop.GetDemand()); + } + } + str.Form(" %03d - %s -@%d", i, tstr.Data(), MRH_TMUSR_RUN_PHYSICAL_QUANTITY); + cout << endl << str; + } + } + // 5th check TStringVector + for (UInt_t j=0; j + */ +void TMusrRunHeader::DrawHeader() +{ + TPaveText *pt; + TCanvas *ca; + + ca = new TCanvas("MusrRoot RunHeader","MusrRoot RunHeader", 147,37,699,527); + ca->Range(0., 0., 100., 100.); + + pt = new TPaveText(10.,10.,90.,90.,"br"); + pt->SetFillColor(19); + pt->SetTextAlign(12); + + pt->Draw(); + + ca->Modified(kTRUE); +} + +//-------------------------------------------------------------------------- +// GetDecimalPlace (private) +//-------------------------------------------------------------------------- +/** + *

Check decimal place of val. If val > 1.0, the function will return 0, otherwise + * the first decimal place found will be returned. + * + * \param val value from which the first significant digit shall be determined + */ +UInt_t TMusrRunHeader::GetDecimalPlace(Double_t val) +{ + UInt_t digit = 0; + + if (val < 1.0) { + UInt_t count=1; + do { + val *= 10.0; + if (val > 1.0) + digit = count; + count++; + } while ((digit == 0) && (count < 20)); + } + + return digit; +} + +//-------------------------------------------------------------------------- +// GetLeastSignificantDigit (private) +//-------------------------------------------------------------------------- +/** + *

returns the number of significant digits + * + * \param val value from which the lowest significant digit shall be determined + */ +UInt_t TMusrRunHeader::GetLeastSignificantDigit(Double_t val) const +{ + char cstr[1024]; + snprintf(cstr, sizeof(cstr), "%.10lf", val); + + int i=0, j=0; + for (i=strlen(cstr)-1; i>=0; i--) { + if (cstr[i] != '0') + break; + } + + for (j=strlen(cstr)-1; j>=0; j--) { + if (cstr[j] == '.') + break; + } + if (j==0) // no decimal point present, e.g. 321 + j=i; + + return i-j; +} + +//-------------------------------------------------------------------------- +// SplitPathName (private) +//-------------------------------------------------------------------------- +/** + *

splits a path name string into the path and the name. + * + * \param pathName path name to be split + * \param path of pathName + * \param name of pathName + */ +void TMusrRunHeader::SplitPathName(TString pathName, TString &path, TString &name) +{ + path = TString(""); + name = TString(""); + Ssiz_t idx = pathName.Last('/'); + + for (Int_t i=0; iextracts form the run header line, as written to the MusrROOT file, the run header label, e.g. Run Number. + * + * \param str runHeader string as written to the MusrROOT file. + */ +TString TMusrRunHeader::GetLabel(TString str) +{ + // get run header label + // the string 'str' should have the structure + // - : -@ + + TString label = TString("n/a"); + Ssiz_t idx1 = str.First('-'); + Ssiz_t idx2 = str.First(':'); + if ((idx1 == -1) || (idx2 == -1)) { + cerr << endl << ">> TMusrRunHeader::GetLabel(): **ERROR** str='" << str << "', seems not correctly encoded." << endl; + return label; + } + + label = TString(""); + for (Int_t j=idx1+2; jextracts form the run header line, as written to the MusrROOT file, the run header str value, e.g. 557 (for Run Number). + * + * \param str runHeader string as written to the MusrROOT file. + */ +TString TMusrRunHeader::GetStrValue(TString str) +{ + // get run header string value + // the string 'str' should have the structure + // - : -@ + + TString strValue = TString("n/a"); + Ssiz_t idx1 = str.First(':'); + Ssiz_t idx2 = str.Last('-'); + if ((idx1 == -1) || (idx2 == -1)) { + cerr << endl << ">> TMusrRunHeader::GetStrValue(): **ERROR** str='" << str << "', seems not correctly encoded." << endl; + return strValue; + } + + strValue = TString(""); + for (Int_t j=idx1+2; jextracts form the run header line, as written to the MusrROOT file, the encoded type and retruns it. + * + * \param str runHeader string with encoded type + */ +TString TMusrRunHeader::GetType(TString str) +{ + TString result = "n/a"; + + // the string 'str' should have the structure + // - : -@ + Ssiz_t pos = str.Last('@'); + + if (pos == -1) { // i.e. NOT found + cerr << endl << ">> TMusrRunHeader::GetType(): **ERROR** str=" << str << " seems to be an invalid MusrROOT run header string." << endl; + return result; + } + + // filter out the encoded type declaration, i.e. -@, where is the encoded type + TString typeStr(str); + typeStr.Remove(0, pos+1); + Int_t typeVal; + if (!typeStr.IsDigit()) { + cerr << endl << ">> TMusrRunHeader::GetType(): **ERROR** typeStr=" << typeStr << " is not supported." << endl; + return result; + } + + typeVal = typeStr.Atoi(); + + switch (typeVal) { + case MRH_TSTRING: + result = "TString"; + break; + case MRH_INT: + result = "Int_t"; + break; + case MRH_DOUBLE: + result = "Double_t"; + break; + case MRH_TMUSR_RUN_PHYSICAL_QUANTITY: + result = "TMusrRunPhysicalQuantity"; + break; + case MRH_TSTRING_VECTOR: + result = "TStringVector"; + break; + case MRH_INT_VECTOR: + result = "TIntVector"; + break; + case MRH_DOUBLE_VECTOR: + result = "TDoubleVector"; + break; + default: + cerr << endl << ">> TMusrRunHeader::GetType(): **ERROR** found unsupport type encoded with: " << typeVal << "." << endl; + break; + } + + return result; +} + +//-------------------------------------------------------------------------- +// UpdateFolder (private) +//-------------------------------------------------------------------------- +/** + *

Update folder structure + * + *

return: + * - true if everything is all right + * - false otherwise + * + * \param treeObj to be updated + * \param path to be added within 'treeObj' + */ +bool TMusrRunHeader::UpdateFolder(TObject *treeObj, TString path) +{ + if (path.First('/') == -1) // only value element left, hence nothing to be done + return true; + + TString str = GetFirst(path, '/'); + + TObject *obj = treeObj->FindObject(str); + + // remove the first path element + if (!RemoveFirst(path, '/')) { + cerr << endl << ">> TMusrRunHeader::FillFolder(): **ERROR** couldn't tokenize path!!" << endl; + return false; + } + + if (!obj) { // required object not present, create it + TObjArray *oarray = new TObjArray(); + if (!oarray) { + cerr << endl << ">> TMusrRunHeader::FillFolder(): **ERROR** couldn't create header structure!!" << endl; + return false; + } + // set the name of the new TObjArray + oarray->SetName(str); + + if (!strcmp(treeObj->ClassName(), "TFolder")) + ((TFolder*)treeObj)->Add(oarray); + else // it is a TObjArray + ((TObjArray*)treeObj)->AddLast(oarray); + + return UpdateFolder(oarray, path); + } else { // object present, hence check rest of the path + return UpdateFolder(obj, path); + } +} + +//-------------------------------------------------------------------------- +// FindObject (private) +//-------------------------------------------------------------------------- +/** + *

Check if 'path' is present in 'treeObj' + * + *

return: + * - pointer to the 'path' object if present + * - otherwise return 0 + * + * \param treeObj to be searched + * \param path searched for within 'treeObj' + */ +TObject* TMusrRunHeader::FindObject(TObject *treeObj, TString path) +{ + Ssiz_t pos; + TObject *obj=0; + + // make sure that treeObj is either TFolder or TObjArray + if (strcmp(treeObj->ClassName(), "TFolder") && strcmp(treeObj->ClassName(), "TObjArray")) + return obj; + + pos = path.First('/'); + if (pos == -1) { // i.e. no sub-paths anymore + obj = treeObj->FindObject(path); + return obj; + } else { // sub-paths present + TString objName = GetFirst(path, '/'); // get first token of the path //.../ + obj = treeObj->FindObject(objName); + if (obj) { // object found, check for subPath object + RemoveFirst(path, '/'); // remove first tokens of the path + return FindObject(obj, path); + } else { // object not found + return obj; + } + } +} + +//-------------------------------------------------------------------------- +// GetHeaderString (private) +//-------------------------------------------------------------------------- +/** + *

+ * + * \param pathName + */ +TObjString TMusrRunHeader::GetHeaderString(UInt_t idx) +{ + TObjString tostr("n/a"); + + TString str(""), path(""), name(""), fmt(""), tstr(""); + TMusrRunPhysicalQuantity prop; + + // go through all objects and try to find it + // 1st check TString + for (UInt_t j=0; j +- ; SP: [; ] + digit = GetDecimalPlace(prop.GetError()); + digit_d = GetLeastSignificantDigit(prop.GetDemand()); + if (prop.GetDescription() != "n/a") { + fmt.Form("%%s: %%.%dlf +- %%.%dlf %%s; SP: %%.%dlf; %%s", digit, digit, digit_d); + + tstr.Form(fmt, prop.GetLabel().Data(), prop.GetValue(), prop.GetError(), prop.GetUnit().Data(), prop.GetDemand(), prop.GetDescription().Data()); + } else { + fmt.Form("%%s: %%.%dlf +- %%.%dlf %%s; SP: %%.%dlf", digit, digit, digit_d); + tstr.Form(fmt, prop.GetLabel().Data(), prop.GetValue(), prop.GetError(), prop.GetUnit().Data(), prop.GetDemand()); + } + } else if ((prop.GetDemand() == MRH_UNDEFINED) && (prop.GetValue() != MRH_UNDEFINED) && (prop.GetError() != MRH_UNDEFINED) && + (prop.GetUnit() != "n/a")) { // +- [; ] + digit = GetDecimalPlace(prop.GetError()); + if (prop.GetDescription() != "n/a") { + fmt.Form("%%s: %%.%dlf +- %%.%dlf %%s; %%s", digit, digit); + tstr.Form(fmt, prop.GetLabel().Data(), prop.GetValue(), prop.GetError(), prop.GetUnit().Data(), prop.GetDescription().Data()); + } else { + fmt.Form("%%s: %%.%dlf +- %%.%dlf %%s", digit, digit); + tstr.Form(fmt, prop.GetLabel().Data(), prop.GetValue(), prop.GetError(), prop.GetUnit().Data()); + } + } else if ((prop.GetDemand() == MRH_UNDEFINED) && (prop.GetValue() != MRH_UNDEFINED) && (prop.GetError() == MRH_UNDEFINED) && + (prop.GetUnit() != "n/a")) { // [; ] + digit = GetLeastSignificantDigit(prop.GetValue()); + if (prop.GetDescription() != "n/a") { + fmt.Form("%%s: %%.%dlf %%s; %%s", digit); + tstr.Form(fmt, prop.GetLabel().Data(), prop.GetValue(), prop.GetUnit().Data(), prop.GetDescription().Data()); + } else { + fmt.Form("%%s: %%.%dlf %%s", digit); + tstr.Form(fmt, prop.GetLabel().Data(), prop.GetValue(), prop.GetUnit().Data()); + } + } else if ((prop.GetDemand() != MRH_UNDEFINED) && (prop.GetValue() != MRH_UNDEFINED) && (prop.GetError() == MRH_UNDEFINED) && + (prop.GetUnit() != "n/a")) { // ; SP: [; ] + digit = GetLeastSignificantDigit(prop.GetValue()); + digit_d = GetLeastSignificantDigit(prop.GetDemand()); + if (prop.GetDescription() != "n/a") { + fmt.Form("%%s: %%.%dlf %%s; SP: %%.%dlf; %%s", digit, digit_d); + tstr.Form(fmt, prop.GetLabel().Data(), prop.GetValue(), prop.GetUnit().Data(), prop.GetDemand(), prop.GetDescription().Data()); + } else { + fmt.Form("%%s: %%.%dlf %%s; SP: %%.%dlf", digit, digit_d); + tstr.Form(fmt, prop.GetLabel().Data(), prop.GetValue(), prop.GetUnit().Data(), prop.GetDemand()); + } + } + str.Form("%03d - %s -@%d", idx, tstr.Data(), MRH_TMUSR_RUN_PHYSICAL_QUANTITY); + tostr.SetString(str); + } + } + // 5th check TStringVector + for (UInt_t j=0; jRemoves the first junk of a string up to 'splitter'. If 'splitter' is + * NOT present in the string, the string stays untouched and the routine + * returns false. + * + * \param str string to be truncated + * \param splitter the start of the string up to the splitter character removed + */ +bool TMusrRunHeader::RemoveFirst(TString &str, const char splitter) +{ + Ssiz_t idx = str.First(splitter); + if (idx == -1) + return false; + + str.Remove(0, idx+1); + + return true; +} + +//-------------------------------------------------------------------------- +// GetFirst (private) +//-------------------------------------------------------------------------- +/** + *

Assuming a string built like 'this/is/a/string:with:diffrent:splitters'. + * Using as splitter '/', this routine would return 'this', it means get from str + * everything up to the first occurance of splitter. If splitter would be ':' + * in this example, the return string would be 'this/is/a/string'. + * + *

If splitter is not present in str the original str is returned. + * + *

return: first part of up to the splitter in struct + * + * \param str + * \param splitter + */ +TString TMusrRunHeader::GetFirst(TString &str, const char splitter) +{ + TString result = str; + + Ssiz_t idx = str.First(splitter); + if (idx != -1) + result.Remove(idx, str.Length()); + + return result; +} + +// end --------------------------------------------------------------------- diff --git a/src/external/MusrRoot/TMusrRunHeader.h b/src/external/MusrRoot/TMusrRunHeader.h new file mode 100644 index 00000000..0e18acf7 --- /dev/null +++ b/src/external/MusrRoot/TMusrRunHeader.h @@ -0,0 +1,196 @@ +/*************************************************************************** + + TMusrRunHeader.h + + Author: Andreas Suter + e-mail: andreas.suter@psi.ch + + $Id: TMusrRunHeader.h 5092 2012-03-13 07:47:00Z nemu $ + +***************************************************************************/ + +/*************************************************************************** + * Copyright (C) 2007-2012 by Andreas Suter * + * andreas.suter@psi.ch * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef TMUSRRUNHEADER_H +#define TMUSRRUNHEADER_H + +#include +using namespace std; + +#include +#include +#include +#include +#include +#include + +#define MRH_UNDEFINED -9.99e99 + +#define MRH_DOUBLE_PREC 6 + +#define MRH_TSTRING 0 +#define MRH_INT 1 +#define MRH_DOUBLE 2 +#define MRH_TMUSR_RUN_PHYSICAL_QUANTITY 3 +#define MRH_TSTRING_VECTOR 4 +#define MRH_INT_VECTOR 5 +#define MRH_DOUBLE_VECTOR 6 + +typedef vector TIntVector; +typedef vector TDoubleVector; +typedef vector TStringVector; + +//------------------------------------------------------------------------- +template class TMusrRunObject : public TObject +{ +public: + TMusrRunObject() { fPathName = "n/a"; fType = "n/a"; } + TMusrRunObject(TString pathName, TString type, T value) : fPathName(pathName), fType(type), fValue(value) {} + virtual ~TMusrRunObject() {} + + virtual TString GetPathName() { return fPathName; } + virtual TString GetType() { return fType; } + virtual T GetValue() { return fValue; } + + virtual void SetPathName(TString pathName) { fPathName = pathName; } + virtual void SetType(TString type) { fType = type; } + virtual void SetValue(T value) { fValue = value; } + +private: + TString fPathName; ///< path name of the variable, e.g. 'RunInfo/Run Number' + TString fType; ///< type of value, e.g. TString, or Int_t, etc. + T fValue; ///< value itself +}; + +//------------------------------------------------------------------------- +class TMusrRunPhysicalQuantity : public TObject +{ +public: + TMusrRunPhysicalQuantity(); + TMusrRunPhysicalQuantity(TString label, Double_t demand, Double_t value, Double_t error, TString unit, TString description = TString("n/a")); + TMusrRunPhysicalQuantity(TString label, Double_t demand, Double_t value, TString unit, TString description = TString("n/a")); + TMusrRunPhysicalQuantity(TString label, Double_t value, TString unit, TString description = TString("n/a")); + virtual ~TMusrRunPhysicalQuantity() {} + + virtual TString GetLabel() const { return fLabel; } + virtual Double_t GetDemand() const { return fDemand; } + virtual Double_t GetValue() const { return fValue; } + virtual Double_t GetError() const { return fError; } + virtual TString GetUnit() const { return fUnit; } + virtual TString GetDescription() const { return fDescription; } + + virtual void Set(TString label, Double_t demand, Double_t value, Double_t error, TString unit, TString description = TString("n/a")); + virtual void Set(TString label, Double_t demand, Double_t value, TString unit, TString description = TString("n/a")); + virtual void Set(TString label, Double_t value, TString unit, TString description = TString("n/a")); + virtual void SetLabel(TString &label) { fLabel = label; } + virtual void SetLabel(const char *label) { fLabel = label; } + virtual void SetDemand(Double_t val) { fDemand = val; } + virtual void SetValue(Double_t val) { fValue = val; } + virtual void SetError(Double_t err) { fError = err; } + virtual void SetUnit(TString &unit) { fUnit = unit; } + virtual void SetUnit(const char *unit) { fUnit = unit; } + virtual void SetDescription(TString &str) { fDescription = str; } + virtual void SetDescription(const char *str) { fDescription = str; } + +private: + TString fLabel; ///< property label, like ’Sample Temperature’ etc. + Double_t fDemand; ///< demand value of the physical quantity, e.g. temperature setpoint + Double_t fValue; ///< measured value of the physical quantity + Double_t fError; ///< estimated error (standard deviation) of the measured value + TString fUnit; ///< unit of the physical quantity + TString fDescription; ///< a more detailed description of the physical quantity + + ClassDef(TMusrRunPhysicalQuantity, 1) +}; + +//------------------------------------------------------------------------- +class TMusrRunHeader : public TObject +{ +public: + TMusrRunHeader(bool quite=false); + TMusrRunHeader(const char *fileName, bool quite=false); + virtual ~TMusrRunHeader(); + + virtual TString GetFileName() { return fFileName; } + + virtual Bool_t FillFolder(TFolder *folder); + + virtual Bool_t ExtractAll(TFolder *folder); + virtual Bool_t ExtractHeaderInformation(TObjArray *headerInfo, TString path); + + virtual void Get(TString pathName, TString &value, Bool_t &ok); + virtual void Get(TString pathName, Int_t &value, Bool_t &ok); + virtual void Get(TString pathName, Double_t &value, Bool_t &ok); + virtual void Get(TString pathName, TMusrRunPhysicalQuantity &value, Bool_t &ok); + virtual void Get(TString pathName, TStringVector &value, Bool_t &ok); + virtual void Get(TString pathName, TIntVector &value, Bool_t &ok); + virtual void Get(TString pathName, TDoubleVector &value, Bool_t &ok); + + virtual void SetFileName(TString fln) { fFileName = fln; } + + virtual void Set(TString pathName, TString value); + virtual void Set(TString pathName, Int_t value); + virtual void Set(TString pathName, Double_t value); + virtual void Set(TString pathName, TMusrRunPhysicalQuantity value); + virtual void Set(TString pathName, TStringVector value); + virtual void Set(TString pathName, TIntVector value); + virtual void Set(TString pathName, TDoubleVector value); + + virtual void DumpHeader(); + virtual void DrawHeader(); + +private: + bool fQuite; + TString fFileName; + TString fVersion; + + vector< TMusrRunObject > fStringObj; + vector< TMusrRunObject > fIntObj; + vector< TMusrRunObject > fDoubleObj; + vector< TMusrRunObject > fMusrRunPhysQuantityObj; + vector< TMusrRunObject > fStringVectorObj; + vector< TMusrRunObject > fIntVectorObj; + vector< TMusrRunObject > fDoubleVectorObj; + + vector< TString > fPathNameOrder; ///< keeps the path-name as they were created in ordered to keep ordering + + virtual void Init(TString str="n/a"); + virtual void CleanUp(); + + virtual UInt_t GetDecimalPlace(Double_t val); + virtual UInt_t GetLeastSignificantDigit(Double_t val) const; + virtual void SplitPathName(TString pathName, TString &path, TString &name); + + virtual TString GetLabel(TString str); + virtual TString GetStrValue(TString str); + virtual TString GetType(TString str); + + virtual bool UpdateFolder(TObject *treeObj, TString path); + virtual TObject* FindObject(TObject *treeObj, TString path); + virtual TObjString GetHeaderString(UInt_t idx); + + virtual bool RemoveFirst(TString &str, const char splitter); + virtual TString GetFirst(TString &str, const char splitter); + + ClassDef(TMusrRunHeader, 1) +}; + +#endif // TMUSRRUNHEADER_H diff --git a/src/external/MusrRoot/TMusrRunHeader.pc.in b/src/external/MusrRoot/TMusrRunHeader.pc.in new file mode 100644 index 00000000..e6918c5f --- /dev/null +++ b/src/external/MusrRoot/TMusrRunHeader.pc.in @@ -0,0 +1,10 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: TMusrRunHeader +Description: C++ shared library providing the MusrRoot Run Header class +Version: @MUSR_ROOT_VERSION@ +Libs: -L${libdir} -l@MUSR_ROOT_LIBRARY_NAME@ +Cflags: -I${includedir} diff --git a/templates/cpp b/src/external/MusrRoot/TMusrRunHeaderLinkDef.h old mode 100755 new mode 100644 similarity index 70% rename from templates/cpp rename to src/external/MusrRoot/TMusrRunHeaderLinkDef.h index bb3f316f..f6d5a358 --- a/templates/cpp +++ b/src/external/MusrRoot/TMusrRunHeaderLinkDef.h @@ -1,5 +1,16 @@ /*************************************************************************** - * Copyright (C) 2007 by Andreas Suter * + + TMusrRunHeaderLinkDef.h + + Author: Andreas Suter + e-mail: andreas.suter@psi.ch + + $Id: TMusrRunHeaderLinkDef.h 5054 2012-01-18 07:43:50Z suter_a $ + +***************************************************************************/ + +/*************************************************************************** + * Copyright (C) 2007-2012 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * @@ -17,3 +28,14 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ + +#ifdef __CINT__ + +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; + +#pragma link C++ class TMusrRunPhysicalQuantity+; +#pragma link C++ class TMusrRunHeader+; + +#endif diff --git a/src/external/MusrRoot/root2xml.C b/src/external/MusrRoot/root2xml.C new file mode 100644 index 00000000..f24a5e08 --- /dev/null +++ b/src/external/MusrRoot/root2xml.C @@ -0,0 +1,318 @@ +// quick and dirty ROOT -> XML converter for MusrRoot +// needs to be rewritten as proper program. +// +// Andreas Suter +// +// $Id: root2xml.C 5092 2012-03-13 07:47:00Z nemu $ + +vector xml_data; + +enum EFolderTag {eUnkown, eDecayAnaModule, eSlowControlAnaModule}; +enum ERunHeaderTag {eUnkown, eRunInfo, eSampleEnvironmentInfo, eMagneticFieldEnvironmentInfo, eBeamlineInfo, eScalerInfo}; +EFolderTag folderTag = eUnkown; +ERunHeaderTag runHeaderTag = eUnkown; + +void root2xml(const char *filename, const char *xmlFilename) +{ + TFile f(filename); + + if (f.IsZombie()) { + cout << endl << "**ERROR** couldn't open file " << filename << endl; + return; + } + + xml_data.clear(); + + xml_data.push_back(""); + xml_data.push_back(""); + + TIter next = f.GetListOfKeys(); + TKey *key; + TFolder *folder; + TString str, tag; + + UInt_t offset = 2; + + while (key = (TKey*) next()) { + cout << endl << "name: " << key->GetName() << ", class name: " << key->GetClassName(); + str = key->GetClassName(); + if (str == "TFolder") { + folder = (TFolder*)key->ReadObj(); + checkClass(folder, str, offset); + } + } + cout << endl; + + f.Close(); + + xml_data.push_back(""); + + // the sort_histo_folders is needed since XML-Schema is not flexible enough to handle + // histos -| + // |- DecayAnaModule + // ... (any other analyzer module sub-folder + // |- SCAnaModule + // Hence SCAnaModule has artificially moved up, just to follow DecayAnaModule + sort_histo_folders(); + + ofstream fout(xmlFilename); + + for (UInt_t i=0; i temp_xml_data; + + // first make a copy of the original xml_data + for (unsigned int i=0; i") != string::npos) + start = i; + if (temp_xml_data[i].find("") != string::npos) + end = i+1; + } + if ((start > 0) && (end > 0)) + temp_xml_data.erase(temp_xml_data.begin()+start, temp_xml_data.begin()+end); + else // no SCAnaModule present, hence nothing to be done + return; + + // insert SCAnaModule just after DecayAnaModule + // 1st find end of DecayAnaModule + unsigned int pos = 0; + for (unsigned int i=0; i") != string::npos) { + pos = i+1; + break; + } + } + if (pos == 0) // something is wrong, hence to not do anything + return; + temp_xml_data.insert(temp_xml_data.begin()+pos, xml_data.begin()+start, xml_data.begin()+end); + + // copy temp_xml_data back into xml_data + xml_data.clear(); + for (unsigned int i=0; iGetListOfFolders(); + TObject *obj; + TString str; + while (obj = (TObject*) next()) { + cout << endl << offsetStr << "name: " << obj->GetName() << ", class name: " << obj->ClassName(); + str = obj->ClassName(); + checkClass(obj, str, offset); + } + +} + +void dumpObjArray(TObjArray *obj, UInt_t offset) +{ + TString offsetStr=""; + for (UInt_t i=0; iGetName()); + if (xmlLabel.BeginsWith("Detector")) { + xmlLabel.Remove(0, 8); // remove 'Detector' + if (xmlLabel.IsDigit()) + xmlLabel = "Detector"; + else + xmlLabel = TString(obj->GetName()); + } + + cout << endl << offsetStr << obj->GetName() << " (# " << obj->GetEntries() << ")"; + + xmlStr = offsetStr + "<" + xmlLabel + ">"; + xml_data.push_back(xmlStr.Data()); + + for (UInt_t i=0; iGetEntries(); i++) { + // check if entry is a TObjArray + type = obj->At(i)->ClassName(); + if (type == "TObjArray") { + dumpObjArray((TObjArray*)(obj->At(i)), offset+2); + } else { // not a TObjArray + tstr = (TObjString*) obj->At(i); + str = tstr->GetString(); + str.Remove(TString::kTrailing, '\n'); + + getType(str, type); + getLabel(str, label); + + cout << endl << offsetStr << i << ": " << str; + + xmlStr = offsetStr + " " + "<" + label + ">" + type + "" ; + xml_data.push_back(xmlStr.Data()); + } + } + + xmlStr = offsetStr + ""; + xml_data.push_back(xmlStr.Data()); +} + +void dumpEntry(TObject *obj, UInt_t offset) +{ + TString offsetStr=""; + for (UInt_t i=0; i"; + str += obj->GetName(); + str += ""; + xml_data.push_back(str.Data()); + + str = offsetStr + "<" + typeTag + ">"; + str += obj->ClassName(); + str += ""; + xml_data.push_back(str.Data()); +} + +void checkClass(TObject *obj, TString str, UInt_t offset) +{ + TString offsetStr=""; + for (UInt_t i=0; iGetName())); + + // set folder tag + if (!xmlTagName.CompareTo("DecayAnaModule")) + folderTag = eDecayAnaModule; + else if (!xmlTagName.CompareTo("SCAnaModule")) + folderTag = eSlowControlAnaModule; + else if (!xmlTagName.CompareTo("SCAnaModule")) + folderTag = eSlowControlAnaModule; + else + folderTag = eUnkown; + + offset += 2; + str = offsetStr + "<" + xmlTagName + ">"; + xml_data.push_back(str.Data()); + + dumpFolder((TFolder*)obj, offset); + + str = offsetStr + ""; + xml_data.push_back(str.Data()); + } else if (str == "TObjArray") { + offset += 2; + dumpObjArray((TObjArray*)obj, offset); + } else { + // filter out the proper entry tag + TString entryTag(""); + switch (folderTag) { + case eDecayAnaModule: + entryTag = TString("DecayHistoEntry"); + break; + case eSlowControlAnaModule: + entryTag = TString("SlowControlHistoEntry"); + break; + case eUnkown: + default: + entryTag = TString("Entry"); + break; + } + + offset += 2; + str = offsetStr + "<" + entryTag + ">"; + xml_data.push_back(str.Data()); + dumpEntry((TObjArray*)obj, offset); + str = offsetStr + ""; + xml_data.push_back(str.Data()); + } +} + +void getType(TString entry, TString &type) +{ + if (entry.Contains("-@0")) { + type = "TString"; + } else if (entry.Contains("-@1")) { + type = "Int_t"; + } else if (entry.Contains("-@2")) { + type = "Double_t"; + } else if (entry.Contains("-@3")) { + type = "TMusrRunPhysicalQuantity"; + } else if (entry.Contains("-@4")) { + type = "TStringVector"; + } else if (entry.Contains("-@5")) { + type = "TIntVector"; + } else if (entry.Contains("-@6")) { + type = "TDoubleVector"; + } else { + type = "TString"; + } + +} + +void getLabel(TString entry, TString &label) +{ + label="no_idea"; + + Ssiz_t start = entry.First('-'); + Ssiz_t end = entry.First(':'); + + if ((start == -1) || (end == -1)) + return; + + if (end - start < 2) + return; + + // check that '-@' is present in the string, otherwise it is NOT a known label + Ssiz_t pos = entry.First('@'); + if (pos < 1) + return; + if (entry(pos-1) != '-') + return; + + // cut out value + label = entry; + label.Remove(0, start+2); + label.Remove(end-start-2, label.Length()); + + label.ReplaceAll(' ', '_'); // replace spaces through underscores + label.ReplaceAll('(', '_'); // replace '(' through underscores + label.ReplaceAll(')', '_'); // replace ')' through underscores + label.ReplaceAll('[', '_'); // replace '[' through underscores + label.ReplaceAll(']', '_'); // replace ']' through underscores + label.ReplaceAll('{', '_'); // replace '[' through underscores + label.ReplaceAll('}', '_'); // replace ']' through underscores +} diff --git a/src/external/nexus/PNeXus.cpp b/src/external/nexus/PNeXus.cpp index 4e814efc..f954318c 100644 --- a/src/external/nexus/PNeXus.cpp +++ b/src/external/nexus/PNeXus.cpp @@ -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 * @@ -565,7 +565,7 @@ int PNeXusData1::GetT0(unsigned int idx) if (idx >= fT0.size()) return -1; - return fT0[idx]; + return (int)fT0[idx]; } //------------------------------------------------------------------------------------------ @@ -581,7 +581,7 @@ int PNeXusData1::GetFirstGoodBin(unsigned int idx) if (idx >= fFirstGoodBin.size()) return -1; - return fFirstGoodBin[idx]; + return (int)fFirstGoodBin[idx]; } //------------------------------------------------------------------------------------------ @@ -597,7 +597,7 @@ int PNeXusData1::GetLastGoodBin(unsigned int idx) if (idx >= fLastGoodBin.size()) return -1; - return fLastGoodBin[idx]; + return (int)fLastGoodBin[idx]; } diff --git a/src/external/nexus/PNeXus.h b/src/external/nexus/PNeXus.h index 19f38d3f..8e9ac219 100644 --- a/src/external/nexus/PNeXus.h +++ b/src/external/nexus/PNeXus.h @@ -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 * diff --git a/src/external/scripts/msr2data b/src/external/scripts/msr2data deleted file mode 100644 index 50f56e1d..00000000 --- a/src/external/scripts/msr2data +++ /dev/null @@ -1,763 +0,0 @@ -#!/bin/bash - -if [ ! -x /usr/bin/awk ]; then - echo ">> msr2data: Please make sure you have installed awk!" - exit 1 -fi - -if [ "$#" -lt 2 ] ; then - - cat <> msr2data: Syntax error - you used the list specification without closing bracket (])! Quitting now." - echo - exit 1 - fi - - EXTENSION=$( eval echo \${$((RIGHTBRACKET + 1))} ) - FIRST_OPT_PAR=$((RIGHTBRACKET + 2)) - LAST_OPT_PAR=$# - RUNLIST_USED=0 - NUM_OF_IND_VAR=1 # 1 for the run number - - else - ISDIGIT1=$( echo $1 | awk '{ if (( $1 + 0 ) == $1 ) {print 1} else {print 0}}' ) # check if the first parameter is a number or not - ISDIGIT2=$( echo $2 | awk '{ if (( $1 + 0 ) == $1 ) {print 1} else {print 0}}' ) # check if the second parameter is a number or not - if [ "$ISDIGIT1" -eq 1 ] && [ "$ISDIGIT2" -eq 1 ]; then # start and end-runs are given - if [ "$1" -le "$2" ]; then # runs are given with increasing run numbers - for (( j=0; j<=$2-$1; j++ )) - do - RUNARRAY[$j]=$(( $1 + $j )) - done - LASTRUN=$(( $2 - $1 )) # RUNARRAY-index of the last run - else # runs are given with decreasing run numbers - for (( j=0; j<=$1-$2; j++ )) - do - RUNARRAY[$j]=$(( $1 - $j )) - done - LASTRUN=$(( $1 - $2 )) # RUNARRAY-index of the last run - fi - - EXTENSION=$3 - - FIRST_OPT_PAR=4 - LAST_OPT_PAR=$# - RUNLIST_USED=0 - NUM_OF_IND_VAR=1 # 1 for the run number - - elif [ "$ISDIGIT1" -eq 1 ] && [ "$ISDIGIT2" -eq 0 ]; then # only one run number is given - RUNARRAY[0]=$1 - - LASTRUN=0 # RUNARRAY-index of the last run - EXTENSION=$2 - - FIRST_OPT_PAR=3 - LAST_OPT_PAR=$# - RUNLIST_USED=0 - NUM_OF_IND_VAR=1 # 1 for the run number - - else # assume a runlist-file with "independent variables" is given - if [ ! -r $1 ]; then - echo - echo ">> msr2data: The specified runlist file $1 is not present... Bye bye!" - echo - exit 1 - fi - - numberOfReadInLines=0 - numberOfComments=0 - - exec 3< $1 # open file for reading in the runlist-file the first time and get the runnumbers to be processed - while read -u 3 -a runList - do - if [ "$numberOfReadInLines" -eq 0 ]; then - NUM_OF_IND_VAR=${#runList[@]} - elif [ "${runList[0]:0:1}" == "#" ] || [ "${runList[0]}" == "" ]; then - ((numberOfComments++)) - else - RUNARRAY[(( numberOfReadInLines - numberOfComments - 1 ))]=${runList[0]} - fi - ((numberOfReadInLines++)) - done - exec 3<&- # close file - - LASTRUN=$(( ${#RUNARRAY[@]} - 1 )) # RUNARRAY-index of the last run - EXTENSION=$2 - - FIRST_OPT_PAR=3 - LAST_OPT_PAR=$# - RUNLIST_USED=1 - fi - fi - - # Check if fitting should be done - TEMP="" - for PAR in "$@" - do - if [ "${PAR:0:3}" == "fit" ]; then - TEMP=${PAR:4} - break - fi - done - - # define which file (msr or mlog) contains the musrfit-output - INPUTEXT=mlog - OUTPUTEXT=msr - - if [ "$TEMP" != "" ]; then # runs should be fitted using musrfit - - SETBATCH=0 # check if the TEMPLATE file should ALWAYS be the template or only for the first run - if [ "${TEMP:(-1)}" == "!" ]; then - SETBATCH=1 - TEMP=${TEMP%"!"} - fi - - # Check for musrfit on the PATH and if found continue with searching the fit-template - PATHTOMUSRFIT=$(echo `which musrfit`) - if [ "$PATHTOMUSRFIT" == "" ]; then - echo - echo ">> msr2data: No musrfit executable was found on the PATH or in the current directory!" - echo ">> msr2data: Please install musrfit first!" - echo - exit 1 - else - if [ -r $TEMP$EXTENSION.$OUTPUTEXT ]; then - TEMPLATE=$TEMP$EXTENSION.$OUTPUTEXT - elif [ -r $TEMP$EXTENSION.$INPUTEXT ]; then - TEMPLATE=$TEMP$EXTENSION.$INPUTEXT - fi - fi - fi - - for (( q=0; q<=LASTRUN; q++ )) # loop over all RUNARRAY entries - the actual data-processing - do - COUNT=${RUNARRAY[$q]} - NEXTCOUNT=${RUNARRAY[ (( q + 1 )) ]} - NEXTINPUT=$NEXTCOUNT$EXTENSION.msr - FIRSTINPUT=${RUNARRAY[0]}$EXTENSION.msr - - if [ "$TEMP" != "" ]; then # if fitting should be done - if [ "$TEMPLATE" == "" ]; then - echo - echo ">> msr2data: The specified musrfit template files $TEMP$EXTENSION.$OUTPUTEXT and $TEMP$EXTENSION.$INPUTEXT do not exist!" - echo - exit 1 - fi - - # if it's the first run to be fitted, take the template and substitute the runnumber to match the first run - if [ "$q" -eq 0 ] && [ "$TEMPLATE" != "$FIRSTINPUT" ]; then - awk -v count=$TEMP -v nextcount=${RUNARRAY[0]} -v nextinput=$FIRSTINPUT '{ - if(NR==1) print nextcount > nextinput - else if($1 == "RUN") { - if (substr(count,1,1) != "_"){ count = sprintf("_%04u", count); nextcount = sprintf("_%04u", nextcount);} - if ($2 !~ count){ - print " " - print ">> msr2data: ATTENTION The run-numbers in the filename and the RUN-block of the template file do not match!" - print ">> msr2data: The run-number substitution is most likely going wrong!" - print " " - } - sub(count, nextcount, $0); - print $0 >> nextinput - } - else print $0 >> nextinput - }' $TEMPLATE - fi - - MUSRFITPARAM="" - for PAR in "$@" - do - if [ "$PAR" == "-k" ]; then - MUSRFITPARAM="$MUSRFITPARAM -k" - break - fi - done - - for PAR in "$@" - do - if [ "$PAR" == "-t" ]; then - MUSRFITPARAM="$MUSRFITPARAM -t" - break - fi - done - - echo - echo ">> msr2data: musrfit $COUNT$EXTENSION.msr $MUSRFITPARAM" - echo - musrfit $COUNT$EXTENSION.msr $MUSRFITPARAM # the fit - - if [ "$q" -ne "$LASTRUN" ]; then # create the next musrfit input file if not the last specified run was fitted already - if [ "$SETBATCH" -eq 1 ]; then # check if the TEMPLATE should be ALWAYS used or only the first time and use the according file - COUNTX=$TEMP - TEMPLATEX=$TEMPLATE - else - COUNTX=$COUNT - TEMPLATEX=$COUNT$EXTENSION.$OUTPUTEXT - fi - if [ "$TEMPLATEX" != "$NEXTINPUT" ]; then - awk -v count=$COUNTX -v nextcount=$NEXTCOUNT -v nextinput=$NEXTINPUT '{ - if(NR==1) print nextcount > nextinput - else if($1 == "RUN") { - if (substr(count,1,1) != "_"){ count = sprintf("_%04u", count); nextcount = sprintf("_%04u", nextcount);} - if ($2 !~ count){ - print " " - print ">> msr2data: ATTENTION The run-numbers in the filename and the RUN-block of the file do not match!" - print ">> msr2data: The run-number substitution is most likely going wrong!" - print " " - } - sub(count, nextcount, $0); - print $0 >> nextinput - } - else print $0 >> nextinput - }' $TEMPLATEX - fi - fi - fi - - if [ ! -r $COUNT$EXTENSION.$OUTPUTEXT ]; then - echo - echo ">> msr2data: The specified musrfit output file $COUNT$EXTENSION.$OUTPUTEXT does not exist!" - echo - exit 1 - fi - - # if the "nosummary"-option is not set and the summary files are present, get some information from there - NOSUMMARY=0 - for PAR in "$@" - do - if [ "$PAR" == "nosummary" ]; then - NOSUMMARY=1 - break - fi - done - - if [ "$NOSUMMARY" -eq 0 ]; then - - if [ -d $SUMMDIR ]; then - # extract runnumber from mlog/msr-file - RUNNUMBER=$( awk '{ - if(NR==1) X=0 - if($1 ~ /^RUN/ && X==0) { - split($2, runNumber, "_") - if(runNumber[1] ~ /lem/ && runNumber[2] != "his") {print runNumber[2] } - if(runNumber[1] ~ /lem/ && runNumber[2] == "his") {print substr(runNumber[3],1,4) } - X=1 - } - }' $COUNT$EXTENSION.$OUTPUTEXT ) - - # extract runyear from mlog/msr-file in case of LEM-data - RUNYEAR=$( awk '{ - if(NR==1) X=0 - if($1 ~ /^RUN/ && X==0) { - split($2, runNumber, "_") - if(runNumber[1] ~ /lem/) {print substr(runNumber[1],length(runNumber[1])-1)} - else print "XX" - X=1 - } - }' $COUNT$EXTENSION.$OUTPUTEXT ) - - if [ "$RUNYEAR" != "XX" ]; then # in case of LEM-data search the summary-file - SUMMFILE=$SUMMDIR/20$RUNYEAR/lem$RUNYEAR\_$RUNNUMBER.summ - TITLE=$( awk '{ if(NR==4) print $0 }' $SUMMFILE ) - ENERGY=$( awk '{ if($0 ~ /implantation energy/) print $(NF-1)}' $SUMMFILE ) - TEMPERATURE=$( awk '{ if($1 == "Sample_CF1") print $(NF-1)}' $SUMMFILE ) - RALRAR=$( awk '{ if($5 == "RA-L") RAL=$7; if($1 == "RA-R") { RAR=$3; print RAL-RAR; nextfile } }' $SUMMFILE ) - RATRAB=$( awk '{ if($5 == "RA-T") RAT=$7; if($1 == "RA-B") { RAB=$3; print RAT-RAB; nextfile } }' $SUMMFILE ) - TRANSPORT=$( awk '{ if($1 == "Moderator") print $3}' $SUMMFILE ) - fi - fi - fi - - # determine the script-output file format, default: db - FORMAT=db - OUTFILE="out.db" - - for PAR in "$@" - do - if [ "$PAR" == "data" ]; then - FORMAT=dat - OUTFILE="out.dat" - break - fi - done - - for (( l="$FIRST_OPT_PAR"; l<="$LAST_OPT_PAR"; l++ )) - do - CUR_PAR=$( eval echo \${$l} ) - NEXT_PAR=$( eval echo \${$((l+1))} ) - if [ "${CUR_PAR:0:2}" == "-o" ]; then - if [ "$CUR_PAR" == "-o" ]; then - if [ "$l" -ne "$LAST_OPT_PAR" ] && [ "$NEXT_PAR" != "noheader" ] && [ "$NEXT_PAR" != "nosummary" ] \ - && [ "${NEXT_PAR:0:3}" != "fit" ] && [ "$NEXT_PAR" != "-k" ] && [ "$NEXT_PAR" != "-t" ]; then - OUTFILE=$NEXT_PAR - break - else - echo - echo ">> msr2data: You did not specify an output file! The default one ($OUTFILE) will be used." - echo - fi - else - OUTFILE=${CUR_PAR:2} - break - fi - fi - done - - # determine, if the header should be written to the output file, default: YES - NOHEADER=0 - for PAR in "$@" - do - if [ "$PAR" == "noheader" ]; then - NOHEADER=1 - break - fi - done - - # put together all data to db- or column-format and write it to the file - awk -v outfile=$OUTFILE -v noheader=$NOHEADER -v runList=$RUNLIST_USED -v numIndVar=$NUM_OF_IND_VAR -v format=$FORMAT '{ - - if(tolower(outfile) == "none") - exit 0 - - FS = " " - OFS = " " - - if(NR==1){title=$0; X=0; Y=0; i=1} - - if(NR>1){ - if(X == 0){ - if($1 == i){ - parArray[i] = $2 - dataArray[i] = $3 - if($4 ~ /^-/) - negErrArray[i] = substr($4, 2) - else - negErrArray[i] = $4 - if($5 ~ /none/) - posErrArray[i] = $4 - else - posErrArray[i] = $5 - i++ - } - if($1 ~ /^THEORY/) X=1 - } - } - - if($1 ~ /^RUN/ && X==1){ split($2, runNumber, "_"); X=2 } - - if(($1 ~ /^chisq/ || $1 ~ /^maxLH/) && X==2){ - if($1 ~ /^maxLH/){ - parArray[i] = "maxLH" - parArray[i+2] = "maxLHred" - } else { - parArray[i] = "CHISQ" - parArray[i+2] = "CHISQred" - } - parArray[i+1] = "NDF" - parArray[i+3] = "RUN" - - sub(/,/, "", $3); sub(/,/, "", $6); - - dataArray[i] = $3 - dataArray[i+1] = $6 - dataArray[i+2] = $9 - - for (j in runNumber) { - if ( runNumber[j] ~ /^0/ ) { - sub(/0+/, "", runNumber[j]) - } - if (int(runNumber[j]) == runNumber[j]) { - dataArray[i+3] = runNumber[j] - break - } - else dataArray[i+3] = "0000" - } - - negErrArray[i] = "0" - negErrArray[i+1] = "0" - negErrArray[i+2] = "0" - negErrArray[i+3] = "0" - - posErrArray[i] = "0" - posErrArray[i+1] = "0" - posErrArray[i+2] = "0" - posErrArray[i+3] = "0" - - # Read in the runlist-variable names - if(runList == 1){ - getline line < "'"$1"'" - split(line, indVar, " ") - } - - # Output to db-file in the case, the LEM summary file is accessible and the option "nosummary" is not set - - if(format != "dat") { - if("'"$TEMPERATURE"'" != "") { - - # Write the db-header - if("'"$q"'" == 0 && noheader != 1){ - - print "TITLE" >> outfile - print ">>>Put your title here<<<\n" >> outfile - print "Abstract" >> outfile - print ">>>Put your abstract here<<<\n" >> outfile - print "LABELS" >> outfile - print "T (K)" >> outfile - print "Tr (kV)" >> outfile - print "E (keV)" >> outfile - print "RAL-RAR (kV)" >> outfile - print "RAT-RAB (kV)" >> outfile - - if(runList == 1){ - for(k=2;k<=numIndVar;k++){print indVar[k] >> outfile} - } - - for(k=1;k> outfile - } - - $1 = "Data" - $2 = "T" - $3 = "Tr" - $4 = "E" - $5 = "RALRAR" - $6 = "RATRAB" - - for(k=1;k> outfile - print "\\-e" >> outfile - } - - # Write the data-block - print "T = " "'"$TEMPERATURE"'" ",,,\\" >> outfile - print "Tr = " "'"$TRANSPORT"'" ",,,\\" >> outfile - if ("'"$ENERGY"'" != "") print "E = " "'"$ENERGY"'" ",,,\\" >> outfile - else print "E = -999,,,\\" >> outfile - if ("'"$RALRAR"'" != "") print "RALRAR = " "'"$RALRAR"'" ",,,\\" >> outfile - else print "RALRAR = -999,,,\\" >> outfile - if ("'"$RATRAB"'" != "") print "RATRAB = " "'"$RATRAB"'" ",,,\\" >> outfile - else print "RATRAB = -999,,,\\" >> outfile - - if(runList == 1) { # process the "independent variables" from the file - while((getline line < "'"$1"'") > 0){ - split(line, indVarValue, " ") - if (indVarValue[1] == "'"$COUNT"'"){ - for(k=2;k<=numIndVar;k++){print indVar[k] " = " indVarValue[k] ",,,\\" >> outfile} - break - } - } - } - - for(l=1;l> outfile - } - - print dataArray[i+3] ",,, " "'"$TITLE"'" >> outfile - - if("'"$q"'" == "'"$LASTRUN"'") print "\n" >> outfile - } - - # If we do not have the information from the summary file or "nosummary" is set - else { - if("'"$q"'" == 0 && noheader != 1){ - - print "TITLE" >> outfile - print ">>>Put your title here<<<\n" >> outfile - print "Abstract" >> outfile - print ">>>Put your abstract here<<<\n" >> outfile - print "LABELS" >> outfile - - if(runList == 1){ - for(k=2;k<=numIndVar;k++){print indVar[k] >> outfile} - } - - for(k=1;k> outfile - } - - $1 = "Data" - - for(k=1;k> outfile - print "\\-e" >> outfile - } - - if(runList == 1) { - while((getline line < "'"$1"'") > 0){ - split(line, indVarValue, " ") - if (indVarValue[1] == "'"$COUNT"'"){ - for(k=2;k<=numIndVar;k++){print indVar[k] " = " indVarValue[k] ",,,\\" >> outfile} - break - } - } - } - - for(l=1;l> outfile - } - - print dataArray[i+3] ",,, " title >> outfile - - if("'"$q"'" == "'"$LASTRUN"'") print "\n" >> outfile - } - } - - # output to a data-file with simple column-structure - # first if the LEM-summary files are present and "nosummary" has not been set - else { - if("'"$TEMPERATURE"'" != "") { - - # Write the dat-header - if("'"$q"'" == 0 && noheader != 1){ - - $1 = "T" - $2 = "Tr" - $3 = "E" - $4 = "RALRAR" - $5 = "RATRAB" - - for(k=1;k> outfile - } - - # Write the data-block - $1 = "'"$TEMPERATURE"'" - $2 = "'"$TRANSPORT"'" - if ("'"$ENERGY"'" != "") { $3 = "'"$ENERGY"'" } else { $3 = "-999" } - if ("'"$RALRAR"'" != "") { $4 = "'"$RALRAR"'" } else { $4 = "-999" } - if ("'"$RATRAB"'" != "") { $5 = "'"$RATRAB"'" } else { $5 = "-999" } - - if(runList == 1) { # process the "independent variables" from the file - while((getline line < "'"$1"'") > 0){ - split(line, indVarValue, " ") - if (indVarValue[1] == "'"$COUNT"'"){ - for(k=2;k<=numIndVar;k++){ $(k+4) = indVarValue[k] } - break - } - } - } - - for(l=1;l> outfile - - if("'"$q"'" == "'"$LASTRUN"'") print "\n" >> outfile - } - - # If we do not have the information from the summary file or "nosummary" is set - # Writing to column-data file - else { - if("'"$q"'" == 0 && noheader != 1){ - - for(k=1;k> outfile - } - - # Write the data-block - - if(runList == 1) { # process the "independent variables" from the file - while((getline line < "'"$1"'") > 0){ - split(line, indVarValue, " ") - if (indVarValue[1] == "'"$COUNT"'"){ - for(k=2;k<=numIndVar;k++){ $(k-1) = indVarValue[k] } - break - } - } - } - - for(l=1;l> outfile - - if("'"$q"'" == "'"$LASTRUN"'") print "\n" >> outfile - - } - } - print " " - print ">> msr2data: The parameter data of " ARGV[1] " have been appended to " outfile - } - if($0 ~ /*** FIT DID NOT CONVERGE ***/ && X==2){ - print " " - print ">> msr2data: ATTENTION At least one of the performed fits has not been converged!" - print ">> msr2data: The data of " ARGV[1] " has not been included in " outfile "!" - print " " - } - }' $COUNT$EXTENSION.$OUTPUTEXT - done - echo - echo ">> msr2data: done" - echo -fi diff --git a/src/include/PFitter.h b/src/include/PFitter.h index f90d4f26..e1c79089 100644 --- a/src/include/PFitter.h +++ b/src/include/PFitter.h @@ -10,8 +10,8 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007 by Andreas Suter * - * andreas.suter@psi.c * + * Copyright (C) 2007-2012 by Andreas Suter * + * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * diff --git a/src/include/PFitterFcn.h b/src/include/PFitterFcn.h index 59135144..2602d1ea 100644 --- a/src/include/PFitterFcn.h +++ b/src/include/PFitterFcn.h @@ -10,8 +10,8 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007 by Andreas Suter * - * andreas.suter@psi.c * + * Copyright (C) 2007-2012 by Andreas Suter * + * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * diff --git a/src/include/PFourier.h b/src/include/PFourier.h index 9328f693..159f6805 100644 --- a/src/include/PFourier.h +++ b/src/include/PFourier.h @@ -10,8 +10,8 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2008 by Andreas Suter * - * andreas.suter@psi.c * + * Copyright (C) 2007-2012 by Andreas Suter * + * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * diff --git a/src/include/PFunction.h b/src/include/PFunction.h index ea8a47ad..ad29135a 100644 --- a/src/include/PFunction.h +++ b/src/include/PFunction.h @@ -10,8 +10,8 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007 by Andreas Suter * - * andreas.suter@psi.c * + * Copyright (C) 2007-2012 by Andreas Suter * + * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * diff --git a/src/include/PFunctionGrammar.h b/src/include/PFunctionGrammar.h index 30608db0..6f0a9bc1 100644 --- a/src/include/PFunctionGrammar.h +++ b/src/include/PFunctionGrammar.h @@ -10,8 +10,8 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007 by Andreas Suter * - * andreas.suter@psi.c * + * Copyright (C) 2007-2012 by Andreas Suter * + * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * diff --git a/src/include/PFunctionHandler.h b/src/include/PFunctionHandler.h index f66e10ba..5436fd87 100644 --- a/src/include/PFunctionHandler.h +++ b/src/include/PFunctionHandler.h @@ -10,8 +10,8 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007 by Andreas Suter * - * andreas.suter@psi.c * + * Copyright (C) 2007-2012 by Andreas Suter * + * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * diff --git a/src/include/PMsr2Data.h b/src/include/PMsr2Data.h index e743d7de..c30734fc 100644 --- a/src/include/PMsr2Data.h +++ b/src/include/PMsr2Data.h @@ -10,7 +10,7 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2009-2010 by Bastian M. Wojek / Andreas Suter * + * Copyright (C) 2009-2012 by Bastian M. Wojek / Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * diff --git a/src/include/PMsrHandler.h b/src/include/PMsrHandler.h index 16dffcd3..408e391e 100644 --- a/src/include/PMsrHandler.h +++ b/src/include/PMsrHandler.h @@ -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 * @@ -77,8 +77,8 @@ class PMsrHandler virtual Bool_t SetMsrParamPosErrorPresent(UInt_t i, Bool_t value); virtual Bool_t SetMsrParamPosError(UInt_t i, Double_t value); - virtual void SetMsrT0Entry(UInt_t runNo, UInt_t idx, Int_t bin); - virtual void SetMsrAddT0Entry(UInt_t runNo, UInt_t addRunIdx, UInt_t histoIdx, Int_t bin); + virtual void SetMsrT0Entry(UInt_t runNo, UInt_t idx, Double_t bin); + virtual void SetMsrAddT0Entry(UInt_t runNo, UInt_t addRunIdx, UInt_t histoIdx, Double_t bin); virtual void SetMsrDataRangeEntry(UInt_t runNo, UInt_t idx, Int_t bin); virtual void SetMsrBkgRangeEntry(UInt_t runNo, UInt_t idx, Int_t bin); diff --git a/src/include/PMusr.h b/src/include/PMusr.h index 46438438..08069afc 100644 --- a/src/include/PMusr.h +++ b/src/include/PMusr.h @@ -10,7 +10,7 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007-2010 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 * @@ -38,6 +38,8 @@ using namespace std; #include +#define PMUSR_VERSION "0.10.0" + #define PMUSR_SUCCESS 0 #define PMUSR_WRONG_STARTUP_SYNTAX -1 #define PMUSR_MSR_FILE_NOT_FOUND -2 @@ -266,6 +268,76 @@ class PNonMusrRawRunData { vector fErrData; ///< vector of all data errors }; +//------------------------------------------------------------- +/** + *

Handles a single raw muSR histogram set, without any additional header information. + */ +class PRawRunDataSet { + public: + PRawRunDataSet(); + virtual ~PRawRunDataSet() { fData.clear(); } + + virtual TString GetName() { return fName; } + virtual Int_t GetHistoNo() { return fHistoNo; } + virtual Double_t GetTimeZeroBin() { return fTimeZeroBin; } + virtual Double_t GetTimeZeroBinEstimated() { return fTimeZeroBinEstimated; } + virtual Int_t GetFirstGoodBin() { return fFirstGoodBin; } + virtual Int_t GetLastGoodBin() { return fLastGoodBin; } + virtual Int_t GetFirstBkgBin() { return fFirstBkgBin; } + virtual Int_t GetLastBkgBin() { return fLastBkgBin; } + virtual PDoubleVector *GetData() { return &fData; } + + virtual void Clear(); + virtual void SetName(TString str) { fName = str; } + virtual void SetHistoNo(Int_t no) { fHistoNo = no; } + virtual void SetTimeZeroBin(Double_t tzb) { fTimeZeroBin = tzb; } + virtual void SetTimeZeroBinEstimated(Double_t tzb) { fTimeZeroBinEstimated = tzb; } + virtual void SetFirstGoodBin(Int_t fgb) { fFirstGoodBin = fgb; } + virtual void SetLastGoodBin(Int_t lgb) { fLastGoodBin = lgb; } + virtual void SetFirstBkgBin(Int_t fbb) { fFirstBkgBin = fbb; } + virtual void SetLastBkgBin(Int_t lbb) { fLastGoodBin = lbb; } + virtual void SetData(PDoubleVector data) { fData = data; } + + private: + TString fName; ///< keeps the histogram name. + Int_t fHistoNo; ///< corresponds to the histogram number in the data file + Double_t fTimeZeroBin; ///< keeps the time zero bin + Double_t fTimeZeroBinEstimated; ///< keeps the estimated time zero bin + Int_t fFirstGoodBin; ///< keeps the first good bin of the data set + Int_t fLastGoodBin; ///< keeps the last good bin of the data set + Int_t fFirstBkgBin; ///< keeps the first background bin of the data set + Int_t fLastBkgBin; ///< keeps the last background bin of the data set + PDoubleVector fData; ///< keeps the histogram data +}; + +//------------------------------------------------------------- +/** + *

Handles a vector of PRawRunDataSet's. Addressing of the data set can be done + * via a map mechanism, since e.g. for MusrRoot, the data sets are not continuously + * numbered due to Red/Green options. + */ +class PRawRunDataVector { + public: + PRawRunDataVector() {} + virtual ~PRawRunDataVector() { fDataVec.clear(); } + + virtual UInt_t Size() { return fDataVec.size(); } + virtual Bool_t IsPresent(UInt_t histoNo); + virtual PRawRunDataSet* GetSet(UInt_t idx); + virtual PRawRunDataSet* Get(UInt_t histoNo); + virtual PRawRunDataSet* operator[](UInt_t histoNo); + virtual PDoubleVector* GetData(UInt_t histoNo); + virtual Double_t GetT0Bin(UInt_t histoNo); + virtual Double_t GetT0BinEstimated(UInt_t histoNo); + virtual PIntPair GetBkgBin(UInt_t histoNo); + virtual PIntPair GetGoodDataBin(UInt_t histoNo); + + virtual void Set(PRawRunDataSet dataSet, Int_t idx=-1); + + private: + vector fDataVec; +}; + //------------------------------------------------------------- /** *

Handles raw data, both non-muSR data as well muSR histogram data. @@ -275,12 +347,20 @@ class PRawRunData { PRawRunData(); virtual ~PRawRunData(); + virtual const TString* GetVersion() { return &fVersion; } + virtual const TString* GetGenericValidatorUrl() { return &fGenericValidatorURL; } + virtual const TString* GetSpecificValidatorUrl() { return &fSpecificValidatorURL; } + virtual const TString* GetGenerator() { return &fGenerator; } + virtual const TString* GetComment() { return &fComment; } + virtual const TString* GetFileName() { return &fFileName; } virtual const TString* GetLaboratory() { return &fLaboratory; } virtual const TString* GetBeamline() { return &fBeamline; } virtual const TString* GetInstrument() { return &fInstrument; } + virtual const TString* GetArea() { return &fArea; } virtual const TString* GetRunName() { return &fRunName; } virtual const TString* GetMuonSource() { return &fMuonSource; } virtual const TString* GetMuonSpecies() { return &fMuonSpecies; } + virtual const Double_t GetMuonBeamMomentum() { return fMuonBeamMomentum; } virtual const Int_t GetRunNumber() { return fRunNumber; } virtual const TString* GetRunTitle() { return &fRunTitle; } virtual const TString* GetSetup() { return &fSetup; } @@ -290,8 +370,10 @@ class PRawRunData { virtual const TString* GetStopTime() { return &fStopTime; } virtual const TString* GetStopDate() { return &fStopDate; } virtual const time_t GetStopDateTime() { return fStopDateTimeSec; } + virtual const TString* GetCryoName() { return &fCryo; } virtual const TString* GetSample() { return &fSample; } virtual const TString* GetOrientation() { return &fOrientation; } + virtual const TString* GetMagnetName() { return &fMagnet; } virtual const Double_t GetField() { return fField; } virtual const UInt_t GetNoOfTemperatures() { return fTemp.size(); } virtual const PDoublePairVector* GetTemperature() const { return &fTemp; } @@ -301,23 +383,31 @@ class PRawRunData { virtual const Double_t GetTransport() { return fTransport; } virtual const PDoubleVector GetRingAnode() { return fRingAnode; } virtual const Double_t GetRingAnode(const UInt_t idx); - virtual const Double_t GetTimeResolution() { return fTimeResolution; } - virtual const UInt_t GetT0Size() { return fT0s.size(); } - virtual const Int_t GetT0(const UInt_t idx); - virtual const UInt_t GetT0EstimatedSize() { return fT0Estimated.size(); } - virtual const Int_t GetT0Estimated(const UInt_t idx); - virtual const PIntPair GetBkgBin(const UInt_t idx); - virtual const UInt_t GetGoodDataBinSize() { return fGoodDataBin.size(); } - virtual const PIntPair GetGoodDataBin(const UInt_t idx); - virtual const UInt_t GetNoOfHistos() { return fDataBin.size(); } - virtual const PDoubleVector* GetDataBin(const UInt_t idx); + virtual const Double_t GetTimeResolution() { return fTimeResolution; } + virtual const Bool_t IsPresent(UInt_t histoNo) { return fData.IsPresent(histoNo); } + virtual const Double_t GetT0Bin(const UInt_t histoNo) { return fData.GetT0Bin(histoNo); } + virtual const Double_t GetT0BinEstimated(const UInt_t histoNo) { return fData.GetT0BinEstimated(histoNo); } + virtual const PIntPair GetBkgBin(const UInt_t histoNo) { return fData.GetBkgBin(histoNo); } + virtual const PIntPair GetGoodDataBin(const UInt_t histoNo) { return fData.GetGoodDataBin(histoNo); } + virtual const PIntVector GetRedGreenOffset() { return fRedGreenOffset; } + virtual const UInt_t GetNoOfHistos() { return fData.Size(); } + virtual PRawRunDataSet* GetDataSet(const UInt_t idx, Bool_t wantHistoNo = true); + virtual const PDoubleVector* GetDataBin(const UInt_t histoNo) { return fData.GetData(histoNo); } virtual const PNonMusrRawRunData* GetDataNonMusr() { return &fDataNonMusr; } + virtual void SetVersion(const TString &str) { fVersion = str; } + virtual void SetGenericValidatorUrl(const TString &str) { fGenericValidatorURL = str; } + virtual void SetSpecificValidatorUrl(const TString &str) { fSpecificValidatorURL = str; } + virtual void SetGenerator(const TString &str) { fGenerator = str; } + virtual void SetComment(const TString &str) { fComment = str; } + virtual void SetFileName(const TString &str) { fFileName = str; } virtual void SetLaboratory(const TString &str) { fLaboratory = str; } virtual void SetBeamline(const TString &str) { fBeamline = str; } virtual void SetInstrument(const TString &str) { fInstrument = str; } + virtual void SetArea(const TString &str) { fArea = str; } virtual void SetMuonSource(const TString &str) { fMuonSource = str; } virtual void SetMuonSpecies(const TString &str) { fMuonSpecies = str; } + virtual void SetMuonBeamMomentum(const Double_t dval) { fMuonBeamMomentum = dval; } virtual void SetRunName(const TString &str) { fRunName = str; } virtual void SetRunNumber(const Int_t &val) { fRunNumber = val; } virtual void SetRunTitle(const TString str) { fRunTitle = str; } @@ -328,7 +418,9 @@ class PRawRunData { virtual void SetStopTime(const TString str) { fStopTime = str; } virtual void SetStopDate(const TString str) { fStopDate = str; } virtual void SetStopDateTime(const time_t val) { fStopDateTimeSec = val; } + virtual void SetMagnetName(const TString str) { fMagnet = str; } virtual void SetField(const Double_t dval) { fField = dval; } + virtual void SetCryoName(const TString str) { fCryo = str; } virtual void SetSample(const TString str) { fSample = str; } virtual void SetOrientation(const TString str) { fOrientation = str; } virtual void ClearTemperature() { fTemp.clear(); } @@ -338,24 +430,27 @@ class PRawRunData { virtual void SetTransport(const Double_t dval) { fTransport = dval; } virtual void SetRingAnode(const UInt_t idx, const Double_t dval); virtual void SetTimeResolution(const Double_t dval) { fTimeResolution = dval; } - virtual void AppendT0(const Int_t ival) { fT0s.push_back(ival); } - virtual void AppendT0Estimated(const Int_t ival) { fT0Estimated.push_back(ival); } - virtual void AppendBkgBin(PIntPair pair) { fBkgBin.push_back(pair); } - virtual void AppendGoodDataBin(PIntPair pair) { fGoodDataBin.push_back(pair); } - virtual void AppendDataBin(PDoubleVector data) { fDataBin.push_back(data); } - virtual void SetDataBin(const UInt_t histoNo, const UInt_t bin, const Double_t dval); - virtual void AddDataBin(const UInt_t histoNo, const UInt_t bin, const Double_t dval); + virtual void SetRedGreenOffset(PIntVector &ivec) { fRedGreenOffset = ivec; } + virtual void SetDataSet(PRawRunDataSet &dataSet, UInt_t idx=-1) { fData.Set(dataSet, idx); } PNonMusrRawRunData fDataNonMusr; ///< keeps all ascii- or db-file info in case of nonMusr fit private: + TString fVersion; ///< keeps the version information of the data file + TString fGenericValidatorURL; ///< keeps the generic validator MusrRoot URL + TString fSpecificValidatorURL; ///< keeps the instrument specific validator MusrRoot URL + TString fGenerator; ///< keeps the data file generator name + TString fComment; ///< keeps the data file comment + TString fFileName; ///< keeps the name of the original data file TString fLaboratory; ///< keeps the name of the laboratory, e.g. PSI, ISIS, TRIUMF, JPARC TString fBeamline; ///< keeps the name of the be beamline, e.g. muE4, piM3.1, ... TString fInstrument; ///< keeps the name of the instrument, e.g. LEM, GPS, MUSR, EMU, ... + TString fArea; ///< keeps the beam area TString fMuonSource; ///< keeps the type of muon source, e.g. continous surface beam, pulsed beam, low energy muon beam TString fMuonSpecies; ///< positive muon or negative muon - TString fRunName; ///< name of the run - Int_t fRunNumber; ///< run number + Double_t fMuonBeamMomentum; ///< given in MeV/c, for LEM this is the momentum of the secondary beamline and NOT the momentum of the low energy beam + TString fRunName; ///< name of the run as found in the msr-file + Int_t fRunNumber; ///< run number TString fRunTitle; ///< run title TString fSetup; ///< description of the setup of this run TString fStartTime; ///< start time of the run @@ -364,19 +459,19 @@ class PRawRunData { TString fStopTime; ///< stop time of the run TString fStopDate; ///< stop date of the run time_t fStopDateTimeSec; ///< stop run given as time_t object + TString fCryo; ///< name of the cryo TString fSample; ///< description of the sample TString fOrientation; ///< description of the orientation - Double_t fField; ///< magnetic field value + TString fMagnet; ///< name of the sample magnet + Double_t fField; ///< magnetic field value in (G) PDoublePairVector fTemp; ///< measured temperatures and standard deviations during the run Double_t fEnergy; ///< implantation energy of the muon Double_t fTransport; ///< LEM transport settings (Moderator HV) PDoubleVector fRingAnode; ///< LEM ring anode HVs (L,R[,T,B]) Double_t fTimeResolution; ///< time resolution of the run in (ns) - PIntVector fT0s; ///< vector of t0's of a run - PIntVector fT0Estimated; ///< vector of t0's estimated based on the maximum of the histogram - PIntPairVector fBkgBin; ///< background bins (first/last) - PIntPairVector fGoodDataBin; ///< data bins (first/last) - vector fDataBin; ///< vector of all histos of a run + PIntVector fRedGreenOffset; ///< keeps the Red/Green offsets + + PRawRunDataVector fData; ///< keeps the histos together with the histo related properties such as T0, first good bin, etc. }; //------------------------------------------------------------- @@ -461,11 +556,11 @@ class PMsrRunBlock { virtual Double_t GetBkgFix(UInt_t idx); virtual Int_t GetBkgRange(UInt_t idx); virtual Int_t GetDataRange(UInt_t idx); - virtual UInt_t GetT0Size() { return fT0.size(); } - virtual Int_t GetT0(UInt_t idx=0); - virtual UInt_t GetAddT0Entries() { return fAddT0.size(); } - virtual Int_t GetAddT0Size(UInt_t addRunIdx); - virtual Int_t GetAddT0(UInt_t addRunIdx, UInt_t histoIdx); + virtual UInt_t GetT0BinSize() { return fT0.size(); } + virtual Double_t GetT0Bin(UInt_t idx=0); + virtual UInt_t GetAddT0BinEntries() { return fAddT0.size(); } + virtual Int_t GetAddT0BinSize(UInt_t addRunIdx); + virtual Double_t GetAddT0Bin(UInt_t addRunIdx, UInt_t histoIdx); virtual Double_t GetFitRange(UInt_t idx); virtual Int_t GetPacking() { return fPacking; } virtual Int_t GetXDataIndex() { return fXYDataIndex[0]; } @@ -493,8 +588,8 @@ class PMsrRunBlock { virtual void SetBkgFix(Double_t dval, Int_t idx); virtual void SetBkgRange(Int_t ival, Int_t idx); virtual void SetDataRange(Int_t ival, Int_t idx); - virtual void SetT0(Int_t ival, Int_t idx=-1); - virtual void SetAddT0(Int_t ival, UInt_t addRunIdx, UInt_t histoNoIdx); + virtual void SetT0Bin(Double_t dval, Int_t idx=-1); + virtual void SetAddT0Bin(Double_t dval, UInt_t addRunIdx, UInt_t histoNoIdx); virtual void SetFitRange(Double_t dval, UInt_t idx); virtual void SetPacking(Int_t ival) { fPacking = ival; } virtual void SetXDataIndex(Int_t ival) { fXYDataIndex[0] = ival; } @@ -523,8 +618,8 @@ class PMsrRunBlock { Double_t fBkgFix[2]; ///< fixed background in (1/ns) (fit type 0, 2, 4) Int_t fBkgRange[4]; ///< background bin range (fit type 0, 2, 4) Int_t fDataRange[4]; ///< data bin range (fit type 0, 2, 4) - PIntVector fT0; ///< t0 bins (fit type 0, 2, 4). if fit type 0 -> f0, f1, f2, ...; if fit type 2, 4 -> f0, b0, f1, b1, ... - vector fAddT0; ///< t0 bins for addrun's + PDoubleVector fT0; ///< t0 bins (fit type 0, 2, 4). if fit type 0 -> f0, f1, f2, ...; if fit type 2, 4 -> f0, b0, f1, b1, ... + vector fAddT0; ///< t0 bins for addrun's Double_t fFitRange[2]; ///< fit range in (us) Int_t fPacking; ///< packing/rebinning Int_t fXYDataIndex[2]; ///< used to get the data indices when using db-files (fit type 8) diff --git a/src/include/PMusrCanvas.h b/src/include/PMusrCanvas.h index 67a786ea..d8986aa3 100644 --- a/src/include/PMusrCanvas.h +++ b/src/include/PMusrCanvas.h @@ -10,7 +10,7 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007 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 * diff --git a/src/include/PMusrCanvasLinkDef.h b/src/include/PMusrCanvasLinkDef.h index 90bebeeb..64f6e0cf 100644 --- a/src/include/PMusrCanvasLinkDef.h +++ b/src/include/PMusrCanvasLinkDef.h @@ -10,7 +10,7 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007 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 * diff --git a/src/include/PMusrT0.h b/src/include/PMusrT0.h index 74e8e433..27133eca 100644 --- a/src/include/PMusrT0.h +++ b/src/include/PMusrT0.h @@ -10,7 +10,7 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2009 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 * @@ -77,12 +77,12 @@ class PMusrT0Data { virtual Int_t GetHistoNo(UInt_t idx); virtual Int_t GetDetectorTag() { return fDetectorTag; } virtual Int_t GetCmdTag() { return fCmdTag; } - virtual UInt_t GetT0Size() { return fT0.size(); } - virtual Int_t GetT0(UInt_t idx); + virtual UInt_t GetT0BinSize() { return fT0.size(); } + virtual Int_t GetT0Bin(UInt_t idx); virtual UInt_t GetAddT0Entries() { return fAddT0.size(); } - virtual UInt_t GetAddT0Size(UInt_t idx); - virtual Int_t GetAddT0(UInt_t addRunIdx, UInt_t idx); - virtual Int_t GetT0Data() { return fT0Data; } + virtual UInt_t GetAddT0BinSize(UInt_t idx); + virtual Int_t GetAddT0Bin(UInt_t addRunIdx, UInt_t idx); + virtual Int_t GetT0BinData() { return fT0Data; } virtual void SetSingleHisto(const Bool_t flag) { fSingleHisto = flag; } virtual void SetRawRunData(const vector rawRunData) { fRawRunData = rawRunData; } @@ -92,9 +92,9 @@ class PMusrT0Data { virtual void SetHistoNo(const PIntVector histoNo) { fHistoNo = histoNo; } virtual void SetDetectorTag(const UInt_t detectorTag) { fDetectorTag = detectorTag; } virtual void SetCmdTag(const UInt_t cmdTag) { fCmdTag = cmdTag; } - virtual void SetT0(UInt_t val, UInt_t idx); - virtual void SetAddT0(UInt_t val, UInt_t addRunIdx, UInt_t idx); - virtual void SetT0Data(UInt_t val) { fT0Data = val; } + virtual void SetT0Bin(UInt_t val, UInt_t idx); + virtual void SetAddT0Bin(UInt_t val, UInt_t addRunIdx, UInt_t idx); + virtual void SetT0BinData(UInt_t val) { fT0Data = val; } private: Bool_t fSingleHisto; ///< true if single histo fit, false for asymmetry fit @@ -102,7 +102,7 @@ class PMusrT0Data { Int_t fRunNo; ///< msr-file run number Int_t fAddRunIdx; ///< msr-file addrun index Int_t fHistoNoIdx; ///< msr-file histo number index - PIntVector fHistoNo; ///< msr-file histo numbers + PIntVector fHistoNo; ///< msr-file histo numbers, i.e. idx + Red/Green offset Int_t fDetectorTag; ///< detector tag. forward=0,backward=1 Int_t fCmdTag; ///< command tag. 0=get t0, 1=get data-/bkg-range, 2=get t0, and data-/bkg-range PIntVector fT0; ///< holding the t0's of the run diff --git a/src/include/PMusrT0LinkDef.h b/src/include/PMusrT0LinkDef.h index b9d8a144..eb6b517e 100644 --- a/src/include/PMusrT0LinkDef.h +++ b/src/include/PMusrT0LinkDef.h @@ -10,7 +10,7 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007 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 * diff --git a/src/include/PRunAsymmetry.h b/src/include/PRunAsymmetry.h index e6c2741f..6e193582 100644 --- a/src/include/PRunAsymmetry.h +++ b/src/include/PRunAsymmetry.h @@ -10,8 +10,8 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007 by Andreas Suter * - * andreas.suter@psi.c * + * Copyright (C) 2007-2012 by Andreas Suter * + * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * diff --git a/src/include/PRunBase.h b/src/include/PRunBase.h index 650adfcc..17a1a534 100644 --- a/src/include/PRunBase.h +++ b/src/include/PRunBase.h @@ -10,7 +10,7 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007 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 * @@ -76,7 +76,7 @@ class PRunBase PRunData fData; ///< data to be fitted, viewed, i.e. binned data Double_t fTimeResolution; ///< time resolution in (us) - PIntVector fT0s; ///< all t0's of a run! The derived classes will handle it + PDoubleVector fT0s; ///< all t0 bins of a run! The derived classes will handle it Double_t fFitStartTime; ///< fit start time Double_t fFitEndTime; ///< fit end time diff --git a/src/include/PRunDataHandler.h b/src/include/PRunDataHandler.h index 475a0db2..7df972f0 100644 --- a/src/include/PRunDataHandler.h +++ b/src/include/PRunDataHandler.h @@ -10,7 +10,7 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007 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 * @@ -61,8 +61,8 @@ class PRunDataHandler PStringVector fDataPath; ///< vector containing all the search paths where to look for data files Bool_t fAllDataAvailable; ///< flag indicating if all data sets could be read - TString fRunName; ///< current run name - TString fRunPathName; ///< current path file name + TString fRunName; ///< current run name + TString fRunPathName; ///< current path file name PRawRunDataList fData; ///< keeping all the raw data virtual Bool_t ReadFilesMsr(); @@ -71,7 +71,7 @@ class PRunDataHandler virtual void TestFileName(TString &runName, const TString &ext); virtual Bool_t FileExistsCheck(PMsrRunBlock &runInfo, const UInt_t idx); virtual Bool_t FileExistsCheck(const Bool_t fileName, const Int_t idx); - virtual Bool_t ReadRootFile(UInt_t tag); + virtual Bool_t ReadRootFile(); virtual Bool_t ReadNexusFile(); virtual Bool_t ReadWkmFile(); virtual Bool_t ReadPsiBinFile(); @@ -80,6 +80,7 @@ class PRunDataHandler virtual Bool_t ReadAsciiFile(); virtual Bool_t ReadDBFile(); + virtual Bool_t WriteMusrRootFile(TString fln=""); virtual Bool_t WriteRootFile(TString fln=""); virtual Bool_t WriteNexusFile(TString fln=""); virtual Bool_t WriteWkmFile(TString fln=""); @@ -97,6 +98,8 @@ class PRunDataHandler virtual TString FileNameFromTemplate(TString &fileNameTemplate, Int_t run, TString &year, Bool_t &ok); virtual bool DateToISO8601(string inDate, string &iso8601Date); virtual void SplitTimeDate(TString timeDate, TString &time, TString &date, Bool_t &ok); + virtual TString GetMonth(Int_t month); + virtual TString GetYear(Int_t month); }; #endif // _PRUNDATAHANDLER_H_ diff --git a/src/include/PRunListCollection.h b/src/include/PRunListCollection.h index 05ee6cf5..f890946c 100644 --- a/src/include/PRunListCollection.h +++ b/src/include/PRunListCollection.h @@ -10,8 +10,8 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007 by Andreas Suter * - * andreas.suter@psi.c * + * Copyright (C) 2007-2012 by Andreas Suter * + * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * diff --git a/src/include/PRunMuMinus.h b/src/include/PRunMuMinus.h index 6e316b33..7d8d2521 100644 --- a/src/include/PRunMuMinus.h +++ b/src/include/PRunMuMinus.h @@ -10,8 +10,8 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007 by Andreas Suter * - * andreas.suter@psi.c * + * Copyright (C) 2007-2012 by Andreas Suter * + * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * diff --git a/src/include/PRunNonMusr.h b/src/include/PRunNonMusr.h index 4f33fff6..bd2c40af 100644 --- a/src/include/PRunNonMusr.h +++ b/src/include/PRunNonMusr.h @@ -10,8 +10,8 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007 by Andreas Suter * - * andreas.suter@psi.c * + * Copyright (C) 2007-2012 by Andreas Suter * + * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * diff --git a/src/include/PRunSingleHisto.h b/src/include/PRunSingleHisto.h index 3b147d10..6474f22a 100644 --- a/src/include/PRunSingleHisto.h +++ b/src/include/PRunSingleHisto.h @@ -10,8 +10,8 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007 by Andreas Suter * - * andreas.suter@psi.c * + * Copyright (C) 2007-2012 by Andreas Suter * + * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -63,6 +63,8 @@ class PRunSingleHisto : public PRunBase UInt_t fNoOfFitBins; ///< number of bins to be fitted Double_t fBackground; ///< needed if background range is given (units: 1/bin) + PDoubleVector fForward; ///< forward histo data + virtual Bool_t EstimateBkg(UInt_t histoNo); virtual Bool_t IsScaleN0AndBkg(); }; diff --git a/src/include/PStartupHandler.h b/src/include/PStartupHandler.h index dedde505..20c0d330 100644 --- a/src/include/PStartupHandler.h +++ b/src/include/PStartupHandler.h @@ -10,8 +10,8 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007 by Andreas Suter * - * andreas.suter@psi.c * + * Copyright (C) 2007-2012 by Andreas Suter * + * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * diff --git a/src/include/PStartupHandlerLinkDef.h b/src/include/PStartupHandlerLinkDef.h index 78ba7e1a..ab61c81f 100644 --- a/src/include/PStartupHandlerLinkDef.h +++ b/src/include/PStartupHandlerLinkDef.h @@ -10,8 +10,8 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007 by Andreas Suter * - * andreas.suter@psi.c * + * Copyright (C) 2007-2012 by Andreas Suter * + * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * diff --git a/src/include/PTheory.h b/src/include/PTheory.h index fae70586..49070744 100644 --- a/src/include/PTheory.h +++ b/src/include/PTheory.h @@ -10,8 +10,8 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007 by Andreas Suter * - * andreas.suter@psi.c * + * Copyright (C) 2007-2012 by Andreas Suter * + * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * diff --git a/src/include/PUserFcn.h b/src/include/PUserFcn.h index 5ac2fc63..3f8beb18 100644 --- a/src/include/PUserFcn.h +++ b/src/include/PUserFcn.h @@ -10,8 +10,8 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007 by Andreas Suter * - * andreas.suter@psi.c * + * Copyright (C) 2007-2012 by Andreas Suter * + * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * diff --git a/src/include/PUserFcnBase.h b/src/include/PUserFcnBase.h index 20afc39e..a58237a5 100644 --- a/src/include/PUserFcnBase.h +++ b/src/include/PUserFcnBase.h @@ -10,8 +10,8 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007 by Andreas Suter * - * andreas.suter@psi.c * + * Copyright (C) 2007-2012 by Andreas Suter * + * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * diff --git a/src/include/PUserFcnBaseLinkDef.h b/src/include/PUserFcnBaseLinkDef.h index 52c8381c..ab49bb15 100644 --- a/src/include/PUserFcnBaseLinkDef.h +++ b/src/include/PUserFcnBaseLinkDef.h @@ -10,8 +10,8 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2007 by Andreas Suter * - * andreas.suter@psi.c * + * Copyright (C) 2007-2012 by Andreas Suter * + * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * diff --git a/src/msr2data.cpp b/src/msr2data.cpp index 935dbe33..27591b65 100644 --- a/src/msr2data.cpp +++ b/src/msr2data.cpp @@ -79,6 +79,7 @@ bool isNumber(const string &s) */ void msr2data_syntax() { + cout << endl << "usage 0: msr2data [--version] | [--help]"; cout << endl << "usage 1: msr2data [-o] [new] [data] [[no]header] [nosummary] [global[+[!]]]"; cout << endl << " [fit [-k] [-t] | fit-