Converting ascii output files from GISMO into
Root files

The ASCII files produced by all stages of processing can be converted to a Root format, via a utility called asc2root.   To convert files from ASCII to lcd format it is convenient to use a simple front-end script which sets up the necessary environment and runs the conversion program.

Install asc2root

Follow the instructions (coming soon!) to install the Event classes and asc2root.

Running asc2root


To run the program just issue the command:

asc2root inputasciifile.dat outputfile.root

Converting Sets of Files

If you have a large number of ASCII files you want to convert to Root files, it might be convenient to use a makefile to run asc2root. An example of a suitable makefile (for use with gmake) is given here. This example is for zipped ascii files.

# Convert all the .dat.gz files to .root files

DATADIR    := /nfs/surrey02/nld/ij737-WW/Small
ASC2ROOTDIR := $(NLDROOT)/RootApps/Asc2root/prod/bin/SunOS/
ROOTOUTDIR := $(DATADIR)/root/
CONVERT := $(ASC2ROOTDIR)asc2root

GZFILES    := $(wildcard $(DATADIR)/*.dat.gz)

# replace .dat.gz by .root in all input files

ROOTFILES0 := $(patsubst %.dat.gz,%.root,$(GZFILES) )

# remove the directory info (the input and output files are probably
# in different places

ROOTFILES1 := $(notdir $(ROOTFILES0) )

# prepend the output directory spec to the to-be-created .root files

ROOTFILES := $(addprefix $(ROOTOUTDIR)/,$(ROOTFILES1) )

all: $(ROOTFILES)


# root files depend on .dat.gz. Unzip them into tmp space, convert them
# and remove the unzipped file. be careful not to be removing the original
# dat file!


$(ROOTFILES): $(ROOTOUTDIR)%.root: $(DATADIR)%.dat.gz
    gunzip -c $< > /tmp/$(patsubst %.dat.gz,%.dat,$(<F)); \
    $(CONVERT) /tmp/$(patsubst %.dat.gz,%.dat,$(<F)) $(ROOTOUTDIR)$(patsubst %.dat.gz,%.root,$(<F)); \
    rm /tmp/$(patsubst %.dat.gz,%.dat,$(<F))

R.Dubois Last Modified: 01/13/04 12:45