diff --git a/ForwardDetectors/LUCID/LUCID_Cnv/LUCID_EventTPCnv/share/LUCID_SimHitCnv_p1_test.ref b/ForwardDetectors/LUCID/LUCID_Cnv/LUCID_EventTPCnv/share/LUCID_SimHitCnv_p1_test.ref index a5bce3fd2565d8f458555a0c6f42d0504a848bd5..6a0927bf3bfd71b47909f10725590944a6daf6ef 100644 --- a/ForwardDetectors/LUCID/LUCID_Cnv/LUCID_EventTPCnv/share/LUCID_SimHitCnv_p1_test.ref +++ b/ForwardDetectors/LUCID/LUCID_Cnv/LUCID_EventTPCnv/share/LUCID_SimHitCnv_p1_test.ref @@ -1 +1,16 @@ +ApplicationMgr SUCCESS +==================================================================================================================================== + Welcome to ApplicationMgr (GaudiCoreSvc v4r1) + running on lxplus008.cern.ch on Fri Feb 9 16:59:26 2018 +==================================================================================================================================== +ApplicationMgr INFO Application Manager Configured successfully +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 +ClassIDSvc INFO getRegistryEntries: read 1130 CLIDRegistry entries for module ALL +ProxyProviderSvc INFO Initializing ProxyProviderSvc - package version SGComps-00-00-00 +ClassIDSvc INFO getRegistryEntries: read 869 CLIDRegistry entries for module ALL +HepMcParticleLink INFO find_hostkey: Using TruthEvent as McEventCollection key for this job diff --git a/ForwardDetectors/LUCID/LUCID_Cnv/LUCID_EventTPCnv/test/LUCID_SimHitCnv_p1_test.cxx b/ForwardDetectors/LUCID/LUCID_Cnv/LUCID_EventTPCnv/test/LUCID_SimHitCnv_p1_test.cxx index 3a7a3928f3cf7a372be0bb46958d99ef54458d5b..670e5f3bc3cec417815aa34f9939e0df048063e1 100644 --- a/ForwardDetectors/LUCID/LUCID_Cnv/LUCID_EventTPCnv/test/LUCID_SimHitCnv_p1_test.cxx +++ b/ForwardDetectors/LUCID/LUCID_Cnv/LUCID_EventTPCnv/test/LUCID_SimHitCnv_p1_test.cxx @@ -17,6 +17,21 @@ #include <cassert> #include <iostream> +#include "GeneratorObjectsTPCnv/initMcEventCollection.h" +#include "HepMC/GenEvent.h" +#include "HepMC/GenParticle.h" + + +void compare (const HepMcParticleLink& p1, + const HepMcParticleLink& p2) +{ + assert ( p1.isValid() == p2.isValid() ); + assert ( p1.barcode() == p2.barcode() ); + assert ( p1.eventIndex() == p2.eventIndex() ); + assert ( p1.cptr() == p2.cptr() ); + assert ( p1 == p2 ); +} + void compare (const LUCID_SimHit& p1, const LUCID_SimHit& p2) @@ -24,6 +39,7 @@ void compare (const LUCID_SimHit& p1, assert (p1.GetTubeID() == p2.GetTubeID()); assert (p1.GetPdgCode() == p2.GetPdgCode()); assert (p1.GetTrack() == p2.GetTrack()); + compare (p1.particleLink(), p2.particleLink()); assert (p1.particleLink() == p2.particleLink()); assert (p1.GetGenVolume() == p2.GetGenVolume()); assert (p1.GetX() == p2.GetX()); @@ -52,22 +68,34 @@ void testit (const LUCID_SimHit& trans1) } -void test1() +void test1(std::vector<HepMC::GenParticle*>& genPartVector) { std::cout << "test1\n"; + const HepMC::GenParticle *particle = genPartVector.at(0); + // Create HepMcParticleLink outside of leak check. + HepMcParticleLink dummyHMPL(particle->barcode(),0); + assert(dummyHMPL.cptr()==particle); Athena_test::Leakcheck check; - LUCID_SimHit trans1 (1, 2, 3, 4, + const HepMC::GenParticle *pGenParticle = genPartVector.at(0); + LUCID_SimHit trans1 (1, pGenParticle->pdg_id(), pGenParticle->barcode(), 4, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5); - + testit (trans1); } int main() { - test1(); + ISvcLocator* pSvcLoc = nullptr; + std::vector<HepMC::GenParticle*> genPartVector; + if (!Athena_test::initMcEventCollection(pSvcLoc,genPartVector)) { + std::cerr << "This test can not be run" << std::endl; + return 0; + } + + test1(genPartVector); return 0; } diff --git a/Generators/GeneratorObjectsTPCnv/CMakeLists.txt b/Generators/GeneratorObjectsTPCnv/CMakeLists.txt index f1bc0a4fb7de62710867e0720313fe62e109a171..14532e37407e60c863ce5004acd72ee672ae123b 100644 --- a/Generators/GeneratorObjectsTPCnv/CMakeLists.txt +++ b/Generators/GeneratorObjectsTPCnv/CMakeLists.txt @@ -26,8 +26,8 @@ atlas_add_tpcnv_library( GeneratorObjectsTPCnv src/*.cxx PUBLIC_HEADERS GeneratorObjectsTPCnv INCLUDE_DIRS ${HEPMC_INCLUDE_DIRS} - PRIVATE_INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} ${HEPMC_LIBRARIES} AthenaPoolCnvSvcLib GaudiKernel GeneratorObjects AthAllocators AthenaKernel TestTools ) + PRIVATE_INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} + LINK_LIBRARIES ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} ${HEPMC_LIBRARIES} AthenaPoolCnvSvcLib GaudiKernel GeneratorObjects AthAllocators AthenaKernel TestTools ) atlas_add_dictionary( GeneratorObjectsTPCnvDict GeneratorObjectsTPCnv/GeneratorObjectsTPCnvDict.h diff --git a/Generators/GeneratorObjectsTPCnv/GeneratorObjectsTPCnv/initMcEventCollection.h b/Generators/GeneratorObjectsTPCnv/GeneratorObjectsTPCnv/initMcEventCollection.h new file mode 100644 index 0000000000000000000000000000000000000000..0a46ab4f962abefbb68f5fdf281665dd061127d5 --- /dev/null +++ b/Generators/GeneratorObjectsTPCnv/GeneratorObjectsTPCnv/initMcEventCollection.h @@ -0,0 +1,37 @@ +/* + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef GENERATOROBJECTSTPCNV_INITMCEVENTCOLLECTION_H +# define GENERATOROBJECTSTPCNV_INITMCEVENTCOLLECTION_H +/** @file initMcEventCollection.h + * @brief minimal gaudi initialization and record an McEventCollection in StoreGate + * + **/ + +#include <string> +#include <vector> +#include "HepMC/GenParticle.h" + +#undef NDEBUG + +class ISvcLocator; +namespace HepMC { + class GenEvent; +} + +namespace Athena_test { + /** @fn bool initGaudi(ISvcLocator*& pSvcLoc, HepMC::GenParticle*& pGenParticle) + * @brief minimal gaudi initialization and record an McEventCollection in StoreGate + * @param pSvcLoc returns a pointer to the Gaudi ServiceLocator + * @param genPartVector returns a vector of pointers to GenParticle objects for use in HepMcParticleLink creation + */ + bool initMcEventCollection(ISvcLocator*& pSvcLoc, std::vector<HepMC::GenParticle*>& genPartVector); + /** @fn HepMC::GenParticle* populateGenEvent(HepMC::GenEvent & ge) + * @brief fills a HepMC::GenEvent with some dummy GenParticle and GenVertex objects + * @param pSvcLoc returns a pointer to the Gaudi ServiceLocator + * @param genPartVector returns a vector of pointers to GenParticle objects for use in HepMcParticleLink creation + */ + void populateGenEvent(HepMC::GenEvent & ge, int pdgid1, int pdgid2, std::vector<HepMC::GenParticle*>& genPartVector); +} +#endif // GENERATOROBJECTSTPCNV_INITMCEVENTCOLLECTION_H diff --git a/Generators/GeneratorObjectsTPCnv/src/initMcEventCollection.cxx b/Generators/GeneratorObjectsTPCnv/src/initMcEventCollection.cxx new file mode 100644 index 0000000000000000000000000000000000000000..63b84505e7af17d9676031dc58601ca7947585aa --- /dev/null +++ b/Generators/GeneratorObjectsTPCnv/src/initMcEventCollection.cxx @@ -0,0 +1,65 @@ +#include "GeneratorObjectsTPCnv/initMcEventCollection.h" + +// HepMC includes +#include "HepMC/GenEvent.h" +#include "HepMC/GenParticle.h" +#include "HepMC/GenVertex.h" + +// CLHEP includes +#include "CLHEP/Vector/LorentzVector.h" +#include "CLHEP/Units/SystemOfUnits.h" + +#include "GeneratorObjectsTPCnv/HepMcParticleLinkCnv_p1.h" +#include "StoreGate/WriteHandle.h" +#include "GeneratorObjects/McEventCollection.h" + +#include "TestTools/initGaudi.h" + +namespace Athena_test { + bool initMcEventCollection(ISvcLocator*& pSvcLoc, std::vector<HepMC::GenParticle*>& genPartList) + { + if (!Athena_test::initGaudi(pSvcLoc)) { + std::cerr << "This test can not be run" << std::endl; + return false; + } + // create dummy input McEventCollection with a name that + // HepMcParticleLink knows about + SG::WriteHandle<McEventCollection> inputTestDataHandle{"TruthEvent"}; + inputTestDataHandle = std::make_unique<McEventCollection>(); + // Add a dummy GenEvent + const int process_id1(20); + const int event_number1(17); + inputTestDataHandle->push_back(new HepMC::GenEvent(process_id1, event_number1)); + HepMC::GenEvent& ge1 = *(inputTestDataHandle->at(0)); + populateGenEvent(ge1,-11,11,genPartList); + populateGenEvent(ge1,-13,13,genPartList); + populateGenEvent(ge1,-11,11,genPartList); + populateGenEvent(ge1,-13,13,genPartList); + populateGenEvent(ge1,-11,11,genPartList); + populateGenEvent(ge1,22,22,genPartList); + return true; + } + + void populateGenEvent(HepMC::GenEvent & ge, int pdgid1, int pdgid2, std::vector<HepMC::GenParticle*>& genPartList) + { + CLHEP::HepLorentzVector myPos( 0.0, 0.0, 0.0, 0.0); + HepMC::GenVertex *myVertex = new HepMC::GenVertex( myPos, -1 ); + HepMC::FourVector fourMomentum1( 0.0, 0.0, 1.0, 1.0*CLHEP::TeV); + HepMC::GenParticle* inParticle1 = new HepMC::GenParticle(fourMomentum1, pdgid1, 2); + myVertex->add_particle_in(inParticle1); + HepMC::FourVector fourMomentum2( 0.0, 0.0, -1.0, 1.0*CLHEP::TeV); + HepMC::GenParticle* inParticle2 = new HepMC::GenParticle(fourMomentum2, pdgid2, 2); + myVertex->add_particle_in(inParticle2); + HepMC::FourVector fourMomentum3( 0.0, 1.0, 0.0, 1.0*CLHEP::TeV); + HepMC::GenParticle* inParticle3 = new HepMC::GenParticle(fourMomentum3, pdgid1, 1); + myVertex->add_particle_out(inParticle3); + genPartList.push_back(inParticle3); + HepMC::FourVector fourMomentum4( 0.0, -1.0, 0.0, 1.0*CLHEP::TeV); + HepMC::GenParticle* inParticle4 = new HepMC::GenParticle(fourMomentum4, pdgid2, 1); + myVertex->add_particle_out(inParticle4); + genPartList.push_back(inParticle4); + ge.add_vertex( myVertex ); + ge.set_signal_process_vertex( myVertex ); + ge.set_beam_particles(inParticle1,inParticle2); + } +} diff --git a/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/share/SiHitCnv_p1_test.ref b/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/share/SiHitCnv_p1_test.ref index a5bce3fd2565d8f458555a0c6f42d0504a848bd5..6a0927bf3bfd71b47909f10725590944a6daf6ef 100644 --- a/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/share/SiHitCnv_p1_test.ref +++ b/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/share/SiHitCnv_p1_test.ref @@ -1 +1,16 @@ +ApplicationMgr SUCCESS +==================================================================================================================================== + Welcome to ApplicationMgr (GaudiCoreSvc v4r1) + running on lxplus008.cern.ch on Fri Feb 9 16:59:26 2018 +==================================================================================================================================== +ApplicationMgr INFO Application Manager Configured successfully +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 +ClassIDSvc INFO getRegistryEntries: read 1130 CLIDRegistry entries for module ALL +ProxyProviderSvc INFO Initializing ProxyProviderSvc - package version SGComps-00-00-00 +ClassIDSvc INFO getRegistryEntries: read 869 CLIDRegistry entries for module ALL +HepMcParticleLink INFO find_hostkey: Using TruthEvent as McEventCollection key for this job diff --git a/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/share/SiHitCollectionCnv_p2_test.ref b/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/share/SiHitCollectionCnv_p2_test.ref index 627cb39ff9f6dda53feeb0de19e60c4486d4d16e..8633d8ace9b4883a00f6e29e68937582b9b5e684 100644 --- a/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/share/SiHitCollectionCnv_p2_test.ref +++ b/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/share/SiHitCollectionCnv_p2_test.ref @@ -1,4 +1,8 @@ +ApplicationMgr INFO Application Manager Configured successfully +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 -Athena::getMessageSvc: WARNING MessageSvc not found, will use std::cout -Athena::getMessageSvc: WARNING MessageSvc not found, will use std::cout -Athena::getMessageSvc: WARNING MessageSvc not found, will use std::cout +HepMcParticleLink INFO find_hostkey: Using TruthEvent as McEventCollection key for this job diff --git a/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/share/TRT_HitCnv_p1_test.ref b/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/share/TRT_HitCnv_p1_test.ref index a5bce3fd2565d8f458555a0c6f42d0504a848bd5..8633d8ace9b4883a00f6e29e68937582b9b5e684 100644 --- a/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/share/TRT_HitCnv_p1_test.ref +++ b/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/share/TRT_HitCnv_p1_test.ref @@ -1 +1,8 @@ +ApplicationMgr INFO Application Manager Configured successfully +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 +HepMcParticleLink INFO find_hostkey: Using TruthEvent as McEventCollection key for this job diff --git a/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/share/TRT_HitCollectionCnv_p2_test.ref b/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/share/TRT_HitCollectionCnv_p2_test.ref index 627cb39ff9f6dda53feeb0de19e60c4486d4d16e..8633d8ace9b4883a00f6e29e68937582b9b5e684 100644 --- a/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/share/TRT_HitCollectionCnv_p2_test.ref +++ b/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/share/TRT_HitCollectionCnv_p2_test.ref @@ -1,4 +1,8 @@ +ApplicationMgr INFO Application Manager Configured successfully +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 -Athena::getMessageSvc: WARNING MessageSvc not found, will use std::cout -Athena::getMessageSvc: WARNING MessageSvc not found, will use std::cout -Athena::getMessageSvc: WARNING MessageSvc not found, will use std::cout +HepMcParticleLink INFO find_hostkey: Using TruthEvent as McEventCollection key for this job diff --git a/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/share/TRT_HitCollectionCnv_p3_test.ref b/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/share/TRT_HitCollectionCnv_p3_test.ref index 627cb39ff9f6dda53feeb0de19e60c4486d4d16e..8633d8ace9b4883a00f6e29e68937582b9b5e684 100644 --- a/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/share/TRT_HitCollectionCnv_p3_test.ref +++ b/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/share/TRT_HitCollectionCnv_p3_test.ref @@ -1,4 +1,8 @@ +ApplicationMgr INFO Application Manager Configured successfully +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 -Athena::getMessageSvc: WARNING MessageSvc not found, will use std::cout -Athena::getMessageSvc: WARNING MessageSvc not found, will use std::cout -Athena::getMessageSvc: WARNING MessageSvc not found, will use std::cout +HepMcParticleLink INFO find_hostkey: Using TruthEvent as McEventCollection key for this job diff --git a/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/SiHitCnv_p1_test.cxx b/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/SiHitCnv_p1_test.cxx index 8a2ce7dc744e8e65078cd65848ade229dcd583cb..92e6c59857a8252ea2fa7adf49d25b106bddb4ae 100644 --- a/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/SiHitCnv_p1_test.cxx +++ b/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/SiHitCnv_p1_test.cxx @@ -17,6 +17,20 @@ #include <cassert> #include <iostream> +#include "GeneratorObjectsTPCnv/initMcEventCollection.h" +#include "HepMC/GenParticle.h" +#include "HepMC/GenEvent.h" + + +void compare (const HepMcParticleLink& p1, + const HepMcParticleLink& p2) +{ + assert ( p1.isValid() == p2.isValid() ); + assert ( p1.barcode() == p2.barcode() ); + assert ( p1.eventIndex() == p2.eventIndex() ); + assert ( p1.cptr() == p2.cptr() ); + assert ( p1 == p2 ); +} void compare (const SiHit& p1, const SiHit& p2) @@ -25,6 +39,7 @@ void compare (const SiHit& p1, assert (p1.localEndPosition() == p2.localEndPosition()); assert (p1.energyLoss() == p2.energyLoss()); assert (p1.meanTime() == p2.meanTime()); + compare(p1.particleLink(), p2.particleLink()); assert (p1.particleLink() == p2.particleLink()); assert (p1.identify() == p2.identify()); } @@ -43,24 +58,37 @@ void testit (const SiHit& trans1) } -void test1() +void test1(std::vector<HepMC::GenParticle*>& genPartVector) { std::cout << "test1\n"; + const HepMC::GenParticle *particle = genPartVector.at(0); + // Create HepMcParticleLink outside of leak check. + HepMcParticleLink dummyHMPL(particle->barcode(),0); + assert(dummyHMPL.cptr()==particle); Athena_test::Leakcheck check; + const HepMC::GenParticle *pGenParticle = genPartVector.at(0); + HepMcParticleLink trkLink(pGenParticle->barcode(),0); SiHit trans1 (HepGeom::Point3D<double> (10.5, 11.5, 12.5), HepGeom::Point3D<double> (13.5, 14.5, 15.5), 16.5, 17.5, - 18, + trkLink, 19); - + testit (trans1); } int main() { - test1(); + ISvcLocator* pSvcLoc = nullptr; + std::vector<HepMC::GenParticle*> genPartVector; + if (!Athena_test::initMcEventCollection(pSvcLoc, genPartVector)) { + std::cerr << "This test can not be run" << std::endl; + return 0; + } + + test1(genPartVector); return 0; } diff --git a/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/SiHitCollectionCnv_p2_test.cxx b/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/SiHitCollectionCnv_p2_test.cxx index da92fe90841f4c689aa778323c0c3fdf8eb35bb6..a40a88c30cc43536b92c8133c58a5088c3aac868 100644 --- a/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/SiHitCollectionCnv_p2_test.cxx +++ b/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/SiHitCollectionCnv_p2_test.cxx @@ -17,6 +17,20 @@ #include <cassert> #include <iostream> +#include "GeneratorObjectsTPCnv/initMcEventCollection.h" +#include "HepMC/GenParticle.h" +#include "HepMC/GenEvent.h" + + +void compare (const HepMcParticleLink& p1, + const HepMcParticleLink& p2) +{ + assert ( p1.isValid() == p2.isValid() ); + assert ( p1.barcode() == p2.barcode() ); + assert ( p1.eventIndex() == p2.eventIndex() ); + assert ( p1.cptr() == p2.cptr() ); + assert ( p1 == p2 ); +} void compare (const SiHit& p1, const SiHit& p2) @@ -25,6 +39,7 @@ void compare (const SiHit& p1, assert (p1.localEndPosition() == p2.localEndPosition()); assert (p1.energyLoss() == p2.energyLoss()); assert (p1.meanTime() == p2.meanTime()); + compare(p1.particleLink(), p2.particleLink()); assert (p1.particleLink() == p2.particleLink()); assert (p1.identify() == p2.identify()); } @@ -53,31 +68,44 @@ void testit (const SiHitCollection& trans1) } -void test1() +void test1(std::vector<HepMC::GenParticle*>& genPartVector) { std::cout << "test1\n"; + const HepMC::GenParticle *particle = genPartVector.at(0); + // Create HepMcParticleLink outside of leak check. + HepMcParticleLink dummyHMPL(particle->barcode(),0); + assert(dummyHMPL.cptr()==particle); // Create DVL info outside of leak check. SiHitCollection dum ("coll"); Athena_test::Leakcheck check; SiHitCollection trans1 ("coll"); for (int i=0; i < 10; i++) { + const HepMC::GenParticle* pGenParticle = genPartVector.at(i); + HepMcParticleLink trkLink(pGenParticle->barcode(),0); int o = i*100; trans1.Emplace (HepGeom::Point3D<double> (10.5+o, 11.5+o, 12.5+o), HepGeom::Point3D<double> (13.5+o, 14.5+o, 15.5+o), 16.5+o, 17.5+o, - 18+o, + trkLink, 19+o); - + } - + testit (trans1); } int main() { - test1(); + ISvcLocator* pSvcLoc = nullptr; + std::vector<HepMC::GenParticle*> genPartVector; + if (!Athena_test::initMcEventCollection(pSvcLoc, genPartVector)) { + std::cerr << "This test can not be run" << std::endl; + return 0; + } + + test1(genPartVector); return 0; } diff --git a/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/TRT_HitCnv_p1_test.cxx b/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/TRT_HitCnv_p1_test.cxx index 81c107c00e5b7414e19211b5807804509b70575a..ed12d1912c8e8a3d56e5e3f270a0e4ead9a39e42 100644 --- a/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/TRT_HitCnv_p1_test.cxx +++ b/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/TRT_HitCnv_p1_test.cxx @@ -17,11 +17,25 @@ #include <cassert> #include <iostream> +#include "GeneratorObjectsTPCnv/initMcEventCollection.h" +#include "HepMC/GenParticle.h" +#include "HepMC/GenEvent.h" + +void compare (const HepMcParticleLink& p1, + const HepMcParticleLink& p2) +{ + assert ( p1.isValid() == p2.isValid() ); + assert ( p1.barcode() == p2.barcode() ); + assert ( p1.eventIndex() == p2.eventIndex() ); + assert ( p1.cptr() == p2.cptr() ); + assert ( p1 == p2 ); +} void compare (const TRTUncompressedHit& p1, const TRTUncompressedHit& p2) { assert (p1.GetHitID() == p2.GetHitID()); + compare(p1.particleLink(), p2.particleLink()); assert (p1.particleLink() == p2.particleLink()); assert (p1.GetParticleEncoding() == p2.GetParticleEncoding()); assert (p1.GetKineticEnergy() == p2.GetKineticEnergy()); @@ -49,23 +63,36 @@ void testit (const TRTUncompressedHit& trans1) } -void test1() +void test1(std::vector<HepMC::GenParticle*>& genPartVector) { std::cout << "test1\n"; + const HepMC::GenParticle *particle = genPartVector.at(0); + // Create HepMcParticleLink outside of leak check. + HepMcParticleLink dummyHMPL(particle->barcode(),0); + assert(dummyHMPL.cptr()==particle); Athena_test::Leakcheck check; - TRTUncompressedHit trans1 (101, 102, 103, + const HepMC::GenParticle *pGenParticle = genPartVector.at(0); + HepMcParticleLink trkLink(pGenParticle->barcode(),0); + TRTUncompressedHit trans1 (101, trkLink, pGenParticle->pdg_id(), 104.5, 105.5, - 106.5, 107.5, 108.5, + 106.5, 107.5, 108.5, 109.5, 110.5, 111.5, 112.5); - + testit (trans1); } int main() { - test1(); + ISvcLocator* pSvcLoc = nullptr; + std::vector<HepMC::GenParticle*> genPartVector; + if (!Athena_test::initMcEventCollection(pSvcLoc, genPartVector)) { + std::cerr << "This test can not be run" << std::endl; + return 0; + } + + test1(genPartVector); return 0; } diff --git a/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/TRT_HitCollectionCnv_p2_test.cxx b/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/TRT_HitCollectionCnv_p2_test.cxx index f55d477a55d324ad734e1d25811900261654fc27..887a2dcfb342c74f753c1e6d7ff2380cd657f867 100644 --- a/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/TRT_HitCollectionCnv_p2_test.cxx +++ b/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/TRT_HitCollectionCnv_p2_test.cxx @@ -17,11 +17,25 @@ #include <cassert> #include <iostream> +#include "GeneratorObjectsTPCnv/initMcEventCollection.h" +#include "HepMC/GenParticle.h" +#include "HepMC/GenEvent.h" + +void compare (const HepMcParticleLink& p1, + const HepMcParticleLink& p2) +{ + assert ( p1.isValid() == p2.isValid() ); + assert ( p1.barcode() == p2.barcode() ); + assert ( p1.eventIndex() == p2.eventIndex() ); + assert ( p1.cptr() == p2.cptr() ); + assert ( p1 == p2 ); +} void compare (const TRTUncompressedHit& p1, const TRTUncompressedHit& p2) { assert (p1.GetHitID() == p2.GetHitID()); + compare(p1.particleLink(), p2.particleLink()); assert (p1.particleLink() == p2.particleLink()); assert (p1.GetParticleEncoding() == p2.GetParticleEncoding()); assert (p1.GetKineticEnergy() == p2.GetKineticEnergy()); @@ -59,9 +73,13 @@ void testit (const TRTUncompressedHitCollection& trans1) } -void test1() +void test1(std::vector<HepMC::GenParticle*>& genPartVector) { std::cout << "test1\n"; + const HepMC::GenParticle *particle = genPartVector.at(0); + // Create HepMcParticleLink outside of leak check. + HepMcParticleLink dummyHMPL(particle->barcode(),0); + assert(dummyHMPL.cptr()==particle); // Create DVL info outside of leak check. TRTUncompressedHitCollection dum ("coll"); Athena_test::Leakcheck check; @@ -69,24 +87,36 @@ void test1() TRTUncompressedHitCollection trans1 ("coll"); for (int i=0; i < 10; i++) { int o = i*100; - trans1.Emplace (101+o, 102+o, 20+o, + const HepMC::GenParticle* pGenParticle = genPartVector.at(0); + HepMcParticleLink trkLink(pGenParticle->barcode(),0); + trans1.Emplace (101+o, trkLink, pGenParticle->pdg_id(), 104.5+o, 105.5+o, - (106.5+o)/1000, (107.5+o)/1000, 108.5+o, + (106.5+o)/1000, (107.5+o)/1000, 108.5+o, (109.5+o)/1000, (110.5+o)/1000, 111.5+o, 112.5+o); } - trans1.Emplace (131, 132, 22, + // Special case for photons + const HepMC::GenParticle* pGenParticle = genPartVector.at(10); + HepMcParticleLink trkLink(pGenParticle->barcode(),0); + trans1.Emplace (131, trkLink, 22, 134.5, 135.5, 10, 3, 138.5, 3, 10, 148.5, 142.5); - + testit (trans1); } int main() { - test1(); + ISvcLocator* pSvcLoc = nullptr; + std::vector<HepMC::GenParticle*> genPartVector; + if (!Athena_test::initMcEventCollection(pSvcLoc, genPartVector)) { + std::cerr << "This test can not be run" << std::endl; + return 0; + } + + test1(genPartVector); return 0; } diff --git a/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/TRT_HitCollectionCnv_p3_test.cxx b/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/TRT_HitCollectionCnv_p3_test.cxx index d3c8b95fe60c7ff3aad57d35bc0dc5943184a39f..5319e538c7ef0ca14b371fd9ca034ffa647f4f72 100644 --- a/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/TRT_HitCollectionCnv_p3_test.cxx +++ b/InnerDetector/InDetEventCnv/InDetSimEventTPCnv/test/TRT_HitCollectionCnv_p3_test.cxx @@ -19,15 +19,29 @@ #include <iostream> #include <cmath> +#include "GeneratorObjectsTPCnv/initMcEventCollection.h" +#include "HepMC/GenParticle.h" +#include "HepMC/GenEvent.h" using Athena_test::isEqual; using std::atan2; +void compare (const HepMcParticleLink& p1, + const HepMcParticleLink& p2) +{ + assert ( p1.isValid() == p2.isValid() ); + assert ( p1.barcode() == p2.barcode() ); + assert ( p1.eventIndex() == p2.eventIndex() ); + assert ( p1.cptr() == p2.cptr() ); + assert ( p1 == p2 ); +} + void compare (const TRTUncompressedHit& p1, const TRTUncompressedHit& p2) { assert (p1.GetHitID() == p2.GetHitID()); + compare(p1.particleLink(), p2.particleLink()); assert (p1.particleLink() == p2.particleLink()); assert (p1.GetParticleEncoding() == p2.GetParticleEncoding()); assert (isEqual (p1.GetKineticEnergy(), p2.GetKineticEnergy(), 5e-4)); @@ -79,9 +93,13 @@ void testit (const TRTUncompressedHitCollection& trans1) } -void test1() +void test1(std::vector<HepMC::GenParticle*>& genPartVector) { std::cout << "test1\n"; + const HepMC::GenParticle *particle = genPartVector.at(0); + // Create HepMcParticleLink outside of leak check. + HepMcParticleLink dummyHMPL(particle->barcode(),0); + assert(dummyHMPL.cptr()==particle); // Create DVL info outside of leak check. TRTUncompressedHitCollection dum ("coll"); Athena_test::Leakcheck check; @@ -89,24 +107,36 @@ void test1() TRTUncompressedHitCollection trans1 ("coll"); for (int i=0; i < 10; i++) { int o = i*100; - trans1.Emplace (101+o, 102+o, 20+o, + const HepMC::GenParticle* pGenParticle = genPartVector.at(0); + HepMcParticleLink trkLink(pGenParticle->barcode(),0); + trans1.Emplace (101+o, trkLink, 20+o, 104.5+o, 105.5+o, - (106.5+o)/1000, (107.5+o)/1000, 108.5+o, + (106.5+o)/1000, (107.5+o)/1000, 108.5+o, (109.5+o)/1000, (110.5+o)/1000, 111.5+o, 112.5+o); } - trans1.Emplace (131, 132, 22, + // Special case for photons + const HepMC::GenParticle* pGenParticle = genPartVector.at(10); + HepMcParticleLink trkLink(pGenParticle->barcode(),0); + trans1.Emplace (131, trkLink, 22, 134.5, 135.5, 10, 3, 138.5, 3, 10, 148.5, 142.5); - + testit (trans1); } int main() { - test1(); + ISvcLocator* pSvcLoc = nullptr; + std::vector<HepMC::GenParticle*> genPartVector; + if (!Athena_test::initMcEventCollection(pSvcLoc, genPartVector)) { + std::cerr << "This test can not be run" << std::endl; + return 0; + } + + test1(genPartVector); return 0; } diff --git a/MuonSpectrometer/MuonCnv/MuonEventTPCnv/share/CscSimDataCnv_p1_test.ref b/MuonSpectrometer/MuonCnv/MuonEventTPCnv/share/CscSimDataCnv_p1_test.ref index a5bce3fd2565d8f458555a0c6f42d0504a848bd5..6a0927bf3bfd71b47909f10725590944a6daf6ef 100644 --- a/MuonSpectrometer/MuonCnv/MuonEventTPCnv/share/CscSimDataCnv_p1_test.ref +++ b/MuonSpectrometer/MuonCnv/MuonEventTPCnv/share/CscSimDataCnv_p1_test.ref @@ -1 +1,16 @@ +ApplicationMgr SUCCESS +==================================================================================================================================== + Welcome to ApplicationMgr (GaudiCoreSvc v4r1) + running on lxplus008.cern.ch on Fri Feb 9 16:59:26 2018 +==================================================================================================================================== +ApplicationMgr INFO Application Manager Configured successfully +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 +ClassIDSvc INFO getRegistryEntries: read 1130 CLIDRegistry entries for module ALL +ProxyProviderSvc INFO Initializing ProxyProviderSvc - package version SGComps-00-00-00 +ClassIDSvc INFO getRegistryEntries: read 869 CLIDRegistry entries for module ALL +HepMcParticleLink INFO find_hostkey: Using TruthEvent as McEventCollection key for this job diff --git a/MuonSpectrometer/MuonCnv/MuonEventTPCnv/share/CscSimDataCollectionCnv_p1_test.ref b/MuonSpectrometer/MuonCnv/MuonEventTPCnv/share/CscSimDataCollectionCnv_p1_test.ref index a5bce3fd2565d8f458555a0c6f42d0504a848bd5..8633d8ace9b4883a00f6e29e68937582b9b5e684 100644 --- a/MuonSpectrometer/MuonCnv/MuonEventTPCnv/share/CscSimDataCollectionCnv_p1_test.ref +++ b/MuonSpectrometer/MuonCnv/MuonEventTPCnv/share/CscSimDataCollectionCnv_p1_test.ref @@ -1 +1,8 @@ +ApplicationMgr INFO Application Manager Configured successfully +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 +HepMcParticleLink INFO find_hostkey: Using TruthEvent as McEventCollection key for this job diff --git a/MuonSpectrometer/MuonCnv/MuonEventTPCnv/share/MuonSimDataCnv_p1_test.ref b/MuonSpectrometer/MuonCnv/MuonEventTPCnv/share/MuonSimDataCnv_p1_test.ref index a5bce3fd2565d8f458555a0c6f42d0504a848bd5..8633d8ace9b4883a00f6e29e68937582b9b5e684 100644 --- a/MuonSpectrometer/MuonCnv/MuonEventTPCnv/share/MuonSimDataCnv_p1_test.ref +++ b/MuonSpectrometer/MuonCnv/MuonEventTPCnv/share/MuonSimDataCnv_p1_test.ref @@ -1 +1,8 @@ +ApplicationMgr INFO Application Manager Configured successfully +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 +HepMcParticleLink INFO find_hostkey: Using TruthEvent as McEventCollection key for this job diff --git a/MuonSpectrometer/MuonCnv/MuonEventTPCnv/share/MuonSimDataCollectionCnv_p1_test.ref b/MuonSpectrometer/MuonCnv/MuonEventTPCnv/share/MuonSimDataCollectionCnv_p1_test.ref index a5bce3fd2565d8f458555a0c6f42d0504a848bd5..8633d8ace9b4883a00f6e29e68937582b9b5e684 100644 --- a/MuonSpectrometer/MuonCnv/MuonEventTPCnv/share/MuonSimDataCollectionCnv_p1_test.ref +++ b/MuonSpectrometer/MuonCnv/MuonEventTPCnv/share/MuonSimDataCollectionCnv_p1_test.ref @@ -1 +1,8 @@ +ApplicationMgr INFO Application Manager Configured successfully +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 +HepMcParticleLink INFO find_hostkey: Using TruthEvent as McEventCollection key for this job diff --git a/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/CscSimDataCnv_p1_test.cxx b/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/CscSimDataCnv_p1_test.cxx index e1e940612fe8507701b5bc578f675f7c3c3014ad..ef454f10eb24b1fbbbbb1cb8e42d2133981cab91 100644 --- a/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/CscSimDataCnv_p1_test.cxx +++ b/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/CscSimDataCnv_p1_test.cxx @@ -17,6 +17,21 @@ #include <cassert> #include <iostream> +#include "GeneratorObjectsTPCnv/initMcEventCollection.h" +#include "HepMC/GenEvent.h" +#include "HepMC/GenParticle.h" + + +void compare (const HepMcParticleLink& p1, + const HepMcParticleLink& p2) +{ + assert ( p1.isValid() == p2.isValid() ); + assert ( p1.barcode() == p2.barcode() ); + assert ( p1.eventIndex() == p2.eventIndex() ); + assert ( p1.cptr() == p2.cptr() ); + assert ( p1 == p2 ); +} + void compare (const CscMcData& p1, const CscMcData& p2) @@ -36,6 +51,7 @@ void compare (const CscSimData& p1, const std::vector< CscSimData::Deposit >& dep2 = p2.getdeposits(); assert (dep1.size() == dep2.size()); for (size_t i = 0; i < dep1.size(); i++) { + compare (dep1[i].first, dep2[i].first); assert (dep1[i].first == dep2[i].first); compare (dep1[i].second, dep2[i].second); } @@ -55,15 +71,22 @@ void testit (const CscSimData& trans1) } -void test1() +void test1(std::vector<HepMC::GenParticle*>& genPartVector) { std::cout << "test1\n"; + const HepMC::GenParticle *particle = genPartVector.at(0); + // Create HepMcParticleLink outside of leak check. + HepMcParticleLink dummyHMPL(particle->barcode(),0); + assert(dummyHMPL.cptr()==particle); Athena_test::Leakcheck check; std::vector<CscSimData::Deposit> deps; - deps.emplace_back (123, CscMcData ( 2.5, 3.5, 4.5)); - deps.emplace_back (223, CscMcData (12.5, 13.5, 14.5)); - deps.emplace_back (323, CscMcData (22.5, 23.5, 24.5)); + HepMcParticleLink trkLink1(genPartVector.at(0)->barcode(),0); + deps.emplace_back (trkLink1, CscMcData ( 2.5, 3.5, 4.5)); + HepMcParticleLink trkLink2(genPartVector.at(1)->barcode(),0); + deps.emplace_back (trkLink2, CscMcData (12.5, 13.5, 14.5)); + HepMcParticleLink trkLink3(genPartVector.at(2)->barcode(),0); + deps.emplace_back (trkLink3, CscMcData (22.5, 23.5, 24.5)); deps[0].second.setCharge ( 5.5); deps[1].second.setCharge (15.5); deps[2].second.setCharge (25.5); @@ -74,6 +97,13 @@ void test1() int main() { - test1(); + ISvcLocator* pSvcLoc = nullptr; + std::vector<HepMC::GenParticle*> genPartVector; + if (!Athena_test::initMcEventCollection(pSvcLoc,genPartVector)) { + std::cerr << "This test can not be run" << std::endl; + return 0; + } + + test1(genPartVector); return 0; } diff --git a/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/CscSimDataCollectionCnv_p1_test.cxx b/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/CscSimDataCollectionCnv_p1_test.cxx index a1da55b118954c2af8e9dbde08f3eb4bafb9750e..1ad780392d53e1202fc3dd50eddb238df1314416 100644 --- a/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/CscSimDataCollectionCnv_p1_test.cxx +++ b/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/CscSimDataCollectionCnv_p1_test.cxx @@ -18,6 +18,22 @@ #include <iostream> +#include "GeneratorObjectsTPCnv/initMcEventCollection.h" +#include "HepMC/GenEvent.h" +#include "HepMC/GenParticle.h" + + +void compare (const HepMcParticleLink& p1, + const HepMcParticleLink& p2) +{ + assert ( p1.isValid() == p2.isValid() ); + assert ( p1.barcode() == p2.barcode() ); + assert ( p1.eventIndex() == p2.eventIndex() ); + assert ( p1.cptr() == p2.cptr() ); + assert ( p1 == p2 ); +} + + void compare (const CscMcData& p1, const CscMcData& p2) { @@ -36,6 +52,7 @@ void compare (const CscSimData& p1, const std::vector< CscSimData::Deposit >& dep2 = p2.getdeposits(); assert (dep1.size() == dep2.size()); for (size_t i = 0; i < dep1.size(); i++) { + compare (dep1[i].first, dep2[i].first); assert (dep1[i].first == dep2[i].first); compare (dep1[i].second, dep2[i].second); } @@ -68,17 +85,24 @@ void testit (const CscSimDataCollection& trans1) } -void test1() +void test1(std::vector<HepMC::GenParticle*>& genPartVector) { std::cout << "test1\n"; + const HepMC::GenParticle *particle = genPartVector.at(0); + // Create HepMcParticleLink outside of leak check. + HepMcParticleLink dummyHMPL(particle->barcode(),0); + assert(dummyHMPL.cptr()==particle); Athena_test::Leakcheck check; CscSimDataCollection trans1; for (int i=0; i < 3; i++) { std::vector<CscSimData::Deposit> deps; - deps.emplace_back (123, CscMcData ( 2.5+i, 3.5+i, 4.5+i)); - deps.emplace_back (223, CscMcData (12.5+i, 13.5+i, 14.5+i)); - deps.emplace_back (323, CscMcData (22.5+i, 23.5+i, 24.5+i)); + HepMcParticleLink trkLink1(genPartVector.at(0+(3*i))->barcode(),0); + deps.emplace_back (trkLink1, CscMcData ( 2.5, 3.5, 4.5)); + HepMcParticleLink trkLink2(genPartVector.at(1+(3*i))->barcode(),0); + deps.emplace_back (trkLink2, CscMcData (12.5, 13.5, 14.5)); + HepMcParticleLink trkLink3(genPartVector.at(2+(3*i))->barcode(),0); + deps.emplace_back (trkLink3, CscMcData (22.5, 23.5, 24.5)); deps[0].second.setCharge ( 5.5+i); deps[1].second.setCharge (15.5+i); deps[2].second.setCharge (25.5+i); @@ -90,6 +114,13 @@ void test1() int main() { - test1(); + ISvcLocator* pSvcLoc = nullptr; + std::vector<HepMC::GenParticle*> genPartVector; + if (!Athena_test::initMcEventCollection(pSvcLoc,genPartVector)) { + std::cerr << "This test can not be run" << std::endl; + return 0; + } + + test1(genPartVector); return 0; } diff --git a/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/MuonSimDataCnv_p1_test.cxx b/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/MuonSimDataCnv_p1_test.cxx index 50408770431513023ad1b0c318f281014e9f8c97..04807c11bb78918e26a2f09c8436ada3e4d81a82 100644 --- a/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/MuonSimDataCnv_p1_test.cxx +++ b/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/MuonSimDataCnv_p1_test.cxx @@ -18,6 +18,22 @@ #include <iostream> +#include "GeneratorObjectsTPCnv/initMcEventCollection.h" +#include "HepMC/GenEvent.h" +#include "HepMC/GenParticle.h" + + +void compare (const HepMcParticleLink& p1, + const HepMcParticleLink& p2) +{ + assert ( p1.isValid() == p2.isValid() ); + assert ( p1.barcode() == p2.barcode() ); + assert ( p1.eventIndex() == p2.eventIndex() ); + assert ( p1.cptr() == p2.cptr() ); + assert ( p1 == p2 ); +} + + void compare (const MuonMCData& p1, const MuonMCData& p2) { @@ -35,6 +51,7 @@ void compare (const MuonSimData& p1, const std::vector< MuonSimData::Deposit >& dep2 = p2.getdeposits(); assert (dep1.size() == dep2.size()); for (size_t i = 0; i < dep1.size(); i++) { + compare (dep1[i].first, dep2[i].first); assert (dep1[i].first == dep2[i].first); compare (dep1[i].second, dep2[i].second); } @@ -54,15 +71,22 @@ void testit (const MuonSimData& trans1) } -void test1() +void test1(std::vector<HepMC::GenParticle*>& genPartVector) { std::cout << "test1\n"; + const HepMC::GenParticle *particle = genPartVector.at(0); + // Create HepMcParticleLink outside of leak check. + HepMcParticleLink dummyHMPL(particle->barcode(),0); + assert(dummyHMPL.cptr()==particle); Athena_test::Leakcheck check; std::vector<MuonSimData::Deposit> deps; - deps.emplace_back (123, MuonMCData ( 2.5, 3.5)); - deps.emplace_back (223, MuonMCData (12.5, 13.5)); - deps.emplace_back (323, MuonMCData (22.5, 23.5)); + HepMcParticleLink trkLink1(genPartVector.at(0)->barcode(),0); + deps.emplace_back (trkLink1, MuonMCData ( 2.5, 3.5)); + HepMcParticleLink trkLink2(genPartVector.at(1)->barcode(),0); + deps.emplace_back (trkLink2, MuonMCData (12.5, 13.5)); + HepMcParticleLink trkLink3(genPartVector.at(2)->barcode(),0); + deps.emplace_back (trkLink3, MuonMCData (22.5, 23.5)); MuonSimData trans1 (deps, 4321); trans1.setPosition (Amg::Vector3D ( 4.5, 5.5, 6.5)); testit (trans1); @@ -71,6 +95,13 @@ void test1() int main() { - test1(); + ISvcLocator* pSvcLoc = nullptr; + std::vector<HepMC::GenParticle*> genPartVector; + if (!Athena_test::initMcEventCollection(pSvcLoc,genPartVector)) { + std::cerr << "This test can not be run" << std::endl; + return 0; + } + + test1(genPartVector); return 0; } diff --git a/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/MuonSimDataCollectionCnv_p1_test.cxx b/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/MuonSimDataCollectionCnv_p1_test.cxx index cf95332b617d6b4e75ddebf2b1299aaa26d8338c..7edb71ecd03d2a0f0435887e65c09c2ec353dff2 100644 --- a/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/MuonSimDataCollectionCnv_p1_test.cxx +++ b/MuonSpectrometer/MuonCnv/MuonEventTPCnv/test/MuonSimDataCollectionCnv_p1_test.cxx @@ -18,6 +18,22 @@ #include <iostream> +#include "GeneratorObjectsTPCnv/initMcEventCollection.h" +#include "HepMC/GenEvent.h" +#include "HepMC/GenParticle.h" + + +void compare (const HepMcParticleLink& p1, + const HepMcParticleLink& p2) +{ + assert ( p1.isValid() == p2.isValid() ); + assert ( p1.barcode() == p2.barcode() ); + assert ( p1.eventIndex() == p2.eventIndex() ); + assert ( p1.cptr() == p2.cptr() ); + assert ( p1 == p2 ); +} + + void compare (const MuonMCData& p1, const MuonMCData& p2) { @@ -35,6 +51,7 @@ void compare (const MuonSimData& p1, const std::vector< MuonSimData::Deposit >& dep2 = p2.getdeposits(); assert (dep1.size() == dep2.size()); for (size_t i = 0; i < dep1.size(); i++) { + compare (dep1[i].first, dep2[i].first); assert (dep1[i].first == dep2[i].first); compare (dep1[i].second, dep2[i].second); } @@ -67,17 +84,24 @@ void testit (const MuonSimDataCollection& trans1) } -void test1() +void test1(std::vector<HepMC::GenParticle*>& genPartVector) { std::cout << "test1\n"; + const HepMC::GenParticle *particle = genPartVector.at(0); + // Create HepMcParticleLink outside of leak check. + HepMcParticleLink dummyHMPL(particle->barcode(),0); + assert(dummyHMPL.cptr()==particle); Athena_test::Leakcheck check; MuonSimDataCollection trans1; for (int i=0; i < 3; i++) { std::vector<MuonSimData::Deposit> deps; - deps.emplace_back (123, MuonMCData ( 2.5+i, 3.5+i)); - deps.emplace_back (223, MuonMCData (12.5+i, 13.5+i)); - deps.emplace_back (323, MuonMCData (22.5+i, 23.5+i)); + HepMcParticleLink trkLink1(genPartVector.at(0+(3*i))->barcode(),0); + deps.emplace_back (trkLink1, MuonMCData ( 2.5+i, 3.5+i)); + HepMcParticleLink trkLink2(genPartVector.at(1+(3*i))->barcode(),0); + deps.emplace_back (trkLink2, MuonMCData (12.5+i, 13.5+i)); + HepMcParticleLink trkLink3(genPartVector.at(2+(3*i))->barcode(),0); + deps.emplace_back (trkLink3, MuonMCData (22.5+i, 23.5+i)); trans1[Identifier(1234+i)] = MuonSimData (deps, 4321+i); trans1[Identifier(1234+i)].setPosition (Amg::Vector3D(4.5+i, 5.5+i, 6.5+i)); } @@ -87,6 +111,13 @@ void test1() int main() { - test1(); + ISvcLocator* pSvcLoc = nullptr; + std::vector<HepMC::GenParticle*> genPartVector; + if (!Athena_test::initMcEventCollection(pSvcLoc,genPartVector)) { + std::cerr << "This test can not be run" << std::endl; + return 0; + } + + test1(genPartVector); return 0; } diff --git a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/share/CSCSimHitCollectionCnv_p1_test.ref b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/share/CSCSimHitCollectionCnv_p1_test.ref index 627cb39ff9f6dda53feeb0de19e60c4486d4d16e..8633d8ace9b4883a00f6e29e68937582b9b5e684 100644 --- a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/share/CSCSimHitCollectionCnv_p1_test.ref +++ b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/share/CSCSimHitCollectionCnv_p1_test.ref @@ -1,4 +1,8 @@ +ApplicationMgr INFO Application Manager Configured successfully +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 -Athena::getMessageSvc: WARNING MessageSvc not found, will use std::cout -Athena::getMessageSvc: WARNING MessageSvc not found, will use std::cout -Athena::getMessageSvc: WARNING MessageSvc not found, will use std::cout +HepMcParticleLink INFO find_hostkey: Using TruthEvent as McEventCollection key for this job diff --git a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/share/CSCSimHitCollectionCnv_p2_test.ref b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/share/CSCSimHitCollectionCnv_p2_test.ref index 627cb39ff9f6dda53feeb0de19e60c4486d4d16e..8633d8ace9b4883a00f6e29e68937582b9b5e684 100644 --- a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/share/CSCSimHitCollectionCnv_p2_test.ref +++ b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/share/CSCSimHitCollectionCnv_p2_test.ref @@ -1,4 +1,8 @@ +ApplicationMgr INFO Application Manager Configured successfully +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 -Athena::getMessageSvc: WARNING MessageSvc not found, will use std::cout -Athena::getMessageSvc: WARNING MessageSvc not found, will use std::cout -Athena::getMessageSvc: WARNING MessageSvc not found, will use std::cout +HepMcParticleLink INFO find_hostkey: Using TruthEvent as McEventCollection key for this job diff --git a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/share/GenericMuonSimHitCollectionCnv_p1_test.ref b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/share/GenericMuonSimHitCollectionCnv_p1_test.ref index 627cb39ff9f6dda53feeb0de19e60c4486d4d16e..8633d8ace9b4883a00f6e29e68937582b9b5e684 100644 --- a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/share/GenericMuonSimHitCollectionCnv_p1_test.ref +++ b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/share/GenericMuonSimHitCollectionCnv_p1_test.ref @@ -1,4 +1,8 @@ +ApplicationMgr INFO Application Manager Configured successfully +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 -Athena::getMessageSvc: WARNING MessageSvc not found, will use std::cout -Athena::getMessageSvc: WARNING MessageSvc not found, will use std::cout -Athena::getMessageSvc: WARNING MessageSvc not found, will use std::cout +HepMcParticleLink INFO find_hostkey: Using TruthEvent as McEventCollection key for this job diff --git a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/share/MDTSimHitCollectionCnv_p1_test.ref b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/share/MDTSimHitCollectionCnv_p1_test.ref index 627cb39ff9f6dda53feeb0de19e60c4486d4d16e..8633d8ace9b4883a00f6e29e68937582b9b5e684 100644 --- a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/share/MDTSimHitCollectionCnv_p1_test.ref +++ b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/share/MDTSimHitCollectionCnv_p1_test.ref @@ -1,4 +1,8 @@ +ApplicationMgr INFO Application Manager Configured successfully +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 -Athena::getMessageSvc: WARNING MessageSvc not found, will use std::cout -Athena::getMessageSvc: WARNING MessageSvc not found, will use std::cout -Athena::getMessageSvc: WARNING MessageSvc not found, will use std::cout +HepMcParticleLink INFO find_hostkey: Using TruthEvent as McEventCollection key for this job diff --git a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/share/MDTSimHitCollectionCnv_p2_test.ref b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/share/MDTSimHitCollectionCnv_p2_test.ref index 627cb39ff9f6dda53feeb0de19e60c4486d4d16e..8633d8ace9b4883a00f6e29e68937582b9b5e684 100644 --- a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/share/MDTSimHitCollectionCnv_p2_test.ref +++ b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/share/MDTSimHitCollectionCnv_p2_test.ref @@ -1,4 +1,8 @@ +ApplicationMgr INFO Application Manager Configured successfully +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 -Athena::getMessageSvc: WARNING MessageSvc not found, will use std::cout -Athena::getMessageSvc: WARNING MessageSvc not found, will use std::cout -Athena::getMessageSvc: WARNING MessageSvc not found, will use std::cout +HepMcParticleLink INFO find_hostkey: Using TruthEvent as McEventCollection key for this job diff --git a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/share/RPCSimHitCollectionCnv_p1_test.ref b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/share/RPCSimHitCollectionCnv_p1_test.ref index e6dabba2a12bcb63f4166bdd8acdad48f8a74126..cebc950724d358be04ad11c1bd5cec289bbb2681 100644 --- a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/share/RPCSimHitCollectionCnv_p1_test.ref +++ b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/share/RPCSimHitCollectionCnv_p1_test.ref @@ -1,5 +1,9 @@ +ApplicationMgr INFO Application Manager Configured successfully +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 -Athena::getMessageSvc: WARNING MessageSvc not found, will use std::cout -Athena::getMessageSvc: WARNING MessageSvc not found, will use std::cout +HepMcParticleLink INFO find_hostkey: Using TruthEvent as McEventCollection key for this job test INFO Processing -Athena::getMessageSvc: WARNING MessageSvc not found, will use std::cout diff --git a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/share/RPCSimHitCollectionCnv_p2_test.ref b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/share/RPCSimHitCollectionCnv_p2_test.ref index 627cb39ff9f6dda53feeb0de19e60c4486d4d16e..8633d8ace9b4883a00f6e29e68937582b9b5e684 100644 --- a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/share/RPCSimHitCollectionCnv_p2_test.ref +++ b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/share/RPCSimHitCollectionCnv_p2_test.ref @@ -1,4 +1,8 @@ +ApplicationMgr INFO Application Manager Configured successfully +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 -Athena::getMessageSvc: WARNING MessageSvc not found, will use std::cout -Athena::getMessageSvc: WARNING MessageSvc not found, will use std::cout -Athena::getMessageSvc: WARNING MessageSvc not found, will use std::cout +HepMcParticleLink INFO find_hostkey: Using TruthEvent as McEventCollection key for this job diff --git a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/share/TGCSimHitCollectionCnv_p1_test.ref b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/share/TGCSimHitCollectionCnv_p1_test.ref index 627cb39ff9f6dda53feeb0de19e60c4486d4d16e..8633d8ace9b4883a00f6e29e68937582b9b5e684 100644 --- a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/share/TGCSimHitCollectionCnv_p1_test.ref +++ b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/share/TGCSimHitCollectionCnv_p1_test.ref @@ -1,4 +1,8 @@ +ApplicationMgr INFO Application Manager Configured successfully +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 -Athena::getMessageSvc: WARNING MessageSvc not found, will use std::cout -Athena::getMessageSvc: WARNING MessageSvc not found, will use std::cout -Athena::getMessageSvc: WARNING MessageSvc not found, will use std::cout +HepMcParticleLink INFO find_hostkey: Using TruthEvent as McEventCollection key for this job diff --git a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/share/TGCSimHitCollectionCnv_p2_test.ref b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/share/TGCSimHitCollectionCnv_p2_test.ref index 627cb39ff9f6dda53feeb0de19e60c4486d4d16e..8633d8ace9b4883a00f6e29e68937582b9b5e684 100644 --- a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/share/TGCSimHitCollectionCnv_p2_test.ref +++ b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/share/TGCSimHitCollectionCnv_p2_test.ref @@ -1,4 +1,8 @@ +ApplicationMgr INFO Application Manager Configured successfully +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 -Athena::getMessageSvc: WARNING MessageSvc not found, will use std::cout -Athena::getMessageSvc: WARNING MessageSvc not found, will use std::cout -Athena::getMessageSvc: WARNING MessageSvc not found, will use std::cout +HepMcParticleLink INFO find_hostkey: Using TruthEvent as McEventCollection key for this job diff --git a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/share/TGCSimHitCollectionCnv_p3_test.ref b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/share/TGCSimHitCollectionCnv_p3_test.ref index 627cb39ff9f6dda53feeb0de19e60c4486d4d16e..8633d8ace9b4883a00f6e29e68937582b9b5e684 100644 --- a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/share/TGCSimHitCollectionCnv_p3_test.ref +++ b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/share/TGCSimHitCollectionCnv_p3_test.ref @@ -1,4 +1,8 @@ +ApplicationMgr INFO Application Manager Configured successfully +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 -Athena::getMessageSvc: WARNING MessageSvc not found, will use std::cout -Athena::getMessageSvc: WARNING MessageSvc not found, will use std::cout -Athena::getMessageSvc: WARNING MessageSvc not found, will use std::cout +HepMcParticleLink INFO find_hostkey: Using TruthEvent as McEventCollection key for this job diff --git a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/CSCSimHitCollectionCnv_p1_test.cxx b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/CSCSimHitCollectionCnv_p1_test.cxx index 42f6c6b6a92dfb76b10f14a93c82b4e23eb18542..e4de5037fdb22dca1b3e948fedb233afb2d99860 100644 --- a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/CSCSimHitCollectionCnv_p1_test.cxx +++ b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/CSCSimHitCollectionCnv_p1_test.cxx @@ -17,6 +17,20 @@ #include <cassert> #include <iostream> +#include "GeneratorObjectsTPCnv/initMcEventCollection.h" +#include "HepMC/GenEvent.h" +#include "HepMC/GenParticle.h" + + +void compare (const HepMcParticleLink& p1, + const HepMcParticleLink& p2) +{ + assert ( p1.isValid() == p2.isValid() ); + assert ( p1.barcode() == p2.barcode() ); + assert ( p1.eventIndex() == p2.eventIndex() ); + assert ( p1.cptr() == p2.cptr() ); + assert ( p1 == p2 ); +} void compare (const CSCSimHit& p1, const CSCSimHit& p2) @@ -27,6 +41,7 @@ void compare (const CSCSimHit& p1, assert (p1.getHitStart() == p2.getHitStart()); assert (p1.getHitEnd() == p2.getHitEnd()); assert (p1.particleID() == p2.particleID()); + compare(p1.particleLink(), p2.particleLink()); assert (p1.particleLink() == p2.particleLink()); //assert (p1.kineticEnergy() == p2.kineticEnergy()); } @@ -54,29 +69,49 @@ void testit (const CSCSimHitCollection& trans1) compare (trans1, trans2); } +int lundCode(int pdgid) { + if(pdgid==22) { return 1; } + if(pdgid==11) { return 2; } + if(pdgid==-11) { return 3; } + if(pdgid==13) { return 5; } + if(pdgid==-13) { return 6; } + return -1; +} -void test1() +void test1(std::vector<HepMC::GenParticle*>& genPartVector) { std::cout << "test1\n"; - // Get dvlinfo created outside of leak check. - CSCSimHitCollection dum1 ("coll"); + const HepMC::GenParticle *particle = genPartVector.at(0); + // Create HepMcParticleLink outside of leak check. + HepMcParticleLink dummyHMPL(particle->barcode(),0); + assert(dummyHMPL.cptr()==particle); + // Create DVL info outside of leak check. + CSCSimHitCollection dum ("coll"); Athena_test::Leakcheck check; CSCSimHitCollection trans1 ("coll"); for (int i=0; i < 10; i++) { + const HepMC::GenParticle* pGenParticle = genPartVector.at(i); trans1.Emplace (123, 10.5, 11.5, Amg::Vector3D (12.5, 13.5, 14.5), Amg::Vector3D (15.5, 16.5, 17.5), - 18, 19, 20.5 + lundCode(pGenParticle->pdg_id()), pGenParticle->barcode(), 20.5 ); } - + testit (trans1); } int main() { - test1(); + ISvcLocator* pSvcLoc = nullptr; + std::vector<HepMC::GenParticle*> genPartVector; + if (!Athena_test::initMcEventCollection(pSvcLoc,genPartVector)) { + std::cerr << "This test can not be run" << std::endl; + return 0; + } + + test1(genPartVector); return 0; } diff --git a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/CSCSimHitCollectionCnv_p2_test.cxx b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/CSCSimHitCollectionCnv_p2_test.cxx index fef91b0e1e67f0ad47c96bb356fcca8d1f24c745..1f1335c9f96763338ee9afa349ad8da4ae10a7aa 100644 --- a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/CSCSimHitCollectionCnv_p2_test.cxx +++ b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/CSCSimHitCollectionCnv_p2_test.cxx @@ -17,6 +17,20 @@ #include <cassert> #include <iostream> +#include "GeneratorObjectsTPCnv/initMcEventCollection.h" +#include "HepMC/GenEvent.h" +#include "HepMC/GenParticle.h" + + +void compare (const HepMcParticleLink& p1, + const HepMcParticleLink& p2) +{ + assert ( p1.isValid() == p2.isValid() ); + assert ( p1.barcode() == p2.barcode() ); + assert ( p1.eventIndex() == p2.eventIndex() ); + assert ( p1.cptr() == p2.cptr() ); + assert ( p1 == p2 ); +} void compare (const CSCSimHit& p1, const CSCSimHit& p2) @@ -27,6 +41,7 @@ void compare (const CSCSimHit& p1, assert (p1.getHitStart() == p2.getHitStart()); assert (p1.getHitEnd() == p2.getHitEnd()); assert (p1.particleID() == p2.particleID()); + compare(p1.particleLink(), p2.particleLink()); assert (p1.particleLink() == p2.particleLink()); assert (p1.kineticEnergy() == p2.kineticEnergy()); } @@ -54,29 +69,49 @@ void testit (const CSCSimHitCollection& trans1) compare (trans1, trans2); } +int lundCode(int pdgid) { + if(pdgid==22) { return 1; } + if(pdgid==11) { return 2; } + if(pdgid==-11) { return 3; } + if(pdgid==13) { return 5; } + if(pdgid==-13) { return 6; } + return -1; +} -void test1() +void test1(std::vector<HepMC::GenParticle*>& genPartVector) { std::cout << "test1\n"; - // Get dvlinfo created outside of leak check. - CSCSimHitCollection dum1 ("coll"); + const HepMC::GenParticle *particle = genPartVector.at(0); + // Create HepMcParticleLink outside of leak check. + HepMcParticleLink dummyHMPL(particle->barcode(),0); + assert(dummyHMPL.cptr()==particle); + // Create DVL info outside of leak check. + CSCSimHitCollection dum ("coll"); Athena_test::Leakcheck check; CSCSimHitCollection trans1 ("coll"); for (int i=0; i < 10; i++) { + const HepMC::GenParticle* pGenParticle = genPartVector.at(i); trans1.Emplace (123, 10.5, 11.5, Amg::Vector3D (12.5, 13.5, 14.5), Amg::Vector3D (15.5, 16.5, 17.5), - 18, 19, 20.5 + lundCode(pGenParticle->pdg_id()), pGenParticle->barcode(), 20.5 ); } - + testit (trans1); } int main() { - test1(); + ISvcLocator* pSvcLoc = nullptr; + std::vector<HepMC::GenParticle*> genPartVector; + if (!Athena_test::initMcEventCollection(pSvcLoc,genPartVector)) { + std::cerr << "This test can not be run" << std::endl; + return 0; + } + + test1(genPartVector); return 0; } diff --git a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/GenericMuonSimHitCollectionCnv_p1_test.cxx b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/GenericMuonSimHitCollectionCnv_p1_test.cxx index 95c947ee0ea0e6dbf144e9f4b46707c6c3a23661..cf4caba238741952dc74e42a60f02bb4298302b4 100644 --- a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/GenericMuonSimHitCollectionCnv_p1_test.cxx +++ b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/GenericMuonSimHitCollectionCnv_p1_test.cxx @@ -17,6 +17,20 @@ #include <cassert> #include <iostream> +#include "GeneratorObjectsTPCnv/initMcEventCollection.h" +#include "HepMC/GenEvent.h" +#include "HepMC/GenParticle.h" + + +void compare (const HepMcParticleLink& p1, + const HepMcParticleLink& p2) +{ + assert ( p1.isValid() == p2.isValid() ); + assert ( p1.barcode() == p2.barcode() ); + assert ( p1.eventIndex() == p2.eventIndex() ); + assert ( p1.cptr() == p2.cptr() ); + assert ( p1 == p2 ); +} void compare (const GenericMuonSimHit& p1, const GenericMuonSimHit& p2) @@ -33,6 +47,7 @@ void compare (const GenericMuonSimHit& p1, assert (p1.globalDirection() == p2.globalDirection()); assert (p1.depositEnergy() == p2.depositEnergy()); assert (p1.StepLength() == p2.StepLength()); + compare(p1.particleLink(), p2.particleLink()); assert (p1.particleLink() == p2.particleLink()); } @@ -60,32 +75,44 @@ void testit (const GenericMuonSimHitCollection& trans1) } -void test1() +void test1(std::vector<HepMC::GenParticle*> genPartVector) { std::cout << "test1\n"; - // Get dvlinfo created outside of leak check. - GenericMuonSimHitCollection dum1 ("coll"); + const HepMC::GenParticle *particle = genPartVector.at(0); + // Create HepMcParticleLink outside of leak check. + HepMcParticleLink dummyHMPL(particle->barcode(),0); + assert(dummyHMPL.cptr()==particle); + // Create DVL info outside of leak check. + GenericMuonSimHitCollection dum ("coll"); Athena_test::Leakcheck check; GenericMuonSimHitCollection trans1 ("coll"); for (int i=0; i < 10; i++) { + const HepMC::GenParticle* pGenParticle = genPartVector.at(i); trans1.Emplace (123, 10.5, 11.5, Amg::Vector3D (12.5, 13.5, 14.5), Amg::Vector3D (15.5, 16.5, 17.5), Amg::Vector3D (18.5, 19.5, 20.5), Amg::Vector3D (21.5, 22.5, 23.5), - 24, 25.5, + pGenParticle->pdg_id(), 25.5, Amg::Vector3D (26.5, 27.5, 28.5), - 29.5, 30.5, 31 + 29.5, 30.5, pGenParticle->barcode() ); } - + testit (trans1); } int main() { - test1(); + ISvcLocator* pSvcLoc = nullptr; + std::vector<HepMC::GenParticle*> genPartVector; + if (!Athena_test::initMcEventCollection(pSvcLoc,genPartVector)) { + std::cerr << "This test can not be run" << std::endl; + return 0; + } + + test1(genPartVector); return 0; } diff --git a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/MDTSimHitCollectionCnv_p1_test.cxx b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/MDTSimHitCollectionCnv_p1_test.cxx index 7b2ac0f195943ed05d5318fcbd528ab952c68a75..ad50eee492da9afb5f83eccbc0462f97640bc0bb 100644 --- a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/MDTSimHitCollectionCnv_p1_test.cxx +++ b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/MDTSimHitCollectionCnv_p1_test.cxx @@ -17,6 +17,20 @@ #include <cassert> #include <iostream> +#include "GeneratorObjectsTPCnv/initMcEventCollection.h" +#include "HepMC/GenEvent.h" +#include "HepMC/GenParticle.h" + + +void compare (const HepMcParticleLink& p1, + const HepMcParticleLink& p2) +{ + assert ( p1.isValid() == p2.isValid() ); + assert ( p1.barcode() == p2.barcode() ); + assert ( p1.eventIndex() == p2.eventIndex() ); + assert ( p1.cptr() == p2.cptr() ); + assert ( p1 == p2 ); +} void compare (const MDTSimHit& p1, const MDTSimHit& p2) @@ -25,6 +39,7 @@ void compare (const MDTSimHit& p1, assert (p1.globalTime() == p2.globalTime()); assert (p1.driftRadius() == p2.driftRadius()); assert (p1.localPosition() == p2.localPosition()); + compare(p1.particleLink(), p2.particleLink()); assert (p1.particleLink() == p2.particleLink()); //assert (p1.stepLength() == p2.stepLength()); //assert (p1.energyDeposit() == p2.energyDeposit()); @@ -56,27 +71,39 @@ void testit (const MDTSimHitCollection& trans1) } -void test1() +void test1(std::vector<HepMC::GenParticle*> genPartVector) { std::cout << "test1\n"; - // Get dvlinfo created outside of leak check. - MDTSimHitCollection dum1 ("coll"); + const HepMC::GenParticle *particle = genPartVector.at(0); + // Create HepMcParticleLink outside of leak check. + HepMcParticleLink dummyHMPL(particle->barcode(),0); + assert(dummyHMPL.cptr()==particle); + // Create DVL info outside of leak check. + MDTSimHitCollection dum ("coll"); Athena_test::Leakcheck check; MDTSimHitCollection trans1 ("coll"); for (int i=0; i < 10; i++) { + const HepMC::GenParticle* pGenParticle = genPartVector.at(i); trans1.Emplace (123, 10.5, 11.5, Amg::Vector3D (12.5, 13.5, 14.5), - 18, 19.5, 20.5, 21, 22.5 + pGenParticle->barcode(), 19.5, 20.5, pGenParticle->pdg_id(), 22.5 ); } - + testit (trans1); } int main() { - test1(); + ISvcLocator* pSvcLoc = nullptr; + std::vector<HepMC::GenParticle*> genPartVector; + if (!Athena_test::initMcEventCollection(pSvcLoc,genPartVector)) { + std::cerr << "This test can not be run" << std::endl; + return 0; + } + + test1(genPartVector); return 0; } diff --git a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/MDTSimHitCollectionCnv_p2_test.cxx b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/MDTSimHitCollectionCnv_p2_test.cxx index af128bce840aacaf62ea8239abdca9a1baf6507e..bfaf4a7bb5ea2355538c2854ce50d15d6667c57e 100644 --- a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/MDTSimHitCollectionCnv_p2_test.cxx +++ b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/MDTSimHitCollectionCnv_p2_test.cxx @@ -17,6 +17,20 @@ #include <cassert> #include <iostream> +#include "GeneratorObjectsTPCnv/initMcEventCollection.h" +#include "HepMC/GenEvent.h" +#include "HepMC/GenParticle.h" + + +void compare (const HepMcParticleLink& p1, + const HepMcParticleLink& p2) +{ + assert ( p1.isValid() == p2.isValid() ); + assert ( p1.barcode() == p2.barcode() ); + assert ( p1.eventIndex() == p2.eventIndex() ); + assert ( p1.cptr() == p2.cptr() ); + assert ( p1 == p2 ); +} void compare (const MDTSimHit& p1, const MDTSimHit& p2) @@ -25,6 +39,7 @@ void compare (const MDTSimHit& p1, assert (p1.globalTime() == p2.globalTime()); assert (p1.driftRadius() == p2.driftRadius()); assert (p1.localPosition() == p2.localPosition()); + compare(p1.particleLink(), p2.particleLink()); assert (p1.particleLink() == p2.particleLink()); assert (p1.stepLength() == p2.stepLength()); assert (p1.energyDeposit() == p2.energyDeposit()); @@ -56,27 +71,39 @@ void testit (const MDTSimHitCollection& trans1) } -void test1() +void test1(std::vector<HepMC::GenParticle*> genPartVector) { std::cout << "test1\n"; - // Get dvlinfo created outside of leak check. - MDTSimHitCollection dum1 ("coll"); + const HepMC::GenParticle *particle = genPartVector.at(0); + // Create HepMcParticleLink outside of leak check. + HepMcParticleLink dummyHMPL(particle->barcode(),0); + assert(dummyHMPL.cptr()==particle); + // Create DVL info outside of leak check. + MDTSimHitCollection dum ("coll"); Athena_test::Leakcheck check; MDTSimHitCollection trans1 ("coll"); for (int i=0; i < 10; i++) { + const HepMC::GenParticle* pGenParticle = genPartVector.at(i); trans1.Emplace (123, 10.5, 11.5, Amg::Vector3D (12.5, 13.5, 14.5), - 18, 19.5, 20.5, 21, 22.5 + pGenParticle->barcode(), 19.5, 20.5, pGenParticle->pdg_id(), 22.5 ); } - + testit (trans1); } int main() { - test1(); + ISvcLocator* pSvcLoc = nullptr; + std::vector<HepMC::GenParticle*> genPartVector; + if (!Athena_test::initMcEventCollection(pSvcLoc,genPartVector)) { + std::cerr << "This test can not be run" << std::endl; + return 0; + } + + test1(genPartVector); return 0; } diff --git a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/RPCSimHitCollectionCnv_p1_test.cxx b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/RPCSimHitCollectionCnv_p1_test.cxx index 19ddf41fd5e3fe53dd643c7b35f74559e6ead98d..d05cc1177bec20d50d0e943300a4ecc41b65084a 100644 --- a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/RPCSimHitCollectionCnv_p1_test.cxx +++ b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/RPCSimHitCollectionCnv_p1_test.cxx @@ -17,6 +17,20 @@ #include <cassert> #include <iostream> +#include "GeneratorObjectsTPCnv/initMcEventCollection.h" +#include "HepMC/GenEvent.h" +#include "HepMC/GenParticle.h" + + +void compare (const HepMcParticleLink& p1, + const HepMcParticleLink& p2) +{ + assert ( p1.isValid() == p2.isValid() ); + assert ( p1.barcode() == p2.barcode() ); + assert ( p1.eventIndex() == p2.eventIndex() ); + assert ( p1.cptr() == p2.cptr() ); + assert ( p1 == p2 ); +} void compare (const RPCSimHit& p1, const RPCSimHit& p2) @@ -24,6 +38,7 @@ void compare (const RPCSimHit& p1, assert (p1.RPCid() == p2.RPCid()); assert (p1.globalTime() == p2.globalTime()); assert (p1.localPosition() == p2.localPosition()); + compare(p1.particleLink(), p2.particleLink()); assert (p1.particleLink() == p2.particleLink()); //assert (p1.postLocalPosition() == p2.postLocalPosition()); //assert (p1.energyDeposit() == p2.energyDeposit()); @@ -56,28 +71,40 @@ void testit (const RPCSimHitCollection& trans1) } -void test1() +void test1(std::vector<HepMC::GenParticle*> genPartVector) { std::cout << "test1\n"; - // Get dvlinfo created outside of leak check. - RPCSimHitCollection dum1 ("coll"); + const HepMC::GenParticle *particle = genPartVector.at(0); + // Create HepMcParticleLink outside of leak check. + HepMcParticleLink dummyHMPL(particle->barcode(),0); + assert(dummyHMPL.cptr()==particle); + // Create DVL info outside of leak check. + RPCSimHitCollection dum ("coll"); Athena_test::Leakcheck check; RPCSimHitCollection trans1 ("coll"); for (int i=0; i < 10; i++) { + const HepMC::GenParticle* pGenParticle = genPartVector.at(i); trans1.Emplace (123, 10.5, Amg::Vector3D (12.5, 13.5, 14.5), - 15, + pGenParticle->barcode(), Amg::Vector3D (16.5, 17.5, 18.5), - 19.5, 20.5, 21, 22.5); + 19.5, 20.5, pGenParticle->pdg_id(), 22.5); } - + testit (trans1); } int main() { - test1(); + ISvcLocator* pSvcLoc = nullptr; + std::vector<HepMC::GenParticle*> genPartVector; + if (!Athena_test::initMcEventCollection(pSvcLoc,genPartVector)) { + std::cerr << "This test can not be run" << std::endl; + return 0; + } + + test1(genPartVector); return 0; } diff --git a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/RPCSimHitCollectionCnv_p2_test.cxx b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/RPCSimHitCollectionCnv_p2_test.cxx index 0033c7173dcc718f999d26cc3890df5cd9fb6ed1..635f225b10113229570f2b1b93f4cadc644a9ef8 100644 --- a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/RPCSimHitCollectionCnv_p2_test.cxx +++ b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/RPCSimHitCollectionCnv_p2_test.cxx @@ -17,6 +17,20 @@ #include <cassert> #include <iostream> +#include "GeneratorObjectsTPCnv/initMcEventCollection.h" +#include "HepMC/GenEvent.h" +#include "HepMC/GenParticle.h" + + +void compare (const HepMcParticleLink& p1, + const HepMcParticleLink& p2) +{ + assert ( p1.isValid() == p2.isValid() ); + assert ( p1.barcode() == p2.barcode() ); + assert ( p1.eventIndex() == p2.eventIndex() ); + assert ( p1.cptr() == p2.cptr() ); + assert ( p1 == p2 ); +} void compare (const RPCSimHit& p1, const RPCSimHit& p2) @@ -24,6 +38,7 @@ void compare (const RPCSimHit& p1, assert (p1.RPCid() == p2.RPCid()); assert (p1.globalTime() == p2.globalTime()); assert (p1.localPosition() == p2.localPosition()); + compare(p1.particleLink(), p2.particleLink()); assert (p1.particleLink() == p2.particleLink()); assert (p1.postLocalPosition() == p2.postLocalPosition()); assert (p1.energyDeposit() == p2.energyDeposit()); @@ -56,28 +71,40 @@ void testit (const RPCSimHitCollection& trans1) } -void test1() +void test1(std::vector<HepMC::GenParticle*> genPartVector) { std::cout << "test1\n"; - // Get dvlinfo created outside of leak check. - RPCSimHitCollection dum1 ("coll"); + const HepMC::GenParticle *particle = genPartVector.at(0); + // Create HepMcParticleLink outside of leak check. + HepMcParticleLink dummyHMPL(particle->barcode(),0); + assert(dummyHMPL.cptr()==particle); + // Create DVL info outside of leak check. + RPCSimHitCollection dum ("coll"); Athena_test::Leakcheck check; RPCSimHitCollection trans1 ("coll"); for (int i=0; i < 10; i++) { + const HepMC::GenParticle* pGenParticle = genPartVector.at(i); trans1.Emplace (123, 10.5, Amg::Vector3D (12.5, 13.5, 14.5), - 15, + pGenParticle->barcode(), Amg::Vector3D (16.5, 17.5, 18.5), - 19.5, 20.5, 21, 22.5); + 19.5, 20.5, pGenParticle->pdg_id(), 22.5); } - + testit (trans1); } int main() { - test1(); + ISvcLocator* pSvcLoc = nullptr; + std::vector<HepMC::GenParticle*> genPartVector; + if (!Athena_test::initMcEventCollection(pSvcLoc,genPartVector)) { + std::cerr << "This test can not be run" << std::endl; + return 0; + } + + test1(genPartVector); return 0; } diff --git a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/TGCSimHitCollectionCnv_p1_test.cxx b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/TGCSimHitCollectionCnv_p1_test.cxx index 8fb97abf5286d1c00abd794192c8b0dd8677504f..55adc9176a6796cad831491907d66c86806d24fa 100644 --- a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/TGCSimHitCollectionCnv_p1_test.cxx +++ b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/TGCSimHitCollectionCnv_p1_test.cxx @@ -17,6 +17,20 @@ #include <cassert> #include <iostream> +#include "GeneratorObjectsTPCnv/initMcEventCollection.h" +#include "HepMC/GenEvent.h" +#include "HepMC/GenParticle.h" + + +void compare (const HepMcParticleLink& p1, + const HepMcParticleLink& p2) +{ + assert ( p1.isValid() == p2.isValid() ); + assert ( p1.barcode() == p2.barcode() ); + assert ( p1.eventIndex() == p2.eventIndex() ); + assert ( p1.cptr() == p2.cptr() ); + assert ( p1 == p2 ); +} void compare (const TGCSimHit& p1, const TGCSimHit& p2) @@ -25,6 +39,7 @@ void compare (const TGCSimHit& p1, assert (p1.globalTime() == p2.globalTime()); assert (p1.localPosition() == p2.localPosition()); assert (p1.localDireCos() == p2.localDireCos()); + compare(p1.particleLink(), p2.particleLink()); assert (p1.particleLink() == p2.particleLink()); //assert (p1.energyDeposit() == p2.energyDeposit()); //assert (p1.stepLength() == p2.stepLength()); @@ -56,27 +71,39 @@ void testit (const TGCSimHitCollection& trans1) } -void test1() +void test1(std::vector<HepMC::GenParticle*> genPartVector) { std::cout << "test1\n"; - // Get dvlinfo created outside of leak check. - TGCSimHitCollection dum1 ("coll"); + const HepMC::GenParticle *particle = genPartVector.at(0); + // Create HepMcParticleLink outside of leak check. + HepMcParticleLink dummyHMPL(particle->barcode(),0); + assert(dummyHMPL.cptr()==particle); + // Create DVL info outside of leak check. + TGCSimHitCollection dum ("coll"); Athena_test::Leakcheck check; TGCSimHitCollection trans1 ("coll"); for (int i=0; i < 10; i++) { + const HepMC::GenParticle* pGenParticle = genPartVector.at(i); trans1.Emplace (123, 10.5, Amg::Vector3D (12.5, 13.5, 14.5), Amg::Vector3D (16.5, 17.5, 18.5), - 19, 20.5, 21.5, 22, 23.5); + pGenParticle->barcode(), 20.5, 21.5, pGenParticle->pdg_id(), 23.5); } - + testit (trans1); } int main() { - test1(); + ISvcLocator* pSvcLoc = nullptr; + std::vector<HepMC::GenParticle*> genPartVector; + if (!Athena_test::initMcEventCollection(pSvcLoc,genPartVector)) { + std::cerr << "This test can not be run" << std::endl; + return 0; + } + + test1(genPartVector); return 0; } diff --git a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/TGCSimHitCollectionCnv_p2_test.cxx b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/TGCSimHitCollectionCnv_p2_test.cxx index 3a79f5ec8eba665ba4563c0a880e6f63eed48823..87253ad37e927fff1d507956befe9b56fadfefca 100644 --- a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/TGCSimHitCollectionCnv_p2_test.cxx +++ b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/TGCSimHitCollectionCnv_p2_test.cxx @@ -17,6 +17,20 @@ #include <cassert> #include <iostream> +#include "GeneratorObjectsTPCnv/initMcEventCollection.h" +#include "HepMC/GenEvent.h" +#include "HepMC/GenParticle.h" + + +void compare (const HepMcParticleLink& p1, + const HepMcParticleLink& p2) +{ + assert ( p1.isValid() == p2.isValid() ); + assert ( p1.barcode() == p2.barcode() ); + assert ( p1.eventIndex() == p2.eventIndex() ); + assert ( p1.cptr() == p2.cptr() ); + assert ( p1 == p2 ); +} void compare (const TGCSimHit& p1, const TGCSimHit& p2) @@ -25,6 +39,7 @@ void compare (const TGCSimHit& p1, assert (p1.globalTime() == p2.globalTime()); assert (p1.localPosition() == p2.localPosition()); assert (p1.localDireCos() == p2.localDireCos()); + compare(p1.particleLink(), p2.particleLink()); assert (p1.particleLink() == p2.particleLink()); assert (p1.energyDeposit() == p2.energyDeposit()); assert (p1.stepLength() == p2.stepLength()); @@ -56,27 +71,39 @@ void testit (const TGCSimHitCollection& trans1) } -void test1() +void test1(std::vector<HepMC::GenParticle*> genPartVector) { std::cout << "test1\n"; - // Get dvlinfo created outside of leak check. - TGCSimHitCollection dum1 ("coll"); + const HepMC::GenParticle *particle = genPartVector.at(0); + // Create HepMcParticleLink outside of leak check. + HepMcParticleLink dummyHMPL(particle->barcode(),0); + assert(dummyHMPL.cptr()==particle); + // Create DVL info outside of leak check. + TGCSimHitCollection dum ("coll"); Athena_test::Leakcheck check; TGCSimHitCollection trans1 ("coll"); for (int i=0; i < 10; i++) { + const HepMC::GenParticle* pGenParticle = genPartVector.at(i); trans1.Emplace (123, 10.5, Amg::Vector3D (12.5, 13.5, 14.5), Amg::Vector3D (16.5, 17.5, 18.5), - 19, 20.5, 21.5, 22, 23.5); + pGenParticle->barcode(), 20.5, 21.5, pGenParticle->pdg_id(), 23.5); } - + testit (trans1); } int main() { - test1(); + ISvcLocator* pSvcLoc = nullptr; + std::vector<HepMC::GenParticle*> genPartVector; + if (!Athena_test::initMcEventCollection(pSvcLoc,genPartVector)) { + std::cerr << "This test can not be run" << std::endl; + return 0; + } + + test1(genPartVector); return 0; } diff --git a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/TGCSimHitCollectionCnv_p3_test.cxx b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/TGCSimHitCollectionCnv_p3_test.cxx index e6351628e30da5b67678206cc12fe0183eab317f..e7170e041446284549c5da2dd9ace6b85a99d817 100644 --- a/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/TGCSimHitCollectionCnv_p3_test.cxx +++ b/MuonSpectrometer/MuonCnv/MuonSimEventTPCnv/test/TGCSimHitCollectionCnv_p3_test.cxx @@ -17,6 +17,20 @@ #include <cassert> #include <iostream> +#include "GeneratorObjectsTPCnv/initMcEventCollection.h" +#include "HepMC/GenEvent.h" +#include "HepMC/GenParticle.h" + + +void compare (const HepMcParticleLink& p1, + const HepMcParticleLink& p2) +{ + assert ( p1.isValid() == p2.isValid() ); + assert ( p1.barcode() == p2.barcode() ); + assert ( p1.eventIndex() == p2.eventIndex() ); + assert ( p1.cptr() == p2.cptr() ); + assert ( p1 == p2 ); +} void compare (const TGCSimHit& p1, const TGCSimHit& p2) @@ -25,6 +39,7 @@ void compare (const TGCSimHit& p1, assert (p1.globalTime() == p2.globalTime()); assert (p1.localPosition() == p2.localPosition()); assert (p1.localDireCos() == p2.localDireCos()); + compare(p1.particleLink(), p2.particleLink()); assert (p1.particleLink() == p2.particleLink()); assert (p1.energyDeposit() == p2.energyDeposit()); assert (p1.stepLength() == p2.stepLength()); @@ -56,27 +71,39 @@ void testit (const TGCSimHitCollection& trans1) } -void test1() +void test1(std::vector<HepMC::GenParticle*>& genPartVector) { std::cout << "test1\n"; - // Get dvlinfo created outside of leak check. - TGCSimHitCollection dum1 ("coll"); + const HepMC::GenParticle *particle = genPartVector.at(0); + // Create HepMcParticleLink outside of leak check. + HepMcParticleLink dummyHMPL(particle->barcode(),0); + assert(dummyHMPL.cptr()==particle); + // Create DVL info outside of leak check. + TGCSimHitCollection dum ("coll"); Athena_test::Leakcheck check; TGCSimHitCollection trans1 ("coll"); for (int i=0; i < 10; i++) { + const HepMC::GenParticle* pGenParticle = genPartVector.at(i); trans1.Emplace (123, 10.5, Amg::Vector3D (12.5, 13.5, 14.5), Amg::Vector3D (16.5, 17.5, 18.5), - 19, 20.5, 21.5, 22, 23.5); + pGenParticle->barcode(), 20.5, 21.5, pGenParticle->pdg_id(), 23.5); } - + testit (trans1); } int main() { - test1(); + ISvcLocator* pSvcLoc = nullptr; + std::vector<HepMC::GenParticle*> genPartVector; + if (!Athena_test::initMcEventCollection(pSvcLoc,genPartVector)) { + std::cerr << "This test can not be run" << std::endl; + return 0; + } + + test1(genPartVector); return 0; }