ATLAS Offline Software
JetSorter.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "JetRec/JetSorter.h"
6 
8 // Comparison functions
9 bool ptCompare(const xAOD::Jet* j1, const xAOD::Jet* j2){ return j1->pt() > j2->pt() ;}
10 
11 // A global map for comparison functions
12 using compFunc = bool (*)(const xAOD::Jet *, const xAOD::Jet *);
13 const std::map<std::string, compFunc> g_compFuncMap = {
14  {"ByPtDown", ptCompare}
15 };
16 
17 JetSorter::JetSorter(const std::string& n) :
18  asg::AsgTool(n)
19  ,m_sortType("ByPtDown")
20 {
21  declareProperty("SortingType", m_sortType);
22 }
23 
25  ATH_MSG_DEBUG(" Sorting : "<< m_sortType << " "<< jets.size() );
26  // leave early if empty otherwise sort() throws an exception.
27  if(jets.empty() ) return StatusCode::SUCCESS;
28 
29  const auto itr = g_compFuncMap.find(m_sortType);
30  if (itr == g_compFuncMap.end()) {
31  ATH_MSG_ERROR("Unsupported SortingType " << m_sortType);
32  return StatusCode::FAILURE;
33  }
34  jets.sort( *itr->second );
35  return StatusCode::SUCCESS;
36 }
ptCompare
bool ptCompare(const xAOD::Jet *j1, const xAOD::Jet *j2)
Definition: JetSorter.cxx:9
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
compFunc
bool(*)(const xAOD::Jet *, const xAOD::Jet *) compFunc
Definition: JetSorter.cxx:12
asg
Definition: DataHandleTestTool.h:28
JetSorter::modify
virtual StatusCode modify(xAOD::JetContainer &jets) const
Method to modify a jet collection.
Definition: JetSorter.cxx:24
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
doubleTestComp.j1
j1
Definition: doubleTestComp.py:21
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
g_compFuncMap
const std::map< std::string, compFunc > g_compFuncMap
Definition: JetSorter.cxx:13
JetSorter::m_sortType
std::string m_sortType
Definition: JetSorter.h:32
JetSorter.h
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
JetSorter::JetSorter
JetSorter(const std::string &t)
Definition: JetSorter.cxx:17
defineDB.jets
list jets
Definition: JetTagCalibration/share/defineDB.py:24
xAOD::bool
setBGCode setTAP setLVL2ErrorBits bool
Definition: TrigDecision_v1.cxx:60
doubleTestComp.j2
j2
Definition: doubleTestComp.py:22