Commit e79ee5ff authored by Matthew Scott Rudolph's avatar Matthew Scott Rudolph Committed by Graeme Stewart
Browse files

Tag to allow optional use of merging tool in InDetPriVxFinder (InDetPriVxFinder-03-00-08)

	* Tag as InDetPriVxFinder-03-00-08 to allow optional use of merge tool

2014-08-08 Matt Rudolph
	* Add to InDetPriVxFinder the ability to use a VertexMergingTool after finding and before sorting, off by default

        * no tag
parent 635d51e9
......@@ -26,6 +26,7 @@
namespace Trk
{
class IVertexMergingTool;
class IVertexCollectionSortingTool;
class IVxCandidateXAODVertex;
}
......@@ -48,9 +49,11 @@ namespace InDet
std::string m_vxCandidatesOutputNameAuxPostfix; //!< Postfix of output auxiliary container to store results (xAOD only)
ToolHandle< IVertexFinder > m_VertexFinderTool;
ToolHandle<Trk::IVertexMergingTool > m_VertexMergingTool;
ToolHandle<Trk::IVertexCollectionSortingTool > m_VertexCollectionSortingTool;
ToolHandle< Trk::IVxCandidateXAODVertex > m_VertexEdmFactory;
bool m_doVertexMerging;
bool m_doVertexSorting;
// for summary output at the end
......
......@@ -13,6 +13,7 @@
#include "InDetPriVxFinder/InDetPriVxFinder.h"
// forward declares
#include "InDetRecToolInterfaces/IVertexFinder.h"
#include "TrkVertexFitterInterfaces/IVertexMergingTool.h"
#include "TrkVertexFitterInterfaces/IVertexCollectionSortingTool.h"
#include "xAODTracking/Vertex.h"
#include "xAODTracking/TrackParticle.h"
......@@ -31,13 +32,15 @@ namespace InDet
{
InDetPriVxFinder::InDetPriVxFinder ( const std::string &n, ISvcLocator *pSvcLoc )
: AthAlgorithm ( n, pSvcLoc ),
: AthAlgorithm ( n, pSvcLoc ),
m_tracksName ( "Tracks" ),
m_vxCandidatesOutputName ( "PrimaryVertices" ),
m_vxCandidatesOutputNameAuxPostfix ( "Aux." ),
m_VertexFinderTool ( "InDet::InDetPriVxFinderTool" ),
m_VertexMergingTool( "Trk::VertexMergingTool" ),
m_VertexCollectionSortingTool ("Trk::VertexCollectionSortingTool"),
m_VertexEdmFactory("Trk::VertexInternalEdmFactory"),
m_doVertexMerging(false),
m_doVertexSorting(false),
// for summary output at the end
m_numEventsProcessed(0),
......@@ -48,8 +51,10 @@ namespace InDet
declareProperty ( "VxCandidatesOutputName",m_vxCandidatesOutputName );
declareProperty ( "VxCandidatesOutputNameAuxPostfix",m_vxCandidatesOutputNameAuxPostfix );
declareProperty ( "VertexFinderTool",m_VertexFinderTool );
declareProperty ( "VertexMergingTool",m_VertexMergingTool );
declareProperty ( "VertexCollectionSortingTool",m_VertexCollectionSortingTool );
declareProperty ( "InternalEdmFactory", m_VertexEdmFactory);
declareProperty ( "doVertexMerging",m_doVertexMerging );
declareProperty ( "doVertexSorting",m_doVertexSorting );
}
......@@ -69,6 +74,20 @@ namespace InDet
msg(MSG::INFO) << "Retrieved tool " << m_VertexFinderTool << endreq;
}
/*Get the Vertex Mergin Tool*/
if (m_doVertexMerging)
{
if ( m_VertexMergingTool.retrieve().isFailure() )
{
msg(MSG::FATAL) << "Failed to retrieve tool " << m_VertexMergingTool << endreq;
return StatusCode::FAILURE;
}
else
{
msg(MSG::INFO) << "Retrieved tool " << m_VertexMergingTool << endreq;
}
}
/*Get the Vertex Collection Sorting Tool*/
if (m_doVertexSorting)
{
......@@ -139,11 +158,20 @@ namespace InDet
return StatusCode::SUCCESS;
}
// now resorting the vertex container and store to SG
// now re-merge and resort the vertex container and store to SG
std::pair<xAOD::VertexContainer*, xAOD::VertexAuxContainer*> myVxContainer;
VxContainer* MyTrackVxContainer = 0;
if (theXAODContainer.first) {
//sort xAOD::Vertex container
if(m_doVertexMerging && theXAODContainer.first->size() > 1) {
myVxContainer = m_VertexMergingTool->mergeVertexContainer( *theXAODContainer.first );
//now delete and copy over theXAODContainer so sorting will still work
delete theXAODContainer.first; //also cleans up the aux store
delete theXAODContainer.second;
theXAODContainer = myVxContainer;
}
if (m_doVertexSorting && theXAODContainer.first->size() > 1) {
myVxContainer = m_VertexCollectionSortingTool->sortVertexContainer(*theXAODContainer.first);
delete theXAODContainer.first; //also cleans up the aux store
......@@ -169,6 +197,14 @@ namespace InDet
return StatusCode::FAILURE;
}
} else if (theVxContainer) {
if( m_doVertexMerging && theVxContainer->size() > 1 ) {
MyTrackVxContainer = m_VertexMergingTool->mergeVxContainer( * theVxContainer );
delete theVxContainer;
//reassign so sorting can still run;
theVxContainer = MyTrackVxContainer;
}
//sort Trk::Track container (or Rec::TrackParticle)
if (m_doVertexSorting && theVxContainer->size() > 1) {
MyTrackVxContainer = m_VertexCollectionSortingTool->sortVxContainer(*theVxContainer);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment