Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-12-05 02:48:05

0001 #include <alpaka/alpaka.hpp>
0002 
0003 #include "RecoTracker/LSTCore/interface/alpaka/LST.h"
0004 
0005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0006 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0008 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0009 #include "FWCore/Utilities/interface/InputTag.h"
0010 
0011 #include "HeterogeneousCore/AlpakaCore/interface/alpaka/EDGetToken.h"
0012 #include "HeterogeneousCore/AlpakaCore/interface/alpaka/EDPutToken.h"
0013 #include "HeterogeneousCore/AlpakaCore/interface/alpaka/Event.h"
0014 #include "HeterogeneousCore/AlpakaCore/interface/alpaka/EventSetup.h"
0015 #include "HeterogeneousCore/AlpakaCore/interface/alpaka/stream/SynchronizingEDProducer.h"
0016 #include "HeterogeneousCore/AlpakaInterface/interface/config.h"
0017 
0018 #include "RecoTracker/LST/interface/LSTOutput.h"
0019 #include "RecoTracker/LST/interface/LSTPhase2OTHitsInput.h"
0020 #include "RecoTracker/LST/interface/LSTPixelSeedInput.h"
0021 
0022 #include "RecoTracker/Record/interface/TrackerRecoGeometryRecord.h"
0023 
0024 namespace ALPAKA_ACCELERATOR_NAMESPACE {
0025 
0026   class LSTProducer : public stream::SynchronizingEDProducer<> {
0027   public:
0028     LSTProducer(edm::ParameterSet const& config)
0029         : lstPixelSeedInputToken_{consumes(config.getParameter<edm::InputTag>("pixelSeedInput"))},
0030           lstPhase2OTHitsInputToken_{consumes(config.getParameter<edm::InputTag>("phase2OTHitsInput"))},
0031           lstESToken_{esConsumes(edm::ESInputTag("", config.getParameter<std::string>("ptCutLabel")))},
0032           verbose_(config.getParameter<bool>("verbose")),
0033           ptCut_(config.getParameter<double>("ptCut")),
0034           nopLSDupClean_(config.getParameter<bool>("nopLSDupClean")),
0035           tcpLSTriplets_(config.getParameter<bool>("tcpLSTriplets")),
0036           lstOutputToken_{produces()} {}
0037 
0038     void acquire(device::Event const& event, device::EventSetup const& setup) override {
0039       // Inputs
0040       auto const& pixelSeeds = event.get(lstPixelSeedInputToken_);
0041       auto const& phase2OTHits = event.get(lstPhase2OTHitsInputToken_);
0042 
0043       auto const& lstESDeviceData = setup.getData(lstESToken_);
0044 
0045       lst_.run(event.queue(),
0046                verbose_,
0047                static_cast<float>(ptCut_),
0048                &lstESDeviceData,
0049                pixelSeeds.px(),
0050                pixelSeeds.py(),
0051                pixelSeeds.pz(),
0052                pixelSeeds.dxy(),
0053                pixelSeeds.dz(),
0054                pixelSeeds.ptErr(),
0055                pixelSeeds.etaErr(),
0056                pixelSeeds.stateTrajGlbX(),
0057                pixelSeeds.stateTrajGlbY(),
0058                pixelSeeds.stateTrajGlbZ(),
0059                pixelSeeds.stateTrajGlbPx(),
0060                pixelSeeds.stateTrajGlbPy(),
0061                pixelSeeds.stateTrajGlbPz(),
0062                pixelSeeds.q(),
0063                pixelSeeds.hitIdx(),
0064                phase2OTHits.detId(),
0065                phase2OTHits.x(),
0066                phase2OTHits.y(),
0067                phase2OTHits.z(),
0068                nopLSDupClean_,
0069                tcpLSTriplets_);
0070     }
0071 
0072     void produce(device::Event& event, device::EventSetup const&) override {
0073       // Output
0074       LSTOutput lstOutput(lst_.hits(), lst_.len(), lst_.seedIdx(), lst_.trackCandidateType());
0075       event.emplace(lstOutputToken_, std::move(lstOutput));
0076     }
0077 
0078     static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0079       edm::ParameterSetDescription desc;
0080       desc.add<edm::InputTag>("pixelSeedInput", edm::InputTag{"lstPixelSeedInputProducer"});
0081       desc.add<edm::InputTag>("phase2OTHitsInput", edm::InputTag{"lstPhase2OTHitsInputProducer"});
0082       desc.add<bool>("verbose", false);
0083       desc.add<double>("ptCut", 0.8);
0084       desc.add<std::string>("ptCutLabel", "0.8");
0085       desc.add<bool>("nopLSDupClean", false);
0086       desc.add<bool>("tcpLSTriplets", false);
0087       descriptions.addWithDefaultLabel(desc);
0088     }
0089 
0090   private:
0091     edm::EDGetTokenT<LSTPixelSeedInput> lstPixelSeedInputToken_;
0092     edm::EDGetTokenT<LSTPhase2OTHitsInput> lstPhase2OTHitsInputToken_;
0093     device::ESGetToken<lst::LSTESData<Device>, TrackerRecoGeometryRecord> lstESToken_;
0094     const bool verbose_;
0095     const double ptCut_;
0096     const bool nopLSDupClean_;
0097     const bool tcpLSTriplets_;
0098     edm::EDPutTokenT<LSTOutput> lstOutputToken_;
0099 
0100     lst::LST lst_;
0101   };
0102 
0103 }  // namespace ALPAKA_ACCELERATOR_NAMESPACE
0104 
0105 #include "HeterogeneousCore/AlpakaCore/interface/alpaka/MakerMacros.h"
0106 DEFINE_FWK_ALPAKA_MODULE(LSTProducer);