ATLAS Offline Software
SelectionNameSvc.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 
8 //
9 // includes
10 //
11 
13 
16 #include <cassert>
17 #include <cmath>
18 #include <regex>
19 #include <functional>
20 
21 //
22 // method implementations
23 //
24 
25 namespace CP
26 {
28  SelectionNameSvc (const std::string& name,
29  ISvcLocator* pSvcLocator)
30  : AsgService (name, pSvcLocator)
31  {
32 
33  declareServiceInterface<ISelectionNameSvc>();
34  }
35 
36 
37 
39  initialize ()
40  {
41  ANA_CHECK (m_sysSvc.retrieve());
42  return StatusCode::SUCCESS;
43  }
44 
45 
46 
48  addAcceptInfo (const std::string& objectName, const std::string& decorName,
49  const asg::AcceptInfo& acceptInfo)
50  {
51  ANA_MSG_DEBUG ("adding selection " << decorName << " for object " << objectName);
52  auto& subMap = m_acceptInfoMap[decorName];
53  if (subMap.find (objectName) != subMap.end())
54  {
55  ANA_MSG_ERROR ("object " << objectName << " already has a selection named " << decorName);
56  return StatusCode::FAILURE;
57  }
58  subMap[objectName] = acceptInfo;
59  if (getAcceptInfo(objectName, decorName) == nullptr)
60  {
61  ANA_MSG_ERROR ("failed to add selection " << decorName << " for object " << objectName);
62  return StatusCode::FAILURE;
63  }
64  return StatusCode::SUCCESS;
65  }
66 
67 
68 
70  getAcceptInfo (const std::string& objectName,
71  const std::string& decorName) const
72  {
73  ANA_MSG_DEBUG ("querying selection " << decorName << " for object " << objectName);
74  auto subMap = m_acceptInfoMap.find (decorName);
75  if (subMap == m_acceptInfoMap.end())
76  return nullptr;
77  std::string myObjectName = objectName;
78  while (!myObjectName.empty())
79  {
80  auto result = subMap->second.find (myObjectName);
81  if (result != subMap->second.end())
82  {
83  ANA_MSG_DEBUG ("found selection " << decorName << " for object " << objectName << " using name " << myObjectName);
84  return &result->second;
85  }
86  myObjectName = m_sysSvc->getCopySource (myObjectName);
87  }
88  return nullptr;
89  }
90 }
get_generator_info.result
result
Definition: get_generator_info.py:21
ANA_MSG_ERROR
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:294
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:48
CP::SelectionNameSvc::m_sysSvc
ServiceHandle< ISystematicsSvc > m_sysSvc
the ISystematicsSvc we use
Definition: SelectionNameSvc.h:66
asg::AcceptInfo
Definition: AcceptInfo.h:28
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
MessageCheck.h
macros for messaging and checking status codes
CP::SelectionNameSvc::getAcceptInfo
virtual const asg::AcceptInfo * getAcceptInfo(const std::string &objectName, const std::string &decorName) const override
Definition: SelectionNameSvc.cxx:70
MakeSystematicsVector.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
CP::SelectionNameSvc::m_acceptInfoMap
std::unordered_map< std::string, std::unordered_map< std::string, asg::AcceptInfo > > m_acceptInfoMap
the map of AcceptInfo objects
Definition: SelectionNameSvc.h:69
CP::SelectionNameSvc::addAcceptInfo
virtual StatusCode addAcceptInfo(const std::string &objectName, const std::string &decorName, const asg::AcceptInfo &acceptInfo) override
Definition: SelectionNameSvc.cxx:48
CP::SelectionNameSvc::initialize
virtual StatusCode initialize() override
set up/tear down functions
Definition: SelectionNameSvc.cxx:39
CP::SelectionNameSvc::SelectionNameSvc
SelectionNameSvc(const std::string &name, ISvcLocator *pSvcLocator)
standard constructor
Definition: SelectionNameSvc.cxx:28
ANA_MSG_DEBUG
#define ANA_MSG_DEBUG(xmsg)
Macro printing debug messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:288
SelectionNameSvc.h