ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/algomez/test/countNumberofEvents.sh
(Generate patch)

Comparing UserCode/algomez/test/countNumberofEvents.sh (file contents):
Revision 1.1 by algomez, Fri Apr 26 00:16:41 2013 UTC vs.
Revision 1.2 by algomez, Fri Apr 26 00:22:53 2013 UTC

# Line 1 | Line 1
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 path/to/folder/
10 + ##
11 + #####################################################################
12  
3 directory=$1 #'/uscms/home/algomez/nobackup/files/stops/AOD/st2_h_bb_st1_bj_250_100_AOD'
13  
14 < ls -1 $directory | while read line
14 > directory=$1 #'/uscms/home/algomez/nobackup/files/stops/AOD/st2_h_bb_st1_bj_250_100_AOD'    # Directory from argument 1
15 >
16 > ls -1 $directory | while read line                                                          # List the files in folder and while each line
17   do
18 <        totalevents=0  
19 <        events=$(edmEventSize -v ${directory}/${line} | grep Events | awk '{ print $4 }' )
20 <        echo $events >> tmp.txt
18 >        events=$(edmEventSize -v ${directory}/${line} | grep Events | awk '{ print $4 }' )  
19 >        # 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
20 >        echo $events >> tmp.txt                                                             # create a tmp file with numbers
21   done
22 <
22 > # Sum each number in the column (with awk) and print the total number of events
23   echo "Total Number of events in " $1 " :" $(cat tmp.txt | awk '{ sum+=$1} END { print sum}')
24 < rm tmp.txt
24 > rm tmp.txt                                                                                   ## remove the tmp file

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines