diff --git a/Trigger/TrigEvent/TrigNavStructure/Root/StringSerializer.cxx b/Trigger/TrigEvent/TrigNavStructure/Root/StringSerializer.cxx index d9ef12162dd02a3de01687ea157ab091931c5066..2fb6ffcbc9084f014dcc348908324835acd85aa5 100644 --- a/Trigger/TrigEvent/TrigNavStructure/Root/StringSerializer.cxx +++ b/Trigger/TrigEvent/TrigNavStructure/Root/StringSerializer.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #include <cstring> @@ -13,7 +13,7 @@ // the implementation is almost exact copy of the one in the TrigSerializeResult namespace { - const char* delimiter = "\n"; + const char* const delimiter = "\n"; unsigned int getPadding(unsigned int sizeToReserve) { return (sizeof(uint32_t) - sizeToReserve%sizeof(uint32_t)) % sizeof(uint32_t); diff --git a/Trigger/TrigEvent/TrigNavStructure/Root/TrigNavStructure.cxx b/Trigger/TrigEvent/TrigNavStructure/Root/TrigNavStructure.cxx index f0fabc9165bed946ae9e69b3c06e764e6f5d6f39..5e1b4dae9e60730c2ecf364838d76470a418a281 100644 --- a/Trigger/TrigEvent/TrigNavStructure/Root/TrigNavStructure.cxx +++ b/Trigger/TrigEvent/TrigNavStructure/Root/TrigNavStructure.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #include <sstream> @@ -726,13 +726,13 @@ bool TrigNavStructure::overlaps(const TriggerElement* te1, const TriggerElement* } bool TrigNavStructure::getTopologicallySpannedBy( const TriggerElement* te, const std::vector<unsigned int>& types, - std::vector<TriggerElement*>& children, const bool activeOnly ) const { + std::vector<const TriggerElement*>& children, const bool activeOnly ) const { if ( getDirectPredecessors(te).size() != types.size() ) { return false; } for ( unsigned i = 0 ; i < types.size(); ++i ) { - TriggerElement* child = const_cast<TriggerElement*>(getSuccessor( getDirectPredecessors(te)[i], types[i])); + const TriggerElement* child = getSuccessor( getDirectPredecessors(te)[i], types[i]); if(child!=0) { if(activeOnly && !child->getActiveState()) { children.clear(); diff --git a/Trigger/TrigEvent/TrigNavStructure/Root/TriggerElement.cxx b/Trigger/TrigEvent/TrigNavStructure/Root/TriggerElement.cxx index ee8c9fbaab16c60ccd5154ea31da78f4224abdb8..2351479fa4a5c8ca6bd9427d0abbb4eae7a7222d 100644 --- a/Trigger/TrigEvent/TrigNavStructure/Root/TriggerElement.cxx +++ b/Trigger/TrigEvent/TrigNavStructure/Root/TriggerElement.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #include <iostream> @@ -83,7 +83,7 @@ void TriggerElement::setGhostState( bool state) { state ? m_state |= ghostState : m_state &= ~ghostState; } -void TriggerElement::relate( TriggerElement* te, Relation r ) const { +void TriggerElement::relate( TriggerElement* te, Relation r ) { // secure form multiple relations of the same type // silently ignoring if already related // his helps if one wants the Topo TE to merge several RoIs @@ -92,7 +92,7 @@ void TriggerElement::relate( TriggerElement* te, Relation r ) const { } -void TriggerElement::relate( const std::vector<TriggerElement*> tes, Relation r ) const { +void TriggerElement::relate( const std::vector<TriggerElement*> tes, Relation r ) { // secure form multiple relations of the same type std::vector<TriggerElement*>::const_iterator it; for ( it = tes.begin(); it != tes.end(); ++it ) { @@ -138,10 +138,15 @@ void TriggerElement::serialize( std::vector<uint32_t>& output, const std::map<Tr unsigned summaryIndex = output.size(); // reserve space for vaious caounters and state output.push_back(0); + auto it = m_relations.find (seededByRelation); + std::vector<TriggerElement*> dumvec; + const std::vector<TriggerElement*>& relvec = + (it != m_relations.end() ? it->second : dumvec); + std::vector<TriggerElement*>::const_iterator teIt; unsigned relationsCount = 0; // go over all TE which seed me and record link to them - for ( teIt = m_relations[seededByRelation].begin(); teIt != m_relations[seededByRelation].end(); ++teIt ) { + for ( teIt = relvec.begin(); teIt != relvec.end(); ++teIt ) { std::map<TriggerElement*, uint16_t>::const_iterator key = keys.find(*teIt); if ( key != keys.end() ) { insertUint16ToUint32Vector(output, key->second, relationsCount); @@ -163,7 +168,7 @@ void TriggerElement::serialize( std::vector<uint32_t>& output, const std::map<Tr featuresCount++; } } - uint32_t seedingUsesStateWord = ((m_relations[seededByRelation].size() << 20)) | (featuresCount << 8) | (m_state & 0xf); + uint32_t seedingUsesStateWord = ((relvec.size() << 20)) | (featuresCount << 8) | (m_state & 0xf); output[summaryIndex] = seedingUsesStateWord; /* std::cerr << "Serialized TE id: " << m_id << " fea: " << featuresCount diff --git a/Trigger/TrigEvent/TrigNavStructure/TrigNavStructure/ATLAS_CHECK_THREAD_SAFETY b/Trigger/TrigEvent/TrigNavStructure/TrigNavStructure/ATLAS_CHECK_THREAD_SAFETY new file mode 100644 index 0000000000000000000000000000000000000000..601bef54694c88892267d30de53fb3251d710807 --- /dev/null +++ b/Trigger/TrigEvent/TrigNavStructure/TrigNavStructure/ATLAS_CHECK_THREAD_SAFETY @@ -0,0 +1 @@ +Trigger/TrigEvent/TrigNavStructure diff --git a/Trigger/TrigEvent/TrigNavStructure/TrigNavStructure/TrigNavStructure.h b/Trigger/TrigEvent/TrigNavStructure/TrigNavStructure/TrigNavStructure.h index 68087cb7ae098e91deff36a61ecec6ed314ac39e..a244565c5feecb97992848f36a2c674bd6e3748f 100644 --- a/Trigger/TrigEvent/TrigNavStructure/TrigNavStructure/TrigNavStructure.h +++ b/Trigger/TrigEvent/TrigNavStructure/TrigNavStructure/TrigNavStructure.h @@ -1,7 +1,7 @@ // Dear emacs, this is -*- c++ -*- /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ @@ -315,7 +315,7 @@ namespace HLT { * @param activeOnly optional parameter specifying whether inactive TEs should be discarded from the search; true by default */ bool getTopologicallySpannedBy( const TriggerElement* te, const std::vector<unsigned int>& types, - std::vector<TriggerElement*>& children, const bool activeOnly = true ) const; + std::vector<const TriggerElement*>& children, const bool activeOnly = true ) const; /** * @brief gets all features from the sourceTE and copies a reference (FeatureAccessHelper) to the destTE diff --git a/Trigger/TrigEvent/TrigNavStructure/TrigNavStructure/TriggerElement.h b/Trigger/TrigEvent/TrigNavStructure/TrigNavStructure/TriggerElement.h index 7eb6767494b7e72582c8e7d2caad11f23435abae..819df8732347cbd76d89981c0d605c1a72199da5 100644 --- a/Trigger/TrigEvent/TrigNavStructure/TrigNavStructure/TriggerElement.h +++ b/Trigger/TrigEvent/TrigNavStructure/TrigNavStructure/TriggerElement.h @@ -1,7 +1,7 @@ // -*- c++ -*- /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #ifndef TRIGNAVSTRUCTURE_TRIGGERELEMENT_H @@ -147,7 +147,14 @@ namespace HLT { * @param rel relation name (one of HLT::Navigation::Relation) # @return is reference ot the vector of related TEs */ - inline const std::vector<TriggerElement*>& getRelated( Relation rel ) const { return m_relations[rel];} + inline const std::vector<TriggerElement*>& getRelated( Relation rel ) const { + auto it = m_relations.find (rel); + if (it != m_relations.end()) { + return it->second; + } + static const std::vector<TriggerElement*> dumvec; + return dumvec; + } enum States { activeState = 0x1, //!< this bit is keeping active/inactive state of TE @@ -156,22 +163,22 @@ namespace HLT { errorState = 0x8 //!< somewhere in the algorithms dealing with this TE there was an error }; - mutable std::map<Relation, std::vector<TriggerElement*> > m_relations; //!< relations holder (features outside) + std::map<Relation, std::vector<TriggerElement*> > m_relations; //!< relations holder (features outside) /** * @brief reates given TE to other TE * @param te TriggerElement pointer * @param r relation .. one of Relation enums - * Nothe that the relation is usially reflexive ... + * Nothe that the relation is usually reflexive ... */ - void relate( TriggerElement* te, Relation r ) const; + void relate( TriggerElement* te, Relation r ); /** * @brief relates this TE to vecor of other TEs * @param tes vector of TriggerElement pointers * @param r relation .. one of Relation enums */ - void relate( const std::vector<TriggerElement*> tes, Relation r ) const; + void relate( const std::vector<TriggerElement*> tes, Relation r ); static unsigned int enquireId( std::vector<uint32_t>::const_iterator& inputIt ); diff --git a/Trigger/TrigEvent/TrigNavStructure/share/ut_features_test.ref b/Trigger/TrigEvent/TrigNavStructure/share/ut_features_test.ref index a8a1992a250d5768a64368cad0f7422c1cea2d3c..648237a1a6958dd8d6d575ce9f069d772178c489 100644 --- a/Trigger/TrigEvent/TrigNavStructure/share/ut_features_test.ref +++ b/Trigger/TrigEvent/TrigNavStructure/share/ut_features_test.ref @@ -1,5 +1,3 @@ -ServiceManager FATAL No Service factory for EventDataSvc available. -getNSlots_once.... ERROR ServiceLocatorHelper::service: can not locate service EventDataSvc ApplicationMgr INFO Application Manager Configured successfully @@ -33,10 +31,10 @@ INFO LINE Test getRecursivelyTEbyLabel DEBUG LINE Test progressing DEBUG LINE Test progressing DEBUG LINE Test progressing -INFO LINE Number of TEs before re-serailziation 11 -INFO LINE size of serialzied navigation is 95 +INFO LINE Number of TEs before re-serialization 11 +INFO LINE size of serialized navigation is 95 INFO LINE elements: 3 95 52 11 -INFO LINE Number of TEs after deserailziation 11 +INFO LINE Number of TEs after deserialization 11 INFO LINE tests after serialization, deserialization DEBUG LINE dumpHolders DEBUG LINE Holder CLID:788776 label: L2Electrons sub: 0 diff --git a/Trigger/TrigEvent/TrigNavStructure/share/ut_iterators_test.ref b/Trigger/TrigEvent/TrigNavStructure/share/ut_iterators_test.ref index f0c1047a9570c6e7d6951b56ea5d65292fb29606..767a62aac54b4da06e1a522f6026ad98b7e736e1 100644 --- a/Trigger/TrigEvent/TrigNavStructure/share/ut_iterators_test.ref +++ b/Trigger/TrigEvent/TrigNavStructure/share/ut_iterators_test.ref @@ -1,5 +1,3 @@ -ServiceManager FATAL No Service factory for EventDataSvc available. -getNSlots_once.... ERROR ServiceLocatorHelper::service: can not locate service EventDataSvc ApplicationMgr INFO Application Manager Configured successfully diff --git a/Trigger/TrigEvent/TrigNavStructure/test/ut_features_test.cxx b/Trigger/TrigEvent/TrigNavStructure/test/ut_features_test.cxx index 75eff6bed7b686d57466ab62284edc4292a09af7..7f17347d04b6484a06edf6d9b86c3496cf430f7e 100644 --- a/Trigger/TrigEvent/TrigNavStructure/test/ut_features_test.cxx +++ b/Trigger/TrigEvent/TrigNavStructure/test/ut_features_test.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #include <stdexcept> @@ -53,13 +53,12 @@ struct TestTNS : public StandaloneNavigation { }; -TestTNS tns; static const class_id_type roi_clid = 6171771; static const class_id_type cluster_clid = 19188792; static const class_id_type track_clid = 472619874; static const class_id_type electron_clid = 788776; -bool build() { +bool build(TestTNS& tns) { tns.reset(); tns.getInitialNode(); TriggerElement* roi1 = tns.addRoINode(tns.getInitialNode()); @@ -89,7 +88,7 @@ bool build() { return true; } -TriggerElement * getById(te_id_type id) { +TriggerElement * getById(TestTNS& tns, te_id_type id) { std::vector<TriggerElement*> tes; tns.getAllOfType(id, tes); if ( tes.size() != 1 ) { @@ -100,7 +99,7 @@ TriggerElement * getById(te_id_type id) { } -bool attach() { +bool attach(TestTNS& tns) { auto roi1 = TrigNavStructure::getDirectSuccessors(tns.getInitialNode())[0]; if( tns.addFeature(roi1, roi_clid, "initial", 0, 1) == false ) @@ -111,22 +110,22 @@ bool attach() { REPORT_AND_STOP("attach to RoI node failed"); // we used for the test TEs ID they have convention that the for digit labels RoI second labels step of processing - if ( tns.addFeature(getById(11), cluster_clid, "L2ElectronClusters", 0, 1) == false ) + if ( tns.addFeature(getById(tns, 11), cluster_clid, "L2ElectronClusters", 0, 1) == false ) REPORT_AND_STOP("Cluster attach failed"); - if ( tns.addFeature(getById(21), cluster_clid, "L2ElectronClusters", 1, 2) == false ) + if ( tns.addFeature(getById(tns, 21), cluster_clid, "L2ElectronClusters", 1, 2) == false ) REPORT_AND_STOP("Cluster attach failed"); - if ( tns.addFeature(getById(12), track_clid, "L2ElectronTracks", 0, 10) == false ) + if ( tns.addFeature(getById(tns, 12), track_clid, "L2ElectronTracks", 0, 10) == false ) REPORT_AND_STOP("Tracks attach failed"); - if ( tns.addFeature(getById(22), track_clid, "L2ElectronTracks", 27, 32) == false ) + if ( tns.addFeature(getById(tns, 22), track_clid, "L2ElectronTracks", 27, 32) == false ) REPORT_AND_STOP("Tracks attach failed"); - if ( tns.addFeature(getById(13), electron_clid, "L2Electrons", 0, 10) == false ) + if ( tns.addFeature(getById(tns, 13), electron_clid, "L2Electrons", 0, 10) == false ) REPORT_AND_STOP("Electrons attach failed"); - if ( tns.addFeature(getById(23), electron_clid, "L2Electrons", 20, 25) == false ) + if ( tns.addFeature(getById(tns, 23), electron_clid, "L2Electrons", 20, 25) == false ) REPORT_AND_STOP("Electrons attach failed"); return true; @@ -156,10 +155,10 @@ bool isGoodFeature(const HLT::TriggerElement::FeatureAccessHelper& fea, -bool getFromExplicitTE() { +bool getFromExplicitTE(TestTNS& tns) { BEGIN_TEST; // get from valid TE - auto fea = tns.getFeature(getById(11), cluster_clid, 3); + auto fea = tns.getFeature(getById(tns, 11), cluster_clid, 3); if ( not isGoodFeature(fea, cluster_clid, 3, 0, 1) ) REPORT_AND_STOP("Valid request to get clusters fails"); PROGRESS; @@ -174,26 +173,26 @@ bool getFromExplicitTE() { PROGRESS; // get from valid TE neglecting the sub index - fea = tns.getFeature(getById(12), track_clid, invalid_sub_index); + fea = tns.getFeature(getById(tns, 12), track_clid, invalid_sub_index); if ( not isGoodFeature(fea, track_clid, 0, 0, 10) ) REPORT_AND_STOP("Valid request (neglecting sub index) to get tracks fails"); PROGRESS; // requests below shuld be failing // wrong subType - fea = tns.getFeature(getById(10), cluster_clid, 1); + fea = tns.getFeature(getById(tns, 10), cluster_clid, 1); if ( fea.valid() ) REPORT_AND_STOP("Got feature while should obtain nothing using this sub type ID"); PROGRESS; // earlier TE - fea = tns.getFeature(getById(10), cluster_clid, 3); + fea = tns.getFeature(getById(tns, 10), cluster_clid, 3); if ( fea.valid() ) REPORT_AND_STOP("Got feature while should obtain nothing from this TE"); PROGRESS; // latter TE - fea = tns.getFeature(getById(12), cluster_clid, 3); + fea = tns.getFeature(getById(tns, 12), cluster_clid, 3); if ( fea.valid() ) REPORT_AND_STOP("Got feature while should obtain nothing from this TE"); PROGRESS; @@ -202,64 +201,64 @@ bool getFromExplicitTE() { -bool getRecursivelyTEbyCLID() { +bool getRecursivelyTEbyCLID(TestTNS& tns) { BEGIN_TEST; const TriggerElement* source {nullptr}; // check if the recursion goes in correct direction - auto fea = tns.getFeatureRecursively(getById(20), cluster_clid,"", source); + auto fea = tns.getFeatureRecursively(getById(tns, 20), cluster_clid,"", source); if ( fea.valid() ) REPORT_AND_STOP("Recursion goes in the wrong direction, we should not be able to get cluster from RoI"); PROGRESS; // check if the recursion starts well (i.e. the TE where objects is available should be covered as well) - fea = tns.getFeatureRecursively(getById(21), cluster_clid, "", source); + fea = tns.getFeatureRecursively(getById(tns, 21), cluster_clid, "", source); if ( not isGoodFeature(fea, cluster_clid, 3, 1, 2) ) REPORT_AND_STOP("Recursion does not start properly"); - if ( source != getById(21) ) + if ( source != getById(tns, 21) ) REPORT_AND_STOP("In no-recursion case, the source is wrong"); PROGRESS; // and finally check if the recursion works well (one step down) - fea = tns.getFeatureRecursively(getById(23), track_clid, "", source); + fea = tns.getFeatureRecursively(getById(tns, 23), track_clid, "", source); if ( not isGoodFeature(fea, track_clid, 0, 27, 32) ) REPORT_AND_STOP("Recursion does not descend properly"); - if ( source != getById(22) ) + if ( source != getById(tns, 22) ) REPORT_AND_STOP("In one step recursion case, the source is wrong"); PROGRESS; // more steps down - fea = tns.getFeatureRecursively(getById(23), cluster_clid, "", source); + fea = tns.getFeatureRecursively(getById(tns, 23), cluster_clid, "", source); if ( not isGoodFeature(fea, cluster_clid, 3, 1, 2) ) REPORT_AND_STOP("Recursion does not descend properly"); - if ( source != getById(21) ) + if ( source != getById(tns, 21) ) REPORT_AND_STOP("In more step recursion case, the source is wrong"); PROGRESS; return true; } -bool getRecursivelyTEbyLabel() { +bool getRecursivelyTEbyLabel(TestTNS& tns) { BEGIN_TEST; const TriggerElement* source {nullptr}; // first let's try invalid label - auto fea = tns.getFeatureRecursively(getById(23), cluster_clid, "invalid", source); + auto fea = tns.getFeatureRecursively(getById(tns, 23), cluster_clid, "invalid", source); if ( fea.valid() ) REPORT_AND_STOP("Feature found irrespectively of incorrect(1) label"); PROGRESS; // some other lable used by another feature - fea = tns.getFeatureRecursively(getById(23), cluster_clid, "L2Electrons", source); + fea = tns.getFeatureRecursively(getById(tns, 23), cluster_clid, "L2Electrons", source); if ( fea.valid() ) REPORT_AND_STOP("Feature found irrespectively of incorrect(2) label"); PROGRESS; // and finally good case - fea = tns.getFeatureRecursively(getById(23), cluster_clid, "L2ElectronClusters", source); + fea = tns.getFeatureRecursively(getById(tns, 23), cluster_clid, "L2ElectronClusters", source); if ( not isGoodFeature(fea, cluster_clid, 3, 1, 2) ) REPORT_AND_STOP("Feature not found using label"); PROGRESS; @@ -269,18 +268,18 @@ bool getRecursivelyTEbyLabel() { -bool ser() { +bool ser(TestTNS& tns) { std::vector<TriggerElement*> tes; tns.getAll(tes, false); - MSG("INFO", "Number of TEs before re-serailziation " << tes.size() ); + MSG("INFO", "Number of TEs before re-serialization " << tes.size() ); const size_t nTEs = tes.size(); std::vector<uint32_t> data; if ( not tns.serialize(data) ) { REPORT_AND_STOP("Serialization fails"); } - MSG("INFO", "size of serialzied navigation is " << data.size()); + MSG("INFO", "size of serialized navigation is " << data.size()); MSG("INFO", "elements: " << data[0] << " " << data[1] << " " << data[2] << " " <<data[3]); @@ -292,7 +291,7 @@ bool ser() { { // check number of all TEs std::vector<TriggerElement*> tes; tns.getAll(tes, false); - MSG("INFO", "Number of TEs after deserailziation " << tes.size() ); + MSG("INFO", "Number of TEs after deserialization " << tes.size() ); if ( tes.size() != nTEs ) REPORT_AND_STOP("Different number of TEs after re-serialization"); } @@ -316,37 +315,39 @@ int main() { ctx.setExtension( Atlas::ExtendedEventContext(xdict) ); Gaudi::Hive::setCurrentContext (ctx); - if ( build() == false ) + TestTNS tns; + + if ( build(tns) == false ) ABORT("not strictly a test but pre-conditions, nonetheless fails"); - if ( attach() == false ) + if ( attach(tns) == false ) ABORT("not strictly a test but pre-conditions, nonetheless fails"); MSG("INFO", "build navigation. test."); - if ( getFromExplicitTE() == false ) + if ( getFromExplicitTE(tns) == false ) ABORT("basic get failed"); - if ( getRecursivelyTEbyCLID() == false ) + if ( getRecursivelyTEbyCLID(tns) == false ) ABORT("Get by CLID failed"); - if ( getRecursivelyTEbyLabel() == false ) + if ( getRecursivelyTEbyLabel(tns) == false ) ABORT("Get by label failed"); // Now is the trick, we serialize the navigation and scratch the old content. - // Then we deserailize into it the old content and see if the tests still work. - if ( ser() == false ) - ABORT("Issue wiht serialziation->reset->deserialization cycle"); + // Then we deserialize into it the old content and see if the tests still work. + if ( ser(tns) == false ) + ABORT("Issue with serialziation->reset->deserialization cycle"); MSG("INFO", "tests after serialization, deserialization"); tns.dumpHolders(); - if ( getFromExplicitTE() == false ) + if ( getFromExplicitTE(tns) == false ) ABORT("basic get failed"); - if ( getRecursivelyTEbyCLID() == false ) + if ( getRecursivelyTEbyCLID(tns) == false ) ABORT("Get by CLID failed"); - if ( getRecursivelyTEbyLabel() == false ) + if ( getRecursivelyTEbyLabel(tns) == false ) ABORT("Get by label failed"); MSG("OK", "test passed"); diff --git a/Trigger/TrigEvent/TrigNavStructure/test/ut_iterators_test.cxx b/Trigger/TrigEvent/TrigNavStructure/test/ut_iterators_test.cxx index 9d4700045fc5d433b68395756fb8260e8654aadd..c35008c789a69f316948a01a9f42679bfaea8e1b 100644 --- a/Trigger/TrigEvent/TrigNavStructure/test/ut_iterators_test.cxx +++ b/Trigger/TrigEvent/TrigNavStructure/test/ut_iterators_test.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #include <stdint.h> @@ -14,7 +14,6 @@ #include "TrigNavStructure/ComboIterator.h" #include "testutils.h" using namespace HLT; -StandaloneNavigation tns; namespace ID { const te_id_type trk=22; //const te_id_type mu=33; @@ -24,14 +23,15 @@ namespace ID { const te_id_type topoMu=8000; const te_id_type topoMuCalo=9000; } -TriggerElement* makeTopoConnections(TriggerElement* t1, TriggerElement* t2, unsigned id) { +TriggerElement* makeTopoConnections(StandaloneNavigation& tns, + TriggerElement* t1, TriggerElement* t2, unsigned id) { std::vector<TriggerElement*> seeds; seeds.push_back(t1); seeds.push_back(t2); return tns.addNode(seeds, id); } -void prepareNavigation() { +void prepareNavigation(StandaloneNavigation& tns) { tns.reset(); // build RoIs (calo) TriggerElement* roi1 = tns.addRoINode(tns.getInitialNode()); @@ -47,9 +47,9 @@ void prepareNavigation() { TriggerElement* calo4 = tns.addNode(roi4, 1104); // make topo connections (1-2, and 1-3, no 2-3) - makeTopoConnections(calo1, calo2, ID::topoCalo); - makeTopoConnections(calo1, calo3, ID::topoCalo); - makeTopoConnections(calo2, calo4, ID::topoCalo)->setActiveState(false); // topo run but failed + makeTopoConnections(tns, calo1, calo2, ID::topoCalo); + makeTopoConnections(tns, calo1, calo3, ID::topoCalo); + makeTopoConnections(tns, calo2, calo4, ID::topoCalo)->setActiveState(false); // topo run but failed tns.addNode(calo1, ID::trk); tns.addNode(calo2, ID::trk); @@ -67,33 +67,34 @@ void prepareNavigation() { TriggerElement* ms3 = tns.addNode(roi7, 3303); // make topo connections - makeTopoConnections(ms1, ms2, ID::topoMu)->setActiveState(false); - makeTopoConnections(ms1, ms3, ID::topoMu); - makeTopoConnections(ms2, ms3, ID::topoMu)->setActiveState(false); + makeTopoConnections(tns, ms1, ms2, ID::topoMu)->setActiveState(false); + makeTopoConnections(tns, ms1, ms3, ID::topoMu); + makeTopoConnections(tns, ms2, ms3, ID::topoMu)->setActiveState(false); tns.addNode(ms1, ID::trk2); tns.addNode(ms2, ID::trk2); tns.addNode(ms3, ID::trk2); // make mu+electron combinations - makeTopoConnections(ms1, calo1, ID::topoMuCalo); - makeTopoConnections(ms2, calo1, ID::topoMuCalo); - makeTopoConnections(ms3, calo2, ID::topoMuCalo)->setActiveState(false); + makeTopoConnections(tns, ms1, calo1, ID::topoMuCalo); + makeTopoConnections(tns, ms2, calo1, ID::topoMuCalo); + makeTopoConnections(tns, ms3, calo2, ID::topoMuCalo)->setActiveState(false); } -void printCombination(size_t n, const TEVec& comb) { +void printCombination(StandaloneNavigation& tns, + size_t n, const TEVec& comb) { const TriggerElement* te1 = tns.getDirectPredecessors(comb[0])[0]; const TriggerElement* te2 = tns.getDirectPredecessors(comb[1])[0]; MSG("INFO", "Combination " << n <<" of TEs seeded of " << te1->getId() << " " << te2->getId()); } -size_t iterateAndPrint(ComboIteratorBase& it) { +size_t iterateAndPrint(StandaloneNavigation& tns, ComboIteratorBase& it) { size_t counter = 0; while( it.isValid() ) { TEVec comb; comb = it.combination(); - printCombination(counter, comb); + printCombination(tns, counter, comb); counter++; it++; } @@ -101,7 +102,7 @@ size_t iterateAndPrint(ComboIteratorBase& it) { } -bool testPlainIteratorSymmetric() { +bool testPlainIteratorSymmetric(StandaloneNavigation& tns) { BEGIN_TEST; TEVec trks; tns.getAllOfType(ID::trk, trks); @@ -112,7 +113,7 @@ bool testPlainIteratorSymmetric() { if ( not it.isValid() ) REPORT_AND_STOP("Newly made ComboIterator is invalid"); PROGRESS; - size_t counter = iterateAndPrint(it); + size_t counter = iterateAndPrint(tns, it); if ( counter != 6 ) REPORT_AND_STOP("To few combinations"); @@ -121,7 +122,7 @@ bool testPlainIteratorSymmetric() { } -bool testPlainIteratorAsymmetric() { +bool testPlainIteratorAsymmetric(StandaloneNavigation& tns) { BEGIN_TEST; TEVec trksCalo; tns.getAllOfType(ID::trk, trksCalo); @@ -133,7 +134,7 @@ bool testPlainIteratorAsymmetric() { if ( not it.isValid() ) REPORT_AND_STOP("Newly made ComboIterator is invalid"); - size_t counter = iterateAndPrint(it); + size_t counter = iterateAndPrint(tns, it); if ( counter != trksCalo.size()*trksMu.size()) REPORT_AND_STOP("Wrong number of combinations " << counter); @@ -143,7 +144,7 @@ bool testPlainIteratorAsymmetric() { -bool testTopoIterator() { +bool testTopoIterator(StandaloneNavigation& tns) { BEGIN_TEST; TEVec trksCalo; tns.getAllOfType(ID::trk, trksCalo); @@ -156,7 +157,7 @@ bool testTopoIterator() { std::vector<TEVec> zipped{trksCalo, trksCalo}; ComboIteratorTopo it(zipped, &tns, ID::topoCalo); it.rewind(); - size_t counter = iterateAndPrint(it); + size_t counter = iterateAndPrint(tns, it); if ( counter != 2 ) REPORT_AND_STOP("Topo iterator provides wrong number of combinations (2)" << counter ); } @@ -165,7 +166,7 @@ bool testTopoIterator() { std::vector<TEVec> zipped{trksMu, trksMu}; ComboIteratorTopo it(zipped, &tns, ID::topoMu); it.rewind(); - size_t counter = iterateAndPrint(it); + size_t counter = iterateAndPrint(tns, it); if ( counter != 1 ) REPORT_AND_STOP("Topo iterator provides wrong number of combinations (1)" << counter ); } @@ -174,7 +175,7 @@ bool testTopoIterator() { std::vector<TEVec> zipped{trksMu, trksCalo}; ComboIteratorTopo it(zipped, &tns, ID::topoMu); // this is on purpose there should be 0 combs as topoMu never spans caloTEs it.rewind(); - size_t counter = iterateAndPrint(it); + size_t counter = iterateAndPrint(tns, it); if ( counter != 0 ) REPORT_AND_STOP("Topo iterator provides wrong number of combinations (0)" << counter ); } @@ -183,7 +184,7 @@ bool testTopoIterator() { std::vector<TEVec> zipped{trksMu, trksCalo}; ComboIteratorTopo it(zipped, &tns, ID::topoMuCalo); it.rewind(); - size_t counter = iterateAndPrint(it); + size_t counter = iterateAndPrint(tns, it); if ( counter != 2 ) REPORT_AND_STOP("Topo iterator provides wrong number of combinations (2)" << counter ); } @@ -206,15 +207,16 @@ int main() { ctx.setExtension( Atlas::ExtendedEventContext(xdict) ); Gaudi::Hive::setCurrentContext (ctx); - prepareNavigation(); + StandaloneNavigation tns; + prepareNavigation(tns); - if ( not testPlainIteratorSymmetric() ) - ABORT("testPlainIteratorAsymmetric() test failed"); + if ( not testPlainIteratorSymmetric(tns) ) + ABORT("testPlainIteratorSymmetric() test failed"); - if ( not testPlainIteratorAsymmetric() ) + if ( not testPlainIteratorAsymmetric(tns) ) ABORT("testPlainIteratorAsymmetric() test failed"); - if (not testTopoIterator()) + if (not testTopoIterator(tns)) ABORT("testTopoIterator() test failed"); MSG("OK", "Test passed");