first implementation of MusrRoot. Cleaner handling of Red/Green mode data. General cleanup

This commit is contained in:
suter_a 2012-03-22 07:00:34 +00:00
parent 59df2224ba
commit 138e7ba369
85 changed files with 5899 additions and 2541 deletions

View File

@ -4,6 +4,14 @@
# $Id$ # $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 changes since 0.9.0
=================================== ===================================
NEW 2011-12-22 added nexus_dump. It is used to dump nexus files in an ascii NEW 2011-12-22 added nexus_dump. It is used to dump nexus files in an ascii

View File

@ -1,7 +1,7 @@
AC_REVISION([$Id$]) AC_REVISION([$Id$])
AC_PREREQ(2.59) 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_CONFIG_AUX_DIR(admin)
AC_CANONICAL_HOST AC_CANONICAL_HOST
#AC_MSG_RESULT([${host} ${host_cpu} ${host_vendor} ${host_os}]) #AC_MSG_RESULT([${host} ${host_cpu} ${host_vendor} ${host_os}])
@ -21,6 +21,7 @@ dnl -----------------------------------------------
MUSR_PROGRAM_NAME=musrfit MUSR_PROGRAM_NAME=musrfit
MUSR_LIBRARY_NAME=PMusr MUSR_LIBRARY_NAME=PMusr
USERFCN_LIBRARY_NAME=PUserFcnBase USERFCN_LIBRARY_NAME=PUserFcnBase
MUSR_ROOT_LIBRARY_NAME=TMusrRunHeader
LEM_LIBRARY_NAME=TLemRunHeader LEM_LIBRARY_NAME=TLemRunHeader
PSIBIN_LIBRARY_NAME=Class_MuSR_PSI PSIBIN_LIBRARY_NAME=Class_MuSR_PSI
MUD_LIBRARY_NAME=mud MUD_LIBRARY_NAME=mud
@ -34,9 +35,14 @@ dnl -----------------------------------------------
#release versioning #release versioning
MUSR_MAJOR_VERSION=0 MUSR_MAJOR_VERSION=0
MUSR_MINOR_VERSION=9 MUSR_MINOR_VERSION=10
MUSR_MICRO_VERSION=0 MUSR_MICRO_VERSION=0
#release versioning
MUSR_ROOT_MAJOR_VERSION=1
MUSR_ROOT_MINOR_VERSION=0
MUSR_ROOT_MICRO_VERSION=0
#release versioning #release versioning
LEM_MAJOR_VERSION=1 LEM_MAJOR_VERSION=1
LEM_MINOR_VERSION=5 LEM_MINOR_VERSION=5
@ -71,6 +77,9 @@ CUBA_MICRO_VERSION=0
MUSR_API_VERSION=$MUSR_MAJOR_VERSION.$MUSR_MINOR_VERSION MUSR_API_VERSION=$MUSR_MAJOR_VERSION.$MUSR_MINOR_VERSION
AC_SUBST(MUSR_API_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 LEM_API_VERSION=$LEM_MAJOR_VERSION.$LEM_MINOR_VERSION
AC_SUBST(LEM_API_VERSION) AC_SUBST(LEM_API_VERSION)
@ -92,6 +101,7 @@ AC_SUBST(CUBA_API_VERSION)
#shared library versioning #shared library versioning
CUBA_LIBRARY_VERSION=$CUBA_MAJOR_VERSION:$CUBA_MINOR_VERSION:$CUBA_MICRO_VERSION CUBA_LIBRARY_VERSION=$CUBA_MAJOR_VERSION:$CUBA_MINOR_VERSION:$CUBA_MICRO_VERSION
PLUGIN_LIBRARY_VERSION=$PLUGIN_MAJOR_VERSION:$PLUGIN_MINOR_VERSION:$PLUGIN_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 LEM_LIBRARY_VERSION=$LEM_MAJOR_VERSION:$LEM_MINOR_VERSION:$LEM_MICRO_VERSION
PSIBIN_LIBRARY_VERSION=$PSIBIN_MAJOR_VERSION:$PSIBIN_MINOR_VERSION:$PSIBIN_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 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 # +- increment if interfaces have been added, removed or changed
AC_SUBST(MUSR_LIBRARY_VERSION) AC_SUBST(MUSR_LIBRARY_VERSION)
AC_SUBST(MUSR_ROOT_LIBRARY_VERSION)
AC_SUBST(LEM_LIBRARY_VERSION) AC_SUBST(LEM_LIBRARY_VERSION)
AC_SUBST(PSIBIN_LIBRARY_VERSION) AC_SUBST(PSIBIN_LIBRARY_VERSION)
AC_SUBST(MUD_LIBRARY_VERSION) AC_SUBST(MUD_LIBRARY_VERSION)
@ -123,6 +134,7 @@ AC_SUBST(CUBA_LIBRARY_VERSION)
PACKAGE=$MUSR_PROGRAM_NAME PACKAGE=$MUSR_PROGRAM_NAME
AC_SUBST(MUSR_LIBRARY_NAME) AC_SUBST(MUSR_LIBRARY_NAME)
AC_SUBST(USERFCN_LIBRARY_NAME) AC_SUBST(USERFCN_LIBRARY_NAME)
AC_SUBST(MUSR_ROOT_LIBRARY_NAME)
AC_SUBST(LEM_LIBRARY_NAME) AC_SUBST(LEM_LIBRARY_NAME)
AC_SUBST(PSIBIN_LIBRARY_NAME) AC_SUBST(PSIBIN_LIBRARY_NAME)
AC_SUBST(MUD_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_RELEASE)
AC_SUBST(LEM_VERSION) 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_VERSION=$MUSR_MAJOR_VERSION.$MUSR_MINOR_VERSION.$MUSR_MICRO_VERSION
MUSR_RELEASE=$MUSR_MAJOR_VERSION.$MUSR_MINOR_VERSION MUSR_RELEASE=$MUSR_MAJOR_VERSION.$MUSR_MINOR_VERSION
AC_SUBST(MUSR_RELEASE) 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]) 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 -----------------------------------------------
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 ----------------------------------------------- dnl -----------------------------------------------
SRCDIR="$(pwd)/src" SRCDIR="$(pwd)/src"
@ -668,6 +685,12 @@ LEM_CFLAGS="-I${LEM_SRCDIR}"
AC_SUBST(LEM_LIBS) AC_SUBST(LEM_LIBS)
AC_SUBST(LEM_CFLAGS) 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_LIBS="${SRCDIR}/classes/lib${MUSR_LIBRARY_NAME}.la"
PMUSR_CFLAGS="-I${SRCDIR}/include" PMUSR_CFLAGS="-I${SRCDIR}/include"
AC_SUBST(PMUSR_LIBS) AC_SUBST(PMUSR_LIBS)
@ -1023,6 +1046,8 @@ AC_CONFIG_FILES([Makefile \
src/classes/PMusr.pc \ src/classes/PMusr.pc \
src/classes/PUserFcnBase.pc \ src/classes/PUserFcnBase.pc \
src/external/Makefile \ src/external/Makefile \
src/external/MusrRoot/Makefile \
src/external/MusrRoot/TMusrRunHeader.pc \
src/external/TLemRunHeader/Makefile \ src/external/TLemRunHeader/Makefile \
src/external/TLemRunHeader/TLemRunHeader.pc \ src/external/TLemRunHeader/TLemRunHeader.pc \
src/external/MuSR_software/Makefile \ src/external/MuSR_software/Makefile \
@ -1140,11 +1165,12 @@ echo " musrfit (including musrfit, musrview, musrt0, musrparam,"
echo " msr2msr, msr2data, any2many): yes" echo " msr2msr, msr2data, any2many): yes"
echo "" echo ""
echo " Supported muSR file formats:" echo " Supported muSR file formats:"
echo " MusrRoot: yes"
echo " ROOT (LEM): yes"
echo " MUD: yes" echo " MUD: yes"
echo " PSI-BIN: yes" echo " PSI-BIN: yes"
echo " PSI-MDU: yes" echo " PSI-MDU: yes"
echo " WKM: yes" echo " WKM: yes"
echo " ROOT (LEM): yes"
if test "${PNEXUS_ENABLED}" -eq 1; then if test "${PNEXUS_ENABLED}" -eq 1; then
echo " NeXus: yes" echo " NeXus: yes"
else else

View File

@ -2,8 +2,8 @@ MgB12H12 No2 ZF T=150
############################################################### ###############################################################
FITPARAMETER FITPARAMETER
# Nr. Name Value Step Pos_Error Boundaries # Nr. Name Value Step Pos_Error Boundaries
1 alpha 1.0 0.0 none 0 2 1 alpha 1 0 none 0 2
2 asy 0.17503 -0.00081 0.00083 0 0.33 2 asy 0.17503 -0.00082 0.00083 0 0.33
3 rate 0.1649 -0.0016 0.0016 0 none 3 rate 0.1649 -0.0016 0.0016 0 none
4 beta 0.892 -0.016 0.016 0.5 2 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) fittype 2 (asymmetry fit)
alpha 1 alpha 1
map 0 0 0 0 0 0 0 0 0 0 0 map 0 0 0 0 0 0 0 0 0 0 0
forward 1 forward 1
backward 2 backward 2
background 79 391 80 409 background 79 391 80 409 # estimated bkg: 21.0224 / 17.1702
data 438 12785 436 12787 data 438 12785 436 12787
t0 432 431 t0 432.0 431.0
fit 0 8 fit 0 8
packing 100 packing 100
@ -51,5 +51,5 @@ runs 1
range 0 8 0 0.25 range 0 8 0 0.25
############################################################### ###############################################################
STATISTIC --- 2011-02-06 15:03:19 STATISTIC --- 2012-03-20 10:11:27
chisq = 133.92904274288378, NDF = 99, chisq/NDF = 1.3528186135644826 chisq = 133.9, NDF = 99, chisq/NDF = 1.352819

View File

@ -53,5 +53,5 @@ range 0 14 -0.22 0.22
view_packing 5 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 chisq = 796.7, NDF = 846, chisq/NDF = 0.941749

View File

@ -27,7 +27,7 @@ forward 2
backward 1 backward 1
background 61 184 57 145 background 61 184 57 145
data 207 7994 167 8009 data 207 7994 167 8009
t0 202 162 t0 202.0 162.0
fit 0 8 fit 0 8
packing 18 packing 18
@ -55,5 +55,5 @@ range 0 8 -0.3 0.3
view_packing 38 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 chisq = 554.2, NDF = 351, chisq/NDF = 1.578917

View File

@ -3,16 +3,16 @@ Temperature = 300 K, Magnetic Field = 20 Gauss, Sample = CAS
FITPARAMETER FITPARAMETER
# No Name Value Step Pos_Error Boundaries # No Name Value Step Pos_Error Boundaries
1 zero 0 0 none 1 zero 0 0 none
2 phase 11.43 -0.35 0.34 0 100 2 phase 11.45 -0.34 0.35 0 100
3 field 20.181 -0.028 0.028 0 none 3 field 20.179 -0.028 0.028 0 none
4 asym 0.1876 -0.0010 0.0010 0 0.3 4 asym 0.1877 -0.0010 0.0010 0 0.3
5 rate 0.1254 -0.0024 0.0024 0 100 5 rate 0.1257 -0.0024 0.0023 0 100
6 beta 1 0 none 6 beta 1 0 none
7 Norm_L 2863.3 -1.4 1.4 7 Norm_L 2863.4 -1.4 1.4
8 BG_L 0.000000000047 -0.000000000047 0.009142577870 0 none 8 BG_L 0 0 none
9 Norm_R 2024.4 -1.1 1.2 0 none 9 Norm_R 2024.3 -1.1 1.2 0 none
10 BG_R 0.0000 -0.0000 0.0017 0 none 10 BG_R 0 0 none 0 none
11 relPhase 172.23 -0.37 0.36 0 none 11 relPhase 172.25 -0.37 0.36 0 none
############################################################### ###############################################################
THEORY THEORY
@ -32,7 +32,7 @@ norm 7
backgr.fit 8 backgr.fit 8
lifetimecorrection lifetimecorrection
map 1 0 0 0 0 0 0 0 0 0 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 data 40 1500
fit 0.2 20 fit 0.2 20
packing 1 packing 1
@ -43,7 +43,7 @@ norm 9
backgr.fit 10 backgr.fit 10
lifetimecorrection lifetimecorrection
map 11 0 0 0 0 0 0 0 0 0 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 data 40 1500
fit 0.2 20 fit 0.2 20
packing 1 packing 1
@ -70,5 +70,5 @@ range 0 20 -0.3 0.3
view_packing 5 view_packing 5
############################################################### ###############################################################
STATISTIC --- 2011-04-08 10:54:21 STATISTIC --- 2012-03-20 10:28:21
chisq = 3051.73767, NDF = 2465, chisq/NDF = 1.23802745 chisq = 3272.6, NDF = 2469, chisq/NDF = 1.325481

View File

@ -3,7 +3,7 @@ nc-ZnO T=80 F=69
FITPARAMETER FITPARAMETER
# No Name Value Step Pos_Error Boundaries # No Name Value Step Pos_Error Boundaries
1 zero 0 0 none 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 3 field 70.996 -0.035 0.035 0 none
4 asym 0.1698 -0.0016 0.0017 0 0.3 4 asym 0.1698 -0.0016 0.0017 0 0.3
5 rate 0.1523 -0.0023 0.0023 0 100 5 rate 0.1523 -0.0023 0.0023 0 100
@ -70,5 +70,5 @@ range 0 14 -0.22 0.22
view_packing 5 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 chisq = 2643.1, NDF = 1696, chisq/NDF = 1.558403

View File

@ -12,7 +12,8 @@ if BUILD_MUSREDIT
EDITORDIR = musredit EDITORDIR = musredit
endif endif
SUBDIRS = external/TLemRunHeader \ SUBDIRS = external/MusrRoot \
external/TLemRunHeader \
external/MuSR_software \ external/MuSR_software \
external/mud \ external/mud \
$(PNEXUSDIRS) \ $(PNEXUSDIRS) \
@ -29,35 +30,38 @@ SUBDIRS += $(EDITORDIR)
EXTRA_DIST = $(EDITORDIR)/Makefile EXTRA_DIST = $(EDITORDIR)/Makefile
endif endif
bin_PROGRAMS = musrfit musrview musrt0 musrparam msr2msr msr2data any2many bin_PROGRAMS = musrfit musrview musrt0 msr2msr msr2data any2many
if PNEXUS_ENABLED if PNEXUS_ENABLED
bin_PROGRAMS += nexus_dump bin_PROGRAMS += nexus_dump
endif endif
bin_PROGRAMS += read_musrRoot_runHeader write_musrRoot_runHeader
musrfit_SOURCES = musrfit.cpp musrfit_SOURCES = musrfit.cpp
musrview_SOURCES = musrview.cpp musrview_SOURCES = musrview.cpp
musrt0_SOURCES = musrt0.cpp musrt0_SOURCES = musrt0.cpp
musrparam_SOURCES = musrparam.cpp
msr2msr_SOURCES = msr2msr.cpp msr2msr_SOURCES = msr2msr.cpp
msr2data_SOURCES = msr2data.cpp msr2data_SOURCES = msr2data.cpp
any2many_SOURCES = any2many.cpp any2many_SOURCES = any2many.cpp
if PNEXUS_ENABLED if PNEXUS_ENABLED
nexus_dump_SOURCES = nexus_dump.cpp nexus_dump_SOURCES = nexus_dump.cpp
endif endif
read_musrRoot_runHeader_SOURCES = read_musrRoot_runHeader.cpp
write_musrRoot_runHeader_SOURCES = write_musrRoot_runHeader.cpp
xmldir = $(bindir) xmldir = $(bindir)
xml_DATA = musrfit_startup.xml 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_CXXFLAGS = $(LOCAL_BIN_CXXFLAGS)
AM_LDFLAGS = $(LOCAL_BIN_LDFLAGS) 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 if PNEXUS_ENABLED
INCLUDES += $(HDF5_CFLAGS) $(NEXUS_CFLAGS) $(PNEXUS_CXXFLAGS) INCLUDES += $(HDF5_CFLAGS) $(NEXUS_CFLAGS) $(PNEXUS_CXXFLAGS)
endif 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) install-xmlDATA: $(xml_DATA)
test -z "$(xmldir)" || $(mkdir_p) "$(DESTDIR)$(xmldir)" test -z "$(xmldir)" || $(mkdir_p) "$(DESTDIR)$(xmldir)"

View File

@ -10,7 +10,7 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.ch * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * 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 << " year, i.e. [yyyy] will result in something like 1999.";
cout << endl << " -c <convert-options> : <inFormat> <outFormat>"; cout << endl << " -c <convert-options> : <inFormat> <outFormat>";
cout << endl << " <inFormat> : input data file format. Supported formats are:"; cout << endl << " <inFormat> : 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 << " <outFormat> : ouput data file format. Supported formats are:"; cout << endl << " <outFormat> : 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 << " NeXus2-HDF4, NeXus2-HDF5, NeXus2-XML, WKM, ASCII";
cout << endl << " -p <output-path> : where <output-path> is the output path for the"; cout << endl << " -p <output-path> : where <output-path> is the output path for the";
cout << endl << " converted files. If nothing is given, the current directory"; 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 << " 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 << " 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 << " 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 << " any2many -f 2010/lem10_his_0123.root -c MusrRoot NEXUS2-HDF5 -o 2010/lem10_his_0123_v2.nxs";
cout << endl << " Will take the LEM ROOT file '2010/lem10_his_0123.root' "; 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 << " 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 << " 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 \\"; 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 << " 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 << " ASCII output and instead of saving them into a file, they will be spit to";
cout << endl << " the standard output." << endl; 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 << " 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 << " Will take the runs 100 through 117 and convert the NEXUS input files";
cout << endl << " to ROOT output. Afterwards these new files will be collected in a"; 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 << " 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 << " 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 << " 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"; cout << endl << " name, e.g. 2010/lem10_his_0123_rebin25.root";
@ -146,6 +146,7 @@ int main(int argc, char *argv[])
TString outputFileName = TString(""); TString outputFileName = TString("");
// init inputFormat // init inputFormat
inputFormat.push_back("musrroot");
inputFormat.push_back("psi-bin"); inputFormat.push_back("psi-bin");
inputFormat.push_back("root"); inputFormat.push_back("root");
inputFormat.push_back("mud"); inputFormat.push_back("mud");
@ -155,6 +156,7 @@ int main(int argc, char *argv[])
// init outputFormat // init outputFormat
outputFormat.push_back("psi-bin"); outputFormat.push_back("psi-bin");
outputFormat.push_back("musrroot");
outputFormat.push_back("root"); outputFormat.push_back("root");
outputFormat.push_back("mud"); outputFormat.push_back("mud");
outputFormat.push_back("nexus1-hdf4"); outputFormat.push_back("nexus1-hdf4");
@ -186,7 +188,7 @@ int main(int argc, char *argv[])
if (strstr(argv[1], "--h")) if (strstr(argv[1], "--h"))
any2many_syntax(); any2many_syntax();
else if (strstr(argv[1], "--v")) else if (strstr(argv[1], "--v"))
cout << endl << "any2many version: $Id$" << endl << endl; cout << endl << "any2many version: " << PMUSR_VERSION << " / $Id$" << endl << endl;
else { else {
any2many_syntax(); any2many_syntax();
return PMUSR_WRONG_STARTUP_SYNTAX; return PMUSR_WRONG_STARTUP_SYNTAX;

View File

@ -76,7 +76,7 @@ dict_cpp_sources_userFcn = \
include_HEADERS = $(h_sources) $(h_sources_userFcn) include_HEADERS = $(h_sources) $(h_sources_userFcn)
noinst_HEADERS = $(h_linkdef) $(dict_h_sources) $(h_linkdef_userFcn) $(dict_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) AM_CXXFLAGS = $(LOCAL_LIB_CXXFLAGS)
BUILT_SOURCES = $(dict_cpp_sources) $(dict_h_sources) $(dict_cpp_sources_userFcn) $(dict_h_sources_userFcn) 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) 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_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) libPMusr_la_LDFLAGS = -version-info $(MUSR_LIBRARY_VERSION) -release $(MUSR_RELEASE) $(AM_LDFLAGS)
pkgconfigdir = $(libdir)/pkgconfig pkgconfigdir = $(libdir)/pkgconfig

View File

@ -10,8 +10,8 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.c * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * 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 * * it under the terms of the GNU General Public License as published by *

View File

@ -10,8 +10,8 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.c * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * 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 * * it under the terms of the GNU General Public License as published by *

View File

@ -10,8 +10,8 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2008 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.c * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * 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 * * it under the terms of the GNU General Public License as published by *

View File

@ -10,8 +10,8 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.c * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * 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 * * it under the terms of the GNU General Public License as published by *

View File

@ -10,8 +10,8 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.c * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * 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 * * it under the terms of the GNU General Public License as published by *

View File

@ -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 * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * This program is free software; you can redistribute it and/or modify *

View File

