#1/bin/tcsh -f

# run this in one of two ways from the OUTPUT directory:
#
# ../macros/mk_chain.csh fine
#
#   or
#
# ../macros/mk_chain.csh course

set granularity=$1


echo "$granularity"

set fname=chain_${granularity}.h

echo " " > $fname
echo "TChain *chain_"${granularity}"(const char *treeName)" >> $fname
echo "{" >> $fname
echo "   TChain *c = new TChain(treeName);" >> $fname
echo " " >> $fname


foreach s (`ls *_${granularity}.root`)
	echo "   c->AddFile("'"'${s}'"'");" >> ${fname}
end

echo " " >> $fname
echo "   return c;" >> $fname
echo "}" >> $fname
echo " " >> $fname
echo " " >> $fname

