Commit bc2b8c16 authored by Atlas-Software Librarian's avatar Atlas-Software Librarian Committed by Graeme Stewart
Browse files

'CMakeLists.txt' (TrkTrackSlimmer-01-00-00)

parent a3546123
################################################################################
# Package: TrkTrackSlimmer
################################################################################
# Declare the package name:
atlas_subdir( TrkTrackSlimmer )
# Declare the package's dependencies:
atlas_depends_on_subdirs( PUBLIC
Control/AthenaBaseComps
GaudiKernel
PRIVATE
Tracking/TrkEvent/TrkTrack
Tracking/TrkTools/TrkToolInterfaces )
# Component(s) in the package:
atlas_add_component( TrkTrackSlimmer
src/*.cxx
src/components/*.cxx
LINK_LIBRARIES AthenaBaseComps GaudiKernel TrkTrack TrkToolInterfaces )
# Install files from the package:
atlas_install_headers( TrkTrackSlimmer )
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
///////////////////////////////////////////////////////////////////
// TrackSlimmer.h, (c) ATLAS Detector software
///////////////////////////////////////////////////////////////////
#ifndef TRKTRACKSLIMMER_TRK_TRACKSLIMMER_H
#define TRKTRACKSLIMMER_TRK_TRACKSLIMMER_H
// Gaudi includes
#include "AthenaBaseComps/AthAlgorithm.h"
#include "GaudiKernel/ToolHandle.h"
#include <string>
class AtlasDetectorID;
class Identifier;
namespace Trk
{
class ITrackSlimmingTool;
/** @class TrackSlimmer
Simple algorithm to load tracks and use Trk::ITrackSlimmingTool to e.g. strip them down
to hits + perigee parameters for use in AOD.
@author Edward Moyse <Edward.Moyse@cern.ch>
*/
class TrackSlimmer : public AthAlgorithm
{
public:
/** Standard Athena-Algorithm Constructor */
TrackSlimmer(const std::string& name, ISvcLocator* pSvcLocator);
/** Default Destructor */
~TrackSlimmer();
/** standard Athena-Algorithm method */
StatusCode initialize();
/** standard Athena-Algorithm method */
StatusCode execute();
/** standard Athena-Algorithm method */
StatusCode finalize();
private:
/** member variables for algorithm properties: */
// int/double/bool m_propertyName;
ToolHandle<ITrackSlimmingTool> m_slimTool;
std::vector<std::string> m_trackLocation;
std::vector<std::string> m_slimmedTracksLocation;
double m_ptCut;
unsigned int m_numSlimmedTracks;
unsigned int m_numOriginalTracks;
};
} // end of namespace
#endif
package TrkTrackSlimmer
author Edward Moyse <Edward.Moyse@cern.ch>
public
use AtlasPolicy AtlasPolicy-*
use GaudiInterface GaudiInterface-* External
use AthenaBaseComps AthenaBaseComps-* Control
private
use TrkToolInterfaces TrkToolInterfaces-* Tracking/TrkTools
use TrkTrack TrkTrack-* Tracking/TrkEvent
library TrkTrackSlimmer *.cxx components/*.cxx
apply_pattern component_library
private
#macro cppdebugflags '$(cppdebugflags_s)'
#macro_remove componentshr_linkopts "-Wl,-s"
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
///////////////////////////////////////////////////////////////////
// TrackSlimmer.cxx, (c) ATLAS Detector software
///////////////////////////////////////////////////////////////////
#include "TrkTrackSlimmer/TrackSlimmer.h"
#include "TrkTrack/TrackCollection.h"
#include "TrkToolInterfaces/ITrackSlimmingTool.h"
//================ Constructor =================================================
Trk::TrackSlimmer::TrackSlimmer(const std::string& name, ISvcLocator* pSvcLocator) :
AthAlgorithm(name,pSvcLocator),
m_slimTool("Trk::TrkTrackSlimmingTool/TrkTrackSlimmingTool"),
m_ptCut(0.0),
m_numSlimmedTracks(0),
m_numOriginalTracks(0)
{
m_trackLocation.push_back("ConvertedMooreTracks");
m_trackLocation.push_back("ConvertedMuonboyTracks");
m_slimmedTracksLocation.push_back("SlimmedMooreTracks");
m_slimmedTracksLocation.push_back("SlimmedMuonboyTracks");
// template for property decalration
declareProperty("TrackSlimmingTool", m_slimTool);
declareProperty("TrackLocation", m_trackLocation);
declareProperty("SlimmedTrackLocation", m_slimmedTracksLocation);
declareProperty("PtCut", m_ptCut);
}
//================ Destructor =================================================
Trk::TrackSlimmer::~TrackSlimmer()
{}
//================ Initialisation =================================================
StatusCode Trk::TrackSlimmer::initialize()
{
// Code entered here will be executed once at program start.
msg(MSG::INFO) << name() << " initialize()" << endreq;
if ( m_slimTool.retrieve().isFailure() ) {
msg(MSG::ERROR) << "Failed to retrieve TrkTrackSlimmingTool tool "<< m_slimTool << endreq;
return StatusCode::FAILURE;
} else {
msg(MSG::INFO) << "Retrieved tool " << m_slimTool << endreq;
}
msg(MSG::INFO) << "initialize() successful in " << name() << endreq;
return StatusCode::SUCCESS;
}
//================ Finalisation =================================================
StatusCode Trk::TrackSlimmer::finalize()
{
msg(MSG::INFO) << "Produced "<< m_numSlimmedTracks<<" slimmed tracks from "<<m_numOriginalTracks<<" original tracks"<<endreq;
// Code entered here will be executed once at the end of the program run.
return StatusCode::SUCCESS;
}
//================ Execution ====================================================
StatusCode Trk::TrackSlimmer::execute()
{
// Code entered here will be executed once per event
int numTracksFailingPtCut=0;
using namespace std;
vector<string>::const_iterator trackLoc = m_trackLocation.begin();
vector<string>::const_iterator slimmedTrackLoc = m_slimmedTracksLocation.begin();
vector<string>::const_iterator trackLocEnd = m_trackLocation.end();
for (;trackLoc!=trackLocEnd;++trackLoc, ++slimmedTrackLoc)
{
const TrackCollection* container;
StatusCode sc = evtStore()->retrieve(container, *trackLoc);
if (sc.isSuccess())
{
//create container for slimmed tracks
TrackCollection* slimmedTracks = new TrackCollection;
//loop through tracks, slimming them as you go.
TrackCollection::const_iterator it = container->begin();
TrackCollection::const_iterator itEnd = container->end();
for (;it!=itEnd;it++)
{
const DataVector< const Trk::TrackParameters > * params = (**it).trackParameters();
if ( params!=0 && params->size()>0 && params->front()->pT()>m_ptCut )
{
Track* slimmed = m_slimTool->slim(**it);
slimmedTracks->push_back(slimmed);
//m_log<<MSG::INFO<<"Original Track"<<(**it)<<endreq;
//m_log<<MSG::INFO<<"Slimmed Track"<<(*slimmed)<<endreq;
} else {
if (params!=0 && params->size()>0) numTracksFailingPtCut++;
}
}
sc = evtStore()->record(slimmedTracks, *slimmedTrackLoc, false);
// info for stats in finalise
m_numSlimmedTracks+=slimmedTracks->size();
m_numOriginalTracks+=container->size();
if (sc.isFailure())
msg(MSG::ERROR) << "Could not record tracks" << endreq;
else
if (msgLvl(MSG::VERBOSE))
msg(MSG::VERBOSE) << "Saved "<<slimmedTracks->size()<<" slimmed tracks (to "<<*slimmedTrackLoc
<<"), from input ("<<*trackLoc<<") of "<<container->size()<<" original tracks (which makes "
<< m_numSlimmedTracks<<"/"<<m_numOriginalTracks<<" so far). "
<< numTracksFailingPtCut<<" tracks failed pT cut of "<<m_ptCut<<endreq;
}
}
return StatusCode::SUCCESS;
}
//============================================================================================
#include "GaudiKernel/DeclareFactoryEntries.h"
#include "TrkTrackSlimmer/TrackSlimmer.h"
DECLARE_NAMESPACE_ALGORITHM_FACTORY( Trk , TrackSlimmer )
DECLARE_FACTORY_ENTRIES( TrkTrackSlimmer ) {
DECLARE_NAMESPACE_ALGORITHM( Trk , TrackSlimmer )
}
#include "GaudiKernel/LoadFactoryEntries.h"
LOAD_FACTORY_ENTRIES( TrkTrackSlimmer )
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