Commit f9060863 authored by Scott Snyder's avatar Scott Snyder Committed by Graeme Stewart
Browse files

Fix test result comparison. (Navigation-00-08-24)

parent 99467d19
// This file's extension implies that it's C, but it's really -*- C++ -*-.
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id$
/**
* @file Navigation/AthenaBarCodeBase.h
* @author scott snyder <snyder@bnl.gov>
* @date Feb, 2011
* @brief A mixin base class implementing @c IAthenaBarCode.
* @c IAthenaBarCode should be a virtual base of the class
* using this.
*/
#ifndef NAVIGATION_ATHENABARCODEBASE_H
#define NAVIGATION_ATHENABARCODEBASE_H
#include "AthenaKernel/IAthenaBarCode.h"
#include "Navigation/AthenaBarCodeImpl.h"
class AthenaBarCodeBase
: public AthenaBarCodeImpl, virtual public IAthenaBarCode
{
public:
// Forward all the virtual functions of the interface to the Impl class.
virtual AthenaBarCode_t getAthenaBarCode() const;
virtual void setAthenaBarCode(AthenaBarCode_t id);
virtual bool hasSameAthenaBarCode(const IAthenaBarCode &obj) const;
virtual bool hasSameAthenaBarCodeExceptVersion(const IAthenaBarCode &obj) const;
virtual AthenaBarCodeVersion_t getVersion() const;
virtual void newVersion();
virtual void setVersion(AthenaBarCodeVersion_t newversion);
};
#endif // not NAVIGATION_ATHENABARCODEBASE_H
///////////////////////// -*- C++ -*- /////////////////////////////
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef ATHENABARCODEIMPL_H
#define ATHENABARCODEIMPL_H
///////////////////////////////////////////////////////////////////////////////
///
/// AthenaBarCodeImpl interface class
///
/// \author Yushu Yao
///
/// \brief barcode for all INav4Mom classes
///
// //
///////////////////////////////////////////////////////////////////////////////
// STL includes
#include <inttypes.h>
#include <iosfwd>
#include <AthenaKernel/IAthenaBarCode.h> //for static const data memebers
///////////////////////////////////////////////////////////////////////////////
//
// Universal Object Identifier for all INav4Mom Objects
//
///////////////////////////////////////////////////////////////////////////////
class StatusCode;
class AthenaBarCodeImpl {
friend class AthenaBarCodeCnv_p1;
public:
static const unsigned short TotalBits = 64;
static const unsigned short UUIDBits = 32;
static const unsigned short CounterBits = 26;
static const unsigned short VersionBits = 4;
static const unsigned short ReserveBits = 2;
static const unsigned short SUUIDBits = 0;
static const unsigned short SCounterBits = UUIDBits;
static const unsigned short SVersionBits = UUIDBits+CounterBits;
static const unsigned short SReserveBits = UUIDBits+CounterBits+VersionBits;
public:
//Constructors
virtual ~AthenaBarCodeImpl() {
}
AthenaBarCodeImpl();
public:
//Public setter and getters
AthenaBarCode_t getAthenaBarCode() const;
void setAthenaBarCode(AthenaBarCode_t id);
public:
//Comparing & Versioning Control
bool hasSameAthenaBarCode(const IAthenaBarCode &obj) const;
bool hasSameAthenaBarCodeExceptVersion(const IAthenaBarCode &obj) const;
AthenaBarCodeVersion_t getVersion() const;
void newVersion();
void setVersion(AthenaBarCodeVersion_t newversion);
std::ostream& dump(std::ostream& out) const;
//True if the athenabarcode is created in this job, meaning a newly created object. False if the object is read from a file.
bool createdInCurrentJob() const;
//Handle reserved bits, mainly for read back of older version of AthenaBarCode when the configuration of #bits for UUID,counter and version bits are different from the current one.
AthenaBarCode_t getReserveBits() const;
void setReserveBits(AthenaBarCode_t id);
// Used to set the default hash when JobIDSvc is not being used.
// Should not be called within Athena.
static void setDefaultHash (const char* jobid);
protected:
void setBits(unsigned short startbit,unsigned short nbits,AthenaBarCode_t id) const;
AthenaBarCode_t getBits(unsigned short startbit,unsigned short nbits) const ;
void initABC() const ;
private:
//UUID related
AthenaBarCode_t combineWithUUIDHash(const AthenaBarCode_t &) const;
static AthenaBarCode_t hashUUID(const char *);
void setUUIDHash(AthenaBarCode_t uuidhash) const;
AthenaBarCode_t hasUUIDHash() const;
AthenaBarCode_t getUUIDHash() const;
//data fields
static AthenaBarCode_t m_defaultHash;
static AthenaBarCode_t m_barcodeCounter;
mutable AthenaBarCode_t m_barcode;
};
inline void AthenaBarCodeImpl::setUUIDHash(AthenaBarCode_t uuidhash) const {
m_barcode = combineWithUUIDHash(uuidhash);
}
inline AthenaBarCode_t AthenaBarCodeImpl::combineWithUUIDHash(
const AthenaBarCode_t &hash) const {
AthenaBarCode_t tmp = 0;
AthenaBarCode_t lowerh = ~tmp >> (TotalBits
- UUIDBits);
AthenaBarCode_t higherh = ~tmp << (UUIDBits);
AthenaBarCode_t lower = m_barcode & lowerh;
AthenaBarCode_t higher = hash & higherh;
/*
std::cout << "AthenaBarCodeImpl::combineWithHash::hash=" << std::hex
<< hash << " lower=" << lower << " higher=" << higher << " lowerh="
<< lowerh << " higherh=" << higherh << " barcode=" << (lower
| higher) << std::endl;
*/
return lower | higher;
}
#endif // not NAVIGATION_ATHENABARCODE_H
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#include "AthenaKernel/IAthenaBarCode.h"
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef INAVIGABLE_H
#define INAVIGABLE_H
///////////////////////////////////////////////////////////////////////////////
//
// Common base type for classes representing navigable objects
//
///////////////////////////////////////////////////////////////////////////////
namespace boost {
class any;
}
class INavigationToken;
class INavigable
{
public:
virtual ~INavigable();
// enforce fillToken(,) method in derived classes!
virtual void fillToken( INavigationToken & thisToken ) const = 0;
virtual void fillToken( INavigationToken & thisToken,
const boost::any& weight ) const = 0;
};
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef INAVIGATIONCONDITION_H
#define INAVIGATIONCONDITION_H
///////////////////////////////////////////////////////////////////////////////
//
// Navigation Condition Abstract Base Class
//
///////////////////////////////////////////////////////////////////////////////
class INavigable;
class INavigationCondition
{
public:
virtual ~INavigationCondition();
// accept function
virtual bool accept( const INavigable * thisNavigable ) = 0;
// reset function
virtual void reset() = 0;
};
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef INAVIGATIONSELECTOR_H
#define INAVIGATIONSELECTOR_H
///////////////////////////////////////////////////////////////////////////////
//
// Navigation Processor Abstract Base Class
//
///////////////////////////////////////////////////////////////////////////////
template <typename T, typename PAR=double>
class INavigationSelector
{
public:
virtual ~INavigationSelector();
// check data acceptance
virtual bool accept(const T* data,PAR weight) const = 0;
// reset condition
virtual void reset() = 0;
};
template<typename T, typename PAR>
INavigationSelector<T, PAR>::~INavigationSelector()
{}
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef INAVIGATIONTOKEN_H
#define INAVIGATIONTOKEN_H
///////////////////////////////////////////////////////////////////////////////
//
// Navigation Abstract Base Class
//
// Author: H. Ma, S. Rajagopalan, P. Loch
//
// This class is the base class for the templated NavigationToken class. A
// method pushQuery(INavigable&) allows to terminate navigation.
//
///////////////////////////////////////////////////////////////////////////////
class INavigable;
namespace boost {
class any;
}
class INavigationToken
{
public:
virtual ~INavigationToken();
// check if query must be forwarded
virtual bool pushQuery( const INavigable& parent,
const INavigable& child ) = 0;
//
virtual bool trySetObject(const INavigable* child) = 0;
virtual bool trySetObject(const INavigable* child,
const boost::any& relPar) = 0;
};
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef NAVIGATION_NAVWRAPPER_H
#define NAVIGATION_NAVWRAPPER_H
#include "Navigation/INavigationToken.h"
#include "Navigation/NavigableTerminalNode.h"
#include <boost/any.hpp>
template<class NAVIMPL>
class NavWrapper
{
public:
/*! \brief Publish navigation implementation type */
typedef NAVIMPL navimpl_t;
// /*!{ \brief Publish important types from \a Navigable, new style */
// typedef typename navimpl::container_t container_t;
// typedef typename navimpl::constituent_t constituent_t;
// typedef typename navimpl::parameter_t parameter_t;
// typedef typename navimpl::object_iter_t object_iter_t;
// typedef typename navimpl::external_index_t external_index_t;
/*!}*/
/*!{ \brief Publish important types from \a Navigable, old style, soon to be
* <b>obsolete</b>!
*/
typedef typename navimpl_t::container_type container_type;
typedef typename navimpl_t::constituent_type constituent_type;
typedef typename navimpl_t::parameter_type parameter_type;
typedef typename navimpl_t::object_iter object_iter;
typedef typename navimpl_t::external_index_type external_index_type;
/*!}*/
/*! \brief Default constructor */
NavWrapper() : m_nav(navimpl_t()) { };
/*! \brief Optional constructor: construct from Navigable */
NavWrapper(const navimpl_t& theNav) : m_nav(theNav) { };
/*! \brief Base class destructor */
virtual ~NavWrapper() { };
// common interface with Navigable FIXME improve code organization
/*! \brief Visitor handler without relational parameter
*
* This is the implementation of the \a INavigable interface.
*/
virtual void fillToken(INavigationToken& navToken) const
{ m_nav.fillToken(navToken); }
/*! \brief Visitor handler including a relational parameter
*
* This is the implementation of the \a INavigable interface.
*/
virtual void fillToken(INavigationToken& navToken,
const boost::any& parentParameter) const
{ m_nav.fillToken(navToken, parentParameter); }
//////////////////////////////////
// Add data objects or elements //
//////////////////////////////////
/*! \brief Add element to Navigable store
*
* Element is referenced by pointer (internal linear index search).
*/
void putElement(const container_type* pCont,
const constituent_type* pObj,
const parameter_type& oPar = parameter_type(),
size_t sizeHint = 0)
{ m_nav.putElement(pCont,pObj,oPar,sizeHint); }
/*! \brief Add element to the Navigable store */
void putElement(const container_type* pCont,
external_index_type& iObj,
const parameter_type& oPar = parameter_type(),
size_t sizeHint = 0)
{ m_nav.putElement(pCont,iObj,oPar,sizeHint); }
/*! \brief Insert element into Navigable store */
void insertElement(const container_type* pCont,
const constituent_type* pObj,
const parameter_type& oPar = parameter_type(),
size_t sizeHint = 0)
{ m_nav.insertElement(pCont,pObj,oPar,sizeHint); }
/*! \brief Insert element into Navigable store */
void insertElement(const container_type* pCont,
external_index_type& iObj,
const parameter_type& oPar = parameter_type(),
size_t sizeHint = 0)
{ m_nav.insertElement(pCont,iObj,oPar,sizeHint); }
///////////////////////
// Data manipulation //
///////////////////////
// re-weight (overwrite old weight)
void reweight(const constituent_type* pObj,
const parameter_type& oPar = parameter_type())
{ m_nav.reweight(pObj,oPar); }
void reweight(const container_type* pCont,
external_index_type& iObj,
const parameter_type& oPar = parameter_type())
{ m_nav.reweight(pCont,iObj,oPar); }
void reweight(object_iter& oIter,
const parameter_type& oPar = parameter_type())
{ m_nav.reweight(oIter,oPar); }
// remove object from the Navigable
bool remove(const constituent_type* pObj)
{ return m_nav.remove(pObj); }
bool remove(const container_type* pCont, external_index_type& iObj)
{ return m_nav.remove(pCont,iObj); }
bool removeAll() { return m_nav.removeAll(); }
// check if constituent is already there
bool contains(const constituent_type* pObj) const
{ return m_nav.contains(pObj); }
bool contains(const container_type* pCont,
external_index_type& iObj) const
{ return m_nav.contains(pCont,iObj); }
////////////////////////////
// Access to Constituents //
////////////////////////////
// public object access: iterators, sizes etc.
virtual object_iter begin() const { return m_nav.begin(); }
virtual object_iter end() const { return m_nav.end(); }
virtual size_t size() const { return size_t(m_nav.size()); }
// public container access: relational parameter retrieval
parameter_type getParameter(const constituent_type* pObj) const
{ return m_nav.getParameter(pObj); }
parameter_type getParameter(const container_type* pCont,
external_index_type& iObj) const
{ return m_nav.getParameter(pCont,iObj); }
parameter_type getParameter(object_iter& oIter) const
{ return m_nav.getParameter(oIter); }
// public container access: retrieve ElementLink for given object pointer
const container_type* getContainer(const constituent_type* pObj) const
{ return m_nav.getContainer(pObj); }
// const container_type* getContainer(constituent_const_iter oIter) const
// { return m_nav.getContainer(oIter); }
const container_type* getContainer(object_iter oIter) const
{ return m_nav.getContainer(oIter); }
// get index of child in original container
bool getIndex(const constituent_type* pObj,
external_index_type& iObj) const
{ return m_nav.getIndex(pObj,iObj); }
// bool getIndex(constituent_const_iter anIter,
// external_index_type& iObj) const;
bool getIndex(object_iter oIter,
external_index_type& iObj) const
{ return m_nav.getIndex(oIter,iObj); }
protected:
navimpl_t& getNavImpl() { return m_nav; }
const navimpl_t& getNavImpl() const { return m_nav; }
private:
/*! \brief Wrapped Navigable implementation */
navimpl_t m_nav;
};
/*!
* \class NavWrapper
*
* \brief Wrapper for Navigable implementation
*
* \date June 2, 2006
* \author Peter Loch <loch@physics.arizona.edu>
*
* This templated wrapper decouples the navigation implementation
* (implementing \a INavigable) from the client class by forwarding
* the \a Navigable behaviour to the actual implementation, rather than
* inheriting it. In particular this means this template itself is not
* derived from \a INavigable. This wrapper together with the \a P4Wrapper
* allows an un-ambiguous implementation of the combined
* \a INavigable4Momentum interface.
*
*/
//class NavigableTerminalNode
//{
//public:
//};
/*! \class NavigableTerminalNode
*
* \brief Dummy type needed fro specialized implementation
*
* \date June 2, 2006
* \author Peter Loch <loch@physics.arizona.edu>
*/
template<>
class NavWrapper<NavigableTerminalNode>
{
public:
/*! \brief Default constructor */
NavWrapper<NavigableTerminalNode>() { };
/*! \brief Base class destructor */
virtual ~NavWrapper<NavigableTerminalNode>() { };
/*!{ \brief Do-nothing visitor */
virtual void fillToken(INavigationToken& /*rToken*/) const { };
virtual void fillToken(INavigationToken& /*rToken*/,
const boost::any& /*rPar*/ ) const { };
/*!}*/
};
/*! \class NavWrapper<NavigableTerminalNode>
*
* \brief Specialized wrapper for singular navigable data objects
*
* \date June 2, 2006
* \author Peter Loch <loch@physics.arizona.edu>
*
* Specialization of the \a NavWrapper template for singular data objects,
* i.e. data objects without constituents. All constituent store manipulations
* (adding, removing, reweighting, etc.) are omitted.
*/
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef NAVIGATION_NAVIGABLE_H
#define NAVIGATION_NAVIGABLE_H
///////////////////////////////////////////////////////////////////////////////
///
/// Generalization of Navigable Object Features
///
/// \author P. Calafiura
/// \author P. Loch
/// \author S. Rajagopalan
///
/// \brief Navigable template generalization to handle navigation
///
/// The \c Navigable<CONT,RPAR,COLL> generalization handles navigation queries
/// and provides persistifiable data stores for composite reconstruction
/// objects. The template parameters are:
///
/// \c CONT - storable container type \n
/// \c RPAR - relational parameter type \n
/// \c COLL - <em>internal collection type for future use<\em>
///
/// \date Oct 7, 2003 update: first implementation
/// \date Dec 18, 2003 update: move to ElementLink internal store
/// \date Apr 27, 2004 update: included in release 8.1.0 and up, bug fixes
// Authors: P. Calafiura, P. Loch, S. Rajagopalan //
// Comments: Implements navigation query with honoring or forwarding the //
// client request for a given object type. The actual //
// implementation is in Navigable.icc //
// //
// Template Parameters: //
// //
// CONT - container type for given constituent object type. Needs //
// to provide a value_type declaration and the usual //
// container access methods. Defaulted to dummy //
// NavTerminator for terminal nodes in relational tree. //
// RPAR - parameter describing the relation between constituent //
// and composite object. Needs to provide +,-,+=,-=,= //
// operators to manage parameter evolution in the //
// relational tree. Defaulted to dummy parameter //
// DefaultWeight for trees without parameters. //
// COLL - allows to specify internal storage container. Needs to //
// provide typical container management like find(), //
// insert(), iterators... Defaulted to container type //
// DefaultChildColl<CONT,RPAR>. //
// There should be no need to provide an explicite internal //
// co