ATLAS Offline Software
TrigNavSlimmingMTAlg.icc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 template< typename CONTAINER >
6 StatusCode TrigNavSlimmingMTAlg::doRepack(TrigCompositeUtils::Decision* decision,
7  SG::WriteHandle<CONTAINER>* writeHandle,
8  const std::string& edgeName) const
9 {
10 
11  if (not decision->hasObjectLink(edgeName, ClassID_traits<CONTAINER>::ID())) {
12  // Nothing to do
13  return StatusCode::SUCCESS;
14  }
15 
16  ElementLink<CONTAINER> current = decision->objectLink<CONTAINER>(edgeName);
17  if (!current.isValid()) {
18  // TODO: Upgrade this first message to a WARNING once the TriggerAPI for Run3 is filtering on the chains whose final-features get saved into the DAOD_PHYS
19  ATH_MSG_DEBUG("Unable to repack '" << edgeName << "' of container type '"<< ClassID_traits<CONTAINER>::typeName() <<"' for '"
20  << decision->name() << "' node, the link is invalid.");
21  ATH_MSG_DEBUG("Dump of DecisionObject: " << *decision);
22  return StatusCode::SUCCESS;
23  }
24 
25  // ROIs have a specialization here w.r.t. xAOD
26  // Actually - due to having template issues, this call is not currently templated.
27  ATH_CHECK( doRepackCopy(*current, writeHandle) );
28 
29  ElementLink<CONTAINER> remapped(**writeHandle, (**writeHandle).size()-1);
30  decision->setObjectLink<CONTAINER>(edgeName, remapped); // Overwrite the existing link
31 
32  ATH_MSG_DEBUG("Repacked from index:" << current.index() << " from key:" << current.dataID()
33  << ", to index:" << remapped.index() << " to key:" << remapped.key());
34 
35  return StatusCode::SUCCESS;
36 }
37 
38 template< typename CONTAINER >
39 StatusCode TrigNavSlimmingMTAlg::doRepackCopy(const typename CONTAINER::base_value_type* object,
40  SG::WriteHandle<CONTAINER>* writeHandle) const
41 {
42  // Note: writeHandle* de-references to writeHandle which de-references to CONTAINER a.k.a. DataVector<CONTAINER::base_value_type>
43  // We call .back() on the CONTAINER to obtain CONTAINER::base_value_type*, this de-references to CONTAINER::base_value_type
44  // We end up with CONTAINER::base_value_type = CONTAINER::base_value_type, an assignment operator copy operation duplicates the data.
45  (**writeHandle).push_back( new typename CONTAINER::base_value_type() );
46  *((**writeHandle).back()) = *object;
47  return StatusCode::SUCCESS;
48 }