Skip to content

Commit

Permalink
Merge pull request #2986 from bendavid/amcatnloprod53x
Browse files Browse the repository at this point in the history
Changes to allow aMC@NLO production with ExternalLHEProducer (53x)
  • Loading branch information
smuzaffar committed Mar 25, 2014
2 parents 6da7ca6 + 7d2c561 commit 871e8d6
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 10 deletions.
99 changes: 99 additions & 0 deletions GeneratorInterface/LHEInterface/data/run_amcatnlo_tarball.sh
@@ -0,0 +1,99 @@
#!/bin/bash

#set -o verbose

echo " ______________________________________ "
echo " Running Madgraph5 "
echo " ______________________________________ "

repo=${1}
echo "%MSG-MG5 repository = $repo"

name=${2}
echo "%MSG-MG5 gridpack = $name"

nevt=${3}
echo "%MSG-MG5 number of events requested = $nevt"

rnum=${4}
echo "%MSG-MG5 random seed used for the run = $rnum"

LHEWORKDIR=`pwd`

if [[ -d madevent ]]
then
echo 'madevent directory found'
echo 'Setting up the environment'
rm -rf madevent
fi
mkdir madevent; cd madevent

# retrieve the wanted gridpack from the official repository
fn-fileget -c `cmsGetFnConnect frontier://smallfiles` ${repo}/${name}_tarball.tar.gz
#cp -p /afs/cern.ch/work/b/bendavid/CMSSWgen62/genproductions/bin/aMCatNLO/${name}_tarball.tar.gz ./

#check the structure of the tarball
tar xzf ${name}_tarball.tar.gz ; rm -f ${name}_tarball.tar.gz ;

# force the f77 compiler to be the CMS defined one
ln -sf `which gfortran` f77
ln -sf `which gfortran` g77
PATH=`pwd`:${PATH}

cd mgbasedir/${name}

#replace the seed in the run card with ${rnum}
sed -i "s#[0-9]\+ *= *iseed# ${rnum} = iseed#g" Cards/run_card.dat

#replace the number of events in the run_card
sed -i "s#[0-9]\+ *= *nevents# ${nevt} = nevents#g" Cards/run_card.dat

run_card_seed=`fgrep "${rnum} = iseed" Cards/run_card.dat | awk '{print $1}'`
run_card_nevents=`fgrep "${nevt} = nevents" Cards/run_card.dat | awk '{print $1}'`

if [[ $run_card_seed -eq $rnum ]] ;then
echo "run_card_seed = ${run_card_seed}"
else
echo "%MSG-MG5 Error: Seed numbers $run_card_seed doesnt match ( $rnum )"
exit 1
fi

if [[ $run_card_nevents -eq $nevt ]] ;then
echo "run_card_nevents = ${run_card_nevents}"
else
echo "%MSG-MG5 Error: Number of events $run_card_nevents doesnt match ( $nevt )"
exit 1
fi

if [ -f Cards/madspin_card.dat ] ;then
#set random seed for madspin
rnum2=$(($rnum+1000000))
sed -i "s#\# set seed 1# set seed ${rnum2}#g" Cards/madspin_card.dat
madspin_card_seed=`fgrep " set seed ${rnum2}" Cards/madspin_card.dat | awk '{print $3}'`
if [[ $madspin_card_seed -eq $rnum2 ]] ;then
echo "madevent seed = $rnum, madspin seed = $rnum2, madspin_card_seed = $madspin_card_seed"
else
echo "%MSG-MG5 Error: Madspin seed $madspin_card_seed doesnt match ( $rnum2 )"
exit 1
fi
fi

#generate events
bin/generate_events -fox -n ${name}

if [[ -d Events/${name}_decayed_1 ]]
then
mv Events/${name}_decayed_1/events.lhe.gz $LHEWORKDIR/${name}_final.lhe.gz
else
mv Events/${name}/events.lhe.gz $LHEWORKDIR/${name}_final.lhe.gz
fi

cd $LHEWORKDIR
gzip -d ${name}_final.lhe.gz
#cp ${name}_final.lhe ${name}_final.lhe.bak

ls -l
echo

exit 0

9 changes: 0 additions & 9 deletions GeneratorInterface/LHEInterface/src/LHEEvent.cc
Expand Up @@ -104,15 +104,6 @@ LHEEvent::LHEEvent(const boost::shared_ptr<LHERunInfo> &runInfo,
} else
continue;
}
size_t found = line.find("amcatnlo");
double NEVT = 1.0;
if ( found != std::string::npos) {
std::string avalue = line.substr(found+1,line.size());
found = avalue.find("_");
avalue = avalue.substr(found+1,avalue.size());
NEVT = atof(avalue.c_str());
}
hepeup.XWGTUP = hepeup.XWGTUP*NEVT;
comments.push_back(line + "\n");
}

Expand Down
6 changes: 5 additions & 1 deletion SimDataFormats/GeneratorProducts/src/LHERunInfoProduct.cc
Expand Up @@ -239,7 +239,11 @@ bool LHERunInfoProduct::mergeProduct(const LHERunInfoProduct &other)
if (header->tag() == "" ||
header->tag().find("Alpgen") == 0 ||
header->tag() == "MGGridCard" ||
header->tag() == "MGGenerationInfo") {
header->tag() == "MGGenerationInfo" ||
header->tag() == "MGRunCard" ||
header->tag() == "mgruncard" ||
header->tag() == "MadSpin" ||
header->tag() == "madspin") {
addHeader(*header);
headers.insert(*header);
} else
Expand Down

0 comments on commit 871e8d6

Please sign in to comment.