CMS 3D CMS Logo

Public Types | Public Member Functions | Static Public Attributes | Private Attributes | Friends

TrackingParticle Class Reference

Monte Carlo truth information used for tracking validation. More...

#include <TrackingParticle.h>

List of all members.

Public Types

typedef int Charge
 electric charge type
typedef std::vector< SimTrack >
::const_iterator 
g4t_iterator
typedef
reco::GenParticleRefVector::iterator 
genp_iterator
 reference to reco::GenParticle
typedef math::XYZTLorentzVectorD LorentzVector
 Lorentz vector.
typedef math::XYZPointD Point
 point in the space
typedef
math::PtEtaPhiMLorentzVector 
PolarLorentzVector
 Lorentz vector.
typedef math::XYZVectorD Vector
 point in the space

Public Member Functions

void addDecayVertex (const TrackingVertexRef &ref)
void addG4Track (const SimTrack &t)
void addGenParticle (const reco::GenParticleRef &ref)
Vector boostToCM () const
 Vector to boost to the particle centre of mass frame.
int charge () const
 Electric charge. Note this is taken from the first SimTrack only.
void clearDecayVertices ()
void clearParentVertex ()
const TrackingVertexRefVectordecayVertices () const
tv_iterator decayVertices_begin () const
tv_iterator decayVertices_end () const
double energy () const
 Energy. Note this is taken from the first SimTrack only.
double et () const
 Transverse energy. Note this is taken from the first SimTrack only.
double eta () const
 Momentum pseudorapidity. Note this is taken from the first SimTrack only.
EncodedEventId eventId () const
 Signal source, crossing number.
g4t_iterator g4Track_begin () const
g4t_iterator g4Track_end () const
const std::vector< SimTrack > & g4Tracks () const
genp_iterator genParticle_begin () const
 iterators
genp_iterator genParticle_end () const
const reco::GenParticleRefVectorgenParticles () const
bool longLived () const
 is long lived?
double mass () const
 Mass. Note this is taken from the first SimTrack only.
double massSqr () const
 Mass squared. Note this is taken from the first SimTrack only.
int matchedHit () const
Vector momentum () const
 spatial momentum vector
double mt () const
 Transverse mass. Note this is taken from the first SimTrack only.
double mtSqr () const
 Transverse mass squared. Note this is taken from the first SimTrack only.
int numberOfHits () const
 Gives the total number of hits, including muon hits. Hits on overlaps in the same layer count separately.
int numberOfTrackerHits () const
 The number of hits in the tracker. Hits on overlaps in the same layer count separately.
int numberOfTrackerLayers () const
 The number of tracker layers with a hit.
double p () const
 Magnitude of momentum vector. Note this is taken from the first SimTrack only.
const LorentzVectorp4 () const
 Four-momentum Lorentz vector. Note this is taken from the first SimTrack only.
const TrackingVertexRefparentVertex () const
int pdgId () const
 PDG ID.
double phi () const
 Momentum azimuthal angle. Note this is taken from the first SimTrack only.
double pt () const
 Transverse momentum. Note this is taken from the first SimTrack only.
double px () const
 x coordinate of momentum vector. Note this is taken from the first SimTrack only.
double py () const
 y coordinate of momentum vector. Note this is taken from the first SimTrack only.
double pz () const
 z coordinate of momentum vector. Note this is taken from the first SimTrack only.
double rapidity () const
 Rapidity. Note this is taken from the first SimTrack only.
void setNumberOfHits (int numberOfHits)
void setNumberOfTrackerHits (int numberOfTrackerHits)
void setNumberOfTrackerLayers (const int numberOfTrackerLayers)
void setParentVertex (const TrackingVertexRef &ref)
int status () const
 Status word.
double theta () const
 Momentum polar angle. Note this is taken from the first SimTrack only.
