2
#------------------------------------------------------------
3
# Simple script to chop out sub-processes which have a small
4
# impact on the cross section, in the grid pack.
5
# This is meant to be run after the gridpack warming up run
6
# and before packing it up.
8
# The script should be run from the main directory of madevent
9
# and sits in the bin directory.
11
# This is still version 0, where no classes can be defined.
12
# However, the result is a script, chop_procs sitting in
13
# SubProcesses, that can be edited by hand.
15
# Author: Fabio Maltoni
21
# 0.2 Fix bug in writing subproc.mg
23
# 0.1 Added the possibility to list SubProc IDs
27
#------------------------------------------------------------
29
#------------------------------------------------------------
30
# Auxiliary Ordering function
31
#------------------------------------------------------------
34
$all{$a} <=> $all{$b};
37
#------------------------------------------------------------
38
# Input the chopping value. Example : 0.01 = 1%
39
#------------------------------------------------------------
41
print "input chopping off value (e.g., 0.01=1% ):\n";
44
#------------------------------------------------------------
45
# Input the SubProcesses ids on which the script should run
46
#------------------------------------------------------------
48
print "Input SubProcesses ids to process (space separated):\n";
49
@id_list=split('\s+',<STDIN>);
52
#------------------------------------------------------------
53
# Parse the form, look for known variables
54
#------------------------------------------------------------
58
chdir("SubProcesses");
59
open(SCRIPT,">chop_procs") or die "Could not write chop_procs \n";
61
foreach $id (@id_list) {
63
print "\n\nNow processing SubProcesses with ID = $id\n";
65
my @all_Pdirs = <P$id*>;
71
foreach $arg (@all_Pdirs) {
73
open(RES,"<default_results.dat") or die "Could not read default_results.dat\n";
75
my $number_read = read(RES,$buff,12);
76
print "$arg has xsec $buff\n";
78
$xsec = $xsec + $buff;
83
print " total xsec for ID = $id : $xsec\n";
84
$cutoff=$cutoff_lim*$xsec;
85
print " cutoff for ID = $id : $cutoff \n";
88
# now I have to order them and find those procs with fall
93
print "Processes in order FOR ID = $id:\n";
94
foreach $key (sort OrderInc (keys(%all))) {
95
$integ[$i+1] = $integ[$i] + $all{$key};
96
if($integ[$i+1] < $cutoff) {
97
$below{$key} .= $all{$key};
98
print "$integ[$i+1] : $all{$key} $key => below cutoff\n";}
100
print "$integ[$i+1] : $all{$key} $key => above cutoff\n";}
104
# Now I move the corresponding procs out of the way
106
print "The following SubProcess will be tagged to be removed:\n";
107
foreach $key (keys(%below)){
109
print SCRIPT "mv $key XXX$key \# $below{$key}\n";
110
# system("mv $key XXX$key ");
112
# print SCRIPT "ls -d P$id* >subproc.mg\n";
113
# system("ls -d P* >subproc.mg");
115
print SCRIPT "ls -d P* >subproc.mg";
117
system("chmod +x chop_procs");