Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

TrackSelector Class Reference

#include <TrackMCTools/TrackSelector.h>

Inheritance diagram for TrackSelector:

ITrackSelector List of all members.

Public Member Functions

 TrackSelector (const std::string &type, const std::string &name, const IInterface *parent)
 Constructor.
virtual ~TrackSelector ()
 Destructor.
virtual StatusCode initialize ()
 Tool initialization.
virtual bool select (Track *track) const
virtual bool select (MCParticle *mcParticle)
virtual bool selectByTrackType (Track *track) const
virtual bool selectByTrackType (MCParticle *mcParticle)
virtual unsigned int trackType (MCParticle *mcPart)
virtual StatusCode setTrackType (MCParticle *mcPart, Track *&track)

Private Attributes

ITrackReconstructiblem_mcParticleJudge
 Pointer to MCParticle judge.
unsigned int m_previousTrackType
 Previous track type identifier.
MCParticle * m_previousMCParticle
 Previously requested MCParticle.
bool m_uniqueFlag
 To monitor unique tracks only.
bool m_validFlag
 To monitor only correctly fitted tracks.
double m_minP
 minimum momentum for the tracks
double m_maxP
 maximum momentum for the tracks
std::vector< int > m_tracktypes
std::string m_mcParticleJudgeName
 Name of the tool to decide which MCParticles should have been found.

Detailed Description

This tool selects Tracks and MCParticles based on certain criteria. These criteria, which can be set with job options, are:

2005-05-04 : Eduardo Rodrigues (adaptations to new track event model)

Author:
Jeroen van Tilburg
Date:
2003-07-28

Definition at line 40 of file TrackSelector.h.


Constructor & Destructor Documentation

TrackSelector::TrackSelector const std::string &  type,
const std::string &  name,
const IInterface *  parent
 

Constructor.

Definition at line 30 of file TrackSelector.cpp.

References m_maxP, m_mcParticleJudgeName, m_minP, m_tracktypes, m_uniqueFlag, and m_validFlag.

00033   : GaudiTool ( type, name , parent )
00034   , m_mcParticleJudge( 0 )
00035   , m_previousTrackType( TrackKeys::TypeUnknown )
00036   , m_previousMCParticle( 0 )
00037 {
00038   // interfaces
00039   declareInterface<ITrackSelector>(this);
00040   // job options
00041   declareProperty( "UniqueFlag",  m_uniqueFlag = true );
00042   declareProperty( "ValidFlag",   m_validFlag = true );
00043   declareProperty( "MinP",        m_minP = 0.0*GeV );
00044   declareProperty( "MaxP",        m_maxP = 100.0*TeV );
00045   declareProperty( "TrackTypes",  m_tracktypes );
00046   declareProperty( "MCParticles", m_mcParticleJudgeName = "TrackAcceptance" );
00047 }

TrackSelector::~TrackSelector  )  [virtual]
 

Destructor.

Definition at line 52 of file TrackSelector.cpp.

00052 {};


Member Function Documentation

StatusCode TrackSelector::initialize  )  [virtual]
 

Tool initialization.

Definition at line 57 of file TrackSelector.cpp.

References m_mcParticleJudge, and m_mcParticleJudgeName.

00058 {
00059   StatusCode sc = GaudiTool::initialize(); // must be executed first
00060   if ( sc.isFailure() ) return sc;  
00061 
00062   debug() << "==> Initialize" << endreq;
00063 
00064   // Retrieve the reconstructibility tool
00065   m_mcParticleJudge = tool<ITrackReconstructible>( m_mcParticleJudgeName );
00066 
00067   return StatusCode::SUCCESS;
00068 }

bool TrackSelector::select MCParticle *  mcParticle  )  [virtual]
 

Select the MCParticle.

Returns:
True, if the MCParticle is selected; false otherwise.
Parameters:
mcParticle,Input MCParticle, which is checked for selection.

Implements ITrackSelector.

Definition at line 93 of file TrackSelector.cpp.

