38 return StatusCode::SUCCESS;
50 size_t usedROIMatching = 0, usedFeatureMatching = 0;
53 size_t totalInput = 0;
57 if( not inputHandle.isValid() ) {
58 ATH_MSG_DEBUG(
"Got no decisions from input "<< inputKey.key() <<
" because implicit handle not valid");
61 if( inputHandle->size() == 0){
62 ATH_MSG_DEBUG(
"Got no decisions from input "<< inputKey.key()<<
": implicit handle is valid but container is empty.");
65 ATH_MSG_DEBUG(
"Running on input "<< inputKey.key()<<
" with " << inputHandle->size() <<
" elements" );
68 size_t input_counter = 0;
72 bool usedROIMatchingFlag =
false;
73 size_t alreadyAddedIndex = std::numeric_limits<std::size_t>::max();
74 const bool alreadyAdded =
matchInCollection(outDecisions, inputDecision, alreadyAddedIndex, usedROIMatchingFlag, matchingCache);
78 if (usedROIMatchingFlag) {
81 ++usedFeatureMatching;
83 outputDecision = outDecisions->
at( alreadyAddedIndex );
84 ATH_MSG_DEBUG(
" -- Matched to existing, " << inputKey.key() <<
" index " << input_counter <<
" is merged into existing output index " << alreadyAddedIndex << (usedROIMatchingFlag ?
" Matched using ROI" :
" Matched using Feature"));
90 ATH_MSG_DEBUG(
" -- Did not match to existing, " << inputKey.key() <<
" index " << input_counter <<
" creates output index " << outDecisions->
size()-1);
99 totalInput+=input_counter;
102 if (usedROIMatching and usedFeatureMatching) {
103 ATH_MSG_DEBUG(
"This input maker used Feature-based mapping on " << usedFeatureMatching <<
" inputs and ROI-based mapping on " << usedROIMatching
111 ATH_MSG_DEBUG(
"Merging complete: from "<<totalInput<<
" input decision to "<<outputHandle->size()<<
" output decisions");
113 return StatusCode::SUCCESS;
118 std::set<const Decision*> cache;
119 std::vector<SG::sgkey_t> keys;
120 std::vector<uint32_t> clids;
121 std::vector<Decision::index_type> indicies;
122 std::vector<const Decision*> sources;
124 bool hasFeature =
false;
125 if (keys.size() != 0) hasFeature=
true;
135 usedROIMatchingFlag =
true;
137 return (matchIndex != std::numeric_limits<std::size_t>::max());
142 ATH_MSG_DEBUG(
"matchDecision "<<linkNameToMatch<<
" with matchingHash="<<matchingHash);
149 const uint64_t checkHash = matchingCache.
getMatchingHash(checkDecision);
151 if (checkHash == matchingHash) {
156 return std::numeric_limits<std::size_t>::max();
160 std::set<const Decision*> cache;
161 std::vector<SG::sgkey_t> keys;
162 std::vector<uint32_t> clids;
163 std::vector<Decision::index_type> indicies;
164 std::vector<const Decision*> sources;
166 ATH_MSG_DEBUG(
"getMatchingHashForDecision keys.size()="<<keys.size());
167 if (keys.size() != 1) {
168 bool suppressError =
false;
171 suppressError =
true;
175 if ( keys.size() > 1) {
176 suppressError =
false;
178 if (not suppressError) {
179 ATH_MSG_ERROR(
"InputMakerBase::getMatchingHashForDecision Did not locate exactly one object having searched for a link named '" << linkNameToMatch
180 <<
"', found " << keys.size() <<
". Unable to match this Decision object.");
181 for (
size_t i = 0; i < keys.size(); ++i) {
182 const std::string* sgKeyStr =
evtStore()->keyToString(keys.at(i));
183 ATH_MSG_ERROR(
" -- Key:" << keys.at(i) <<
" KeyStr:" << (sgKeyStr ? *sgKeyStr :
"UNKNOWN") <<
" Index:" << indicies.at(i) <<
" CLID:" << clids.at(i));
191 return std::numeric_limits<std::size_t>::max();
195 const uint64_t matchingHash = keys.at(0) + clids.at(0) + indicies.at(0);
204 ATH_MSG_DEBUG(
" " << inputKey.key() <<
" " << (inputHandle.isValid()?
"valid":
"not valid" ) );
205 if (inputHandle.isValid()) {
206 if (inputHandle->size() > 0) {
209 ATH_MSG_DEBUG(
" " << inputKey.key() <<
" actually NOT valid due to size() == 0");
213 ATH_MSG_DEBUG(
"Number of implicit ReadHandles for input decisions is " <<
decisionInputs().size() <<
", " << validInput <<
" are valid/not-empty" );
215 ATH_MSG_DEBUG(
"Output " << outputHandle.
key() <<
" with "<< outputHandle->size() <<
" decisions:");
216 for (
const auto outdecision : *outputHandle){
219 ATH_MSG_DEBUG(
"Number of positive decisions for this output: " << objDecisions.size() );
238 if (!outputDecision) {
239 throw std::runtime_error(
"InputMakerBase::MatchingCache::getMatchingHash: Called with nullptr.");
244 throw std::runtime_error(
"InputMakerBase::MatchingCache::getMatchingHash: No matching input Decision* for the supplied output Decision*");
246 const Decision* inputDecision = it_inDec->second;
250 throw std::runtime_error(
"InputMakerBase::MatchingCache::getMatchingHash: No matching hash for this input Decision*");
252 const uint64_t hash = it_hash->second;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define CHECK(...)
Evaluate an expression and check for errors.
ServiceHandle< StoreGateSvc > & evtStore()
virtual StatusCode sysInitialize() override
void renounceArray(SG::VarHandleKeyArray &handlesArray)
bool msgLvl(const MSG::Level lvl) const
An algorithm that can be simultaneously executed in multiple threads.
const T * at(size_type n) const
Access an element, as an rvalue.
size_type size() const noexcept
Returns the number of elements in the collection.
virtual const std::string & key() const override final
Return the StoreGate ID for the referenced object.
Property holding a SG store/key/clid from which a WriteHandle is made.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
pointer_type ptr()
Dereference the pointer.
Structure to hold a transient Directed Acyclic Graph (DAG) structure.
void printAllPaths(MsgStream &log, MSG::Level msgLevel=MSG::VERBOSE) const
Helper function.
void setName(const std::string &name)
Set a human-readable name for the object.
const std::vector< TrigCompositeUtils::DecisionID > & decisions() const
Get positive HLT chain decisions associated with this TrigComposite. Navigation use.
bool setDetail(const std::string &name, const TYPE &value)
Set an TYPE detail on the object.
HandleKeyArray< ReadHandle< T >, ReadHandleKey< T >, Gaudi::DataHandle::Reader > ReadHandleKeyArray
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
const std::string & inputMakerNodeName()
xAOD::TrigComposite Decision
void insertDecisionIDs(const Decision *src, Decision *dest)
Appends the decision IDs of src to the dest decision object.
Decision * newDecisionIn(DecisionContainer *dc, const std::string &name)
Helper method to create a Decision object, place it in the container and return a pointer to it.
const std::vector< ElementLink< DecisionContainer > > getLinkToPrevious(const Decision *d)
returns links to previous decision object 'seed'
const std::string & featureString()
void recursiveGetDecisions(const Decision *start, NavGraph &navGraph, const DecisionIDContainer &ids, const bool enforceDecisionOnStartNode)
Search back in time from "node" and locate all paths back through Decision objects for a given chain.
std::set< DecisionID > DecisionIDContainer
void linkToPrevious(Decision *d, const std::string &previousCollectionKey, size_t previousIndex)
Links to the previous object, location of previous 'seed' decision supplied by hand.
bool typelessFindLinks(const Decision *start, const std::string &linkName, std::vector< sgkey_t > &keyVec, std::vector< CLID > &clidVec, std::vector< Decision::index_type > &indexVec, std::vector< const Decision * > &sourceVec, const unsigned int behaviour, std::set< const Decision * > *fullyExploredFrom)
search back the TC links for the object of type T linked to the one of TC (recursively) Returns the l...
xAOD::TrigCompositeContainer DecisionContainer
void decisionIDs(const Decision *d, DecisionIDContainer &destination)
Extracts DecisionIDs stored in the Decision object.
static const unsigned int lastFeatureOfType
Run 3 "enum". Only return the final feature along each route through the navigation.