Skip to content
Snippets Groups Projects
Commit 0c2c19a8 authored by Scott Snyder's avatar Scott Snyder Committed by scott snyder
Browse files

EventCommonTPCnv: Add unit tests for tp converters.

Add unit tests for tp converters.


Former-commit-id: c19ac76b
parent a434c661
No related branches found
No related tags found
No related merge requests found
Showing
with 453 additions and 0 deletions
......@@ -42,3 +42,35 @@ atlas_add_dictionary( OLD_EventCommonTPCnvDict
INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS}
LINK_LIBRARIES ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} AthLinks DataModelAthenaPoolLib AthenaPoolCnvSvcLib FourMom NavFourMom AthenaKernel StoreGateLib SGtests GaudiKernel EventCommonTPCnv )
# Helper variable for running the tests:
set( _jobOPath "${CMAKE_CURRENT_SOURCE_DIR}/share" )
set( _jobOPath "${_jobOPath}:${CMAKE_JOBOPT_OUTPUT_DIRECTORY}" )
set( _jobOPath "${_jobOPath}:$ENV{JOBOPTSEARCHPATH}" )
foreach( name
HepLorentzVectorCnv_p1_test
P4EEtaPhiMCnv_p1_test
P4EEtaPhiMCnv_p2_test
P4IPtCotThPhiMCnv_p1_test
P4ImplEEtaPhiMCnv_p1_test
P4ImplEEtaPhiMCnv_p2_test
P4ImplPtEtaPhiMCnv_p1_test
P4ImplPtEtaPhiMCnv_p2_test
P4PtEtaPhiMCnv_p1_test
P4PtEtaPhiMCnv_p2_test
P4PxPyPzECnv_p1_test
INav4MomAssocsCnv_p1_test
INav4MomAssocsCnv_p2_test
INav4MomAssocsCnv_p3_test
)
atlas_add_test( ${name}
SOURCES
test/${name}.cxx
INCLUDE_DIRS ${ROOT_INCLUDE_DIRS}
LINK_LIBRARIES ${ROOT_LIBRARIES} TestTools EventCommonTPCnv
ENVIRONMENT "JOBOPTSEARCHPATH=${_jobOPath}" )
endforeach()
ApplicationMgr.DLLs += { "StoreGate", "CLIDComps" };
ApplicationMgr.ExtSvc += { "StoreGateSvc" };
HepLorentzVectorCnv_p1_test
test1
INav4MomAssocsCnv_p1_test
Initializing Gaudi ApplicationMgr using job opts ../share/EventCommonTPCnv_test.txt
JobOptionsSvc INFO # =======> /home/sss/atlas/dvtest/build/../tests/../share/EventCommonTPCnv_test.txt
JobOptionsSvc INFO # (1,1): ApplicationMgr.DLLs += ["StoreGate", "CLIDComps"]
JobOptionsSvc INFO # (2,1): ApplicationMgr.ExtSvc += ["StoreGateSvc"]
JobOptionsSvc INFO Job options successfully read in from ../share/EventCommonTPCnv_test.txt
ApplicationMgr SUCCESS
====================================================================================================================================
Welcome to ApplicationMgr (GaudiCoreSvc v27r1p99)
running on karma on Wed Nov 7 22:22:56 2018
====================================================================================================================================
ApplicationMgr INFO Successfully loaded modules : StoreGate, CLIDComps
ApplicationMgr INFO Application Manager Configured successfully
ClassIDSvc INFO getRegistryEntries: read 1769 CLIDRegistry entries for module ALL
EventLoopMgr WARNING Unable to locate service "EventSelector"
EventLoopMgr WARNING No events will be processed from external input.
HistogramPersis...WARNING Histograms saving not required.
ApplicationMgr INFO Application Manager Initialized successfully
ApplicationMgr Ready
test1
INav4MomAssocsCnv_p2_test
test1
INav4MomAssocsCnv_p3_test
test1
P4EEtaPhiMCnv_p1_test
test1
P4EEtaPhiMCnv_p2_test
test1
P4IPtCotThPhiMCnv_p1_test
test1
P4ImplEEtaPhiMCnv_p1_test
test1
P4ImplEEtaPhiMCnv_p2_test
test1
P4ImplPtEtaPhiMCnv_p1_test
test1
P4ImplPtEtaPhiMCnv_p2_test
test1
P4PtEtaPhiMCnv_p1_test
test1
P4PtEtaPhiMCnv_p2_test
test1
P4PxPyPzECnv_p1_test
test1
/*
* Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration.
*/
/**
* @file EventCommonTPCnv/test/HepLorentzVectorCnv_p1_test.cxx
* @author scott snyder <snyder@bnl.gov>
* @date Nov, 2018
* @brief Regression tests.
*/
#undef NDEBUG
#include "EventCommonTPCnv/HepLorentzVectorCnv_p1.h"
#include "CLHEP/Vector/LorentzVector.h"
#include "TestTools/leakcheck.h"
#include "GaudiKernel/MsgStream.h"
#include <cassert>
#include <iostream>
void compare (const CLHEP::HepLorentzVector& a1,
const CLHEP::HepLorentzVector& a2)
{
assert (a1 == a2);
}
void testit (const CLHEP::HepLorentzVector& trans1)
{
MsgStream log (0, "test");
HepLorentzVectorCnv_p1 cnv;
HepLorentzVector_p1 pers;
cnv.transToPers (&trans1, &pers, log);
CLHEP::HepLorentzVector trans2;
cnv.persToTrans (&pers, &trans2, log);
compare (trans1, trans2);
}
void test1()
{
std::cout << "test1\n";
Athena_test::Leakcheck check;
CLHEP::HepLorentzVector trans1 (1, 2, 3, 4);
testit (trans1);
}
int main()
{
std::cout << "HepLorentzVectorCnv_p1_test\n";
test1();
return 0;
}
/*
* Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration.
*/
/**
* @file EventCommonTPCnv/test/INav4MomAssocsCnv_p1_test.cxx
* @author scott snyder <snyder@bnl.gov>
* @date Nov, 2018
* @brief Regression tests.
*/
#undef NDEBUG
#include "EventCommonTPCnv/INav4MomAssocsCnv_p1.h"
#include "NavFourMom/INav4MomAssocs.h"
#include "NavFourMom/Nav4MomWrapper.h"
#include "FourMom/P4PxPyPzE.h"
#include "TestTools/leakcheck.h"
#include "TestTools/initGaudi.h"
#include "StoreGate/StoreGateSvc.h"
#include "GaudiKernel/MsgStream.h"
#include "GaudiKernel/ServiceHandle.h"
#include <cassert>
#include <iostream>
class Part
: virtual public INavigable4Momentum,
public P4PxPyPzE,
public NavigableTerminalNode
{
public:
};
void compare (const INav4MomAssocs& a1,
const INav4MomAssocs& a2)
{
assert (a1.getAssocStores() == a2.getAssocStores());
assert (a1.size() == a2.size());
INav4MomAssocs::object_iterator i1 = a1.beginObject();
INav4MomAssocs::object_iterator i2 = a2.beginObject();
for (size_t i = 0; i < a1.size(); ++i, ++i1, ++i2) {
assert (i1.getObjectLink() == i2.getObjectLink());
assert (i1.getNumberOfAssociations() == i2.getNumberOfAssociations());
INav4MomAssocs::asso_iterator j1 = i1.second();
INav4MomAssocs::asso_iterator j2 = i2.second();
for (size_t j = 0; j < i1.getNumberOfAssociations(); ++j, ++j1, ++j2) {
assert (j1.getLink() == j2.getLink());
}
}
}
void testit (const INav4MomAssocs& trans1, StoreGateSvc* sg)
{
MsgStream log (0, "test");
INav4MomAssocsCnv_p1 cnv (sg);
INav4MomAssocs_p1 pers;
cnv.transToPers (&trans1, &pers, log);
INav4MomAssocs trans2;
cnv.persToTrans (&pers, &trans2, log);
compare (trans1, trans2);
}
void test1()
{
std::cout << "test1\n";
ServiceHandle<StoreGateSvc> sg ("StoreGateSvc", "test");
INavigable4MomentumCollection* in4mc = new INavigable4MomentumCollection;
for (int i=0; i < 10; i++)
in4mc->push_back (CxxUtils::make_unique<Part>());
assert (sg->record (in4mc, "in").isSuccess());
INavigable4MomentumCollection* xn4mc = new INavigable4MomentumCollection;
for (int i=0; i < 10; i++)
xn4mc->push_back (CxxUtils::make_unique<Part>());
assert (sg->record (xn4mc, "xn").isSuccess());
// Get proxies created.
ElementLink<INavigable4MomentumCollection> dum1 ("in", 3);
ElementLink<INavigable4MomentumCollection> dum2 ("xn", 2);
Athena_test::Leakcheck check;
INav4MomAssocs trans1;
trans1.addAssociation (ElementLink<INavigable4MomentumCollection> ("in", 3),
ElementLink<INavigable4MomentumCollection> ("xn", 2));
trans1.addAssociation (ElementLink<INavigable4MomentumCollection> ("in", 6),
ElementLink<INavigable4MomentumCollection> ("xn", 4));
testit (trans1, &*sg);
}
int main()
{
std::cout << "INav4MomAssocsCnv_p1_test\n";
ISvcLocator* pSvcLoc;
if (!Athena_test::initGaudi("EventCommonTPCnv_test.txt", pSvcLoc)) {
std::cerr << "This test can not be run" << std::endl;
return 0;
}
test1();
return 0;
}
/*
* Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration.
*/
/**
* @file EventCommonTPCnv/test/INav4MomAssocsCnv_p2_test.cxx
* @author scott snyder <snyder@bnl.gov>
* @date Nov, 2018
* @brief Regression tests.
*/
#undef NDEBUG
#include "EventCommonTPCnv/INav4MomAssocsCnv_p2.h"
#include "NavFourMom/INav4MomAssocs.h"
#include "NavFourMom/Nav4MomWrapper.h"
#include "FourMom/P4PxPyPzE.h"
#include "TestTools/leakcheck.h"
#include "SGTools/TestStore.h"
#include "GaudiKernel/MsgStream.h"
#include <cassert>
#include <iostream>
class Part
: virtual public INavigable4Momentum,
public P4PxPyPzE,
public NavigableTerminalNode
{
public:
};
void compare (const INav4MomAssocs& a1,
const INav4MomAssocs& a2)
{
assert (a1.getAssocStores() == a2.getAssocStores());
assert (a1.size() == a2.size());
INav4MomAssocs::object_iterator i1 = a1.beginObject();
INav4MomAssocs::object_iterator i2 = a2.beginObject();
for (size_t i = 0; i < a1.size(); ++i, ++i1, ++i2) {
assert (i1.getObjectLink() == i2.getObjectLink());
assert (i1.getNumberOfAssociations() == i2.getNumberOfAssociations());
INav4MomAssocs::asso_iterator j1 = i1.second();
INav4MomAssocs::asso_iterator j2 = i2.second();
for (size_t j = 0; j < i1.getNumberOfAssociations(); ++j, ++j1, ++j2) {
assert (j1.getLink() == j2.getLink());
}
}
}
void testit (const INav4MomAssocs& trans1)
{
MsgStream log (0, "test");
INav4MomAssocsCnv_p2 cnv;
INav4MomAssocs_p2 pers;
cnv.transToPers (&trans1, &pers, log);
INav4MomAssocs trans2;
cnv.persToTrans (&pers, &trans2, log);
compare (trans1, trans2);
}
void test1()
{
std::cout << "test1\n";
INavigable4MomentumCollection* in4mc = new INavigable4MomentumCollection;
for (int i=0; i < 10; i++)
in4mc->push_back (CxxUtils::make_unique<Part>());
SGTest::store.record (in4mc, "in");
INavigable4MomentumCollection* xn4mc = new INavigable4MomentumCollection;
for (int i=0; i < 10; i++)
xn4mc->push_back (CxxUtils::make_unique<Part>());
SGTest::store.record (xn4mc, "xn");
// Get proxies created.
ElementLink<INavigable4MomentumCollection> dum1 ("in", 3);
ElementLink<INavigable4MomentumCollection> dum2 ("xn", 2);
Athena_test::Leakcheck check;
INav4MomAssocs trans1;
trans1.addAssociation (ElementLink<INavigable4MomentumCollection> ("in", 3),
ElementLink<INavigable4MomentumCollection> ("xn", 2));
trans1.addAssociation (ElementLink<INavigable4MomentumCollection> ("in", 6),
ElementLink<INavigable4MomentumCollection> ("xn", 4));
testit (trans1);
}
int main()
{
std::cout << "INav4MomAssocsCnv_p2_test\n";
SGTest::initTestStore();
test1();
return 0;
}
/*
* Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration.
*/
/**
* @file EventCommonTPCnv/test/INav4MomAssocsCnv_p3_test.cxx
* @author scott snyder <snyder@bnl.gov>
* @date Nov, 2018
* @brief Regression tests.
*/
#undef NDEBUG
#include "EventCommonTPCnv/INav4MomAssocsCnv_p3.h"
#include "NavFourMom/INav4MomAssocs.h"
#include "NavFourMom/Nav4MomWrapper.h"
#include "FourMom/P4PxPyPzE.h"
#include "TestTools/leakcheck.h"
#include "SGTools/TestStore.h"
#include "GaudiKernel/MsgStream.h"
#include <cassert>
#include <iostream>
class Part
: virtual public INavigable4Momentum,
public P4PxPyPzE,
public NavigableTerminalNode
{
public:
};
void compare (const INav4MomAssocs& a1,
const INav4MomAssocs& a2)
{
assert (a1.getAssocStores() == a2.getAssocStores());
assert (a1.size() == a2.size());
INav4MomAssocs::object_iterator i1 = a1.beginObject();
INav4MomAssocs::object_iterator i2 = a2.beginObject();
for (size_t i = 0; i < a1.size(); ++i, ++i1, ++i2) {
assert (i1.getObjectLink() == i2.getObjectLink());
assert (i1.getNumberOfAssociations() == i2.getNumberOfAssociations());
INav4MomAssocs::asso_iterator j1 = i1.second();
INav4MomAssocs::asso_iterator j2 = i2.second();
for (size_t j = 0; j < i1.getNumberOfAssociations(); ++j, ++j1, ++j2) {
assert (j1.getLink() == j2.getLink());
}
}
}
void testit (const INav4MomAssocs& trans1)
{
MsgStream log (0, "test");
INav4MomAssocsCnv_p3 cnv;
INav4MomAssocs_p3 pers;
cnv.transToPers (&trans1, &pers, log);
INav4MomAssocs trans2;
cnv.persToTrans (&pers, &trans2, log);
compare (trans1, trans2);
}
void test1()
{
std::cout << "test1\n";
INavigable4MomentumCollection* in4mc = new INavigable4MomentumCollection;
for (int i=0; i < 10; i++)
in4mc->push_back (CxxUtils::make_unique<Part>());
SGTest::store.record (in4mc, "in");
INavigable4MomentumCollection* xn4mc = new INavigable4MomentumCollection;
for (int i=0; i < 10; i++)
xn4mc->push_back (CxxUtils::make_unique<Part>());
SGTest::store.record (xn4mc, "xn");
// Get proxies created.
ElementLink<INavigable4MomentumCollection> dum1 ("in", 3);
ElementLink<INavigable4MomentumCollection> dum2 ("xn", 2);
Athena_test::Leakcheck check;
INav4MomAssocs trans1;
trans1.addAssociation (ElementLink<INavigable4MomentumCollection> ("in", 3),
ElementLink<INavigable4MomentumCollection> ("xn", 2));
trans1.addAssociation (ElementLink<INavigable4MomentumCollection> ("in", 6),
ElementLink<INavigable4MomentumCollection> ("xn", 4));
testit (trans1);
}
int main()
{
std::cout << "INav4MomAssocsCnv_p3_test\n";
SGTest::initTestStore();
test1();
return 0;
}
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