source: SuperB-LAL/trunk/slacExperiment_USBWC-CRT/convertCRT2root.csh

Last change on this file was 14, checked in by narnaud, 14 years ago

Initial commit

File size: 2.9 KB
Line 
1#!/bin/csh
2
3srtpath newest Linux26SL5_i386_gcc412
4#echo "BFCURRENT = $BFCURRENT"
5#echo "   BFARCH = $BFARCH"
6
7if ($#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
12endif
13
14set underscore = "_"
15
16set runName = $1;
17echo "runName = $runName"
18
19set first = $2
20set last  = $3
21
22echo "Processing files $first -> $last"
23
24set rawDataDir  = "/u3/CRT_DST/exp3"
25set rootDataDir = "/nfs/farm/g/superb/u02/crt/crtDataConvertedToRoot"
26
27set currentDir = `pwd`
28echo "currentDir = $currentDir"
29
30cd $rawDataDir
31if( ! -d $runName ) then
32  echo "CRT directory $runName does not exist in area $rawDataDir"
33  echo "=> Exiting the script"
34  exit
35endif
36
37cd $runName
38#echo "first = $first last = $last"
39set list = `ls -1 *.dst2 | awk -F "." '{ print $1}' | awk -F "_" '{ if( $NF >= '"$first"' && $NF <= '"$last"' ) {print $0".dst2"; } }'`
40
41#echo "LIST"
42echo "DST2 files to be processed: $list"
43#echo "LIST"
44
45cd $currentDir
46
47if( -e list_CRT.tmp ) then
48  rm list_CRT.tmp
49endif
50
51foreach 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
57end
58
59# Remove by hand a bad file with data not ordered by increasing time:
60# file 00166 in run16
61if( $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
69endif
70
71if( $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
82endif
83
84if( $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
95endif
96
97if ($#argv == 4 ) then
98  set rootFileName = $4
99else
100  set rootFileName = "CRT_$runName$underscore$first-$last.root"
101endif
102
103cd $rootDataDir
104if( ! -d $runName ) then
105  mkdir $runName
106  chmod g+rwx $runName
107endif
108
109cd $runName
110if( -e $rootFileName ) then
111  mv $rootFileName $rootFileName.old
112  chmod g+w $rootFileName.old
113endif
114
115cd $currentDir
116
117if( -e convertCRT2root.log ) then
118  mv convertCRT2root.log convertCRT2root.log.old
119endif
120
121#echo "ROOTSYS = $ROOTSYS"
122#gmake clean
123#gmake
124convertCRT2rootApp list_CRT.tmp $rawDataDir/$runName $rootDataDir/$runName/$rootFileName |& tee convertCRT2root.log
125
126echo
127echo "---> Newly created root file: $rootDataDir/$runName/$rootFileName"
128echo
Note: See TracBrowser for help on using the repository browser.