ATLAS Offline Software
FeatureContainer.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /**********************************************************************************
6  * @Project: TrigDecisionTool
7  * @Package: TrigDecisionTool
8  * @Class : FeatureContainer
9  *
10  *
11  * @author Nicolas Berger <Nicolas.Berger@cern.ch> - LAPP Annecy
12  *
13 ***********************************************************************************/
14 
17 
18 
20 {
21  /* Keep unique combinations and preserve insertion order to guarantee
22  reproducibility. We achieve this by an additional set (faster than doing
23  a linear search in the vector each time). */
24  if (m_combinations_unique.insert(newComb).second) { // true if element was inserted (not known yet)
25  m_combinations.push_back(newComb);
26  }
27 }
28 
30 {
31  for(const Trig::Combination& comb : other.m_combinations)
32  addWithChecking(comb);
33 }
34 
35 
38  return m_cgm->navigation();
39 }
40 
41 
42 
43 bool
45  const void* obj_a, const void* obj_b) const {
46  // returning False -> no insertion into set
47  // returning True -> insertion into set
48  // each pair of candidates is tested twice (if test returns False twice, then no insertion into set)
49 
50  using namespace HLT;
51  if (a==b && obj_a==obj_b) {
52  return false; // if TE and object pointers are the same, then we don't insert the second cand at all
53  }
54 
55  if(a==b && obj_a!=obj_b) {
56  // if different objects but the same TE, then we always insert, so the order in the set is the insertion order
57  // this guaranties reproducibility only if the order of the objects in the TE is reproducible
58  return true;
59  }
60 
61  // if the TEs are different we follow the old procedure which does guaranty reproducibily (the order of features is always the same)
62  const TriggerElement::FeatureVec& a_features = a->getFeatureAccessHelpers();
63  const TriggerElement::FeatureVec& b_features = b->getFeatureAccessHelpers();
64 
65  if ( a_features.size() != b_features.size() )
66  return a_features.size() < b_features.size();
67 
68  for ( unsigned f = 0, sz = a_features.size(); f < sz; ++f ) {
69  const TriggerElement::FeatureAccessHelper& a_f = a_features[f];
70  const TriggerElement::FeatureAccessHelper& b_f = b_features[f];
71  if ( a_f.getCLID() == b_f.getCLID()) {
72  if ( a_f.getIndex() == b_f.getIndex()) continue;
73  return a_f.getIndex() < b_f.getIndex();
74  }
75  return a_f.getCLID() < b_f.getCLID();
76  }
77  return false;
78 }
79 
80 //this is a helper method to weakly order feature access helpers.
82 public:
84  if ( a.accessHelper().getCLID() == b.accessHelper().getCLID()) {
85  return a.accessHelper().getIndex() < b.accessHelper().getIndex();
86  }
87  return a.accessHelper().getCLID() < b.accessHelper().getCLID();
88  }
89  };
90 
91 
92 const std::vector<Trig::TypelessFeature> Trig::FeatureContainer::typelessGet(HLT::class_id_type clid, const std::string& label, unsigned int condition, const std::string& teName) const {
93  if ( condition != TrigDefs::Physics && condition != TrigDefs::alsoDeactivateTEs ) {
94  throw std::runtime_error("Only two flags can be supplied to features");
95  }
96 
97  std::set<Trig::TypelessFeature,::order_by_clid_and_index> uniqnessHelper;
98  for(auto& comb : m_combinations ) {
99  if (condition == TrigDefs::Physics) {
100  if (!comb.active()) continue;
101  }
102 
103  std::vector<Trig::TypelessFeature> features = comb.typelessGet(clid, label, condition, teName);
104  for(auto& f : features) {
105  uniqnessHelper.insert(f);
106  }
107  }
108  return std::vector<Trig::TypelessFeature>(uniqnessHelper.begin(), uniqnessHelper.end());
109 }
order_by_clid_and_index
Definition: FeatureContainer.cxx:81
Combination.h
python.CaloRecoConfig.f
f
Definition: CaloRecoConfig.py:127
fitman.sz
sz
Definition: fitman.py:527
FeatureContainer.h
PlotCalibFromCool.label
label
Definition: PlotCalibFromCool.py:78
Trig::FeatureContainer::ordering_by_objects_attached::weakOrder
bool weakOrder(const HLT::TriggerElement *te_a, const HLT::TriggerElement *te_b, const void *obj_a, const void *obj_b) const
Definition: FeatureContainer.cxx:44
HLT::TriggerElement::FeatureVec
std::vector< FeatureAccessHelper > FeatureVec
Definition: TrigNavStructure/TrigNavStructure/TriggerElement.h:233
Trig::FeatureContainer::m_combinations_unique
std::unordered_set< Trig::Combination > m_combinations_unique
set for ensuring uniqueness in the above container
Definition: FeatureContainer.h:150
HLT::TriggerElement::FeatureAccessHelper::getCLID
class_id_type getCLID() const
Class ID of object.
Definition: TrigNavStructure/TrigNavStructure/TriggerElement.h:208
navigation2dot.teName
def teName(teid)
Definition: navigation2dot.py:59
LArG4GenerateShowerLib.condition
condition
Definition: LArG4GenerateShowerLib.py:19
HLT::TrigNavStructure
Definition: TrigNavStructure.h:40
Trig::FeatureContainer
Definition: FeatureContainer.h:54
Trig::FeatureContainer::typelessGet
const std::vector< Trig::TypelessFeature > typelessGet(HLT::class_id_type clid, const std::string &label="", unsigned int condition=TrigDefs::Physics, const std::string &teName="") const
typeless version of get
Definition: FeatureContainer.cxx:92
Trig::TypelessFeature
Feature class, holding information on Feature attached to navigation.
Definition: TypelessFeature.h:20
HLT
It used to be useful piece of code for replacing actual SG with other store of similar functionality ...
Definition: HLTResultReader.h:26
Trig::Combination
Definition: Trigger/TrigAnalysis/TrigDecisionTool/TrigDecisionTool/Combination.h:55
HLT::TriggerElement
TriggerElement is the basic ingreedient of the interface between HLT algorithms and the navigation It...
Definition: TrigNavStructure/TrigNavStructure/TriggerElement.h:27
Trig::FeatureContainer::navigation
const HLT::TrigNavStructure * navigation() const
Definition: FeatureContainer.cxx:37
HLT::class_id_type
uint32_t class_id_type
Definition: Trigger/TrigEvent/TrigNavStructure/Root/Types.h:11
order_by_clid_and_index::operator()
bool operator()(const Trig::TypelessFeature &a, const Trig::TypelessFeature &b) const
Definition: FeatureContainer.cxx:83
Trig::FeatureContainer::m_combinations
std::vector< Trig::Combination > m_combinations
container preserving insertion order
Definition: FeatureContainer.h:148
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
a
TList * a
Definition: liststreamerinfos.cxx:10
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
HLT::TriggerElement::FeatureAccessHelper::getIndex
const ObjectIndex & getIndex() const
index in the external ojects array
Definition: TrigNavStructure/TrigNavStructure/TriggerElement.h:209
HLT::TriggerElement::FeatureAccessHelper
the FeatureAccessHelper is a class used to keep track of features attached to this TE.
Definition: TrigNavStructure/TrigNavStructure/TriggerElement.h:192
Trig::FeatureContainer::addWithChecking
void addWithChecking(const Combination &newComb)
add new combination to the container checking for overlap
Definition: FeatureContainer.cxx:19
Trig::FeatureContainer::append
void append(const FeatureContainer &other)
Definition: FeatureContainer.cxx:29