Skip to content
Snippets Groups Projects
Commit 25a75e34 authored by cranshaw's avatar cranshaw
Browse files

Fix two problems with thread/slot safety in the CutFlowSvc

- Move the reading of EventInfo weights to the only client
  AthFilterAlgorithm
- add a mutex to the addEvent method called by AthFilterAlgorithm
parent 6af7bfb3
9 merge requests!58791DataQualityConfigurations: Modify L1Calo config for web display,!46784MuonCondInterface: Enable thread-safety checking.,!46776Updated LArMonitoring config file for WD to match new files produced using MT,!45405updated ART test cron job,!42417Draft: DIRE and VINCIA Base Fragments for Pythia 8.3,!28528Revert 63f845ae,!27054Atr20369 210,!26342Monopole: Handle fractionally charged particles,!20019Fix two problems with thread/slot safety in the CutFlowSvc
......@@ -102,23 +102,20 @@ AthFilterAlgorithm::setFilterPassed( bool state ) const
AthAlgorithm::setFilterPassed(state);
if (state) {
/*
double evtWeight=1.0;
const xAOD::EventInfo* evtInfo = 0;
const xAOD::EventInfo* evtInfo = nullptr;
StatusCode sc = evtStore()->retrieve(evtInfo);
if ( sc.isFailure() || NULL == evtInfo ) {
ATH_MSG_WARNING("Could not retrieve EventInfo from StoreGate ");
ATH_MSG_ERROR("Could not retrieve xAOD::EventInfo from StoreGate ");
evtWeight=-1000.;
} else {
// Only try to access the mcEventWeight is we are running on Monte Carlo, duhhh!
// Only try to access the mcEventWeight if we are running on Monte Carlo, duhhh!
if ( evtInfo->eventType(xAOD::EventInfo::IS_SIMULATION) ) {
evtWeight = evtInfo->mcEventWeight();
}
}
m_cutFlowSvc->addEvent(m_cutID,evtWeight);
*/
m_cutFlowSvc->addEvent(m_cutID);
}
}
......
......@@ -93,18 +93,6 @@ public:
/// using CutIdentifier returned by selfRegisterFilter or registerCut
virtual void addEvent( CutIdentifier cutID, double weight) = 0;
/// Get a CutBookkeeper given a CutID
// virtual xAOD::CutBookkeeper* getCutBookkeeper( const CutIdentifier cutID ) = 0;
/// Helper function for D3PDs, dumps the CutFlowSvc content into a flat TTree.
/// The returned TTree is owned by the caller and can be eventually written by the caller in its favorite output TFile.
//virtual TTree* dumpCutFlowToTTree( const char* treeName="CutFlowTree" ) = 0;
/// Inverse of above DumpCutFlowToTTree: when reading a D3PD, re-interpret the flat TTree to a usual transient EventBookkeeperCollection.
/// This should be the only method able to read flat TTrees, the other CutFlowSvc functionalities always work with EventBookkeepers.
/// The produced EventBookkeeperCollection remains internal to the CutFlowSvc, users can manipulate it using the usual ICutFlowSvc interface.
//virtual void loadCutFlowFromTTree( TTree* t ) = 0;
/// Gaudi boilerplate
static const InterfaceID& interfaceID();
......
......@@ -318,9 +318,10 @@ void
CutFlowSvc::addEvent( CutIdentifier cutID )
{
ATH_MSG_INFO("calling addEvent(" << cutID << ")" );
ATH_MSG_WARNING("DEPRECATED method, please call addEvent(ID,weight)");
double evtWeight=1.0;
/*
const xAOD::EventInfo* evtInfo = nullptr;
StatusCode sc = m_eventStore->retrieve(evtInfo);
if ( sc.isFailure() || nullptr == evtInfo ) {
......@@ -332,6 +333,7 @@ CutFlowSvc::addEvent( CutIdentifier cutID )
evtWeight = evtInfo->mcEventWeight();
}
}
*/
addEvent(cutID,evtWeight);
......@@ -345,6 +347,7 @@ CutFlowSvc::addEvent( CutIdentifier cutID, double weight)
{
ATH_MSG_INFO("calling addEvent(" << cutID << ", " << weight << ")" );
std::lock_guard<std::recursive_mutex> lock(m_addeventMutex);
// Create bookkeeper container for bookkeepers in _this_ processing
xAOD::CutBookkeeperContainer* fileBook = nullptr;
if (m_outMetaDataStore->retrieve(fileBook,m_fileCollName).isFailure()) {
......@@ -545,7 +548,7 @@ CutFlowSvc::recordCollection( xAOD::CutBookkeeperContainer * coll,
xAOD::CutBookkeeper*
CutFlowSvc::getCutBookkeeper( const CutIdentifier cutID ) {
CutFlowSvc::getCutBookkeeper( const CutIdentifier cutID ) const {
xAOD::CutBookkeeperContainer* fileBook = nullptr;
if (m_outMetaDataStore->retrieve(fileBook,m_fileCollName).isFailure()) {
ATH_MSG_ERROR("Could not retrieve handle to cutflowsvc bookkeeper");
......
......@@ -22,6 +22,7 @@
// STL includes
#include <string>
#include <vector>
#include <mutex>
// FrameWork includes
#include "GaudiKernel/ISvcLocator.h"
......@@ -127,7 +128,7 @@ public:
void addEvent( CutIdentifier cutID, double weight ) override final;
/// Get a CutBookkeeper given a CutID
xAOD::CutBookkeeper* getCutBookkeeper( const CutIdentifier cutID );
xAOD::CutBookkeeper* getCutBookkeeper( const CutIdentifier cutID ) const;
void print();
......@@ -175,6 +176,8 @@ private:
/// to the pointer of associated CutBookkeeper
CutIDMap_t m_ebkMap;
mutable std::recursive_mutex m_addeventMutex;
public:
/// Publish the interface for this service
......
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