3 #----------------------------------------------------------------------------------
4 # A perl script to download jnubeam hbook ntuples and convert them to ROOT format.
8 # --username <some_username>
9 # --passwd <some_password>
11 # --prefix <file_prefix>
12 # --suffix <file_suffix>
15 # [--target <local_disk_path (default: '.')>]
18 # You want to download/convert the 07a near detector flux files
19 # (named as 'nu.nd280.<RUN_NUMBER>.hbk)
20 # living at http://jnusrv01.kek.jp/internal/t2k/nubeam/flux/07a/nd/
21 # You only want to download / convert the files corresponding to MC runs 20->80,
22 # and you want to copy the downloaded files in /some/local/datadir/
27 # --passwd type_actual_passwd
28 # --url http://jnusrv01.kek.jp/internal/t2k/nubeam/flux/07a/nd/
29 # --prefix nu.nd280. --suffix .hbk --rmin 20 --rmax 80
30 # --target /some/local/datadir/
32 # Costas Andreopoulos <constantinos.andreopoulos \at cern.ch>
33 # STFC, Rutherford Appleton Lab
34 #----------------------------------------------------------------------------------
39 if($_ eq '--username') { $username = $ARGV[$iarg+1]; }
40 if($_ eq '--passwd') { $passwd = $ARGV[$iarg+1]; }
41 if($_ eq '--url' ) { $url = $ARGV[$iarg+1]; }
42 if($_ eq '--prefix') { $file_prfx = $ARGV[$iarg+1]; }
43 if($_ eq '--suffix') { $file_sufx = $ARGV[$iarg+1]; }
44 if($_ eq '--rmin') { $run_min = $ARGV[$iarg+1]; }
45 if($_ eq '--rmax') { $run_max = $ARGV[$iarg+1]; }
46 if($_ eq '--target') { $target = $ARGV[$iarg+1]; }
49 die("** Aborting [Undefined user name. Use the --username option]")
50 unless defined $username;
51 die("** Aborting [Undefined URL. Use the --url option]")
53 die("** Aborting [Undefined file prefix. Use the --prefix option]")
54 unless defined $file_prfx;
55 die("** Aborting [Undefined file suffix. Use the --suffix option]")
56 unless defined $file_sufx;
57 die("** Aborting [Undefined minimum run number. Use the --rmin option]")
58 unless defined $run_min;
59 die("** Aborting [Undefined maximum run number. Use the --rmax option]")
60 unless defined $run_max;
62 $passwd = "" unless defined $passwd;
65 for($i=$run_min; $i<=$run_max; $i++) {
67 # fetch hbook file from remote location
68 $filename = $file_prfx.$i.$file_sufx;
69 $fetch_cmd = "curl -O --user $username:$passwd $url/$filename";
70 print "@@@ $fetch_cmd \n";
73 print "*** Couldn't download $url/$filename \n";
76 # copy to local directory
77 if( -defined $target ) {
78 print "@@@ mv $filename $target \n";
79 `mv $filename $target`;