From c96ccfbe39f9f5f9de8df0e4d03b4e7104bd3acb Mon Sep 17 00:00:00 2001 From: christos <christos@cern.ch> Date: Thu, 1 Apr 2021 21:52:54 +0200 Subject: [PATCH] PhotonEfficiencyCorrection tidy code and add ATLAS_CHECK_THREAD_SAFETY --- .../ATLAS_CHECK_THREAD_SAFETY | 1 + .../AsgPhotonEfficiencyCorrectionTool.h | 4 ++-- .../IAsgPhotonEfficiencyCorrectionTool.h | 13 ------------ .../AsgPhotonEfficiencyCorrectionTool.cxx | 20 +++++++++---------- .../src/testAthenaPhotonAlg.cxx | 4 ++-- .../util/PrintPhotonSF.cxx | 6 +++--- 6 files changed, 18 insertions(+), 30 deletions(-) create mode 100644 PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/ATLAS_CHECK_THREAD_SAFETY delete mode 100644 PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/PhotonEfficiencyCorrection/IAsgPhotonEfficiencyCorrectionTool.h diff --git a/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/ATLAS_CHECK_THREAD_SAFETY b/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/ATLAS_CHECK_THREAD_SAFETY new file mode 100644 index 000000000000..fd67419ce871 --- /dev/null +++ b/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/ATLAS_CHECK_THREAD_SAFETY @@ -0,0 +1 @@ +PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection diff --git a/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/PhotonEfficiencyCorrection/AsgPhotonEfficiencyCorrectionTool.h b/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/PhotonEfficiencyCorrection/AsgPhotonEfficiencyCorrectionTool.h index b768614117ec..fb500318ef1c 100644 --- a/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/PhotonEfficiencyCorrection/AsgPhotonEfficiencyCorrectionTool.h +++ b/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/PhotonEfficiencyCorrection/AsgPhotonEfficiencyCorrectionTool.h @@ -44,7 +44,7 @@ class AsgPhotonEfficiencyCorrectionTool public: /// Standard constructor - AsgPhotonEfficiencyCorrectionTool ( const std::string myname ); + AsgPhotonEfficiencyCorrectionTool ( const std::string& myname ); /// Standard destructor virtual ~AsgPhotonEfficiencyCorrectionTool(); @@ -108,7 +108,7 @@ private: std::string m_sysSubstring; // Get the correction filename from the map - std::string getFileName(std::string isoWP, std::string trigWP, bool isConv); + std::string getFileName(const std::string& isoWP, const std::string& trigWP, bool isConv); // Set prefix of the corresponding calibration filenames: std::string m_file_prefix_ID="offline.Tight"; diff --git a/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/PhotonEfficiencyCorrection/IAsgPhotonEfficiencyCorrectionTool.h b/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/PhotonEfficiencyCorrection/IAsgPhotonEfficiencyCorrectionTool.h deleted file mode 100644 index dcf194cde6ce..000000000000 --- a/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/PhotonEfficiencyCorrection/IAsgPhotonEfficiencyCorrectionTool.h +++ /dev/null @@ -1,13 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -//IAsgPhotonEfficiencyCorrection.h to be used in the tool. -#ifndef __IASGPHOTONEFFICIENCYCORRECTION__ -#define __IASGPHOTONEFFICIENCYCORRECTION__ - -#include "EgammaAnalysisInterfaces/IAsgPhotonEfficiencyCorrectionTool.h" -#pragma message "In the process of moving the Interface part under PhysicsAnalysis/Interfaces/EgammaAnalysisInterfaces" - -#endif - diff --git a/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/Root/AsgPhotonEfficiencyCorrectionTool.cxx b/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/Root/AsgPhotonEfficiencyCorrectionTool.cxx index a3178fe0f472..01f6a32efb86 100644 --- a/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/Root/AsgPhotonEfficiencyCorrectionTool.cxx +++ b/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/Root/AsgPhotonEfficiencyCorrectionTool.cxx @@ -14,10 +14,10 @@ #include "PhotonEfficiencyCorrection/AsgPhotonEfficiencyCorrectionTool.h" // STL includes -#include <string> #include <cfloat> +#include <climits> #include <iostream> -#include <limits.h> +#include <string> // Include the return object #include "PATCore/PATCoreEnums.h" @@ -45,11 +45,11 @@ typedef Root::TPhotonEfficiencyCorrectionTool::Result Result; // ============================================================================= // Standard constructor // ============================================================================= -AsgPhotonEfficiencyCorrectionTool::AsgPhotonEfficiencyCorrectionTool( std::string myname ) : +AsgPhotonEfficiencyCorrectionTool::AsgPhotonEfficiencyCorrectionTool( const std::string& myname ) : AsgTool(myname), - m_rootTool_unc(0), - m_rootTool_con(0), - m_appliedSystematics(0), + m_rootTool_unc(nullptr), + m_rootTool_con(nullptr), + m_appliedSystematics(nullptr), m_sysSubstring("") { @@ -106,11 +106,11 @@ StatusCode AsgPhotonEfficiencyCorrectionTool::initialize() std::vector < std::string > corrFileNameList; // First check if the tool is initialized using the input files or map - if(m_mapFile.size()){ // using map file + if(!m_mapFile.empty()){ // using map file corrFileNameList.push_back(getFileName(m_isoWP,m_trigger,true)); // converted photons input corrFileNameList.push_back(getFileName(m_isoWP,m_trigger,false)); // unconverted photons input } - else if(m_corrFileNameConv.size() && m_corrFileNameUnconv.size()){ // initialize the tool using input files (old scheme) + else if(!m_corrFileNameConv.empty() && !m_corrFileNameUnconv.empty()){ // initialize the tool using input files (old scheme) corrFileNameList.push_back(m_corrFileNameConv); corrFileNameList.push_back(m_corrFileNameUnconv); } @@ -140,7 +140,7 @@ StatusCode AsgPhotonEfficiencyCorrectionTool::initialize() if( corrFileNameList[0].find(m_file_prefix_ID) != std::string::npos) m_sysSubstring="ID_"; if( corrFileNameList[0].find(m_file_prefix_ISO) != std::string::npos) m_sysSubstring="ISO_"; if( corrFileNameList[0].find(m_file_prefix_Trig) != std::string::npos) m_sysSubstring="TRIGGER_"; - if(m_sysSubstring == "") {ATH_MSG_ERROR ( "Invalid input file" ); return StatusCode::FAILURE;} + if(m_sysSubstring.empty()) {ATH_MSG_ERROR ( "Invalid input file" ); return StatusCode::FAILURE;} // Configure the underlying Root tool m_rootTool_con->addFileName( corrFileNameList[0] ); @@ -418,7 +418,7 @@ applySystematicVariation ( const CP::SystematicSet& systConfig ) // Map Key Feature //=============================================================================== // Gets the correction filename from map -std::string AsgPhotonEfficiencyCorrectionTool::getFileName(std::string isoWP, std::string trigWP, bool isConv) { +std::string AsgPhotonEfficiencyCorrectionTool::getFileName(const std::string& isoWP, const std::string& trigWP, bool isConv) { // First locate the map file: std::string mapFileName = PathResolverFindCalibFile( m_mapFile ); diff --git a/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/src/testAthenaPhotonAlg.cxx b/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/src/testAthenaPhotonAlg.cxx index 3c8f8ed6051a..2f0eafc788ef 100644 --- a/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/src/testAthenaPhotonAlg.cxx +++ b/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/src/testAthenaPhotonAlg.cxx @@ -41,7 +41,7 @@ StatusCode testAthenaPhotonAlg::execute() { //---------------------------- // Event information //--------------------------- - const xAOD::EventInfo* eventInfo = 0; //NOTE: Everything that comes from the storegate direct from the input files is const! + const xAOD::EventInfo* eventInfo = nullptr; //NOTE: Everything that comes from the storegate direct from the input files is const! // ask the event store to retrieve the xAOD EventInfo container //ATH_CHECK( evtStore()->retrieve( eventInfo, "EventInfo") ); // the second argument ("EventInfo") is the key name @@ -59,7 +59,7 @@ StatusCode testAthenaPhotonAlg::execute() { //--------- // photons //--------- - const xAOD::PhotonContainer* photons = 0; + const xAOD::PhotonContainer* photons = nullptr; ATH_CHECK( evtStore()->retrieve( photons, "Photons") ); ATH_MSG_DEBUG("Found "<<photons->size() <<" photons in event, itterate...."); diff --git a/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/util/PrintPhotonSF.cxx b/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/util/PrintPhotonSF.cxx index f0f5e1f12d45..0576a441b11b 100644 --- a/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/util/PrintPhotonSF.cxx +++ b/PhysicsAnalysis/ElectronPhotonID/PhotonEfficiencyCorrection/util/PrintPhotonSF.cxx @@ -5,10 +5,10 @@ //michael.pitt@cern.ch // System include(s): -#include <stdio.h> +#include <boost/filesystem.hpp> +#include <cstdio> #include <cstdlib> #include <iostream> -#include <boost/filesystem.hpp> // ROOT ide(s): #include "TFile.h" @@ -67,7 +67,7 @@ int main (int argc, const char * argv[]) { // read first run number from the directory name: int run_number = atoi(dirName.Tokenize("_")->First()->GetName()); - if(getenv("ROOTCOREDIR")==NULL){ + if(getenv("ROOTCOREDIR")==nullptr){ cout << "Please setup RootCore before running the PrintPhotonSF [file]"<<endl; return 0.; } -- GitLab