References m_maxP, and selectByTrackType().

00094 {
00095   bool selected = true;
00096 
00097   // Check the momentum of MCParticle
00098   double momentum = mcParticle -> momentum().vect().mag();  
00099   if ( momentum < m_minP || momentum > m_maxP ) selected = false;
00100 
00101   // Check if the MCParticle is of the requested type
00102   if ( !selectByTrackType( mcParticle ) ) selected = false;
00103   
00104   return selected;
00105 }

bool TrackSelector::select Track track  )  const [virtual]
 

Select the Track.

Returns:
True, if the track is selected; false otherwise.
Parameters:
track,Input track, which is checked for selection.

Implements ITrackSelector.

Definition at line 73 of file TrackSelector.cpp.

References m_maxP, selectByTrackType(), and str::states().

00074 {
00075   bool selected = true;
00076 
00077   // Check the momentum of track (at first state)  
00078   State* firstState = *( track -> states().begin() );
00079   if ( firstState ) {
00080     double momentum = firstState -> p();
00081     if ( momentum < m_minP || momentum > m_maxP ) selected = false;
00082   }
00083 
00084   // Check if the track is of the requested type
00085   if ( !selectByTrackType( track ) ) selected = false;
00086 
00087   return selected;
00088 }

bool TrackSelector::selectByTrackType MCParticle *  mcParticle  )  [virtual]
 

Select the MCParticle only by track type.

Returns:
True, if the MCParticle is selected; false otherwise.
Parameters:
mcParticle,Input MCParticle, which is checked for selection.

Implements ITrackSelector.

Definition at line 135 of file TrackSelector.cpp.

References m_tracktypes, and trackType().

00136 {
00137   bool selected = true;
00138 
00139   // Check if the MCParticle is of the requested type
00140   int tracktype = trackType( mcParticle );
00141   if ( tracktype == TrackKeys::TypeUnknown ||
00142        ( !m_tracktypes.empty() &&
00143          std::find( m_tracktypes.begin(), m_tracktypes.end(),  
00144                     tracktype ) == m_tracktypes.end() ) ) selected = false;
00145 
00146   return selected;
00147 }

bool TrackSelector::selectByTrackType Track track  )  const [virtual]
 

Select the Track only by track type, unique- and valid-flag .

Returns:
True, if the track is selected; false otherwise.
Parameters:
track,Input track, which is checked for selection.

Implements ITrackSelector.

Definition at line 110 of file TrackSelector.cpp.

References m_tracktypes, m_uniqueFlag, and m_validFlag.

Referenced by select().

00111 {
00112   bool selected = true;
00113 
00114   // Check the Unique flag
00115   if ( m_uniqueFlag && !( track->checkFlag( TrackKeys::Unique ) ) )
00116     selected = false;
00117 
00118   // Check the validity flag
00119   if ( m_validFlag && !( track->checkFlag( TrackKeys::Valid ) ) )
00120     selected = false;
00121 
00122   // Check if the track is of the requested type
00123   int tracktype = track -> type();
00124   if ( tracktype == TrackKeys::TypeUnknown ||
00125        ( !m_tracktypes.empty() &&  
00126          std::find( m_tracktypes.begin(), m_tracktypes.end(), 
00127                     tracktype ) == m_tracktypes.end() ) ) selected = false;
00128 
00129   return selected;
00130 }

StatusCode TrackSelector::setTrackType MCParticle *  mcPart,
Track *&  track
[virtual]
 

Set the track type of a Track with an MCParticle's type.

Returns:
StatusCode.
Parameters:
mcPart,MCParticle which will determine the type of the (true) Track.
track,Track of which the type will be set.

Implements ITrackSelector.

Definition at line 183 of file TrackSelector.cpp.

References m_previousMCParticle, m_previousTrackType, and trackType().

00185 {
00186   unsigned int tracktype = TrackKeys::TypeUnknown;
00187   
00188   if ( mcPart == m_previousMCParticle ) {
00189     tracktype = m_previousTrackType;
00190   }
00191   else {
00192     tracktype = trackType( mcPart );
00193   }
00194 
00195   track -> setType ( tracktype );
00196   if ( TrackKeys::TypeUnknown == tracktype ) return StatusCode::FAILURE;
00197   else                                       return StatusCode::SUCCESS;
00198 }

unsigned int TrackSelector::trackType MCParticle *  mcPart  )  [virtual]
 

Get the track type identifyer of the MCParticle.

Returns:
Track type identifyer as defined in TrackKeys.h
Parameters:
mcParticle,Input MCParticle.

Implements ITrackSelector.

Definition at line 152 of file TrackSelector.cpp.

References m_mcParticleJudge, m_previousMCParticle, and m_previousTrackType.

Referenced by selectByTrackType(), and setTrackType().

00153 {
00154   bool hasVelo = m_mcParticleJudge -> hasVelo( mcPart );
00155   bool hasSeed = m_mcParticleJudge -> hasSeed( mcPart );
00156   bool hasTT   = m_mcParticleJudge -> hasTT( mcPart );
00157 
00158   const HepLorentzVector fourMom = mcPart->momentum();
00159 
00160   unsigned int tracktype = TrackKeys::TypeUnknown;
00161 
00162   if ( hasVelo && hasSeed ) {            // long track
00163     tracktype = TrackKeys::Long;
00164   } else if ( hasVelo && hasTT ) {       // upstream track
00165     tracktype = TrackKeys::Upstream;
00166   } else if ( hasSeed && hasTT ) {       // downstream track
00167     tracktype = TrackKeys::Downstream;
00168   } else if ( hasVelo ) {                // velo track
00169     tracktype = TrackKeys::Velo;
00170   } else if ( hasSeed ) {                // seed track
00171     tracktype = TrackKeys::Ttrack;
00172   } 
00173 
00174   m_previousTrackType  = tracktype;
00175   m_previousMCParticle = mcPart;
00176 
00177   return tracktype;
00178 }


Member Data Documentation

double TrackSelector::m_maxP [private]
 

maximum momentum for the tracks

Definition at line 107 of file TrackSelector.h.

Referenced by select(), and TrackSelector().

ITrackReconstructible* TrackSelector::m_mcParticleJudge [private]
 

Pointer to MCParticle judge.

Definition at line 97 of file TrackSelector.h.

Referenced by initialize(), and trackType().

std::string TrackSelector::m_mcParticleJudgeName [private]
 

Name of the tool to decide which MCParticles should have been found.

Definition at line 110 of file TrackSelector.h.

Referenced by initialize(), and TrackSelector().

double TrackSelector::m_minP [private]
 

minimum momentum for the tracks

Definition at line 106 of file TrackSelector.h.

Referenced by TrackSelector().

MCParticle* TrackSelector::m_previousMCParticle [private]
 

Previously requested MCParticle.

Definition at line 101 of file TrackSelector.h.

Referenced by setTrackType(), and trackType().

unsigned int TrackSelector::m_previousTrackType [private]
 

Previous track type identifier.

Definition at line 100 of file TrackSelector.h.

Referenced by setTrackType(), and trackType().

std::vector<int> TrackSelector::m_tracktypes [private]
 

Track types of the monitored tracks

Definition at line 108 of file TrackSelector.h.

Referenced by selectByTrackType(), and TrackSelector().

bool TrackSelector::m_uniqueFlag [private]
 

To monitor unique tracks only.

Definition at line 104 of file TrackSelector.h.

Referenced by selectByTrackType(), and TrackSelector().

bool TrackSelector::m_validFlag [private]
 

To monitor only correctly fitted tracks.

Definition at line 105 of file TrackSelector.h.

Referenced by selectByTrackType(), and TrackSelector().


The documentation for this class was generated from the following files:
Generated on Fri May 27 13:59:48 2005 for New Track Event Model by doxygen 1.4.1