ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitHzz4l/scripts/mergeFakes.sh
Revision: 1.2
Committed: Mon Dec 17 17:23:53 2012 UTC (12 years, 5 months ago) by dkralph
Content type: application/x-sh
Branch: MAIN
CVS Tags: compiled, HEAD
Changes since 1.1: +19 -19 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 dkralph 1.1 conf=$1; if ! [ $1 ]; then echo "what?"; return; fi
2 dkralph 1.2 faketype=$2 # 2P2F or 3P1F
3     outName=$3; #if ! [ $3 ]; then echo "what?"; return; fi
4     inName=$4; #if ! [ $4 ]; then echo "what?"; return; fi
5 dkralph 1.1
6     if ! [ -s $conf ]; then echo "no file provided..."; return; fi
7     if ! [ $outName ]; then echo "using outName fakes"; outName=fakes; fi
8     if ! [ $inName ]; then echo "using inName fakes"; inName=fakes; fi
9 dkralph 1.2 if [ "$faketype" != "3P1F" ] && [ "$faketype" != "2P2F" ]; then return; fi
10 dkralph 1.1 echo -e "\ninName: $inName"
11     echo -e "outName: $outName\n"
12    
13     label=`grep '^\^label' $conf | awk '{print $2}'`; if ! [ $label ]; then echo "no label in config file!"; return; fi
14     ntupdir=`grep '^\^ntupdir' $conf | awk '{print $2}'`; if ! [ $ntupdir ]; then echo "no ntupdir in config file!"; return; fi
15    
16 dkralph 1.2 fname=merged-$faketype-$inName.root
17 dkralph 1.1 fakeFileList=
18 dkralph 1.2 if ! [ $linkOnly ]; then
19     echo "merging fakes with label: $label"
20     while read -u 7 line; do
21     if echo $line | grep '^\^\|^#\|^\$' &>/dev/null; then continue; fi
22     dset=`echo $line | awk '{print $1}'`
23     indir=$ntupdir/$label/$dset
24     if [ "$faketype" == "2P2F" ] && [ "`echo $line | awk '{print $2}'`" == "0" ]; then echo -e "\nHEY! You sure you wanna add monte carlo to the fakes?\n"; read; fi
25     if ! [ -s $indir/$fname ]; then echo "ERROR: $indir/$fname does not exist..."; fi
26     fakeFileList="$fakeFileList $indir/$fname"
27     mkdir -p `echo $indir | sed "s/$dset/$outName/"`
28     done 7< $conf
29    
30     hadd -f $ntupdir/$label/$outName/merged.root $fakeFileList
31     fi
32 dkralph 1.1
33     ls -ltrh $ntupdir/$label/$outName/merged.root
34     echo "Enter the label for the dir in Selection/root/ to which you want to make the link: "
35     read
36     selectionNtupDir=`echo $ntupdir | sed 's@\(.*MitHzz4l\).*@\1/Selection/root@'`/$REPLY
37     ln -fvs $ntupdir/$label/$outName $selectionNtupDir/