diff --git a/Generators/Sherpa_i/CMakeLists.txt b/Generators/Sherpa_i/CMakeLists.txt index a237c46ea1b309496a3cbbfcf88e06d5dad2f65f..cb25a0e43d52120239e9ad80a17af98011211690 100644 --- a/Generators/Sherpa_i/CMakeLists.txt +++ b/Generators/Sherpa_i/CMakeLists.txt @@ -6,27 +6,34 @@ atlas_subdir( Sherpa_i ) # Declare the package's dependencies: -atlas_depends_on_subdirs( - PUBLIC - GaudiKernel - Generators/GeneratorModules - Generators/TruthUtils - PRIVATE - Control/AthenaBaseComps - Control/AthenaKernel ) +atlas_depends_on_subdirs( PUBLIC + GaudiKernel + Generators/GeneratorModules + Generators/TruthUtils + PRIVATE + Control/AthenaBaseComps + Control/AthenaKernel ) + +# Set the version of Sherpa to use: +#set( SHERPA_VERSION 2.2.2 ) +#set( SHERPA_ROOT +# ${LCG_RELEASE_DIR}/MCGenerators/sherpa/${SHERPA_VERSION}/${ATLAS_PLATFORM} ) # External dependencies: find_package( CLHEP ) find_package( HepMC ) -find_package( Sherpa COMPONENTS SherpaTools SherpaInitialization ) +find_package( Sherpa COMPONENTS SherpaTools ) # Remove the --as-needed linker flags: atlas_disable_as_needed() # Component(s) in the package: atlas_add_component( Sherpa_i - Sherpa_i/*.h src/*.cxx src/components/*.cxx - INCLUDE_DIRS ${CLHEP_INCLUDE_DIRS} ${HEPMC_INCLUDE_DIRS} - ${SHERPA_INCLUDE_DIRS} - LINK_LIBRARIES ${CLHEP_LIBRARIES} ${HEPMC_LIBRARIES} ${SHERPA_LIBRARIES} - GaudiKernel GeneratorModulesLib TruthUtils AthenaBaseComps AthenaKernel ) + src/*.cxx + src/components/*.cxx + INCLUDE_DIRS ${CLHEP_INCLUDE_DIRS} ${HEPMC_INCLUDE_DIRS} ${SHERPA_INCLUDE_DIRS} + LINK_LIBRARIES ${CLHEP_LIBRARIES} ${HEPMC_LIBRARIES} ${SHERPA_LIBRARIES} GaudiKernel GeneratorModulesLib TruthUtils AthenaBaseComps AthenaKernel ) + +# Install files from the package: +atlas_install_headers( Sherpa_i ) + diff --git a/Generators/Sherpa_i/Sherpa_i/Sherpa_i.h b/Generators/Sherpa_i/Sherpa_i/Sherpa_i.h index 27be67d95ef9ed5552a34eba57183d44a0442a2e..395903d6ac27c45c79581c18ca9b5c0cca457b93 100644 --- a/Generators/Sherpa_i/Sherpa_i/Sherpa_i.h +++ b/Generators/Sherpa_i/Sherpa_i/Sherpa_i.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ #ifndef SHERPA_I_SHERPA_I_H @@ -31,10 +31,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; }; diff --git a/Generators/Sherpa_i/src/Sherpa_i.cxx b/Generators/Sherpa_i/src/Sherpa_i.cxx index 4cbc17298018177c5f773d2cd54123059df65b3f..22fb0b6642fc6cea69e69565fb5beaab56ff67ff 100644 --- a/Generators/Sherpa_i/src/Sherpa_i.cxx +++ b/Generators/Sherpa_i/src/Sherpa_i.cxx @@ -1,7 +1,6 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ - #include "HepMC/GenEvent.h" #include "GaudiKernel/MsgStream.h" #include "AthenaBaseComps/AthMsgStreamMacros.h" @@ -17,6 +16,7 @@ #include <cstdio> #include <cstring> +#include <signal.h> #include "CLHEP/Random/RandFlat.h" #include "AthenaKernel/IAtRndmGenSvc.h" @@ -25,10 +25,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 +69,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 +116,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 @@ -164,10 +138,15 @@ StatusCode Sherpa_i::genFinalize() { std::cout << "MetaData: PDF = " << p_sherpa->PDFInfo() << std::endl; std::cout << "Named variations initialised by Sherpa:" << std::endl; - std::cout << *p_sherpa->GetInitHandler()->GetVariations() << std::endl; + std::cout << "MN: disabled output because of CI link failure. REVERT once fixed. *p_sherpa->GetInitHandler()->GetVariations()" << std::endl; 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 +156,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 +189,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]; diff --git a/Projects/Athena/externals/Lhapdf.cmake b/Projects/Athena/externals/Lhapdf.cmake index ca1ff7347c834f5aa5332a27c65de080197004cf..3eb6fa66064be4ac0d0fbcbbcb5ed590616338f3 100644 --- a/Projects/Athena/externals/Lhapdf.cmake +++ b/Projects/Athena/externals/Lhapdf.cmake @@ -2,6 +2,6 @@ # File specifying the location of Lhapdf to use. # -set( LHAPDF_VERSION 6.1.6 ) +set( LHAPDF_VERSION 6.2.1 ) set( LHAPDF_ROOT ${LCG_RELEASE_DIR}/MCGenerators/lhapdf/${LHAPDF_VERSION}/${LCG_PLATFORM} ) diff --git a/Projects/Athena/externals/Sherpa.cmake b/Projects/Athena/externals/Sherpa.cmake index 284ecfeb0451daadfbe363ea0d1de142073e41d8..1a89135be3b911e601e82aa5414dfc3f13bea21b 100644 --- a/Projects/Athena/externals/Sherpa.cmake +++ b/Projects/Athena/externals/Sherpa.cmake @@ -2,6 +2,6 @@ # File specifying the location of Sherpa to use. # -set( SHERPA_VERSION 2.2.1 ) +set( SHERPA_VERSION 2.2.5 ) set( SHERPA_ROOT ${LCG_RELEASE_DIR}/MCGenerators/sherpa/${SHERPA_VERSION}/${LCG_PLATFORM} )