
# all processes must be defined here
$procnames{"pes-align"} = "streamb/pesal_bb";
$procnames{"CEM"} = "streamb/CEM";

$calib_dir = "/export/data1/cdfopr/current";
$calib_id  = "cdfopr";
$calib_host = "fcdfdata125.fnal.gov";


#my @pesfiles = &getCalibFiles("pes-align","210914");

#my $pf;
#foreach $pf (@pesfiles)
#{
#    printf("File is $pf");
#}



sub getCalibFiles()
{
    my $process;
    my $run;
    ($process,$run) = @_;
    my $hrun = `printf "%06x" $run`;
    my $procname = $procnames{$process};
    if ($procname eq "")
    {
	printf("No such process $procname\n");
	my @empty;
	return @empty;
    }
    else
    {
	printf ("Looking for files: ssh ${calib_id}\@${calib_host} \"ls ${calib_dir}/${procname}${hrun}*.root\"\n");
	my @rawfiles = `ssh ${calib_id}\@${calib_host} \"ls ${calib_dir}/${procname}${hrun}*.root\"`;
	my @rootdfiles;
	my $rf;
	my $i=0;
	foreach $rf (@rawfiles)
	{
	    chop($rf);
	    $rootdfiles[$i++] = "rootd://${calib_host}/$rf";
	}
	return @rootdfiles
	}
}
