Skip to content
Snippets Groups Projects
Commit b7963712 authored by Graeme Stewart's avatar Graeme Stewart
Browse files

PhysicsAnalysis/AssociationBuilder/AssociationUtils deleted from master

parent 8080b516
No related merge requests found
Showing
with 0 additions and 966 deletions
///////////////////////// -*- C++ -*- /////////////////////////////
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// DeltaROverlapFilter.h
// Header file for class DeltaROverlapFilter
// Author: S.Binet<binet@cern.ch>
///////////////////////////////////////////////////////////////////
#ifndef ASSOCIATIONUTILS_DELTAROVERLAPFILTER_H
#define ASSOCIATIONUTILS_DELTAROVERLAPFILTER_H
// STL includes
#include <functional>
// EventKernel includes
#include "EventKernel/INavigable4Momentum.h"
// AssociationUtils includes
#include "AssociationUtils/IOverlapFilter.h"
// Forward declaration
class DeltaROverlapFilter : public IOverlapFilter
{
public:
using IOverlapFilter::hasOverlap;
///////////////////////////////////////////////////////////////////
// Public methods:
///////////////////////////////////////////////////////////////////
public:
/** Default constructor:
*/
DeltaROverlapFilter();
/** Copy constructor:
*/
DeltaROverlapFilter( const DeltaROverlapFilter& rhs );
/** Assignment operator:
*/
DeltaROverlapFilter& operator=( const DeltaROverlapFilter& rhs );
/** Constructor with parameters:
*/
DeltaROverlapFilter( double maxDeltaR );
/** Constructor with parameters:
*/
DeltaROverlapFilter( double minDeltaR, double maxDeltaR );
/** Destructor:
*/
virtual ~DeltaROverlapFilter();
///////////////////////////////////////////////////////////////////
// Const methods:
///////////////////////////////////////////////////////////////////
/** @brief Filtering method. If true then objects overlap.
*/
bool hasOverlap( const INavigable4Momentum& obj1,
const INavigable4Momentum& obj2 ) const;
/** @brief Retrieve the defined lowest value cut for the $\Delta R$
*/
double minDeltaR() const;
/** @brief Retrieve the defined highest value cut for the $\Delta R$
*/
double maxDeltaR() const;
///////////////////////////////////////////////////////////////////
// Non-const methods:
///////////////////////////////////////////////////////////////////
void setMinDeltaR( double minDeltaR );
void setMaxDeltaR( double maxDeltaR );
void setDeltaR( double minDeltaR, double maxDeltaR );
///////////////////////////////////////////////////////////////////
// Protected data:
///////////////////////////////////////////////////////////////////
protected:
/** Inner crown limit for delta-R check
*/
double m_minDeltaR;
/** Outer crown limit for delta-R check
*/
double m_maxDeltaR;
};
///////////////////////////////////////////////////////////////////
/// Inline methods:
///////////////////////////////////////////////////////////////////
inline DeltaROverlapFilter::~DeltaROverlapFilter()
{}
inline double DeltaROverlapFilter::minDeltaR() const
{
return m_minDeltaR;
}
inline double DeltaROverlapFilter::maxDeltaR() const
{
return m_maxDeltaR;
}
inline void DeltaROverlapFilter::setMinDeltaR( double minDeltaR )
{
m_minDeltaR = minDeltaR;
}
inline void DeltaROverlapFilter::setMaxDeltaR( double maxDeltaR )
{
m_maxDeltaR = maxDeltaR;
}
inline
void DeltaROverlapFilter::setDeltaR( double minDeltaR, double maxDeltaR )
{
m_minDeltaR = minDeltaR;
m_maxDeltaR = maxDeltaR;
}
#endif //> ASSOCIATIONUTILS_DELTAROVERLAPFILTER_H
///////////////////////// -*- C++ -*- /////////////////////////////
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// IOverlapFilter.h
// Header file for class IOverlapFilter
// Author: S.Binet<binet@cern.ch>
///////////////////////////////////////////////////////////////////
#ifndef ASSOCIATIONUTILS_IOVERLAPFILTER_H
#define ASSOCIATIONUTILS_IOVERLAPFILTER_H
// STL includes
#include <functional>
// EventKernel includes
#include "EventKernel/INavigable4Momentum.h"
// Forward declaration
class IOverlapFilter : public std::binary_function<
const INavigable4Momentum*,
const INavigable4Momentum*,
bool
>
{
///////////////////////////////////////////////////////////////////
// Public methods:
///////////////////////////////////////////////////////////////////
public:
/** Destructor:
*/
virtual ~IOverlapFilter();
///////////////////////////////////////////////////////////////////
// Const methods:
///////////////////////////////////////////////////////////////////
/** @brief Filtering method.
* Return true if objects overlap.
*/
virtual bool hasOverlap( const INavigable4Momentum& obj1,
const INavigable4Momentum& obj2 ) const = 0;
/** @brief Filtering method.
* Return true if objects overlap ( forwards to @c hasOverlap )
*/
bool hasOverlap( const INavigable4Momentum* obj1,
const INavigable4Momentum* obj2 ) const;
/** @brief Filtering method.
* Return true if objects overlap ( forwards to @c hasOverlap )
*/
bool operator()( const INavigable4Momentum& obj1,
const INavigable4Momentum& obj2 ) const;
/** @brief Filtering method.
* Return true if objects overlap ( forwards to @c hasOverlap )
*/
bool operator()( const INavigable4Momentum* obj1,
const INavigable4Momentum* obj2 ) const;
///////////////////////////////////////////////////////////////////
// Non-const methods:
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
// Protected data:
///////////////////////////////////////////////////////////////////
protected:
};
///////////////////////////////////////////////////////////////////
/// Inline methods:
///////////////////////////////////////////////////////////////////
inline bool
IOverlapFilter::hasOverlap( const INavigable4Momentum* obj1,
const INavigable4Momentum* obj2 ) const
{
return hasOverlap(*obj1, *obj2);
}
inline bool IOverlapFilter::operator()( const INavigable4Momentum& obj1,
const INavigable4Momentum& obj2 ) const
{
return hasOverlap(obj1, obj2);
}
inline bool IOverlapFilter::operator()( const INavigable4Momentum* obj1,
const INavigable4Momentum* obj2 ) const
{
return hasOverlap(*obj1, *obj2);
}
#endif //> ASSOCIATIONUTILS_IOVERLAPFILTER_H
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
///////////////////////////////////////////////////////////////////
// NavigationOverlapFilter.h
// Header file for class NavigationOverlapFilter
// Author: S.Binet<binet@cern.ch>
///////////////////////////////////////////////////////////////////
#ifndef ASSOCIATIONUTILS_NAVIGATIONOVERLAPFILTER_H
#define ASSOCIATIONUTILS_NAVIGATIONOVERLAPFILTER_H
// STL includes
#include <functional>
// EventKernel includes
#include "EventKernel/INavigable4Momentum.h"
// AssociationUtils includes
#include "AssociationUtils/IOverlapFilter.h"
// Forward declaration
class NavigationOverlapFilter : public IOverlapFilter
{
///////////////////////////////////////////////////////////////////
// Public methods:
///////////////////////////////////////////////////////////////////
public:
/** Default constructor:
*/
NavigationOverlapFilter();
/** Copy constructor:
*/
NavigationOverlapFilter( const NavigationOverlapFilter& rhs );
/** Assignment operator:
*/
NavigationOverlapFilter& operator=( const NavigationOverlapFilter& rhs );
/** Destructor:
*/
virtual ~NavigationOverlapFilter();
///////////////////////////////////////////////////////////////////
// Const methods:
///////////////////////////////////////////////////////////////////
/** @brief Filtering method. If true then objects overlap.
*/
bool hasOverlap( const INavigable4Momentum& obj1,
const INavigable4Momentum& obj2 ) const;
///////////////////////////////////////////////////////////////////
// Non-const methods:
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
// Protected data:
///////////////////////////////////////////////////////////////////
protected:
};
///////////////////////////////////////////////////////////////////
/// Inline methods:
///////////////////////////////////////////////////////////////////
inline NavigationOverlapFilter::~NavigationOverlapFilter()
{}
#endif //> ASSOCIATIONUTILS_NAVIGATIONOVERLAPFILTER_H
################################################################################
# Package: AssociationUtils
################################################################################
# Declare the package name:
atlas_subdir( AssociationUtils )
# Declare the package's dependencies:
atlas_depends_on_subdirs( PUBLIC
Event/EventKernel
PRIVATE
AtlasTest/TestTools
Control/AthContainers
Control/AthLinks
Control/CLIDSvc
Control/Navigation
Control/SGTools
Event/FourMom
Event/FourMomUtils
TestPolicy )
# External dependencies:
find_package( Boost COMPONENTS filesystem thread system )
# Component(s) in the package:
atlas_add_library( AssociationUtils
src/*.cxx
PUBLIC_HEADERS AssociationUtils
PRIVATE_INCLUDE_DIRS ${Boost_INCLUDE_DIRS}
LINK_LIBRARIES EventKernel
PRIVATE_LINK_LIBRARIES ${Boost_LIBRARIES} AthContainers AthLinks FourMomUtils )
package AssociationUtils
author Ketevi A. Assamagan <ketevi@bnl.gov>
author Sebastien Binet <binet@cern.ch>
use AtlasPolicy AtlasPolicy-*
use EventKernel EventKernel-* Event
branches AssociationUtils src doc share run
library AssociationUtils *.cxx
apply_pattern installed_library
#############
# unit tests
#
private
use TestPolicy TestPolicy-* -no_auto_imports
use TestTools TestTools-* AtlasTest -no_auto_imports
use AthContainers AthContainers-* Control
use AthLinks AthLinks-* Control
use Navigation Navigation-* Control -no_auto_imports
#use DataModel DataModel-* Control -no_auto_imports
use CLIDSvc CLIDSvc-* Control -no_auto_imports
use AtlasBoost AtlasBoost-* External -no_auto_imports
use FourMom FourMom-* Event -no_auto_imports
use FourMomUtils FourMomUtils-* Event
macro cppUnit_deltaROverlapFilterTest_imports ""
macro_append cppUnit_deltaROverlapFilterTest_imports " -import=StoreGate"
macro_append cppUnit_deltaROverlapFilterTest_imports " -import=Navigation"
macro_append cppUnit_deltaROverlapFilterTest_imports " -import=DataModel"
macro_append cppUnit_deltaROverlapFilterTest_imports " -import=AtlasBoost"
macro_append cppUnit_deltaROverlapFilterTest_imports " -import=CLIDSvc"
macro_append cppUnit_deltaROverlapFilterTest_imports " -import=FourMom"
macro_append cppUnit_deltaROverlapFilterTest_imports " -import=FourMomUtils"
apply_pattern CppUnit name=cppUnit_deltaROverlapFilterTest \
files="-s=${AssociationUtils_root}/test DeltaROverlapFilter_CppUnit.cxx" \
imports=$(cppUnit_deltaROverlapFilterTest_imports)
end_private
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
///////////////////////////////////////////////////////////////////
// DeltaROverlapFilter.cxx
// Implementation file for class DeltaROverlapFilter
// Author: S.Binet<binet@cern.ch>
///////////////////////////////////////////////////////////////////
// STL includes
#include <cfloat>
// FourMomUtils includes
#include "FourMomUtils/P4Helpers.h"
// AssociationUtils includes
#include "AssociationUtils/DeltaROverlapFilter.h"
///////////////////////////////////////////////////////////////////
/// Public methods:
///////////////////////////////////////////////////////////////////
// Constructors
////////////////
DeltaROverlapFilter::DeltaROverlapFilter() :
IOverlapFilter( ),
m_minDeltaR ( 0. ),
m_maxDeltaR ( DBL_MAX )
{}
DeltaROverlapFilter::DeltaROverlapFilter( const DeltaROverlapFilter& rhs ) :
IOverlapFilter( rhs ),
m_minDeltaR( rhs.m_minDeltaR ),
m_maxDeltaR( rhs.m_maxDeltaR )
{}
DeltaROverlapFilter&
DeltaROverlapFilter::operator=( const DeltaROverlapFilter& rhs )
{
if ( this != &rhs ) {
IOverlapFilter::operator=( rhs );
m_minDeltaR = rhs.m_minDeltaR;
m_maxDeltaR = rhs.m_maxDeltaR;
}
return *this;
}
DeltaROverlapFilter::DeltaROverlapFilter( double maxDeltaR ) :
IOverlapFilter( ),
m_minDeltaR( 0. ),
m_maxDeltaR( maxDeltaR )
{}
DeltaROverlapFilter::DeltaROverlapFilter( double minDeltaR,
double maxDeltaR ) :
IOverlapFilter( ),
m_minDeltaR( minDeltaR ),
m_maxDeltaR( maxDeltaR )
{}
// Destructor
///////////////
///////////////////////////////////////////////////////////////////
// Const methods:
///////////////////////////////////////////////////////////////////
bool DeltaROverlapFilter::hasOverlap( const INavigable4Momentum& obj1,
const INavigable4Momentum& obj2 ) const
{
const double deltaR = P4Helpers::deltaR( obj1, obj2 );
return ( m_minDeltaR <= deltaR ) && ( deltaR < m_maxDeltaR );
}
///////////////////////////////////////////////////////////////////
// Non-const methods:
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
// Protected methods:
///////////////////////////////////////////////////////////////////
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
///////////////////////////////////////////////////////////////////
// IOverlapFilter.cxx
// Implementation file for class IOverlapFilter
// Author: S.Binet<binet@cern.ch>
///////////////////////////////////////////////////////////////////
// STL includes
// AssociationUtils includes
#include "AssociationUtils/IOverlapFilter.h"
///////////////////////////////////////////////////////////////////
/// Public methods:
///////////////////////////////////////////////////////////////////
// Constructors
////////////////
// Destructor
///////////////
IOverlapFilter::~IOverlapFilter()
{}
///////////////////////////////////////////////////////////////////
// Const methods:
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
// Non-const methods:
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
// Protected methods:
///////////////////////////////////////////////////////////////////
#!/bin/sh
# This just selects the directory to run cmt commands
# But with project builds and as this package (AssociationUtils) can be moved
# from some project to another, we wildcard the AtlasXyzRelease directory
cd ${NIGHTLYAREA}/Atlas*Release/cmt
#
cmt broadcast -select=AssociationUtils make CppUnit
stat=$?
if [ "$stat" != "0" ]; then
echo " -------------------------------- "
echo " FAILURE : test AssociationUtils "
echo " -------------------------------- "
fi
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
/// Class to test the DeltaROverlapFilter class
/// Author : S.Binet<binet@cern.ch>
// CppUnit includes
#include<cppunit/extensions/HelperMacros.h>
#include<cppunit/Exception.h>
// STL includes
#include <list>
#include <vector>
#include <iostream>
#include <stdexcept>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
// to ease tests
#include <boost/bind.hpp>
// DataModel includes
#include "AthContainers/DataVector.h"
#include "AthLinks/ElementLink.h"
#include "CLIDSvc/CLASS_DEF.h"
// EventKernel includes
#include "EventKernel/INavigable4Momentum.h"
// FourMom includes
#include "FourMom/P4PxPyPzE.h"
#include "Navigation/NavigableTerminalNode.h"
// FourMomUtils includes
#include "FourMomUtils/P4Helpers.h"
// AssociationUtils includes
#include "AssociationUtils/DeltaROverlapFilter.h"
class MyNav4Mom : virtual public INavigable4Momentum,
public P4PxPyPzE,
public NavigableTerminalNode
{
public:
MyNav4Mom():
INavigable4Momentum(),
P4PxPyPzE(),
NavigableTerminalNode()
{}
MyNav4Mom( double px, double py, double pz, double ene ):
INavigable4Momentum(),
P4PxPyPzE(px, py, pz, ene),
NavigableTerminalNode()
{}
};
CLASS_DEF( DataVector<MyNav4Mom> , 77574488 , 1 )
class DeltaROverlapFilterTest : public CppUnit::TestFixture
{
/// Definition of the unit test suite
CPPUNIT_TEST_SUITE( DeltaROverlapFilterTest );
CPPUNIT_TEST( testConstructor );
CPPUNIT_TEST( testSettersAndGetters );
CPPUNIT_TEST( testPredicate );
CPPUNIT_TEST( testCountIf );
CPPUNIT_TEST( testFindIf );
CPPUNIT_TEST( testAccumulate );
/// end the definition test suite
CPPUNIT_TEST_SUITE_END();
private:
unsigned int m_nmax;
DataVector<MyNav4Mom> m_dvMoms;
std::vector<MyNav4Mom*> m_stlMoms;
public:
/// Set up the data members
void setUp()
{
m_nmax = 11;
const double x = 10.;
m_dvMoms.resize(m_nmax);
m_stlMoms.resize(m_nmax);
for ( unsigned int i = 0; i != m_nmax; ++i ) {
m_dvMoms[i] = new MyNav4Mom( (i+1)*x, (i+2)*x, (i+3)*x, (i+4)*x );
m_stlMoms[i] = new MyNav4Mom( (i+1)*x, (i+2)*x, (i+3)*x, (i+4)*x );
}
}
/// destroy any on-the-heap-created data member
void tearDown()
{
m_dvMoms.clear();
for ( unsigned int i = 0; i != m_nmax; ++i ) {
delete m_stlMoms[i];
m_stlMoms[i] = 0;
}
}
/// Test the McVtxFilter constructors
void testConstructor()
{
{
DeltaROverlapFilter filter;
CPPUNIT_ASSERT( filter.minDeltaR() == 0. );
CPPUNIT_ASSERT( filter.maxDeltaR() == DBL_MAX );
}
{
DeltaROverlapFilter filter( 0.7 );
CPPUNIT_ASSERT( filter.minDeltaR() == 0. );
CPPUNIT_ASSERT( filter.maxDeltaR() == 0.7 );
}
{
DeltaROverlapFilter filter( 0.4, 0.7 );
CPPUNIT_ASSERT( filter.minDeltaR() == 0.4 );
CPPUNIT_ASSERT( filter.maxDeltaR() == 0.7 );
}
{
DeltaROverlapFilter filter( 0.4, 0.7 );
CPPUNIT_ASSERT( filter.minDeltaR() == 0.4 );
CPPUNIT_ASSERT( filter.maxDeltaR() == 0.7 );
DeltaROverlapFilter g(filter);
CPPUNIT_ASSERT( g.minDeltaR() == 0.4 );
CPPUNIT_ASSERT( g.maxDeltaR() == 0.7 );
DeltaROverlapFilter h;
CPPUNIT_ASSERT( h.minDeltaR() == 0. );
CPPUNIT_ASSERT( h.maxDeltaR() == DBL_MAX );
h = filter;
CPPUNIT_ASSERT( h.minDeltaR() == 0.4 );
CPPUNIT_ASSERT( h.maxDeltaR() == 0.7 );
}
}
void testSettersAndGetters()
{
DeltaROverlapFilter filter( 0.4, 0.7 );
CPPUNIT_ASSERT( filter.minDeltaR() == 0.4 );
CPPUNIT_ASSERT( filter.maxDeltaR() == 0.7 );
filter.setMinDeltaR( 0.3 );
CPPUNIT_ASSERT( filter.minDeltaR() == 0.3 );
CPPUNIT_ASSERT( filter.maxDeltaR() == 0.7 );
filter.setMaxDeltaR( 0.8 );
CPPUNIT_ASSERT( filter.minDeltaR() == 0.3 );
CPPUNIT_ASSERT( filter.maxDeltaR() == 0.8 );
filter.setDeltaR( 0.4, 0.7 );
CPPUNIT_ASSERT( filter.minDeltaR() == 0.4 );
CPPUNIT_ASSERT( filter.maxDeltaR() == 0.7 );
}
void testPredicate()
{
{
DeltaROverlapFilter filter;
MyNav4Mom mom1( 10., 10., 10., 20. );
MyNav4Mom mom2( 10., 10., 10., 20. );
CPPUNIT_ASSERT( P4Helpers::deltaR(mom1, mom2) == 0. );
CPPUNIT_ASSERT( filter.hasOverlap(mom1, mom2) );
CPPUNIT_ASSERT( filter(mom1, mom2) );
}
{
DeltaROverlapFilter filter( 0.1, 0.2 );
MyNav4Mom mom1( 10., 10., 10., 20. );
MyNav4Mom mom2( 10., 10., 10., 20. );
CPPUNIT_ASSERT( P4Helpers::deltaR(mom1, mom2) == 0. );
CPPUNIT_ASSERT( !filter.hasOverlap(mom1, mom2) );
CPPUNIT_ASSERT( !filter(mom1, mom2) );
}
{
typedef ElementLink<DataVector<MyNav4Mom> > Link_t;
std::vector<Link_t> moms;
moms.push_back( Link_t( m_dvMoms, 0 ) );
DeltaROverlapFilter filter( 0.1, 0.2 );
CPPUNIT_ASSERT( P4Helpers::deltaR( *moms[0], *moms[0] ) == 0. );
CPPUNIT_ASSERT( !filter.hasOverlap(**moms[0],**moms[0]) );
CPPUNIT_ASSERT( !filter.hasOverlap(*moms[0],*moms[0]) );
CPPUNIT_ASSERT( !filter( *moms[0], *moms[0] ) );
}
{
MyNav4Mom mom1( -10., -10., -10., 20. );
MyNav4Mom mom2( 10., 10., 10., 20. );
const double minDeltaR = 3.40646;
const double maxDeltaR = 3.40647;
CPPUNIT_ASSERT( P4Helpers::deltaR(mom1, mom2) < maxDeltaR );
CPPUNIT_ASSERT( P4Helpers::deltaR(mom1, mom2) >= minDeltaR );
DeltaROverlapFilter filter;
CPPUNIT_ASSERT( filter.hasOverlap(mom1, mom2) );
CPPUNIT_ASSERT( filter(mom1, mom2) );
filter.setDeltaR( 0., minDeltaR );
CPPUNIT_ASSERT( !filter.hasOverlap(mom1, mom2) );
CPPUNIT_ASSERT( !filter(mom1, mom2) );
filter.setDeltaR( minDeltaR, maxDeltaR );
CPPUNIT_ASSERT( filter.hasOverlap(mom1, mom2) );
CPPUNIT_ASSERT( filter(mom1, mom2) );
filter.setDeltaR( maxDeltaR, DBL_MAX );
CPPUNIT_ASSERT( !filter.hasOverlap(mom1, mom2) );
CPPUNIT_ASSERT( !filter(mom1, mom2) );
}
}
template <class CONT>
void testCountIf_t( const CONT& cont, const DeltaROverlapFilter& filter,
const int INRANGE )
{
const int OUTRANGE = static_cast<int>(cont.size()) - INRANGE;
{
const int n = std::count_if( cont.begin(), cont.end(),
std::bind2nd( filter, cont[0] ) );
CPPUNIT_ASSERT( n == (INRANGE+1) );
}
{
const int n = std::count_if( cont.begin(), cont.end(),
boost::bind( filter, _1, cont[0] ) );
CPPUNIT_ASSERT( n == (INRANGE+1) );
}
{
const int n = std::count_if( cont.begin(), cont.end(),
boost::bind( filter, cont[0], _1 ) );
CPPUNIT_ASSERT( n == (INRANGE+1) );
}
{
const int n = std::count_if( cont.begin(), cont.end(),
boost::bind( std::logical_not<bool>(),
boost::bind( filter,
cont[0], _1 ) ) );
CPPUNIT_ASSERT( n == (OUTRANGE-1) );
}
}
void testCountIf()
{
const int INRANGE = 6;
DeltaROverlapFilter filter( 0., P4Helpers::deltaR( m_stlMoms[0],
m_stlMoms[INRANGE] ) );
// std::cout << std::endl;
// for ( unsigned int i = 0; i != m_nmax; ++i ) {
// std::cout << i << " => " << P4Helpers::deltaR(m_stlMoms[0], m_stlMoms[i])
// << std::endl;
// }
testCountIf_t( m_dvMoms, filter, INRANGE );
testCountIf_t( m_stlMoms, filter, INRANGE );
}
template <class CONT>
void testFindIf_t( const CONT& cont, const DeltaROverlapFilter& filter,
const int INRANGE )
{
const int OUTRANGE = static_cast<int>(cont.size()) - INRANGE;
{
typename CONT::const_iterator itr;
itr = std::find_if( cont.begin(), cont.end(),
std::bind2nd( filter, cont[0] ) );
CPPUNIT_ASSERT( itr == cont.begin() );
}
{
typename CONT::const_iterator itr;
itr = std::find_if( cont.begin(), cont.end(),
boost::bind( filter, _1, cont[0] ) );
CPPUNIT_ASSERT( itr == cont.begin() );
}
{
typename CONT::const_iterator itr;
itr = std::find_if( cont.begin(), cont.end(),
boost::bind( filter, cont[0], _1 ) );
CPPUNIT_ASSERT( itr == cont.begin() );
}
{
typename CONT::const_iterator itr;
itr = std::find_if( cont.begin(), cont.end(),
boost::bind( std::logical_not<bool>(),
boost::bind( filter,
cont[0], _1 ) ) );
CPPUNIT_ASSERT( itr == (cont.begin()+INRANGE+1) );
}
{
typename CONT::const_reverse_iterator ritr;
ritr = std::find_if( cont.rbegin(), cont.rend(),
boost::bind( filter, cont[0], _1 ) );
CPPUNIT_ASSERT( ritr == (cont.rbegin()+OUTRANGE-1) );
}
{
typename CONT::const_reverse_iterator ritr;
ritr = std::find_if( cont.rbegin(), cont.rend(),
boost::bind( std::logical_not<bool>(),
boost::bind( filter,
cont[0], _1 ) ) );
CPPUNIT_ASSERT( ritr == cont.rbegin() );
}
}
void testFindIf()
{
const int INRANGE = 6;
DeltaROverlapFilter filter( 0., P4Helpers::deltaR( m_stlMoms[0],
m_stlMoms[INRANGE] ) );
testFindIf_t( m_dvMoms, filter, INRANGE );
testFindIf_t( m_stlMoms, filter, INRANGE );
}
template <class CONT>
void testAccumulate_t( const CONT& cont, const DeltaROverlapFilter& filter,
const int INRANGE )
{
{
bool allOk = true;
allOk = std::accumulate( cont.begin(),
cont.begin()+INRANGE,
allOk,
boost::bind( std::logical_and<bool>(),
_1,
boost::bind( filter,
cont[0], _2 ) ) );
CPPUNIT_ASSERT( allOk );
}
{
bool allOk = true;
allOk = std::accumulate( cont.rbegin()+INRANGE,
cont.rend(),
allOk,
boost::bind( std::logical_and<bool>(),
_1,
boost::bind( filter,
cont[0], _2 ) ) );
CPPUNIT_ASSERT( allOk );
}
{
bool allOk = true;
allOk = std::accumulate( cont.begin(),
cont.begin()+INRANGE+1,
allOk,
boost::bind( std::logical_and<bool>(),
_1, // allOk_sum
boost::bind( filter,
cont[0], _2 ) ) );
CPPUNIT_ASSERT( allOk );
}
{
bool allOk = false;
allOk = std::accumulate( cont.begin(),
cont.end(),
allOk,
boost::bind( std::logical_or<bool>(),
_1, // allOk_sum
boost::bind( filter,
cont[0], _2 ) ) );
CPPUNIT_ASSERT( allOk );
}
{
bool allOk = false;
allOk = std::accumulate( cont.begin()+INRANGE,
cont.end(),
allOk,
boost::bind( std::logical_or<bool>(),
_1, // allOk_sum
boost::bind( filter,
cont[0], _2 ) ) );
CPPUNIT_ASSERT( allOk );
}
{
bool allOk = false;
allOk = std::accumulate( cont.rbegin(),
cont.rend()-INRANGE,
allOk,
boost::bind( std::logical_or<bool>(),
_1, // allOk_sum
boost::bind( filter,
cont[0], _2 ) ) );
CPPUNIT_ASSERT( allOk );
}
}
void testAccumulate()
{
const int INRANGE = 6;
DeltaROverlapFilter filter( 0., P4Helpers::deltaR( m_stlMoms[0],
m_stlMoms[INRANGE] ) );
testAccumulate_t( m_dvMoms, filter, INRANGE );
testAccumulate_t( m_stlMoms, filter, INRANGE );
}
};
/// Registration of the test suite "DeltaROverlapFilterTest" so it will be
/// recognized by the main test program which drives the different tests
CPPUNIT_TEST_SUITE_REGISTRATION( DeltaROverlapFilterTest );
/// CppUnit test-driver common for all the cppunit test classes.
/// In ATLAS sw release it is located in TestPolicy package
#include <TestPolicy/CppUnit_SGtestdriver.cxx>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment