CMS 3D CMS Logo

Public Member Functions | Private Attributes

TrackHistory Class Reference

This class traces the simulated and generated history of a given track. More...

#include <TrackHistory.h>

Inheritance diagram for TrackHistory:
HistoryBase

List of all members.

Public Member Functions

bool evaluate (TrackingParticleRef tpr)
 Evaluate track history using a TrackingParticleRef.
bool evaluate (reco::TrackBaseRef)
 Evaluate reco::Track history using a given association.
void newEvent (const edm::Event &, const edm::EventSetup &)
 Pre-process event information (for accessing reconstruction information)
double quality () const
const reco::TrackBaseRefrecoTrack () const
 Return a reference to the reconstructed track.
 TrackHistory (const edm::ParameterSet &)
 Constructor by pset.

Private Attributes

bool bestMatchByMaxValue_
bool enableRecoToSim_
bool enableSimToReco_
bool newEvent_
double quality_
reco::RecoToSimCollection recoToSim_
reco::TrackBaseRef recotrack_
reco::SimToRecoCollection simToReco_
std::string trackAssociator_
edm::InputTag trackingTruth_
edm::InputTag trackProducer_

Detailed Description

This class traces the simulated and generated history of a given track.

Definition at line 16 of file TrackHistory.h.


Constructor & Destructor Documentation

TrackHistory::TrackHistory ( const edm::ParameterSet config)

Constructor by pset.

Definition at line 6 of file TrackHistory.cc.

References bestMatchByMaxValue_, enableRecoToSim_, enableSimToReco_, edm::ParameterSet::getUntrackedParameter(), quality_, AlCaHLTBitMon_QueryRunRegistry::string, trackAssociator_, trackingTruth_, and trackProducer_.

  : HistoryBase()
{
    // Name of the track collection
    trackProducer_ = config.getUntrackedParameter<edm::InputTag> ( "trackProducer" );

    // Name of the traking pariticle collection
    trackingTruth_ = config.getUntrackedParameter<edm::InputTag> ( "trackingTruth" );

    // Track association record
    trackAssociator_ = config.getUntrackedParameter<std::string> ( "trackAssociator" );

    // Association by max. value
    bestMatchByMaxValue_ = config.getUntrackedParameter<bool> ( "bestMatchByMaxValue" );

    // Enable RecoToSim association
    enableRecoToSim_ = config.getUntrackedParameter<bool> ( "enableRecoToSim" );

    // Enable SimToReco association
    enableSimToReco_ = config.getUntrackedParameter<bool> ( "enableSimToReco" );

    quality_ = 0.;
}

Member Function Documentation

bool TrackHistory::evaluate ( TrackingParticleRef  tpr) [inline]

Evaluate track history using a TrackingParticleRef.

Reimplemented from HistoryBase.

Definition at line 39 of file TrackHistory.h.

References bestMatchByMaxValue_, enableSimToReco_, match(), quality_, recotrack_, query::result, and simToReco_.

Referenced by evaluate(), TrackClassifier::evaluate(), and GenTrackMatcher::produce().

    {
        if ( enableSimToReco_ )
        {
            std::pair<reco::TrackBaseRef, double> result =  match(tpr, simToReco_, bestMatchByMaxValue_);
            recotrack_ = result.first;
            quality_ =  result.second;
        }
        return HistoryBase::evaluate(tpr);
    }
bool TrackHistory::evaluate ( reco::TrackBaseRef  tr)

Evaluate reco::Track history using a given association.

Definition at line 59 of file TrackHistory.cc.

References bestMatchByMaxValue_, enableRecoToSim_, evaluate(), edm::Ref< C, T, F >::isNull(), match(), quality_, recoToSim_, recotrack_, and query::result.

{
    if ( !enableRecoToSim_ ) return false;

    std::pair<TrackingParticleRef, double> result =  match(tr, recoToSim_, bestMatchByMaxValue_);

    TrackingParticleRef tpr( result.first );
    quality_ = result.second;

    if ( !tpr.isNull() )
    {
        HistoryBase::evaluate(tpr);

        recotrack_ = tr;

        return true;
    }

    return false;
}
void TrackHistory::newEvent ( const edm::Event event,
const edm::EventSetup setup 
)

Pre-process event information (for accessing reconstruction information)

Definition at line 32 of file TrackHistory.cc.

References enableRecoToSim_, enableSimToReco_, edm::EventSetup::get(), recoToSim_, simToReco_, ecalTPGAnalyzer_cfg::TPCollection, trackAssociator_, trackingTruth_, and trackProducer_.

Referenced by TrackClassifier::newEvent(), and GenTrackMatcher::produce().

{
    if ( enableRecoToSim_ || enableSimToReco_ )
    {
        // Track collection
        edm::Handle<edm::View<reco::Track> > trackCollection;
        event.getByLabel(trackProducer_, trackCollection);

        // Tracking particle information
        edm::Handle<TrackingParticleCollection>  TPCollection;
        event.getByLabel(trackingTruth_, TPCollection);

        // Get the track associator
        edm::ESHandle<TrackAssociatorBase> associator;
        setup.get<TrackAssociatorRecord>().get(trackAssociator_, associator);

        // Calculate the map between recotracks -> tp
        if ( enableRecoToSim_ ) recoToSim_ = associator->associateRecoToSim(trackCollection, TPCollection, &event, &setup);

        // Calculate the map between recotracks <- tp
        if ( enableSimToReco_ ) simToReco_ = associator->associateSimToReco(trackCollection, TPCollection, &event, &setup);
    }
}
double TrackHistory::quality ( void  ) const [inline]

Definition at line 65 of file TrackHistory.h.

References quality_.

    {
        return quality_;
    }
const reco::TrackBaseRef& TrackHistory::recoTrack ( ) const [inline]

Return a reference to the reconstructed track.

Definition at line 60 of file TrackHistory.h.

References recotrack_.

Referenced by TrackClassifier::evaluate().

    {
        return recotrack_;
    }

Member Data Documentation

Definition at line 74 of file TrackHistory.h.

Referenced by evaluate(), and TrackHistory().

Definition at line 76 of file TrackHistory.h.

Referenced by evaluate(), newEvent(), and TrackHistory().

Definition at line 76 of file TrackHistory.h.

Referenced by evaluate(), newEvent(), and TrackHistory().

bool TrackHistory::newEvent_ [private]

Definition at line 72 of file TrackHistory.h.

double TrackHistory::quality_ [private]

Definition at line 78 of file TrackHistory.h.

Referenced by evaluate(), quality(), and TrackHistory().

Definition at line 88 of file TrackHistory.h.

Referenced by evaluate(), and newEvent().

Definition at line 86 of file TrackHistory.h.

Referenced by evaluate(), and recoTrack().

Definition at line 90 of file TrackHistory.h.

Referenced by evaluate(), and newEvent().

std::string TrackHistory::trackAssociator_ [private]

Definition at line 84 of file TrackHistory.h.

Referenced by newEvent(), and TrackHistory().

Definition at line 82 of file TrackHistory.h.

Referenced by newEvent(), and TrackHistory().

Definition at line 80 of file TrackHistory.h.

Referenced by newEvent(), and TrackHistory().