ATLAS Offline Software
Loading...
Searching...
No Matches
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
43bool
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.
82public:
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
92const 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}
static Double_t sz
static Double_t a
the FeatureAccessHelper is a class used to keep track of features attached to this TE.
const ObjectIndex & getIndex() const
index in the external ojects array
TriggerElement is the basic ingreedient of the interface between HLT algorithms and the navigation It...
is a connector between chains and object It store single combination of trigger elements.
bool weakOrder(const HLT::TriggerElement *te_a, const HLT::TriggerElement *te_b, const void *obj_a, const void *obj_b) const
std::vector< Trig::Combination > m_combinations
container preserving insertion order
void append(const FeatureContainer &other)
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
FeatureContainer(const CacheGlobalMemory *cgm=0)
constructors, destructor
std::unordered_set< Trig::Combination > m_combinations_unique
set for ensuring uniqueness in the above container
const Trig::CacheGlobalMemory * m_cgm
const HLT::TrigNavStructure * navigation() const
void addWithChecking(const Combination &newComb)
add new combination to the container checking for overlap
Feature class, holding information on Feature attached to navigation.
bool operator()(const Trig::TypelessFeature &a, const Trig::TypelessFeature &b) const
std::string label(const std::string &format, int i)
Definition label.h:19
It used to be useful piece of code for replacing actual SG with other store of similar functionality ...