int threeCharge () const
 Kept for backwards compatibility. Gives 3*charge(), don't know why.
 TrackingParticle ()
 Default constructor. Note that the object will be useless until it is provided with a SimTrack and parent TrackingVertex.
 TrackingParticle (const SimTrack &simtrk, const TrackingVertexRef &parentVertex)
Point vertex () const
 Parent vertex position.
double vx () const
 x coordinate of parent vertex position
double vy () const
 y coordinate of parent vertex position
double vz () const
 z coordinate of parent vertex position
double y () const
 Same as rapidity().
 ~TrackingParticle ()

Static Public Attributes

static const unsigned int longLivedTag = 65536
 long lived flag

Private Attributes

TrackingVertexRefVector decayVertices_
std::vector< SimTrackg4Tracks_
 references to G4 and reco::GenParticle tracks
reco::GenParticleRefVector genParticles_
int numberOfHits_
 The total number of hits.
int numberOfTrackerHits_
 The number of tracker only hits.
int numberOfTrackerLayers_
 The number of tracker layers with hits. Equivalent to the old matchedHit.
TrackingVertexRef parentVertex_

Friends

std::ostream & operator<< (std::ostream &s, TrackingParticle const &tp)

Detailed Description

Monte Carlo truth information used for tracking validation.

Object with references to the original SimTrack and parent and daughter TrackingVertices. Simulation with high (~100) pileup was taking too much memory so the class was slimmed down and copies of the SimHits were removed.

Author:
original author unknown, re-engineering and slimming by Subir Sarkar (subir.sarkar@cern.ch), some tweaking and documentation by Mark Grimes (mark.grimes@bristol.ac.uk).
Date:
original date unknown, re-engineering Jan-May 2013

Definition at line 29 of file TrackingParticle.h.


Member Typedef Documentation

electric charge type

Definition at line 33 of file TrackingParticle.h.

typedef std::vector<SimTrack>::const_iterator TrackingParticle::g4t_iterator

Definition at line 41 of file TrackingParticle.h.

reference to reco::GenParticle

Definition at line 40 of file TrackingParticle.h.

Lorentz vector.

Definition at line 34 of file TrackingParticle.h.

point in the space

Definition at line 36 of file TrackingParticle.h.

Lorentz vector.

Definition at line 35 of file TrackingParticle.h.

point in the space

Definition at line 37 of file TrackingParticle.h.


Constructor & Destructor Documentation

TrackingParticle::TrackingParticle ( )

Default constructor. Note that the object will be useless until it is provided with a SimTrack and parent TrackingVertex.

Most of the methods assume there is a SimTrack and parent TrackingVertex set, so will either crash or give undefined results if this isn't true. This constructor should only be used to create a placeholder until setParentVertex() and addG4Track() can be called.

Definition at line 10 of file TrackingParticle.cc.

{
        // No operation
}
TrackingParticle::TrackingParticle ( const SimTrack simtrk,
const TrackingVertexRef parentVertex 
)

Definition at line 15 of file TrackingParticle.cc.

References addG4Track(), and setParentVertex().

{
        addG4Track( simtrk );
        setParentVertex( parentVertex );
}
TrackingParticle::~TrackingParticle ( )

Definition at line 21 of file TrackingParticle.cc.

{
}

Member Function Documentation

void TrackingParticle::addDecayVertex ( const TrackingVertexRef ref)

Definition at line 71 of file TrackingParticle.cc.

References decayVertices_, and edm::RefVector< C, T, F >::push_back().

void TrackingParticle::addG4Track ( const SimTrack t)

Definition at line 41 of file TrackingParticle.cc.

References g4Tracks_.

Referenced by TrackingParticle().

{
        g4Tracks_.push_back( t );
}
void TrackingParticle::addGenParticle ( const reco::GenParticleRef ref)

Definition at line 36 of file TrackingParticle.cc.

References genParticles_, and edm::RefVector< C, T, F >::push_back().

TrackingParticle::Vector TrackingParticle::boostToCM ( ) const

Vector to boost to the particle centre of mass frame.

Definition at line 136 of file TrackingParticle.cc.

References p4().

{
        return p4().BoostToCM();
}
int TrackingParticle::charge ( void  ) const
void TrackingParticle::clearDecayVertices ( )

Definition at line 81 of file TrackingParticle.cc.

References edm::RefVector< C, T, F >::clear(), and decayVertices_.

void TrackingParticle::clearParentVertex ( )

Definition at line 76 of file TrackingParticle.cc.

References parentVertex_.

const TrackingVertexRefVector & TrackingParticle::decayVertices ( ) const

Definition at line 101 of file TrackingParticle.cc.

References decayVertices_.

Referenced by operator<<().

{
        return decayVertices_;
}
tv_iterator TrackingParticle::decayVertices_begin ( ) const

Definition at line 106 of file TrackingParticle.cc.

References edm::RefVector< C, T, F >::begin(), and decayVertices_.

Referenced by operator<<().

{
        return decayVertices_.begin();
}
tv_iterator TrackingParticle::decayVertices_end ( ) const

Definition at line 111 of file TrackingParticle.cc.

References decayVertices_, and edm::RefVector< C, T, F >::end().

Referenced by operator<<().

{
        return decayVertices_.end();
}
double TrackingParticle::energy ( void  ) const

Energy. Note this is taken from the first SimTrack only.

Definition at line 146 of file TrackingParticle.cc.

References p4().

{
        return p4().E();
}
double TrackingParticle::et ( ) const

Transverse energy. Note this is taken from the first SimTrack only.

Definition at line 151 of file TrackingParticle.cc.

References p4().

{
        return p4().Et();
}
double TrackingParticle::eta ( void  ) const

Momentum pseudorapidity. Note this is taken from the first SimTrack only.

Definition at line 206 of file TrackingParticle.cc.

References p4().

Referenced by RecoMuonValidator::MuonME::fill(), and ShallowSimTracksProducer::produce().

{
        return p4().Eta();
}
EncodedEventId TrackingParticle::eventId ( ) const

Signal source, crossing number.

Note this is taken from the first SimTrack only, but there shouldn't be any SimTracks from different crossings in the TrackingParticle.

Definition at line 31 of file TrackingParticle.cc.

References g4Tracks_.

Referenced by MultiTrackValidator::analyze(), TrackerSeedValidator::analyze(), TrackingParticleSelector::operator()(), and operator<<().

{
        return g4Tracks_.at( 0 ).eventId();
}
TrackingParticle::g4t_iterator TrackingParticle::g4Track_begin ( ) const

Definition at line 56 of file TrackingParticle.cc.

References g4Tracks_.

Referenced by operator<<(), and QuickTrackAssociatorByHits::trackingParticleContainsIdentifier().

{
        return g4Tracks_.begin();
}
TrackingParticle::g4t_iterator TrackingParticle::g4Track_end ( ) const

Definition at line 61 of file TrackingParticle.cc.

References g4Tracks_.

Referenced by operator<<(), and QuickTrackAssociatorByHits::trackingParticleContainsIdentifier().

{
        return g4Tracks_.end();
}
const std::vector< SimTrack > & TrackingParticle::g4Tracks ( ) const

Definition at line 91 of file TrackingParticle.cc.

References g4Tracks_.

{
        return g4Tracks_;
}
TrackingParticle::genp_iterator TrackingParticle::genParticle_begin ( ) const

iterators

Definition at line 46 of file TrackingParticle.cc.

References edm::RefVector< C, T, F >::begin(), and genParticles_.

Referenced by TrackingParticleSelector::operator()(), and operator<<().

{
        return genParticles_.begin();
}
TrackingParticle::genp_iterator TrackingParticle::genParticle_end ( ) const

Definition at line 51 of file TrackingParticle.cc.

References edm::RefVector< C, T, F >::end(), and genParticles_.

Referenced by TrackingParticleSelector::operator()(), and operator<<().

{
        return genParticles_.end();
}
const reco::GenParticleRefVector & TrackingParticle::genParticles ( ) const

