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

Merge branch '21.6-sherpa-output-level' into '21.6'

Sherpa_i: restructure input-file passing and propagate output level

See merge request atlas/athena!46748
parents 5b7e5e8a 70a38c6c
No related branches found
No related tags found
No related merge requests found
...@@ -31,11 +31,8 @@ protected: ...@@ -31,11 +31,8 @@ protected:
SHERPA::Sherpa * p_sherpa; SHERPA::Sherpa * p_sherpa;
/// Sherpa base settings (read from base fragment file) /// Sherpa base settings (read from base fragment file) and run card snippet (from JO file)
std::string m_basefragment; std::map<std::string,std::string> m_inputfiles;
/// Sherpa run card snippet (from JO file)
std::string m_runcard;
/// List of needed OpenLoops process libraries (from JO file) /// List of needed OpenLoops process libraries (from JO file)
std::vector<std::string> m_openloopslibs; std::vector<std::string> m_openloopslibs;
......
...@@ -27,8 +27,8 @@ CLHEP::HepRandomEngine* p_rndEngine; ...@@ -27,8 +27,8 @@ CLHEP::HepRandomEngine* p_rndEngine;
Sherpa_i::Sherpa_i(const std::string& name, ISvcLocator* pSvcLocator) Sherpa_i::Sherpa_i(const std::string& name, ISvcLocator* pSvcLocator)
: GenModule(name, pSvcLocator), p_sherpa(NULL) : GenModule(name, pSvcLocator), p_sherpa(NULL)
{ {
declareProperty("BaseFragment", m_basefragment = ""); declareProperty("BaseFragment", m_inputfiles["Base.yaml"] = "");
declareProperty("RunCard", m_runcard = ""); declareProperty("RunCard", m_inputfiles["Sherpa.yaml"] = "");
declareProperty("OpenLoopsLibs", m_openloopslibs); declareProperty("OpenLoopsLibs", m_openloopslibs);
declareProperty("ExtraFiles", m_extrafiles); declareProperty("ExtraFiles", m_extrafiles);
declareProperty("NCores", m_ncores=1); declareProperty("NCores", m_ncores=1);
...@@ -43,28 +43,44 @@ Sherpa_i::Sherpa_i(const std::string& name, ISvcLocator* pSvcLocator) ...@@ -43,28 +43,44 @@ Sherpa_i::Sherpa_i(const std::string& name, ISvcLocator* pSvcLocator)
StatusCode Sherpa_i::genInitialize(){ StatusCode Sherpa_i::genInitialize(){
ATH_MSG_INFO("Sherpa initialising... ");
for(auto& inputfile : m_inputfiles) {
// remove first line and last character containing '"'
// TODO fix Python/C++ string passing, to not contain " in first place
inputfile.second.erase(0, inputfile.second.find("\n") + 1);
inputfile.second.pop_back();
}
ATH_MSG_DEBUG("... compiling plugin code");
if (m_plugincode != "") { if (m_plugincode != "") {
compilePlugin(m_plugincode); compilePlugin(m_plugincode);
m_basefragment += "SHERPA_LDADD: Sherpa_iPlugin \n"; m_inputfiles["Base.yaml"] += "SHERPA_LDADD: Sherpa_iPlugin \n";
} }
ATH_MSG_INFO("Sherpa initialising...");
ATH_MSG_DEBUG("... seeding Athena random number generator");
p_rndEngine = atRndmGenSvc().GetEngine("SHERPA"); p_rndEngine = atRndmGenSvc().GetEngine("SHERPA");
const long* sip = p_rndEngine->getSeeds(); const long* sip = p_rndEngine->getSeeds();
long int si1 = sip[0]; long int si1 = sip[0];
long int si2 = sip[1]; long int si2 = sip[1];
atRndmGenSvc().CreateStream(si1, si2, "SHERPA"); atRndmGenSvc().CreateStream(si1, si2, "SHERPA");
std::map<std::string,std::string> inputfiles; ATH_MSG_DEBUG("... adapting output level");
inputfiles["Base.yaml"] = m_basefragment; if( msg().level()==MSG::FATAL || msg().level()==MSG::ERROR || msg().level()==MSG::WARNING ){
inputfiles["Sherpa.yaml"] = m_runcard; m_inputfiles["Base.yaml"] += "EVT_OUTPUT: 0 \n";
for(auto& inputfile : inputfiles) { }
// remove first line and last character containing '"' else if(msg().level()==MSG::INFO){
// TODO fix Python/C++ string passing, cf. also below m_inputfiles["Base.yaml"] += "EVT_OUTPUT: 2 \n";
inputfile.second.erase(0, inputfile.second.find("\n") + 1); }
inputfile.second.pop_back(); else if(msg().level()==MSG::DEBUG){
m_inputfiles["Base.yaml"] += "EVT_OUTPUT: 15 \n";
}
else{
m_inputfiles["Base.yaml"] += "EVT_OUTPUT: 15 \n";
}
ATH_MSG_DEBUG("... writing input files to directory");
for(auto& inputfile : m_inputfiles) {
// write input content to file in working directory // write input content to file in working directory
FILE *file = fopen(inputfile.first.c_str(),"w"); FILE *file = fopen(inputfile.first.c_str(),"w");
fputs(inputfile.second.c_str(),file); fputs(inputfile.second.c_str(),file);
...@@ -73,6 +89,7 @@ StatusCode Sherpa_i::genInitialize(){ ...@@ -73,6 +89,7 @@ StatusCode Sherpa_i::genInitialize(){
ATH_MSG_INFO("\n"+inputfile.second+"\n"); ATH_MSG_INFO("\n"+inputfile.second+"\n");
} }
ATH_MSG_DEBUG("... go Sherpa!");
int argc = 2; int argc = 2;
char** argv = new char*[2]; char** argv = new char*[2];
argv[0] = new char[7]; argv[0] = new char[7];
......
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