Commit cf9227b4 authored by Attila Krasznahorkay's avatar Attila Krasznahorkay Committed by Graeme Stewart
Browse files

Defining a CLID for xAOD::TrigPassBits (xAODTrigger-00-00-45)

2015-10-28 Attila Krasznahorkay <Attila.Krasznahorkay@cern.ch>
	* Declared a CLID for xAOD::TrigPassBits as well, as it's needed
	  by the navigation when attaching it. Even if only the container
	  is recorded into StoreGate.
	* Tagging as xAODTrigger-00-00-45

2015-10-28 Attila Krasznahorkay <Attila.Krasznahorkay@cern.ch>
	* Removed the DataLink code from TrigPassBits, as we agreed that
	  the uniquie key of the object would be coming from the navigation
	  instead. (We would use the subTypeIndex variable.)
	* Created an xAOD::makeTrigPassBits function, which is much like
	  the HLT::makeTrigPassBits function, just making use of some nice
	  new C++11 coding.
	* Updated the unit test to check the behaviour of the new code.
	* Tagging as xAODTrigger-00-00-44

2015-10-27 Attila Krasznahorkay <Attila.Krasznahorkay@cern.ch>
	* Extended xAOD::TrigPassBits to hold on to the CLID, and some
	  sort of hashed key of the target container that it describes.
	  This key right now tries to store the hashed key provided by
