ATLAS Offline Software
SelectionNameSvc.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 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 {
27 
29  initialize ()
30  {
31  ANA_CHECK (m_sysSvc.retrieve());
32  return StatusCode::SUCCESS;
33  }
34 
35 
36 
38  addAcceptInfo (const std::string& objectName, const std::string& decorName,
39  const asg::AcceptInfo& acceptInfo)
40  {
41  ANA_MSG_DEBUG ("adding selection " << decorName << " for object " << objectName);
42  auto& subMap = m_acceptInfoMap[decorName];
43  if (subMap.find (objectName) != subMap.end())
44  {
45  ANA_MSG_ERROR ("object " << objectName << " already has a selection named " << decorName);
46  return StatusCode::FAILURE;
47  }
48  subMap[objectName] = acceptInfo;
49  if (getAcceptInfo(objectName, decorName) == nullptr)
50  {
51  ANA_MSG_ERROR ("failed to add selection " << decorName << " for object " << objectName);
52  return StatusCode::FAILURE;
53  }
54  return StatusCode::SUCCESS;
55  }
56 
57 
58 
60  getAcceptInfo (const std::string& objectName,
61  const std::string& decorName) const
62  {
63  ANA_MSG_DEBUG ("querying selection " << decorName << " for object " << objectName);
64  auto subMap = m_acceptInfoMap.find (decorName);
65  if (subMap == m_acceptInfoMap.end())
66  return nullptr;
67  std::string myObjectName = objectName;
68  while (!myObjectName.empty())
69  {
70  auto result = subMap->second.find (myObjectName);
71  if (result != subMap->second.end())
72  {
73  ANA_MSG_DEBUG ("found selection " << decorName << " for object " << objectName << " using name " << myObjectName);
74  return &result->second;
75  }
76  myObjectName = m_sysSvc->getCopySource (myObjectName);
77  }
78  return nullptr;
79  }
80 }
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:52
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:60
MakeSystematicsVector.h
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:55
CP::SelectionNameSvc::addAcceptInfo
virtual StatusCode addAcceptInfo(const std::string &objectName, const std::string &decorName, const asg::AcceptInfo &acceptInfo) override
Definition: SelectionNameSvc.cxx:38
CP::SelectionNameSvc::initialize
virtual StatusCode initialize() override
Definition: SelectionNameSvc.cxx:29
ANA_MSG_DEBUG
#define ANA_MSG_DEBUG(xmsg)
Macro printing debug messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:288
SelectionNameSvc.h