Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:03:38

0001 #! /bin/bash
0002 
0003 # script to change energy in all files using comEnergy
0004 # $1 = old energy (e.g. 10000.) $2 = new energy (e.g. 7000.), $3 string for new files (e.g. 7TeV)
0005 
0006 # move the script into the directory where you wnat to add files with new comEnergy
0007 # usage example: ./changeEnergy 10000. 7000. 7TeV
0008 
0009 # F. Stoeckli
0010 
0011 numFiles=$(grep $1 * | grep -c comEnergy)
0012 
0013 iter=1
0014 while [ $iter -le $numFiles ]
0015   do
0016   fileName=$(grep $1 * | grep comEnergy | sed -n $iter'p' | sed 's/:/\n/g' | sed -n 1'p')
0017   newFile=$(echo $fileName | sed 's/\_cf/\_'$3'\_cf/g')
0018   echo "From file "$fileName" creaeting new file "$newFile"."
0019   sed 's/comEnergy = cms.double('$1$'/comEnergy = cms.double('$2'/g' $fileName > $newFile
0020   echo "Diff from file "$fileName" and new file "$newFile":"
0021   diff $fileName $newFile
0022   echo "--------------------------------------------------------------------"
0023   iter=`expr $iter + 1`
0024 done