Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:01:10

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