#!/usr/bin/perl -w
#
# runbbh.pl
# (C) R. Harlander, May 19, 2011.
#
# Example for using slharoutines.pm
# (http://www.robert-harlander.de/software/slharoutines)
#
# Computes the LO, NLO, and NNLO cross section
# for bb->H+X at Higgs masses between 100 and 300 GeV in steps of 10 GeV.
# Call from the source directory of bbh@nnlo.
# (http://www.robert-harlander.de/software/bbh@nnlo)
#
# Usage: copy this file to the directory bbh@nnlo/scripts
# (create it if it does not exist yet), then
# $ cd bbh@nnlo/source
# $ ../scripts/runbbh.pl
# The data will be written to bbh@nnlo/data/run142/order.{0,1,2}/out.*
# Read them using extractbbh.pl from
# http://www.robert-harlander.de/software/bbh@nnlo/scripts/extractbbh.pl
#
# Modify according to your requirements
#
# ----------------------------------------------------------------------
# put the path of slharoutines.pm here:
use lib $ENV{'HOME'}."/perl/modules";
use slharoutines;

# save a copy of the template input file:
system('cp ../infiles/in.init in.tmp');

# compile if necessary:
system("make");

#define a pdf set for each order:
@pdfs = ("MSTW2008lo68cl.LHgrid",
	 "MSTW2008nlo68cl.LHgrid",
	 "MSTW2008nnlo68cl.LHgrid");

$order = 0;
# loop over the parameters:
while ($order<=2) {
    print("order = $order\n");
    changeparam('in.tmp','HNNLO1',1,$order);
    changeparam('in.tmp','HNNLO1',4,"$pdfs[$order]");
    system("mkdir -p ../data/run142/order.$order");
    $mh = 100.;
    $mhcount = 1;
    while ($mh<=300.) {
	changeparam('in.tmp','MASS',25,$mh);
	system('./x.main-lhapdf in.tmp');
	system("mv out.bbh ../data/run142/order.$order/out.$mhcount");
	$mh += 100.;
	$mhcount += 1;
    }
    $order += 1;
}

#EOF
