Skip to content
Snippets Groups Projects
Commit 4fb31d6d authored by Ewelina Maria Lobodzinska's avatar Ewelina Maria Lobodzinska
Browse files

update Sherpa to version 2.2.4

update interface to changes from Sherpa_i-02-02-03
        * Remove obsolete Sherpa 2.2.1 workaround for weight variations.
        * Remove parameters which should live in Sherpa_2.2.4_Base_Fragment.py in the future.
        * Remove rarely used option to automatically compile Sherpa process libraries -- this may use afs (depending on Genser installation) and thus should never happen automatically on the Grid but rather fail.
        * Introduce a few new properties which can be set from the JO and will come in handy for the automatic input tarball creator and for fixing AGENE-643. Everything is still backward compatible with old JOs.
parent c648c7e2
No related branches found
No related tags found
No related merge requests found
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef SHERPA_I_SHERPA_I_H
#define SHERPA_I_SHERPA_I_H
......@@ -31,10 +27,26 @@ protected:
SHERPA::Sherpa * p_sherpa;
std::string m_path;
/// Sherpa run card snippet (from JO file)
std::string m_runcard;
/// List of additional Sherpa parameters beyond run card snippet (from JO file)
std::vector<std::string> m_params;
/// List of needed OpenLoops process libraries (from JO file)
std::vector<std::string> m_openloopslibs;
/// List of any additional needed files, e.g. custom libraries, PDF sets (from JO file)
std::vector<std::string> m_extrafiles;
/// Number of cores recommended for multi-core integration file
int m_ncores;
/// Memory required for integration/evgen
double m_memorymb;
double m_xsscale;
std::string m_scalevarref;
bool m_cleanup;
};
......
include("MC15JobOptions/Sherpa_NNPDF30NNLO_Common.py")
include("MC15JobOptions/Sherpa_2.2.2_NNPDF30NNLO_Common.py")
evgenConfig.description = "Sherpa 2.2.x example JO, Z+0,1-jet production."
evgenConfig.keywords = [ "Example", "DrellYan" ]
evgenConfig.keywords = [ "2lepton" ]
evgenConfig.contact = [ "atlas-generators-sherpa@cern.ch", "frank.siegert@cern.ch"]
sherpaRunCard="""
genSeq.Sherpa_i.RunCard="""
(processes){
Process 93 93 -> 11 -11 93{1}
Order (*,2)
......@@ -16,3 +16,10 @@ sherpaRunCard="""
Mass 11 -11 40 E_CMS
}(selector)
"""
genSeq.Sherpa_i.Parameters = []
genSeq.Sherpa_i.OpenLoopsLibs = []
genSeq.Sherpa_i.ExtraFiles = []
genSeq.Sherpa_i.NCores = 1
genSeq.Sherpa_i.CleanupGeneratedFiles = 1
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#include "HepMC/GenEvent.h"
#include "GaudiKernel/MsgStream.h"
#include "AthenaBaseComps/AthMsgStreamMacros.h"
......@@ -25,10 +21,15 @@ CLHEP::HepRandomEngine* p_rndEngine;
Sherpa_i::Sherpa_i(const std::string& name, ISvcLocator* pSvcLocator)
: GenModule(name, pSvcLocator), p_sherpa(NULL)
{
declareProperty("RunPath", m_path = ".");
declareProperty("RunCard", m_runcard = "");
declareProperty("Parameters", m_params);
declareProperty("OpenLoopsLibs", m_openloopslibs);
declareProperty("ExtraFiles", m_extrafiles);
declareProperty("NCores", m_ncores=1);
declareProperty("MemoryMB", m_memorymb=2500.);
declareProperty("CrossSectionScaleFactor", m_xsscale=1.0);
declareProperty("ScaleVariationReference", m_scalevarref="MUR1_MUF1_PDF261000");
declareProperty("CleanupGeneratedFiles", m_cleanup=false);
}
......@@ -64,40 +65,24 @@ StatusCode Sherpa_i::genInitialize(){
getParameters(argc, argv);
p_sherpa->InitializeTheRun(argc,(char **)argv);
delete [] argv;
p_sherpa->InitializeTheEventHandler();
}
catch (ATOOLS::Exception exception) {
if (exception.Class()=="Matrix_Element_Handler" && exception.Type()==ATOOLS::ex::normal_exit) {
delete p_sherpa;
ATH_MSG_INFO("Have to compile Amegic libraries");
std::string tmp="cd "+m_path+"; ./makelibs && cd -;";
int stat = system(tmp.c_str());
if (stat==0) {
ATH_MSG_INFO("Finished compiling Amegic libraries");
}
else {
ATH_MSG_ERROR("Error while compiling Amegic libraries.");
return StatusCode::FAILURE;
}
int argc;
char** argv;
getParameters(argc, argv);
p_sherpa = new SHERPA::Sherpa();
p_sherpa->InitializeTheRun(argc,(char **)argv);
delete [] argv;
ATH_MSG_ERROR("Have to compile Amegic libraries");
ATH_MSG_ERROR("You probably want to run ./makelibs");
}
else {
ATH_MSG_ERROR("Unwanted ATOOLS::exception caught.");
ATH_MSG_ERROR(exception);
return StatusCode::FAILURE;
}
return StatusCode::FAILURE;
}
catch (std::exception exception) {
ATH_MSG_ERROR("std::exception caught.");
return StatusCode::FAILURE;
}
p_sherpa->InitializeTheEventHandler();
return StatusCode::SUCCESS;
}
......@@ -127,21 +112,6 @@ StatusCode Sherpa_i::fillEvt(HepMC::GenEvent* event) {
if (i==0 || i>3) event->weights()[i] /= weight_normalisation;
ATH_MSG_DEBUG("Sherpa WEIGHT " << i << " value="<< event->weights()[i]);
}
// workaround according to https://sherpa.hepforge.org/trac/ticket/365
if (event->weights().has_key(m_scalevarref)) {
double correction_factor = event->weights()[0] / event->weights()[m_scalevarref];
if (correction_factor != 1.0) {
ATH_MSG_DEBUG("correction_factor = " << correction_factor);
for (size_t i=4; i<event->weights().size(); ++i) {
event->weights()[i] *= correction_factor;
}
}
}
else {
ATH_MSG_DEBUG("No weight with key " << m_scalevarref);
}
}
GeVToMeV(event); //unit check
......@@ -168,6 +138,11 @@ StatusCode Sherpa_i::genFinalize() {
p_sherpa->SummarizeRun();
delete p_sherpa;
if (m_cleanup) {
ATH_MSG_INFO("Deleting left-over files from working directory.");
system("rm -rf Results.db Process MIG_*.db MPI_*.dat libSherpa*.so libProc*.so");
}
return StatusCode::SUCCESS;
}
......@@ -177,11 +152,7 @@ void Sherpa_i::getParameters(int &argc, char** &argv) {
std::vector<std::string> params;
// set some ATLAS specific default values as a starting point
params.push_back("PATH="+m_path);
params.push_back("EXTERNAL_RNG=Atlas_RNG");
params.push_back("MAX_PROPER_LIFETIME=10.0");
params.push_back("BEAM_1=2212");
params.push_back("BEAM_2=2212");
/***
Adopt Atlas Debug Level Scheme
......@@ -214,6 +185,7 @@ void Sherpa_i::getParameters(int &argc, char** &argv) {
strcpy(argv[0], "Sherpa");
ATH_MSG_INFO("Sherpa_i using the following Arguments");
ATH_MSG_INFO(m_runcard);
for(size_t i=0; i<params.size(); i++) {
ATH_MSG_INFO(" [ " << params[i] << " ] ");
argv[i+1] = new char[params[i].size()+1];
......
......@@ -2,6 +2,6 @@
# File specifying the location of Sherpa to use.
#
set( SHERPA_VERSION 2.2.1 )
set( SHERPA_VERSION 2.2.4 )
set( SHERPA_ROOT
${LCG_RELEASE_DIR}/MCGenerators/sherpa/${SHERPA_VERSION}/${LCG_PLATFORM} )
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment