Commit 60333faf authored by Elmar Ritsch's avatar Elmar Ritsch Committed by Graeme Stewart
Browse files

Fix previously introduced unit tests in cmt/requirements file for backwards...

Fix previously introduced unit tests in cmt/requirements file for backwards compatibility. ATLASSIM-2749 (ISF_Algorithms-00-03-04)

	* Fix previously introduced unit tests in cmt/requirements file for
	backwards compatibility. ATLASSIM-2749
	* tag as ISF_Algorithms-00-03-04

2016-05-11  Elmar Ritsch  <Elmar.Ritsch@cern.ch>
	* Remove MiniFCALHits from input/output collections in CollectionMerger as
	Geant4 is currently the only simulator generating those hits. ATLASSIM-2749
	* Add integration test for CollectionMerger. ATLASSIM-2749
	* Update cmt/requirements file to build and execute CollectionMerger tests.
	* tag as ISF_Algorithms-00-03-03

2016-05-10  Elmar Ritsch  <Elmar.Ritsch@cern.ch>
	* Add tests for CollectionMerger and move templated member functions from
	CollectionMerger.cxx to CollectionMerger.h file to allow for arbitrary
	template type arguments. ATLASSIM-2749
	* tag as ISF_Algorithms-00-03-02

2016-05-03  Elmar Ritsch  <Elmar.Ritsch@cern.ch>
	* Update cmt/requirements file with new depedencies that were
	previously added to CMakeLists.txt. ATLASSIM-2749
...
(Long ChangeLog diff - truncated)
parent d967408c
......@@ -11,9 +11,14 @@ atlas_depends_on_subdirs( PUBLIC
PRIVATE
Control/AthenaBaseComps
DetectorDescription/AtlasDetDescr
InnerDetector/InDetSimEvent
LArCalorimeter/LArSimEvent
TileCalorimeter/TileSimEvent
MuonSpectrometer/MuonSimEvent
Simulation/ISF/ISF_Core/ISF_Event
Simulation/ISF/ISF_Core/ISF_Interfaces
Tools/PmbCxxUtils )
Tools/PmbCxxUtils
AtlasTest/TestTools )
# External dependencies:
find_package( Boost COMPONENTS filesystem thread system )
......@@ -24,8 +29,22 @@ atlas_add_component( ISF_Algorithms
src/*.cxx
src/components/*.cxx
INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS}
LINK_LIBRARIES ${Boost_LIBRARIES} ${ROOT_LIBRARIES} GaudiKernel AthenaBaseComps AtlasDetDescr ISF_Event ISF_Interfaces PmbCxxUtils )
LINK_LIBRARIES ${Boost_LIBRARIES} ${ROOT_LIBRARIES} GaudiKernel AthenaBaseComps AtlasDetDescr ISF_Event ISF_Interfaces PmbCxxUtils InDetSimEvent LArSimEvent TileSimEvent MuonSimEvent )
atlas_add_library( ISF_AlgorithmsLib
src/*.cxx
PUBLIC_HEADERS ISF_Algorithms
INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS}
LINK_LIBRARIES ${Boost_LIBRARIES} ${ROOT_LIBRARIES} GaudiKernel AthenaBaseComps AtlasDetDescr ISF_Event ISF_Interfaces PmbCxxUtils InDetSimEvent LArSimEvent TileSimEvent MuonSimEvent )
atlas_add_test( CollectionMerger_test
SOURCES test/CollectionMerger_test.cxx
LINK_LIBRARIES TestTools ISF_AlgorithmsLib
ENVIRONMENT "JOBOPTSEARCHPATH=${CMAKE_CURRENT_SOURCE_DIR}/share" )
# Install files from the package:
atlas_install_headers( ISF_Algorithms )
# Install files from the package:
atlas_install_python_modules( python/*.py )
atlas_install_joboptions( share/*.py )
......@@ -20,11 +20,25 @@ use AtlasROOT AtlasROOT-* External
use ISF_Event ISF_Event-* Simulation/ISF/ISF_Core
use ISF_Interfaces ISF_Interfaces-* Simulation/ISF/ISF_Core
use PmbCxxUtils PmbCxxUtils-* Tools
use InDetSimEvent InDetSimEvent-* InnerDetector
use LArSimEvent LArSimEvent-* LArCalorimeter
use TileSimEvent TileSimEvent-* TileCalorimeter
use MuonSimEvent MuonSimEvent-* MuonSpectrometer
use CxxUtils CxxUtils-* Control
use StoreGate StoreGate-* Control
public
library ISF_Algorithms *.cxx components/*.cxx
apply_pattern component_library
apply_pattern declare_joboptions files="*.py"
apply_pattern declare_python_modules files="*.py"
private
use TestTools TestTools-* AtlasTest
apply_pattern UnitTest_run unit_test=CollectionMerger extra_sources=../src/CollectionMerger.cxx
# activate the following lines to compile this package with debug symbols
#private
#macro cppdebugflags '$(cppdebugflags_s)'
......
# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
def getCollectionMerger(name="ISF_CollectionMerger", **kwargs):
kwargs.setdefault( "InputBCMHits", [ ] )
kwargs.setdefault( "InputBLMHits", [ ] )
kwargs.setdefault( "InputPixelHits", [ ] )
kwargs.setdefault( "InputSCTHits", [ ] )
kwargs.setdefault( "InputTRTUncompressedHits", [ ] )
kwargs.setdefault( "InputLArEMBHits", [ ] )
kwargs.setdefault( "InputLArEMECHits", [ ] )
kwargs.setdefault( "InputLArFCALHits", [ ] )
kwargs.setdefault( "InputLArHECHits", [ ] )
kwargs.setdefault( "InputTileHits", [ ] )
kwargs.setdefault( "InputMBTSHits", [ ] )
kwargs.setdefault( "InputCSCHits", [ ] )
kwargs.setdefault( "InputMDTHits", [ ] )
kwargs.setdefault( "InputRPCHits", [ ] )
kwargs.setdefault( "InputTGCHits", [ ] )
kwargs.setdefault( "OutputBCMHits", "BCMHits" )
kwargs.setdefault( "OutputBLMHits", "BLMHits" )
kwargs.setdefault( "OutputPixelHits", "PixelHits" )
kwargs.setdefault( "OutputSCTHits", "SCT_Hits" )
kwargs.setdefault( "OutputTRTUncompressedHits", "TRTUncompressedHits" )
kwargs.setdefault( "OutputLArEMBHits", "LArHitEMB" )
kwargs.setdefault( "OutputLArEMECHits", "LArHitEMEC" )
kwargs.setdefault( "OutputLArFCALHits", "LArHitFCAL" )
kwargs.setdefault( "OutputLArHECHits", "LArHitHEC" )
kwargs.setdefault( "OutputTileHits", "MBTSHits" )
kwargs.setdefault( "OutputMBTSHits", "TileHitVec" )
kwargs.setdefault( "OutputCSCHits", "CSC_Hits" )
kwargs.setdefault( "OutputMDTHits", "MDT_Hits" )
kwargs.setdefault( "OutputRPCHits", "RPC_Hits" )
kwargs.setdefault( "OutputTGCHits", "TGC_Hits" )
from ISF_Algorithms.ISF_AlgorithmsConf import ISF__CollectionMerger
collectionMerger = ISF__CollectionMerger(name, **kwargs)
return collectionMerger
# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
"""
Configuration database for ISF_Algorithms package
"""
from AthenaCommon.CfgGetter import addAlgorithm
# Common tools, services and algorithms used by jobs
addAlgorithm("ISF_Algorithms.ISF_AlgorithmsConfig.getCollectionMerger", "ISF_CollectionMerger")
CollectionMergerIntegrationTestWithData.InputPixelHits = ["inputPixelCollectionIntegrationTestA",
"inputPixelCollectionIntegrationTestC",
"inputPixelCollectionIntegrationTestB"];
CollectionMergerIntegrationTestWithData.OutputPixelHits = "outputPixelCollectionIntegrationTest";
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
///////////////////////////////////////////////////////////////////
// CollectionMerger.cxx, (c) ATLAS Detector software
///////////////////////////////////////////////////////////////////
#include "CollectionMerger.h"
/** Constructor */
ISF::CollectionMerger::CollectionMerger( const std::string& name, ISvcLocator* pSvcLocator ) :
::AthAlgorithm( name, pSvcLocator ),
m_inputBCMHitsSGKeys(),
m_inputBLMHitsSGKeys(),
m_inputPixelHitsSGKeys(),
m_inputSCTHitsSGKeys(),
m_inputTRTUncompressedHitsSGKeys(),
m_inputLArEMBHitsSGKeys(),
m_inputLArEMECHitsSGKeys(),
m_inputLArFCALHitsSGKeys(),
m_inputLArHECHitsSGKeys(),
m_inputTileHitsSGKeys(),
m_inputMBTSHitsSGKeys(),
m_inputCSCHitsSGKeys(),
m_inputMDTHitsSGKeys(),
m_inputRPCHitsSGKeys(),
m_inputTGCHitsSGKeys(),
m_inputBCMHits(),
m_inputBLMHits(),
m_inputPixelHits(),
m_inputSCTHits(),
m_inputTRTUncompressedHits(),
m_inputLArEMBHits(),
m_inputLArEMECHits(),
m_inputLArFCALHits(),
m_inputLArHECHits(),
m_inputTileHits(),
m_inputMBTSHits(),
m_inputCSCHits(),
m_inputMDTHits(),
m_inputRPCHits(),
m_inputTGCHits(),
m_outputBCMHits(),
m_outputBLMHits(),
m_outputPixelHits(),
m_outputSCTHits(),
m_outputTRTUncompressedHits(),
m_outputLArEMBHits(),
m_outputLArEMECHits(),
m_outputLArFCALHits(),
m_outputLArHECHits(),
m_outputTileHits(),
m_outputMBTSHits(),
m_outputCSCHits(),
m_outputMDTHits(),
m_outputRPCHits(),
m_outputTGCHits()
{
// Input collections StoreGate keys
declareProperty( "InputBCMHits", m_inputBCMHitsSGKeys );
declareProperty( "InputBLMHits", m_inputBLMHitsSGKeys );
declareProperty( "InputPixelHits", m_inputPixelHitsSGKeys );
declareProperty( "InputSCTHits", m_inputSCTHitsSGKeys );
declareProperty( "InputTRTUncompressedHits", m_inputTRTUncompressedHitsSGKeys );
declareProperty( "InputLArEMBHits", m_inputLArEMBHitsSGKeys );
declareProperty( "InputLArEMECHits", m_inputLArEMECHitsSGKeys );
declareProperty( "InputLArFCALHits", m_inputLArFCALHitsSGKeys );
declareProperty( "InputLArHECHits", m_inputLArHECHitsSGKeys );
declareProperty( "InputTileHits", m_inputTileHitsSGKeys );
declareProperty( "InputMBTSHits", m_inputMBTSHitsSGKeys );
declareProperty( "InputCSCHits", m_inputCSCHitsSGKeys );
declareProperty( "InputMDTHits", m_inputMDTHitsSGKeys );
declareProperty( "InputRPCHits", m_inputRPCHitsSGKeys );
declareProperty( "InputTGCHits", m_inputTGCHitsSGKeys );
// Output collections
declareProperty( "OutputBCMHits", m_outputBCMHits );
declareProperty( "OutputBLMHits", m_outputBLMHits );
declareProperty( "OutputPixelHits", m_outputPixelHits );
declareProperty( "OutputSCTHits", m_outputSCTHits );
declareProperty( "OutputTRTUncompressedHits", m_outputTRTUncompressedHits );
declareProperty( "OutputLArEMBHits", m_outputLArEMBHits );
declareProperty( "OutputLArEMECHits", m_outputLArEMECHits );
declareProperty( "OutputLArFCALHits", m_outputLArFCALHits );
declareProperty( "OutputLArHECHits", m_outputLArHECHits );
declareProperty( "OutputTileHits", m_outputTileHits );
declareProperty( "OutputMBTSHits", m_outputMBTSHits );
declareProperty( "OutputCSCHits", m_outputCSCHits );
declareProperty( "OutputMDTHits", m_outputMDTHits );
declareProperty( "OutputRPCHits", m_outputRPCHits );
declareProperty( "OutputTGCHits", m_outputTGCHits );
}
/** Destructor */
ISF::CollectionMerger::~CollectionMerger()
{}
/** Athena Algorithm initialize */
StatusCode ISF::CollectionMerger::initialize()
{
ATH_CHECK( setupReadHandleKeyVector(m_inputBCMHitsSGKeys, m_inputBCMHits ) );
ATH_CHECK( setupReadHandleKeyVector(m_inputBLMHitsSGKeys, m_inputBLMHits ) );
ATH_CHECK( setupReadHandleKeyVector(m_inputPixelHitsSGKeys, m_inputPixelHits ) );
ATH_CHECK( setupReadHandleKeyVector(m_inputSCTHitsSGKeys, m_inputSCTHits ) );
ATH_CHECK( setupReadHandleKeyVector(m_inputTRTUncompressedHitsSGKeys, m_inputTRTUncompressedHits) );
ATH_CHECK( setupReadHandleKeyVector(m_inputLArEMBHitsSGKeys, m_inputLArEMBHits ) );
ATH_CHECK( setupReadHandleKeyVector(m_inputLArEMECHitsSGKeys, m_inputLArEMECHits ) );
ATH_CHECK( setupReadHandleKeyVector(m_inputLArFCALHitsSGKeys, m_inputLArFCALHits ) );
ATH_CHECK( setupReadHandleKeyVector(m_inputLArHECHitsSGKeys, m_inputLArHECHits ) );
ATH_CHECK( setupReadHandleKeyVector(m_inputTileHitsSGKeys, m_inputTileHits ) );
ATH_CHECK( setupReadHandleKeyVector(m_inputMBTSHitsSGKeys, m_inputMBTSHits ) );
ATH_CHECK( setupReadHandleKeyVector(m_inputCSCHitsSGKeys, m_inputCSCHits ) );
ATH_CHECK( setupReadHandleKeyVector(m_inputMDTHitsSGKeys, m_inputMDTHits ) );
ATH_CHECK( setupReadHandleKeyVector(m_inputRPCHitsSGKeys, m_inputRPCHits ) );
ATH_CHECK( setupReadHandleKeyVector(m_inputTGCHitsSGKeys, m_inputTGCHits ) );
ATH_CHECK( initializeVarHandleKey(m_outputBCMHits ) );
ATH_CHECK( initializeVarHandleKey(m_outputBLMHits ) );
ATH_CHECK( initializeVarHandleKey(m_outputPixelHits ) );
ATH_CHECK( initializeVarHandleKey(m_outputSCTHits ) );
ATH_CHECK( initializeVarHandleKey(m_outputTRTUncompressedHits) );
ATH_CHECK( initializeVarHandleKey(m_outputLArEMBHits ) );
ATH_CHECK( initializeVarHandleKey(m_outputLArEMECHits ) );
ATH_CHECK( initializeVarHandleKey(m_outputLArFCALHits ) );
ATH_CHECK( initializeVarHandleKey(m_outputLArHECHits ) );
ATH_CHECK( initializeVarHandleKey(m_outputTileHits ) );
ATH_CHECK( initializeVarHandleKey(m_outputMBTSHits ) );
ATH_CHECK( initializeVarHandleKey(m_outputCSCHits ) );
ATH_CHECK( initializeVarHandleKey(m_outputMDTHits ) );
ATH_CHECK( initializeVarHandleKey(m_outputRPCHits ) );
ATH_CHECK( initializeVarHandleKey(m_outputTGCHits ) );
return StatusCode::SUCCESS;
}
/** Athena Algorithm execute */
StatusCode ISF::CollectionMerger::execute()
{
mergeCollections( m_inputBCMHits, m_outputBCMHits );
mergeCollections( m_inputBLMHits, m_outputBLMHits );
mergeCollections( m_inputPixelHits, m_outputPixelHits );
mergeCollections( m_inputSCTHits, m_outputSCTHits );
mergeCollections( m_inputTRTUncompressedHits, m_outputTRTUncompressedHits );
mergeCollections( m_inputLArEMBHits, m_outputLArEMBHits );
mergeCollections( m_inputLArEMECHits, m_outputLArEMECHits );
mergeCollections( m_inputLArFCALHits, m_outputLArFCALHits );
mergeCollections( m_inputLArHECHits, m_outputLArHECHits );
mergeCollections( m_inputTileHits, m_outputTileHits );
mergeCollections( m_inputMBTSHits, m_outputMBTSHits );
mergeCollections( m_inputCSCHits, m_outputCSCHits );
mergeCollections( m_inputMDTHits, m_outputMDTHits );
mergeCollections( m_inputRPCHits, m_outputRPCHits );
mergeCollections( m_inputTGCHits, m_outputTGCHits );
return StatusCode::SUCCESS;
}
/** Athena Algorithm finalize */
StatusCode ISF::CollectionMerger::finalize()
{
return StatusCode::SUCCESS;
}
/** Initialize the given VarHandleKey */
StatusCode ISF::CollectionMerger::initializeVarHandleKey( SG::VarHandleKey& varHandleKey ) const {
if ( varHandleKey.key().empty() )
return StatusCode::SUCCESS;
return varHandleKey.initialize();
}
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
///////////////////////////////////////////////////////////////////
// CollectionMerger.h, (c) ATLAS Detector software
///////////////////////////////////////////////////////////////////
#ifndef ISF_ALGS_COLLECTIONMERGER_H
#define ISF_ALGS_COLLECTIONMERGER_H 1
// STL includes
#include <string>
// Framework includes
#include "AthenaBaseComps/AthAlgorithm.h"
#include "StoreGate/WriteHandleKey.h"
// ATLAS C++
#include "CxxUtils/make_unique.h"
// SimHit EDM includes
// InnerDetector
#include "InDetSimEvent/SiHitCollection.h"
#include "InDetSimEvent/TRTUncompressedHitCollection.h"
// Calorimeter
#include "LArSimEvent/LArHitContainer.h"
#include "TileSimEvent/TileHitVector.h"
// Muon Spectrometer
#include "MuonSimEvent/CSCSimHitCollection.h"
#include "MuonSimEvent/MDTSimHitCollection.h"
#include "MuonSimEvent/RPCSimHitCollection.h"
#include "MuonSimEvent/TGCSimHitCollection.h"
// forward declarations
namespace ISFTesting {
class CollectionMerger_test;
}
namespace ISF {
/** @class CollectionMerger
@brief Athena Algorithm that merges a given set of StoreGate collections in one final collection.
@author Elmar.Ritsch -at- cern.ch
*/
class CollectionMerger final : public AthAlgorithm {
/** Allow the test class access to all methods */
friend class ISFTesting::CollectionMerger_test;
public:
/** Constructor */
CollectionMerger( const std::string& name, ISvcLocator* pSvcLocator );
/** Destructor */
virtual ~CollectionMerger();
/** Athena algorithm's interface methods */
StatusCode initialize() override;
StatusCode execute() override;
StatusCode finalize() override;
private:
/** Initialize the given VarHandleKey */
StatusCode initializeVarHandleKey( SG::VarHandleKey& varHandleKey ) const;
/** Commonly used member and function parameter types */
typedef std::vector<std::string> SGKeyVector_t;
template <typename T>
using ReadHandleKeyVector_t = typename std::vector<SG::ReadHandleKey<T>>;
/** Setup a vector of ReadHandleKeys for the given vector of string StoreGate Keys */
template <typename T>
StatusCode setupReadHandleKeyVector( const SGKeyVector_t& sgKeyVec,
ReadHandleKeyVector_t<T>& readHandleVec ) const;
/** Merge all hits of inputReadHandleKeys's collections into outputWriteHandleKey */
template <typename T>
void mergeCollections( const ReadHandleKeyVector_t<T>& inputReadHandleKeys,
SG::WriteHandleKey<T>& outputWriteHandleKey ) const;
/** Input collection StoreGate keys */
SGKeyVector_t m_inputBCMHitsSGKeys;
SGKeyVector_t m_inputBLMHitsSGKeys;
SGKeyVector_t m_inputPixelHitsSGKeys;
SGKeyVector_t m_inputSCTHitsSGKeys;
SGKeyVector_t m_inputTRTUncompressedHitsSGKeys;
SGKeyVector_t m_inputLArEMBHitsSGKeys;
SGKeyVector_t m_inputLArEMECHitsSGKeys;
SGKeyVector_t m_inputLArFCALHitsSGKeys;
SGKeyVector_t m_inputLArHECHitsSGKeys;
SGKeyVector_t m_inputTileHitsSGKeys;
SGKeyVector_t m_inputMBTSHitsSGKeys;
SGKeyVector_t m_inputCSCHitsSGKeys;
SGKeyVector_t m_inputMDTHitsSGKeys;
SGKeyVector_t m_inputRPCHitsSGKeys;
SGKeyVector_t m_inputTGCHitsSGKeys;
/** Input collection ReadHandleKeys */
ReadHandleKeyVector_t<SiHitCollection> m_inputBCMHits;
ReadHandleKeyVector_t<SiHitCollection> m_inputBLMHits;
ReadHandleKeyVector_t<SiHitCollection> m_inputPixelHits;
ReadHandleKeyVector_t<SiHitCollection> m_inputSCTHits;
ReadHandleKeyVector_t<TRTUncompressedHitCollection> m_inputTRTUncompressedHits;
ReadHandleKeyVector_t<LArHitContainer> m_inputLArEMBHits;
ReadHandleKeyVector_t<LArHitContainer> m_inputLArEMECHits;
ReadHandleKeyVector_t<LArHitContainer> m_inputLArFCALHits;
ReadHandleKeyVector_t<LArHitContainer> m_inputLArHECHits;
ReadHandleKeyVector_t<TileHitVector> m_inputTileHits;
ReadHandleKeyVector_t<TileHitVector> m_inputMBTSHits;
ReadHandleKeyVector_t<CSCSimHitCollection> m_inputCSCHits;
ReadHandleKeyVector_t<MDTSimHitCollection> m_inputMDTHits;
ReadHandleKeyVector_t<RPCSimHitCollection> m_inputRPCHits;
ReadHandleKeyVector_t<TGCSimHitCollection> m_inputTGCHits;
/** Output collection WriteHandleKeys */
SG::WriteHandleKey<SiHitCollection> m_outputBCMHits;
SG::WriteHandleKey<SiHitCollection> m_outputBLMHits;
SG::WriteHandleKey<SiHitCollection> m_outputPixelHits;
SG::WriteHandleKey<SiHitCollection> m_outputSCTHits;
SG::WriteHandleKey<TRTUncompressedHitCollection> m_outputTRTUncompressedHits;
SG::WriteHandleKey<LArHitContainer> m_outputLArEMBHits;
SG::WriteHandleKey<LArHitContainer> m_outputLArEMECHits;
SG::WriteHandleKey<LArHitContainer> m_outputLArFCALHits;
SG::WriteHandleKey<LArHitContainer> m_outputLArHECHits;
SG::WriteHandleKey<TileHitVector> m_outputTileHits;
SG::WriteHandleKey<TileHitVector> m_outputMBTSHits;
SG::WriteHandleKey<CSCSimHitCollection> m_outputCSCHits;
SG::WriteHandleKey<MDTSimHitCollection> m_outputMDTHits;
SG::WriteHandleKey<RPCSimHitCollection> m_outputRPCHits;
SG::WriteHandleKey<TGCSimHitCollection> m_outputTGCHits;
};
}
//
// templated methods below
//
/** Setup a vector of ReadHandleKeys for the given vector of string StoreGate Keys */
template <typename T>
StatusCode ISF::CollectionMerger::setupReadHandleKeyVector( const SGKeyVector_t& sgKeyVec,
ReadHandleKeyVector_t<T>& readHandleVec ) const {
readHandleVec.reserve( sgKeyVec.size() );
// convert string StoreGate key to ReadHandleKey
for ( const auto& sgKey: sgKeyVec ) {
readHandleVec.emplace_back( sgKey );
}
// initialize all ReadHandleKeys
for ( auto& readHandleKey: readHandleVec ) {
if ( readHandleKey.initialize().isFailure() ) {
return StatusCode::FAILURE;
}
}
return StatusCode::SUCCESS;
}
/** Merge all hits of inputReadHandleKeys's collections into outputWriteHandleKey */
template <typename T>
void ISF::CollectionMerger::mergeCollections( const ReadHandleKeyVector_t<T>& inputReadHandleKeys,
SG::WriteHandleKey<T>& outputWriteHandleKey ) const {
// skip if not input collection
if ( inputReadHandleKeys.empty() )
return;
// TODO: is there a way to conveniently get the total number of hits in all inputReadHandleKeys
// and reserve the corresponding size in the outputHandle
SG::WriteHandle<T> outputHandle{outputWriteHandleKey};
outputHandle.record( CxxUtils::make_unique<T>() );
for ( const auto& collKey: inputReadHandleKeys ) {
SG::ReadHandle<T> inputHandle{collKey};
for ( const auto& hit: *inputHandle ) {
// TODO: replace with ->Emplace(hit) once LArHitContainer supports this
outputHandle->push_back( hit );
}
}
}
#endif //> !ISF_ALGS_COLLECTIONMERGER_H
#include "GaudiKernel/DeclareFactoryEntries.h"
#include "../SimKernel.h"
#include "../CollectionMerger.h"
DECLARE_NAMESPACE_ALGORITHM_FACTORY( ISF , SimKernel )
DECLARE_NAMESPACE_ALGORITHM_FACTORY( ISF , SimKernel )
DECLARE_NAMESPACE_ALGORITHM_FACTORY( ISF , CollectionMerger )
DECLARE_FACTORY_ENTRIES( ISF_Algorithms ) {
DECLARE_NAMESPACE_ALGORITHM( ISF , SimKernel )
DECLARE_NAMESPACE_ALGORITHM( ISF , SimKernel )
DECLARE_NAMESPACE_ALGORITHM( ISF , CollectionMerger )
}
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
/**
* @author Elmar Ritsch <Elmar.Ritsch@cern.ch>
* @date May, 2016
* @brief Tests for ISF::CollectionMerger.
*/
#undef NDEBUG
// Framework
#include "TestTools/initGaudi.h"
// Standard C/C++
#include <cassert>
// ATLAS C++
#include "CxxUtils/make_unique.h"
// Tested AthAlgorithm
#include "../src/CollectionMerger.h"
namespace ISFTesting {
class TestHits {
public:
TestHits(int value):m_value(value) { };
int m_value;
};
// typedef for convenience
typedef AtlasHitsVector<ISFTesting::TestHits> TestHitCollection_t;
class CollectionMerger_test {
public:
static void test_empty_alg(ISvcLocator* svcLoc) {
ISF::CollectionMerger alg{"CollectionMergerEmptyAlgTest", svcLoc};
assert( alg.setProperties().isSuccess() );
assert( alg.initialize().isSuccess() );
assert( alg.execute().isSuccess() );
assert( alg.finalize().isSuccess() );
}