CMS 3D CMS Logo

Public Types | Public Member Functions | Private Member Functions | Private Attributes

helper::TrackCollectionStoreManager Struct Reference

Class to manage copying of RecHits and Clusters from Tracks. More...

#include <TrackSelector.h>

List of all members.

Public Types

typedef reco::TrackCollection collection

Public Member Functions

template<typename I >
void cloneAndStore (const I &begin, const I &end, edm::Event &evt)
 Method to clone tracks, track extras and their hits and clusters. typename I = this is an interator over a track collection, **I needs to dereference into a Track.
bool cloneClusters ()
edm::OrphanHandle
< reco::TrackCollection
put (edm::Event &evt)
 Put tracks, track extras and hits+clusters into the event.
void setCloneClusters (bool w)
size_t size () const
 Get the size.
 TrackCollectionStoreManager (const edm::Handle< reco::TrackCollection > &)

Private Member Functions

void processTrack (const reco::Track &trk)
 Process a single track.

Private Attributes

bool cloneClusters_
 Clone clusters, or not? Default: true.
ClusterStorer clusterStorer_
size_t hidx_
 index to tracking rec hits
size_t idx_
 index to track extra coll
TrackingRecHitRefProd rHits_
reco::TrackExtraRefProd rTrackExtras_
reco::TrackRefProd rTracks_
std::auto_ptr
< TrackingRecHitCollection
selHits_
std::auto_ptr
< edmNew::DetSetVector
< SiPixelCluster > > 
selPixelClusters_
std::auto_ptr
< edmNew::DetSetVector
< SiStripCluster > > 
selStripClusters_
std::auto_ptr
< reco::TrackExtraCollection
selTrackExtras_
std::auto_ptr
< reco::TrackCollection
selTracks_

Detailed Description

Class to manage copying of RecHits and Clusters from Tracks.

Definition at line 33 of file TrackSelector.h.


Member Typedef Documentation

Definition at line 35 of file TrackSelector.h.


Constructor & Destructor Documentation

helper::TrackCollectionStoreManager::TrackCollectionStoreManager ( const edm::Handle< reco::TrackCollection > &  )

Member Function Documentation

template<typename I >
void helper::TrackCollectionStoreManager::cloneAndStore ( const I &  begin,
const I &  end,
edm::Event evt 
)

Method to clone tracks, track extras and their hits and clusters. typename I = this is an interator over a track collection, **I needs to dereference into a Track.

< index to track extra coll

< index to tracking rec hits

Definition at line 101 of file TrackSelector.h.

References helper::ClusterStorer::clear(), clusterStorer_, end, hidx_, Exhume::I, i, idx_, helper::ClusterStorer::processAllClusters(), processTrack(), dt_offlineAnalysis_common_cff::reco, rHits_, rTrackExtras_, rTracks_, selPixelClusters_, and selStripClusters_.

  {
      using namespace reco;

      rTracks_       = evt.template getRefBeforePut<TrackCollection>();      
      rTrackExtras_  = evt.template getRefBeforePut<TrackExtraCollection>();
      rHits_         = evt.template getRefBeforePut<TrackingRecHitCollection>();
      //--- New: save clusters too
      edm::RefProd<edmNew::DetSetVector<SiPixelCluster> > rPixelClusters
        = evt.template getRefBeforePut<edmNew::DetSetVector<SiPixelCluster> >();
      edm::RefProd<edmNew::DetSetVector<SiStripCluster> > rStripClusters 
        = evt.template getRefBeforePut<edmNew::DetSetVector<SiStripCluster> >();

      //--- Indices into collections handled with RefProd
      idx_ = 0;         
      hidx_ = 0;        
      clusterStorer_.clear();

      //--- Loop over tracks
      for( I i = begin; i != end; ++ i ) {
          //--- Whatever type the iterator i is, deref to reco::Track &
          const reco::Track & trk = * * i;
          //--- Clone this track, and store references aside
          processTrack( trk );
      }
      //--- Clone the clusters and fixup refs
      clusterStorer_.processAllClusters(*selPixelClusters_, rPixelClusters,
                                        *selStripClusters_, rStripClusters);
  }
bool helper::TrackCollectionStoreManager::cloneClusters ( ) [inline]