Definition at line 86 of file TrackingParticle.cc.

References genParticles_.

{
        return genParticles_;
}
bool TrackingParticle::longLived ( ) const

is long lived?

Definition at line 250 of file TrackingParticle.cc.

References longLivedTag, and status().

{
        return status()&longLivedTag;
}
double TrackingParticle::mass ( ) const

Mass. Note this is taken from the first SimTrack only.

Definition at line 156 of file TrackingParticle.cc.

References p4().

Referenced by massSqr().

{
        return p4().M();
}
double TrackingParticle::massSqr ( ) const

Mass squared. Note this is taken from the first SimTrack only.

Definition at line 161 of file TrackingParticle.cc.

References mass(), and funct::pow().

{
        return pow( mass(), 2 );
}
int TrackingParticle::matchedHit ( ) const

Definition at line 265 of file TrackingParticle.cc.

References numberOfTrackerLayers_.

{
        edm::LogWarning("TrackingParticle") << "The method matchedHit() has been deprecated. Use numberOfTrackerLayers() instead.";
        return numberOfTrackerLayers_;
}
TrackingParticle::Vector TrackingParticle::momentum ( ) const
double TrackingParticle::mt ( ) const

Transverse mass. Note this is taken from the first SimTrack only.

Definition at line 166 of file TrackingParticle.cc.

References p4().

{
        return p4().Mt();
}
double TrackingParticle::mtSqr ( ) const

Transverse mass squared. Note this is taken from the first SimTrack only.

Definition at line 171 of file TrackingParticle.cc.

References p4().

{
        return p4().Mt2();
}
int TrackingParticle::numberOfHits ( void  ) const

Gives the total number of hits, including muon hits. Hits on overlaps in the same layer count separately.

Equivalent to trackPSimHit().size() in the old TrackingParticle implementation.

Definition at line 255 of file TrackingParticle.cc.

References numberOfHits_.

Referenced by QuickTrackAssociatorByHits::associateTrack(), and setNumberOfHits().

{
    return numberOfHits_;
}
int TrackingParticle::numberOfTrackerHits ( ) const

The number of hits in the tracker. Hits on overlaps in the same layer count separately.

Equivalent to trackPSimHit(DetId::Tracker).size() in the old TrackingParticle implementation.

Definition at line 260 of file TrackingParticle.cc.

References numberOfTrackerHits_.

Referenced by MultiTrackValidator::analyze(), and setNumberOfTrackerHits().

int TrackingParticle::numberOfTrackerLayers ( ) const

The number of tracker layers with a hit.

Different from numberOfTrackerHits because this method counts multiple hits on overlaps in the layer as one hit.

Definition at line 271 of file TrackingParticle.cc.

References numberOfTrackerLayers_.

Referenced by TrackingParticleSelector::operator()(), and setNumberOfTrackerLayers().

double TrackingParticle::p ( ) const

Magnitude of momentum vector. Note this is taken from the first SimTrack only.

Definition at line 141 of file TrackingParticle.cc.

References p4().

Referenced by RecoMuonValidator::MuonME::fill(), and ShallowSimTracksProducer::produce().

{
        return p4().P();
}
const TrackingParticle::LorentzVector & TrackingParticle::p4 ( ) const

Four-momentum Lorentz vector. Note this is taken from the first SimTrack only.

Definition at line 126 of file TrackingParticle.cc.

References g4Tracks_.

Referenced by boostToCM(), MuonMCClassifier::convertAndPush(), energy(), et(), eta(), mass(), momentum(), mt(), mtSqr(), operator<<(), p(), phi(), pt(), px(), py(), pz(), rapidity(), and theta().

{
        return g4Tracks_.at( 0 ).momentum();
}
const TrackingVertexRef & TrackingParticle::parentVertex ( ) const
int TrackingParticle::pdgId ( ) const

PDG ID.

