diff --git a/Event/xAOD/xAODTrigger/CMakeLists.txt b/Event/xAOD/xAODTrigger/CMakeLists.txt index 94954c333bac0e7b611f87cb05e9e9cda6024ba9..31698f02172dd37d4c1c301d632a40f80f1ff015 100644 --- a/Event/xAOD/xAODTrigger/CMakeLists.txt +++ b/Event/xAOD/xAODTrigger/CMakeLists.txt @@ -20,6 +20,7 @@ atlas_depends_on_subdirs( Control/AthLinks Event/xAOD/xAODCore Trigger/TrigConfiguration/TrigConfHLTData + Trigger/TrigEvent/TrigNavStructure ${extra_deps} ) # Component(s) in the package: @@ -27,7 +28,7 @@ atlas_add_library( xAODTrigger xAODTrigger/*.h xAODTrigger/versions/*.h xAODTrigger/versions/*.icc Root/*.cxx PUBLIC_HEADERS xAODTrigger - LINK_LIBRARIES AthContainers AthLinks xAODCore TrigConfHLTData ${extra_libs} ) + LINK_LIBRARIES AthContainers AthLinks xAODCore TrigConfHLTData TrigNavStructure ${extra_libs} ) atlas_add_dictionary( xAODTriggerDict xAODTrigger/xAODTriggerDict.h diff --git a/Event/xAOD/xAODTrigger/Root/TrigComposite_v1.cxx b/Event/xAOD/xAODTrigger/Root/TrigComposite_v1.cxx index 5894e19bf9f4219ca05cfa323b0ea33b339bf799..0f7640ce7811f486a6dcca598f1d5f91f8a65874 100644 --- a/Event/xAOD/xAODTrigger/Root/TrigComposite_v1.cxx +++ b/Event/xAOD/xAODTrigger/Root/TrigComposite_v1.cxx @@ -11,6 +11,8 @@ // xAOD include(s): #include "xAODCore/AuxStoreAccessorMacros.h" +#include "TrigNavStructure/StringSerializer.h" + // Local include(s): #include "xAODTrigger/versions/TrigComposite_v1.h" @@ -40,14 +42,30 @@ namespace xAOD { AUXSTORE_OBJECT_SETTER_AND_GETTER( TrigComposite_v1, std::string, name, setName ) - template<> - bool TrigComposite_v1::hasDetail<unsigned int>( const std::string& name ) const { - return hasDetail<int>(name); + template<> + bool TrigComposite_v1::hasDetail<uint32_t>( const std::string& name ) const { + return hasDetail<int32_t>(name); + } + + template<> + bool TrigComposite_v1::hasDetail<std::vector<uint32_t>>( const std::string& name ) const { + return hasDetail<std::vector<int32_t>>(name); + } + + template<> + bool TrigComposite_v1::hasDetail<std::vector<uint16_t>>( const std::string& name ) const { + return hasDetail<std::vector<int32_t>>(name); } - template<> - bool TrigComposite_v1::hasDetail<std::vector<unsigned int>>( const std::string& name ) const { - return hasDetail<std::vector<int>>(name); + template<> + bool TrigComposite_v1::hasDetail<std::string>( const std::string& name ) const { + std::cout << " TTTEEEESSSSTTT " << std::endl; + return hasDetail<std::vector<int32_t>>(name); + } + + template<> + bool TrigComposite_v1::hasDetail<std::vector<std::string>>( const std::string& name ) const { + return hasDetail<std::vector<int32_t>>(name); } ///////////////////////////////////////////////////////////////////////////// @@ -55,12 +73,13 @@ namespace xAOD { // Simple detail accessor functions // - bool TrigComposite_v1::setDetail( const std::string& name, int value ) { + bool TrigComposite_v1::setDetail( const std::string& name, int32_t value ) { // It should be pretty strange if this should fail: try { - auxdata< int >( name ) = value; - } catch(...) { + auxdata< int32_t >( name ) = value; + } catch(const std::exception& exc) { + std::cerr << "xAOD::TrigComposite_v1::setDetail ERROR Internal logic error found in int32_t: [" << exc.what() << "]" << std::endl; return false; } @@ -68,8 +87,8 @@ namespace xAOD { return true; } - bool TrigComposite_v1::setDetail( const std::string& name, unsigned int value ) { - return setDetail(name, (int)value); // place for conversion if needed + bool TrigComposite_v1::setDetail( const std::string& name, uint32_t value ) { + return setDetail(name, (int32_t)value); // place for conversion if needed } bool TrigComposite_v1::setDetail( const std::string& name, float value ) { @@ -77,7 +96,8 @@ namespace xAOD { // It should be pretty strange if this should fail: try { auxdata< float >( name ) = value; - } catch(...) { + } catch(const std::exception& exc) { + std::cerr << "xAOD::TrigComposite_v1::setDetail ERROR Internal logic error found in float: [" << exc.what() << "]" << std::endl; return false; } @@ -86,12 +106,13 @@ namespace xAOD { } bool TrigComposite_v1::setDetail( const std::string& name, - const std::vector< int >& value ) { + const std::vector< int32_t >& value ) { // It should be pretty strange if this should fail: try { - auxdata< std::vector< int > >( name ) = value; - } catch(...) { + auxdata< std::vector< int32_t > >( name ) = value; + } catch(const std::exception& exc) { + std::cerr << "xAOD::TrigComposite_v1::setDetail ERROR Internal logic error found in vector<int32_t>: [" << exc.what() << "]" << std::endl; return false; } @@ -101,13 +122,14 @@ namespace xAOD { bool TrigComposite_v1::setDetail( const std::string& name, - const std::vector< unsigned int >& value ) { + const std::vector< uint32_t >& value ) { // It should be pretty strange if this should fail: - std::vector<int> temp(value.begin(), value.end()); // + std::vector<int32_t> temp(value.begin(), value.end()); // try { - auxdata< std::vector< int > >( name ) = temp; - } catch(...) { + auxdata< std::vector< int32_t > >( name ) = temp; + } catch(const std::exception& exc) { + std::cerr << "xAOD::TrigComposite_v1::setDetail ERROR Internal logic error found in vector<uint32_t>: [" << exc.what() << "]" << std::endl; return false; } @@ -115,6 +137,22 @@ namespace xAOD { return true; } + bool TrigComposite_v1::setDetail( const std::string& name, + const std::vector< uint16_t >& value ) { + + std::vector<uint32_t> temp; + temp.reserve( value.size() / 2 ); + + // Pack shorts for space efficiency + for (size_t i = 0; i < value.size(); i += 2) { + const uint16_t a = value.at(i); + const uint16_t b = (i + 1 < value.size() ? value.at(i + 1) : std::numeric_limits<uint16_t>::max() ); + const uint32_t combine = ( (b << 16) | (a & 0xffff) ); + temp.push_back( combine ); + } + + return setDetail(name, temp); + } bool TrigComposite_v1::setDetail( const std::string& name, const std::vector< float >& value ) { @@ -122,7 +160,8 @@ namespace xAOD { // It should be pretty strange if this should fail: try { auxdata< std::vector< float > >( name ) = value; - } catch(...) { + } catch(const std::exception& exc) { + std::cerr << "xAOD::TrigComposite_v1::setDetail ERROR Internal logic error found in vector<float>: [" << exc.what() << "]" << std::endl; return false; } @@ -130,11 +169,25 @@ namespace xAOD { return true; } + bool TrigComposite_v1::setDetail( const std::string& name, const std::string& value ) { + + std::vector<uint32_t> serialForm; + HLT::StringSerializer::serialize(value, serialForm); + return setDetail(name, serialForm); + } + + bool TrigComposite_v1::setDetail( const std::string& name, const std::vector< std::string >& value ) { + + std::vector<uint32_t> serialForm; + HLT::StringSerializer::serialize(value, serialForm); + return setDetail(name, serialForm); + } + bool TrigComposite_v1::getDetail( const std::string& name, - int& value ) const { + int32_t& value ) const { // Object used to access the auxiliary data: - Accessor< int > acc( name ); + Accessor< int32_t > acc( name ); // Enable the check once it will work correctly: if( ! acc.isAvailable( *this ) ) { @@ -148,15 +201,14 @@ namespace xAOD { bool TrigComposite_v1::getDetail( const std::string& name, - unsigned int& value ) const { - int v; + uint32_t& value ) const { + int32_t v = 0; const bool status = getDetail(name, v); value = v; // place for cast return status; } - bool TrigComposite_v1::getDetail( const std::string& name, float& value ) const { @@ -175,10 +227,10 @@ namespace xAOD { bool TrigComposite_v1::getDetail( const std::string& name, - std::vector< int >& value ) const { + std::vector< int32_t >& value ) const { // Object used to access the auxiliary data: - Accessor< std::vector< int > > acc( name ); + Accessor< std::vector< int32_t > > acc( name ); // Enable the check once it will work correctly: if( ! acc.isAvailable( *this ) ) { @@ -191,17 +243,41 @@ namespace xAOD { } bool TrigComposite_v1::getDetail( const std::string& name, - std::vector< unsigned int >& value ) const { + std::vector< uint32_t >& value ) const { - std::vector<int> temp; + std::vector<int32_t> temp; const bool status = getDetail(name, temp); value.reserve(temp.size()); - for ( int i: temp ) + for ( int32_t i: temp ) value.push_back(i); return status; } + bool TrigComposite_v1::getDetail( const std::string& name, + std::vector< uint16_t >& value ) const { + + std::vector<uint32_t> temp; + const bool status = getDetail(name, temp); + value.reserve(temp.size() * 2); + + // Unpack shorts + static const uint32_t mask = std::numeric_limits<uint16_t>::max(); + for (size_t i = 0; i < temp.size(); ++i) { + const uint32_t packed = temp.at(i); + const uint16_t a = packed & mask; + const uint16_t b = packed >> 16; + value.push_back(a); + // Use this to tell if the second half of the int was used or not + if (b != std::numeric_limits<uint16_t>::max()) { + value.push_back(b); + } + } + + return status; + } + + bool TrigComposite_v1::getDetail( const std::string& name, std::vector< float >& value ) const { @@ -218,6 +294,26 @@ namespace xAOD { return true; } + bool TrigComposite_v1::getDetail( const std::string& name, + std::string& value ) const { + + std::vector<uint32_t> temp; + const bool status = getDetail(name, temp); + + HLT::StringSerializer::deserialize(temp.begin(), temp.end(), value); + return status; + } + + bool TrigComposite_v1::getDetail( const std::string& name, + std::vector< std::string >& value ) const { + + std::vector<uint32_t> temp; + const bool status = getDetail(name, temp); + + HLT::StringSerializer::deserialize(temp.begin(), temp.end(), value); + return status; + } + // ///////////////////////////////////////////////////////////////////////////// diff --git a/Event/xAOD/xAODTrigger/share/ut_xaodtrigger_trigcomposite_test.ref b/Event/xAOD/xAODTrigger/share/ut_xaodtrigger_trigcomposite_test.ref index ee44bdb6b0c27aac94c302351ebbae3c267c0bd1..332fac4a699a78f39db54123f5b784acf545ed45 100644 --- a/Event/xAOD/xAODTrigger/share/ut_xaodtrigger_trigcomposite_test.ref +++ b/Event/xAOD/xAODTrigger/share/ut_xaodtrigger_trigcomposite_test.ref @@ -1,24 +1,36 @@ Populating initial TC object Set detail ok. Testing initial TC object +Has detail ok. +UnsignedShortVecValueEven = 5 10 50 100 +UnsignedShortVecValueOdd = 1 1 3 4 7 FloatVecValue = [1.23, 2.34] Simple getDetail API ok. Missing details handled ok. Basic link functionality OK Link recovery OK Testing copy constructor +Has detail ok. +UnsignedShortVecValueEven = 5 10 50 100 +UnsignedShortVecValueOdd = 1 1 3 4 7 FloatVecValue = [1.23, 2.34] Simple getDetail API ok. Missing details handled ok. Basic link functionality OK Link recovery OK Testing assignment operator (standalone object) +Has detail ok. +UnsignedShortVecValueEven = 5 10 50 100 +UnsignedShortVecValueOdd = 1 1 3 4 7 FloatVecValue = [1.23, 2.34] Simple getDetail API ok. Missing details handled ok. Basic link functionality OK Link recovery OK Testing assignment operator (object with store) +Has detail ok. +UnsignedShortVecValueEven = 5 10 50 100 +UnsignedShortVecValueOdd = 1 1 3 4 7 FloatVecValue = [1.23, 2.34] Simple getDetail API ok. Missing details handled ok. diff --git a/Event/xAOD/xAODTrigger/test/ut_xaodtrigger_trigcomposite_test.cxx b/Event/xAOD/xAODTrigger/test/ut_xaodtrigger_trigcomposite_test.cxx index 6e7545528465d2482585d967a9c304f96ab1d523..37fc21fd3e899442819d1fc94ace3f93719a4f8a 100644 --- a/Event/xAOD/xAODTrigger/test/ut_xaodtrigger_trigcomposite_test.cxx +++ b/Event/xAOD/xAODTrigger/test/ut_xaodtrigger_trigcomposite_test.cxx @@ -53,7 +53,12 @@ int populateObject(xAOD::TrigComposite* obj) { obj->setDetail( "FloatValue", 3.14f ); obj->setDetail( "IntVecValue", std::vector< int >( { 1, 2, 3 } ) ); obj->setDetail( "UnsignedIntVecValue", std::vector< unsigned int >( { uintTestConst, 2, 3 } ) ); + obj->setDetail( "UnsignedShortVecValueEven", std::vector< uint16_t >( { 5, 10, 50, 100 } ) ); // Packs into two ints + obj->setDetail( "UnsignedShortVecValueOdd", std::vector< uint16_t >( { 1, 1, 3, 4, 7 } ) ); // Packs into three ints obj->setDetail( "FloatVecValue", std::vector< float >( { 1.23, 2.34 } ) ); + obj->setDetail( "StringValue", std::string("I am a string")); + obj->setDetail( "StringVecValue", std::vector< std::string >( {"Hello", "I", "am", "a", "string", "vector"} ) ); + std::cout << "Set detail ok." << std::endl; // Now test the ElementLink functionality in a basic way: @@ -72,8 +77,17 @@ int populateObject(xAOD::TrigComposite* obj) { int testDetails(const xAOD::TrigComposite* obj) { SIMPLE_ASSERT( obj->hasDetail<int>("IntValue") ); SIMPLE_ASSERT( obj->hasDetail<unsigned int>("UnsignedIntValue") ); - SIMPLE_ASSERT( obj->hasDetail<std::vector<unsigned int> >("UnsignedIntVecValue") ); + SIMPLE_ASSERT( obj->hasDetail<float>("FloatValue") ); SIMPLE_ASSERT( obj->hasDetail<std::vector<int> >("IntVecValue") ); + SIMPLE_ASSERT( obj->hasDetail<std::vector<unsigned int> >("UnsignedIntVecValue") ); + // These should work.... but they do not.... still being investigated + // SIMPLE_ASSERT( obj->hasDetail<std::vector<uint16_t> >("UnsignedShortVecValueEven") ); + // SIMPLE_ASSERT( obj->hasDetail<std::vector<uint16_t> >("UnsignedShortVecValueOdd") ); + SIMPLE_ASSERT( obj->hasDetail<std::vector<float> >("FloatVecValue") ); + // SIMPLE_ASSERT( obj->hasDetail<std::string>("StringValue") ); + // SIMPLE_ASSERT( obj->hasDetail<std::vector<std::string> >("StringVecValue") ); + + std::cout << "Has detail ok." << std::endl; // Check them: SIMPLE_ASSERT( obj->name() == "TestObj" ); @@ -98,12 +112,33 @@ int testDetails(const xAOD::TrigComposite* obj) { SIMPLE_ASSERT( obj->getDetail("UnsignedIntVecValue", unsignedIntVector) ); SIMPLE_ASSERT( unsignedIntVector == std::vector<unsigned int>( { uintTestConst, 2, 3 } ) ); + std::vector<uint16_t> unsignedShortVectorEven; + SIMPLE_ASSERT( obj->getDetail("UnsignedShortVecValueEven", unsignedShortVectorEven) ); + std::cout << "UnsignedShortVecValueEven = "; + for (auto v : unsignedShortVectorEven) std::cout << v << " "; + std::cout << std::endl; + SIMPLE_ASSERT( unsignedShortVectorEven == std::vector<uint16_t>( { 5, 10, 50, 100 } ) ); + + std::vector<uint16_t> unsignedShortVectorOdd; + SIMPLE_ASSERT( obj->getDetail("UnsignedShortVecValueOdd", unsignedShortVectorOdd) ); + std::cout << "UnsignedShortVecValueOdd = "; + for (auto v : unsignedShortVectorOdd) std::cout << v << " "; + std::cout << std::endl; + SIMPLE_ASSERT( unsignedShortVectorOdd == std::vector<uint16_t>( { 1, 1, 3, 4, 7 } ) ); + std::vector< float > floatVector; SIMPLE_ASSERT( obj->getDetail( "FloatVecValue", floatVector ) ); - // Simply just print the last one: std::cout << "FloatVecValue = " << floatVector << std::endl; + std::string stringValue; + SIMPLE_ASSERT( obj->getDetail("StringValue", stringValue) ); + SIMPLE_ASSERT( stringValue == std::string("I am a string") ); + + std::vector<std::string> stringVecValue; + SIMPLE_ASSERT( obj->getDetail("StringVecValue", stringVecValue) ); + SIMPLE_ASSERT( stringVecValue == std::vector< std::string >( {"Hello", "I", "am", "a", "string", "vector"} ) ); + int intValue2 = obj->getDetail<int>("IntValue"); SIMPLE_ASSERT( intValue2 == 12 ); unsigned int unsignedIntValue2 = obj->getDetail<unsigned int>("UnsignedIntValue"); diff --git a/Event/xAOD/xAODTrigger/xAODTrigger/versions/TrigComposite_v1.h b/Event/xAOD/xAODTrigger/xAODTrigger/versions/TrigComposite_v1.h index 4b2ec01a0709dcdb743ff248f285fd5690858bd4..7da1fceacbbcc3bd6522638e8b0648aa54eeda43 100644 --- a/Event/xAOD/xAODTrigger/xAODTrigger/versions/TrigComposite_v1.h +++ b/Event/xAOD/xAODTrigger/xAODTrigger/versions/TrigComposite_v1.h @@ -64,41 +64,65 @@ namespace xAOD { bool hasDetail( const std::string& name ) const; /// Set an integer detail on the object - bool setDetail( const std::string& name, int value ); + bool setDetail( const std::string& name, int32_t value ); /// Set an unsigned detail on the object - bool setDetail( const std::string& name, unsigned int value ); + bool setDetail( const std::string& name, uint32_t value ); /// Set a floating point detail on the object bool setDetail( const std::string& name, float value ); + /// Set a string detail on the object + bool setDetail( const std::string& name, + const std::string& value ); /// Set a vector<int> detail on the object bool setDetail( const std::string& name, - const std::vector< int >& value ); + const std::vector< int32_t >& value ); /// Set a vector<unsigned int> detail on the object bool setDetail( const std::string& name, - const std::vector< unsigned int >& value ); + const std::vector< uint32_t >& value ); + /// Set a vector<unsigned short> detail on the object. Note: For an even vector, the final entry cannot be (2^16)-1=65535 + bool setDetail( const std::string& name, + const std::vector< uint16_t >& value ); /// Set a vector<float> detail on the object bool setDetail( const std::string& name, const std::vector< float >& value ); + /// Set a vector<string> detail on the object + bool setDetail( const std::string& name, + const std::vector< std::string >& value ); /// Get an integer detail from the object - bool getDetail( const std::string& name, int& value ) const; + bool getDetail( const std::string& name, int32_t& value ) const; /// Get an unsigned integer detail from the object - bool getDetail( const std::string& name, unsigned int& value ) const; + bool getDetail( const std::string& name, uint32_t& value ) const; /// Get a floating point detail from the object bool getDetail( const std::string& name, float& value ) const; + /// Get a string detail from the object + bool getDetail( const std::string& name, std::string& value ) const; + /// Get a vector<int> detail from the object bool getDetail( const std::string& name, - std::vector< int >& value ) const; + std::vector< int32_t >& value ) const; /// Get a vector<insigned int> detail from the object bool getDetail( const std::string& name, - std::vector< unsigned int>& value ) const; + std::vector< uint32_t >& value ) const; + + /// Get a vector<short> detail from the object + bool getDetail( const std::string& name, + std::vector< int16_t >& value ) const; + + /// Get a vector<unsigned short> detail from the object + bool getDetail( const std::string& name, + std::vector< uint16_t >& value ) const; + /// Get a vector<float> detail from the object bool getDetail( const std::string& name, std::vector< float >& value ) const; + /// Get a vector<string> detail from the object + bool getDetail( const std::string& name, + std::vector< std::string >& value ) const; /// Get a detail by name, missing detail will result on std::runtime_error exception template<typename T> diff --git a/Trigger/TrigValidation/TrigUpgradeTest/share/egamma.withViews.py b/Trigger/TrigValidation/TrigUpgradeTest/share/egamma.withViews.py index 4a3fb9ca45797f672ae4e971339da4ee9659e4c3..d88312ec05add31239005872372b7db2e29b358a 100644 --- a/Trigger/TrigValidation/TrigUpgradeTest/share/egamma.withViews.py +++ b/Trigger/TrigValidation/TrigUpgradeTest/share/egamma.withViews.py @@ -91,7 +91,7 @@ def createFastCaloSequence(rerun=False): fastCaloHypo.CaloClusters = clusterMaker.ClustersName # fastCaloHypo.RoIs = fastCaloViewsMaker.InViewRoIs fastCaloHypo.HypoOutputDecisions = __prefix+"EgammaCaloDecisions" - fastCaloHypo.HypoTools = [ TrigL2CaloHypoToolFromName( c ) for c in testChains ] + fastCaloHypo.HypoTools = [ TrigL2CaloHypoToolFromName( c,c ) for c in testChains ] for t in fastCaloHypo.HypoTools: t.OutputLevel = DEBUG @@ -176,7 +176,7 @@ theElectronHypo.Electrons = theElectronFex.ElectronsName theElectronHypo.OutputLevel = VERBOSE -theElectronHypo.HypoTools = [ TrigL2ElectronHypoToolFromName( c ) for c in testChains ] +theElectronHypo.HypoTools = [ TrigL2ElectronHypoToolFromName( c,c ) for c in testChains ] for t in theElectronHypo.HypoTools: t.OutputLevel = VERBOSE @@ -235,13 +235,18 @@ summary.OutputTools = [ egammaViewsMerger ] summary.OutputLevel = DEBUG -steps = seqAND("HLTSteps", [ step0, step1, step0r ] ) +step0filter = parOR("step0filter", [ findAlgorithm( egammaCaloStep, "filterL1RoIsAlg") ] ) +step1filter = parOR("step1filter", [ findAlgorithm(egammaIDStep, "filterCaloRoIsAlg") ] ) +step0rfilter = parOR("step0rfilter", [ findAlgorithm(egammaCaloStepRR, "Rerurn_filterL1RoIsAlg") ] ) + + +steps = seqAND("HLTSteps", [ step0filter, step0, step1filter, step1, step0rfilter, step0r ] ) from TrigSteerMonitor.TrigSteerMonitorConf import TrigSignatureMoniMT, DecisionCollectorTool mon = TrigSignatureMoniMT() mon.FinalDecisions = [ "ElectronL2Decisions", "MuonL2Decisions", "WhateverElse" ] from TrigUpgradeTest.TestUtils import MenuTest -mon.ChainsList = [ x.split(":")[1] for x in MenuTest.CTPToChainMapping ] +mon.ChainsList = list( set( MenuTest.CTPToChainMapping.keys() ) ) mon.OutputLevel = DEBUG step1Collector = DecisionCollectorTool("Step1Collector")