Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:50:04

0001 #include "CommonTools/RecoAlgos/interface/TrackSelector.h"
0002 
0003 using namespace reco;
0004 
0005 namespace helper {
0006 
0007   TrackCollectionStoreManager::TrackCollectionStoreManager(const edm::Handle<reco::TrackCollection>&)
0008       : selTracks_(new reco::TrackCollection),
0009         selTrackExtras_(new reco::TrackExtraCollection),
0010         selHits_(new TrackingRecHitCollection),
0011         selStripClusters_(new edmNew::DetSetVector<SiStripCluster>),
0012         selPixelClusters_(new edmNew::DetSetVector<SiPixelCluster>),
0013         rTracks_(),
0014         rTrackExtras_(),
0015         rHits_(),
0016         clusterStorer_(),
0017         idx_(0),
0018         hidx_(0),
0019         cloneClusters_(true) {}
0020 
0021   //------------------------------------------------------------------
0022   //!  Process a single track.
0023   //------------------------------------------------------------------
0024   void TrackCollectionStoreManager::processTrack(const Track& trk) {
0025     selTracks_->push_back(Track(trk));
0026     selTracks_->back().setExtra(TrackExtraRef(rTrackExtras_, idx_++));
0027     selTrackExtras_->push_back(TrackExtra(trk.outerPosition(),
0028                                           trk.outerMomentum(),
0029                                           trk.outerOk(),
0030                                           trk.innerPosition(),
0031                                           trk.innerMomentum(),
0032                                           trk.innerOk(),
0033                                           trk.outerStateCovariance(),
0034                                           trk.outerDetId(),
0035                                           trk.innerStateCovariance(),
0036                                           trk.innerDetId(),
0037                                           trk.seedDirection()));
0038     TrackExtra& tx = selTrackExtras_->back();
0039     auto const firstHitIndex = hidx_;
0040     unsigned int nHitsAdded = 0;
0041     for (trackingRecHit_iterator hit = trk.recHitsBegin(); hit != trk.recHitsEnd(); ++hit, ++hidx_) {
0042       selHits_->push_back((*hit)->clone());
0043       TrackingRecHit* newHit = &(selHits_->back());
0044       ++nHitsAdded;
0045 
0046       //--- Skip the rest for this hit if we don't want to clone the cluster.
0047       //--- The copy constructer in the rec hit will copy the link properly.
0048       if (cloneClusters() && newHit->isValid() && ((*hit)->geographicalId().det() == DetId::Tracker)) {
0049         clusterStorer_.addCluster(*selHits_, hidx_);
0050       }
0051     }  // end of for loop over tracking rec hits on this track
0052     tx.setHits(rHits_, firstHitIndex, nHitsAdded);
0053 
0054   }  // end of track, and function
0055 
0056   //------------------------------------------------------------------
0057   //!  Put tracks, track extras and hits+clusters into the event.
0058   //------------------------------------------------------------------
0059   edm::OrphanHandle<reco::TrackCollection> TrackCollectionStoreManager::put(edm::Event& evt) {
0060     edm::OrphanHandle<reco::TrackCollection> h = evt.put(std::move(selTracks_));
0061     evt.put(std::move(selTrackExtras_));
0062     evt.put(std::move(selHits_));
0063     evt.put(std::move(selStripClusters_));
0064     evt.put(std::move(selPixelClusters_));
0065     return h;
0066   }
0067 
0068 }  // end of namespace helper