Index: trunk/tools/diskspace/merge_counts_and_sizes.pl
===================================================================
--- trunk/tools/diskspace/merge_counts_and_sizes.pl	(revision 32960)
+++ trunk/tools/diskspace/merge_counts_and_sizes.pl	(revision 32961)
@@ -5,5 +5,5 @@
 use PS::IPP::Config;
 
-getopts('ND:',\%opt);
+getopts('ND:M:',\%opt);
 
 my $ipprc = PS::IPP::Config->new("GPC1");
@@ -33,4 +33,5 @@
 
 	$size{$stage}{$product} = $size_in_gb;
+	$stage_min{$stage} += $size_in_gb;
 	$diskcount{$stage}{$product} = $count;
 	$total += $size_in_gb;
@@ -58,14 +59,22 @@
 my $mappings_file = "neb:///ipp_diskspace/mappings_im.dat";
 my $M_real_file = $ipprc->file_resolve($mappings_file);
+if (exists($opt{M})) {
+    $M_real_file = $opt{M};
+}
 open(M,$M_real_file) || die "Cannot find mappings.dat\n";
 while (<M>) {
     chomp;
     unless ($_ =~ /^#/) {
-	($stage,$product,$state) = split /\s+/;
-	$map{$stage}{$product}{$state} = 1;
-	if ($stage eq 'RAW' && $product eq 'FITS') {
-	    if (($state eq 'full')||($state eq 'pending_burntool')||($state eq 'keep')||($state eq 'compressed')||($state eq 'error_compressed')||
-		($state eq 'goto_lossy')||($state eq 'check_burntool')) {
-		$map{$stage}{$product}{$state} = 2;
+	($stage,$product,$state,$mult) = split /\s+/;
+	if (defined($mult)&&($mult !~ /^$/)) {
+	    $map{$stage}{$product}{$state} = $mult;
+	}
+	else {
+	    $map{$stage}{$product}{$state} = 1;
+	    if ($stage eq 'RAW' && $product eq 'FITS') {
+		if (($state eq 'full')||($state eq 'pending_burntool')||($state eq 'keep')||($state eq 'compressed')||($state eq 'error_compressed')||
+		    ($state eq 'goto_lossy')||($state eq 'check_burntool')) {
+		    $map{$stage}{$product}{$state} = 2;
+		}
 	    }
 	}
@@ -88,5 +97,5 @@
 	$VpN{$stage}{$state} = 0;
 	foreach $product (keys (%{ $size{$stage} })) {
-	    $N{$stage}{$product} += $map{$stage}{$product}{$state} * $count{$stage}{$state};
+	    $N{$stage}{$product} += $count{$stage}{$state}; # $map{$stage}{$product}{$state} * $count{$stage}{$state};
 	}		
     }
@@ -94,5 +103,5 @@
 	foreach $state (keys (%{ $count{$stage} })) {
 	    if ($N{$stage}{$product} > 0) {
-		$VpN{$stage}{$state} += $map{$stage}{$product}{$state} * $size{$stage}{$product} / $N{$stage}{$product};
+		$VpN{$stage}{$state} += $size{$stage}{$product} / $N{$stage}{$product};#$map{$stage}{$product}{$state} * $size{$stage}{$product} / $N{$stage}{$product};
 		$DVpN{$stage}{$state} += $map{$stage}{$product}{$state} * $size{$stage}{$product} / $diskcount{$stage}{$product};
 	    }
@@ -127,4 +136,6 @@
 
 foreach $stage (sort (keys %VpN)) {
+    $measuredA = 0;
+    $measuredB = 0;
     foreach $state (sort (keys %{ $VpN{$stage} })) {
 	unless(exists($count{$stage}{$state})) {
@@ -161,4 +172,6 @@
 	$labels{$label} += $V;
 	$alt_labels{$label} += $DVpN{$stage}{$state} * $count{$stage}{$state};
+	$measuredA += $V;
+	$measuredB += $DVpN{$stage}{$state} * $count{$stage}{$state};
 	printf("%-8s %-18s %-10s\t%14.4f %12.6f\t%14.6f %12.6f\t%9d\n",
 		$stage,$state,$label,$V,$VpN{$stage}{$state},$DVpN{$stage}{$state} * $count{$stage}{$state},$DVpN{$stage}{$state},$count{$stage}{$state});
@@ -167,4 +180,12 @@
 		   $stage,$state,$label,$V,$VpN{$stage}{$state},$DVpN{$stage}{$state} * $count{$stage}{$state},$DVpN{$stage}{$state},$count{$stage}{$state});
 	}
+    }
+    printf("%-8s %-18s %-10s\t%14.4f %-12s\t%14.6f\n",
+	   $stage,"","MINIMUM",$stage_min{$stage},"",$stage_min{$stage});
+    printf("%-8s %-18s %-10s\t%14.4f %-12s\t%14.6f\n",
+	   $stage,"","MEASURED",$measuredA,"",$measuredB);
+    if (exists($opt{N})) {
+	printf($out_fh "%-8s %-18s %-10s\t%14.4f %-12s\t%14.6f\n",
+	       $stage,"","MINIMUM",$stage_min{$stage},"",$stage_min{$stage});
     }
 }
