6 |
|
## Alejandro Gomez Espinosa |
7 |
|
## gomez@physics.rutgers.edu |
8 |
|
## |
9 |
< |
## How to run: ./countNumberOfEvents.sh path/to/folder/ |
9 |
> |
## How to run: ./countNumberOfEvents.sh Stop1Mass Stop2Mass Process |
10 |
> |
## |
11 |
> |
## This script counts the number of events and move events to HexFarm |
12 |
|
## |
13 |
|
##################################################################### |
14 |
|
|
15 |
+ |
st1=$1 |
16 |
+ |
st2=$2 |
17 |
+ |
process=$3 |
18 |
|
|
19 |
< |
directory=$1 #'/uscms/home/algomez/nobackup/files/stops/AOD/st2_h_bb_st1_bj_250_100_AOD' # Directory from argument 1 |
19 |
> |
directory='/pnfs/cms/WAX/11/store/user/algomez/st2_h_bb_st1_'${process}'_'$st2'_'$st1'_AOD' # Directory from argument 1 |
20 |
> |
tmp_dir='/uscms_data/d3/algomez/tmp/' |
21 |
> |
toHexfarm='/cms/karen/algomez/Stops/AOD/st2_h_bb_st1_'${process}'_'$st2'_'$st1'/' |
22 |
|
|
23 |
|
ls -1 $directory | while read line # List the files in folder and while each line |
24 |
|
do |
25 |
< |
events=$(edmEventSize -v ${directory}/${line} | grep Events | awk '{ print $4 }' ) |
25 |
> |
dccp ${directory}/${line} $tmp_dir |
26 |
> |
echo 'Copying '${directory}/${line} 'to '$tmp_dir |
27 |
> |
done |
28 |
> |
|
29 |
> |
ls -1 $tmp_dir | while read line # List the files in folder and while each line |
30 |
> |
do |
31 |
> |
events=$(edmEventSize -v ${tmp_dir}/${line} | grep Events | awk '{ print $4 }' ) |
32 |
|
# edmEventsSize is CMSSW to create a list out of a root file, then search for the line displaying the Events, finally print only number of events |
33 |
|
echo $events >> tmp.txt # create a tmp file with numbers |
34 |
|
done |
35 |
+ |
|
36 |
+ |
#Move files to my Rutgers area |
37 |
+ |
scp ${tmp_dir}/*root gomez@hexcms.rutgers/edu:${toHexfarm} |
38 |
+ |
|
39 |
|
# Sum each number in the column (with awk) and print the total number of events |
40 |
|
echo "Total Number of events in " $1 " :" $(cat tmp.txt | awk '{ sum+=$1} END { print sum}') |
41 |
|
rm tmp.txt ## remove the tmp file |
42 |
+ |
rm $tmp_dir/* |