Returns the PDG ID of the first associated gen particle. If there are no gen particles associated then it returns type() from the first SimTrack.

Definition at line 25 of file TrackingParticle.cc.

References edm::RefVector< C, T, F >::begin(), edm::RefVector< C, T, F >::empty(), g4Tracks_, and genParticles_.

Referenced by V0Validator::analyze(), MuonMCClassifier::convertAndPush(), TrackingParticleSelector::operator()(), operator<<(), and ShallowSimTracksProducer::produce().

{
        if( genParticles_.empty() ) return g4Tracks_.at( 0 ).type();
        else return (*genParticles_.begin())->pdgId();
}
double TrackingParticle::phi ( void  ) const

Momentum azimuthal angle. Note this is taken from the first SimTrack only.

Definition at line 196 of file TrackingParticle.cc.

References p4().

Referenced by RecoMuonValidator::MuonME::fill(), and ShallowSimTracksProducer::produce().

{
        return p4().Phi();
}
double TrackingParticle::pt ( ) const

Transverse momentum. Note this is taken from the first SimTrack only.

Definition at line 191 of file TrackingParticle.cc.

References p4().

Referenced by RecoMuonValidator::MuonME::fill(), and ShallowSimTracksProducer::produce().

{
        return p4().Pt();
}
double TrackingParticle::px ( ) const

x coordinate of momentum vector. Note this is taken from the first SimTrack only.

Definition at line 176 of file TrackingParticle.cc.

References p4().

Referenced by FWTrackingParticleProxyBuilder::build().

{
        return p4().Px();
}
double TrackingParticle::py ( ) const

y coordinate of momentum vector. Note this is taken from the first SimTrack only.

Definition at line 181 of file TrackingParticle.cc.

References p4().

Referenced by FWTrackingParticleProxyBuilder::build().

{
        return p4().Py();
}
double TrackingParticle::pz ( ) const

z coordinate of momentum vector. Note this is taken from the first SimTrack only.

Definition at line 186 of file TrackingParticle.cc.

References p4().

Referenced by FWTrackingParticleProxyBuilder::build().

{
        return p4().Pz();
}
double TrackingParticle::rapidity ( ) const

Rapidity. Note this is taken from the first SimTrack only.

Definition at line 211 of file TrackingParticle.cc.

References p4().

Referenced by y().

{
        return p4().Rapidity();
}
void TrackingParticle::setNumberOfHits ( int  numberOfHits)

Definition at line 276 of file TrackingParticle.cc.

References numberOfHits(), and numberOfHits_.

void TrackingParticle::setNumberOfTrackerHits ( int  numberOfTrackerHits)
void TrackingParticle::setNumberOfTrackerLayers ( const int  numberOfTrackerLayers)
void TrackingParticle::setParentVertex ( const TrackingVertexRef ref)

Definition at line 66 of file TrackingParticle.cc.

References parentVertex_.

Referenced by TrackingParticle().

{
        parentVertex_=ref;
}
int TrackingParticle::status ( void  ) const

Status word.

Returns status() from the first gen particle, or -99 if there are no gen particles attached.

Definition at line 244 of file TrackingParticle.cc.

References edm::RefVector< C, T, F >::begin(), edm::RefVector< C, T, F >::empty(), and genParticles_.

Referenced by MuonMCClassifier::convertAndPush(), longLived(), and TrackingParticleSelector::operator()().

{
        if( genParticles_.empty() ) return -99; // Use the old invalid status flag that used to be set by TrackingTruthProducer.
        else return (*genParticles_.begin())->status();
}
double TrackingParticle::theta ( void  ) const

Momentum polar angle. Note this is taken from the first SimTrack only.

Definition at line 201 of file TrackingParticle.cc.

References p4().

Referenced by ShallowSimTracksProducer::produce().

{
        return p4().Theta();
}
int TrackingParticle::threeCharge ( ) const

Kept for backwards compatibility. Gives 3*charge(), don't know why.

Definition at line 121 of file TrackingParticle.cc.

