3 #----------------------------------------------------------------------------------
4 # A perl script to download jnubeam hbook ntuples and convert them to ROOT format.
7 # perl fetch-t2k_flux.pl
8 # --passwd <usual_t2k_password>
10 # --prefix <file_prefix>
11 # [--suffix <file_suffix (default:'.hbk')>]
14 # [--target <local_disk_path (default: '.')>]
17 # You want to download/convert the 07a near detector flux files
18 # (named as 'nu.nd280.<RUN_NUMBER>.hbk)
19 # living at http://jnusrv01.kek.jp/internal/t2k/nubeam/flux/07a/nd/
20 # You only want to download / convert the files corresponding to MC runs 20->80,
21 # and you want to copy all *hbk and *root files in /some/local/datadir/
24 # perl fetch-t2k_flux.pl
25 # --passwd type_actual_passwd
26 # --url http://jnusrv01.kek.jp/internal/t2k/nubeam/flux/07a/nd/
27 # --prefix nu.nd280. --rmin 20 --rmax 80
28 # --target /some/local/datadir/
30 # Costas Andreopoulos <constantinos.andreopoulos \at cern.ch>
31 # STFC, Rutherford Appleton Lab
32 #----------------------------------------------------------------------------------
45 if($_ eq '--passwd') { $passwd = $ARGV[$iarg+1]; }
46 if($_ eq '--url' ) { $url = $ARGV[$iarg+1]; }
47 if($_ eq '--prefix') { $file_prfx = $ARGV[$iarg+1]; }
48 if($_ eq '--suffix') { $file_sufx = $ARGV[$iarg+1]; }
49 if($_ eq '--rmin') { $run_min = $ARGV[$iarg+1]; }
50 if($_ eq '--rmax') { $run_max = $ARGV[$iarg+1]; }
51 if($_ eq '--target') { $target = $ARGV[$iarg+1]; }
56 for($i=$run_min; $i<=$run_max; $i++) {
58 # fetch hbook file from remote location
59 $filename_hbk = $file_prfx.$i.$file_sufx;
60 $fetch_cmd = "curl -O --user $user:$passwd $url/$filename_hbk";
61 print "@@@ $fetch_cmd \n";
64 print "*** Couldn't download $url/$filename_hbk \n";
68 $filename_root = $filename_hbk;
69 $filename_root =~ s/.hbk/.root/;
70 $convert_cmd = "h2root $filename_hbk";
71 print "@@@ $convert_cmd \n";
74 # copy to local directory
75 if( -defined $target ) {
76 print "@@@ mv $filename_hbk $target \n";
77 `mv $filename_hbk $target`;
78 print "@@@ mv $filename_root $target \n";
79 `mv $filename_root $target`;