File indexing completed on 2024-04-06 12:21:44
0001 #include "FWCore/Framework/interface/stream/EDProducer.h"
0002 #include "FWCore/Framework/interface/Run.h"
0003 #include "FWCore/Framework/interface/EventSetup.h"
0004 #include "FWCore/Framework/interface/Event.h"
0005 #include "FWCore/Framework/interface/MakerMacros.h"
0006 #include "FWCore/Utilities/interface/EDGetToken.h"
0007 #include "FWCore/Utilities/interface/EDPutToken.h"
0008 #include "FWCore/Utilities/interface/ESGetToken.h"
0009 #include "FWCore/Utilities/interface/InputTag.h"
0010 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0011 #include "DataFormats/Common/interface/Handle.h"
0012
0013 #include "DataFormats/L1TrackTrigger/interface/TTTypes.h"
0014 #include "L1Trigger/TrackTrigger/interface/Setup.h"
0015 #include "L1Trigger/TrackerTFP/interface/DataFormats.h"
0016 #include "L1Trigger/TrackerTFP/interface/HoughTransform.h"
0017
0018 #include <string>
0019 #include <numeric>
0020
0021 using namespace std;
0022 using namespace edm;
0023 using namespace tt;
0024
0025 namespace trackerTFP {
0026
0027
0028
0029
0030
0031
0032 class ProducerHT : public stream::EDProducer<> {
0033 public:
0034 explicit ProducerHT(const ParameterSet&);
0035 ~ProducerHT() override {}
0036
0037 private:
0038 void beginRun(const Run&, const EventSetup&) override;
0039 void produce(Event&, const EventSetup&) override;
0040 virtual void endJob() {}
0041
0042
0043 EDGetTokenT<StreamsStub> edGetToken_;
0044
0045 EDPutTokenT<StreamsStub> edPutTokenAccepted_;
0046
0047 EDPutTokenT<StreamsStub> edPutTokenLost_;
0048
0049 ESGetToken<Setup, SetupRcd> esGetTokenSetup_;
0050
0051 ESGetToken<DataFormats, DataFormatsRcd> esGetTokenDataFormats_;
0052
0053 ParameterSet iConfig_;
0054
0055 const Setup* setup_ = nullptr;
0056
0057 const DataFormats* dataFormats_ = nullptr;
0058 };
0059
0060 ProducerHT::ProducerHT(const ParameterSet& iConfig) : iConfig_(iConfig) {
0061 const string& label = iConfig.getParameter<string>("LabelGP");
0062 const string& branchAccepted = iConfig.getParameter<string>("BranchAcceptedStubs");
0063 const string& branchLost = iConfig.getParameter<string>("BranchLostStubs");
0064
0065 edGetToken_ = consumes<StreamsStub>(InputTag(label, branchAccepted));
0066 edPutTokenAccepted_ = produces<StreamsStub>(branchAccepted);
0067 edPutTokenLost_ = produces<StreamsStub>(branchLost);
0068
0069 esGetTokenSetup_ = esConsumes<Setup, SetupRcd, Transition::BeginRun>();
0070 esGetTokenDataFormats_ = esConsumes<DataFormats, DataFormatsRcd, Transition::BeginRun>();
0071 }
0072
0073 void ProducerHT::beginRun(const Run& iRun, const EventSetup& iSetup) {
0074
0075 setup_ = &iSetup.getData(esGetTokenSetup_);
0076 if (!setup_->configurationSupported())
0077 return;
0078
0079 if (iConfig_.getParameter<bool>("CheckHistory"))
0080 setup_->checkHistory(iRun.processHistory());
0081
0082 dataFormats_ = &iSetup.getData(esGetTokenDataFormats_);
0083 }
0084
0085 void ProducerHT::produce(Event& iEvent, const EventSetup& iSetup) {
0086
0087 StreamsStub accepted(dataFormats_->numStreams(Process::ht));
0088 StreamsStub lost(dataFormats_->numStreams(Process::ht));
0089
0090 if (setup_->configurationSupported()) {
0091 Handle<StreamsStub> handle;
0092 iEvent.getByToken<StreamsStub>(edGetToken_, handle);
0093 const StreamsStub& streams = *handle.product();
0094 for (int region = 0; region < setup_->numRegions(); region++) {
0095
0096 HoughTransform ht(iConfig_, setup_, dataFormats_, region);
0097
0098 ht.consume(streams);
0099
0100 ht.produce(accepted, lost);
0101 }
0102 }
0103
0104 iEvent.emplace(edPutTokenAccepted_, std::move(accepted));
0105 iEvent.emplace(edPutTokenLost_, std::move(lost));
0106 }
0107
0108 }
0109
0110 DEFINE_FWK_MODULE(trackerTFP::ProducerHT);