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