ATLAS Offline Software
Loading...
Searching...
No Matches
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
25namespace CP
26{
27
28 StatusCode SelectionNameSvc ::
29 initialize ()
30 {
31 ANA_CHECK (m_sysSvc.retrieve());
32 return StatusCode::SUCCESS;
33 }
34
35
36
37 StatusCode SelectionNameSvc ::
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
59 const asg::AcceptInfo* SelectionNameSvc ::
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}
macros for messaging and checking status codes
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
#define ANA_MSG_DEBUG(xmsg)
Macro printing debug messages.
#define ANA_CHECK(EXP)
check whether the given expression was successful
std::unordered_map< std::string, std::unordered_map< std::string, asg::AcceptInfo > > m_acceptInfoMap
the map of AcceptInfo objects
ServiceHandle< ISystematicsSvc > m_sysSvc
the ISystematicsSvc we use
virtual const asg::AcceptInfo * getAcceptInfo(const std::string &objectName, const std::string &decorName) const override
Select isolated Photons, Electrons and Muons.