From 447f66762a95912cc4fccd74993cb736c1144a1b Mon Sep 17 00:00:00 2001 From: Tamara Vazquez Schroeder <tamara.vazquez.schroeder@cern.ch> Date: Tue, 7 Nov 2017 17:29:47 +0000 Subject: [PATCH] Merge branch 'FixHepMCWeightSvc-21.0' into '21.0' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Attempted fix for ATLASSIM-3482: If there is only one attributeList, then just… See merge request !6163 Former-commit-id: a705c7fbabf73cf9c5b3a23fb93d4700125134a6 --- .../SGTools/SGTools/ATLAS_CHECK_THREAD_SAFETY | 0 .../HepMCWeightSvc/src/HepMCWeightSvc.cxx | 26 ++++++++++++------- 2 files changed, 17 insertions(+), 9 deletions(-) mode change 100755 => 100644 Control/SGTools/SGTools/ATLAS_CHECK_THREAD_SAFETY diff --git a/Control/SGTools/SGTools/ATLAS_CHECK_THREAD_SAFETY b/Control/SGTools/SGTools/ATLAS_CHECK_THREAD_SAFETY old mode 100755 new mode 100644 diff --git a/Generators/HepMCWeightSvc/src/HepMCWeightSvc.cxx b/Generators/HepMCWeightSvc/src/HepMCWeightSvc.cxx index 49d91516dcea..6e357b23f557 100644 --- a/Generators/HepMCWeightSvc/src/HepMCWeightSvc.cxx +++ b/Generators/HepMCWeightSvc/src/HepMCWeightSvc.cxx @@ -75,15 +75,23 @@ StatusCode HepMCWeightSvc::loadWeights() { //only look a the first one, assuming it exists, and within that only look at the first channel; if(! (cont->payloadContainer()->size()>0 && cont->payloadContainer()->at(0)->size()>0) ) return StatusCode::FAILURE; - //need to retrieve the EventStreamInfo to get at the channel number - const EventStreamInfo* esi = 0; - CHECK( inputMetaStore->retrieve(esi) ); - if(esi->getEventTypes().size() == 0) return StatusCode::FAILURE; - int chanNum = esi->getEventTypes().begin()->mc_channel_number(); - if(chanNum==0) { - //perhaps channel number not set yet, use the first run number instead - if(esi->getRunNumbers().size()==0) return StatusCode::FAILURE; - chanNum = *esi->getRunNumbers().begin(); + + int chanNum(0); + //if there is only one collection of weights, then we just load that one + if(cont->payloadContainer()->at(0)->size()==1) { + chanNum = cont->payloadContainer()->at(0)->chanNum(0); + } else { + ATH_MSG_DEBUG("Multiple /Generation/Parameters attributeLists found ... using EventStreamInfo to determine which to use"); + //need to retrieve the EventStreamInfo to get at the channel number + const EventStreamInfo* esi = 0; + CHECK( inputMetaStore->retrieve(esi) ); + if(esi->getEventTypes().size() == 0) return StatusCode::FAILURE; + chanNum = esi->getEventTypes().begin()->mc_channel_number(); + if(chanNum==0) { + //perhaps channel number not set yet, use the first run number instead + if(esi->getRunNumbers().size()==0) return StatusCode::FAILURE; + chanNum = *esi->getRunNumbers().begin(); + } } const coral::Attribute& attr = cont->payloadContainer()->at(0)->attributeList(chanNum)["HepMCWeightNames"]; -- GitLab