...
(Long ChangeLog diff - truncated)
parent ef89ac1d
......@@ -2,7 +2,7 @@
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id: ByteStreamAuxContainer_v1.cxx 611308 2014-08-11 16:51:49Z ssnyder $
// $Id: ByteStreamAuxContainer_v1.cxx 658394 2015-04-01 12:48:35Z krasznaa $
// System include(s):
#include <iostream>
......@@ -23,7 +23,8 @@ namespace xAOD {
m_int(), m_float(), m_vecInt(), m_vecFloat(),
m_staticVecs(), m_dynamicVecs(),
m_locked( false ),
m_tick( 0 ) {
m_tick( 0 ),
m_name( "UNKNOWN" ) {
}
......@@ -37,7 +38,8 @@ namespace xAOD {
// But the internal pointers are not:
m_staticVecs(),
m_dynamicVecs(), m_locked( false ),
m_tick( 1 ) {
m_tick( 1 ),
m_name( parent.m_name ) {
}
......@@ -71,9 +73,16 @@ namespace xAOD {
m_auxids = rhs.m_auxids;
++m_tick;
// But then, reset the internal pointers:
m_staticVecs.clear();
// The static variables should be left alone. Those should still
// point to the correct places in memory. But the dynamic variables
// need to be cleared out. Those will be re-created when/if needed.
for( auto* ptr : m_dynamicVecs ) {
delete ptr;
}
m_dynamicVecs.clear();
// Copy the container's name:
m_name = rhs.m_name;
}
return *this;
......@@ -108,6 +117,109 @@ namespace xAOD {
return getWritableAuxIDs();
}
/// Get a pointer to a given array, as a decoration.
void* ByteStreamAuxContainer_v1::getDecoration (auxid_t auxid,
size_t size,
size_t capacity)
{
guard_t guard (m_mutex);
// Does this variable already exist?
void* ret = 0;
if( ( auxid < m_staticVecs.size() ) && ( m_staticVecs[ auxid ] ) ) {
ret = m_staticVecs[ auxid ]->toPtr();
}
// If it's a dynamic one:
else if( ( auxid < m_dynamicVecs.size() ) &&
( m_dynamicVecs[ auxid ] ) ) {
ret = m_dynamicVecs[ auxid ]->toPtr();
}
if (!ret)
ret = getData1 (auxid, 0, 0, true, true);
if (ret) {
// Raise exception if locked and not a decoration.
if (m_locked) {
if ( ! (auxid < m_isDecoration.size() && m_isDecoration[auxid]) )
throw SG::ExcStoreLocked (auxid);
}
return ret;
}
// Make a new variable.
ret = getData1 (auxid, size, capacity, false, true);
// If locked, mark as a decoration.
if (m_locked) {
if (m_isDecoration.size() <= auxid)
m_isDecoration.resize (auxid+1);
m_isDecoration[auxid] = true;
}
return ret;
}
void ByteStreamAuxContainer_v1::lock()
{
guard_t guard (m_mutex);
m_locked = true;
}
void ByteStreamAuxContainer_v1::clearDecorations()
{
guard_t guard (m_mutex);
const SG::AuxTypeRegistry& r = SG::AuxTypeRegistry::instance();
size_t sz = m_isDecoration.size();
for (auxid_t auxid = 0; auxid < sz; auxid++) {
if (m_isDecoration[auxid]) {
if (m_dynamicVecs[auxid]) {
delete m_dynamicVecs[auxid];
m_dynamicVecs[auxid] = 0;
m_auxids.erase( auxid );
++m_tick;
const std::string name = r.getName( auxid );
const std::type_info* ti = r.getType( auxid );
if (ti == &typeid(int))
m_int.erase (name);
else if (ti == &typeid(float))
m_float.erase (name);
else if (ti == &typeid(std::vector<int>))
m_vecInt.erase (name);
else if (ti == &typeid(std::vector<float>))
m_vecFloat.erase (name);
}
}
}
m_isDecoration.clear();
}
size_t ByteStreamAuxContainer_v1::size() const
{
guard_t guard (m_mutex);
auxid_set_t::const_iterator i = m_auxids.begin();
auxid_set_t::const_iterator end = m_auxids.end();
for (; i != end; ++i) {
if (*i < m_staticVecs.size() && m_staticVecs[*i]) {
size_t sz = m_staticVecs[*i]->size();
if (sz > 0)
return sz;
}
if (*i < m_dynamicVecs.size() && m_dynamicVecs[*i]) {
size_t sz = m_dynamicVecs[*i]->size();
if (sz > 0)
return sz;
}
}
return 0;
}
void* ByteStreamAuxContainer_v1::getData( auxid_t auxid, size_t size,
size_t capacity ) {
......@@ -235,6 +347,17 @@ namespace xAOD {
return;
}
const char* ByteStreamAuxContainer_v1::name() const {
return m_name.c_str();
}
void ByteStreamAuxContainer_v1::setName( const char* name ) {
m_name = name;
return;
}
/// Look for variable auxid in pers.
/// If not found, create it if capacity != 0.
template< typename T >
......@@ -342,108 +465,4 @@ namespace xAOD {
return 0;
}
/// Get a pointer to a given array, as a decoration.
void* ByteStreamAuxContainer_v1::getDecoration (auxid_t auxid,
size_t size,
size_t capacity)
{
guard_t guard (m_mutex);
// Does this variable already exist?
void* ret = 0;
if( ( auxid < m_staticVecs.size() ) && ( m_staticVecs[ auxid ] ) ) {
ret = m_staticVecs[ auxid ]->toPtr();
}
// If it's a dynamic one:
else if( ( auxid < m_dynamicVecs.size() ) &&
( m_dynamicVecs[ auxid ] ) ) {
ret = m_dynamicVecs[ auxid ]->toPtr();
}
if (!ret)
ret = getData1 (auxid, 0, 0, true, true);
if (ret) {
// Raise exception if locked and not a decoration.
if (m_locked) {
if ( ! (auxid < m_isDecoration.size() && m_isDecoration[auxid]) )
throw SG::ExcStoreLocked (auxid);
}
return ret;
}
// Make a new variable.
ret = getData1 (auxid, size, capacity, false, true);
// If locked, mark as a decoration.
if (m_locked) {
if (m_isDecoration.size() <= auxid)
m_isDecoration.resize (auxid+1);
m_isDecoration[auxid] = true;
}
return ret;
}
void ByteStreamAuxContainer_v1::lock()
{
guard_t guard (m_mutex);
m_locked = true;
}
void ByteStreamAuxContainer_v1::clearDecorations()
{
guard_t guard (m_mutex);
const SG::AuxTypeRegistry& r = SG::AuxTypeRegistry::instance();
size_t sz = m_isDecoration.size();
for (auxid_t auxid = 0; auxid < sz; auxid++) {
if (m_isDecoration[auxid]) {
if (m_dynamicVecs[auxid]) {
delete m_dynamicVecs[auxid];
m_dynamicVecs[auxid] = 0;
m_auxids.erase( auxid );
++m_tick;
const std::string name = r.getName( auxid );
const std::type_info* ti = r.getType( auxid );
if (ti == &typeid(int))
m_int.erase (name);
else if (ti == &typeid(float))
m_float.erase (name);
else if (ti == &typeid(std::vector<int>))
m_vecInt.erase (name);
else if (ti == &typeid(std::vector<float>))
m_vecFloat.erase (name);
}
}
}
m_isDecoration.clear();
}
size_t ByteStreamAuxContainer_v1::size() const
{
guard_t guard (m_mutex);
auxid_set_t::const_iterator i = m_auxids.begin();
auxid_set_t::const_iterator end = m_auxids.end();
for (; i != end; ++i) {
if (*i < m_staticVecs.size() && m_staticVecs[*i]) {
size_t sz = m_staticVecs[*i]->size();
if (sz > 0)
return sz;
}
if (*i < m_dynamicVecs.size() && m_dynamicVecs[*i]) {
size_t sz = m_dynamicVecs[*i]->size();
if (sz > 0)
return sz;
}
}
return 0;
}
} // namespace xAOD
......@@ -2,7 +2,7 @@
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id: EmTauRoI_v1.cxx 625821 2014-11-03 17:03:16Z krasznaa $
// $Id: EmTauRoI_v1.cxx 652708 2015-03-09 15:46:47Z krasznaa $
// System include(s):
#include <stdexcept>
......@@ -40,9 +40,9 @@ namespace xAOD {
const uint32_t roi = roiWord();
if( ( roi & 0xc0000000 ) == 0 ) {
return CPRoIWord;
} else if( ( roi & 0xf0000000 ) == 0xa ) {
} else if( ( roi & 0xf0000000 ) == 0xa0000000 ) {
return EMRoIWord;
} else if( ( roi & 0xf0000000 ) == 0xb ) {
} else if( ( roi & 0xf0000000 ) == 0xb0000000 ) {
return TauRoIWord;
}
......
......@@ -2,7 +2,7 @@
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id: EnergySumRoIAuxInfo_v1.cxx 680153 2015-07-03 13:47:51Z krasznaa $
// $Id: EnergySumRoIAuxInfo_v1.cxx 680159 2015-07-03 14:02:33Z krasznaa $
// Local includes
#include "xAODTrigger/versions/EnergySumRoIAuxInfo_v1.h"
......
......@@ -2,7 +2,7 @@
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id: JetEtRoIAuxInfo_v1.cxx 634618 2014-12-09 02:37:22Z ssnyder $
// $Id: JetEtRoIAuxInfo_v1.cxx 680159 2015-07-03 14:02:33Z krasznaa $
// Local include(s):
#include "xAODTrigger/versions/JetEtRoIAuxInfo_v1.h"
......@@ -10,9 +10,9 @@
namespace xAOD {
JetEtRoIAuxInfo_v1::JetEtRoIAuxInfo_v1()
: AuxInfoBase() {
: AuxInfoBase(),
roiWord( 0 ), thrNames() {
roiWord = 0;
AUX_VARIABLE( roiWord );
AUX_VARIABLE( thrNames );
}
......
......@@ -2,7 +2,7 @@
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id: TrigDecisionAuxInfo_v1.cxx 680153 2015-07-03 13:47:51Z krasznaa $
// $Id: TrigDecisionAuxInfo_v1.cxx 680159 2015-07-03 14:02:33Z krasznaa $
// Local include(s):
#include "xAODTrigger/versions/TrigDecisionAuxInfo_v1.h"
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id: TrigPassBitsAuxContainer_v1.cxx 703368 2015-10-27 08:45:13Z krasznaa $
// Local include(s):
#include "xAODTrigger/versions/TrigPassBitsAuxContainer_v1.h"
namespace xAOD {
TrigPassBitsAuxContainer_v1::TrigPassBitsAuxContainer_v1()
: AuxContainerBase() {
AUX_VARIABLE( size );
AUX_VARIABLE( passBits );
AUX_VARIABLE( containerKey );
AUX_VARIABLE( containerClid );
}
} // namespace xAOD
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id: TrigPassBits_v1.cxx 703368 2015-10-27 08:45:13Z krasznaa $
// xAOD include(s):
#include "xAODCore/AuxStoreAccessorMacros.h"
// Local include(s):
#include "xAODTrigger/versions/TrigPassBits_v1.h"
namespace xAOD {
TrigPassBits_v1::TrigPassBits_v1()
: SG::AuxElement(), m_container( 0 ) {
}
/// Non-template function for marking an element with the specified
/// index as passing/non-passing. Performs fewer checks than the
/// template function, so should be used with care.
///
/// @param index The index of the object to set the state of
/// @param passed The "passing state" of the object with the specified index
///
void TrigPassBits_v1::markPassing( size_t index, bool passed ) {
// A sanity check:
if( index >= size() ) {
throw std::runtime_error( "Index out of range" );
}
// Access the serialised bits:
static SG::AuxElement::Accessor< std::vector< uint32_t > >
accBits( "passBits" );
std::vector< uint32_t >& bits = accBits( *this );
// Calculate which bit to modify:
const size_t vec_element = index / 32;
const size_t vec_index = index % 32;
// Another sanity check:
if( vec_element >= bits.size() ) {
throw std::runtime_error( "The object is in an inconsistent state" );
}
// Set the bit:
const uint32_t bit = ( 0x1 << vec_index );
uint32_t mask = bits[ vec_element ];
if( passed ) {
mask |= bit;
} else {
mask &= ~bit;
}
bits[ vec_element ] = mask;
return;
}
/// Non-template function for checking the state of an object with a given
/// index inside the container.
///
/// @param index The index of the object to check the state of
/// @returns The "passing state" of the object with the specified index
///
bool TrigPassBits_v1::isPassing( size_t index ) const {
// A sanity check:
if( index >= size() ) {
throw std::runtime_error( "Index out of range" );
}
// Access the serialised bits:
const std::vector< uint32_t >& bits = passBits();
// Calculate the bit to extract:
const size_t vec_element = index / 32;
const size_t vec_index = index % 32;
// Another sanity check:
if( vec_element >= bits.size() ) {
throw std::runtime_error( "The object is in an inconsistent state" );
}
// Extract the bit:
const uint32_t bit = ( 0x1 << vec_index );
const uint32_t mask = bits[ vec_element ];
return ( mask & bit );
}
// Implementation of the raw accessor functions:
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER( TrigPassBits_v1, uint32_t,
size, setSize )
AUXSTORE_OBJECT_SETTER_AND_GETTER( TrigPassBits_v1, std::vector< uint32_t >,
passBits, setPassBits )
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER( TrigPassBits_v1, uint32_t,
containerKey, setContainerKey )
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER( TrigPassBits_v1, uint32_t,
containerClid, setContainerClid )
} // namespace xAOD
......@@ -2,7 +2,7 @@
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id: TriggerMenu_v1.cxx 683716 2015-07-17 10:03:58Z krasznaa $
// $Id: TriggerMenu_v1.cxx 647153 2015-02-16 13:34:19Z krasznaa $
// System include(s):
#include <iostream>
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
//simple includes to force the CLASS_DEF etc to be encountered during compile
#include "xAODTrigger/BunchConfContainer.h"
#include "xAODTrigger/BunchConfAuxContainer.h"
#include "xAODTrigger/EmTauRoIContainer.h"
#include "xAODTrigger/EmTauRoIAuxContainer.h"
#include "xAODTrigger/EnergySumRoI.h"
#include "xAODTrigger/EnergySumRoIAuxInfo.h"
#include "xAODTrigger/JetRoIContainer.h"
#include "xAODTrigger/JetRoIAuxContainer.h"
#include "xAODTrigger/MuonRoIContainer.h"
#include "xAODTrigger/MuonRoIAuxContainer.h"
#include "xAODTrigger/TrigCompositeContainer.h"
#include "xAODTrigger/TrigCompositeAuxContainer.h"
#include "xAODTrigger/TrigDecision.h"
#include "xAODTrigger/TrigDecisionAuxInfo.h"
#include "xAODTrigger/TrigNavigation.h"
#include "xAODTrigger/TrigNavigationAuxInfo.h"
#include "xAODTrigger/TriggerMenuContainer.h"
#include "xAODTrigger/TriggerMenuAuxContainer.h"
#include "xAODTrigger/TrigPassBitsContainer.h"
#include "xAODTrigger/TrigPassBitsAuxContainer.h"
......@@ -16,7 +16,7 @@ PACKAGE_DEP = AthContainersInterfaces AthContainers AthLinks xAODCore
PACKAGE_TRYDEP =
PACKAGE_CLEAN =
PACKAGE_NOGRID =
PACKAGE_PEDANTIC = 0
PACKAGE_PEDANTIC = 1
PACKAGE_NOOPT = 0
PACKAGE_NOCC = 0
PACKAGE_REFLEX = 1
......
package xAODTrigger
# $Id: requirements 631318 2014-11-26 18:32:04Z krasznaa $
# $Id: requirements 683359 2015-07-16 09:24:36Z will $
author Lukas Heinrich <Lukas.Heinrich@cern.ch>
author Gordon Watts <gwatts@uw.edu>
......@@ -27,3 +27,5 @@ use AtlasROOT AtlasROOT-* External
apply_pattern lcgdict dict=xAODTrigger selectionfile=selection.xml \
headerfiles="../xAODTrigger/xAODTriggerDict.h" \
extralibfiles=../Root/dict/*.cxx
apply_pattern do_genCLIDDB library=xAODTrigger
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id: ut_xaodtrigger_trigpassbits_test.cxx 704009 2015-10-28 08:32:05Z krasznaa $
// System include(s):
#include <iostream>
#include <stdexcept>
#include <vector>
// Local include(s):
#include "xAODTrigger/TrigPassBits.h"
/// Helper macro for testing the code
#define SIMPLE_ASSERT( EXP ) \
do { \
const bool result = EXP; \
if( ! result ) { \
std::cerr << __FILE__ << ":" << __LINE__ \
<< " Failed test: " << #EXP << std::endl; \
throw std::runtime_error( "Failed " #EXP ); \
} \
} while( 0 )
/// Helper struct
struct StructA {};
CLASS_DEF( std::vector< StructA* >, 12345678, 1 )
/// Testing the non-templated functions
void simpleFunctions() {
// Create an object to test:
xAOD::TrigPassBits bits;
bits.makePrivateStore();
// Initialise it:
bits.setSize( 40 );
bits.setPassBits( std::vector< uint32_t >( 2, 0 ) );
// Run some simple tests on it:
bits.markPassing( 20, true );
for( int i = 0; i < 40; ++i ) {
SIMPLE_ASSERT( bits.isPassing( i ) == ( i == 20 ) );
}
bits.markPassing( 30, true );
for( int i = 0; i < 40; ++i ) {
SIMPLE_ASSERT( bits.isPassing( i ) == ( i == 20 ||
i == 30 ) );
}
bits.markPassing( 20, false );
for( int i = 0; i < 40; ++i ) {
SIMPLE_ASSERT( bits.isPassing( i ) == ( i == 30 ) );
}
// Test some failure modes:
bool exceptionThrown = false;
try {
bits.markPassing( 50 );
} catch( const std::exception& ) {
exceptionThrown = true;
}
SIMPLE_ASSERT( exceptionThrown == true );
exceptionThrown = false;
try {