1 | #!/bin/csh |
---|
2 | |
---|
3 | srtpath newest Linux26SL5_i386_gcc412 |
---|
4 | #echo "BFCURRENT = $BFCURRENT" |
---|
5 | #echo " BFARCH = $BFARCH" |
---|
6 | |
---|
7 | if ($#argv != 3 && $#argv != 4) then |
---|
8 | echo "Usage: source convertCRT2root.csh <CRT run name> <number of the first file to process> <number of the last file to process>" |
---|
9 | echo " or" |
---|
10 | echo "Usage: source convertCRT2root.csh <CRT run name> <number of the first file to process> <number of the last file to process> <ROOT output file name>" |
---|
11 | exit |
---|
12 | endif |
---|
13 | |
---|
14 | set underscore = "_" |
---|
15 | |
---|
16 | set runName = $1; |
---|
17 | echo "runName = $runName" |
---|
18 | |
---|
19 | set first = $2 |
---|
20 | set last = $3 |
---|
21 | |
---|
22 | echo "Processing files $first -> $last" |
---|
23 | |
---|
24 | set rawDataDir = "/u3/CRT_DST/exp3" |
---|
25 | set rootDataDir = "/nfs/farm/g/superb/u02/crt/crtDataConvertedToRoot" |
---|
26 | |
---|
27 | set currentDir = `pwd` |
---|
28 | echo "currentDir = $currentDir" |
---|
29 | |
---|
30 | cd $rawDataDir |
---|
31 | if( ! -d $runName ) then |
---|
32 | echo "CRT directory $runName does not exist in area $rawDataDir" |
---|
33 | echo "=> Exiting the script" |
---|
34 | exit |
---|
35 | endif |
---|
36 | |
---|
37 | cd $runName |
---|
38 | #echo "first = $first last = $last" |
---|
39 | set list = `ls -1 *.dst2 | awk -F "." '{ print $1}' | awk -F "_" '{ if( $NF >= '"$first"' && $NF <= '"$last"' ) {print $0".dst2"; } }'` |
---|
40 | |
---|
41 | #echo "LIST" |
---|
42 | echo "DST2 files to be processed: $list" |
---|
43 | #echo "LIST" |
---|
44 | |
---|
45 | cd $currentDir |
---|
46 | |
---|
47 | if( -e list_CRT.tmp ) then |
---|
48 | rm list_CRT.tmp |
---|
49 | endif |
---|
50 | |
---|
51 | foreach file( $list ) |
---|
52 | if( ! -e list_CRT.tmp ) then |
---|
53 | echo "$file" >! list_CRT.tmp |
---|
54 | else |
---|
55 | echo "$file" >> list_CRT.tmp |
---|
56 | endif |
---|
57 | end |
---|
58 | |
---|
59 | # Remove by hand a bad file with data not ordered by increasing time: |
---|
60 | # file 00166 in run16 |
---|
61 | if( $runName == "run16" && $first <= 166 && 166 <= $last ) then |
---|
62 | #if( $runName == "run16" ) then |
---|
63 | echo "Remove a bad file" |
---|
64 | ( cat list_CRT.tmp | grep -v exp3_run16_00166.dst2 ) >! tmp.txt |
---|
65 | mv list_CRT.tmp list_CRT.tmp.old |
---|
66 | mv tmp.txt list_CRT.tmp |
---|
67 | echo "Diffing the two files" |
---|
68 | diff list_CRT.tmp list_CRT.tmp.old |
---|
69 | endif |
---|
70 | |
---|
71 | if( $first < 10 ) then |
---|
72 | set first = "0000$first" |
---|
73 | else if( $first < 100 ) then |
---|
74 | set first = "000$first" |
---|
75 | else if( $first < 1000 ) then |
---|
76 | set first = "00$first" |
---|
77 | else if( $first < 10000 ) then |
---|
78 | set first = "0$first" |
---|
79 | endif |
---|
80 | endif |
---|
81 | endif |
---|
82 | endif |
---|
83 | |
---|
84 | if( $last < 10 ) then |
---|
85 | set last = "0000$last" |
---|
86 | else if( $last < 100 ) then |
---|
87 | set last = "000$last" |
---|
88 | else if( $last < 1000 ) then |
---|
89 | set last = "00$last" |
---|
90 | else if( $last < 10000 ) then |
---|
91 | set last = "0$last" |
---|
92 | endif |
---|
93 | endif |
---|
94 | endif |
---|
95 | endif |
---|
96 | |
---|
97 | if ($#argv == 4 ) then |
---|
98 | set rootFileName = $4 |
---|
99 | else |
---|
100 | set rootFileName = "CRT_$runName$underscore$first-$last.root" |
---|
101 | endif |
---|
102 | |
---|
103 | cd $rootDataDir |
---|
104 | if( ! -d $runName ) then |
---|
105 | mkdir $runName |
---|
106 | chmod g+rwx $runName |
---|
107 | endif |
---|
108 | |
---|
109 | cd $runName |
---|
110 | if( -e $rootFileName ) then |
---|
111 | mv $rootFileName $rootFileName.old |
---|
112 | chmod g+w $rootFileName.old |
---|
113 | endif |
---|
114 | |
---|
115 | cd $currentDir |
---|
116 | |
---|
117 | if( -e convertCRT2root.log ) then |
---|
118 | mv convertCRT2root.log convertCRT2root.log.old |
---|
119 | endif |
---|
120 | |
---|
121 | #echo "ROOTSYS = $ROOTSYS" |
---|
122 | #gmake clean |
---|
123 | #gmake |
---|
124 | convertCRT2rootApp list_CRT.tmp $rawDataDir/$runName $rootDataDir/$runName/$rootFileName |& tee convertCRT2root.log |
---|
125 | |
---|
126 | echo |
---|
127 | echo "---> Newly created root file: $rootDataDir/$runName/$rootFileName" |
---|
128 | echo |
---|