diff --git a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/CMakeLists.txt b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..e9184443c097666676a7049817d9a62cdbe4f343 --- /dev/null +++ b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/CMakeLists.txt @@ -0,0 +1,124 @@ +################################################################################ +# Package: ParticleEventTPCnv +################################################################################ + +# Declare the package name: +atlas_subdir( ParticleEventTPCnv ) + +# Declare the package's dependencies: +atlas_depends_on_subdirs( PUBLIC + AtlasTest/TestTools + Control/AthLinks + Control/DataModelAthenaPool + Database/AthenaPOOL/AthenaPoolCnvSvc + Event/EventCommonTPCnv + GaudiKernel + PhysicsAnalysis/AnalysisCommon/ParticleEvent + Reconstruction/Particle + PRIVATE + Control/AthAllocators + Control/AthenaKernel + Control/CxxUtils + Control/SGTools + Tracking/TrkEvent/VxVertex ) + +# External dependencies: +find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread ) + +# Component(s) in the package: +atlas_add_tpcnv_library( ParticleEventTPCnv + src/*.cxx + PUBLIC_HEADERS ParticleEventTPCnv + INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} + LINK_LIBRARIES ${ROOT_LIBRARIES} TestTools AthLinks DataModelAthenaPoolLib AthenaPoolCnvSvcLib EventCommonTPCnv GaudiKernel ParticleEvent Particle AthAllocators AthenaKernel CxxUtils SGTools VxVertex ) + +atlas_add_dictionary( ParticleEventTPCnvDict + ParticleEventTPCnv/ParticleEventTPCnvDict.h + ParticleEventTPCnv/selection.xml + INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} + LINK_LIBRARIES ${ROOT_LIBRARIES} TestTools AthLinks DataModelAthenaPoolLib AthenaPoolCnvSvcLib EventCommonTPCnv GaudiKernel ParticleEvent Particle AthAllocators AthenaKernel CxxUtils SGTools VxVertex ParticleEventTPCnv ) + +atlas_add_test( CompositeParticleCnv_p1_test + SOURCES + test/CompositeParticleCnv_p1_test.cxx + INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} + LINK_LIBRARIES ${ROOT_LIBRARIES} TestTools AthLinks DataModelAthenaPoolLib AthenaPoolCnvSvcLib EventCommonTPCnv GaudiKernel ParticleEvent Particle AthAllocators AthenaKernel CxxUtils SGTools VxVertex ParticleEventTPCnv ) + +atlas_add_test( CompositeParticleContainerCnv_p1_test + SOURCES + test/CompositeParticleContainerCnv_p1_test.cxx + INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} + LINK_LIBRARIES ${ROOT_LIBRARIES} TestTools AthLinks DataModelAthenaPoolLib AthenaPoolCnvSvcLib EventCommonTPCnv GaudiKernel ParticleEvent Particle AthAllocators AthenaKernel CxxUtils SGTools VxVertex ParticleEventTPCnv ) + +atlas_add_test( INav4MomToTrackParticleAssocsCnv_p1_test + SOURCES + test/INav4MomToTrackParticleAssocsCnv_p1_test.cxx + INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} + LINK_LIBRARIES ${ROOT_LIBRARIES} TestTools AthLinks DataModelAthenaPoolLib AthenaPoolCnvSvcLib EventCommonTPCnv GaudiKernel ParticleEvent Particle AthAllocators AthenaKernel CxxUtils SGTools VxVertex ParticleEventTPCnv ) + +atlas_add_test( NeutrinoCnv_p1_test + SOURCES + test/NeutrinoCnv_p1_test.cxx + INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} + LINK_LIBRARIES ${ROOT_LIBRARIES} TestTools AthLinks DataModelAthenaPoolLib AthenaPoolCnvSvcLib EventCommonTPCnv GaudiKernel ParticleEvent Particle AthAllocators AthenaKernel CxxUtils SGTools VxVertex ParticleEventTPCnv ) + +atlas_add_test( NeutrinoCnv_p2_test + SOURCES + test/NeutrinoCnv_p2_test.cxx + INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} + LINK_LIBRARIES ${ROOT_LIBRARIES} TestTools AthLinks DataModelAthenaPoolLib AthenaPoolCnvSvcLib EventCommonTPCnv GaudiKernel ParticleEvent Particle AthAllocators AthenaKernel CxxUtils SGTools VxVertex ParticleEventTPCnv ) + +atlas_add_test( NeutrinoContainerCnv_p1_test + SOURCES + test/NeutrinoContainerCnv_p1_test.cxx + INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} + LINK_LIBRARIES ${ROOT_LIBRARIES} TestTools AthLinks DataModelAthenaPoolLib AthenaPoolCnvSvcLib EventCommonTPCnv GaudiKernel ParticleEvent Particle AthAllocators AthenaKernel CxxUtils SGTools VxVertex ParticleEventTPCnv ) + +atlas_add_test( NeutrinoContainerCnv_p2_test + SOURCES + test/NeutrinoContainerCnv_p2_test.cxx + INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} + LINK_LIBRARIES ${ROOT_LIBRARIES} TestTools AthLinks DataModelAthenaPoolLib AthenaPoolCnvSvcLib EventCommonTPCnv GaudiKernel ParticleEvent Particle AthAllocators AthenaKernel CxxUtils SGTools VxVertex ParticleEventTPCnv ) + +atlas_add_test( ParticleBaseCnv_p1_test + SOURCES + test/ParticleBaseCnv_p1_test.cxx + INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} + LINK_LIBRARIES ${ROOT_LIBRARIES} TestTools AthLinks DataModelAthenaPoolLib AthenaPoolCnvSvcLib EventCommonTPCnv GaudiKernel ParticleEvent Particle AthAllocators AthenaKernel CxxUtils SGTools VxVertex ParticleEventTPCnv ) + +atlas_add_test( ParticleBaseCnv_p2_test + SOURCES + test/ParticleBaseCnv_p2_test.cxx + INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} + LINK_LIBRARIES ${ROOT_LIBRARIES} TestTools AthLinks DataModelAthenaPoolLib AthenaPoolCnvSvcLib EventCommonTPCnv GaudiKernel ParticleEvent Particle AthAllocators AthenaKernel CxxUtils SGTools VxVertex ParticleEventTPCnv ) + +atlas_add_test( ParticleBaseLinksCnv_p1_test + SOURCES + test/ParticleBaseLinksCnv_p1_test.cxx + INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} + LINK_LIBRARIES ${ROOT_LIBRARIES} TestTools AthLinks DataModelAthenaPoolLib AthenaPoolCnvSvcLib EventCommonTPCnv GaudiKernel ParticleEvent Particle AthAllocators AthenaKernel CxxUtils SGTools VxVertex ParticleEventTPCnv ) + +atlas_add_test( ParticleShallowCloneCnv_p1_test + SOURCES + test/ParticleShallowCloneCnv_p1_test.cxx + INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} + LINK_LIBRARIES ${ROOT_LIBRARIES} TestTools AthLinks DataModelAthenaPoolLib AthenaPoolCnvSvcLib EventCommonTPCnv GaudiKernel ParticleEvent Particle AthAllocators AthenaKernel CxxUtils SGTools VxVertex ParticleEventTPCnv ) + +atlas_add_test( ParticleShallowCloneContainerCnv_p1_test + SOURCES + test/ParticleShallowCloneContainerCnv_p1_test.cxx + INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} + LINK_LIBRARIES ${ROOT_LIBRARIES} TestTools AthLinks DataModelAthenaPoolLib AthenaPoolCnvSvcLib EventCommonTPCnv GaudiKernel ParticleEvent Particle AthAllocators AthenaKernel CxxUtils SGTools VxVertex ParticleEventTPCnv ) + +atlas_add_test( SelectedParticlesCnv_p1_test + SOURCES + test/SelectedParticlesCnv_p1_test.cxx + INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} + LINK_LIBRARIES ${ROOT_LIBRARIES} TestTools AthLinks DataModelAthenaPoolLib AthenaPoolCnvSvcLib EventCommonTPCnv GaudiKernel ParticleEvent Particle AthAllocators AthenaKernel CxxUtils SGTools VxVertex ParticleEventTPCnv ) + +atlas_add_test( TrackParticleAssocsCnv_p1_test + SOURCES + test/TrackParticleAssocsCnv_p1_test.cxx + INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} + LINK_LIBRARIES ${ROOT_LIBRARIES} TestTools AthLinks DataModelAthenaPoolLib AthenaPoolCnvSvcLib EventCommonTPCnv GaudiKernel ParticleEvent Particle AthAllocators AthenaKernel CxxUtils SGTools VxVertex ParticleEventTPCnv ) + diff --git a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/ParticleEventTPCnv/INav4MomToTrackParticleAssocsCnv_p1.h b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/ParticleEventTPCnv/INav4MomToTrackParticleAssocsCnv_p1.h index f2e2d22574e38d9cb7b8c101808c1b27d688f60a..43f9755591b3930e7e73b4e779582a620140dabe 100644 --- a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/ParticleEventTPCnv/INav4MomToTrackParticleAssocsCnv_p1.h +++ b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/ParticleEventTPCnv/INav4MomToTrackParticleAssocsCnv_p1.h @@ -17,8 +17,7 @@ // Gaudi includes -// DataModel includes -#include "DataModel/ElementLink.h" +#include "AthLinks/ElementLink.h" // DataModelAthenaPool includes #include "DataModelAthenaPool/ElementLinkCnv_p3.h" diff --git a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/ParticleEventTPCnv/ParticleLinksCnv_p1.h b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/ParticleEventTPCnv/ParticleLinksCnv_p1.h index b7c4e736a942ce96477ec4f1ec82175ba641358b..295d6bbc76bfdb1b0c8c5101fa19de502fb51387 100644 --- a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/ParticleEventTPCnv/ParticleLinksCnv_p1.h +++ b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/ParticleEventTPCnv/ParticleLinksCnv_p1.h @@ -17,14 +17,10 @@ // AthenaPoolCnvSvc includes //#include "AthenaPoolCnvSvc/T_AthenaPoolTPConverter.h" (in DataLinkCnv_p1.h) #include "DataModelAthenaPool/DataLinkCnv_p1.h" -#include "DataModel/DataLink.h" +#include "AthLinks/DataLink.h" #include "GaudiKernel/MsgStream.h" #include "ParticleEvent/ParticleLinks.h" -#define private public -#define protected public #include "ParticleEvent/SelectedParticles.h" -#undef private -#undef protected #include "ParticleEventTPCnv/ParticleLinks_p1.h" #include <string> #include <iostream> @@ -86,7 +82,7 @@ void ParticleLinksCnv_p1<Container>::transToPers(const ParticleLinks<Container>* std::string container_name=(&(*transObj)[0])->dataID(); msg<< MSG::DEBUG<<"Container name="<<container_name<<endreq; - selparts_p1.m_bits=selparts.m_bits; + selparts_p1.m_bits=selparts.AllBits(); persObj->setSelectedParticles_p1(selparts_p1); DataLink<Container> dl(container_name); DataLink_p1 dl_p1; @@ -104,20 +100,18 @@ void ParticleLinksCnv_p1<Container>::persToTrans(const ParticleLinks_p1* persObj const DataLink_p1* dl_p1=persObj->dl_p1(); m_dl.persToTrans(dl_p1,&dl,msg); dl.toTransient(); - const Container *particles=dl.cptr(); + //const Container *particles=dl.cptr(); const SelectedParticles_p1* selparts_p1=persObj->sel(); - typename Container::const_iterator ipItr = particles->begin(); - typename Container::const_iterator ipEnd = particles->end(); + //typename Container::const_iterator ipItr = particles->begin(); + //typename Container::const_iterator ipEnd = particles->end(); SelectedParticles selparts; + selparts.Set (selparts_p1->m_bits); //SelectedParticles selparts(m_bits); - transObj->reserve(selparts.numGood()); - selparts.m_bits=selparts_p1->m_bits; - unsigned ipart=0; - for(; ipItr != ipEnd; ++ipItr) { - if(selparts.isGood(ipart++)){ - ElementLink<Container> el(*particles,ipart-1); - transObj->push_back(el); - } + std::vector<unsigned> goodparts; + selparts.goodParticles (goodparts); + transObj->reserve(goodparts.size()); + for (unsigned index : goodparts) { + transObj->emplace_back (dl.key(), index); } msg << MSG::DEBUG << "Loading "<<typeid(*transObj).name()<<"from SelectedParticles"<<endreq; diff --git a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/ParticleEventTPCnv/ParticleShallowCloneCnv_p1.h b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/ParticleEventTPCnv/ParticleShallowCloneCnv_p1.h index 72502ac9140d61b197a8591ff8d3d49b7f881d89..fd51444e4c22e04c830511ef1b8a83b6cc1e08a1 100644 --- a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/ParticleEventTPCnv/ParticleShallowCloneCnv_p1.h +++ b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/ParticleEventTPCnv/ParticleShallowCloneCnv_p1.h @@ -21,7 +21,9 @@ // Forward declaration class MsgStream; -class ParticleShallowClone; +namespace Analysis { + class ParticleShallowClone; +} class ParticleShallowCloneCnv_p1 : public T_AthenaPoolTPCnvBase<Analysis::ParticleShallowClone, ParticleShallowClone_p1> diff --git a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/ParticleEventTPCnv/TrackParticleAssocsCnv_p1.h b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/ParticleEventTPCnv/TrackParticleAssocsCnv_p1.h index 16d9ebc595d3d30259882ac668e0a141e9be9117..d3e6d8f29d9ad885c45d4c2e763eabf2712ea6a2 100644 --- a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/ParticleEventTPCnv/TrackParticleAssocsCnv_p1.h +++ b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/ParticleEventTPCnv/TrackParticleAssocsCnv_p1.h @@ -17,8 +17,7 @@ // Gaudi includes -// DataModel includes -#include "DataModel/ElementLink.h" +#include "AthLinks/ElementLink.h" // DataModelAthenaPool includes #include "DataModelAthenaPool/ElementLinkCnv_p3.h" diff --git a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/cmt/requirements b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/cmt/requirements index ffdbe37c7aeae01c15ad1477118cb97b19b9afa1..1a7472b7505c9094fba33d63c6655015e62fd12c 100644 --- a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/cmt/requirements +++ b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/cmt/requirements @@ -8,16 +8,19 @@ use AtlasPolicy AtlasPolicy-* use AtlasReflex AtlasReflex-* External use AthenaPoolCnvSvc AthenaPoolCnvSvc-* Database/AthenaPOOL -use DataModel DataModel-* Control +use AthLinks AthLinks-* Control use DataModelAthenaPool DataModelAthenaPool-* Control -use EventCommonTPCnv EventCommonTPCnv-* Event +use EventCommonTPCnv EventCommonTPCnv-* Event use GaudiInterface GaudiInterface-* External use ParticleEvent ParticleEvent-* PhysicsAnalysis/AnalysisCommon use Particle Particle-* Reconstruction private +use CxxUtils CxxUtils-* Control use AthenaKernel AthenaKernel-* Control +use AthAllocators AthAllocators-* Control +use SGTools SGTools-* Control use VxVertex VxVertex-* Tracking/TrkEvent end_private @@ -31,3 +34,19 @@ apply_pattern tpcnv_library # of transient classes apply_pattern lcgdict dict=ParticleEventTPCnv selectionfile=selection.xml headerfiles="../ParticleEventTPCnv/ParticleEventTPCnvDict.h" + +use TestTools TestTools-* AtlasTest +apply_pattern UnitTest_run unit_test=CompositeParticleCnv_p1 +apply_pattern UnitTest_run unit_test=CompositeParticleContainerCnv_p1 +apply_pattern UnitTest_run unit_test=INav4MomToTrackParticleAssocsCnv_p1 +apply_pattern UnitTest_run unit_test=NeutrinoCnv_p1 +apply_pattern UnitTest_run unit_test=NeutrinoCnv_p2 +apply_pattern UnitTest_run unit_test=NeutrinoContainerCnv_p1 +apply_pattern UnitTest_run unit_test=NeutrinoContainerCnv_p2 +apply_pattern UnitTest_run unit_test=ParticleBaseCnv_p1 +apply_pattern UnitTest_run unit_test=ParticleBaseCnv_p2 +apply_pattern UnitTest_run unit_test=ParticleBaseLinksCnv_p1 +apply_pattern UnitTest_run unit_test=ParticleShallowCloneCnv_p1 +apply_pattern UnitTest_run unit_test=ParticleShallowCloneContainerCnv_p1 +apply_pattern UnitTest_run unit_test=SelectedParticlesCnv_p1 +apply_pattern UnitTest_run unit_test=TrackParticleAssocsCnv_p1 diff --git a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/share/CompositeParticleCnv_p1_test.ref b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/share/CompositeParticleCnv_p1_test.ref new file mode 100644 index 0000000000000000000000000000000000000000..a5bce3fd2565d8f458555a0c6f42d0504a848bd5 --- /dev/null +++ b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/share/CompositeParticleCnv_p1_test.ref @@ -0,0 +1 @@ +test1 diff --git a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/share/CompositeParticleContainerCnv_p1_test.ref b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/share/CompositeParticleContainerCnv_p1_test.ref new file mode 100644 index 0000000000000000000000000000000000000000..a5bce3fd2565d8f458555a0c6f42d0504a848bd5 --- /dev/null +++ b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/share/CompositeParticleContainerCnv_p1_test.ref @@ -0,0 +1 @@ +test1 diff --git a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/share/INav4MomToTrackParticleAssocsCnv_p1_test.ref b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/share/INav4MomToTrackParticleAssocsCnv_p1_test.ref new file mode 100644 index 0000000000000000000000000000000000000000..a5bce3fd2565d8f458555a0c6f42d0504a848bd5 --- /dev/null +++ b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/share/INav4MomToTrackParticleAssocsCnv_p1_test.ref @@ -0,0 +1 @@ +test1 diff --git a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/share/NeutrinoCnv_p1_test.ref b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/share/NeutrinoCnv_p1_test.ref new file mode 100644 index 0000000000000000000000000000000000000000..a5bce3fd2565d8f458555a0c6f42d0504a848bd5 --- /dev/null +++ b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/share/NeutrinoCnv_p1_test.ref @@ -0,0 +1 @@ +test1 diff --git a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/share/NeutrinoCnv_p2_test.ref b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/share/NeutrinoCnv_p2_test.ref new file mode 100644 index 0000000000000000000000000000000000000000..a5bce3fd2565d8f458555a0c6f42d0504a848bd5 --- /dev/null +++ b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/share/NeutrinoCnv_p2_test.ref @@ -0,0 +1 @@ +test1 diff --git a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/share/NeutrinoContainerCnv_p1_test.ref b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/share/NeutrinoContainerCnv_p1_test.ref new file mode 100644 index 0000000000000000000000000000000000000000..a5bce3fd2565d8f458555a0c6f42d0504a848bd5 --- /dev/null +++ b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/share/NeutrinoContainerCnv_p1_test.ref @@ -0,0 +1 @@ +test1 diff --git a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/share/NeutrinoContainerCnv_p2_test.ref b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/share/NeutrinoContainerCnv_p2_test.ref new file mode 100644 index 0000000000000000000000000000000000000000..a5bce3fd2565d8f458555a0c6f42d0504a848bd5 --- /dev/null +++ b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/share/NeutrinoContainerCnv_p2_test.ref @@ -0,0 +1 @@ +test1 diff --git a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/share/ParticleBaseCnv_p1_test.ref b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/share/ParticleBaseCnv_p1_test.ref new file mode 100644 index 0000000000000000000000000000000000000000..a5bce3fd2565d8f458555a0c6f42d0504a848bd5 --- /dev/null +++ b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/share/ParticleBaseCnv_p1_test.ref @@ -0,0 +1 @@ +test1 diff --git a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/share/ParticleBaseCnv_p2_test.ref b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/share/ParticleBaseCnv_p2_test.ref new file mode 100644 index 0000000000000000000000000000000000000000..a5bce3fd2565d8f458555a0c6f42d0504a848bd5 --- /dev/null +++ b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/share/ParticleBaseCnv_p2_test.ref @@ -0,0 +1 @@ +test1 diff --git a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/share/ParticleBaseLinksCnv_p1_test.ref b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/share/ParticleBaseLinksCnv_p1_test.ref new file mode 100644 index 0000000000000000000000000000000000000000..a5bce3fd2565d8f458555a0c6f42d0504a848bd5 --- /dev/null +++ b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/share/ParticleBaseLinksCnv_p1_test.ref @@ -0,0 +1 @@ +test1 diff --git a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/share/ParticleShallowCloneCnv_p1_test.ref b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/share/ParticleShallowCloneCnv_p1_test.ref new file mode 100644 index 0000000000000000000000000000000000000000..a5bce3fd2565d8f458555a0c6f42d0504a848bd5 --- /dev/null +++ b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/share/ParticleShallowCloneCnv_p1_test.ref @@ -0,0 +1 @@ +test1 diff --git a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/share/ParticleShallowCloneContainerCnv_p1_test.ref b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/share/ParticleShallowCloneContainerCnv_p1_test.ref new file mode 100644 index 0000000000000000000000000000000000000000..a5bce3fd2565d8f458555a0c6f42d0504a848bd5 --- /dev/null +++ b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/share/ParticleShallowCloneContainerCnv_p1_test.ref @@ -0,0 +1 @@ +test1 diff --git a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/share/SelectedParticlesCnv_p1_test.ref b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/share/SelectedParticlesCnv_p1_test.ref new file mode 100644 index 0000000000000000000000000000000000000000..a5bce3fd2565d8f458555a0c6f42d0504a848bd5 --- /dev/null +++ b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/share/SelectedParticlesCnv_p1_test.ref @@ -0,0 +1 @@ +test1 diff --git a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/share/TrackParticleAssocsCnv_p1_test.ref b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/share/TrackParticleAssocsCnv_p1_test.ref new file mode 100644 index 0000000000000000000000000000000000000000..a5bce3fd2565d8f458555a0c6f42d0504a848bd5 --- /dev/null +++ b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/share/TrackParticleAssocsCnv_p1_test.ref @@ -0,0 +1 @@ +test1 diff --git a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/src/CompositeParticleCnv_p1.cxx b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/src/CompositeParticleCnv_p1.cxx index b405419c53643eda3de3f10ae5ae079b9b05a4fb..fbaff9fb464f1d62b81e61e0de20ba9b5f25ef3b 100644 --- a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/src/CompositeParticleCnv_p1.cxx +++ b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/src/CompositeParticleCnv_p1.cxx @@ -13,11 +13,7 @@ // STL includes // ParticleEvent includes -#define private public -#define protected public #include "ParticleEvent/CompositeParticle.h" -#undef private -#undef protected // DataModelAthenaPool includes #include "DataModelAthenaPool/NavigableCnv_p1.h" diff --git a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/src/CompositeParticleContainerCnv_p1.cxx b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/src/CompositeParticleContainerCnv_p1.cxx index bfc93f5d0ba2b19284ba80ac69a5c26df1a0f013..ac1f0783b4184d7a12126efddee798a6d049bd38 100644 --- a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/src/CompositeParticleContainerCnv_p1.cxx +++ b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/src/CompositeParticleContainerCnv_p1.cxx @@ -9,8 +9,7 @@ // Author: S.Binet<binet@cern.ch> /////////////////////////////////////////////////////////////////// -// DataModel includes -#include "DataModel/DataPool.h" +#include "AthAllocators/DataPool.h" // ParticleEvent includes #define private public @@ -54,7 +53,7 @@ CompositeParticleContainerCnv_p1::persToTrans( const CompositeParticleContainer_ // elements are managed by DataPool trans->clear(SG::VIEW_ELEMENTS); - static DataPool<CompositeParticle> pool( 20 ); + DataPool<CompositeParticle> pool( 20 ); const std::size_t nElems = pers->size(); if ( pool.capacity() - pool.allocated() < nElems ) { pool.reserve( pool.allocated() + nElems ); diff --git a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/src/NeutrinoCnv_p1.cxx b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/src/NeutrinoCnv_p1.cxx index 9cd46810c78794add616af3265d008e9a26fd8c3..580d20fcdac357e36d7a53190f73587421e966bd 100644 --- a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/src/NeutrinoCnv_p1.cxx +++ b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/src/NeutrinoCnv_p1.cxx @@ -13,11 +13,7 @@ // STL includes // ParticleEvent includes -#define private public -#define protected public #include "ParticleEvent/Neutrino.h" -#undef private -#undef protected // EventCommonTPCnv includes #include "EventCommonTPCnv/P4ImplPxPyPzECnv_p1.h" diff --git a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/src/NeutrinoCnv_p2.cxx b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/src/NeutrinoCnv_p2.cxx index 8367b402c16de2d385202a64d0cf189462772d5e..2e6dc4ac664fc99f309d702f37b56087f212e839 100644 --- a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/src/NeutrinoCnv_p2.cxx +++ b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/src/NeutrinoCnv_p2.cxx @@ -13,11 +13,7 @@ // STL includes // ParticleEvent includes -#define private public -#define protected public #include "ParticleEvent/Neutrino.h" -#undef private -#undef protected // EventCommonTPCnv includes #include "EventCommonTPCnv/P4ImplPxPyPzECnv_p1.h" diff --git a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/src/ParticleShallowCloneCnv_p1.cxx b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/src/ParticleShallowCloneCnv_p1.cxx index 9e833e788375dbfac5e6a7e33b51a070ef414c84..2692c1d317ffda733f9c68384f418ade84b1c940 100644 --- a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/src/ParticleShallowCloneCnv_p1.cxx +++ b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/src/ParticleShallowCloneCnv_p1.cxx @@ -13,11 +13,7 @@ // STL includes // ParticleEvent includes -#define private public -#define protected public #include "ParticleEvent/ParticleShallowClone.h" -#undef private -#undef protected // DataModelAthenaPool includes #include "DataModelAthenaPool/ElementLinkCnv_p3.h" diff --git a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/src/ParticleShallowCloneContainerCnv_p1.cxx b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/src/ParticleShallowCloneContainerCnv_p1.cxx index 166db4f9bd80964cfd0276ebf254153a48f47613..2f0a29ff27e6c3898e0ff7733a969cb27c202ae3 100644 --- a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/src/ParticleShallowCloneContainerCnv_p1.cxx +++ b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/src/ParticleShallowCloneContainerCnv_p1.cxx @@ -9,8 +9,7 @@ // Author: Karsten Koeneke - February 2013 /////////////////////////////////////////////////////////////////// -// DataModel includes -#include "DataModel/DataPool.h" +#include "AthAllocators/DataPool.h" // ParticleEvent includes #define private public @@ -54,7 +53,7 @@ ParticleShallowCloneContainerCnv_p1::persToTrans( const ParticleShallowCloneCont // elements are managed by DataPool trans->clear(SG::VIEW_ELEMENTS); - static DataPool<Analysis::ParticleShallowClone> pool( 20 ); + DataPool<Analysis::ParticleShallowClone> pool( 20 ); const std::size_t nElems = pers->size(); if ( pool.capacity() - pool.allocated() < nElems ) { pool.reserve( pool.allocated() + nElems ); diff --git a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/src/SelectedParticlesCnv_p1.cxx b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/src/SelectedParticlesCnv_p1.cxx index f35b8abc07ff6d6e2d1f1e505e72727af8d7b3f0..45123a85300fb41a997197396cda3ccaaeb1ada6 100644 --- a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/src/SelectedParticlesCnv_p1.cxx +++ b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/src/SelectedParticlesCnv_p1.cxx @@ -13,11 +13,7 @@ // STL includes // ParticleEvent includes -#define private public -#define protected public #include "ParticleEvent/SelectedParticles.h" -#undef private -#undef protected #include "ParticleEventTPCnv/SelectedParticlesCnv_p1.h" #include "GaudiKernel/MsgStream.h" @@ -28,7 +24,7 @@ SelectedParticlesCnv_p1::persToTrans( const SelectedParticles_p1* pers, { msg << MSG::DEBUG << "Creating transient state of SelectedParticles" << endreq; - trans->m_bits=pers->m_bits; + trans->Set (pers->m_bits); return; } @@ -39,6 +35,6 @@ SelectedParticlesCnv_p1::transToPers( const SelectedParticles* trans, { msg << MSG::DEBUG << "Creating persistent state of SelectedParticles" << endreq; - pers->m_bits=trans->m_bits; + pers->m_bits=trans->AllBits(); return; } diff --git a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/test/CompositeParticleCnv_p1_test.cxx b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/test/CompositeParticleCnv_p1_test.cxx new file mode 100644 index 0000000000000000000000000000000000000000..2efafa158b851055aa67e72c6d6ed95c2b5d7951 --- /dev/null +++ b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/test/CompositeParticleCnv_p1_test.cxx @@ -0,0 +1,110 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id$ +/** + * @file ParticleEventTPCnv/test/CompositeParticleCnv_p1_test.cxx + * @author scott snyder <snyder@bnl.gov> + * @date Nov, 2015 + * @brief Regression tests. + */ + +#undef NDEBUG +#include "ParticleEventTPCnv/CompositeParticleCnv_p1.h" +#include "ParticleEvent/CompositeParticle.h" +#include "SGTools/TestStore.h" +#include "GaudiKernel/MsgStream.h" +#include <cassert> +#include <iostream> + + +void compare (const ParticleEvent::Base& p1, + const ParticleEvent::Base& p2) +{ + assert (p1.dataType() == p2.dataType()); + assert (p1.originLink() == p2.originLink()); + assert (p1.hasCharge() == p2.hasCharge()); + if (p1.hasCharge()) + assert (p1.charge() == p2.charge()); + assert (p1.hasPdgId() == p2.hasPdgId()); + if (p1.hasPdgId()) + assert (p1.pdgId() == p2.pdgId()); +} + + +void compare (const P4ImplPxPyPzE& p1, + const P4ImplPxPyPzE& p2) +{ + assert (p1.px() == p2.px()); + assert (p1.py() == p2.py()); + assert (p1.pz() == p2.pz()); + assert (p1.e() == p2.e()); +} + + +void compare (const CompositeParticleNavigation& p1, + const CompositeParticleNavigation& p2) +{ + assert (p1.size() == p2.size()); + CompositeParticleNavigation::object_iter i1 = p1.begin(); + CompositeParticleNavigation::object_iter i2 = p2.begin(); + for (size_t i = 0; i < p1.size(); ++i, ++i1, ++i2) { + assert (*i1 == *i2); + assert (p1.getParameter(i1) == p2.getParameter(i2)); + } +} + + +void compare (const CompositeParticle& p1, + const CompositeParticle& p2) +{ + compare (p1.particleBase(), p2.particleBase()); + compare (p1.momentumBase(), p2.momentumBase()); + compare (p1.navigableBase(), p2.navigableBase()); +} + + +void testit (const CompositeParticle& trans1) +{ + MsgStream log (0, "test"); + + CompositeParticleCnv_p1 cnv; + CompositeParticle_p1 pers; + cnv.transToPers (&trans1, &pers, log); + + CompositeParticle trans2; + cnv.persToTrans (&pers, &trans2, log); + + compare (trans1, trans2); +} + + +void test1() +{ + std::cout << "test1\n"; + + CompositeParticle trans1; + trans1.set4Mom (CLHEP::HepLorentzVector(100,200,300,400)); + trans1.set_dataType (ParticleDataType::FastShower); + trans1.set_origin (ElementLink<VxContainer> ("orig", 10)); + trans1.navigableBase().insertElement (INav4MomLink ("part", 12)); + trans1.navigableBase().insertElement (INav4MomLink ("part", 19)); + testit (trans1); + + CompositeParticle trans2 (trans1); + trans2.set_charge (1.5); + testit (trans2); + + CompositeParticle trans3 (trans1); + trans3.set_pdgId (PDG::t); + testit (trans3); +} + + +int main() +{ + SGTest::initTestStore(); + test1(); + return 0; +} diff --git a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/test/CompositeParticleContainerCnv_p1_test.cxx b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/test/CompositeParticleContainerCnv_p1_test.cxx new file mode 100644 index 0000000000000000000000000000000000000000..f768b87791cda757d1072c5be91ffa9b7eb4bd47 --- /dev/null +++ b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/test/CompositeParticleContainerCnv_p1_test.cxx @@ -0,0 +1,118 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id$ +/** + * @file ParticleEventTPCnv/test/CompositeParticleCnv_p1_test.cxx + * @author scott snyder <snyder@bnl.gov> + * @date Nov, 2015 + * @brief Regression tests. + */ + +#undef NDEBUG +#include "ParticleEventTPCnv/CompositeParticleContainerCnv_p1.h" +#include "ParticleEvent/CompositeParticleContainer.h" +#include "SGTools/TestStore.h" +#include "CxxUtils/make_unique.h" +#include "GaudiKernel/MsgStream.h" +#include <cassert> +#include <iostream> + + +void compare (const ParticleEvent::Base& p1, + const ParticleEvent::Base& p2) +{ + assert (p1.dataType() == p2.dataType()); + assert (p1.originLink() == p2.originLink()); + assert (p1.hasCharge() == p2.hasCharge()); + if (p1.hasCharge()) + assert (p1.charge() == p2.charge()); + assert (p1.hasPdgId() == p2.hasPdgId()); + if (p1.hasPdgId()) + assert (p1.pdgId() == p2.pdgId()); +} + + +void compare (const P4ImplPxPyPzE& p1, + const P4ImplPxPyPzE& p2) +{ + assert (p1.px() == p2.px()); + assert (p1.py() == p2.py()); + assert (p1.pz() == p2.pz()); + assert (p1.e() == p2.e()); +} + + +void compare (const CompositeParticleNavigation& p1, + const CompositeParticleNavigation& p2) +{ + assert (p1.size() == p2.size()); + CompositeParticleNavigation::object_iter i1 = p1.begin(); + CompositeParticleNavigation::object_iter i2 = p2.begin(); + for (size_t i = 0; i < p1.size(); ++i, ++i1, ++i2) { + assert (*i1 == *i2); + assert (p1.getParameter(i1) == p2.getParameter(i2)); + } +} + + +void compare (const CompositeParticle& p1, + const CompositeParticle& p2) +{ + compare (p1.particleBase(), p2.particleBase()); + compare (p1.momentumBase(), p2.momentumBase()); + compare (p1.navigableBase(), p2.navigableBase()); +} + + +void compare (const CompositeParticleContainer& c1, + const CompositeParticleContainer& c2) +{ + assert (c1.size() == c2.size()); + for (size_t i = 0; i < c1.size(); i++) + compare (*c1[i], *c2[i]); +} + + +void test1() +{ + std::cout << "test1\n"; + + CompositeParticleContainer trans1; + auto p1 = CxxUtils::make_unique<CompositeParticle>(); + p1->set4Mom (CLHEP::HepLorentzVector(100,200,300,400)); + p1->set_dataType (ParticleDataType::FastShower); + p1->set_origin (ElementLink<VxContainer> ("orig", 10)); + p1->navigableBase().insertElement (INav4MomLink ("part", 12)); + p1->navigableBase().insertElement (INav4MomLink ("part", 19)); + + auto p2 = CxxUtils::make_unique<CompositeParticle>(*p1); + p2->set_charge (1.5); + + auto p3 = CxxUtils::make_unique<CompositeParticle>(*p1); + p3->set_pdgId (PDG::t); + + trans1.push_back (std::move(p1)); + trans1.push_back (std::move(p2)); + trans1.push_back (std::move(p3)); + + MsgStream log (0, "test"); + + CompositeParticleContainerCnv_p1 cnv; + CompositeParticleContainer_p1 pers; + cnv.transToPers (&trans1, &pers, log); + + CompositeParticleContainer trans2; + cnv.persToTrans (&pers, &trans2, log); + + compare (trans1, trans2); +} + + +int main() +{ + SGTest::initTestStore(); + test1(); + return 0; +} diff --git a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/test/INav4MomToTrackParticleAssocsCnv_p1_test.cxx b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/test/INav4MomToTrackParticleAssocsCnv_p1_test.cxx new file mode 100644 index 0000000000000000000000000000000000000000..01d1dfa80a3a616d0af55292506618d964b2bd84 --- /dev/null +++ b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/test/INav4MomToTrackParticleAssocsCnv_p1_test.cxx @@ -0,0 +1,87 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id$ +/** + * @file ParticleEventTPCnv/test/INav4MomToTrackParticleAssocsCnv_p1_test.cxx + * @author scott snyder <snyder@bnl.gov> + * @date Nov, 2015 + * @brief Regression tests. + */ + +#undef NDEBUG +#include "ParticleEventTPCnv/INav4MomToTrackParticleAssocsCnv_p1.h" +#include "ParticleEvent/INav4MomToTrackParticleAssocs.h" +#include "ParticleEvent/Neutrino.h" +#include "SGTools/TestStore.h" +#include "CxxUtils/make_unique.h" +#include "GaudiKernel/MsgStream.h" +#include <cassert> +#include <iostream> + + +void compare (const INav4MomToTrackParticleAssocs& a1, + const INav4MomToTrackParticleAssocs& a2) +{ + assert (a1.size() == a2.size()); + INav4MomToTrackParticleAssocs::object_iterator i1 = a1.beginObject(); + INav4MomToTrackParticleAssocs::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()); + INav4MomToTrackParticleAssocs::asso_iterator j1 = i1.second(); + INav4MomToTrackParticleAssocs::asso_iterator j2 = i2.second(); + for (size_t j = 0; j < i1.getNumberOfAssociations(); ++j, ++j1, ++j2) { + assert (j1.getLink() == j2.getLink()); + } + } + + assert (a1.nAssocStores() == a2.nAssocStores()); + assert (a1.assocStore ("foo").isDefault()); + assert (a2.assocStore ("foo").isDefault()); + assert (a1.assocStore ("xstore") == DataLink<INav4MomToTrackParticleAssocs> ("xstore")); + assert (a2.assocStore ("xstore") == DataLink<INav4MomToTrackParticleAssocs> ("xstore")); +} + + +void test1() +{ + std::cout << "test1\n"; + + INavigable4MomentumCollection* in4mc = new INavigable4MomentumCollection; + for (int i=0; i < 10; i++) + in4mc->push_back (CxxUtils::make_unique<Neutrino>()); + SGTest::store.record (in4mc, "in"); + + INav4MomToTrackParticleAssocs* xstore = new INav4MomToTrackParticleAssocs; + SGTest::store.record (xstore, "xstore"); + + INav4MomToTrackParticleAssocs trans1; + trans1.addAssociation (ElementLink<INavigable4MomentumCollection> ("in", 3), + ElementLink<Rec::TrackParticleContainer> ("tp", 2)); + trans1.addAssociation (ElementLink<INavigable4MomentumCollection> ("in", 6), + ElementLink<Rec::TrackParticleContainer> ("tp", 4)); + + trans1.addAssocStore (DataLink<INav4MomToTrackParticleAssocs> ("xstore")); + + MsgStream log (0, "test"); + + INav4MomToTrackParticleAssocsCnv_p1 cnv; + INav4MomToTrackParticleAssocs_p1 pers; + cnv.transToPers (&trans1, &pers, log); + + INav4MomToTrackParticleAssocs trans2; + cnv.persToTrans (&pers, &trans2, log); + + compare (trans1, trans2); +} + + +int main() +{ + SGTest::initTestStore(); + test1(); + return 0; +} diff --git a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/test/NeutrinoCnv_p1_test.cxx b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/test/NeutrinoCnv_p1_test.cxx new file mode 100644 index 0000000000000000000000000000000000000000..9a7f695570eb3eea66d5564af0f68fbd227f6fdb --- /dev/null +++ b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/test/NeutrinoCnv_p1_test.cxx @@ -0,0 +1,94 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id$ +/** + * @file ParticleEventTPCnv/test/NeutrinoCnv_p1_test.cxx + * @author scott snyder <snyder@bnl.gov> + * @date Nov, 2015 + * @brief Regression tests. + */ + +#undef NDEBUG +#include "ParticleEventTPCnv/NeutrinoCnv_p1.h" +#include "ParticleEvent/Neutrino.h" +#include "SGTools/TestStore.h" +#include "GaudiKernel/MsgStream.h" +#include <cassert> +#include <iostream> + + +void compare (const ParticleEvent::Base& p1, + const ParticleEvent::Base& p2) +{ + assert (p1.dataType() == p2.dataType()); + assert (p1.originLink() == p2.originLink()); + assert (p1.hasCharge() == p2.hasCharge()); + if (p1.hasCharge()) + assert (p1.charge() == p2.charge()); + assert (p1.hasPdgId() == p2.hasPdgId()); + if (p1.hasPdgId()) + assert (p1.pdgId() == p2.pdgId()); +} + + +void compare (const P4ImplPxPyPzE& p1, + const P4ImplPxPyPzE& p2) +{ + assert (p1.px() == p2.px()); + assert (p1.py() == p2.py()); + assert (p1.pz() == p2.pz()); + assert (p1.e() == p2.e()); +} + + +void compare (const Neutrino& p1, + const Neutrino& p2) +{ + compare (p1.particleBase(), p2.particleBase()); + compare (p1.momentumBase(), p2.momentumBase()); +} + + +void testit (const Neutrino& trans1) +{ + MsgStream log (0, "test"); + + NeutrinoCnv_p1 cnv; + Neutrino_p1 pers; + cnv.transToPers (&trans1, &pers, log); + + Neutrino trans2; + cnv.persToTrans (&pers, &trans2, log); + + compare (trans1, trans2); +} + + +void test1() +{ + std::cout << "test1\n"; + + Neutrino trans1; + trans1.set4Mom (CLHEP::HepLorentzVector(100,200,300,400)); + trans1.set_dataType (ParticleDataType::FastShower); + trans1.set_origin (ElementLink<VxContainer> ("orig", 10)); + testit (trans1); + + Neutrino trans2 (trans1); + trans2.set_charge (1.5); + testit (trans2); + + Neutrino trans3 (trans1); + trans3.set_pdgId (PDG::t); + testit (trans3); +} + + +int main() +{ + SGTest::initTestStore(); + test1(); + return 0; +} diff --git a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/test/NeutrinoCnv_p2_test.cxx b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/test/NeutrinoCnv_p2_test.cxx new file mode 100644 index 0000000000000000000000000000000000000000..40923da46136b876d64f38a5a379c5906b35c3bd --- /dev/null +++ b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/test/NeutrinoCnv_p2_test.cxx @@ -0,0 +1,94 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id$ +/** + * @file ParticleEventTPCnv/test/NeutrinoCnv_p2_test.cxx + * @author scott snyder <snyder@bnl.gov> + * @date Nov, 2015 + * @brief Regression tests. + */ + +#undef NDEBUG +#include "ParticleEventTPCnv/NeutrinoCnv_p2.h" +#include "ParticleEvent/Neutrino.h" +#include "SGTools/TestStore.h" +#include "GaudiKernel/MsgStream.h" +#include <cassert> +#include <iostream> + + +void compare (const ParticleEvent::Base& p1, + const ParticleEvent::Base& p2) +{ + assert (p1.dataType() == p2.dataType()); + assert (p1.originLink() == p2.originLink()); + assert (p1.hasCharge() == p2.hasCharge()); + if (p1.hasCharge()) + assert (p1.charge() == p2.charge()); + assert (p1.hasPdgId() == p2.hasPdgId()); + if (p1.hasPdgId()) + assert (p1.pdgId() == p2.pdgId()); +} + + +void compare (const P4ImplPxPyPzE& p1, + const P4ImplPxPyPzE& p2) +{ + assert (p1.px() == p2.px()); + assert (p1.py() == p2.py()); + assert (p1.pz() == p2.pz()); + assert (p1.e() == p2.e()); +} + + +void compare (const Neutrino& p1, + const Neutrino& p2) +{ + compare (p1.particleBase(), p2.particleBase()); + compare (p1.momentumBase(), p2.momentumBase()); +} + + +void testit (const Neutrino& trans1) +{ + MsgStream log (0, "test"); + + NeutrinoCnv_p2 cnv; + Neutrino_p2 pers; + cnv.transToPers (&trans1, &pers, log); + + Neutrino trans2; + cnv.persToTrans (&pers, &trans2, log); + + compare (trans1, trans2); +} + + +void test1() +{ + std::cout << "test1\n"; + + Neutrino trans1; + trans1.set4Mom (CLHEP::HepLorentzVector(100,200,300,400)); + trans1.set_dataType (ParticleDataType::FastShower); + trans1.set_origin (ElementLink<VxContainer> ("orig", 10)); + testit (trans1); + + Neutrino trans2 (trans1); + trans2.set_charge (1.5); + testit (trans2); + + Neutrino trans3 (trans1); + trans3.set_pdgId (PDG::t); + testit (trans3); +} + + +int main() +{ + SGTest::initTestStore(); + test1(); + return 0; +} diff --git a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/test/NeutrinoContainerCnv_p1_test.cxx b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/test/NeutrinoContainerCnv_p1_test.cxx new file mode 100644 index 0000000000000000000000000000000000000000..50b226a30df149298725a42b39c1d96df5499c28 --- /dev/null +++ b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/test/NeutrinoContainerCnv_p1_test.cxx @@ -0,0 +1,102 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id$ +/** + * @file ParticleEventTPCnv/test/NeutrinoContainerCnv_p1_test.cxx + * @author scott snyder <snyder@bnl.gov> + * @date Nov, 2015 + * @brief Regression tests. + */ + +#undef NDEBUG +#include "ParticleEventTPCnv/NeutrinoContainerCnv_p1.h" +#include "ParticleEvent/NeutrinoContainer.h" +#include "SGTools/TestStore.h" +#include "CxxUtils/make_unique.h" +#include "GaudiKernel/MsgStream.h" +#include <cassert> +#include <iostream> + + +void compare (const ParticleEvent::Base& p1, + const ParticleEvent::Base& p2) +{ + assert (p1.dataType() == p2.dataType()); + assert (p1.originLink() == p2.originLink()); + assert (p1.hasCharge() == p2.hasCharge()); + if (p1.hasCharge()) + assert (p1.charge() == p2.charge()); + assert (p1.hasPdgId() == p2.hasPdgId()); + if (p1.hasPdgId()) + assert (p1.pdgId() == p2.pdgId()); +} + + +void compare (const P4ImplPxPyPzE& p1, + const P4ImplPxPyPzE& p2) +{ + assert (p1.px() == p2.px()); + assert (p1.py() == p2.py()); + assert (p1.pz() == p2.pz()); + assert (p1.e() == p2.e()); +} + + +void compare (const Neutrino& p1, + const Neutrino& p2) +{ + compare (p1.particleBase(), p2.particleBase()); + compare (p1.momentumBase(), p2.momentumBase()); +} + + +void compare (const NeutrinoContainer& c1, + const NeutrinoContainer& c2) +{ + assert (c1.size() == c2.size()); + for (size_t i = 0; i < c1.size(); i++) + compare (*c1[i], *c2[i]); +} + + +void test1() +{ + std::cout << "test1\n"; + + NeutrinoContainer trans1; + auto p1 = CxxUtils::make_unique<Neutrino>(); + p1->set4Mom (CLHEP::HepLorentzVector(100,200,300,400)); + p1->set_dataType (ParticleDataType::FastShower); + p1->set_origin (ElementLink<VxContainer> ("orig", 10)); + + auto p2 = CxxUtils::make_unique<Neutrino>(*p1); + p2->set_charge (1.5); + + auto p3 = CxxUtils::make_unique<Neutrino>(*p1); + p3->set_pdgId (PDG::t); + + trans1.push_back (std::move(p1)); + trans1.push_back (std::move(p2)); + trans1.push_back (std::move(p3)); + + MsgStream log (0, "test"); + + NeutrinoContainerCnv_p1 cnv; + NeutrinoContainer_p1 pers; + cnv.transToPers (&trans1, &pers, log); + + NeutrinoContainer trans2; + cnv.persToTrans (&pers, &trans2, log); + + compare (trans1, trans2); +} + + +int main() +{ + SGTest::initTestStore(); + test1(); + return 0; +} diff --git a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/test/NeutrinoContainerCnv_p2_test.cxx b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/test/NeutrinoContainerCnv_p2_test.cxx new file mode 100644 index 0000000000000000000000000000000000000000..8e102087b89621e025f5f032a64c296e0adfaa33 --- /dev/null +++ b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/test/NeutrinoContainerCnv_p2_test.cxx @@ -0,0 +1,102 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id$ +/** + * @file ParticleEventTPCnv/test/NeutrinoContainerCnv_p2_test.cxx + * @author scott snyder <snyder@bnl.gov> + * @date Nov, 2015 + * @brief Regression tests. + */ + +#undef NDEBUG +#include "ParticleEventTPCnv/NeutrinoContainerCnv_p2.h" +#include "ParticleEvent/NeutrinoContainer.h" +#include "SGTools/TestStore.h" +#include "CxxUtils/make_unique.h" +#include "GaudiKernel/MsgStream.h" +#include <cassert> +#include <iostream> + + +void compare (const ParticleEvent::Base& p1, + const ParticleEvent::Base& p2) +{ + assert (p1.dataType() == p2.dataType()); + assert (p1.originLink() == p2.originLink()); + assert (p1.hasCharge() == p2.hasCharge()); + if (p1.hasCharge()) + assert (p1.charge() == p2.charge()); + assert (p1.hasPdgId() == p2.hasPdgId()); + if (p1.hasPdgId()) + assert (p1.pdgId() == p2.pdgId()); +} + + +void compare (const P4ImplPxPyPzE& p1, + const P4ImplPxPyPzE& p2) +{ + assert (p1.px() == p2.px()); + assert (p1.py() == p2.py()); + assert (p1.pz() == p2.pz()); + assert (p1.e() == p2.e()); +} + + +void compare (const Neutrino& p1, + const Neutrino& p2) +{ + compare (p1.particleBase(), p2.particleBase()); + compare (p1.momentumBase(), p2.momentumBase()); +} + + +void compare (const NeutrinoContainer& c1, + const NeutrinoContainer& c2) +{ + assert (c1.size() == c2.size()); + for (size_t i = 0; i < c1.size(); i++) + compare (*c1[i], *c2[i]); +} + + +void test1() +{ + std::cout << "test1\n"; + + NeutrinoContainer trans1; + auto p1 = CxxUtils::make_unique<Neutrino>(); + p1->set4Mom (CLHEP::HepLorentzVector(100,200,300,400)); + p1->set_dataType (ParticleDataType::FastShower); + p1->set_origin (ElementLink<VxContainer> ("orig", 10)); + + auto p2 = CxxUtils::make_unique<Neutrino>(*p1); + p2->set_charge (1.5); + + auto p3 = CxxUtils::make_unique<Neutrino>(*p1); + p3->set_pdgId (PDG::t); + + trans1.push_back (std::move(p1)); + trans1.push_back (std::move(p2)); + trans1.push_back (std::move(p3)); + + MsgStream log (0, "test"); + + NeutrinoContainerCnv_p2 cnv; + NeutrinoContainer_p2 pers; + cnv.transToPers (&trans1, &pers, log); + + NeutrinoContainer trans2; + cnv.persToTrans (&pers, &trans2, log); + + compare (trans1, trans2); +} + + +int main() +{ + SGTest::initTestStore(); + test1(); + return 0; +} diff --git a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/test/ParticleBaseCnv_p1_test.cxx b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/test/ParticleBaseCnv_p1_test.cxx new file mode 100644 index 0000000000000000000000000000000000000000..3c4edf57f6d35b759272416ef9ee7a70a1443d6d --- /dev/null +++ b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/test/ParticleBaseCnv_p1_test.cxx @@ -0,0 +1,75 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id$ +/** + * @file ParticleEventTPCnv/test/ParticleBaseCnv_p1_test.cxx + * @author scott snyder <snyder@bnl.gov> + * @date Nov, 2015 + * @brief Regression tests. + */ + +#undef NDEBUG +#include "ParticleEventTPCnv/ParticleBaseCnv_p1.h" +#include "ParticleEvent/ParticleBase.h" +#include "SGTools/TestStore.h" +#include "GaudiKernel/MsgStream.h" +#include <cassert> +#include <iostream> + + +void compare (const ParticleEvent::Base& p1, + const ParticleEvent::Base& p2) +{ + assert (p1.dataType() == p2.dataType()); + assert (p1.originLink() == p2.originLink()); + assert (p1.hasCharge() == p2.hasCharge()); + if (p1.hasCharge()) + assert (p1.charge() == p2.charge()); + assert (p1.hasPdgId() == p2.hasPdgId()); + if (p1.hasPdgId()) + assert (p1.pdgId() == p2.pdgId()); +} + + +void testit (const ParticleEvent::Base& trans1) +{ + MsgStream log (0, "test"); + + ParticleBaseCnv_p1 cnv; + ParticleBase_p1 pers; + cnv.transToPers (&trans1, &pers, log); + + ParticleEvent::Base trans2; + cnv.persToTrans (&pers, &trans2, log); + + compare (trans1, trans2); +} + + +void test1() +{ + std::cout << "test1\n"; + + ParticleEvent::Base trans1; + trans1.set_dataType (ParticleDataType::FastShower); + trans1.set_origin (ElementLink<VxContainer> ("orig", 10)); + testit (trans1); + + ParticleEvent::Base trans2 (trans1); + trans2.set_charge (1.5); + testit (trans2); + + ParticleEvent::Base trans3 (trans1); + trans3.set_pdgId (PDG::t); + testit (trans3); +} + + +int main() +{ + SGTest::initTestStore(); + test1(); + return 0; +} diff --git a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/test/ParticleBaseCnv_p2_test.cxx b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/test/ParticleBaseCnv_p2_test.cxx new file mode 100644 index 0000000000000000000000000000000000000000..87ff0ffe2007b25172409057151b193177798186 --- /dev/null +++ b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/test/ParticleBaseCnv_p2_test.cxx @@ -0,0 +1,75 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id$ +/** + * @file ParticleEventTPCnv/test/ParticleBaseCnv_p2_test.cxx + * @author scott snyder <snyder@bnl.gov> + * @date Nov, 2015 + * @brief Regression tests. + */ + +#undef NDEBUG +#include "ParticleEventTPCnv/ParticleBaseCnv_p2.h" +#include "ParticleEvent/ParticleBase.h" +#include "SGTools/TestStore.h" +#include "GaudiKernel/MsgStream.h" +#include <cassert> +#include <iostream> + + +void compare (const ParticleEvent::Base& p1, + const ParticleEvent::Base& p2) +{ + assert (p1.dataType() == p2.dataType()); + assert (p1.originLink() == p2.originLink()); + assert (p1.hasCharge() == p2.hasCharge()); + if (p1.hasCharge()) + assert (p1.charge() == p2.charge()); + assert (p1.hasPdgId() == p2.hasPdgId()); + if (p1.hasPdgId()) + assert (p1.pdgId() == p2.pdgId()); +} + + +void testit (const ParticleEvent::Base& trans1) +{ + MsgStream log (0, "test"); + + ParticleBaseCnv_p2 cnv; + ParticleBase_p2 pers; + cnv.transToPers (&trans1, &pers, log); + + ParticleEvent::Base trans2; + cnv.persToTrans (&pers, &trans2, log); + + compare (trans1, trans2); +} + + +void test1() +{ + std::cout << "test1\n"; + + ParticleEvent::Base trans1; + trans1.set_dataType (ParticleDataType::FastShower); + trans1.set_origin (ElementLink<VxContainer> ("orig", 10)); + testit (trans1); + + ParticleEvent::Base trans2 (trans1); + trans2.set_charge (1.5); + testit (trans2); + + ParticleEvent::Base trans3 (trans1); + trans3.set_pdgId (PDG::t); + testit (trans3); +} + + +int main() +{ + SGTest::initTestStore(); + test1(); + return 0; +} diff --git a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/test/ParticleBaseLinksCnv_p1_test.cxx b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/test/ParticleBaseLinksCnv_p1_test.cxx new file mode 100644 index 0000000000000000000000000000000000000000..069728e250c92b09c42c21e37798500e48291dfc --- /dev/null +++ b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/test/ParticleBaseLinksCnv_p1_test.cxx @@ -0,0 +1,56 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id$ +/** + * @file ParticleEventTPCnv/test/ParticleBaseLinksCnv_p1_test.cxx + * @author scott snyder <snyder@bnl.gov> + * @date Nov, 2015 + * @brief Regression tests. + */ + +#undef NDEBUG +#include "ParticleEventTPCnv/ParticleBaseLinksCnv_p1.h" +#include "ParticleEvent/ParticleBaseLinks.h" +#include "SGTools/TestStore.h" +#include "GaudiKernel/MsgStream.h" +#include <cassert> +#include <iostream> + + +void compare (const ParticleBaseLinks& c1, + const ParticleBaseLinks& c2) +{ + assert (c1.size() == c2.size()); + for (size_t i = 0; i < c1.size(); i++) + assert (c1[i] == c2[i]); +} + + +void test1() +{ + std::cout << "test1\n"; + MsgStream log (0, "test"); + + ParticleBaseLinks trans1; + trans1.push_back (ParticleBaseLink ("pp", 10)); + trans1.push_back (ParticleBaseLink ("pp", 20)); + + ParticleBaseLinksCnv_p1 cnv; + ParticleLinks_p1 pers; + cnv.transToPers (&trans1, &pers, log); + + ParticleBaseLinks trans2; + cnv.persToTrans (&pers, &trans2, log); + + compare (trans1, trans2); +} + + +int main() +{ + SGTest::initTestStore(); + test1(); + return 0; +} diff --git a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/test/ParticleEventTPCnv.xml b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/test/ParticleEventTPCnv.xml new file mode 100644 index 0000000000000000000000000000000000000000..d0c1b5caee92eec9d8fbb7ab89c07501c322f1f5 --- /dev/null +++ b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/test/ParticleEventTPCnv.xml @@ -0,0 +1,16 @@ +<?xml version="1.0"?> +<atn> + <TEST name="ParticleEventTPCnvTest type="makecheck" suite="Examples"> + <package>PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv</package> + <timelimit>40</timelimit> + <author> Scott Snyder </author> + <mailto> snyder@bnl.gov </mailto> + <expectations> + <errorMessage>Athena exited abnormally</errorMessage> + <errorMessage>differ</errorMessage> + <warningMessage> # WARNING_MESSAGE : post.sh> ERROR</warningMessage> + <successMessage>check ok</successMessage> + <returnValue>0</returnValue> + </expectations> + </TEST> +</atn> diff --git a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/test/ParticleShallowCloneCnv_p1_test.cxx b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/test/ParticleShallowCloneCnv_p1_test.cxx new file mode 100644 index 0000000000000000000000000000000000000000..90053e56f45d6f2c5daef10d4953c41fc6d161bd --- /dev/null +++ b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/test/ParticleShallowCloneCnv_p1_test.cxx @@ -0,0 +1,83 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id$ +/** + * @file ParticleEventTPCnv/test/ParticleShallowCloneCnv_p1_test.cxx + * @author scott snyder <snyder@bnl.gov> + * @date Nov, 2015 + * @brief Regression tests. + */ + +#undef NDEBUG +#include "ParticleEventTPCnv/ParticleShallowCloneCnv_p1.h" +#include "ParticleEvent/ParticleShallowClone.h" +#include "ParticleEvent/Neutrino.h" +#include "ParticleEvent/NeutrinoContainer.h" +#include "SGTools/TestStore.h" +#include "CxxUtils/make_unique.h" +#include "GaudiKernel/MsgStream.h" +#include <cassert> +#include <iostream> + + +void compare (const Analysis::ParticleShallowClone& p1, + const Analysis::ParticleShallowClone& p2) +{ + assert (p1.px() == p2.px()); + assert (p1.py() == p2.py()); + assert (p1.pz() == p2.pz()); + assert (p1.e() == p2.e()); + + assert (p1.getMasterLink() == p2.getMasterLink()); + assert (p1.originLink() == p2.originLink()); + assert (p1.hasCharge() == p2.hasCharge()); + if (p1.hasCharge()) + assert (p1.charge() == p2.charge()); +} + + +void testit (const Analysis::ParticleShallowClone& trans1) +{ + MsgStream log (0, "test"); + + ParticleShallowCloneCnv_p1 cnv; + ParticleShallowClone_p1 pers; + cnv.transToPers (&trans1, &pers, log); + + Analysis::ParticleShallowClone trans2; + cnv.persToTrans (&pers, &trans2, log); + + compare (trans1, trans2); +} + + +void test1() +{ + std::cout << "test1\n"; + + IParticleContainer* c = new IParticleContainer; + c->push_back (CxxUtils::make_unique<Neutrino>()); + SGTest::store.record (c, "cont"); + + P4Momentum_t mom (100, 200, 300, 400); + ElementLink<VxContainer> origin ("vx", 0); + Analysis::ParticleShallowClone trans1 (MasterLink_t ("cont", 0), + &mom, + std::numeric_limits<ChargeType>::quiet_NaN(), + &origin); + testit (trans1); + + Analysis::ParticleShallowClone trans2 (trans1); + trans2.set_charge (1.5); + testit (trans2); +} + + +int main() +{ + SGTest::initTestStore(); + test1(); + return 0; +} diff --git a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/test/ParticleShallowCloneContainerCnv_p1_test.cxx b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/test/ParticleShallowCloneContainerCnv_p1_test.cxx new file mode 100644 index 0000000000000000000000000000000000000000..1ef8683f8cd177165d5a03a01bb538155868f83f --- /dev/null +++ b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/test/ParticleShallowCloneContainerCnv_p1_test.cxx @@ -0,0 +1,90 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id$ +/** + * @file ParticleEventTPCnv/test/ParticleShallowCloneContainerCnv_p1_test.cxx + * @author scott snyder <snyder@bnl.gov> + * @date Nov, 2015 + * @brief Regression tests. + */ + +#undef NDEBUG +#include "ParticleEventTPCnv/ParticleShallowCloneContainerCnv_p1.h" +#include "ParticleEvent/ParticleShallowCloneContainer.h" +#include "ParticleEvent/Neutrino.h" +#include "ParticleEvent/NeutrinoContainer.h" +#include "SGTools/TestStore.h" +#include "CxxUtils/make_unique.h" +#include "GaudiKernel/MsgStream.h" +#include <cassert> +#include <iostream> + + +void compare (const Analysis::ParticleShallowClone& p1, + const Analysis::ParticleShallowClone& p2) +{ + assert (p1.px() == p2.px()); + assert (p1.py() == p2.py()); + assert (p1.pz() == p2.pz()); + assert (p1.e() == p2.e()); + + assert (p1.getMasterLink() == p2.getMasterLink()); + assert (p1.originLink() == p2.originLink()); + assert (p1.hasCharge() == p2.hasCharge()); + if (p1.hasCharge()) + assert (p1.charge() == p2.charge()); +} + + +void compare (const ParticleShallowCloneContainer& c1, + const ParticleShallowCloneContainer& c2) +{ + assert (c1.size() == c2.size()); + for (size_t i = 0; i < c1.size(); i++) + compare (*c1[i], *c2[i]); +} + + +void test1() +{ + std::cout << "test1\n"; + + IParticleContainer* c = new IParticleContainer; + c->push_back (CxxUtils::make_unique<Neutrino>()); + SGTest::store.record (c, "cont"); + + P4Momentum_t mom (100, 200, 300, 400); + ElementLink<VxContainer> origin ("vx", 0); + ParticleShallowCloneContainer trans1; + auto p1 = CxxUtils::make_unique<Analysis::ParticleShallowClone> + (MasterLink_t ("cont", 0), + &mom, + std::numeric_limits<ChargeType>::quiet_NaN(), + &origin); + + auto p2 = CxxUtils::make_unique<Analysis::ParticleShallowClone> (*p1); + p2->set_charge (1.5); + + trans1.push_back (std::move (p1)); + trans1.push_back (std::move (p2)); + + MsgStream log (0, "test"); + ParticleShallowCloneContainerCnv_p1 cnv; + ParticleShallowCloneContainer_p1 pers; + cnv.transToPers (&trans1, &pers, log); + + ParticleShallowCloneContainer trans2; + cnv.persToTrans (&pers, &trans2, log); + + compare (trans1, trans2); +} + + +int main() +{ + SGTest::initTestStore(); + test1(); + return 0; +} diff --git a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/test/SelectedParticlesCnv_p1_test.cxx b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/test/SelectedParticlesCnv_p1_test.cxx new file mode 100644 index 0000000000000000000000000000000000000000..0082df252e56e9466337ce90612a15c5e7b93a73 --- /dev/null +++ b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/test/SelectedParticlesCnv_p1_test.cxx @@ -0,0 +1,54 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id$ +/** + * @file ParticleEventTPCnv/test/SelectedParticlesCnv_p1_test.cxx + * @author scott snyder <snyder@bnl.gov> + * @date Nov, 2015 + * @brief Regression tests. + */ + +#undef NDEBUG +#include "ParticleEventTPCnv/SelectedParticlesCnv_p1.h" +#include "ParticleEvent/SelectedParticles.h" +#include "GaudiKernel/MsgStream.h" +#include <cassert> +#include <iostream> + + +void compare (const SelectedParticles& p1, + const SelectedParticles& p2) +{ + assert (p1.AllBits() == p2.AllBits()); +} + + +void test1() +{ + std::cout << "test1\n"; + + SelectedParticles trans1; + trans1.SetBit (10); + trans1.SetBit (20); + trans1.SetBit (100); + + MsgStream log (0, "test"); + + SelectedParticlesCnv_p1 cnv; + SelectedParticles_p1 pers; + cnv.transToPers (&trans1, &pers, log); + + SelectedParticles trans2; + cnv.persToTrans (&pers, &trans2, log); + + compare (trans1, trans2); +} + + +int main() +{ + test1(); + return 0; +} diff --git a/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/test/TrackParticleAssocsCnv_p1_test.cxx b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/test/TrackParticleAssocsCnv_p1_test.cxx new file mode 100644 index 0000000000000000000000000000000000000000..e1678ed7588f820a9e8fa2b6407c710014d50dfe --- /dev/null +++ b/PhysicsAnalysis/AnalysisCommon/ParticleEventTPCnv/test/TrackParticleAssocsCnv_p1_test.cxx @@ -0,0 +1,86 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id$ +/** + * @file ParticleEventTPCnv/test/ParticleAssocsCnv_p1_test.cxx + * @author scott snyder <snyder@bnl.gov> + * @date Nov, 2015 + * @brief Regression tests. + */ + +#undef NDEBUG +#include "ParticleEventTPCnv/TrackParticleAssocsCnv_p1.h" +#include "ParticleEvent/TrackParticleAssocs.h" +#include "SGTools/TestStore.h" +#include "CxxUtils/make_unique.h" +#include "GaudiKernel/MsgStream.h" +#include <cassert> +#include <iostream> + + +void compare (const TrackParticleAssocs& a1, + const TrackParticleAssocs& a2) +{ + assert (a1.size() == a2.size()); + TrackParticleAssocs::object_iterator i1 = a1.beginObject(); + TrackParticleAssocs::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()); + TrackParticleAssocs::asso_iterator j1 = i1.second(); + TrackParticleAssocs::asso_iterator j2 = i2.second(); + for (size_t j = 0; j < i1.getNumberOfAssociations(); ++j, ++j1, ++j2) { + assert (j1.getLink() == j2.getLink()); + } + } + + assert (a1.nAssocStores() == a2.nAssocStores()); + assert (a1.assocStore ("foo").isDefault()); + assert (a2.assocStore ("foo").isDefault()); + assert (a1.assocStore ("xstore") == DataLink<TrackParticleAssocs> ("xstore")); + assert (a2.assocStore ("xstore") == DataLink<TrackParticleAssocs> ("xstore")); +} + + +void test1() +{ + std::cout << "test1\n"; + + Rec::TrackParticleContainer* tpc = new Rec::TrackParticleContainer; + for (int i=0; i < 10; i++) + tpc->push_back (CxxUtils::make_unique<Rec::TrackParticle>()); + SGTest::store.record (tpc, "tpc"); + + TrackParticleAssocs* xstore = new TrackParticleAssocs; + SGTest::store.record (xstore, "xstore"); + + TrackParticleAssocs trans1; + trans1.addAssociation (ElementLink<Rec::TrackParticleContainer> ("tpc", 3), + ElementLink<Rec::TrackParticleContainer> ("tpc", 2)); + trans1.addAssociation (ElementLink<Rec::TrackParticleContainer> ("tpc", 6), + ElementLink<Rec::TrackParticleContainer> ("tpc", 4)); + + trans1.addAssocStore (DataLink<TrackParticleAssocs> ("xstore")); + + MsgStream log (0, "test"); + + TrackParticleAssocsCnv_p1 cnv; + TrackParticleAssocs_p1 pers; + cnv.transToPers (&trans1, &pers, log); + + TrackParticleAssocs trans2; + cnv.persToTrans (&pers, &trans2, log); + + compare (trans1, trans2); +} + + +int main() +{ + SGTest::initTestStore(); + test1(); + return 0; +}