Skip to content
Snippets Groups Projects
Commit 9b62c3c7 authored by Walter Lampl's avatar Walter Lampl
Browse files

DRAW_ZMUMU_SkimmingTool: ReadHandle, atomic counters, range-based for loop

parent f4935c90
No related branches found
No related tags found
6 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,!41782MT migration of DRAW_ZMUMU_SkimmingTool
/*
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/
///////////////////////////////////////////////////////////////////
......@@ -17,6 +17,7 @@
// DerivationFramework includes
#include "DerivationFrameworkInterfaces/ISkimmingTool.h"
#include "MuonAnalysisInterfaces/IMuonSelectionTool.h"
#include "xAODMuon/MuonContainer.h"
namespace DerivationFramework {
......@@ -44,9 +45,10 @@ namespace DerivationFramework {
virtual bool eventPassesFilter() const;
private:
mutable unsigned int m_ntot;
mutable unsigned int m_npass;
std::string m_muonSGKey;
mutable std::atomic<unsigned int> m_ntot{0};
mutable std::atomic<unsigned int> m_npass{0};
SG::ReadHandleKey<xAOD::MuonContainer> m_muonSGKey{this,"MuonContainerKey","Muons"};
ToolHandle<CP::IMuonSelectionTool> m_muonSelectionTool;
unsigned int m_nMuons;
double m_muonPtCut;
......
/*
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/
/////////////////////////////////////////////////////////////////
......@@ -11,7 +11,6 @@
// muons. Inherits from derivation framework components.
#include "PrimaryDPDMaker/DRAW_ZMUMUSkimmingTool.h"
#include "xAODMuon/MuonContainer.h"
#include <vector>
#include <string>
......@@ -20,15 +19,11 @@ DerivationFramework::DRAW_ZMUMUSkimmingTool::DRAW_ZMUMUSkimmingTool( const std::
const std::string& n,
const IInterface* p ) :
AthAlgTool(t,n,p),
m_ntot(0),
m_npass(0),
m_muonSGKey("Muons"),
m_muonSelectionTool("CP::MuonSelectionTool/MuonSelectionTool"),
m_nMuons(1),
m_muonPtCut(20.0)
{
declareInterface<DerivationFramework::ISkimmingTool>(this);
declareProperty("MuonContainerKey", m_muonSGKey);
declareProperty("MuonSelectorTool", m_muonSelectionTool);
declareProperty("MinimumNumberOfMuons", m_nMuons);
declareProperty("MuonPtCut", m_muonPtCut);
......@@ -42,6 +37,7 @@ DerivationFramework::DRAW_ZMUMUSkimmingTool::~DRAW_ZMUMUSkimmingTool() {
StatusCode DerivationFramework::DRAW_ZMUMUSkimmingTool::initialize()
{
ATH_MSG_VERBOSE("initialize() ...");
ATH_CHECK(m_muonSGKey.initialize());
return StatusCode::SUCCESS;
}
StatusCode DerivationFramework::DRAW_ZMUMUSkimmingTool::finalize()
......@@ -56,19 +52,11 @@ bool DerivationFramework::DRAW_ZMUMUSkimmingTool::eventPassesFilter() const
{
++m_ntot;
// Retrieve muon container
const xAOD::MuonContainer* muons(0);
StatusCode sc = evtStore()->retrieve(muons,m_muonSGKey);
if (sc.isFailure()) {
ATH_MSG_ERROR("No muon collection with name " << m_muonSGKey << " found in StoreGate!");
return(false);
}
SG::ReadHandle<xAOD::MuonContainer> muons{m_muonSGKey};
// Loop over muons, count up and set decision
xAOD::MuonContainer::const_iterator muItr;
unsigned int nGoodMu(0);
for (muItr=muons->begin(); muItr!=muons->end(); ++muItr) {
if ( m_muonSelectionTool->accept(**muItr) && (*muItr)->pt() > m_muonPtCut ) ++nGoodMu;
for (const xAOD::Muon* muItr : *muons) {
if ( m_muonSelectionTool->accept(*muItr) && muItr->pt() > m_muonPtCut ) ++nGoodMu;
}
bool acceptEvent(false);
if (nGoodMu >= m_nMuons) {
......
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