Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:34:39

0001 // Plugin setting the track pointer for TICLCandidates based on Tracksters whose seed ID and seed index refer to a
0002 // track that is or inherits from a reco::Track.
0003 
0004 #include "DataFormats/Math/interface/LorentzVector.h"
0005 #include "FWCore/Framework/interface/ConsumesCollector.h"
0006 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0007 #include "RecoHGCal/TICL/interface/TracksterTrackPluginBase.h"
0008 
0009 namespace ticl {
0010   class TracksterRecoTrackPlugin final : public TracksterTrackPluginBase {
0011   public:
0012     typedef edm::Ptr<reco::Track> TrackPtr;
0013     explicit TracksterRecoTrackPlugin(const edm::ParameterSet&, edm::ConsumesCollector&& iC);
0014     void setTrack(const std::vector<const Trackster*>& tracksters,
0015                   std::vector<TICLCandidate>& ticl_cands,
0016                   edm::Event& event) const override;
0017   };
0018 
0019   TracksterRecoTrackPlugin::TracksterRecoTrackPlugin(const edm::ParameterSet& ps, edm::ConsumesCollector&& ic)
0020       : TracksterTrackPluginBase(ps, std::move(ic)) {}
0021 
0022   void TracksterRecoTrackPlugin::setTrack(const std::vector<const Trackster*>& tracksters,
0023                                           std::vector<TICLCandidate>& ticl_cands,
0024                                           edm::Event& event) const {
0025     auto size = std::min(tracksters.size(), ticl_cands.size());
0026     for (size_t i = 0; i < size; ++i) {
0027       const auto& trackster = *tracksters[i];
0028 
0029       if (trackster.seedIndex() == -1 || !trackster.seedID().isValid()) {
0030         return;  // leave default empty track ref
0031       }
0032 
0033       TrackPtr ptr(trackster.seedID(), trackster.seedIndex(), &event.productGetter());
0034       auto& ticl_cand = ticl_cands[i];
0035       ticl_cand.setTrackPtr(ptr);
0036     }
0037   }
0038 }  // namespace ticl
0039 
0040 #include "FWCore/Framework/interface/MakerMacros.h"
0041 DEFINE_EDM_PLUGIN(TracksterTrackPluginFactory, ticl::TracksterRecoTrackPlugin, "TracksterRecoTrackPlugin");