ATLAS Offline Software
Loading...
Searching...
No Matches
Navigation.icc
Go to the documentation of this file.
1// Emacs -*- c++ -*-
2
3/*
4 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
5*/
6
7
8#ifndef TRIGNAVIGATION_HLTNAVIGATION_ICC
9#define TRIGNAVIGATION_HLTNAVIGATION_ICC
10
11
12/*****************************************************************************
13 *
14 * COMPILE TYPE OBJECTS REGISTRATION
15 *
16 *****************************************************************************/
17
18#include <type_traits>
19#include "TrigNavigation/Holder.h"
20#include "CxxUtils/checker_macros.h"
21#include "CxxUtils/no_sanitize_undefined.h"
22
23
24/*****************************************************************************
25 *
26 * FEATURES OPERATIONS
27 *
28 *****************************************************************************/
29
30template<class T>
31__attribute__((__used__))
32bool HLT::Navigation::attachFeature NO_SANITIZE_UNDEFINED ATLAS_NOT_THREAD_SAFE
33 ( TriggerElement* te, const T* feature,
34 MemoryManagement mmanagement, std::string& key,
35 const std::string& label ) {
36 // Get clid
37 CLID clid = ClassID_traits<T>::ID();
38
39 ATH_MSG_DEBUG("attachFeature: of clid: " << clid << "(" << ClassID_traits<T>::typeName() << ")"
40 << " to TE: " << te->getId()
41 << " label: \"" << label << "\""
42 << " memory management: " << mmanagement);
43
44 // get a holder for this type --- if that's new it will be created
45
46 ATH_MSG_VERBOSE("getting Holder for label: " << label);
47 HLTNavDetails::Holder<T>* holder = getHolder<T>(label, nextSubTypeIndex(clid,label));
48 ATH_MSG_VERBOSE("got Holder: " << holder);
49
50 if ( ! holder ) {
51 ATH_MSG_WARNING("attachFeature: Holder missing for CLID: " << clid);
52 return false;
53 }
54
55 TriggerElement::ObjectIndex objectIndex = holder->add(feature, mmanagement == ObjectInStoreGate, key);
56 if ( not objectIndex.valid() )
57 return false;
58 te->addFeature(clid, objectIndex, false);
59
60 return true;
61}
62
63
64template<class T>
65__attribute__((__used__))
66bool HLT::Navigation::attachFeature ATLAS_NOT_THREAD_SAFE ( TriggerElement* te, const ConstDataVector<T>* feature,
67 MemoryManagement mmanagement, std::string& key,
68 const std::string& label ) {
69 return attachFeature (te, feature->asDataVector(),
70 mmanagement, key, label);
71}
72
73
74template<class T>
75__attribute__((__used__))
76bool HLT::Navigation::associateExternalCollection(const std::string& label) {
77 CLID clid = ClassID_traits<T>::ID();
78
79 ATH_MSG_DEBUG("associateExternalCollection: of clid: " << clid << "(" << ClassID_traits<T>::typeName() << ")"
80 << " label: \"" << label << "\"");
81 HLTNavDetails::Holder<T>* holder = getHolder<T>(label, nextSubTypeIndex(clid,label));
82 if ( ! holder ) {
83 ATH_MSG_WARNING("associateExternalCollection: Holder missing for CLID: " << clid);
84 return false;
85 }
86 return true;
87}
88
89
90/////////////////////////////////////////////////////////////////////////////
91template<class T>
92__attribute__((__used__))
93bool HLT::Navigation::findOwners(const T* obj, std::vector<const TriggerElement*>& owners, unsigned int id) {
94 std::lock_guard<std::recursive_mutex> lock(getMutex());
95 TriggerElementFactory& factory = getFactory();
96 TrigHolderStructure& holderstorage = getHolderStorage();
97
98 std::vector<TriggerElement*>::const_iterator it = factory.listOfProduced().begin();
99 std::vector<TriggerElement*>::const_iterator itEnd = factory.listOfProduced().end();
100 if ( id != 0 ) {
101 it = factory.listOfProduced(id).begin();
102 itEnd = factory.listOfProduced(id).end();
103 ATH_MSG_VERBOSE("findOwners will scann TEs of ID : " << id << " #: " << itEnd-it);
104 } else {
105 ATH_MSG_VERBOSE("findOwners will scann ALL TEs (slow):" << itEnd-it);
106 }
107
108 CLID clid = ClassID_traits<T>::ID();
109
110 auto holders_of_clid = holderstorage.getHoldersOfClid<HLTNavDetails::Holder<T> >(clid);
111
112 if(holders_of_clid.empty())
113 return true;
114
115 ATH_MSG_VERBOSE("findOwners features of this CLID present");
116 bool holderFound = false;
117 HLT::TriggerElement::ObjectIndex idx;
118 for(auto holder : holders_of_clid ) {
119 if ( holder->contains(obj, idx) ) {
120 holderFound = true;
121 ATH_MSG_VERBOSE("findOwners found holder owning the object " << *holder << " and index: " << idx);
122 break;
123 }
124 }
125 if ( !holderFound )
126 return true;
127
128 for (; it != itEnd; ++it ) {
129 for ( const TriggerElement::FeatureAccessHelper& f : (*it)->getFeatureAccessHelpers() ) {
130 if ( f.getCLID() == clid && f.getIndex().isSameOrWithin(&idx) ) {
131 owners.push_back(*it);
132 ATH_MSG_VERBOSE("findOwners while looking in TE(id): " << *it <<"(" << (*it)->getId() << ")" <<
133 " and access helper " << f.getIndex() << " found owner");
134 break;
135 }
136 }
137 }
138 return true;
139}
140
141template<class T>
142__attribute__((__used__))
143const std::string HLT::Navigation::getNextKey( const std::string& label ) {
144 CLID clid = ClassID_traits<T>::ID();
145 HLTNavDetails::Holder<T>* holder = getHolder<T>(label, nextSubTypeIndex(clid,label));
146 if (!holder) return ""; // should never happen, but who knows
147
148 return holder->getNextKey( );
149}
150
151template<class T>
152__attribute__((__used__))
153const std::string HLT::Navigation::getUniqueKey( const std::string& label ) {
154 CLID clid = ClassID_traits<T>::ID();
155 HLTNavDetails::Holder<T>* holder = getHolder<T>(label, nextSubTypeIndex(clid, label));
156
157 if (!holder) return ""; // should never happen, but who knows
158
159 return holder->getUniqueKey( );
160}
161
162
163#endif // TRIGNAVIGATION_HLTNAVIGATION_ICC