@ -10,7 +10,7 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007-2010 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.ch * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * 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; PBoolVector bvec;
for (UInt_t i=0; i<fRuns.size(); i++) { for (UInt_t i=0; i<fRuns.size(); i++) {
bvec.clear(); bvec.clear();
for (UInt_t j=0; j<fRuns[i].GetAddT0Entries(); j++) for (UInt_t j=0; j<fRuns[i].GetAddT0BinEntries(); j++)
bvec.push_back(true); bvec.push_back(true);
addt0TagMissing.push_back(bvec); addt0TagMissing.push_back(bvec);
} }
@ -775,24 +775,28 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages)
fout << endl; fout << endl;
} else if (sstr.BeginsWith("t0")) { } else if (sstr.BeginsWith("t0")) {
t0TagMissing[runNo] = false; t0TagMissing[runNo] = false;
fout.width(16); fout.width(16);
fout << left << "t0"; fout << left << "t0";
for (UInt_t j=0; j<fRuns[runNo].GetT0Size(); j++) { for (UInt_t j=0; j<fRuns[runNo].GetT0BinSize(); j++) {
fout.width(8); fout.width(8);
fout << left << fRuns[runNo].GetT0(j); fout.precision(1);
fout.setf(ios::fixed,ios::floatfield);
fout << left << fRuns[runNo].GetT0Bin(j);
} }
fout << endl; fout << endl;
} else if (sstr.BeginsWith("addt0")) { } else if (sstr.BeginsWith("addt0")) {
addt0TagMissing[runNo][addT0Counter] = false; addt0TagMissing[runNo][addT0Counter] = false;
if (fRuns[runNo].GetAddT0Size(addT0Counter) <=0) { if (fRuns[runNo].GetAddT0BinSize(addT0Counter) <=0) {
cerr << endl << ">> PMsrHandler::WriteMsrLogFile: **WARNING** 'addt0' tag without any data found!"; cerr << endl << ">> PMsrHandler::WriteMsrLogFile: **WARNING** 'addt0' tag without any data found!";
cerr << endl << ">> Something is VERY fishy, please check your msr-file carfully." << endl; cerr << endl << ">> Something is VERY fishy, please check your msr-file carfully." << endl;
} else { } else {
fout.width(16); fout.width(16);
fout << left << "addt0"; fout << left << "addt0";
for (Int_t j=0; j<fRuns[runNo].GetAddT0Size(addT0Counter); j++) { for (Int_t j=0; j<fRuns[runNo].GetAddT0BinSize(addT0Counter); j++) {
fout.width(8); fout.width(8);
fout << left << fRuns[runNo].GetAddT0(addT0Counter, j); fout.precision(1);
fout.setf(ios::fixed,ios::floatfield);
fout << left << fRuns[runNo].GetAddT0Bin(addT0Counter, j);
} }
fout << endl; fout << endl;
addT0Counter++; addT0Counter++;
@ -820,25 +824,30 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages)
} }
} else if (sstr.BeginsWith("fit")) { } else if (sstr.BeginsWith("fit")) {
// check if missing t0/addt0/background/data tag are present eventhough the values are present, if so write these data values // check if missing t0/addt0/background/data tag are present eventhough the values are present, if so write these data values
if (t0TagMissing[runNo]) { // if ISIS data, do not do anything
if (fRuns[runNo].GetT0Size() > 0) { if (t0TagMissing[runNo] && fRuns[runNo].GetInstitute()->CompareTo("isis", TString::kIgnoreCase)) {
if (fRuns[runNo].GetT0BinSize() > 0) {
fout.width(16); fout.width(16);
fout << left << "t0"; fout << left << "t0";
for (UInt_t j=0; j<fRuns[runNo].GetT0Size(); j++) { for (UInt_t j=0; j<fRuns[runNo].GetT0BinSize(); j++) {
fout.width(8); fout.width(8);
fout << left << fRuns[runNo].GetT0(j); fout.precision(1);
fout.setf(ios::fixed,ios::floatfield);
fout << left << fRuns[runNo].GetT0Bin(j);
} }
fout << endl; fout << endl;
} }
} }
for (UInt_t i=0; i<fRuns[runNo].GetAddT0Entries(); i++) { for (UInt_t i=0; i<fRuns[runNo].GetAddT0BinEntries(); i++) {
if (addt0TagMissing[runNo][i]) { if (addt0TagMissing[runNo][i] && fRuns[runNo].GetInstitute()->CompareTo("isis", TString::kIgnoreCase)) {
if (fRuns[runNo].GetAddT0Size(i) > 0) { if (fRuns[runNo].GetAddT0BinSize(i) > 0) {
fout.width(16); fout.width(16);
fout << left << "addt0"; fout << left << "addt0";
for (Int_t j=0; j<fRuns[runNo].GetAddT0Size(i); j++) { for (Int_t j=0; j<fRuns[runNo].GetAddT0BinSize(i); j++) {
fout.width(8); fout.width(8);
fout << left << fRuns[runNo].GetAddT0(i, j); fout.precision(1);
fout.setf(ios::fixed,ios::floatfield);
fout << left << fRuns[runNo].GetAddT0Bin(i, j);
} }
fout << endl; fout << endl;
} }
@ -1621,24 +1630,28 @@ Int_t PMsrHandler::WriteMsrFile(const Char_t *filename, map<UInt_t, TString> *co
} }
// t0 // t0
if (fRuns[i].GetT0Size() > 0) { if (fRuns[i].GetT0BinSize() > 0) {
fout.width(16); fout.width(16);
fout << left << "t0"; fout << left << "t0";
for (UInt_t j=0; j<fRuns[i].GetT0Size(); ++j) { for (UInt_t j=0; j<fRuns[i].GetT0BinSize(); ++j) {
fout.width(8); fout.width(8);
fout << left << fRuns[i].GetT0(j); fout.precision(1);
fout.setf(ios::fixed,ios::floatfield);
fout << left << fRuns[i].GetT0Bin(j);
} }
fout << endl; fout << endl;
} }
// addt0 // addt0
for (UInt_t j = 0; j < fRuns[i].GetRunNameSize() - 1; ++j) { for (UInt_t j = 0; j < fRuns[i].GetRunNameSize() - 1; ++j) {
if (fRuns[i].GetAddT0Size(j) > 0) { if (fRuns[i].GetAddT0BinSize(j) > 0) {
fout.width(16); fout.width(16);
fout << left << "addt0"; fout << left << "addt0";
for (Int_t k=0; k<fRuns[i].GetAddT0Size(j); ++k) { for (Int_t k=0; k<fRuns[i].GetAddT0BinSize(j); ++k) {
fout.width(8); fout.width(8);
fout << left << fRuns[i].GetAddT0(j, k); fout.precision(1);
fout.setf(ios::fixed,ios::floatfield);
fout << left << fRuns[i].GetAddT0Bin(j, k);
} }
fout << endl; fout << endl;
} }
@ -2051,7 +2064,7 @@ Bool_t PMsrHandler::SetMsrParamPosError(UInt_t idx, Double_t value)
* \param idx msr-file histogram index * \param idx msr-file histogram index
* \param bin t0 bin value * \param bin t0 bin value
*/ */
void PMsrHandler::SetMsrT0Entry(UInt_t runNo, UInt_t idx, Int_t bin) void PMsrHandler::SetMsrT0Entry(UInt_t runNo, UInt_t idx, Double_t bin)
{ {
if (runNo >= fRuns.size()) { // error if (runNo >= fRuns.size()) { // error
cerr << endl << ">> PMsrHandler::SetMsrT0Entry: **ERROR** runNo = " << runNo << ", is out of valid range 0.." << fRuns.size(); 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; return;
} }
if (idx >= fRuns[runNo].GetT0Size()) { // error if (idx >= fRuns[runNo].GetT0BinSize()) { // error
cerr << endl << ">> PMsrHandler::SetMsrT0Entry: **WARNING** idx = " << idx << ", is out of valid range 0.." << fRuns[runNo].GetT0Size(); cerr << endl << ">> PMsrHandler::SetMsrT0Entry: **WARNING** idx = " << idx << ", is out of valid range 0.." << fRuns[runNo].GetT0BinSize();
cerr << endl << ">> Will add it anyway."; cerr << endl << ">> Will add it anyway.";
cerr << endl; 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 histoIdx msr-file histogram index for an addrun.
* \param bin t0 bin value. * \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 if (runNo >= fRuns.size()) { // error
cerr << endl << ">> PMsrHandler::SetMsrAddT0Entry: **ERROR** runNo = " << runNo << ", is out of valid range 0.." << fRuns.size(); 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; return;
} }
if (addRunIdx >= fRuns[runNo].GetAddT0Entries()) { // error if (addRunIdx >= fRuns[runNo].GetAddT0BinEntries()) { // error
cerr << endl << ">> PMsrHandler::SetMsrAddT0Entry: **WARNING** addRunIdx = " << addRunIdx << ", is out of valid range 0.." << fRuns[runNo].GetAddT0Entries(); cerr << endl << ">> PMsrHandler::SetMsrAddT0Entry: **WARNING** addRunIdx = " << addRunIdx << ", is out of valid range 0.." << fRuns[runNo].GetAddT0BinEntries();
cerr << endl << ">> Will add it anyway."; cerr << endl << ">> Will add it anyway.";
cerr << endl; cerr << endl;
} }
if (static_cast<Int_t>(histoIdx) > fRuns[runNo].GetAddT0Size(addRunIdx)) { // error if (static_cast<Int_t>(histoIdx) > fRuns[runNo].GetAddT0BinSize(addRunIdx)) { // error
cerr << endl << ">> PMsrHandler::SetMsrAddT0Entry: **WARNING** histoIdx = " << histoIdx << ", is out of valid range 0.." << fRuns[runNo].GetAddT0Size(addRunIdx); 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 << ">> Will add it anyway.";
cerr << endl; 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; UInt_t addT0Counter = 0;
Int_t ival; Int_t ival;
Double_t dval;
iter = lines.begin(); iter = lines.begin();
while ((iter != lines.end()) && !error) { while ((iter != lines.end()) && !error) {
@ -2860,10 +2874,10 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines)
for (Int_t i=1; i<tokens->GetEntries(); i++) { for (Int_t i=1; i<tokens->GetEntries(); i++) {
ostr = dynamic_cast<TObjString*>(tokens->At(i)); ostr = dynamic_cast<TObjString*>(tokens->At(i));
str = ostr->GetString(); str = ostr->GetString();
if (str.IsDigit()) { if (str.IsFloat()) {
ival = str.Atoi(); dval = str.Atof();
if (ival > 0) if (dval >= 0.0)
param.SetT0(ival); param.SetT0Bin(dval);
else else
error = true; error = true;
} else { } else {
@ -2884,10 +2898,10 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines)
for (Int_t i=1; i<tokens->GetEntries(); i++) { for (Int_t i=1; i<tokens->GetEntries(); i++) {
ostr = dynamic_cast<TObjString*>(tokens->At(i)); ostr = dynamic_cast<TObjString*>(tokens->At(i));
str = ostr->GetString(); str = ostr->GetString();
if (str.IsDigit()) { if (str.IsFloat()) {
ival = str.Atoi(); dval = str.Atof();
if (ival > 0) if (dval >= 0.0)
param.SetAddT0(ival, addT0Counter, i-1); param.SetAddT0Bin(dval, addT0Counter, i-1);
else else
error = true; error = true;
} else { } else {
@ -4972,8 +4986,8 @@ Bool_t PMsrHandler::CheckAddRunParameters()
for (UInt_t i=0; i<fRuns.size(); i++) { for (UInt_t i=0; i<fRuns.size(); i++) {
if (fRuns[i].GetRunNameSize() > 1) { if (fRuns[i].GetRunNameSize() > 1) {
// check concerning the addt0 tags // check concerning the addt0 tags
if (fRuns[i].GetAddT0Entries() != 0) { if (fRuns[i].GetAddT0BinEntries() != 0) {
if (fRuns[i].GetAddT0Entries() != fRuns[i].GetRunNameSize()-1) { if (fRuns[i].GetAddT0BinEntries() != fRuns[i].GetRunNameSize()-1) {
cerr << endl << ">> PMsrHandler::CheckAddRunParameters: **ERROR** # of addt0 != # of addruns."; cerr << endl << ">> PMsrHandler::CheckAddRunParameters: **ERROR** # of addt0 != # of addruns.";
cerr << endl << ">> Run #" << i+1; cerr << endl << ">> Run #" << i+1;
cerr << endl; cerr << endl;

View File

@ -10,7 +10,7 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007-2010 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.ch * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * 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); fErrData[idx].push_back(dval);
} }
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// implementation PRawRunDataSet
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//--------------------------------------------------------------------------
// Constructor
//--------------------------------------------------------------------------
/**
* <p>Constructor
*/
PRawRunDataSet::PRawRunDataSet()
{
Clear();
}
//--------------------------------------------------------------------------
// Clear (public)
//--------------------------------------------------------------------------
/**
* <p>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)
//--------------------------------------------------------------------------
/**
* <p>Checks if the histogram set with histgram number histoNo is present.
*
* <p><b>return:</b>
* - 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; i<fDataVec.size(); i++) {
if (fDataVec[i].GetHistoNo() == (Int_t)histoNo) {
found = true;
break;
}
}
return found;
}
//--------------------------------------------------------------------------
// GetSet (public)
//--------------------------------------------------------------------------
/**
* <p>Get 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.
*
* <p><b>return:</b>
* - 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)
//--------------------------------------------------------------------------
/**
* <p>Get the raw data set with histogram number histoNo.
*
* <p><b>return:</b>
* - 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; i<fDataVec.size(); i++) {
if (fDataVec[i].GetHistoNo() == (Int_t)histoNo) {
result = &fDataVec[i];
break;
}
}
return result;
}
//--------------------------------------------------------------------------
// operator[] (public)
//--------------------------------------------------------------------------
/**
* <p>Get the raw data set with histogram number histoNo.
*
* <p><b>return:</b>
* - 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)
//--------------------------------------------------------------------------
/**
* <p>Get the raw data set data with histogram number histoNo.
*
* <p><b>return:</b>
* - 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; i<fDataVec.size(); i++) {
if (fDataVec[i].GetHistoNo() == (Int_t)histoNo) {
result = fDataVec[i].GetData();
break;
}
}
return result;
}
//--------------------------------------------------------------------------
// GetT0Bin (public)
//--------------------------------------------------------------------------
/**
* <p>Get the T0 bin of raw run data with histogram number histoNo.
*
* <p><b>return:</b>
* - 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; i<fDataVec.size(); i++) {
if (fDataVec[i].GetHistoNo() == (Int_t)histoNo) {
result = fDataVec[i].GetTimeZeroBin();
break;
}
}
return result;
}
//--------------------------------------------------------------------------
// GetT0BinEstimated (public)
//--------------------------------------------------------------------------
/**
* <p>Get the estimated T0 bin of raw run data with histogram number histoNo.
*
* <p><b>return:</b>
* - 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; i<fDataVec.size(); i++) {
if (fDataVec[i].GetHistoNo() == (Int_t)histoNo) {
result = fDataVec[i].GetTimeZeroBinEstimated();
break;
}
}
return result;
}
//--------------------------------------------------------------------------
// GetBkgBin (public)
//--------------------------------------------------------------------------
/**
* <p>Get the background bins (start, end).
*
* <p><b>return:</b>
* - 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; i<fDataVec.size(); i++) {
if (fDataVec[i].GetHistoNo() == (Int_t)histoNo) {
bkg.first = fDataVec[i].GetFirstBkgBin();
bkg.second = fDataVec[i].GetLastBkgBin();
break;
}
}
return bkg;
}
//--------------------------------------------------------------------------
// GetGoodDataBin (public)
//--------------------------------------------------------------------------
/**
* <p>Get the first/last good data bin (fgb, lgb).
*
* <p><b>return:</b>
* - 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; i<fDataVec.size(); i++) {
if (fDataVec[i].GetHistoNo() == (Int_t)histoNo) {
gdb.first = fDataVec[i].GetFirstGoodBin();
gdb.second = fDataVec[i].GetLastGoodBin();
break;
}
}
return gdb;
}
//--------------------------------------------------------------------------
// Set (public)
//--------------------------------------------------------------------------
/**
* <p>Set 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 // implementation PRawRunData
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@ -221,11 +507,19 @@ void PNonMusrRawRunData::AppendSubErrData(const UInt_t idx, const Double_t dval)
*/ */
PRawRunData::PRawRunData() 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"); fLaboratory = TString("n/a");
fBeamline = TString("n/a"); fBeamline = TString("n/a");
fInstrument = TString("n/a"); fInstrument = TString("n/a");
fArea = TString("n/a");
fMuonSource = TString("n/a"); fMuonSource = TString("n/a");
fMuonSpecies = TString("n/a"); fMuonSpecies = TString("n/a");
fMuonBeamMomentum = PMUSR_UNDEFINED;
fRunName = TString("n/a"); fRunName = TString("n/a");
fRunNumber = -1; fRunNumber = -1;
fRunTitle = TString("n/a"); fRunTitle = TString("n/a");
@ -236,12 +530,15 @@ PRawRunData::PRawRunData()
fStopTime = TString("n/a"); fStopTime = TString("n/a");
fStopDate = TString("n/a"); fStopDate = TString("n/a");
fStopDateTimeSec = 0; fStopDateTimeSec = 0;
fCryo = TString("n/a");
fSample = TString("n/a"); fSample = TString("n/a");
fOrientation = TString("n/a"); fOrientation = TString("n/a");
fMagnet = TString("n/a");
fField = PMUSR_UNDEFINED; fField = PMUSR_UNDEFINED;
fEnergy = PMUSR_UNDEFINED; fEnergy = PMUSR_UNDEFINED;
fTransport = PMUSR_UNDEFINED; fTransport = PMUSR_UNDEFINED;
fTimeResolution = PMUSR_UNDEFINED; fTimeResolution = PMUSR_UNDEFINED;
fRedGreenOffset.push_back(0);
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
@ -254,13 +551,7 @@ PRawRunData::~PRawRunData()
{ {
fTemp.clear(); fTemp.clear();
fRingAnode.clear(); fRingAnode.clear();
fT0s.clear(); fRedGreenOffset.clear();
fT0Estimated.clear();
fBkgBin.clear();
fGoodDataBin.clear();
for (UInt_t i=0; i<fDataBin.size(); i++)
fDataBin[i].clear();
fDataBin.clear();
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
@ -330,128 +621,24 @@ const Double_t PRawRunData::GetRingAnode(const UInt_t idx)
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
// GetT0 // GetDataSet
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
/** /**
* <p> Returns a T0 value. * <p>Returns a raw muSR run data set.
*
* <b>return:</b>
* - 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
//--------------------------------------------------------------------------
/**
* <p>Returns an estimated T0 value.
*
* <b>return:</b>
* - 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
//--------------------------------------------------------------------------
/**
* <p>Returns the background bin range (start, stop) from the data file.
* Currently only used in mud-files.
*
* <b>return:</b>
* - (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
//--------------------------------------------------------------------------
/**
* <p>Returns the data range (first good bin, last good bin) from the data file.
* Currently only used in mud-files.
*
* <b>return:</b>
* - (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
//--------------------------------------------------------------------------
/**
* <p>Returns a raw muSR run histogram.
* *
* <b>return:</b> * <b>return:</b>
* - pointer of the data vector, if idx is within proper boundaries * - pointer of the data vector, if idx is within proper boundaries
* - 0, otherwise * - 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()) { if (wantHistoNo)
cerr << endl << ">> PRawRunData::GetDataBin: **WARNING** idx=" << idx << " is out of range [0," << fDataBin.size() << "[."; return fData[idx];
cerr << endl; else
return 0; return fData.GetSet(idx);
}
return &fDataBin[idx];
} }
@ -508,61 +695,6 @@ void PRawRunData::SetTempError(const UInt_t idx, const Double_t errTemp)
fTemp[idx].second = errTemp; fTemp[idx].second = errTemp;
} }
//--------------------------------------------------------------------------
// SetDataBin
//--------------------------------------------------------------------------
/**
* <p> 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
//--------------------------------------------------------------------------
/**
* <p> 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 // implementation PMsrRunBlock
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@ -575,7 +707,7 @@ void PRawRunData::AddDataBin(const UInt_t histoNo, const UInt_t bin, const Doubl
*/ */
PMsrRunBlock::PMsrRunBlock() PMsrRunBlock::PMsrRunBlock()
{ {
fFitType = -1; // undefined fit type fFitType = -1; // undefined fit type
fAlphaParamNo = -1; // undefined alpha parameter number fAlphaParamNo = -1; // undefined alpha parameter number
fBetaParamNo = -1; // undefined beta parameter number fBetaParamNo = -1; // undefined beta parameter number
fNormParamNo = -1; // undefined norm parameter number fNormParamNo = -1; // undefined norm parameter number
@ -1128,18 +1260,18 @@ void PMsrRunBlock::SetDataRange(Int_t ival, Int_t idx)
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
// GetT0 // GetT0Bin
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
/** /**
* <p> get T0 value at position idx * <p> get T0 bin at position idx
* *
* <b>return:</b> * <b>return:</b>
* - t0 value, if idx is within proper boundaries * - T0 bin, if idx is within proper boundaries
* - -1, otherwise * - -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()) if (idx >= fT0.size())
return -1; return -1;
@ -1148,29 +1280,29 @@ Int_t PMsrRunBlock::GetT0(UInt_t idx)
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
// SetT0 // SetT0Bin
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
/** /**
* <p> set T0 value at position idx * <p> set T0 bin at position idx
* *
* \param ival t0 value * \param ival T0 bin
* \param idx index of the T0 value to be set. If idx==-1, append value * \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) { if (idx == -1) {
fT0.push_back(ival); fT0.push_back(dval);
return; return;
} }
if (idx >= static_cast<Int_t>(fT0.size())) if (idx >= static_cast<Int_t>(fT0.size()))
fT0.resize(idx+1); fT0.resize(idx+1);
fT0[idx] = ival; fT0[idx] = dval;
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
// GetAddT0Size // GetAddT0BinSize
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
/** /**
* <p> get add T0 size of the addrun at index addRunIdx * <p> 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 * \param addRunIdx index of the addrun
*/ */
Int_t PMsrRunBlock::GetAddT0Size(UInt_t addRunIdx) Int_t PMsrRunBlock::GetAddT0BinSize(UInt_t addRunIdx)
{ {
if (fAddT0.empty()) if (fAddT0.empty())
return -1; return -1;
@ -1193,7 +1325,7 @@ Int_t PMsrRunBlock::GetAddT0Size(UInt_t addRunIdx)
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
// GetAddT0 // GetAddT0Bin
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
/** /**
* <p> get add T0 of the addrun (index addRunIdx) at index histoIdx * <p> 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 addRunIdx index of the addrun
* \param histoIdx index of the add backward histo number value * \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()) if (fAddT0.empty())
return -1; return -1.0;
if (addRunIdx >= fAddT0.size()) if (addRunIdx >= fAddT0.size())
return -1; return -1.0;
if (fAddT0[addRunIdx].empty()) if (fAddT0[addRunIdx].empty())
return -1; return -1.0;
if (histoIdx >= fAddT0[addRunIdx].size()) if (histoIdx >= fAddT0[addRunIdx].size())
return -1; return -1.0;
return fAddT0[addRunIdx][histoIdx]; return fAddT0[addRunIdx][histoIdx];
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
// SetAddT0 // SetAddT0Bin
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
/** /**
* <p> set add t0 value of the addrun at index histoNoIdx * <p> set add T0 bin of the addrun at index histoNoIdx
* *
* \param ival t0 value * \param ival T0 bin
* \param addRunIdx addrun index * \param addRunIdx addrun index
* \param histoNoIdx index whithin the fAddT0 vector where to set the value. * \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()) if (addRunIdx >= fAddT0.size())
fAddT0.resize(addRunIdx+1); 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()) if (histoNoIdx >= fAddT0[addRunIdx].size())
fAddT0[addRunIdx].resize(histoNoIdx+1); fAddT0[addRunIdx].resize(histoNoIdx+1);
fAddT0[addRunIdx][histoNoIdx] = ival; fAddT0[addRunIdx][histoNoIdx] = dval;
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------

View File

@ -10,7 +10,7 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.ch * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * This program is free software; you can redistribute it and/or modify *

View File

@ -10,7 +10,7 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2009 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.ch * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * 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
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
/** /**
* <p>Get t0 (in bin) of a run. * <p>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). * \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()) if (idx >= fT0.size())
return -1; return -1;
@ -154,7 +154,7 @@ Int_t PMusrT0Data::GetT0(UInt_t idx)
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
// GetAddT0Size // GetAddT0BinSize
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
/** /**
* <p>Get addt0 size of a run, i.e. the number of addt0's for a given msr-file run. * <p>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). * \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()) if (idx >= fAddT0.size())
return 0; return 0;
@ -174,7 +174,7 @@ UInt_t PMusrT0Data::GetAddT0Size(UInt_t idx)
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
// GetAddT0 // GetAddT0Bin
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
/** /**
* <p>Get addt0 (in bin) of a run. * <p>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 addRunIdx index of the addrun
* \param idx index of the run (msr-file). * \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()) if (addRunIdx >= fAddT0.size())
return -1; return -1;
@ -198,7 +198,7 @@ Int_t PMusrT0Data::GetAddT0(UInt_t addRunIdx, UInt_t idx)
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
// SetT0 // SetT0Bin
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
/** /**
* <p>Set t0 value. * <p>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 val t0 value to be set
* \param idx index at which t0 shall 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()) if (idx >= fT0.size())
fT0.resize(idx+1); fT0.resize(idx+1);
@ -215,7 +215,7 @@ void PMusrT0Data::SetT0(UInt_t val, UInt_t idx)
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
// SetAddT0 // SetAddT0Bin
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
/** /**
* <p>Set addt0 value. * <p>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 addRunIdx addt0 index (for each addrun, there has to be an addt0)
* \param idx index at which t0 shall be set. * \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()) if (addRunIdx >= fAddT0.size())
fAddT0.resize(addRunIdx+1); fAddT0.resize(addRunIdx+1);
@ -334,9 +334,9 @@ PMusrT0::PMusrT0(PMusrT0Data &data) : fMusrT0Data(data)
fValid = false; fValid = false;
return; return;
} }
Int_t histoNo = fMusrT0Data.GetHistoNo(fMusrT0Data.GetHistoNoIdx())-1; Int_t histoNo = fMusrT0Data.GetHistoNo(fMusrT0Data.GetHistoNoIdx());
if (histoNo >= (Int_t)rawRunData->GetNoOfHistos()) { if (!rawRunData->IsPresent(histoNo)) {
cerr << endl << ">> PMusrT0::PMusrT0: **ERROR** found histogram number " << histoNo+1 << ", but only " << rawRunData->GetNoOfHistos() << " are present."; 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; cerr << endl << ">> Please try to fix this first ..." << endl;
fValid = false; fValid = false;
return; return;
@ -375,7 +375,7 @@ PMusrT0::PMusrT0(PMusrT0Data &data) : fMusrT0Data(data)
} }
// get run and first histo of grouping and feed it into fHisto // 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(); Int_t noOfBins = rawRunData->GetDataBin(histoNo)->size();
Double_t start = -0.5; Double_t start = -0.5;
Double_t end = noOfBins - 0.5; // -0.5 is correct since the data start at 0.0 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; factor=2;
if (fMusrT0Data.GetDetectorTag() == PMUSRT0_FORWARD) if (fMusrT0Data.GetDetectorTag() == PMUSRT0_FORWARD)
t00 = fMusrT0Data.GetT0(0); t00 = fMusrT0Data.GetT0Bin(0);
else else
t00 = fMusrT0Data.GetT0(1); t00 = fMusrT0Data.GetT0Bin(1);
// check if there are addruns and grouping // check if there are addruns and grouping
if ((fMusrT0Data.GetRawRunDataSize() > 1) && (fMusrT0Data.GetHistoNoSize() > 1)) { // addruns and grouping present 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<fMusrT0Data.GetHistoNoSize(); k++) { // loop over all histograms (grouping) for (UInt_t k=0; k<fMusrT0Data.GetHistoNoSize(); k++) { // loop over all histograms (grouping)
histoNo = fMusrT0Data.GetHistoNo(k)-1; histoNo = fMusrT0Data.GetHistoNo(k);
// get t0 // get t0
if (fMusrT0Data.GetDetectorTag() == PMUSRT0_FORWARD) if (fMusrT0Data.GetDetectorTag() == PMUSRT0_FORWARD)
t0 = fMusrT0Data.GetT0(factor*k); t0 = fMusrT0Data.GetT0Bin(factor*k);
else else
t0 = fMusrT0Data.GetT0(factor*k+1); t0 = fMusrT0Data.GetT0Bin(factor*k+1);
// get proper rawRunData // get proper rawRunData
rawRunData = fMusrT0Data.GetRawRunData(0); rawRunData = fMusrT0Data.GetRawRunData(0);
@ -429,9 +429,9 @@ PMusrT0::PMusrT0(PMusrT0Data &data) : fMusrT0Data(data)
// get t0 // get t0
if (fMusrT0Data.GetDetectorTag() == PMUSRT0_FORWARD) if (fMusrT0Data.GetDetectorTag() == PMUSRT0_FORWARD)
t0 = fMusrT0Data.GetAddT0(j-1, factor*k); t0 = fMusrT0Data.GetAddT0Bin(j-1, factor*k);
else else
t0 = fMusrT0Data.GetAddT0(j-1, factor*k+1); t0 = fMusrT0Data.GetAddT0Bin(j-1, factor*k+1);
// get bin value from addrun/grouping // get bin value from addrun/grouping
if ((i+t0-t00 > 0) && (i+t0-t00 < static_cast<Int_t>(rawRunData->GetDataBin(histoNo)->size()))) if ((i+t0-t00 > 0) && (i+t0-t00 < static_cast<Int_t>(rawRunData->GetDataBin(histoNo)->size())))
@ -448,13 +448,13 @@ PMusrT0::PMusrT0(PMusrT0Data &data) : fMusrT0Data(data)
dval = 0; dval = 0;
histoNo = fMusrT0Data.GetHistoNo(0)-1; histoNo = fMusrT0Data.GetHistoNo(0);
// get t0 // get t0
if (fMusrT0Data.GetDetectorTag() == PMUSRT0_FORWARD) if (fMusrT0Data.GetDetectorTag() == PMUSRT0_FORWARD)
t0 = fMusrT0Data.GetT0(0); t0 = fMusrT0Data.GetT0Bin(0);
else else
t0 = fMusrT0Data.GetT0(1); t0 = fMusrT0Data.GetT0Bin(1);
// get proper rawRunData // get proper rawRunData
rawRunData = fMusrT0Data.GetRawRunData(0); rawRunData = fMusrT0Data.GetRawRunData(0);
@ -470,9 +470,9 @@ PMusrT0::PMusrT0(PMusrT0Data &data) : fMusrT0Data(data)
// get t0 // get t0
if (fMusrT0Data.GetDetectorTag() == PMUSRT0_FORWARD) if (fMusrT0Data.GetDetectorTag() == PMUSRT0_FORWARD)
t0 = fMusrT0Data.GetAddT0(j-1, 0); t0 = fMusrT0Data.GetAddT0Bin(j-1, 0);
else else
t0 = fMusrT0Data.GetAddT0(j-1, 1); t0 = fMusrT0Data.GetAddT0Bin(j-1, 1);
// get bin value from addrun/grouping // get bin value from addrun/grouping
if ((i+t0-t00 > 0) && (i+t0-t00 < static_cast<Int_t>(rawRunData->GetDataBin(histoNo)->size()))) if ((i+t0-t00 > 0) && (i+t0-t00 < static_cast<Int_t>(rawRunData->GetDataBin(histoNo)->size())))
@ -493,13 +493,13 @@ PMusrT0::PMusrT0(PMusrT0Data &data) : fMusrT0Data(data)
for (UInt_t k=0; k<fMusrT0Data.GetHistoNoSize(); k++) { // loop over all histograms (grouping) for (UInt_t k=0; k<fMusrT0Data.GetHistoNoSize(); k++) { // loop over all histograms (grouping)
histoNo = fMusrT0Data.GetHistoNo(k)-1; histoNo = fMusrT0Data.GetHistoNo(k);
// get t0 // get t0
if (fMusrT0Data.GetDetectorTag() == PMUSRT0_FORWARD) if (fMusrT0Data.GetDetectorTag() == PMUSRT0_FORWARD)
t0 = fMusrT0Data.GetT0(factor*k); t0 = fMusrT0Data.GetT0Bin(factor*k);
else else
t0 = fMusrT0Data.GetT0(factor*k+1); t0 = fMusrT0Data.GetT0Bin(factor*k+1);
// get bin value from run/grouping // get bin value from run/grouping
if ((i+t0-t00 > 0) && (i+t0-t00 < static_cast<Int_t>(rawRunData->GetDataBin(histoNo)->size()))) if ((i+t0-t00 > 0) && (i+t0-t00 < static_cast<Int_t>(rawRunData->GetDataBin(histoNo)->size())))
@ -724,7 +724,7 @@ void PMusrT0::SetMsrHandler(PMsrHandler *msrHandler)
void PMusrT0::InitT0() void PMusrT0::InitT0()
{ {
// t0 line // t0 line
Int_t t0Bin = 0; Double_t t0Bin = 0;
Int_t histoIdx = fMusrT0Data.GetHistoNoIdx(); Int_t histoIdx = fMusrT0Data.GetHistoNoIdx();
Int_t addRunIdx = fMusrT0Data.GetAddRunIdx(); Int_t addRunIdx = fMusrT0Data.GetAddRunIdx();
UInt_t factor=1; UInt_t factor=1;
@ -733,15 +733,15 @@ void PMusrT0::InitT0()
switch (fMusrT0Data.GetDetectorTag() ) { switch (fMusrT0Data.GetDetectorTag() ) {
case PMUSRT0_FORWARD: case PMUSRT0_FORWARD:
if (addRunIdx == 0) 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) 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; break;
case PMUSRT0_BACKWARD: case PMUSRT0_BACKWARD:
if (addRunIdx == 0) 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) 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; break;
default: default:
// not clear yet what to be done // not clear yet what to be done
@ -861,7 +861,7 @@ void PMusrT0::InitDataAndBkg()
void PMusrT0::ShowDataFileT0Channel() void PMusrT0::ShowDataFileT0Channel()
{ {
// t0 line // t0 line
Int_t t0Bin = fMusrT0Data.GetT0Data(); Int_t t0Bin = fMusrT0Data.GetT0BinData();
Double_t max = fHisto->GetMaximum(); Double_t max = fHisto->GetMaximum();
if (!fT0DataLine) { if (!fT0DataLine) {

View File

@ -10,7 +10,7 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.ch * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * This program is free software; you can redistribute it and/or modify *
@ -385,11 +385,11 @@ Bool_t PRunAsymmetry::PrepareData()
PUIntVector forwardHistoNo; PUIntVector forwardHistoNo;
PUIntVector backwardHistoNo; PUIntVector backwardHistoNo;
for (UInt_t i=0; i<fRunInfo->GetForwardHistoNoSize(); i++) { for (UInt_t i=0; i<fRunInfo->GetForwardHistoNoSize(); 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 << ">> 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 << ">> Will quit :-(";
cerr << endl; cerr << endl;
// clean up // clean up
@ -399,11 +399,11 @@ Bool_t PRunAsymmetry::PrepareData()
} }
} }
for (UInt_t i=0; i<fRunInfo->GetBackwardHistoNoSize(); i++) { for (UInt_t i=0; i<fRunInfo->GetBackwardHistoNoSize(); 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 << ">> 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 << ">> Will quit :-(";
cerr << endl; cerr << endl;
// clean up // clean up
@ -423,75 +423,74 @@ Bool_t PRunAsymmetry::PrepareData()
return false; return false;
} }
// check if the t0's are given in the msr-file // feed all T0's
if (fRunInfo->GetT0Size() == 0) { // t0's are NOT in the msr-file // first init T0's, T0's are stored as (forward T0, backward T0, etc.)
// check if the t0's are in the data file fT0s.clear();
if (runData->GetT0Size() != 0) { // t0's in the run data fT0s.resize(2*forwardHistoNo.size());
// keep the proper t0's. For asymmetry runs, forward/backward are holding the histo no for (UInt_t i=0; i<fT0s.size(); i++) {
// fForwardHistoNo starts with 1 not with 0 etc. ;-) fT0s[i] = -1.0;
for (UInt_t i=0; i<forwardHistoNo.size(); i++) { }
fT0s.push_back(runData->GetT0(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; i<forwardHistoNo.size(); i++) {
fT0s.push_back(runData->GetT0Estimated(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; i<forwardHistoNo.size(); 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() <= 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<Int_t>(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<Int_t>(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
// check if t0's are given in the data file // fill in the T0's from the msr-file (if present)
if (runData->GetT0Size() != 0) { for (UInt_t i=0; i<fRunInfo->GetT0BinSize(); i++) {
// compare t0's of the msr-file with the one in the data file fT0s[i] = fRunInfo->GetT0Bin(i);
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; // fill in the T0's from the data file, if not already present in the msr-file
cerr << endl << ">> t0 from the data file is " << runData->GetT0(fRunInfo->GetForwardHistoNo(i)-1); for (UInt_t i=0; i<forwardHistoNo.size(); i++) {
cerr << endl << ">> This is quite a deviation! Is this done intentionally??"; if (fT0s[2*i] == -1.0) // i.e. not present in the msr-file, try the data file
cerr << endl; if (runData->GetT0Bin(forwardHistoNo[i]) > 0.0) {
} fT0s[2*i] = runData->GetT0Bin(forwardHistoNo[i]);
if (fabs(fRunInfo->GetT0(2*i+1)-runData->GetT0(fRunInfo->GetBackwardHistoNo(i)-1))>5.0) { // given in bins!! fRunInfo->SetT0Bin(fT0s[2*i], 2*i);
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;
}
}
} }
}
for (UInt_t i=0; i<backwardHistoNo.size(); i++) {
if (fT0s[2*i+1] == -1.0) // i.e. not present in the msr-file, try the data file
if (runData->GetT0Bin(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; i<forwardHistoNo.size(); i++) {
if (fT0s[2*i] == -1.0) { // i.e. not present in the msr-file and data file, use the estimated T0
fT0s[2*i] = runData->GetT0BinEstimated(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; i<backwardHistoNo.size(); i++) {
if (fT0s[2*i+1] == -1.0) { // i.e. not present in the msr-file and data file, use the estimated T0
fT0s[2*i+1] = runData->GetT0BinEstimated(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<forwardHistoNo.size(); i++) {
if ((fT0s[2*i] < 0) || (fT0s[2*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 // get T0's of the to be added run
PUIntVector t0Add; PDoubleVector t0Add;
// check if the t0's are given in the msr-file
if (i > fRunInfo->GetAddT0Entries()) { // t0's are NOT in the msr-file // feed all T0's
// check if the t0's are in the data file // first init T0's, T0's are stored as (forward T0, backward T0, etc.)
if (addRunData->GetT0Size() != 0) { // t0's in the run data t0Add.clear();
// keep the proper t0's. For asymmetry runs, forward/backward are holding the histo no t0Add.resize(2*forwardHistoNo.size());
// fForwardHistoNo starts with 1 not with 0 etc. ;-) for (UInt_t j=0; j<t0Add.size(); j++) {
for (UInt_t j=0; j<fRunInfo->GetForwardHistoNoSize(); j++) { t0Add[j] = -1.0;
t0Add.push_back(addRunData->GetT0(fRunInfo->GetForwardHistoNo(j)-1)); // forward t0 }
t0Add.push_back(addRunData->GetT0(fRunInfo->GetBackwardHistoNo(j)-1)); // backward t0
// fill in the T0's from the msr-file (if present)
for (Int_t j=0; j<fRunInfo->GetAddT0BinSize(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; j<forwardHistoNo.size(); j++) {
if (t0Add[2*j] == -1.0) // i.e. not present in the msr-file, try the data file
if (addRunData->GetT0Bin(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; j<fRunInfo->GetForwardHistoNoSize(); j++) { for (UInt_t j=0; j<backwardHistoNo.size(); j++) {
t0Add.push_back(addRunData->GetT0Estimated(fRunInfo->GetForwardHistoNo(j)-1)); if (t0Add[2*j+1] == -1.0) // i.e. not present in the msr-file, try the data file
t0Add.push_back(addRunData->GetT0Estimated(fRunInfo->GetBackwardHistoNo(j)-1)); if (addRunData->GetT0Bin(backwardHistoNo[j]) > 0.0) {
cerr << endl << ">> PRunAsymmetry::PrepareData(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!"; t0Add[2*j+1] = addRunData->GetT0Bin(backwardHistoNo[j]);
cerr << endl << ">> addRun: " << fRunInfo->GetRunName(i)->Data(); fRunInfo->SetAddT0Bin(t0Add[2*j+1], i-1, 2*j+1);
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;
} }
}
// 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; j<forwardHistoNo.size(); j++) {
if (t0Add[2*j] == -1.0) { // i.e. not present in the msr-file and data file, use the estimated T0
t0Add[2*j] = addRunData->GetT0BinEstimated(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; j<fRunInfo->GetForwardHistoNoSize(); j++) { for (UInt_t j=0; j<backwardHistoNo.size(); j++) {
// check if t0's are given in the data file if (t0Add[2*j+1] == -1.0) { // i.e. not present in the msr-file and data file, use the estimated T0
if (addRunData->GetT0Size() != 0) { t0Add[2*j+1] = addRunData->GetT0BinEstimated(backwardHistoNo[j]);
// compare t0's of the msr-file with the one in the data file fRunInfo->SetAddT0Bin(t0Add[2*j+1], i-1, 2*j+1);
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 << ">> PRunAsymmetry::PrepareData(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!";
cerr << endl << ">> t0 from the msr-file is " << fRunInfo->GetAddT0(i-1,2*j)+1; // +1 since vector starts at 0 cerr << endl << ">> run: " << fRunInfo->GetRunName(i);
cerr << endl << ">> t0 from the data file is " << addRunData->GetT0(fRunInfo->GetForwardHistoNo(j)-1); cerr << endl << ">> will try the estimated one: backward t0 = " << runData->GetT0BinEstimated(backwardHistoNo[j]);
cerr << endl << ">> This is quite a deviation! Is this done intentionally??"; cerr << endl << ">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!";
cerr << endl << ">> addrun: " << fRunInfo->GetRunName(i)->Data(); cerr << endl;
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<UInt_t>(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));
}
}
} }
} }
@ -589,8 +582,8 @@ Bool_t PRunAsymmetry::PrepareData()
addRunSize = addRunData->GetDataBin(forwardHistoNo[k])->size(); addRunSize = addRunData->GetDataBin(forwardHistoNo[k])->size();
for (UInt_t j=0; j<addRunData->GetDataBin(forwardHistoNo[k])->size(); j++) { // loop over the bin indices for (UInt_t j=0; j<addRunData->GetDataBin(forwardHistoNo[k])->size(); j++) { // loop over the bin indices
// make sure that the index stays in the proper range // 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)) { 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+t0Add[2*k]-fT0s[2*k]); 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(); addRunSize = addRunData->GetDataBin(backwardHistoNo[k])->size();
for (UInt_t j=0; j<addRunData->GetDataBin(backwardHistoNo[k])->size(); j++) { // loop over the bin indices for (UInt_t j=0; j<addRunData->GetDataBin(backwardHistoNo[k])->size(); j++) { // loop over the bin indices
// make sure that the index stays in the proper range // 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)) { 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+t0Add[2*k+1]-fT0s[2*k+1]); 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 // check if data range has been provided, and if not try to estimate them
if (start[0] < 0) { if (start[0] < 0) {
start[0] = (Int_t)t0[0]+offset; 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 << ">> 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 << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE.";
cerr << endl; cerr << endl;
} }
if (start[1] < 0) { if (start[1] < 0) {
start[1] = (Int_t)t0[1]+offset; 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 << ">> 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 << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE.";
cerr << endl; cerr << endl;
} }
if (end[0] < 0) { if (end[0] < 0) {
end[0] = runData->GetDataBin(histoNo[0])->size(); 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 << ">> 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 << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE.";
cerr << endl; cerr << endl;
} }
if (end[1] < 0) { if (end[1] < 0) {
end[1] = runData->GetDataBin(histoNo[1])->size(); 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 << ">> 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 << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE.";
cerr << endl; cerr << endl;
@ -1023,14 +1020,6 @@ Bool_t PRunAsymmetry::PrepareFitData(PRawRunData* runData, UInt_t histoNo[2])
fData.AppendErrorValue(error); fData.AppendErrorValue(error);
} }
// // count the number of bins to be fitted
// Double_t time;
// fNoOfFitBins=0;
// for (UInt_t i=0; i<fData.GetValue()->size(); i++) {
// time = fData.GetDataTimeStart() + (Double_t)i * fData.GetDataTimeStep();
// if ((time >= fFitStartTime) && (time <= fFitEndTime))
// fNoOfFitBins++;
// }
CalcNoOfFitBins(); CalcNoOfFitBins();
// clean up // clean up

View File

@ -10,7 +10,7 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.ch * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * This program is free software; you can redistribute it and/or modify *

File diff suppressed because it is too large Load Diff

View File

@ -10,8 +10,8 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.c * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * 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 * * it under the terms of the GNU General Public License as published by *

View File

@ -10,8 +10,8 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.c * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * 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 * * it under the terms of the GNU General Public License as published by *

View File

@ -10,7 +10,7 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.ch * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * This program is free software; you can redistribute it and/or modify *

View File

@ -10,7 +10,7 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.ch * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * This program is free software; you can redistribute it and/or modify *
@ -91,6 +91,7 @@ PRunSingleHisto::PRunSingleHisto(PMsrHandler *msrInfo, PRunDataHandler *rawData,
*/ */
PRunSingleHisto::~PRunSingleHisto() PRunSingleHisto::~PRunSingleHisto()
{ {
fForward.clear();
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
@ -509,13 +510,13 @@ Bool_t PRunSingleHisto::PrepareData()
} }
// collect histogram numbers // collect histogram numbers
PUIntVector histoNo; PUIntVector histoNo; // histoNo = msr-file forward + redGreen_offset - 1
for (UInt_t i=0; i<fRunInfo->GetForwardHistoNoSize(); i++) { for (UInt_t i=0; i<fRunInfo->GetForwardHistoNoSize(); 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 << ">> 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 << ">> Will quit :-(";
cerr << endl; cerr << endl;
histoNo.clear(); histoNo.clear();
@ -523,64 +524,59 @@ Bool_t PRunSingleHisto::PrepareData()
} }
} }
// check if the t0's are given in the msr-file // feed all T0's
if (fRunInfo->GetT0Size() == 0) { // t0's are NOT in the msr-file // first init T0's, T0's are stored as (forward T0, backward T0, etc.)
// check if the t0's are in the data file fT0s.clear();
if (runData->GetT0Size() != 0) { // t0's in the run data fT0s.resize(histoNo.size());
// keep the proper t0's. For single histo runs, forward is holding the histo no for (UInt_t i=0; i<fT0s.size(); i++) {
// fForwardHistoNo starts with 1 not with 0 ;-) fT0s[i] = -1.0;
for (UInt_t i=0; i<fRunInfo->GetForwardHistoNoSize(); 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! // fill in the T0's from the msr-file (if present)
for (UInt_t i=0; i<fRunInfo->GetForwardHistoNoSize(); i++) { for (UInt_t i=0; i<fRunInfo->GetT0BinSize(); i++) {
fT0s.push_back(runData->GetT0Estimated(fRunInfo->GetForwardHistoNo(i)-1)); fT0s[i] = fRunInfo->GetT0Bin(i);
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); // fill in the T0's from the data file, if not already present in the msr-file
cerr << endl << ">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; for (UInt_t i=0; i<histoNo.size(); i++) {
cerr << endl; if (fT0s[i] == -1.0) // i.e. not present in the msr-file, try the data file
} if (runData->GetT0Bin(histoNo[i]) > 0.0) {
} fT0s[i] = runData->GetT0Bin(histoNo[i]);
} else { // t0's in the msr-file fRunInfo->SetT0Bin(fT0s[i], i); // keep value for the msr-file
for (UInt_t i=0; i<fRunInfo->GetForwardHistoNoSize(); 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<Int_t>(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;
}
}
} }
}
// 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; i<histoNo.size(); i++) {
if (fT0s[i] == -1.0) { // i.e. not present in the msr-file and data file, use the estimated T0
fT0s[i] = runData->GetT0BinEstimated(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 // check if t0 is within proper bounds
for (UInt_t i=0; i<fRunInfo->GetForwardHistoNoSize(); i++) { for (UInt_t i=0; i<fRunInfo->GetForwardHistoNoSize(); i++) {
if ((fT0s[i] < 0) || (fT0s[i] > (Int_t)runData->GetDataBin(histoNo[i])->size())) { 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; cerr << endl;
return false; return false;
} }
} }
// keep the histo of each group at this point (addruns handled below)
vector<PDoubleVector> forward;
forward.resize(histoNo.size()); // resize to number of groups
for (UInt_t i=0; i<histoNo.size(); i++) {
forward[i].resize(runData->GetDataBin(histoNo[i])->size());
forward[i] = *runData->GetDataBin(histoNo[i]);
}
// check if there are runs to be added to the current one // check if there are runs to be added to the current one
if (fRunInfo->GetRunNameSize() > 1) { // runs to be added present if (fRunInfo->GetRunNameSize() > 1) { // runs to be added present
PRawRunData *addRunData; PRawRunData *addRunData;
@ -594,62 +590,59 @@ Bool_t PRunSingleHisto::PrepareData()
return false; return false;
} }
// get T0's of the to be added run // feed all T0's
PUIntVector t0Add; // first init T0's, T0's are stored as (forward T0, backward T0, etc.)
// check if the t0's are given in the msr-file PDoubleVector t0Add;
if (i > fRunInfo->GetAddT0Entries()) { // t0's are NOT in the msr-file t0Add.resize(histoNo.size());
// check if the t0's are in the data file for (UInt_t j=0; j<t0Add.size(); j++) {
if (addRunData->GetT0Size() != 0) { // t0's in the run data t0Add[j] = -1.0;
// 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; j<fRunInfo->GetForwardHistoNoSize(); j++) // fill in the T0's from the msr-file (if present)
t0Add.push_back(addRunData->GetT0(fRunInfo->GetForwardHistoNo(j)-1)); for (UInt_t j=0; j<fRunInfo->GetT0BinSize(); j++) {
} else { // t0's are neither in the run data nor in the msr-file -> will try estimated ones! t0Add[j] = fRunInfo->GetAddT0Bin(i-1,j); // addRunIdx starts at 0
for (UInt_t j=0; j<fRunInfo->GetForwardHistoNoSize(); 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!"; // fill in the T0's from the data file, if not already present in the msr-file
cerr << endl << ">> addrun: " << fRunInfo->GetRunName(i)->Data(); for (UInt_t j=0; j<histoNo.size(); j++) {
cerr << endl << ">> will try the estimated one: t0 = " << addRunData->GetT0Estimated(fRunInfo->GetForwardHistoNo(j)-1); if (t0Add[j] == -1.0) // i.e. not present in the msr-file, try the data file
cerr << endl << ">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; if (addRunData->GetT0Bin(histoNo[j]) > 0.0) {
cerr << endl; t0Add[j] = addRunData->GetT0Bin(histoNo[j]);
} fRunInfo->SetAddT0Bin(t0Add[j], i-1, j); // keep value for the msr-file
}
} else { // t0's in the msr-file
for (UInt_t j=0; j<fRunInfo->GetForwardHistoNoSize(); 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<UInt_t>(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));
}
} }
}
// 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; j<histoNo.size(); j++) {
if (t0Add[j] == -1.0) { // i.e. not present in the msr-file and data file, use the estimated T0
t0Add[j] = addRunData->GetT0BinEstimated(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 // check if t0 is within proper bounds
for (UInt_t k=0; k<fRunInfo->GetForwardHistoNoSize(); k++) { for (UInt_t j=0; j<fRunInfo->GetForwardHistoNoSize(); j++) {
for (UInt_t j=0; j<runData->GetDataBin(histoNo[k])->size(); j++) { if ((t0Add[j] < 0) || (t0Add[j] > (Int_t)addRunData->GetDataBin(histoNo[j])->size())) {
// make sure that the index stays within proper range cerr << endl << ">> PRunSingleHisto::PrepareData(): **ERROR** addt0 data bin (" << t0Add[j] << ") doesn't make any sense!";
if ((j+t0Add[k]-fT0s[k] >= 0) && (j+t0Add[k]-fT0s[k] < addRunData->GetDataBin(histoNo[k])->size())) { cerr << endl;
runData->AddDataBin(histoNo[k], j, addRunData->GetDataBin(histoNo[k])->at(j+t0Add[k]-fT0s[k])); return false;
}
}
// add forward run
UInt_t addRunSize;
for (UInt_t k=0; k<histoNo.size(); k++) { // fill each group
addRunSize = addRunData->GetDataBin(histoNo[k])->size();
for (UInt_t j=0; j<addRunData->GetDataBin(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] // set forward/backward histo data of the first group
for (UInt_t i=1; i<fRunInfo->GetForwardHistoNoSize(); i++) { fForward.resize(forward[0].size());
for (UInt_t j=0; j<runData->GetDataBin(histoNo[0])->size(); j++) { for (UInt_t i=0; i<fForward.size(); i++) {
fForward[i] = forward[0][i];
}
// group histograms, add all the remaining forward histograms of the group
for (UInt_t i=1; i<histoNo.size(); i++) { // loop over the groupings
for (UInt_t j=0; j<runData->GetDataBin(histoNo[i])->size(); j++) { // loop over the bin indices
// make sure that the index stays within proper range // 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())) { 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) { if (start < 0) {
Int_t offset = (Int_t)(10.0e-3/fTimeResolution); Int_t offset = (Int_t)(10.0e-3/fTimeResolution);
start = fT0s[0]+offset; 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 << ">> 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 << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE.";
cerr << endl; cerr << endl;
} }
if (end < 0) { 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 << ">> 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 << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE.";
cerr << endl; cerr << endl;
@ -740,13 +741,13 @@ Bool_t PRunSingleHisto::PrepareFitData(PRawRunData* runData, const UInt_t histoN
start = keep; start = keep;
} }
// 2nd check if start is within proper bounds // 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 << ">> PRunSingleHisto::PrepareFitData(): **ERROR** start data bin doesn't make any sense!";
cerr << endl; cerr << endl;
return false; return false;
} }
// 3rd check if end is within proper bounds // 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 << ">> PRunSingleHisto::PrepareFitData(): **ERROR** end data bin doesn't make any sense!";
cerr << endl; cerr << endl;
return false; return false;
@ -770,8 +771,8 @@ Bool_t PRunSingleHisto::PrepareFitData(PRawRunData* runData, const UInt_t histoN
return false; return false;
} }
} else { // fixed background given } else { // fixed background given
for (UInt_t i=0; i<runData->GetDataBin(histoNo)->size(); i++) { for (UInt_t i=0; i<fForward.size(); i++) {
runData->AddDataBin(histoNo, i, -fRunInfo->GetBkgFix(0)); fForward[i] -= fRunInfo->GetBkgFix(0);
} }
} }
} }
@ -790,7 +791,7 @@ Bool_t PRunSingleHisto::PrepareFitData(PRawRunData* runData, const UInt_t histoN
fData.SetDataTimeStep(fTimeResolution*fRunInfo->GetPacking()); fData.SetDataTimeStep(fTimeResolution*fRunInfo->GetPacking());
for (Int_t i=start; i<end; i++) { for (Int_t i=start; i<end; i++) {
if (fRunInfo->GetPacking() == 1) { if (fRunInfo->GetPacking() == 1) {
value = runData->GetDataBin(histoNo)->at(i); value = fForward[i];
value /= normalizer; value /= normalizer;
fData.AppendValue(value); fData.AppendValue(value);
if (value == 0.0) if (value == 0.0)
@ -808,7 +809,7 @@ Bool_t PRunSingleHisto::PrepareFitData(PRawRunData* runData, const UInt_t histoN
// reset values // reset values
value = 0.0; 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 // 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; 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 // 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 // check if data range has been provided, and if not try to estimate them
if (start < 0) { if (start < 0) {
Int_t offset = (Int_t)(10.0e-3/fTimeResolution); Int_t offset = (Int_t)(10.0e-3/fTimeResolution);
start = (fT0s[0]+offset) - ((fT0s[0]+offset)/packing)*packing; 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 << ">> 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 << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE.";
cerr << endl; cerr << endl;
@ -874,13 +875,13 @@ Bool_t PRunSingleHisto::PrepareRawViewData(PRawRunData* runData, const UInt_t hi
start = keep; start = keep;
} }
// 2nd check if start is within proper bounds // 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 << ">> PRunSingleHisto::PrepareRawViewData(): **ERROR** start data bin doesn't make any sense!";
cerr << endl; cerr << endl;
return false; return false;
} }
// 3rd check if end is within proper bounds // 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 << ">> PRunSingleHisto::PrepareRawViewData(): **ERROR** end data bin doesn't make any sense!";
cerr << endl; cerr << endl;
return false; return false;
@ -905,7 +906,7 @@ Bool_t PRunSingleHisto::PrepareRawViewData(PRawRunData* runData, const UInt_t hi
// reset values // reset values
value = 0.0; value = 0.0;
} }
value += runData->GetDataBin(histoNo)->at(i); value += fForward[i];
} }
CalcNoOfFitBins(); CalcNoOfFitBins();
@ -969,11 +970,11 @@ Bool_t PRunSingleHisto::PrepareRawViewData(PRawRunData* runData, const UInt_t hi
} }
// calculate theory // calculate theory
UInt_t size = runData->GetDataBin(histoNo)->size(); UInt_t size = fForward.size();
Double_t factor = 1.0; 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; 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 time;
Double_t theoryValue; 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 // 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; 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 // 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 // check if data range has been provided, and if not try to estimate them
if (start < 0) { if (start < 0) {
Int_t offset = (Int_t)(10.0e-3/fTimeResolution); Int_t offset = (Int_t)(10.0e-3/fTimeResolution);
start = (fT0s[0]+offset) - ((fT0s[0]+offset)/packing)*packing; 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 << ">> 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 << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE.";
cerr << endl; cerr << endl;
@ -1071,13 +1072,13 @@ Bool_t PRunSingleHisto::PrepareViewData(PRawRunData* runData, const UInt_t histo
start = keep; start = keep;
} }
// 2nd check if start is within proper bounds // 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 << ">> PRunSingleHisto::PrepareViewData(): **ERROR** start data bin doesn't make any sense!";
cerr << endl; cerr << endl;
return false; return false;
} }
// 3rd check if end is within proper bounds // 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 << ">> PRunSingleHisto::PrepareViewData(): **ERROR** end data bin doesn't make any sense!";
cerr << endl; cerr << endl;
return false; return false;
@ -1157,7 +1158,7 @@ Bool_t PRunSingleHisto::PrepareViewData(PRawRunData* runData, const UInt_t histo
fData.AppendErrorValue(expval*TMath::Sqrt(value*dataNorm)); fData.AppendErrorValue(expval*TMath::Sqrt(value*dataNorm));
value = 0.0; value = 0.0;
} }
value += runData->GetDataBin(histoNo)->at(i); value += fForward[i];
} }
} else { // RRF representation } else { // RRF representation
// check which units shall be used // 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; time = ((Double_t)i-t0)*fTimeResolution;
expval = TMath::Exp(+time/tau)/N0; 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; 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 // calculate theory
Double_t theoryValue; Double_t theoryValue;
UInt_t size = runData->GetDataBin(histoNo)->size(); UInt_t size = fForward.size();
Double_t factor = 1.0; Double_t factor = 1.0;
UInt_t rebinRRF = 0; UInt_t rebinRRF = 0;
if (wRRF == 0) { // no RRF if (wRRF == 0) { // no RRF
// check if a finer binning for the theory is needed // 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; 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.SetTheoryTimeStart(fData.GetDataTimeStart());
fData.SetTheoryTimeStep(fTimeResolution*factor); fData.SetTheoryTimeStep(fTimeResolution*factor);
@ -1316,22 +1317,19 @@ Bool_t PRunSingleHisto::EstimateBkg(UInt_t histoNo)
end = fRunInfo->GetBkgRange(1); end = fRunInfo->GetBkgRange(1);
} }
// get the proper run
PRawRunData* runData = fRawData->GetRunData(*fRunInfo->GetRunName());
// check if start is within histogram bounds // 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 << ">> 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 << ">> background start = " << start;
cerr << endl; cerr << endl;
return false; return false;
} }
// check if end is within histogram bounds // 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 << ">> 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 << ">> background end = " << end;
cerr << endl; cerr << endl;
return false; return false;
@ -1342,7 +1340,7 @@ Bool_t PRunSingleHisto::EstimateBkg(UInt_t histoNo)
// forward // forward
for (UInt_t i=start; i<end; i++) for (UInt_t i=start; i<end; i++)
bkg += runData->GetDataBin(histoNo)->at(i); bkg += fForward[i];
bkg /= static_cast<Double_t>(end - start + 1); bkg /= static_cast<Double_t>(end - start + 1);
if (fScaleN0AndBkg) if (fScaleN0AndBkg)

View File

@ -10,8 +10,8 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.c * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * 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 * * it under the terms of the GNU General Public License as published by *

View File

@ -10,8 +10,8 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.c * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * 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 * * it under the terms of the GNU General Public License as published by *

View File

@ -10,8 +10,8 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.c * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * 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 * * it under the terms of the GNU General Public License as published by *

View File

@ -10,8 +10,8 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.c * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * 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 * * it under the terms of the GNU General Public License as published by *

40
src/external/MusrRoot/Makefile.am vendored Normal file
View File

@ -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

196
src/external/MusrRoot/MusrRoot.xsd vendored Normal file
View File

@ -0,0 +1,196 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:annotation>
<xs:documentation>
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 $
</xs:documentation>
</xs:annotation>
<xs:element name="MusrRoot" type="musrRoot"/>
<xs:complexType name="musrRoot">
<xs:sequence>
<xs:element ref="histos"/>
<xs:element name="RunHeader" type="runHeaderFolder"/>
<xs:any processContents="skip" minOccurs="0" maxOccurs="unbounded"/> <!-- here can go any additional stuff you like -->
</xs:sequence>
</xs:complexType>
<xs:element name="histos">
<xs:annotation>
<xs:documentation>
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.
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="DecayAnaModule" type="decayHistoData"/>
<xs:element name="SCAnaModule" type="slowControlHistoData"/>
<xs:any processContents="skip" minOccurs="0" maxOccurs="unbounded"/> <!-- here can go any additional stuff you like -->
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="decayHistoData">
<xs:sequence>
<xs:element name="DecayHistoEntry" type="decayHistoEntry" minOccurs="1" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="decayHistoEntry">
<xs:sequence>
<xs:element name="HistoName" type="histoName"/>
<xs:element name="HistoType" type="histoType"/>
</xs:sequence>
</xs:complexType>
<xs:simpleType name="histoName">
<xs:restriction base="xs:string">
<xs:pattern value="hDecay([0-9]){3,}"/> <!-- this means hDecayXXX, where XXX are 3 digits -->
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="histoType">
<xs:restriction base="xs:string">
<xs:pattern value="TH1F"></xs:pattern>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="slowControlHistoData">
<xs:sequence>
<xs:element name="SlowControlHistoEntry" type="slowControlHistoEntry" minOccurs="1" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="slowControlHistoEntry">
<xs:sequence>
<xs:element name="SlowControlName" type="xs:string"/>
<xs:element name="SlowControlType" type="slowControlType"/>
</xs:sequence>
</xs:complexType>
<xs:simpleType name="slowControlType">
<xs:restriction base="xs:string">
<xs:pattern value="TH1F"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="runHeaderFolder">
<xs:sequence>
<xs:element name="RunInfo" type="runInfo"/>
<xs:element name="DetectorInfo" type="detectorInfo"/>
<xs:element name="SampleEnvironmentInfo" type="sampleEnvironmentInfo"/>
<xs:element name="MagneticFieldEnvironmentInfo" type="magneticFieldEnvironmentInfo"/>
<xs:element name="BeamlineInfo" type="beamlineInfo"/>
<xs:any processContents="skip" minOccurs="0" maxOccurs="unbounded"/> <!-- here can go any additional stuff you like -->
</xs:sequence>
</xs:complexType>
<xs:complexType name="runInfo">
<xs:sequence>
<xs:element name="Version" type="TString"/>
<xs:element name="Generic_Validator_URL" type="TString"/>
<xs:element name="Specific_Validator_URL" type="TString"/>
<xs:element name="Generator" type="TString"/>
<xs:element name="File_Name" type="TString"/>
<xs:element name="Run_Title" type="TString"/>
<xs:element name="Run_Number" type="Int_t"/>
<xs:element name="Run_Start_Time" type="TString"/>
<xs:element name="Run_Stop_Time" type="TString"/>
<xs:element name="Run_Duration" type="TMusrRunPhysicalQuantity"/>
<xs:element name="Laboratory" type="TString"/>
<xs:element name="Area" type="TString"/>
<xs:element name="Instrument" type="TString"/>
<xs:element name="Muon_Beam_Momentum" type="TMusrRunPhysicalQuantity"/>
<xs:element name="Muon_Species" type="TString"/>
<xs:element name="Muon_Source" type="TString"/>
<xs:element name="Setup" type="TString"/>
<xs:element name="Comment" type="TString"/>
<xs:element name="Sample_Name" type="TString"/>
<xs:element name="Sample_Temperature" type="TMusrRunPhysicalQuantity"/>
<xs:element name="Sample_Magnetic_Field" type="TMusrRunPhysicalQuantity"/>
<xs:element name="No_of_Histos" type="Int_t"/>
<xs:element name="Time_Resolution" type="TMusrRunPhysicalQuantity"/>
<xs:element name="RedGreen_Offsets" type="TIntVector"/>
<xs:any processContents="skip" minOccurs="0" maxOccurs="unbounded"/> <!-- here can go any additional stuff you like -->
</xs:sequence>
</xs:complexType>
<xs:simpleType name="Int_t">
<xs:restriction base="xs:string">
<xs:pattern value="Int_t"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="Double_t">
<xs:restriction base="xs:string">
<xs:pattern value="Double_t"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TString">
<xs:restriction base="xs:string">
<xs:pattern value="TString"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TMusrRunPhysicalQuantity">
<xs:restriction base="xs:string">
<xs:pattern value="TMusrRunPhysicalQuantity"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TIntVector">
<xs:restriction base="xs:string">
<xs:pattern value="TIntVector"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="sampleEnvironmentInfo">
<xs:sequence>
<xs:element name="Cryo" type="TString"/>
<xs:any processContents="skip" minOccurs="0" maxOccurs="unbounded"/> <!-- here can go any additional stuff you like -->
</xs:sequence>
</xs:complexType>
<xs:complexType name="magneticFieldEnvironmentInfo">
<xs:sequence>
<xs:element name="Magnet_Name" type="TString"/>
<xs:any processContents="skip" minOccurs="0" maxOccurs="unbounded"/> <!-- here can go any additional stuff you like -->
</xs:sequence>
</xs:complexType>
<xs:complexType name="detectorInfo">
<xs:sequence>
<xs:element name="Detector" type="detector" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="detector">
<xs:sequence>
<xs:element name="Name" type="TString"/>
<xs:element name="Histo_Number" type="Int_t"/>
<xs:element name="Histo_Length" type="Int_t"/>
<xs:element name="Time_Zero_Bin" type="Double_t"/>
<xs:element name="First_Good_Bin" type="Int_t"/>
<xs:element name="Last_Good_Bin" type="Int_t"/>
<xs:any processContents="skip" minOccurs="0" maxOccurs="unbounded"/> <!-- here can go any additional stuff you like -->
</xs:sequence>
</xs:complexType>
<xs:complexType name="beamlineInfo">
<xs:sequence>
<xs:element name="Name" type="TString"/>
<xs:any processContents="skip" minOccurs="0" maxOccurs="unbounded"/> <!-- here can go any additional stuff you like -->
</xs:sequence>
</xs:complexType>
</xs:schema>

222
src/external/MusrRoot/MusrRootLEM.xsd vendored Normal file
View File

@ -0,0 +1,222 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:annotation>
<xs:documentation>
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 $
</xs:documentation>
</xs:annotation>
<xs:element name="MusrRoot" type="musrRoot"/>
<xs:complexType name="musrRoot">
<xs:sequence>
<xs:element ref="histos"/>
<xs:element name="RunHeader" type="runHeaderFolder"/>
<xs:any processContents="skip" minOccurs="0" maxOccurs="unbounded"/> <!-- here can go any additional stuff you like -->
</xs:sequence>
</xs:complexType>
<xs:element name="histos">
<xs:annotation>
<xs:documentation>
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.
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="DecayAnaModule" type="decayHistoData"/>
<xs:element name="SCAnaModule" type="slowControlHistoData"/>
<xs:element name="TOFAnaModule" type="histoData"/>
<xs:element name="PileUpAnaModule" type="histoData"/>
<xs:any processContents="skip" minOccurs="0" maxOccurs="unbounded"/> <!-- here can go any additional stuff you like -->
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="decayHistoData">
<xs:sequence>
<xs:element name="DecayHistoEntry" type="decayHistoEntry" minOccurs="1" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="decayHistoEntry">
<xs:sequence>
<xs:element name="HistoName" type="histoName"/>
<xs:element name="HistoType" type="histoType"/>
</xs:sequence>
</xs:complexType>
<xs:simpleType name="histoName">
<xs:restriction base="xs:string">
<xs:pattern value="hDecay([0-9]){3,}"/> <!-- this means hDecayXXX, where XXX are 3 digits or more -->
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="histoType">
<xs:restriction base="xs:string">
<xs:pattern value="TH1F"></xs:pattern>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="slowControlHistoData">
<xs:sequence>
<xs:element name="SlowControlHistoEntry" type="slowControlHistoEntry" minOccurs="1" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="slowControlHistoEntry">
<xs:sequence>
<xs:element name="SlowControlName" type="xs:string"/>
<xs:element name="SlowControlType" type="slowControlType"/>
</xs:sequence>
</xs:complexType>
<xs:simpleType name="slowControlType">
<xs:restriction base="xs:string">
<xs:pattern value="TH1F"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="runHeaderFolder">
<xs:sequence>
<xs:element name="RunInfo" type="runInfo"/>
<xs:element name="DetectorInfo" type="detectorInfo"/>
<xs:element name="SampleEnvironmentInfo" type="sampleEnvironmentInfo"/>
<xs:element name="MagneticFieldEnvironmentInfo" type="magneticFieldEnvironmentInfo"/>
<xs:element name="BeamlineInfo" type="beamlineInfo"/>
<xs:any processContents="skip" minOccurs="0" maxOccurs="unbounded"/> <!-- here can go any additional stuff you like -->
</xs:sequence>
</xs:complexType>
<xs:complexType name="runInfo">
<xs:sequence>
<xs:element name="Version" type="TString"/>
<xs:element name="Generic_Validator_URL" type="TString"/>
<xs:element name="Specific_Validator_URL" type="TString"/>
<xs:element name="Generator" type="TString"/>
<xs:element name="File_Name" type="TString"/>
<xs:element name="Run_Title" type="TString"/>
<xs:element name="Run_Number" type="Int_t"/>
<xs:element name="Run_Start_Time" type="TString"/>
<xs:element name="Run_Stop_Time" type="TString"/>
<xs:element name="Run_Duration" type="TMusrRunPhysicalQuantity"/>
<xs:element name="Laboratory" type="TString"/>
<xs:element name="Area" type="TString"/>
<xs:element name="Instrument" type="TString"/>
<xs:element name="Muon_Beam_Momentum" type="TMusrRunPhysicalQuantity"/>
<xs:element name="Muon_Species" type="TString"/>
<xs:element name="Muon_Source" type="TString"/>
<xs:element name="Setup" type="TString"/>
<xs:element name="Comment" type="TString"/>
<xs:element name="Sample_Name" type="TString"/>
<xs:element name="Sample_Temperature" type="TMusrRunPhysicalQuantity"/>
<xs:element name="Sample_Magnetic_Field" type="TMusrRunPhysicalQuantity"/>
<xs:element name="No_of_Histos" type="Int_t"/>
<xs:element name="Time_Resolution" type="TMusrRunPhysicalQuantity"/>
<xs:element name="RedGreen_Offsets" type="TIntVector"/>
<xs:element name="Moderator" type="TString"/>
<xs:element name="Moderator_HV" type="TMusrRunPhysicalQuantity"/>
<xs:element name="Sample_HV" type="TMusrRunPhysicalQuantity"/>
<xs:element name="Implantation_Energy" type="TMusrRunPhysicalQuantity"/>
<xs:element name="Cuts" type="TString"/>
<xs:any processContents="skip" minOccurs="0" maxOccurs="unbounded"/> <!-- here can go any additional stuff you like -->
</xs:sequence>
</xs:complexType>
<xs:simpleType name="Int_t">
<xs:restriction base="xs:string">
<xs:pattern value="Int_t"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="Double_t">
<xs:restriction base="xs:string">
<xs:pattern value="Double_t"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TString">
<xs:restriction base="xs:string">
<xs:pattern value="TString"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TMusrRunPhysicalQuantity">
<xs:restriction base="xs:string">
<xs:pattern value="TMusrRunPhysicalQuantity"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TIntVector">
<xs:restriction base="xs:string">
<xs:pattern value="TIntVector"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="sampleEnvironmentInfo">
<xs:sequence>
<xs:element name="Cryo" type="TString"/>
<xs:any processContents="skip" minOccurs="0" maxOccurs="unbounded"/> <!-- here can go any additional stuff you like -->
</xs:sequence>
</xs:complexType>
<xs:complexType name="magneticFieldEnvironmentInfo">
<xs:sequence>
<xs:element name="Magnet_Name" type="TString"/>
<xs:any processContents="skip" minOccurs="0" maxOccurs="unbounded"/> <!-- here can go any additional stuff you like -->
</xs:sequence>
</xs:complexType>
<xs:complexType name="detectorInfo">
<xs:sequence>
<xs:element name="Detector" type="detector" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="detector">
<xs:sequence>
<xs:element name="Name" type="TString"/>
<xs:element name="Histo_Number" type="Int_t"/>
<xs:element name="Histo_Length" type="Int_t"/>
<xs:element name="Time_Zero_Bin" type="Double_t"/>
<xs:element name="First_Good_Bin" type="Int_t"/>
<xs:element name="Last_Good_Bin" type="Int_t"/>
<xs:any processContents="skip" minOccurs="0" maxOccurs="unbounded"/> <!-- here can go any additional stuff you like -->
</xs:sequence>
</xs:complexType>
<xs:complexType name="beamlineInfo">
<xs:sequence>
<xs:element name="Name" type="TString"/>
<xs:element name="Beamline_Settings" type="TString"/>
<xs:any processContents="skip" minOccurs="0" maxOccurs="unbounded"/> <!-- here can go any additional stuff you like -->
</xs:sequence>
</xs:complexType>
<xs:complexType name="histoData">
<xs:sequence>
<xs:element name="Entry" type="histoEntry" minOccurs="1" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="histoEntry">
<xs:sequence>
<xs:element name="Name" type="xs:string"/>
<xs:element name="Type" type="rootHistoType"/>
</xs:sequence>
</xs:complexType>
<xs:simpleType name="rootHistoType">
<xs:restriction base="xs:string">
<xs:pattern value="TH([1-2])F"/> <!-- this means TH1F or TH2F -->
</xs:restriction>
</xs:simpleType>
</xs:schema>

1691
src/external/MusrRoot/TMusrRunHeader.cpp vendored Normal file

File diff suppressed because it is too large Load Diff

196
src/external/MusrRoot/TMusrRunHeader.h vendored Normal file
View File

@ -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 <vector>
using namespace std;
#include <TDatime.h>
#include <TObject.h>
#include <TQObject.h>
#include <TObjString.h>
#include <TObjArray.h>
#include <TFolder.h>
#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<Int_t> TIntVector;
typedef vector<Double_t> TDoubleVector;
typedef vector<TString> TStringVector;
//-------------------------------------------------------------------------
template <class T> 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<TString> > fStringObj;
vector< TMusrRunObject<Int_t> > fIntObj;
vector< TMusrRunObject<Double_t> > fDoubleObj;
vector< TMusrRunObject<TMusrRunPhysicalQuantity> > fMusrRunPhysQuantityObj;
vector< TMusrRunObject<TStringVector> > fStringVectorObj;
vector< TMusrRunObject<TIntVector> > fIntVectorObj;
vector< TMusrRunObject<TDoubleVector> > fDoubleVectorObj;
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

View File

@ -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}

24
templates/cpp → src/external/MusrRoot/TMusrRunHeaderLinkDef.h vendored Executable file → Normal file
View File

@ -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 * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * This program is free software; you can redistribute it and/or modify *
@ -17,3 +28,14 @@
* Free Software Foundation, Inc., * * Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 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

318
src/external/MusrRoot/root2xml.C vendored Normal file
View File

@ -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<string> 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 version=\"1.0\" encoding=\"UTF-8\"?>");
xml_data.push_back("<MusrRoot xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"file:MusrRoot.xsd\">");
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("</MusrRoot>");
// 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<xml_data.size(); i++)
fout << xml_data[i] << endl;
fout.close();
}
void sort_histo_folders()
{
vector<string> temp_xml_data;
// first make a copy of the original xml_data
for (unsigned int i=0; i<xml_data.size(); i++)
temp_xml_data.push_back(xml_data[i]);
// remove SCAnaModule from temp_xml_data
unsigned int start = 0, end = 0;
for (unsigned int i=0; i<temp_xml_data.size(); i++) {
if (temp_xml_data[i].find("<SCAnaModule>") != string::npos)
start = i;
if (temp_xml_data[i].find("</SCAnaModule>") != 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<temp_xml_data.size(); i++) {
if (temp_xml_data[i].find("</DecayAnaModule>") != 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; i<temp_xml_data.size(); i++)
xml_data.push_back(temp_xml_data[i]);
// clean up
temp_xml_data.clear();
}
void dumpFolder(TFolder *folder, UInt_t offset)
{
TString offsetStr="";
for (UInt_t i=0; i<offset; i++)
offsetStr += " ";
TIter next = folder->GetListOfFolders();
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; i<offset; i++)
offsetStr += " ";
TObjString *tstr;
TString str, xmlStr, type, label, xmlLabel;
// check if the obj name is anything like DetectorXXX, where XXX is a number
xmlLabel = TString(obj->GetName());
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; i<obj->GetEntries(); 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 + "</" + label + ">" ;
xml_data.push_back(xmlStr.Data());
}
}
xmlStr = offsetStr + "</" + xmlLabel + ">";
xml_data.push_back(xmlStr.Data());
}
void dumpEntry(TObject *obj, UInt_t offset)
{
TString offsetStr="";
for (UInt_t i=0; i<offset; i++)
offsetStr += " ";
TString nameTag(""), typeTag("");
switch (folderTag) {
case eDecayAnaModule:
nameTag = "HistoName";
typeTag = "HistoType";
break;
case eSlowControlAnaModule:
nameTag = "SlowControlName";
typeTag = "SlowControlType";
break;
case eUnkown:
default:
nameTag = "Name";
typeTag = "Type";
break;
}
TString str;
str = offsetStr + "<" + nameTag + ">";
str += obj->GetName();
str += "</" + nameTag + ">";
xml_data.push_back(str.Data());
str = offsetStr + "<" + typeTag + ">";
str += obj->ClassName();
str += "</" + typeTag + ">";
xml_data.push_back(str.Data());
}
void checkClass(TObject *obj, TString str, UInt_t offset)
{
TString offsetStr="";
for (UInt_t i=0; i<offset; i++)
offsetStr += " ";
if (str == "TFolder") {
TString xmlTagName(TString(obj->GetName()));
// 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 + "</" + xmlTagName + ">";
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 + "</" + entryTag + ">";
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
}

View File

@ -10,7 +10,7 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007-2011 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.ch * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * 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()) if (idx >= fT0.size())
return -1; return -1;
return fT0[idx]; return (int)fT0[idx];
} }
//------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------
@ -581,7 +581,7 @@ int PNeXusData1::GetFirstGoodBin(unsigned int idx)
if (idx >= fFirstGoodBin.size()) if (idx >= fFirstGoodBin.size())
return -1; return -1;
return fFirstGoodBin[idx]; return (int)fFirstGoodBin[idx];
} }
//------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------
@ -597,7 +597,7 @@ int PNeXusData1::GetLastGoodBin(unsigned int idx)
if (idx >= fLastGoodBin.size()) if (idx >= fLastGoodBin.size())
return -1; return -1;
return fLastGoodBin[idx]; return (int)fLastGoodBin[idx];
} }

View File

@ -10,7 +10,7 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007-2011 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.ch * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * This program is free software; you can redistribute it and/or modify *

View File

@ -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 <<EOFHELP
"musrfit-msr to db/dat converter"
USAGE: msr2data FIRSTRUN# LASTRUN# EXTENSION [noheader | nosummary | fit-TEMPLATERUN# | -oOUTPUT_FILE | -k | -t | data ]
OR
msr2data \[SPACE SEPARATED LIST OF RUNS\] EXTENSION [noheader | nosummary | fit-TEMPLATERUN# | -oOUTPUT_FILE | -k | -t | data ]
OR
msr2data RUNLISTFILE EXTENSION [noheader | nosummary | fit-TEMPLATERUN# | -oOUTPUT_FILE | -k | -t | data ]
This small script converts subsequent musrfit msr output files into one db- or column-ASCII-file using bash/awk.
Example 1:
msr2data 1423 1425 _tf_h13
generates the db-file "out.db" (or whatever filename you additionally specify with the -o option) from 1423_tf_h13.msr, 1424_tf_h13.msr, and 1425_tf_h13.msr .
Example 2:
msr2data [1487 1435] _tf_h13
generates the db-file "out.db" (or whatever filename you additionally specify with the -o option) from 1487_tf_h13.msr and 1435_tf_h13.msr .
Example 3:
msr2data runs.txt _tf_h13
generates the db-file "out.db" (or whatever filename you additionally specify with the -o option) from all runs listed in the ASCII-file
"runs.txt" in the working directory. In the file it's also possible to include external parameters which should be put in the resulting db-file.
The structure of the "runs.txt" is the following:
RUN VAR1 VAR2 VAR3 ...
2716 200 27.1 46.2 ...
2787 205 27.1 46.3 ...
2260 210 27.2 45.9 ...
...
The first line specifies the db-parameter names and labels and has to be present!
The output files in all examples above also include the db header.
In the case you are dealing with LEM-data AND have locally mounted the /mnt/data/nemu directory some available parameters like the
temperature or transport settings will be taken from the summary files and added to the db-file.
You can suppress the reading of the summary files with the option "nosummary".
If you want to generate a file without the header information just run the script with the option "noheader".
If you additionally want to fit some data using musrfit specify the option "fit-TEMPLATERUN#".
In this case either a msr-file or a mlog-file have to be present for the specified template run.
The subsequent input files will be created.
If you add a "!" to the fit option, e.g. "fit-199!" the specified template will serve as template for ALL runs, not only for the first one.
Example 4:
msr2data 200 220 _tf_h13 -oABC.db fit-199
This will fit the runs 200 to 220 using musrfit. The file 199_tf_h13.msr (or if that is not available: 199_tf_h13.mlog) is used as
template for the first musrfit input file. The results of the fits will be written to ABC.db.
For keeping the MINUIT2 output files after calling musrfit, i.e. invoke musrfit with the option "--keep-mn2-output" just pass the option "-k" to msr2data. If you pass this option to msr2data but do not fit any data, the option will just be ignored.
If musrfit should add the title present in the first data file mentioned in a RUN block to the title line of the mlog output file, pass the option "-t" to msr2data. Then musrfit is called with the option "--title-from-data-file". If you pass this option to msr2data but do not fit any data, the option will just be ignored.
If your musrfit output files do not have an extension as specified above like "200.msr" you have to call the script as in the following example.
Example 5:
msr2data 200 220 "" -oABC.db fit-199
As an alternative to the db-format as output-format of the script it is possible to choose an ASCII file with simple data columns by invoking the script with the option "data". All features described above are available also for that case!
CAUTION:
The "indexing number" of the .msr has to be at the begin of the filename.
Furthermore the data files that were fitted have to have the name "XXX_RUN#[_YYY]", where XXX,YYY are strings without whitespaces ("/" is OK).
If you want to use the fitting feature, musrfit has to be installed either on the PATH or in the working directory.
Those of you who do not like scripting without functions better do not look at the code. Still it is more or less straight forward.
EOFHELP
else
export PATH=./:$PATH
export LC_NUMERIC=en_US.UTF-8
SUMMDIR="/mnt/data/nemu/summ"
# In case a list of runs is given by [...]
if [ "${1:0:1}" == "[" ]; then
RUNARRAY=($@)
if [ "$1" == "[" ]; then
RUNARRAY[0]=""
else
RUNARRAY[0]=${RUNARRAY[0]#"["}
fi
tLen=${#RUNARRAY[@]}
for (( i=0; i<${tLen}; i++ ))
do
if [ "$1" == "[" ]; then
RUNARRAY[$i]=${RUNARRAY[ (( i + 1 )) ]}
fi
if [ "${RUNARRAY[$i]:(-1)}" == "]" ]; then
if [ "${RUNARRAY[$i]}" == "]" ]; then
RUNARRAY[$i]=""
LASTRUN=$(( i - 1 )) # RUNARRAY-index of the last run
else
RUNARRAY[$i]=${RUNARRAY[$i]%"]"}
LASTRUN=$i # RUNARRAY-index of the last run
fi
fi
done
# search for the parameter including the "]"
for (( i=1; i<="$#"; i++ ))
do
RIGHTBRACKET=$( eval echo \${$i} )
if [ "${RIGHTBRACKET:(-1)}" == "]" ]; then
RIGHTBRACKET=$i
break
else
RIGHTBRACKET=0
fi
done
if [ "$RIGHTBRACKET" -eq 0 ]; then
echo
echo ">> 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<i+4;k++){
print parArray[k] >> outfile
}
$1 = "Data"
$2 = "T"
$3 = "Tr"
$4 = "E"
$5 = "RALRAR"
$6 = "RATRAB"
for(k=1;k<numIndVar;k++){
$(k+6)=indVar[k+1]
}
for(k=1;k<i+4;k++){
$(k+6+numIndVar-1)=parArray[k]
}
print "\n" $0 >> 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<i+3;l++){
print parArray[l] " = " dataArray[l] ", " posErrArray[l] ", " negErrArray[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<i+4;k++){
print parArray[k] >> outfile
}
$1 = "Data"
for(k=1;k<numIndVar;k++){
$(k+1)=indVar[k+1]
}
for(k=1;k<i+4;k++){
$(k+1+numIndVar-1)=parArray[k]
}
print "\n" $0 >> 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<i+3;l++){
print parArray[l] " = " dataArray[l] ", " posErrArray[l] ", " negErrArray[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<numIndVar;k++){
$(k+5)=indVar[k+1]
}
for(k=1;k<i;k++){ # musrfit parameters
$(3*k-2+5+numIndVar-1)=parArray[k]
$(3*k-2+5+numIndVar)="PosErr"
$(3*k-2+5+numIndVar+1)="NegErr"
}
for(k=0;k<4;k++){ # CHI2, NDF, CHI2red, RUN (without errors)
$(3*i-2+5+numIndVar-1+k)=parArray[i+k]
}
print $0 >> 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<i;l++){ # musrfit parameters
$(3*l-2+5+numIndVar-1)=dataArray[l]
$(3*l-2+5+numIndVar)=posErrArray[l]
$(3*l-2+5+numIndVar+1)=negErrArray[l]
}
for(l=0;l<4;l++){ # CHI2, NDF, CHI2red, RUN (without errors)
$(3*i-2+5+numIndVar-1+l)=dataArray[i+l]
}
print $0 >> 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<numIndVar;k++){
$(k)=indVar[k+1]
}
for(k=1;k<i;k++){ # musrfit parameters
$(3*k-2+numIndVar-1)=parArray[k]
$(3*k-2+numIndVar)="PosErr"
$(3*k-2+numIndVar+1)="NegErr"
}
for(k=0;k<4;k++){ # CHI2, NDF, CHI2red, RUN (without errors)
$(3*i-2+numIndVar-1+k)=parArray[i+k]
}
print $0 >> 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<i;l++){ # musrfit parameters
$(3*l-2+numIndVar-1)=dataArray[l]
$(3*l-2+numIndVar)=posErrArray[l]
$(3*l-2+numIndVar+1)=negErrArray[l]
}
for(l=0;l<4;l++){ # CHI2, NDF, CHI2red, RUN (without errors)
$(3*i-2+numIndVar-1+l)=dataArray[i+l]
}
print $0 >> 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

View File

@ -10,8 +10,8 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.c * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * 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 * * it under the terms of the GNU General Public License as published by *

View File

@ -10,8 +10,8 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.c * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * 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 * * it under the terms of the GNU General Public License as published by *

View File

@ -10,8 +10,8 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2008 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.c * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * 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 * * it under the terms of the GNU General Public License as published by *

View File

@ -10,8 +10,8 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.c * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * 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 * * it under the terms of the GNU General Public License as published by *

View File

@ -10,8 +10,8 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.c * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * 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 * * it under the terms of the GNU General Public License as published by *

View File

@ -10,8 +10,8 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.c * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * 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 * * it under the terms of the GNU General Public License as published by *

View File

@ -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 * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * This program is free software; you can redistribute it and/or modify *

View File

@ -10,7 +10,7 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007-2011 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.ch * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * 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 SetMsrParamPosErrorPresent(UInt_t i, Bool_t value);
virtual Bool_t SetMsrParamPosError(UInt_t i, Double_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 SetMsrT0Entry(UInt_t runNo, UInt_t idx, Double_t bin);
virtual void SetMsrAddT0Entry(UInt_t runNo, UInt_t addRunIdx, UInt_t histoIdx, Int_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 SetMsrDataRangeEntry(UInt_t runNo, UInt_t idx, Int_t bin);
virtual void SetMsrBkgRangeEntry(UInt_t runNo, UInt_t idx, Int_t bin); virtual void SetMsrBkgRangeEntry(UInt_t runNo, UInt_t idx, Int_t bin);

View File

@ -10,7 +10,7 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007-2010 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.ch * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * This program is free software; you can redistribute it and/or modify *
@ -38,6 +38,8 @@ using namespace std;
#include <TString.h> #include <TString.h>
#define PMUSR_VERSION "0.10.0"
#define PMUSR_SUCCESS 0 #define PMUSR_SUCCESS 0
#define PMUSR_WRONG_STARTUP_SYNTAX -1 #define PMUSR_WRONG_STARTUP_SYNTAX -1
#define PMUSR_MSR_FILE_NOT_FOUND -2 #define PMUSR_MSR_FILE_NOT_FOUND -2
@ -266,6 +268,76 @@ class PNonMusrRawRunData {
vector<PDoubleVector> fErrData; ///< vector of all data errors vector<PDoubleVector> fErrData; ///< vector of all data errors
}; };
//-------------------------------------------------------------
/**
* <p>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
};
//-------------------------------------------------------------
/**
* <p>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<PRawRunDataSet> fDataVec;
};
//------------------------------------------------------------- //-------------------------------------------------------------
/** /**
* <p>Handles raw data, both non-muSR data as well muSR histogram data. * <p>Handles raw data, both non-muSR data as well muSR histogram data.
@ -275,12 +347,20 @@ class PRawRunData {
PRawRunData(); PRawRunData();
virtual ~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* GetLaboratory() { return &fLaboratory; }
virtual const TString* GetBeamline() { return &fBeamline; } virtual const TString* GetBeamline() { return &fBeamline; }
virtual const TString* GetInstrument() { return &fInstrument; } virtual const TString* GetInstrument() { return &fInstrument; }
virtual const TString* GetArea() { return &fArea; }
virtual const TString* GetRunName() { return &fRunName; } virtual const TString* GetRunName() { return &fRunName; }
virtual const TString* GetMuonSource() { return &fMuonSource; } virtual const TString* GetMuonSource() { return &fMuonSource; }
virtual const TString* GetMuonSpecies() { return &fMuonSpecies; } virtual const TString* GetMuonSpecies() { return &fMuonSpecies; }
virtual const Double_t GetMuonBeamMomentum() { return fMuonBeamMomentum; }
virtual const Int_t GetRunNumber() { return fRunNumber; } virtual const Int_t GetRunNumber() { return fRunNumber; }
virtual const TString* GetRunTitle() { return &fRunTitle; } virtual const TString* GetRunTitle() { return &fRunTitle; }
virtual const TString* GetSetup() { return &fSetup; } virtual const TString* GetSetup() { return &fSetup; }
@ -290,8 +370,10 @@ class PRawRunData {
virtual const TString* GetStopTime() { return &fStopTime; } virtual const TString* GetStopTime() { return &fStopTime; }
virtual const TString* GetStopDate() { return &fStopDate; } virtual const TString* GetStopDate() { return &fStopDate; }
virtual const time_t GetStopDateTime() { return fStopDateTimeSec; } virtual const time_t GetStopDateTime() { return fStopDateTimeSec; }
virtual const TString* GetCryoName() { return &fCryo; }
virtual const TString* GetSample() { return &fSample; } virtual const TString* GetSample() { return &fSample; }
virtual const TString* GetOrientation() { return &fOrientation; } virtual const TString* GetOrientation() { return &fOrientation; }
virtual const TString* GetMagnetName() { return &fMagnet; }
virtual const Double_t GetField() { return fField; } virtual const Double_t GetField() { return fField; }
virtual const UInt_t GetNoOfTemperatures() { return fTemp.size(); } virtual const UInt_t GetNoOfTemperatures() { return fTemp.size(); }
virtual const PDoublePairVector* GetTemperature() const { return &fTemp; } virtual const PDoublePairVector* GetTemperature() const { return &fTemp; }
@ -301,23 +383,31 @@ class PRawRunData {
virtual const Double_t GetTransport() { return fTransport; } virtual const Double_t GetTransport() { return fTransport; }
virtual const PDoubleVector GetRingAnode() { return fRingAnode; } virtual const PDoubleVector GetRingAnode() { return fRingAnode; }
virtual const Double_t GetRingAnode(const UInt_t idx); virtual const Double_t GetRingAnode(const UInt_t idx);
virtual const Double_t GetTimeResolution() { return fTimeResolution; } virtual const Double_t GetTimeResolution() { return fTimeResolution; }
virtual const UInt_t GetT0Size() { return fT0s.size(); } virtual const Bool_t IsPresent(UInt_t histoNo) { return fData.IsPresent(histoNo); }
virtual const Int_t GetT0(const UInt_t idx); virtual const Double_t GetT0Bin(const UInt_t histoNo) { return fData.GetT0Bin(histoNo); }
virtual const UInt_t GetT0EstimatedSize() { return fT0Estimated.size(); } virtual const Double_t GetT0BinEstimated(const UInt_t histoNo) { return fData.GetT0BinEstimated(histoNo); }
virtual const Int_t GetT0Estimated(const UInt_t idx); virtual const PIntPair GetBkgBin(const UInt_t histoNo) { return fData.GetBkgBin(histoNo); }
virtual const PIntPair GetBkgBin(const UInt_t idx); virtual const PIntPair GetGoodDataBin(const UInt_t histoNo) { return fData.GetGoodDataBin(histoNo); }
virtual const UInt_t GetGoodDataBinSize() { return fGoodDataBin.size(); } virtual const PIntVector GetRedGreenOffset() { return fRedGreenOffset; }
virtual const PIntPair GetGoodDataBin(const UInt_t idx); virtual const UInt_t GetNoOfHistos() { return fData.Size(); }
virtual const UInt_t GetNoOfHistos() { return fDataBin.size(); } virtual PRawRunDataSet* GetDataSet(const UInt_t idx, Bool_t wantHistoNo = true);
virtual const PDoubleVector* GetDataBin(const UInt_t idx); virtual const PDoubleVector* GetDataBin(const UInt_t histoNo) { return fData.GetData(histoNo); }
virtual const PNonMusrRawRunData* GetDataNonMusr() { return &fDataNonMusr; } 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 SetLaboratory(const TString &str) { fLaboratory = str; }
virtual void SetBeamline(const TString &str) { fBeamline = str; } virtual void SetBeamline(const TString &str) { fBeamline = str; }
virtual void SetInstrument(const TString &str) { fInstrument = 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 SetMuonSource(const TString &str) { fMuonSource = str; }
virtual void SetMuonSpecies(const TString &str) { fMuonSpecies = 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 SetRunName(const TString &str) { fRunName = str; }
virtual void SetRunNumber(const Int_t &val) { fRunNumber = val; } virtual void SetRunNumber(const Int_t &val) { fRunNumber = val; }
virtual void SetRunTitle(const TString str) { fRunTitle = str; } virtual void SetRunTitle(const TString str) { fRunTitle = str; }
@ -328,7 +418,9 @@ class PRawRunData {
virtual void SetStopTime(const TString str) { fStopTime = str; } virtual void SetStopTime(const TString str) { fStopTime = str; }
virtual void SetStopDate(const TString str) { fStopDate = str; } virtual void SetStopDate(const TString str) { fStopDate = str; }
virtual void SetStopDateTime(const time_t val) { fStopDateTimeSec = val; } 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 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 SetSample(const TString str) { fSample = str; }
virtual void SetOrientation(const TString str) { fOrientation = str; } virtual void SetOrientation(const TString str) { fOrientation = str; }
virtual void ClearTemperature() { fTemp.clear(); } virtual void ClearTemperature() { fTemp.clear(); }
@ -338,24 +430,27 @@ class PRawRunData {
virtual void SetTransport(const Double_t dval) { fTransport = dval; } virtual void SetTransport(const Double_t dval) { fTransport = dval; }
virtual void SetRingAnode(const UInt_t idx, const Double_t dval); virtual void SetRingAnode(const UInt_t idx, const Double_t dval);
virtual void SetTimeResolution(const Double_t dval) { fTimeResolution = dval; } virtual void SetTimeResolution(const Double_t dval) { fTimeResolution = dval; }
virtual void AppendT0(const Int_t ival) { fT0s.push_back(ival); } virtual void SetRedGreenOffset(PIntVector &ivec) { fRedGreenOffset = ivec; }
virtual void AppendT0Estimated(const Int_t ival) { fT0Estimated.push_back(ival); } virtual void SetDataSet(PRawRunDataSet &dataSet, UInt_t idx=-1) { fData.Set(dataSet, idx); }
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);
PNonMusrRawRunData fDataNonMusr; ///< keeps all ascii- or db-file info in case of nonMusr fit PNonMusrRawRunData fDataNonMusr; ///< keeps all ascii- or db-file info in case of nonMusr fit
private: 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 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 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 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 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 fMuonSpecies; ///< positive muon or negative muon
TString fRunName; ///< name of the run 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
Int_t fRunNumber; ///< run number TString fRunName; ///< name of the run as found in the msr-file
Int_t fRunNumber; ///< run number
TString fRunTitle; ///< run title TString fRunTitle; ///< run title
TString fSetup; ///< description of the setup of this run TString fSetup; ///< description of the setup of this run
TString fStartTime; ///< start time of the run TString fStartTime; ///< start time of the run
@ -364,19 +459,19 @@ class PRawRunData {
TString fStopTime; ///< stop time of the run TString fStopTime; ///< stop time of the run
TString fStopDate; ///< stop date of the run TString fStopDate; ///< stop date of the run
time_t fStopDateTimeSec; ///< stop run given as time_t object time_t fStopDateTimeSec; ///< stop run given as time_t object
TString fCryo; ///< name of the cryo
TString fSample; ///< description of the sample TString fSample; ///< description of the sample
TString fOrientation; ///< description of the orientation 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 PDoublePairVector fTemp; ///< measured temperatures and standard deviations during the run
Double_t fEnergy; ///< implantation energy of the muon Double_t fEnergy; ///< implantation energy of the muon
Double_t fTransport; ///< LEM transport settings (Moderator HV) Double_t fTransport; ///< LEM transport settings (Moderator HV)
PDoubleVector fRingAnode; ///< LEM ring anode HVs (L,R[,T,B]) PDoubleVector fRingAnode; ///< LEM ring anode HVs (L,R[,T,B])
Double_t fTimeResolution; ///< time resolution of the run in (ns) Double_t fTimeResolution; ///< time resolution of the run in (ns)
PIntVector fT0s; ///< vector of t0's of a run PIntVector fRedGreenOffset; ///< keeps the Red/Green offsets
PIntVector fT0Estimated; ///< vector of t0's estimated based on the maximum of the histogram
PIntPairVector fBkgBin; ///< background bins (first/last) PRawRunDataVector fData; ///< keeps the histos together with the histo related properties such as T0, first good bin, etc.
PIntPairVector fGoodDataBin; ///< data bins (first/last)
vector<PDoubleVector> fDataBin; ///< vector of all histos of a run
}; };
//------------------------------------------------------------- //-------------------------------------------------------------
@ -461,11 +556,11 @@ class PMsrRunBlock {
virtual Double_t GetBkgFix(UInt_t idx); virtual Double_t GetBkgFix(UInt_t idx);
virtual Int_t GetBkgRange(UInt_t idx); virtual Int_t GetBkgRange(UInt_t idx);
virtual Int_t GetDataRange(UInt_t idx); virtual Int_t GetDataRange(UInt_t idx);
virtual UInt_t GetT0Size() { return fT0.size(); } virtual UInt_t GetT0BinSize() { return fT0.size(); }
virtual Int_t GetT0(UInt_t idx=0); virtual Double_t GetT0Bin(UInt_t idx=0);
virtual UInt_t GetAddT0Entries() { return fAddT0.size(); } virtual UInt_t GetAddT0BinEntries() { return fAddT0.size(); }
virtual Int_t GetAddT0Size(UInt_t addRunIdx); virtual Int_t GetAddT0BinSize(UInt_t addRunIdx);
virtual Int_t GetAddT0(UInt_t addRunIdx, UInt_t histoIdx); virtual Double_t GetAddT0Bin(UInt_t addRunIdx, UInt_t histoIdx);
virtual Double_t GetFitRange(UInt_t idx); virtual Double_t GetFitRange(UInt_t idx);
virtual Int_t GetPacking() { return fPacking; } virtual Int_t GetPacking() { return fPacking; }
virtual Int_t GetXDataIndex() { return fXYDataIndex[0]; } virtual Int_t GetXDataIndex() { return fXYDataIndex[0]; }
@ -493,8 +588,8 @@ class PMsrRunBlock {
virtual void SetBkgFix(Double_t dval, Int_t idx); virtual void SetBkgFix(Double_t dval, Int_t idx);
virtual void SetBkgRange(Int_t ival, Int_t idx); virtual void SetBkgRange(Int_t ival, Int_t idx);
virtual void SetDataRange(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 SetT0Bin(Double_t dval, Int_t idx=-1);
virtual void SetAddT0(Int_t ival, UInt_t addRunIdx, UInt_t histoNoIdx); virtual void SetAddT0Bin(Double_t dval, UInt_t addRunIdx, UInt_t histoNoIdx);
virtual void SetFitRange(Double_t dval, UInt_t idx); virtual void SetFitRange(Double_t dval, UInt_t idx);
virtual void SetPacking(Int_t ival) { fPacking = ival; } virtual void SetPacking(Int_t ival) { fPacking = ival; }
virtual void SetXDataIndex(Int_t ival) { fXYDataIndex[0] = 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) 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 fBkgRange[4]; ///< background bin range (fit type 0, 2, 4)
Int_t fDataRange[4]; ///< data 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, ... 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<PIntVector> fAddT0; ///< t0 bins for addrun's vector<PDoubleVector> fAddT0; ///< t0 bins for addrun's
Double_t fFitRange[2]; ///< fit range in (us) Double_t fFitRange[2]; ///< fit range in (us)
Int_t fPacking; ///< packing/rebinning Int_t fPacking; ///< packing/rebinning
Int_t fXYDataIndex[2]; ///< used to get the data indices when using db-files (fit type 8) Int_t fXYDataIndex[2]; ///< used to get the data indices when using db-files (fit type 8)

View File

@ -10,7 +10,7 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.ch * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * This program is free software; you can redistribute it and/or modify *

View File

@ -10,7 +10,7 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.ch * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * This program is free software; you can redistribute it and/or modify *

View File

@ -10,7 +10,7 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2009 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.ch * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * 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 GetHistoNo(UInt_t idx);
virtual Int_t GetDetectorTag() { return fDetectorTag; } virtual Int_t GetDetectorTag() { return fDetectorTag; }
virtual Int_t GetCmdTag() { return fCmdTag; } virtual Int_t GetCmdTag() { return fCmdTag; }
virtual UInt_t GetT0Size() { return fT0.size(); } virtual UInt_t GetT0BinSize() { return fT0.size(); }
virtual Int_t GetT0(UInt_t idx); virtual Int_t GetT0Bin(UInt_t idx);
virtual UInt_t GetAddT0Entries() { return fAddT0.size(); } virtual UInt_t GetAddT0Entries() { return fAddT0.size(); }
virtual UInt_t GetAddT0Size(UInt_t idx); virtual UInt_t GetAddT0BinSize(UInt_t idx);
virtual Int_t GetAddT0(UInt_t addRunIdx, UInt_t idx); virtual Int_t GetAddT0Bin(UInt_t addRunIdx, UInt_t idx);
virtual Int_t GetT0Data() { return fT0Data; } virtual Int_t GetT0BinData() { return fT0Data; }
virtual void SetSingleHisto(const Bool_t flag) { fSingleHisto = flag; } virtual void SetSingleHisto(const Bool_t flag) { fSingleHisto = flag; }
virtual void SetRawRunData(const vector<PRawRunData*> rawRunData) { fRawRunData = rawRunData; } virtual void SetRawRunData(const vector<PRawRunData*> rawRunData) { fRawRunData = rawRunData; }
@ -92,9 +92,9 @@ class PMusrT0Data {
virtual void SetHistoNo(const PIntVector histoNo) { fHistoNo = histoNo; } virtual void SetHistoNo(const PIntVector histoNo) { fHistoNo = histoNo; }
virtual void SetDetectorTag(const UInt_t detectorTag) { fDetectorTag = detectorTag; } virtual void SetDetectorTag(const UInt_t detectorTag) { fDetectorTag = detectorTag; }
virtual void SetCmdTag(const UInt_t cmdTag) { fCmdTag = cmdTag; } virtual void SetCmdTag(const UInt_t cmdTag) { fCmdTag = cmdTag; }
virtual void SetT0(UInt_t val, UInt_t idx); virtual void SetT0Bin(UInt_t val, UInt_t idx);
virtual void SetAddT0(UInt_t val, UInt_t addRunIdx, UInt_t idx); virtual void SetAddT0Bin(UInt_t val, UInt_t addRunIdx, UInt_t idx);
virtual void SetT0Data(UInt_t val) { fT0Data = val; } virtual void SetT0BinData(UInt_t val) { fT0Data = val; }
private: private:
Bool_t fSingleHisto; ///< true if single histo fit, false for asymmetry fit 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 fRunNo; ///< msr-file run number
Int_t fAddRunIdx; ///< msr-file addrun index Int_t fAddRunIdx; ///< msr-file addrun index
Int_t fHistoNoIdx; ///< msr-file histo number 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 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 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 PIntVector fT0; ///< holding the t0's of the run

View File

@ -10,7 +10,7 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.ch * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * This program is free software; you can redistribute it and/or modify *

View File

@ -10,8 +10,8 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.c * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * 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 * * it under the terms of the GNU General Public License as published by *

View File

@ -10,7 +10,7 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.ch * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * 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 PRunData fData; ///< data to be fitted, viewed, i.e. binned data
Double_t fTimeResolution; ///< time resolution in (us) 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 fFitStartTime; ///< fit start time
Double_t fFitEndTime; ///< fit end time Double_t fFitEndTime; ///< fit end time

View File

@ -10,7 +10,7 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.ch * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * 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 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 Bool_t fAllDataAvailable; ///< flag indicating if all data sets could be read
TString fRunName; ///< current run name TString fRunName; ///< current run name
TString fRunPathName; ///< current path file name TString fRunPathName; ///< current path file name
PRawRunDataList fData; ///< keeping all the raw data PRawRunDataList fData; ///< keeping all the raw data
virtual Bool_t ReadFilesMsr(); virtual Bool_t ReadFilesMsr();
@ -71,7 +71,7 @@ class PRunDataHandler
virtual void TestFileName(TString &runName, const TString &ext); virtual void TestFileName(TString &runName, const TString &ext);
virtual Bool_t FileExistsCheck(PMsrRunBlock &runInfo, const UInt_t idx); 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 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 ReadNexusFile();
virtual Bool_t ReadWkmFile(); virtual Bool_t ReadWkmFile();
virtual Bool_t ReadPsiBinFile(); virtual Bool_t ReadPsiBinFile();
@ -80,6 +80,7 @@ class PRunDataHandler
virtual Bool_t ReadAsciiFile(); virtual Bool_t ReadAsciiFile();
virtual Bool_t ReadDBFile(); virtual Bool_t ReadDBFile();
virtual Bool_t WriteMusrRootFile(TString fln="");
virtual Bool_t WriteRootFile(TString fln=""); virtual Bool_t WriteRootFile(TString fln="");
virtual Bool_t WriteNexusFile(TString fln=""); virtual Bool_t WriteNexusFile(TString fln="");
virtual Bool_t WriteWkmFile(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 TString FileNameFromTemplate(TString &fileNameTemplate, Int_t run, TString &year, Bool_t &ok);
virtual bool DateToISO8601(string inDate, string &iso8601Date); virtual bool DateToISO8601(string inDate, string &iso8601Date);
virtual void SplitTimeDate(TString timeDate, TString &time, TString &date, Bool_t &ok); 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_ #endif // _PRUNDATAHANDLER_H_

View File

@ -10,8 +10,8 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.c * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * 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 * * it under the terms of the GNU General Public License as published by *

View File

@ -10,8 +10,8 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.c * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * 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 * * it under the terms of the GNU General Public License as published by *

View File

@ -10,8 +10,8 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.c * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * 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 * * it under the terms of the GNU General Public License as published by *

View File

@ -10,8 +10,8 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.c * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * 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 * * 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 UInt_t fNoOfFitBins; ///< number of bins to be fitted
Double_t fBackground; ///< needed if background range is given (units: 1/bin) 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 EstimateBkg(UInt_t histoNo);
virtual Bool_t IsScaleN0AndBkg(); virtual Bool_t IsScaleN0AndBkg();
}; };

View File

@ -10,8 +10,8 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.c * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * 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 * * it under the terms of the GNU General Public License as published by *

View File

@ -10,8 +10,8 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.c * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * 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 * * it under the terms of the GNU General Public License as published by *

View File

@ -10,8 +10,8 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.c * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * 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 * * it under the terms of the GNU General Public License as published by *

View File

@ -10,8 +10,8 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.c * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * 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 * * it under the terms of the GNU General Public License as published by *

View File

@ -10,8 +10,8 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.c * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * 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 * * it under the terms of the GNU General Public License as published by *

View File

@ -10,8 +10,8 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.c * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * 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 * * it under the terms of the GNU General Public License as published by *

View File

@ -79,6 +79,7 @@ bool isNumber(const string &s)
*/ */
void msr2data_syntax() void msr2data_syntax()
{ {
cout << endl << "usage 0: msr2data [--version] | [--help]";
cout << endl << "usage 1: msr2data <run> <extension> [-o<outputfile>] [new] [data] [[no]header] [nosummary] [global[+[!]]]"; cout << endl << "usage 1: msr2data <run> <extension> [-o<outputfile>] [new] [data] [[no]header] [nosummary] [global[+[!]]]";
cout << endl << " [fit [-k] [-t] | fit-<template>[!] [-k] [-t] | msr-<template>]"; cout << endl << " [fit [-k] [-t] | fit-<template>[!] [-k] [-t] | msr-<template>]";
cout << endl << "usage 2: msr2data <run1> <run2> <extension> [-o<outputfile>] [new] [data] [[no]header] [nosummary] [global[+[!]]]"; cout << endl << "usage 2: msr2data <run1> <run2> <extension> [-o<outputfile>] [new] [data] [[no]header] [nosummary] [global[+[!]]]";
@ -379,8 +380,22 @@ int msr2data_doInputCreation(vector<string> &arg, bool &inputOnly)
*/ */
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
// check if version dump is wanted
if (argc == 2) {
if (!strcmp(argv[1], "--help")) {
msr2data_syntax();
return 0;
} else if (!strcmp(argv[1], "--version")) {
cout << endl << "msr2data version: " << PMUSR_VERSION << " / $Id$" << endl << endl;
return 0;
} else {
msr2data_syntax();
return 0;
}
}
// check the number of arguments // check the number of arguments
if (argc < 3) { if (argc < 2) {
msr2data_syntax(); msr2data_syntax();
return 0; return 0;
} }

View File

@ -364,7 +364,7 @@ int main(int argc, char *argv[])
if (argc == 2) { if (argc == 2) {
if (!strcmp(argv[1], "--version")) { if (!strcmp(argv[1], "--version")) {
cout << endl << "musrfit version: $Id$"; cout << endl << "musrfit version: " << PMUSR_VERSION << " / $Id$";
cout << endl << endl; cout << endl << endl;
return PMUSR_SUCCESS; return PMUSR_SUCCESS;
} }

View File

@ -1,217 +0,0 @@
/***************************************************************************
musrparam.cpp
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
$Id$
***************************************************************************/
/***************************************************************************
* Copyright (C) 2008 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
#include <TString.h>
#include <TObjArray.h>
#include <TObjString.h>
//--------------------------------------------------------------------------
/**
* <p>Sends the usage description to the standard output.
*/
void musrparam_syntax()
{
cout << endl << "usage: musrparam <input-filename> <output-filename>";
cout << endl << " <input-filename>: file name of the control file to extract the parameters.";
cout << endl << " It has the following structure:";
cout << endl << " msr-file-name-1, independent-var1-1, independent-var2-1";
cout << endl << " msr-file-name-2, independent-var1-2, independent-var2-2";
cout << endl << " etc.";
cout << endl << " It is allowed to add comment lines which start with '%'";
cout << endl;
cout << endl << " <output-filename>: file name of the generated output file";
cout << endl << " The output will have the structure:";
cout << endl << " msr-file-name-1, independent-var1-1, ..., par1, err_par1, par2, err_par2, par3, err_par3, ... ";
cout << endl << " msr-file-name-2, independent-var1-2, ..., par1, err_par1, par2, err_par2, par3, err_par3, ... ";
cout << endl << " etc.";
cout << endl << " If positive and negative errors are present, it will be par1, err_par1-, err_par1+, etc.";
cout << endl << endl;
}
//--------------------------------------------------------------------------
/**
* <p>Used to extract fit parameters from msr-files. msr2data is much more flexible and not much effort
* will go into supporting musrparam anymore (only bug fixing).
*
* <b>return:</b>
* - 0 if everything went smooth
* - negative number otherwise
*
* \param argc number of arguments
* \param argv list of arguments
*/
int main(int argc, char *argv[])
{
if (argc != 3) {
musrparam_syntax();
return -1;
}
TString inputFln(argv[1]);
TString outputFln(argv[2]);
vector<TString> param;
// open input file for read
ifstream fin;
fin.open(inputFln.Data(), iostream::in);
if (!fin.is_open()) {
cout << endl << "**ERROR** Couldn't open input file " << inputFln.Data() << " will quit.";
cout << endl << endl;
return -1;
}
// read file
int lineNo = 0;
char str[256];
TString tstr;
TString paramStr;
TObjArray *tokens;
TObjString *ostr;
ifstream fmsr;
while (!fin.eof()) {
// read a line
fin.getline(str, sizeof(str));
lineNo++;
// check if only a comment or empty line
if ((str[0] == '%') || strlen(str) == 0)
continue;
// tokenize string
tstr = TString(str);
tokens = tstr.Tokenize(" ,;\t");
// keep msr-file name and temperature
paramStr = TString(str) + TString(", ");
// open msr-file
ostr = dynamic_cast<TObjString*>(tokens->At(0));
fmsr.open(ostr->GetString().Data(), iostream::in);
if (!fmsr.is_open()) {
cout << endl << "**ERROR** Couldn't open msr file " << ostr->GetString().Data() << " will quit.";
cout << endl << endl;
fin.close();
return -1;
}
// read msr-file relevant parts
bool fitParamFound = false;
bool done = false;
TString msrLine;
TObjArray *msrTokens;
TObjString *msrOstr;
while (!fmsr.eof() && !done) {
// read a line
fmsr.getline(str, sizeof(str));
msrLine = TString(str);
if (msrLine.Contains("FITPARAMETER")) {
fitParamFound = true;
continue;
}
if (fitParamFound) {
if (msrLine.BeginsWith("#")) // comment
continue;
if (msrLine.IsWhitespace()) { // end if FTIPARAMETER block
done = true;
continue;
}
// get parameters and errors
msrTokens = msrLine.Tokenize(" \t");
if (msrTokens->GetEntries() < 4) { // not enough tokens: no name value error
cout << endl << "**ERROR** Found " << tokens->GetEntries() << " tokens only (in " << ostr->GetString().Data() << "), will quit.";
cout << endl << endl;
fmsr.close();
fin.close();
return -1;
}
// keep parameter value
msrOstr = dynamic_cast<TObjString*>(msrTokens->At(2));
paramStr += msrOstr->GetString();
paramStr += TString(", ");
// keep parameter error/neg. error
msrOstr = dynamic_cast<TObjString*>(msrTokens->At(3));
paramStr += msrOstr->GetString();
paramStr += TString(", ");
if (msrTokens->GetEntries() >= 5) { // check for positive errors
msrOstr = dynamic_cast<TObjString*>(msrTokens->At(4));
if (msrOstr->GetString().IsFloat()) {
paramStr += msrOstr->GetString();
paramStr += TString(", ");
}
}
// clean up
if (msrTokens) {
delete msrTokens;
msrTokens = 0;
}
}
}
fmsr.close();
paramStr.Remove(TString::kTrailing, ' ');
paramStr.Remove(TString::kTrailing, ',');
param.push_back(paramStr);
// clean up
if (tokens) {
delete tokens;
tokens = 0;
}
}
fin.close();
// open output file for write
ofstream fout;
fout.open(outputFln.Data(), iostream::out);
if (!fout.is_open()) {
cout << endl << "**ERROR** Couldn't open output file " << outputFln.Data() << " will quit.";
cout << endl << endl;
return -1;
}
for (UInt_t i=0; i<param.size(); i++) {
fout << param[i] << endl;
}
fout.close();
// clean up
param.clear();
return 0;
}

View File

@ -10,7 +10,7 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007 by Andreas Suter * * Copyright (C) 2007-2012 by Andreas Suter *
* andreas.suter@psi.ch * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * This program is free software; you can redistribute it and/or modify *
@ -214,7 +214,7 @@ Int_t main(Int_t argc, Char_t *argv[])
break; break;
case 2: case 2:
if (strstr(argv[1], "--version")) { if (strstr(argv[1], "--version")) {
cout << endl << ">> musrt0 version: $Id$"; cout << endl << ">> musrt0 version: " << PMUSR_VERSION << " / $Id$";
cout << endl << endl; cout << endl << endl;
return PMUSR_SUCCESS; return PMUSR_SUCCESS;
} else if (strstr(argv[1], "--help")) { } else if (strstr(argv[1], "--help")) {
@ -369,12 +369,12 @@ Int_t main(Int_t argc, Char_t *argv[])
case MSR_FITTYPE_SINGLE_HISTO: case MSR_FITTYPE_SINGLE_HISTO:
if ((runList->at(i).GetRunNameSize() == 1) && (runList->at(i).GetForwardHistoNoSize() == 1)) { // no addruns / no grouping if ((runList->at(i).GetRunNameSize() == 1) && (runList->at(i).GetForwardHistoNoSize() == 1)) { // no addruns / no grouping
// get histo number // get histo number
histoNo = runList->at(i).GetForwardHistoNo()-1; histoNo = runList->at(i).GetForwardHistoNo();
runName = runList->at(i).GetRunName(); runName = runList->at(i).GetRunName();
// get bin position of maximal data // get bin position of maximal data
t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo)); t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo));
// set t0 to maximum data position // set t0 to maximum data position
runList->at(i).SetT0(t0Bin, 0); runList->at(i).SetT0Bin(t0Bin, 0);
// set data range as well if firstGoodBinOffset is given // set data range as well if firstGoodBinOffset is given
if (firstGoodBinOffsetPresent) { if (firstGoodBinOffsetPresent) {
start = t0Bin + firstGoodBinOffset; start = t0Bin + firstGoodBinOffset;
@ -384,12 +384,12 @@ Int_t main(Int_t argc, Char_t *argv[])
} }
} else if ((runList->at(i).GetRunNameSize() > 1) && (runList->at(i).GetForwardHistoNoSize() == 1)) { // addruns / no grouping } else if ((runList->at(i).GetRunNameSize() > 1) && (runList->at(i).GetForwardHistoNoSize() == 1)) { // addruns / no grouping
// get histo number // get histo number
histoNo = runList->at(i).GetForwardHistoNo()-1; histoNo = runList->at(i).GetForwardHistoNo();
runName = runList->at(i).GetRunName(); runName = runList->at(i).GetRunName();
// get bin position of maximal data // get bin position of maximal data
t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo)); t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo));
// set t0 to maximum data position // set t0 to maximum data position
runList->at(i).SetT0(t0Bin, 0); runList->at(i).SetT0Bin(t0Bin, 0);
// set data range as well if firstGoodBinOffset is given // set data range as well if firstGoodBinOffset is given
if (firstGoodBinOffsetPresent) { if (firstGoodBinOffsetPresent) {
start = t0Bin + firstGoodBinOffset; start = t0Bin + firstGoodBinOffset;
@ -403,17 +403,17 @@ Int_t main(Int_t argc, Char_t *argv[])
// get bin position of maximal data // get bin position of maximal data
t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo)); t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo));
// set t0 to maximum data position // set t0 to maximum data position
runList->at(i).SetAddT0(t0Bin, j-1, 0); runList->at(i).SetAddT0Bin(t0Bin, j-1, 0);
} }
} else if ((runList->at(i).GetRunNameSize() == 1) && (runList->at(i).GetForwardHistoNoSize() > 1)) { // no addruns / grouping } else if ((runList->at(i).GetRunNameSize() == 1) && (runList->at(i).GetForwardHistoNoSize() > 1)) { // no addruns / grouping
for (UInt_t j=0; j<runList->at(i).GetForwardHistoNoSize(); j++) { for (UInt_t j=0; j<runList->at(i).GetForwardHistoNoSize(); j++) {
// get histo number // get histo number
histoNo = runList->at(i).GetForwardHistoNo(j)-1; histoNo = runList->at(i).GetForwardHistoNo(j);
runName = runList->at(i).GetRunName(); runName = runList->at(i).GetRunName();
// get bin position of maximal data // get bin position of maximal data
t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo)); t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo));
// set t0 to maximum data position // set t0 to maximum data position
runList->at(i).SetT0(t0Bin, j); runList->at(i).SetT0Bin(t0Bin, j);
if (firstGoodBinOffsetPresent && (j==0)) { if (firstGoodBinOffsetPresent && (j==0)) {
start = t0Bin + firstGoodBinOffset; start = t0Bin + firstGoodBinOffset;
end = dataHandler->GetRunData(*runName)->GetDataBin(histoNo)->size(); end = dataHandler->GetRunData(*runName)->GetDataBin(histoNo)->size();
@ -424,12 +424,12 @@ Int_t main(Int_t argc, Char_t *argv[])
} else { // addruns / grouping } else { // addruns / grouping
for (UInt_t j=0; j<runList->at(i).GetForwardHistoNoSize(); j++) { for (UInt_t j=0; j<runList->at(i).GetForwardHistoNoSize(); j++) {
// get histo number // get histo number
histoNo = runList->at(i).GetForwardHistoNo(j)-1; histoNo = runList->at(i).GetForwardHistoNo(j);
runName = runList->at(i).GetRunName(); runName = runList->at(i).GetRunName();
// get bin position of maximal data // get bin position of maximal data
t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo)); t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo));
// set t0 to maximum data position // set t0 to maximum data position
runList->at(i).SetT0(t0Bin, j); runList->at(i).SetT0Bin(t0Bin, j);
if (firstGoodBinOffsetPresent && (j==0)) { if (firstGoodBinOffsetPresent && (j==0)) {
start = t0Bin + firstGoodBinOffset; start = t0Bin + firstGoodBinOffset;
end = dataHandler->GetRunData(*runName)->GetDataBin(histoNo)->size(); end = dataHandler->GetRunData(*runName)->GetDataBin(histoNo)->size();
@ -442,7 +442,7 @@ Int_t main(Int_t argc, Char_t *argv[])
// get bin position of maximal data // get bin position of maximal data
t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo)); t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo));
// set t0 to maximum data position // set t0 to maximum data position
runList->at(i).SetAddT0(t0Bin, k-1, j); runList->at(i).SetAddT0Bin(t0Bin, k-1, j);
} }
} }
} }
@ -451,12 +451,12 @@ Int_t main(Int_t argc, Char_t *argv[])
if ((runList->at(i).GetRunNameSize() == 1) && (runList->at(i).GetForwardHistoNoSize() == 1)) { // no addruns / no grouping if ((runList->at(i).GetRunNameSize() == 1) && (runList->at(i).GetForwardHistoNoSize() == 1)) { // no addruns / no grouping
// handle forward histo // handle forward histo
// get histo number // get histo number
histoNo = runList->at(i).GetForwardHistoNo()-1; histoNo = runList->at(i).GetForwardHistoNo();
runName = runList->at(i).GetRunName(); runName = runList->at(i).GetRunName();
// get bin position of maximal data // get bin position of maximal data
t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo)); t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo));
// set t0 to maximum data position // set t0 to maximum data position
runList->at(i).SetT0(t0Bin, 0); runList->at(i).SetT0Bin(t0Bin, 0);
// set data range as well if firstGoodBinOffset is given // set data range as well if firstGoodBinOffset is given
if (firstGoodBinOffsetPresent) { if (firstGoodBinOffsetPresent) {
start = t0Bin + firstGoodBinOffset; start = t0Bin + firstGoodBinOffset;
@ -466,12 +466,12 @@ Int_t main(Int_t argc, Char_t *argv[])
} }
// handle backward histo // handle backward histo
// get histo number // get histo number
histoNo = runList->at(i).GetBackwardHistoNo()-1; histoNo = runList->at(i).GetBackwardHistoNo();
runName = runList->at(i).GetRunName(); runName = runList->at(i).GetRunName();
// get bin position of maximal data // get bin position of maximal data
t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo)); t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo));
// set t0 to maximum data position // set t0 to maximum data position
runList->at(i).SetT0(t0Bin, 1); runList->at(i).SetT0Bin(t0Bin, 1);
// set data range as well if firstGoodBinOffset is given // set data range as well if firstGoodBinOffset is given
if (firstGoodBinOffsetPresent) { if (firstGoodBinOffsetPresent) {
start = t0Bin + firstGoodBinOffset; start = t0Bin + firstGoodBinOffset;
@ -482,12 +482,12 @@ Int_t main(Int_t argc, Char_t *argv[])
} else if ((runList->at(i).GetRunNameSize() > 1) && (runList->at(i).GetForwardHistoNoSize() == 1)) { // addruns / no grouping } else if ((runList->at(i).GetRunNameSize() > 1) && (runList->at(i).GetForwardHistoNoSize() == 1)) { // addruns / no grouping
// handle forward histo // handle forward histo
// get histo number // get histo number
histoNo = runList->at(i).GetForwardHistoNo()-1; histoNo = runList->at(i).GetForwardHistoNo();
runName = runList->at(i).GetRunName(); runName = runList->at(i).GetRunName();
// get bin position of maximal data // get bin position of maximal data
t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo)); t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo));
// set t0 to maximum data position // set t0 to maximum data position
runList->at(i).SetT0(t0Bin, 0); runList->at(i).SetT0Bin(t0Bin, 0);
// set data range as well if firstGoodBinOffset is given // set data range as well if firstGoodBinOffset is given
if (firstGoodBinOffsetPresent) { if (firstGoodBinOffsetPresent) {
start = t0Bin + firstGoodBinOffset; start = t0Bin + firstGoodBinOffset;
@ -501,16 +501,16 @@ Int_t main(Int_t argc, Char_t *argv[])
// get bin position of maximal data // get bin position of maximal data
t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo)); t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo));
// set t0 to maximum data position // set t0 to maximum data position
runList->at(i).SetAddT0(t0Bin, j-1, 0); runList->at(i).SetAddT0Bin(t0Bin, j-1, 0);
} }
// handle backward histo // handle backward histo
// get histo number // get histo number
histoNo = runList->at(i).GetBackwardHistoNo()-1; histoNo = runList->at(i).GetBackwardHistoNo();
runName = runList->at(i).GetRunName(); runName = runList->at(i).GetRunName();
// get bin position of maximal data // get bin position of maximal data
t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo)); t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo));
// set t0 to maximum data position // set t0 to maximum data position
runList->at(i).SetT0(t0Bin, 1); runList->at(i).SetT0Bin(t0Bin, 1);
// set data range as well if firstGoodBinOffset is given // set data range as well if firstGoodBinOffset is given
if (firstGoodBinOffsetPresent) { if (firstGoodBinOffsetPresent) {
start = t0Bin + firstGoodBinOffset; start = t0Bin + firstGoodBinOffset;
@ -524,18 +524,18 @@ Int_t main(Int_t argc, Char_t *argv[])
// get bin position of maximal data // get bin position of maximal data
t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo)); t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo));
// set t0 to maximum data position // set t0 to maximum data position
runList->at(i).SetAddT0(t0Bin, j-1, 1); runList->at(i).SetAddT0Bin(t0Bin, j-1, 1);
} }
} else if ((runList->at(i).GetRunNameSize() == 1) && (runList->at(i).GetForwardHistoNoSize() > 1)) { // no addruns / grouping } else if ((runList->at(i).GetRunNameSize() == 1) && (runList->at(i).GetForwardHistoNoSize() > 1)) { // no addruns / grouping
// handle forward histo // handle forward histo
for (UInt_t j=0; j<runList->at(i).GetForwardHistoNoSize(); j++) { for (UInt_t j=0; j<runList->at(i).GetForwardHistoNoSize(); j++) {
// get histo number // get histo number
histoNo = runList->at(i).GetForwardHistoNo(j)-1; histoNo = runList->at(i).GetForwardHistoNo(j);
runName = runList->at(i).GetRunName(); runName = runList->at(i).GetRunName();
// get bin position of maximal data // get bin position of maximal data
t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo)); t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo));
// set t0 to maximum data position // set t0 to maximum data position
runList->at(i).SetT0(t0Bin, 2*j); runList->at(i).SetT0Bin(t0Bin, 2*j);
if (firstGoodBinOffsetPresent && (j==0)) { if (firstGoodBinOffsetPresent && (j==0)) {
start = t0Bin + firstGoodBinOffset; start = t0Bin + firstGoodBinOffset;
end = dataHandler->GetRunData(*runName)->GetDataBin(histoNo)->size(); end = dataHandler->GetRunData(*runName)->GetDataBin(histoNo)->size();
@ -546,12 +546,12 @@ Int_t main(Int_t argc, Char_t *argv[])
// handle backward histo // handle backward histo
for (UInt_t j=0; j<runList->at(i).GetBackwardHistoNoSize(); j++) { for (UInt_t j=0; j<runList->at(i).GetBackwardHistoNoSize(); j++) {
// get histo number // get histo number
histoNo = runList->at(i).GetBackwardHistoNo(j)-1; histoNo = runList->at(i).GetBackwardHistoNo(j);
runName = runList->at(i).GetRunName(); runName = runList->at(i).GetRunName();
// get bin position of maximal data // get bin position of maximal data
t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo)); t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo));
// set t0 to maximum data position // set t0 to maximum data position
runList->at(i).SetT0(t0Bin, 2*j+1); runList->at(i).SetT0Bin(t0Bin, 2*j+1);
if (firstGoodBinOffsetPresent && (j==0)) { if (firstGoodBinOffsetPresent && (j==0)) {
start = t0Bin + firstGoodBinOffset; start = t0Bin + firstGoodBinOffset;
end = dataHandler->GetRunData(*runName)->GetDataBin(histoNo)->size(); end = dataHandler->GetRunData(*runName)->GetDataBin(histoNo)->size();
@ -563,12 +563,12 @@ Int_t main(Int_t argc, Char_t *argv[])
// handle forward histo // handle forward histo
for (UInt_t j=0; j<runList->at(i).GetForwardHistoNoSize(); j++) { for (UInt_t j=0; j<runList->at(i).GetForwardHistoNoSize(); j++) {
// get histo number // get histo number
histoNo = runList->at(i).GetForwardHistoNo(j)-1; histoNo = runList->at(i).GetForwardHistoNo(j);
runName = runList->at(i).GetRunName(); runName = runList->at(i).GetRunName();
// get bin position of maximal data // get bin position of maximal data
t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo)); t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo));
// set t0 to maximum data position // set t0 to maximum data position
runList->at(i).SetT0(t0Bin, 2*j); runList->at(i).SetT0Bin(t0Bin, 2*j);
if (firstGoodBinOffsetPresent && (j==0)) { if (firstGoodBinOffsetPresent && (j==0)) {
start = t0Bin + firstGoodBinOffset; start = t0Bin + firstGoodBinOffset;
end = dataHandler->GetRunData(*runName)->GetDataBin(histoNo)->size(); end = dataHandler->GetRunData(*runName)->GetDataBin(histoNo)->size();
@ -581,18 +581,18 @@ Int_t main(Int_t argc, Char_t *argv[])
// get bin position of maximal data // get bin position of maximal data
t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo)); t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo));
// set t0 to maximum data position // set t0 to maximum data position
runList->at(i).SetAddT0(t0Bin, k-1, 2*j); runList->at(i).SetAddT0Bin(t0Bin, k-1, 2*j);
} }
} }
// handle backward histo // handle backward histo
for (UInt_t j=0; j<runList->at(i).GetBackwardHistoNoSize(); j++) { for (UInt_t j=0; j<runList->at(i).GetBackwardHistoNoSize(); j++) {
// get histo number // get histo number
histoNo = runList->at(i).GetBackwardHistoNo(j)-1; histoNo = runList->at(i).GetBackwardHistoNo(j);
runName = runList->at(i).GetRunName(); runName = runList->at(i).GetRunName();
// get bin position of maximal data // get bin position of maximal data
t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo)); t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo));
// set t0 to maximum data position // set t0 to maximum data position
runList->at(i).SetT0(t0Bin, 2*j+1); runList->at(i).SetT0Bin(t0Bin, 2*j+1);
if (firstGoodBinOffsetPresent && (j==0)) { if (firstGoodBinOffsetPresent && (j==0)) {
start = t0Bin + firstGoodBinOffset; start = t0Bin + firstGoodBinOffset;
end = dataHandler->GetRunData(*runName)->GetDataBin(histoNo)->size(); end = dataHandler->GetRunData(*runName)->GetDataBin(histoNo)->size();
@ -605,7 +605,7 @@ Int_t main(Int_t argc, Char_t *argv[])
// get bin position of maximal data // get bin position of maximal data
t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo)); t0Bin = musrt0_getMaxBin(dataHandler->GetRunData(*runName)->GetDataBin(histoNo));
// set t0 to maximum data position // set t0 to maximum data position
runList->at(i).SetAddT0(t0Bin, k-1, 2*j+1); runList->at(i).SetAddT0Bin(t0Bin, k-1, 2*j+1);
} }
} }
} }
@ -648,8 +648,8 @@ Int_t main(Int_t argc, Char_t *argv[])
rawRunData.push_back(dataHandler->GetRunData(*(runList->at(i).GetRunName(0)))); rawRunData.push_back(dataHandler->GetRunData(*(runList->at(i).GetRunName(0))));
musrT0Data.SetRawRunData(rawRunData); musrT0Data.SetRawRunData(rawRunData);
// feed data t0 if present // feed data t0 if present
if (rawRunData[0]->GetT0Size() > 0) { if (rawRunData[0]->IsPresent(runList->at(i).GetForwardHistoNo(0))) {
musrT0Data.SetT0Data(rawRunData[0]->GetT0(runList->at(i).GetForwardHistoNo(0)-1)); musrT0Data.SetT0BinData(rawRunData[0]->GetT0Bin(runList->at(i).GetForwardHistoNo(0)));
} }
musrT0Data.SetRunNo(i); musrT0Data.SetRunNo(i);
musrT0Data.SetAddRunIdx(0); // no addruns musrT0Data.SetAddRunIdx(0); // no addruns
@ -682,8 +682,8 @@ Int_t main(Int_t argc, Char_t *argv[])
musrT0Data.SetRawRunData(rawRunData); musrT0Data.SetRawRunData(rawRunData);
for (UInt_t j=0; j<runList->at(i).GetRunNameSize(); j++) { for (UInt_t j=0; j<runList->at(i).GetRunNameSize(); j++) {
// feed data t0 if present // feed data t0 if present
if (rawRunData[j]->GetT0Size() > 0) { if (rawRunData[j]->IsPresent(runList->at(i).GetForwardHistoNo(0))) {
musrT0Data.SetT0Data(rawRunData[j]->GetT0(runList->at(i).GetForwardHistoNo(0)-1)); musrT0Data.SetT0BinData(rawRunData[j]->GetT0Bin(runList->at(i).GetForwardHistoNo(0)));
} }
// feed necessary data // feed necessary data
musrT0Data.SetAddRunIdx(j); // addruns musrT0Data.SetAddRunIdx(j); // addruns
@ -709,8 +709,8 @@ Int_t main(Int_t argc, Char_t *argv[])
musrT0Data.SetAddRunIdx(0); musrT0Data.SetAddRunIdx(0);
for (UInt_t j=0; j<runList->at(i).GetForwardHistoNoSize(); j++) { for (UInt_t j=0; j<runList->at(i).GetForwardHistoNoSize(); j++) {
// feed data t0 if present // feed data t0 if present
if (rawRunData[0]->GetT0Size() > 0) { if (rawRunData[0]->IsPresent(runList->at(i).GetForwardHistoNo(j))) {
musrT0Data.SetT0Data(rawRunData[0]->GetT0(runList->at(i).GetForwardHistoNo(j)-1)); musrT0Data.SetT0BinData(rawRunData[0]->GetT0Bin(runList->at(i).GetForwardHistoNo(j)));
} }
// feed necessary data // feed necessary data
musrT0Data.SetHistoNoIdx(j); musrT0Data.SetHistoNoIdx(j);
@ -738,8 +738,8 @@ Int_t main(Int_t argc, Char_t *argv[])
musrT0Data.SetAddRunIdx(j); // addruns musrT0Data.SetAddRunIdx(j); // addruns
for (UInt_t k=0; k<runList->at(i).GetForwardHistoNoSize(); k++) { // forward histo grouping for (UInt_t k=0; k<runList->at(i).GetForwardHistoNoSize(); k++) { // forward histo grouping
// feed data t0 if present // feed data t0 if present
if (rawRunData[j]->GetT0Size() > 0) { if (rawRunData[j]->IsPresent(runList->at(i).GetForwardHistoNo(k))) {
musrT0Data.SetT0Data(rawRunData[j]->GetT0(runList->at(i).GetForwardHistoNo(k)-1)); musrT0Data.SetT0BinData(rawRunData[j]->GetT0Bin(runList->at(i).GetForwardHistoNo(k)));
} }
// feed necessary data // feed necessary data
musrT0Data.SetHistoNoIdx(k); musrT0Data.SetHistoNoIdx(k);
@ -753,10 +753,10 @@ Int_t main(Int_t argc, Char_t *argv[])
// get data- and bkg-range // get data- and bkg-range
musrT0Data.SetCmdTag(PMUSRT0_GET_DATA_AND_BKG_RANGE); musrT0Data.SetCmdTag(PMUSRT0_GET_DATA_AND_BKG_RANGE);
// feed all t0's // feed all t0's
for (UInt_t j=0; j<runList->at(i).GetT0Size(); j++) { for (UInt_t j=0; j<runList->at(i).GetT0BinSize(); j++) {
musrT0Data.SetT0(runList->at(i).GetT0(j), j); musrT0Data.SetT0Bin(runList->at(i).GetT0Bin(j), j);
for (UInt_t k=0; k<runList->at(i).GetAddT0Entries(); k++) { for (UInt_t k=0; k<runList->at(i).GetAddT0BinEntries(); k++) {
musrT0Data.SetAddT0(runList->at(i).GetAddT0(k, j), k, j); musrT0Data.SetAddT0Bin(runList->at(i).GetAddT0Bin(k, j), k, j);
} }
} }
if (!musrt0_item(app, msrHandler, musrT0Data, 0)) { if (!musrt0_item(app, msrHandler, musrT0Data, 0)) {
@ -774,8 +774,8 @@ Int_t main(Int_t argc, Char_t *argv[])
rawRunData.push_back(dataHandler->GetRunData(*(runList->at(i).GetRunName(0)))); rawRunData.push_back(dataHandler->GetRunData(*(runList->at(i).GetRunName(0))));
musrT0Data.SetRawRunData(rawRunData); musrT0Data.SetRawRunData(rawRunData);
// feed data t0 if present // feed data t0 if present
if (rawRunData[0]->GetT0Size() > 0) { if (rawRunData[0]->IsPresent(runList->at(i).GetForwardHistoNo(0))) {
musrT0Data.SetT0Data(rawRunData[0]->GetT0(runList->at(i).GetForwardHistoNo(0)-1)); musrT0Data.SetT0BinData(rawRunData[0]->GetT0Bin(runList->at(i).GetForwardHistoNo(0)));
} }
musrT0Data.SetRunNo(i); musrT0Data.SetRunNo(i);
musrT0Data.SetAddRunIdx(0); // no addruns musrT0Data.SetAddRunIdx(0); // no addruns
@ -797,8 +797,8 @@ Int_t main(Int_t argc, Char_t *argv[])
rawRunData.push_back(dataHandler->GetRunData(*(runList->at(i).GetRunName(0)))); rawRunData.push_back(dataHandler->GetRunData(*(runList->at(i).GetRunName(0))));
musrT0Data.SetRawRunData(rawRunData); musrT0Data.SetRawRunData(rawRunData);
// feed data t0 if present // feed data t0 if present
if (rawRunData[0]->GetT0Size() > 0) { if (rawRunData[0]->IsPresent(runList->at(i).GetForwardHistoNo(0))) {
musrT0Data.SetT0Data(rawRunData[0]->GetT0(runList->at(i).GetBackwardHistoNo(0)-1)); musrT0Data.SetT0BinData(rawRunData[0]->GetT0Bin(runList->at(i).GetForwardHistoNo(0)));
} }
musrT0Data.SetRunNo(i); musrT0Data.SetRunNo(i);
musrT0Data.SetAddRunIdx(0); // no addruns musrT0Data.SetAddRunIdx(0); // no addruns
@ -832,8 +832,8 @@ Int_t main(Int_t argc, Char_t *argv[])
musrT0Data.SetRawRunData(rawRunData); musrT0Data.SetRawRunData(rawRunData);
for (UInt_t j=0; j<runList->at(i).GetRunNameSize(); j++) { for (UInt_t j=0; j<runList->at(i).GetRunNameSize(); j++) {
// feed data t0 if present // feed data t0 if present
if (rawRunData[j]->GetT0Size() > 0) { if (rawRunData[j]->IsPresent(runList->at(i).GetForwardHistoNo(0))) {
musrT0Data.SetT0Data(rawRunData[j]->GetT0(runList->at(i).GetForwardHistoNo(0)-1)); musrT0Data.SetT0BinData(rawRunData[j]->GetT0Bin(runList->at(i).GetForwardHistoNo(0)));
} }
// feed necessary data // feed necessary data
musrT0Data.SetAddRunIdx(j); // addruns musrT0Data.SetAddRunIdx(j); // addruns
@ -858,8 +858,8 @@ Int_t main(Int_t argc, Char_t *argv[])
musrT0Data.SetRawRunData(rawRunData); musrT0Data.SetRawRunData(rawRunData);
for (UInt_t j=0; j<runList->at(i).GetRunNameSize(); j++) { for (UInt_t j=0; j<runList->at(i).GetRunNameSize(); j++) {
// feed data t0 if present // feed data t0 if present
if (rawRunData[j]->GetT0Size() > 0) { if (rawRunData[j]->IsPresent(runList->at(i).GetForwardHistoNo(0))) {
musrT0Data.SetT0Data(rawRunData[j]->GetT0(runList->at(i).GetBackwardHistoNo(0)-1)); musrT0Data.SetT0BinData(rawRunData[j]->GetT0Bin(runList->at(i).GetForwardHistoNo(0)));
} }
// feed necessary data // feed necessary data
musrT0Data.SetAddRunIdx(j); // addruns musrT0Data.SetAddRunIdx(j); // addruns
@ -885,8 +885,8 @@ Int_t main(Int_t argc, Char_t *argv[])
musrT0Data.SetAddRunIdx(0); musrT0Data.SetAddRunIdx(0);
for (UInt_t j=0; j<runList->at(i).GetForwardHistoNoSize(); j++) { for (UInt_t j=0; j<runList->at(i).GetForwardHistoNoSize(); j++) {
// feed data t0 if present // feed data t0 if present
if (rawRunData[0]->GetT0Size() > 0) { if (rawRunData[0]->IsPresent(runList->at(i).GetForwardHistoNo(j))) {
musrT0Data.SetT0Data(rawRunData[0]->GetT0(runList->at(i).GetForwardHistoNo(j)-1)); musrT0Data.SetT0BinData(rawRunData[0]->GetT0Bin(runList->at(i).GetForwardHistoNo(j)));
} }
// feed necessary data // feed necessary data
musrT0Data.SetHistoNoIdx(j); musrT0Data.SetHistoNoIdx(j);
@ -911,8 +911,8 @@ Int_t main(Int_t argc, Char_t *argv[])
musrT0Data.SetAddRunIdx(0); musrT0Data.SetAddRunIdx(0);
for (UInt_t j=0; j<runList->at(i).GetBackwardHistoNoSize(); j++) { for (UInt_t j=0; j<runList->at(i).GetBackwardHistoNoSize(); j++) {
// feed data t0 if present // feed data t0 if present
if (rawRunData[0]->GetT0Size() > 0) { if (rawRunData[0]->IsPresent(runList->at(i).GetForwardHistoNo(j))) {
musrT0Data.SetT0Data(rawRunData[0]->GetT0(runList->at(i).GetBackwardHistoNo(j)-1)); musrT0Data.SetT0BinData(rawRunData[0]->GetT0Bin(runList->at(i).GetForwardHistoNo(j)));
} }
// feed necessary data // feed necessary data
musrT0Data.SetHistoNoIdx(j); musrT0Data.SetHistoNoIdx(j);
@ -940,8 +940,8 @@ Int_t main(Int_t argc, Char_t *argv[])
musrT0Data.SetAddRunIdx(j); // addruns musrT0Data.SetAddRunIdx(j); // addruns
for (UInt_t k=0; k<runList->at(i).GetForwardHistoNoSize(); k++) { // forward histo grouping for (UInt_t k=0; k<runList->at(i).GetForwardHistoNoSize(); k++) { // forward histo grouping
// feed data t0 if present // feed data t0 if present
if (rawRunData[j]->GetT0Size() > 0) { if (rawRunData[j]->IsPresent(runList->at(i).GetForwardHistoNo(k))) {
musrT0Data.SetT0Data(rawRunData[j]->GetT0(runList->at(i).GetForwardHistoNo(k)-1)); musrT0Data.SetT0BinData(rawRunData[j]->GetT0Bin(runList->at(i).GetForwardHistoNo(k)));
} }
// feed necessary data // feed necessary data
musrT0Data.SetHistoNoIdx(k); musrT0Data.SetHistoNoIdx(k);
@ -969,8 +969,8 @@ Int_t main(Int_t argc, Char_t *argv[])
musrT0Data.SetAddRunIdx(j); // addruns musrT0Data.SetAddRunIdx(j); // addruns
for (UInt_t k=0; k<runList->at(i).GetBackwardHistoNoSize(); k++) { // backward histo grouping for (UInt_t k=0; k<runList->at(i).GetBackwardHistoNoSize(); k++) { // backward histo grouping
// feed data t0 if present // feed data t0 if present
if (rawRunData[j]->GetT0Size() > 0) { if (rawRunData[j]->IsPresent(runList->at(i).GetForwardHistoNo(k))) {
musrT0Data.SetT0Data(rawRunData[j]->GetT0(runList->at(i).GetBackwardHistoNo(k)-1)); musrT0Data.SetT0BinData(rawRunData[j]->GetT0Bin(runList->at(i).GetForwardHistoNo(k)));
} }
// feed necessary data // feed necessary data
musrT0Data.SetHistoNoIdx(k); musrT0Data.SetHistoNoIdx(k);
@ -984,10 +984,10 @@ Int_t main(Int_t argc, Char_t *argv[])
// get data- and bkg-range // get data- and bkg-range
musrT0Data.SetCmdTag(PMUSRT0_GET_DATA_AND_BKG_RANGE); musrT0Data.SetCmdTag(PMUSRT0_GET_DATA_AND_BKG_RANGE);
// feed all t0's // feed all t0's
for (UInt_t j=0; j<runList->at(i).GetT0Size(); j++) { for (UInt_t j=0; j<runList->at(i).GetT0BinSize(); j++) {
musrT0Data.SetT0(runList->at(i).GetT0(j), j); musrT0Data.SetT0Bin(runList->at(i).GetT0Bin(j), j);
for (UInt_t k=0; k<runList->at(i).GetAddT0Entries(); k++) { for (UInt_t k=0; k<runList->at(i).GetAddT0BinEntries(); k++) {
musrT0Data.SetAddT0(runList->at(i).GetAddT0(k, j), k, j); musrT0Data.SetAddT0Bin(runList->at(i).GetAddT0Bin(k, j), k, j);
} }
} }
musrT0Data.SetHistoNo(forwardHistos); musrT0Data.SetHistoNo(forwardHistos);

View File

@ -104,7 +104,7 @@ int main(int argc, char *argv[])
break; break;
case 2: case 2:
if (strstr(argv[1], "--version")) { if (strstr(argv[1], "--version")) {
cout << endl << "musrview version: $Id$"; cout << endl << "musrview version: " << PMUSR_VERSION << " / $Id$";
cout << endl << endl; cout << endl << endl;
return PMUSR_SUCCESS; return PMUSR_SUCCESS;
} else if (strstr(argv[1], "--help")) { } else if (strstr(argv[1], "--help")) {

View File

@ -5,7 +5,7 @@
Author: Andreas Suter Author: Andreas Suter
e-mail: andreas.suter@psi.ch e-mail: andreas.suter@psi.ch
$Id: nexus_read_test.cpp 4981 2011-08-23 17:22:29Z nemu $ $Id$
***************************************************************************/ ***************************************************************************/
@ -38,6 +38,7 @@
#include <vector> #include <vector>
using namespace std; using namespace std;
#include "PMusr.h"
#include "PNeXus.h" #include "PNeXus.h"
//--------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------
@ -45,7 +46,7 @@ using namespace std;
void nexus_read_test_syntax() void nexus_read_test_syntax()
{ {
cout << endl << ">>---------------------------------------------------------------------------------------"; cout << endl << ">>---------------------------------------------------------------------------------------";
cout << endl << ">> usage: nexus_dump <nexus-in-filename>"; cout << endl << ">> usage: nexus_dump [<nexus-in-filename>] | --version";
cout << endl << ">> This will try to read a nexus-files <nexus-in-filename> and send the relevant"; cout << endl << ">> This will try to read a nexus-files <nexus-in-filename> and send the relevant";
cout << endl << ">> information to the standard output."; cout << endl << ">> information to the standard output.";
cout << endl << ">>---------------------------------------------------------------------------------------"; cout << endl << ">>---------------------------------------------------------------------------------------";
@ -61,6 +62,11 @@ int main(int argc, char *argv[])
return -1; return -1;
} }
if (!strcmp(argv[1], "--version")) {
cout << endl << "nexus_dump version: " << PMUSR_VERSION << " / $Id$" << endl << endl;
return 0;
}
PNeXus *nxs_file = new PNeXus(argv[1]); PNeXus *nxs_file = new PNeXus(argv[1]);
if (nxs_file->IsValid(false)) { if (nxs_file->IsValid(false)) {

View File

@ -0,0 +1,103 @@
/***************************************************************************
read_musrRoot_runHeader.cpp
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
$Id$
***************************************************************************/
/***************************************************************************
* 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 <iostream>
using namespace std;
#include <TROOT.h>
#include <TFile.h>
#include <TFolder.h>
#include "PMusr.h"
#include "TMusrRunHeader.h"
void closeFile(TFile *f)
{
if (f == 0)
return;
f->Close();
delete f;
}
void read_musrRoot_runHeader_syntax()
{
cout << endl << "usage: read_musrRoot_runHeader [<fileName>] | --version";
cout << endl << " <fileName> is the file name including the extention root, e.g. test.root";
cout << endl << endl;
}
int main(int argc, char *argv[])
{
if (argc != 2) {
read_musrRoot_runHeader_syntax();
return 1;
}
if (!strcmp(argv[1], "--version")) {
cout << endl << "read_musrRoot_runHeader version: " << PMUSR_VERSION << " / $Id$" << endl << endl;
return 0;
}
// read the file back and extract the header info
TFile *f = new TFile(argv[1], "READ", "read_musrRoot_runHeader");
if (f->IsZombie()) {
delete f;
return -1;
}
TFolder *runHeader = 0;
f->GetObject("RunHeader", runHeader);
if (runHeader == 0) {
cerr << endl << ">> **ERROR** Couldn't get top folder RunHeader";
closeFile(f);
return -1;
}
TMusrRunHeader *header = new TMusrRunHeader(argv[1]);
if (!header->ExtractAll(runHeader)) {
cerr << endl << ">> **ERROR** couldn't extract all RunHeader information :-(" << endl << endl;
closeFile(f);
return -1;
}
f->Close();
delete f;
header->DumpHeader();
delete header;
cout << endl << endl;
return 0;
}

View File

@ -0,0 +1,266 @@
/***************************************************************************
analyticFakeData.C
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
$Id$
***************************************************************************/
/***************************************************************************
* 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. *
***************************************************************************/
void analyticFakeData(const TString type)
{
// load library
gSystem->Load("$ROOTSYS/lib/libTLemRunHeader");
gSystem->Load("$ROOTSYS/lib/libTMusrRunHeader");
gSystem->Load("$ROOTSYS/lib/libPAddPoissonNoise");
// generate data
TFolder *histosFolder;
TFolder *decayAnaModule;
TFolder *runHeader;
TFolder *runInfo;
UInt_t offset = 0;
histosFolder = gROOT->GetRootFolder()->AddFolder("histos", "Histograms");
gROOT->GetListOfBrowsables()->Add(histosFolder, "histos");
decayAnaModule = histosFolder->AddFolder("DecayAnaModule", "muSR decay histograms");
UInt_t runNo = 3000;
TString fileName, tstr, label, tstr1;
fileName.Form("0%d.root", (Int_t)runNo);
Double_t t0[8] = {3419.0, 3520.0, 3520.0, 3421.0, 3517.0, 3418.0, 3522.0, 3623.0}; // runNo: 1000 & 2000
// Double_t t0[8] = {3519.0, 3420.0, 3520.0, 3621.0, 3417.0, 3518.0, 3422.0, 3423.0}; // runNo: 1001 & 2001
if (!type.CompareTo("TLemRunHeader")) {
// feed run info header
runInfo = gROOT->GetRootFolder()->AddFolder("RunInfo", "LEM RunInfo");
gROOT->GetListOfBrowsables()->Add(runInfo, "RunInfo");
TLemRunHeader *header = new TLemRunHeader();
tstr.Form("0%d - test", runNo);
header->SetRunTitle(tstr);
header->SetLemSetup("trivial");
header->SetRunNumber(runNo);
header->SetStartTime(0);
header->SetStopTime(1);
header->SetModeratorHV(32.0, 0.01);
header->SetSampleHV(0.0, 0.01);
header->SetImpEnergy(31.8);
header->SetSampleTemperature(0.2, 0.001);
header->SetSampleBField(-1.0, 0.1);
header->SetTimeResolution(0.1953125);
header->SetNChannels(66601);
header->SetNHist(8);
header->SetCuts("none");
header->SetModerator("none");
header->SetTimeZero(t0);
runInfo->Add(header); //add header to RunInfo folder
} else { // TMusrRunHeader
runHeader = gROOT->GetRootFolder()->AddFolder("RunHeader", "MusrRoot RunHeader");
gROOT->GetListOfBrowsables()->Add(runHeader, "RunHeader");
TMusrRunHeader *header = new TMusrRunHeader(true);
TMusrRunPhysicalQuantity prop;
// 1st write all the required RunInfo entries
header->Set("RunInfo/Generic Validator URL", "http://lmu.web.psi.ch/facilities/software/MusrRoot/validation/MusrRoot.xsd");
header->Set("RunInfo/Specific Validator URL", "http://lmu.web.psi.ch/facilities/software/MusrRoot/validation/MusrRootLEM.xsd");
header->Set("RunInfo/Generator", "analyticFakeData");
header->Set("RunInfo/File Name", fileName);
tstr.Form("0%d - test", runNo);
header->Set("RunInfo/Run Title", tstr);
header->Set("RunInfo/Run Number", (Int_t)runNo);
header->Set("RunInfo/Start Time", "1970-01-01 00:00:00");
header->Set("RunInfo/Stop Time", "1970-01-01 00:00:00");
prop.Set("Run Duration", 0, "sec");
header->Set("RunInfo/Run Duration", prop);
header->Set("RunInfo/Laboratory", "PSI");
header->Set("RunInfo/Instrument", "virtual");
prop.Set("Muon Beam Momentum", 28.1, "MeV/c");
header->Set("RunInfo/Muon Beam Momentum", prop);
header->Set("RunInfo/Muon Species", "positive muon");
header->Set("RunInfo/Muon Source", "computer");
header->Set("RunInfo/Setup", "virtual");
header->Set("RunInfo/Comment", "fake data runs");
header->Set("RunInfo/Sample Name", "virtual");
prop.Set("Sample Temperature", 1.0, "mK");
header->Set("RunInfo/Sample Temperature", prop);
prop.Set("Sample Magnetic Field", 0.0, "G");
header->Set("RunInfo/Sample Magnetic Field", prop);
prop.Set("Sample Temperature", 1.0, "mK");
header->Set("RunInfo/No of Histos", 8);
prop.Set("Time Resolution", 0.1953125, "ns");
header->Set("RunInfo/Time Resolution", prop);
vector<Int_t> ivec;
ivec.push_back(0);
ivec.push_back(20);
header->Set("RunInfo/RedGreen Offset", ivec);
offset = 1;
// 2nd write all the required DetectorInfo entries
for (UInt_t i=0; i<8; i++) {
tstr.Form("DetectorInfo/Detector%03d/", i+offset);
label = tstr + TString("Name");
tstr1.Form("Detector%03d", (Int_t)(i+offset));
header->Set(label, tstr1);
label = tstr + TString("Histo No");
header->Set(label, (Int_t)(i+offset));
label = tstr + TString("Histo Length");
header->Set(label, 66601);
label = tstr + TString("Time Zero Bin");
header->Set(label, t0[i]);
label = tstr + TString("First Good Bin");
header->Set(label, (Int_t)t0[i]);
label = tstr + TString("Last Good Bin");
header->Set(label, 66600);
}
for (UInt_t i=0; i<8; i++) {
tstr.Form("DetectorInfo/Detector%03d/", 20+i+offset);
label = tstr + TString("Name");
tstr1.Form("Detector%03d", (Int_t)(20+i+offset));
header->Set(label, tstr1);
label = tstr + TString("Histo No");
header->Set(label, (Int_t)(20+i+offset));
label = tstr + TString("Histo Length");
header->Set(label, 66601);
label = tstr + TString("Time Zero Bin");
header->Set(label, t0[i]);
label = tstr + TString("First Good Bin");
header->Set(label, (Int_t)t0[i]);
label = tstr + TString("Last Good Bin");
header->Set(label, 66600);
}
// 3rd write required SampleEnvironmentInfo entries
header->Set("SampleEnvironmentInfo/Cryo", "virtual");
// 4th write required MagneticFieldEnvironmentInfo entries
header->Set("MagneticFieldEnvironmentInfo/Magnet Name", "virtual");
// 5th write required BeamlineInfo entries
header->Set("BeamlineInfo/Name", "virtual");
}
// create histos
UInt_t n0[8] = {100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0};
UInt_t bkg[8] = {10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0};
const Double_t tau = 2197.019; // ns
// asymmetry related stuff
const Double_t timeResolution = 0.1953125; // ns
Double_t a0[8] = {0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12};
Double_t a1[8] = {0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05};
Double_t phase[8] = {5.0*TMath::Pi()/180.0, 50.0*TMath::Pi()/180.0, 95.0*TMath::Pi()/180.0, 140.0*TMath::Pi()/180.0,
185.0*TMath::Pi()/180.0, 230.0*TMath::Pi()/180.0, 275.0*TMath::Pi()/180.0, 320.0*TMath::Pi()/180.0,};
const Double_t gamma = 0.00001355; // gamma/(2pi)
Double_t bb0 = 150.0; // field in Gauss
Double_t bb1 = 400.0; // field in Gauss
Double_t sigma0 = 0.35/1000.0; // Gaussian sigma in 1/ns
Double_t sigma1 = 0.15/1000.0; // Gaussian sigma in 1/ns
TH1F *histo[16];
char str[128];
for (UInt_t i=0; i<8; i++) {
if (!type.CompareTo("TLemRunHeader"))
sprintf(str, "hDecay%02d", (Int_t)(i+offset));
else
sprintf(str, "hDecay%03d", (Int_t)(i+offset));
histo[i] = new TH1F(str, str, 66601, -0.5, 66600.5);
if (!type.CompareTo("TLemRunHeader"))
sprintf(str, "hDecay%02d", (Int_t)(20+i+offset));
else
sprintf(str, "hDecay%03d", (Int_t)(20+i+offset));
histo[i+8] = new TH1F(str, str, 66601, -0.5, 66600.5);
}
Double_t time;
Double_t dval, dval1;
for (UInt_t i=0; i<8; i++) {
for (UInt_t j=0; j<66600; j++) {
if (j<t0[i]) {
histo[i]->SetBinContent(j+1, bkg[i]);
} else {
time = (Double_t)(j-t0[i])*timeResolution;
dval = (Double_t)n0[i]*TMath::Exp(-time/tau)*(1.0+a0[i]*TMath::Exp(-0.5*TMath::Power(time*sigma0,1.2))*TMath::Cos(TMath::TwoPi()*gamma*bb0*time+phase[i])
+a1[i]*TMath::Exp(-0.5*TMath::Power(time*sigma1,2.0))*TMath::Cos(TMath::TwoPi()*gamma*bb1*time+phase[i]))+(Double_t)bkg[i];
histo[i]->SetBinContent(j+1, (UInt_t)dval);
}
}
}
// add a promp peak
Double_t ampl = 1000.0;
Double_t promptLambda = 500.0/1000.0; // Lorentzain in 1/ns
for (UInt_t i=0; i<8; i++) {
for (UInt_t j=1; j<66601; j++) {
dval = histo[i]->GetBinContent(j);
dval1 = dval*0.9; // simulate a PPC
time = (Double_t)(j-t0[i])*timeResolution;
dval += ampl*TMath::Exp(-fabs(time)*promptLambda);
dval1 += ampl*TMath::Exp(-fabs(time)*promptLambda);
histo[i]->SetBinContent(j, (UInt_t)dval);
histo[i+8]->SetBinContent(j, (UInt_t)dval1);
}
}
// add Poisson noise
PAddPoissonNoise *addNoise = new PAddPoissonNoise();
if (!addNoise->IsValid()) {
cerr << endl << "**ERROR** while invoking PAddPoissonNoise" << endl;
return;
}
for (UInt_t i=0; i<16; i++) {
addNoise->AddNoise(histo[i]);
}
/*
for (UInt_t i=0; i<8; i++) {
for (UInt_t j=1; j<histo[i]->GetEntries(); j++) {
histo[i+8]->SetBinContent(j, histo[i]->GetBinContent(j));
}
}
*/
for (UInt_t i=0; i<16; i++)
decayAnaModule->Add(histo[i]);
// write file
TFile *fout = new TFile(fileName.Data(), "RECREATE", "Midas Fake Histograms");
if (fout == 0) {
cout << endl << "**ERROR** Couldn't create ROOT file";
cout << endl << endl;
exit(0);
}
fout->cd();
if (!type.CompareTo("TLemRunHeader")) {
runInfo->Write();
} else {
if (header->FillFolder(runHeader))
runHeader->Write();
}
histosFolder->Write();
fout->Close();
delete fout;
delete [] histo;
}

View File

@ -17,7 +17,7 @@
PAR 1.0 2.1 3.5 -0.87 0.87 PAR 1.0 2.1 3.5 -0.87 0.87
MAP 2 1 4 5 MAP 2 1 4 5
FUNCTIONS FUNCTIONS
fun0 = cos(par1) #fun0 = cos(par1)
#fun1 = sin(par3/(par1+map2)) #fun1 = sin(par3/(par1+map2))
#fun0 = 1.2+pi #fun0 = 1.2+pi
#fun1 = gamma_mu #fun1 = gamma_mu
@ -27,7 +27,7 @@ fun0 = cos(par1)
#fun8 = -par1*log(sin(par1)) + exp(-1.0*map2) #fun8 = -par1*log(sin(par1)) + exp(-1.0*map2)
#fun1 = par1 + map1 * (0.01355+par1*(2.1 - (-2.3 / 3.4))) #fun1 = par1 + map1 * (0.01355+par1*(2.1 - (-2.3 / 3.4)))
#fun2 = par1 * par2 - map3 #fun2 = par1 * par2 - map3
#fun3 = -3.2 + (par2-par1)/(map2+map3) fun3 = -3.2 + (par2-par1)/(map2+map3)
#fun7 = 1.2 #fun7 = 1.2
END END
#---------------------------------------------- #----------------------------------------------

View File

@ -1,164 +0,0 @@
/***************************************************************************
t0NotEqFirstGoodData.C
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
$Id$
***************************************************************************/
/***************************************************************************
* Copyright (C) 2009 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. *
***************************************************************************/
void t0NotEqFirstGoodData()
{
// load library
gSystem->Load("$ROOTSYS/lib/libTLemRunHeader");
gSystem->Load("$ROOTSYS/lib/libPAddPoissonNoise");
// generate data
TFolder *histosFolder;
TFolder *decayAnaModule;
TFolder *runInfo;
histosFolder = gROOT->GetRootFolder()->AddFolder("histos", "Histograms");
gROOT->GetListOfBrowsables()->Add(histosFolder, "histos");
decayAnaModule = histosFolder->AddFolder("DecayAnaModule", "muSR decay histograms");
// feed run info header
UInt_t runNo = 30002;
TString tstr;
runInfo = gROOT->GetRootFolder()->AddFolder("RunInfo", "LEM RunInfo");
gROOT->GetListOfBrowsables()->Add(runInfo, "RunInfo");
header = new TLemRunHeader();
tstr = TString("0");
tstr += runNo;
tstr += TString(" - test");
header->SetRunTitle(tstr.Data());
header->SetLemSetup("trivial");
header->SetRunNumber(runNo);
header->SetStartTime(0);
header->SetStopTime(1);
header->SetModeratorHV(32.0, 0.01);
header->SetSampleHV(0.0, 0.01);
header->SetImpEnergy(31.8);
header->SetSampleTemperature(0.2, 0.001);
header->SetSampleBField(-1.0, 0.1);
header->SetTimeResolution(0.1953125);
header->SetNChannels(66601);
header->SetNHist(8);
header->SetCuts("none");
header->SetModerator("none");
Double_t tt0[8] = {3419.0, 3420.0, 3520.0, 3521.0, 3417.0, 3418.0, 3522.0, 3523.0};
header->SetTimeZero(tt0);
runInfo->Add(header); //add header to RunInfo folder
// create histos
UInt_t t0[8] = {3419, 3420, 3520, 3521, 3417, 3418, 3522, 3523};
UInt_t n0[8] = {10000.0, 10000.0, 10000.0, 10000.0, 10000.0, 10000.0, 10000.0, 10000.0};
UInt_t bkg[8] = {10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0};
const Double_t tau = 2197.019; // ns
// asymmetry related stuff
const Double_t timeResolution = 0.1953125; // ns
Double_t a0[8] = {0.26, 0.26, 0.26, 0.26, 0.26, 0.26, 0.26, 0.26};
Double_t a1[8] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
Double_t phase[8] = {5.0*TMath::Pi()/180.0, 50.0*TMath::Pi()/180.0, 95.0*TMath::Pi()/180.0, 140.0*TMath::Pi()/180.0,
185.0*TMath::Pi()/180.0, 230.0*TMath::Pi()/180.0, 275.0*TMath::Pi()/180.0, 320.0*TMath::Pi()/180.0,};
const Double_t gamma = 0.00001355; // gamma/(2pi)
Double_t bb0 = 15000.0; // field in Gauss
Double_t bb1 = 400.0; // field in Gauss
Double_t sigma0 = 0.05/1000.0; // Gaussian sigma in 1/ns
Double_t sigma1 = 0.005/1000.0; // Gaussian sigma in 1/ns
TH1F *histo[16];
char str[128];
for (UInt_t i=0; i<8; i++) {
sprintf(str, "hDecay0%d", (Int_t)i);
histo[i] = new TH1F(str, str, 66601, -0.5, 66600.5);
sprintf(str, "hDecay2%d", (Int_t)i);
histo[i+8] = new TH1F(str, str, 66601, -0.5, 66600.5);
}
Double_t time;
Double_t dval;
for (UInt_t i=0; i<8; i++) {
for (UInt_t j=0; j<66600; j++) {
if (j<t0[i]) {
histo[i]->SetBinContent(j+1, bkg[i]);
} else {
time = (Double_t)(j-t0[i])*timeResolution;
dval = (Double_t)n0[i]*TMath::Exp(-time/tau)*(1.0+a0[i]*TMath::Exp(-0.5*TMath::Power(time*sigma0,1.2))*TMath::Cos(TMath::TwoPi()*gamma*bb0*time+phase[i])
+a1[i]*TMath::Exp(-0.5*TMath::Power(time*sigma1,2.0))*TMath::Cos(TMath::TwoPi()*gamma*bb1*time+phase[i]))+(Double_t)bkg[i];
histo[i]->SetBinContent(j+1, (UInt_t)dval);
}
}
}
// add a promp peak
Double_t ampl = 10000.0;
Double_t promptLambda = 500.0/1000.0; // Lorentzain in 1/ns
for (UInt_t i=0; i<8; i++) {
for (UInt_t j=1; j<66601; j++) {
dval = histo[i]->GetBinContent(j);
time = (Double_t)(j-t0[i])*timeResolution;
dval += ampl*TMath::Exp(-fabs(time)*promptLambda);
histo[i]->SetBinContent(j, (UInt_t)dval);
histo[i+8]->SetBinContent(j, (UInt_t)dval);
}
}
// add Poisson noise
PAddPoissonNoise *addNoise = new PAddPoissonNoise();
if (!addNoise->IsValid()) {
cerr << endl << "**ERROR** while invoking PAddPoissonNoise" << endl;
return;
}
for (UInt_t i=0; i<8; i++) {
addNoise->AddNoise(histo[i]);
}
for (UInt_t i=0; i<8; i++) {
for (UInt_t j=1; j<histo[i]->GetEntries(); j++) {
histo[i+8]->SetBinContent(j, histo[i]->GetBinContent(j));
}
}
for (UInt_t i=0; i<16; i++)
decayAnaModule->Add(histo[i]);
// write file
tstr = TString("0");
tstr += runNo;
tstr += TString(".root");
TFile *fout = new TFile(tstr.Data(), "RECREATE", "Midas Fake Histograms");
if (fout == 0) {
cout << endl << "**ERROR** Couldn't create ROOT file";
cout << endl << endl;
exit(0);
}
fout->cd();
runInfo->Write();
histosFolder->Write();
fout->Close();
delete fout;
delete [] histo;
}

View File

@ -0,0 +1,242 @@
/***************************************************************************
write_musrRoot_runHeader.cpp
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
$Id$
***************************************************************************/
/***************************************************************************
* 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 <cstdlib>
#include <ctime>
#include <cstring>
#include <iostream>
using namespace std;
#include <TROOT.h>
#include <TFile.h>
#include <TFolder.h>
#include "PMusr.h"
#include "TMusrRunHeader.h"
void write_musrRoot_runHeader_syntax()
{
cout << endl << "usage: write_musrRoot_runHeader [<fileName>] | --version";
cout << endl << " <fileName> is the file name including the extention root, e.g. test.root";
cout << endl << endl;
}
int main(int argc, char *argv[])
{
if (argc != 2) {
write_musrRoot_runHeader_syntax();
return 1;
}
if (!strcmp(argv[1], "--version")) {
cout << endl << "write_musrRoot_runHeader version: " << PMUSR_VERSION << " / $Id$" << endl << endl;
return 0;
}
// MusrRoot Run Header object
TMusrRunHeader *header = new TMusrRunHeader(argv[1]);
TMusrRunPhysicalQuantity prop;
// run info
header->Set("RunInfo/Generic Validator URL", "http://lmu.web.psi.ch/facilities/software/MusrRoot/Validation/MusrRoot.xsd");
header->Set("RunInfo/Specific Validator URL", "http://lmu.web.psi.ch/facilities/software/MusrRoot/Validation/MusrRootGPS.xsd");
header->Set("RunInfo/Generator", "any2many");
header->Set("RunInfo/File Name", "deltat_tdc_gps_2871.root");
header->Set("RunInfo/Run Title", "here comes the run title");
header->Set("RunInfo/Run Number", 2871);
// run info - start/stop time and duration
TString startTime("2012-04-19 14:25:22"), stopTime("2012-04-19 19:13:47");
struct tm tm_start, tm_stop;
header->Set("RunInfo/Run Start Time", startTime);
header->Set("RunInfo/Run Stop Time", stopTime);
// calculate run duration
memset(&tm_start, 0, sizeof(tm_start));
strptime(startTime.Data(), "%Y-%m-%d %H:%M:%S", &tm_start);
memset(&tm_stop, 0, sizeof(tm_stop));
strptime(stopTime.Data(), "%Y-%m-%d %H:%M:%S", &tm_stop);
Double_t duration = difftime(mktime(&tm_stop), mktime(&tm_start));
prop.Set("Run Duration", (Int_t)duration, "sec");
header->Set("RunInfo/Run Duration", prop);
header->Set("RunInfo/Laboratory", "PSI");
header->Set("RunInfo/Instrument", "GPS");
prop.Set("Muon Beam Momentum", 28.1, "MeV/c");
header->Set("RunInfo/Muon Beam Momentum", prop);
header->Set("RunInfo/Muon Species", "positive muon");
header->Set("RunInfo/Muon Source", "target M");
header->Set("RunInfo/Setup", "a very special setup with Heliox");
header->Set("RunInfo/Comment", "nothing more to be said");
header->Set("RunInfo/Sample Name", "the best ever");
prop.Set("Sample Temperature", 3.2, 3.21, 0.05, "K", "CF1");
header->Set("RunInfo/Sample Temperature", prop);
prop.Set("Sample Magnetic Field", 350.0, 350.002, 0.005, "G", "WXY");
header->Set("RunInfo/Sample Magnetic Field", prop);
header->Set("RunInfo/No of Histos", 4);
prop.Set("Time Resolution", 0.1953125, "ns", "TDC 9999");
header->Set("RunInfo/Time Resolution", prop);
header->Set("DetectorInfo/Detector000/Name", "Left - NPP");
header->Set("DetectorInfo/Detector000/Histo Number", 0);
header->Set("DetectorInfo/Detector000/Histo Length", 66661);
header->Set("DetectorInfo/Detector000/Time Zero Bin", 3419.0);
header->Set("DetectorInfo/Detector000/First Good Bin", 3419);
header->Set("DetectorInfo/Detector000/Last Good Bin", 66661);
header->Set("DetectorInfo/Detector001/Name", "Top - NPP");
header->Set("DetectorInfo/Detector001/Histo Number", 1);
header->Set("DetectorInfo/Detector001/Histo Length", 66661);
header->Set("DetectorInfo/Detector001/Time Zero Bin", 3419.0);
header->Set("DetectorInfo/Detector001/First Good Bin", 3419);
header->Set("DetectorInfo/Detector001/Last Good Bin", 66661);
header->Set("DetectorInfo/Detector002/Name", "Right - NPP");
header->Set("DetectorInfo/Detector002/Histo Number", 2);
header->Set("DetectorInfo/Detector002/Histo Length", 66661);
header->Set("DetectorInfo/Detector002/Time Zero Bin", 3419.0);
header->Set("DetectorInfo/Detector002/First Good Bin", 3419);
header->Set("DetectorInfo/Detector002/Last Good Bin", 66661);
header->Set("DetectorInfo/Detector003/Name", "Bottom - NPP");
header->Set("DetectorInfo/Detector003/Histo Number", 3);
header->Set("DetectorInfo/Detector003/Histo Length", 66661);
header->Set("DetectorInfo/Detector003/Time Zero Bin", 3419.0);
header->Set("DetectorInfo/Detector003/First Good Bin", 3419);
header->Set("DetectorInfo/Detector003/Last Good Bin", 66661);
header->Set("DetectorInfo/Detector004/Name", "Left - PPC");
header->Set("DetectorInfo/Detector004/Histo Number", 20);
header->Set("DetectorInfo/Detector004/Histo Length", 66661);
header->Set("DetectorInfo/Detector004/Time Zero Bin", 3419.0);
header->Set("DetectorInfo/Detector004/First Good Bin", 3419);
header->Set("DetectorInfo/Detector004/Last Good Bin", 66661);
header->Set("DetectorInfo/Detector005/Name", "Top - PPC");
header->Set("DetectorInfo/Detector005/Histo Number", 21);
header->Set("DetectorInfo/Detector005/Histo Length", 66661);
header->Set("DetectorInfo/Detector005/Time Zero Bin", 3419.0);
header->Set("DetectorInfo/Detector005/First Good Bin", 3419);
header->Set("DetectorInfo/Detector005/Last Good Bin", 66661);
header->Set("DetectorInfo/Detector006/Name", "Right - PPC");
header->Set("DetectorInfo/Detector006/Histo Number", 22);
header->Set("DetectorInfo/Detector006/Histo Length", 66661);
header->Set("DetectorInfo/Detector006/Time Zero Bin", 3419.0);
header->Set("DetectorInfo/Detector006/First Good Bin", 3419);
header->Set("DetectorInfo/Detector006/Last Good Bin", 66661);
header->Set("DetectorInfo/Detector007/Name", "Bottom - PPC");
header->Set("DetectorInfo/Detector007/Histo Number", 23);
header->Set("DetectorInfo/Detector007/Histo Length", 66661);
header->Set("DetectorInfo/Detector007/Time Zero Bin", 3419.0);
header->Set("DetectorInfo/Detector007/First Good Bin", 3419);
header->Set("DetectorInfo/Detector007/Last Good Bin", 66661);
TStringVector scHistoNames;
scHistoNames.push_back("Sample Temperature");
scHistoNames.push_back("Sample Magnetic Field");
header->Set("RunInfo/Slow Control Histo Names", scHistoNames);
TStringVector dummyTest;
dummyTest.push_back("dummy1");
dummyTest.push_back("dummy2");
dummyTest.push_back("dummy3");
header->Set("RunInfo/Dummy Test", dummyTest);
// sample environment
header->Set("SampleEnvironmentInfo/Cryo", "Konti-1");
header->Set("SampleEnvironmentInfo/Insert", "X123");
header->Set("SampleEnvironmentInfo/Orientation", "c-axis perp spin, perp field. spin perp field");
prop.Set("CF2", 3.2, 3.22, 0.04, "K");
header->Set("SampleEnvironmentInfo/CF2", prop);
prop.Set("CF3", MRH_UNDEFINED, 3.27, 0.09, "K", "strange temperature");
header->Set("SampleEnvironmentInfo/CF3", prop);
prop.Set("CF4", 3.25, 3.28, "K");
header->Set("SampleEnvironmentInfo/CF4", prop);
prop.Set("CF5", 3.26, 3.29, "K", "another strange temperature");
header->Set("SampleEnvironmentInfo/CF5", prop);
prop.Set("Dummy Prop", -2.0, -2.001, 0.002, "SI-unit");
header->Set("SampleEnvironmentInfo/Dummy Prop", prop);
// magnetic field environment
header->Set("MagneticFieldEnvironmentInfo/Magnet Name", "Bpar");
prop.Set("Current", 1.34, "A");
header->Set("MagneticFieldEnvironmentInfo/Current", prop);
// beamline
header->Set("BeamlineInfo/Name", "piM3.2");
header->Set("BeamlineInfo/WSX61a", "DAC = 3289, ADC = 0.800");
TIntVector dummyInt;
for (UInt_t i=0; i<3; i++) dummyInt.push_back(i+1000);
header->Set("BeamlineInfo/Dummy Int", dummyInt);
// scaler
header->Set("ScalerInfo/Ip", 12332123);
// funny sub/sub/../sub-structure
header->Set("aa/bb/cc/dd/ee/ff/name", "funny");
header->Set("aa/bb/cc/dd/ee/ff/gg/xyz", 123);
TFile *f = new TFile(argv[1], "RECREATE", "write_musrRoot_runHeader");
if (f->IsZombie()) {
delete f;
return -1;
}
// root file header related things
TFolder *runHeader = new TFolder("RunHeader", "MusrRoot Run Header Info");
if (header->FillFolder(runHeader)) {
runHeader->Write();
}
f->Close();
// clean up
delete f;
delete header;
return 0;
}

View File

@ -1,19 +0,0 @@
/***************************************************************************
* Copyright (C) 2007 by Andreas Suter *
* andreas.suter@psi.c *
* *
* 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. *
***************************************************************************/