Use these to turn off/on the cloning of clusters. The default is to clone them. To not clone (and save space in a quick local job, do: setCloneClusters(false);

Definition at line 45 of file TrackSelector.h.

References cloneClusters_.

Referenced by processTrack().

{return cloneClusters_ ; } 
void helper::TrackCollectionStoreManager::processTrack ( const reco::Track trk) [private]

Process a single track.

Definition at line 29 of file TrackSelector.cc.

References reco::TrackExtraBase::add(), helper::ClusterStorer::addCluster(), cloneClusters(), clusterStorer_, hidx_, idx_, reco::Track::innerDetId(), reco::Track::innerMomentum(), reco::Track::innerOk(), reco::Track::innerPosition(), reco::Track::innerStateCovariance(), TrackingRecHit::isValid(), reco::Track::outerDetId(), reco::Track::outerMomentum(), reco::Track::outerOk(), reco::Track::outerPosition(), reco::Track::outerStateCovariance(), reco::Track::recHitsBegin(), reco::Track::recHitsEnd(), rHits_, rTrackExtras_, reco::Track::seedDirection(), selHits_, selTrackExtras_, selTracks_, and align::Tracker.

Referenced by cloneAndStore().

  {
    selTracks_->push_back( Track( trk ) );
    selTracks_->back().setExtra( TrackExtraRef( rTrackExtras_, idx_ ++ ) );
    selTrackExtras_->push_back( TrackExtra( trk.outerPosition(), trk.outerMomentum(), trk.outerOk(),
                                            trk.innerPosition(), trk.innerMomentum(), trk.innerOk(),
                                            trk.outerStateCovariance(), trk.outerDetId(),
                                            trk.innerStateCovariance(), trk.innerDetId(),
                                            trk.seedDirection() ) );
    TrackExtra & tx = selTrackExtras_->back();
    for( trackingRecHit_iterator hit = trk.recHitsBegin(); hit != trk.recHitsEnd();
         ++ hit, ++ hidx_ ) {

        selHits_->push_back( (*hit)->clone() );
        TrackingRecHit * newHit = & (selHits_->back());
        tx.add( TrackingRecHitRef( rHits_, hidx_ ) );

        //--- Skip the rest for this hit if we don't want to clone the cluster.
        //--- The copy constructer in the rec hit will copy the link properly.
        if (cloneClusters() && newHit->isValid()
            && ((*hit)->geographicalId().det() == DetId::Tracker)) {
          clusterStorer_.addCluster( *selHits_, hidx_ );
        }
    } // end of for loop over tracking rec hits on this track
  } // end of track, and function
edm::OrphanHandle< reco::TrackCollection > helper::TrackCollectionStoreManager::put ( edm::Event evt)

Put tracks, track extras and hits+clusters into the event.

Definition at line 61 of file TrackSelector.cc.

References h, edm::Event::put(), selHits_, selPixelClusters_, selStripClusters_, selTrackExtras_, and selTracks_.

void helper::TrackCollectionStoreManager::setCloneClusters ( bool  w) [inline]

Definition at line 46 of file TrackSelector.h.

References cloneClusters_.

{ cloneClusters_ = w; }
size_t helper::TrackCollectionStoreManager::size ( void  ) const [inline]

Get the size.

Definition at line 56 of file TrackSelector.h.

References selTracks_.

{ return selTracks_->size(); }

Member Data Documentation

Clone clusters, or not? Default: true.

Definition at line 88 of file TrackSelector.h.

Referenced by cloneClusters(), and setCloneClusters().

Helper to treat copies of selected clusters and make the hits refer to the output cluster collections:

Definition at line 81 of file TrackSelector.h.

Referenced by cloneAndStore(), and processTrack().

index to tracking rec hits

Definition at line 85 of file TrackSelector.h.

Referenced by cloneAndStore(), and processTrack().

index to track extra coll

Definition at line 84 of file TrackSelector.h.

Referenced by cloneAndStore(), and processTrack().

Definition at line 78 of file TrackSelector.h.

Referenced by cloneAndStore(), and processTrack().

Definition at line 77 of file TrackSelector.h.

Referenced by cloneAndStore(), and processTrack().

Definition at line 76 of file TrackSelector.h.

Referenced by cloneAndStore().

Definition at line 71 of file TrackSelector.h.

Referenced by processTrack(), and put().

Definition at line 73 of file TrackSelector.h.

Referenced by cloneAndStore(), and put().

Definition at line 72 of file TrackSelector.h.

Referenced by cloneAndStore(), and put().

Definition at line 70 of file TrackSelector.h.

Referenced by processTrack(), and put().

Definition at line 69 of file TrackSelector.h.

Referenced by processTrack(), put(), and size().