Changeset 7453 for trunk/MagicSoft/Mars/datacenter/scripts/linkmc
- Timestamp:
- 12/12/05 16:30:50 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/datacenter/scripts/linkmc
r7452 r7453 53 53 mccampath=/montecarlo/camera 54 54 mcpath=/montecarlo/rawfiles 55 next=$mcpath/.next 56 processed=$mcpath/.processed 57 processeddir=$mcpath/.processed.dir 58 readme=$mcpath/README.txt 55 next=$mcpath/.next #in .next the next runno is stored 56 processed=$mcpath/.processed #in .processed the linked files are stored 57 readme=$mcpath/README.txt #file in which the information about the modes is redirected to have always an updated explanation 59 58 60 59 if ! ls $next >> $scriptlog 2>&1 … … 68 67 69 68 70 modes=("" "Gammawobble+" "Gammanowobble0" "GammawobbleHE+" "GammanowobbleHE0" "Gammawobble0" "GammawobbleHE0" "Proton" "DiffuseGamma" ) 69 modes=("" "Gammawobble+" "Gammanowobble0" "GammawobbleHE+" "GammanowobbleHE0" "Gammawobble0" "GammawobbleHE0" "Gammadiffuse0" "Protonnowobble0" ) 70 71 #be carful: 72 # w- not yet foreseen in this script 71 73 72 74 echo "" >> $readme 2>&1 … … 101 103 102 104 105 #get runnumber 103 106 runno=`cat $next` 104 107 108 #get files, which have to be linked 105 109 camfiles=`find $mccampath -type f | grep -v Cal_and_Ped` 106 110 107 111 for camfile in ${camfiles[@]} 108 112 do 113 #continue, if file is already linked 109 114 if grep $camfile $processed >> $scriptlog 2>&1 110 115 then 111 116 continue 112 117 fi 113 file=`basename $camfile` 114 no=`printf %08d $runno | cut -c 0-5` 115 # no2=`printf %08d $runno` 118 file=`basename $camfile` #filename 119 no=`printf %08d $runno | cut -c 0-5` #first 5 digits of a 8digit runno -> for path 120 # no2=`printf %08d $runno` #runno with 8 digits 116 121 # workaround due to 5digit runnumber for data with runnumber < 35487 117 122 no2=`printf %05d $runno` 118 zbin=`echo $file | cut -d_ -f2 | cut -c 5-6` 119 zbin=`printf %02d $zbin` 120 wobble=`echo $file | cut -d_ -f6 | cut -c 2` 121 particle=`echo $file | cut -d_ -f1` 122 psf=`echo $camfile | cut -d/ -f5 | cut -c 6,8` 123 124 particledir=`echo $camfile | cut -d/ -f4` 125 wobbledir=`echo $camfile | cut -d/ -f6` 126 123 zbin=`echo $file | cut -d_ -f2 | cut -c 5-6` #zbin from filename 124 zbin=`printf %02d $zbin` #2digit 125 wobble=`echo $file | cut -d_ -f6 | cut -c 2` #mode from filename 126 particle=`echo $file | cut -d_ -f1` #particle type from filename 127 psf=`echo $camfile | cut -d/ -f5 | cut -c 6,8` #psf from path 128 129 particledir=`echo $camfile | cut -d/ -f4` #particletype from path 130 wobbledir=`echo $camfile | cut -d/ -f6` #mode from path 131 132 #build mode name 127 133 testmode=$particle$wobbledir$wobble 128 # echo "testmode:"$testmode >> $scriptlog 2>&1 129 134 135 #get mode extension for filename 130 136 case $wobble in 131 137 0) wobblemode="";; … … 136 142 esac 137 143 144 #get no of mode from array $modes 138 145 for (( i=1 ; i <= 12 ; i++ )) 139 146 do 140 147 if [ "${modes[$i]}" == "$testmode" ] 141 148 then 142 # echo "modes[$i]=${modes[$i]}" >> $scriptlog 2>&1143 149 totalmode=$i 144 150 break … … 146 152 done 147 153 148 totalmode=`printf %02d $totalmode` 149 # echo "totalmode: "$totalmode >> $scriptlog 2>&1 150 151 project=${particle}${zbin}${wobblemode}154 totalmode=`printf %02d $totalmode` #2 digits 155 156 project=${particle}${zbin}${wobblemode} #build project name 157 #create new filename 152 158 newfile="$mcpath/19$zbin/$totalmode/$psf/19${zbin}${totalmode}${psf}_${no2}_D_${project}_E.root" 153 159 newdir=`dirname $newfile` 154 160 makedir $newdir >> $scriptlog 2>&1 155 161 156 runno=`expr $runno + 1` 162 runno=`expr $runno + 1` #next runnumber 157 163 echo $runno >| $next 158 164 159 ln -sv $camfile $newfile >> $scriptlog 2>&1 165 #link file 166 ln -sv $camfile $newfile >> $scriptlog 2>&1 167 #add filename to processed file 160 168 echo $camfile >> $processed 161 169 … … 163 171 164 172 echo "linking cal and ped file" >> $scriptlog 2>&1 173 #get files 165 174 pedfile=`find $mccampath/Cal_and_Ped -name *_P_*.root` 166 175 calfile=`find $mccampath/Cal_and_Ped -name *_C_*.root` 167 176 echo "calfile"$calfile >> $scriptlog 2>&1 168 177 echo "pedfile"$pedfile >> $scriptlog 2>&1 178 #check number of files 169 179 numfiles=`echo $pedfile $calfile | wc -w` 170 180 if [ "$numfiles" != "2" ] … … 175 185 fi 176 186 187 #get all directories in the linked structure 177 188 dirs=`find $mcpath -type d` 178 189 179 190 for dir in ${dirs[@]} 180 191 do 181 if grep $dir $processeddir >> $scriptlog 2>&1 192 #continue, if directory has already linked C and P run 193 $cont=`ls $dir/*_0000[12]_[CP]_MonteCarlo_E.root | wc -w` 194 if [ "$cont" == "2" ] >> $scriptlog 2>&1 182 195 then 183 196 continue 184 197 fi 185 198 199 #continue, if directory is not at the lowest level of the structure 186 200 cont=`echo $dir | cut -d/ -f6` 187 201 if [ "$cont" == "" ] … … 190 204 fi 191 205 206 #get date for filename from directory name 192 207 date=`echo $dir | cut -c 22-25,27,28,30,31` 208 209 #create new filenames and link files 193 210 # workaround due to 5digit runnumber for data with runnumber < 35487 194 211 # newcalfile="${dir}/${date}_00000001_C_MonteCarlo_E.root" … … 199 216 newpedfile="${dir}/${date}_00002_P_MonteCarlo_E.root" 200 217 ln -sv $pedfile $newpedfile >> $scriptlog 2>&1 201 echo $dir >> $processeddir202 218 done 203 219
Note:
See TracChangeset
for help on using the changeset viewer.