References g4Tracks_.

{
        return g4Tracks_.at( 0 ).charge()*3;
}
TrackingParticle::Point TrackingParticle::vertex ( ) const
double TrackingParticle::vx ( ) const

x coordinate of parent vertex position

Definition at line 226 of file TrackingParticle.cc.

References TrackingVertex::position(), and alignCSCRings::r.

Referenced by FWTrackingParticleProxyBuilder::build(), and vertex().

{
        const TrackingVertex& r=( *parentVertex_);
        return r.position().X();
}
double TrackingParticle::vy ( ) const

y coordinate of parent vertex position

Definition at line 232 of file TrackingParticle.cc.

References TrackingVertex::position(), and alignCSCRings::r.

Referenced by FWTrackingParticleProxyBuilder::build(), and vertex().

{
        const TrackingVertex& r=( *parentVertex_);
        return r.position().Y();
}
double TrackingParticle::vz ( ) const

z coordinate of parent vertex position

Definition at line 238 of file TrackingParticle.cc.

References TrackingVertex::position(), and alignCSCRings::r.

Referenced by FWTrackingParticleProxyBuilder::build(), and vertex().

{
        const TrackingVertex& r=( *parentVertex_);
        return r.position().Z();
}
double TrackingParticle::y ( ) const

Same as rapidity().

Definition at line 216 of file TrackingParticle.cc.

References rapidity().

{
        return rapidity();
}

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  s,
TrackingParticle const &  tp 
) [friend]

Concrete TrackingParticle. All track parameters are passed in the constructor and stored internally.

Definition at line 12 of file TrackingDataPrint.h.

{

    // Compare momenta from sources
    s << "T.P.   Track Momentum, q , ID, & Event # "
    << tp.p4()    << " " << tp.charge() << " "
    << tp.pdgId() << " "
    << tp.eventId().bunchCrossing() << "." << tp.eventId().event()
    << std::endl;
    s << " Hits for this track: " << tp.trackPSimHit().size()
    << std::endl;

    for (TrackingParticle::genp_iterator hepT = tp.genParticle_begin();
            hepT !=  tp.genParticle_end(); ++hepT)
    {
        s << " HepMC Track Momentum " << (*hepT)->momentum().mag() << std::endl;
    }
    for (TrackingParticle::g4t_iterator g4T = tp.g4Track_begin();
            g4T !=  tp.g4Track_end(); ++g4T)
    {
        s << " Geant Track Momentum  " << g4T->momentum() << std::endl;
        s << " Geant Track ID & type " << g4T->trackId() << " "
        << g4T->type() << std::endl;
        if (g4T->type() !=  tp.pdgId())
        {
            s << " Mismatch b/t TrackingParticle and Geant types"
            << std::endl;
        }
    }
    return s;
}

Member Data Documentation

std::vector<SimTrack> TrackingParticle::g4Tracks_ [private]

references to G4 and reco::GenParticle tracks

Definition at line 156 of file TrackingParticle.h.

Referenced by addG4Track(), charge(), eventId(), g4Track_begin(), g4Track_end(), g4Tracks(), p4(), pdgId(), and threeCharge().

const unsigned int TrackingParticle::longLivedTag = 65536 [static]

long lived flag

Definition at line 125 of file TrackingParticle.h.

Referenced by longLived().

The total number of hits.

Definition at line 151 of file TrackingParticle.h.

Referenced by numberOfHits(), and setNumberOfHits().

The number of tracker only hits.

Definition at line 152 of file TrackingParticle.h.

Referenced by numberOfTrackerHits(), and setNumberOfTrackerHits().

The number of tracker layers with hits. Equivalent to the old matchedHit.

Definition at line 153 of file TrackingParticle.h.

Referenced by matchedHit(), numberOfTrackerLayers(), and setNumberOfTrackerLayers().

Definition at line 160 of file TrackingParticle.h.

Referenced by clearParentVertex(), parentVertex(), and setParentVertex().