ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/algomez/test/countNumberofEvents.sh
Revision: 1.3
Committed: Sat Jun 8 15:28:33 2013 UTC (11 years, 11 months ago) by algomez
Content type: application/x-sh
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +21 -3 lines
Log Message:
*** empty log message ***

File Contents

# Content
1 #!/bin/bash
2 ####################################################################
3 ##
4 ## Simple script to count the number of events of several root files
5 ##
6 ## Alejandro Gomez Espinosa
7 ## gomez@physics.rutgers.edu
8 ##
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='/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 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/*