Skip to content
Snippets Groups Projects
Commit cc3ed11b authored by Andreas Salzburger's avatar Andreas Salzburger Committed by Graeme Stewart
Browse files

Tagging as TrkTrackCollectionMerger-00-03-00 (TrkTrackCollectionMerger-00-03-00)

parent 570905fc
No related branches found
No related tags found
No related merge requests found
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
///////////////////////////////////////////////////////////////////
// TrackCollectionMerger.h, (c) ATLAS Detector software
///////////////////////////////////////////////////////////////////
#ifndef TrackCollectionMerger_H
#define TrackCollectionMerger_H
#include <string>
#include <map>
#include "AthenaBaseComps/AthAlgorithm.h"
#include "GaudiKernel/ToolHandle.h"
#include "TrkTrack/TrackCollection.h"
#include "TrkToolInterfaces/ITrackSummaryTool.h"
#include "TrkToolInterfaces/IPRD_AssociationTool.h"
namespace Trk {
/** @brief Class-algorithm for track collection merging and removalof potential duplicate tracks. */
class TrackCollectionMerger : public AthAlgorithm
{
///////////////////////////////////////////////////////////////////
/** @brief Public methods: */
///////////////////////////////////////////////////////////////////
public:
///////////////////////////////////////////////////////////////////
/** @brief Standard Algotithm methods: */
///////////////////////////////////////////////////////////////////
TrackCollectionMerger(const std::string &name, ISvcLocator *pSvcLocator);
virtual ~TrackCollectionMerger() {}
StatusCode initialize();
StatusCode execute();
StatusCode finalize();
///////////////////////////////////////////////////////////////////
/** @brief Print internal tool parameters and status. */
///////////////////////////////////////////////////////////////////
MsgStream& dump (MsgStream& out) const;
std::ostream& dump (std::ostream& out) const;
protected:
///////////////////////////////////////////////////////////////////
/** @brief Protected data: */
///////////////////////////////////////////////////////////////////
std::vector<std::string> m_tracklocation ; /** Vector of track collections to be merged. */
std::string m_outtracklocation ; /** Combined track collection. */
ToolHandle< Trk::IPRD_AssociationTool > m_assoTool ; /** association tool for PRDs */
ToolHandle< Trk::ITrackSummaryTool > m_trkSummaryTool ; /** summary tool with shared hits enabled */
///////////////////////////////////////////////////////////////////
/** @brief Protected methods: */
///////////////////////////////////////////////////////////////////
/** @brief A routine that merges the track collections. */
StatusCode mergeTrack(const TrackCollection* trackCol, TrackCollection* outputCol);
MsgStream& dumptools(MsgStream& out) const;
MsgStream& dumpevent(MsgStream& out) const;
private:
bool m_createViewCollection; //!< option to create a view collection and not deep-copy tracks
bool m_updateSharedHitsOnly; //!< do not create the track summary again, but only update shared hits
};
MsgStream& operator << (MsgStream& ,const TrackCollectionMerger&);
std::ostream& operator << (std::ostream&,const TrackCollectionMerger&);
}
#endif // TrackCollectionMerger_H
package TrkTrackCollectionMerger
author Thomas Koffas <Thomas.Koffas@cern.ch>
private
use TrkPrepRawData TrkPrepRawData-* Tracking/TrkEvent
public
use AtlasPolicy AtlasPolicy-*
use GaudiInterface GaudiInterface-* External
use AthenaBaseComps AthenaBaseComps-* Control
use TrkTrack TrkTrack-* Tracking/TrkEvent
use TrkToolInterfaces TrkToolInterfaces-* Tracking/TrkTools
library TrkTrackCollectionMerger *.cxx components/*.cxx
apply_pattern component_library
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
/**
@mainpage TrkTrackCollectionMerger
@author Thomas.Koffas@cern.ch
@section TrkTrackCollectionMergerIntro Introduction
This is an algorithm that merges all individual track collections,
SiSeededTracks, back-tracks, standalone TRT tracks etc. It runs at
the end of the tracking and before the post processing. It ouputs
a global track collection.
@section TrkTrackCollectionMergerDescription Description
This algorithm performs the following tasks:
1. Loops over the input vector of all available track collections.
For each track collection, the track are saved in a common track
container that will be stored for later usage. The hit association
tool also gets updated simultaneuosly.
2. Using the new common track collection, that track summary tool is then
updated.
3. The new collection is stored.
@section TrkTrackCollectionMergerTools Used Tools
This algorithm uses the ITrackSummaryTool, IPRD_AssociationTool tools.
@section TrkTrackCollectionMergerContents Algorithm Contents
The TrkTrackCollectionMerger contains the following classes/files:
- TrkTrackCollectionMerger.cxx...Main class calling all the necessary tools and producing the ouput track collection.
@section TrkTrackCollectionMergerPackages Used Packages
@htmlinclude used_packages.html
@section TrkTrackCollectionMergerReq Requirements file
@include requirements
*/
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
///////////////////////////////////////////////////////////////////
// Implementation file for class Trk::TrackCollectionMerger
///////////////////////////////////////////////////////////////////
// (c) ATLAS Detector software
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
// Version 1.0 11/26/2007 Thomas Koffas
///////////////////////////////////////////////////////////////////
#include "GaudiKernel/MsgStream.h"
#include "TrkPrepRawData/PrepRawData.h"
#include "TrkTrackCollectionMerger/TrackCollectionMerger.h"
///////////////////////////////////////////////////////////////////
// Constructor
///////////////////////////////////////////////////////////////////
Trk::TrackCollectionMerger::TrackCollectionMerger
(const std::string& name, ISvcLocator* pSvcLocator ) :
AthAlgorithm(name, pSvcLocator ),
m_createViewCollection(true),
m_updateSharedHitsOnly(true)
{
m_outtracklocation = "CombinedInDetTracks" ;
declareProperty("TracksLocation", m_tracklocation );
declareProperty("OutputTracksLocation", m_outtracklocation );
declareProperty("AssoTool", m_assoTool );
declareProperty("SummaryTool" , m_trkSummaryTool );
declareProperty("CreateViewColllection" , m_createViewCollection );
declareProperty("UpdateSharedHitsOnly" , m_updateSharedHitsOnly);
}
///////////////////////////////////////////////////////////////////
// Initialisation
///////////////////////////////////////////////////////////////////
StatusCode Trk::TrackCollectionMerger::initialize()
{
ATH_MSG_DEBUG("Initializing TrackCollectionMerger");
if ( m_assoTool.retrieve().isFailure() ) {
msg(MSG::FATAL) << "Failed to retrieve tool " << m_assoTool << endreq;
return StatusCode::FAILURE;
} else
ATH_MSG_INFO("Retrieved tool " << m_assoTool);
if (m_trkSummaryTool.retrieve().isFailure()) {
msg(MSG::FATAL) << "Failed to retrieve tool " << m_trkSummaryTool << endreq;
return StatusCode::FAILURE;
} else
ATH_MSG_INFO("Retrieved tool " << m_trkSummaryTool);
return StatusCode::SUCCESS;
}
///////////////////////////////////////////////////////////////////
// Execute
///////////////////////////////////////////////////////////////////
StatusCode Trk::TrackCollectionMerger::execute()
{
// clean up association tool
m_assoTool->reset();
// out output track collection
TrackCollection* outputCol = m_createViewCollection ?
new TrackCollection(SG::VIEW_ELEMENTS) : new TrackCollection;
ATH_MSG_DEBUG("Number of Track collections " << m_tracklocation.size());
// pre-loop to reserve enough space in the output collection
std::vector<const TrackCollection*> trackCollections;
trackCollections.reserve(m_tracklocation.size());
size_t ttNumber = 0;
for (auto& tcname : m_tracklocation){
const TrackCollection* trackCol;
///Retrieve forward tracks from StoreGate
if (evtStore()->retrieve(trackCol,tcname).isFailure()){
ATH_MSG_DEBUG("No tracks with name " << tcname);
} else {
ATH_MSG_DEBUG("Found track collection " << tcname );
trackCollections.push_back(trackCol);
ttNumber += trackCol->size();
}
}
// reserve the right number of entries for the output collection
outputCol->reserve(ttNumber);
// merging loop
for(auto& tciter : trackCollections){
// merge them in
if(mergeTrack(tciter,outputCol).isFailure()){
ATH_MSG_ERROR( "Failed to merge tracks! ");
}
}
ATH_MSG_DEBUG("Size of combined tracks " << outputCol->size());
if( evtStore()->record(outputCol,m_outtracklocation,false).isFailure() ){
ATH_MSG_ERROR("Could not save the reconstructed TRT seeded Si tracks!");
return StatusCode::FAILURE ;
}
ATH_MSG_DEBUG("Update summaries");
// now loop over all tracks and update summaries with new shared hit counts
TrackCollection::iterator rf = outputCol->begin();
TrackCollection::iterator rfE = outputCol->end();
for( ; rf != rfE; ++rf){
if (m_updateSharedHitsOnly) m_trkSummaryTool->updateSharedHitCount(**rf);
else m_trkSummaryTool->updateTrack(**rf);
}
//Print common event information
if(msgLvl(MSG::DEBUG)){
ATH_MSG_DEBUG((*this));
}
ATH_MSG_DEBUG("Done !");
return StatusCode::SUCCESS;
}
///////////////////////////////////////////////////////////////////
// Finalize
///////////////////////////////////////////////////////////////////
StatusCode Trk::TrackCollectionMerger::finalize()
{
return StatusCode::SUCCESS;
}
///////////////////////////////////////////////////////////////////
// Dumps relevant information into the MsgStream
///////////////////////////////////////////////////////////////////
MsgStream& Trk::TrackCollectionMerger::dump( MsgStream& out ) const
{
out<<std::endl;
if(msgLvl(MSG::DEBUG)) return dumpevent(out);
return dumptools(out);
}
///////////////////////////////////////////////////////////////////
// Dumps conditions information into the MsgStream
///////////////////////////////////////////////////////////////////
MsgStream& Trk::TrackCollectionMerger::dumptools( MsgStream& out ) const
{
return out;
}
///////////////////////////////////////////////////////////////////
// Dumps event information into the MsgStream
///////////////////////////////////////////////////////////////////
MsgStream& Trk::TrackCollectionMerger::dumpevent( MsgStream& out ) const
{
return out;
}
///////////////////////////////////////////////////////////////////
// Dumps relevant information into the ostream
///////////////////////////////////////////////////////////////////
std::ostream& Trk::TrackCollectionMerger::dump( std::ostream& out ) const
{
return out;
}
///////////////////////////////////////////////////////////////////
// Overload of << operator MsgStream
///////////////////////////////////////////////////////////////////
MsgStream& Trk::operator <<
(MsgStream& sl,const Trk::TrackCollectionMerger& se)
{
return se.dump(sl);
}
///////////////////////////////////////////////////////////////////
// Overload of << operator std::ostream
///////////////////////////////////////////////////////////////////
std::ostream& Trk::operator <<
(std::ostream& sl,const Trk::TrackCollectionMerger& se)
{
return se.dump(sl);
}
///////////////////////////////////////////////////////////////////
// Merge track collections and remove duplicates
///////////////////////////////////////////////////////////////////
StatusCode Trk::TrackCollectionMerger::mergeTrack(const TrackCollection* trackCol, TrackCollection* outputCol)
{
// loop over forward track, accept them and add them imto association tool
if(trackCol && trackCol->size()) {
ATH_MSG_DEBUG("Size of track collection " << trackCol->size());
// loop over tracks
for(auto& rf: *trackCol){
// add track into output
Trk::Track* newTrack = m_createViewCollection ? rf : new Trk::Track(*rf);
outputCol->push_back(newTrack);
// add tracks into PRD tool
if (m_assoTool->addPRDs(*newTrack).isFailure())
msg(MSG::WARNING) << "Failed to add PRDs to map" << endreq;
}
}
return StatusCode::SUCCESS;
}
#include "GaudiKernel/DeclareFactoryEntries.h"
#include "TrkTrackCollectionMerger/TrackCollectionMerger.h"
using namespace Trk;
DECLARE_ALGORITHM_FACTORY( TrackCollectionMerger )
DECLARE_FACTORY_ENTRIES( TrkTrackCollectionMerger )
{
DECLARE_ALGORITHM( TrackCollectionMerger )
}
#include "GaudiKernel/LoadFactoryEntries.h"
LOAD_FACTORY_ENTRIES( TrkTrackCollectionMerger)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment