File indexing completed on 2023-03-17 11:14:04
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #ifndef L1_TRACK_TRIGGER_STUB_BUILDER_H
0018 #define L1_TRACK_TRIGGER_STUB_BUILDER_H
0019
0020 #include "FWCore/Framework/interface/Frameworkfwd.h"
0021 #include "FWCore/Framework/interface/one/EDProducer.h"
0022 #include "FWCore/Framework/interface/Event.h"
0023 #include "FWCore/Framework/interface/EventSetup.h"
0024 #include "FWCore/Framework/interface/ESHandle.h"
0025 #include "FWCore/Framework/interface/MakerMacros.h"
0026 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0027 #include "FWCore/Utilities/interface/ESGetToken.h"
0028
0029 #include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h"
0030 #include "Geometry/CommonTopologies/interface/PixelTopology.h"
0031
0032 #include "L1Trigger/TrackTrigger/interface/TTStubAlgorithm.h"
0033 #include "L1Trigger/TrackTrigger/interface/TTStubAlgorithmRecord.h"
0034
0035 #include "DataFormats/Common/interface/DetSetVectorNew.h"
0036
0037 #include <memory>
0038 #include <map>
0039 #include <vector>
0040
0041 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
0042 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0043
0044 template <typename T>
0045 class TTStubBuilder : public edm::one::EDProducer<edm::one::WatchRuns> {
0046 public:
0047
0048 explicit TTStubBuilder(const edm::ParameterSet& iConfig);
0049
0050
0051 ~TTStubBuilder() override;
0052
0053
0054 enum FEreject { CBCFailOffset = 500, CICFailOffset = 1000 };
0055
0056 private:
0057
0058 edm::ESHandle<TTStubAlgorithm<T>> theStubFindingAlgoHandle;
0059 edm::EDGetTokenT<edmNew::DetSetVector<TTCluster<T>>> clustersToken;
0060 edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> tTopoToken;
0061 edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> tGeomToken;
0062 edm::ESGetToken<TTStubAlgorithm<T>, TTStubAlgorithmRecord> ttStubToken;
0063 bool ForbidMultipleStubs;
0064
0065
0066 void beginRun(const edm::Run& run, const edm::EventSetup& iSetup) override;
0067 void endRun(const edm::Run& run, const edm::EventSetup& iSetup) override;
0068 void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override;
0069
0070
0071
0072 static bool SortStubBendPairs(const std::pair<unsigned int, double>& left,
0073 const std::pair<unsigned int, double>& right);
0074 static bool SortStubsBend(const TTStub<T>& left, const TTStub<T>& right);
0075
0076
0077 template <typename TT>
0078 void fill(edmNew::DetSetVector<TT>& outputEP, const DetId& detId, const std::vector<TT>& inputVec) const {
0079
0080 typename edmNew::DetSetVector<TT>::FastFiller outputFiller(outputEP, detId);
0081 outputFiller.resize(inputVec.size());
0082 std::copy(inputVec.begin(), inputVec.end(), outputFiller.begin());
0083 }
0084
0085
0086 void updateStubs(const edm::OrphanHandle<edmNew::DetSetVector<TTCluster<Ref_Phase2TrackerDigi_>>>& clusterHandle,
0087 const edmNew::DetSetVector<TTStub<Ref_Phase2TrackerDigi_>>& inputEDstubs,
0088 edmNew::DetSetVector<TTStub<Ref_Phase2TrackerDigi_>>& outputEDstubs) const;
0089
0090
0091
0092 bool applyFE;
0093
0094
0095 unsigned int maxStubs_2S;
0096 unsigned int maxStubs_PS;
0097 unsigned int maxStubs_2S_CIC_5;
0098 unsigned int maxStubs_PS_CIC_5;
0099 unsigned int maxStubs_PS_CIC_10;
0100
0101
0102
0103
0104
0105 unsigned int high_rate_max_ring[5];
0106 unsigned int high_rate_max_layer;
0107
0108
0109 int ievt;
0110 std::unordered_map<int, std::vector<TTStub<Ref_Phase2TrackerDigi_>>> moduleStubs_CIC;
0111 std::unordered_map<int, int> moduleStubs_MPA;
0112 std::unordered_map<int, int> moduleStubs_CBC;
0113
0114 };
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124 template <typename T>
0125 TTStubBuilder<T>::TTStubBuilder(const edm::ParameterSet& iConfig) {
0126 clustersToken = consumes<edmNew::DetSetVector<TTCluster<T>>>(iConfig.getParameter<edm::InputTag>("TTClusters"));
0127 tTopoToken = esConsumes<TrackerTopology, TrackerTopologyRcd>();
0128 tGeomToken = esConsumes<TrackerGeometry, TrackerDigiGeometryRecord>();
0129 ttStubToken = esConsumes<TTStubAlgorithm<T>, TTStubAlgorithmRecord, edm::Transition::BeginRun>();
0130 ForbidMultipleStubs = iConfig.getParameter<bool>("OnlyOnePerInputCluster");
0131 applyFE = iConfig.getParameter<bool>("FEineffs");
0132 maxStubs_2S = iConfig.getParameter<uint32_t>("CBClimit");
0133 maxStubs_PS = iConfig.getParameter<uint32_t>("MPAlimit");
0134 maxStubs_2S_CIC_5 = iConfig.getParameter<uint32_t>("SS5GCIClimit");
0135 maxStubs_PS_CIC_5 = iConfig.getParameter<uint32_t>("PS5GCIClimit");
0136 maxStubs_PS_CIC_10 = iConfig.getParameter<uint32_t>("PS10GCIClimit");
0137 unsigned int tedd1_max10Gring = iConfig.getParameter<uint32_t>("TEDD1Max10GRing");
0138 unsigned int tedd2_max10Gring = iConfig.getParameter<uint32_t>("TEDD2Max10GRing");
0139 high_rate_max_layer = iConfig.getParameter<uint32_t>("BarrelMax10GLay");
0140
0141 produces<edmNew::DetSetVector<TTCluster<T>>>("ClusterAccepted");
0142 produces<edmNew::DetSetVector<TTCluster<T>>>("ClusterRejected");
0143 produces<edmNew::DetSetVector<TTStub<T>>>("StubAccepted");
0144 produces<edmNew::DetSetVector<TTStub<T>>>("StubRejected");
0145
0146 high_rate_max_ring[0] = tedd1_max10Gring;
0147 high_rate_max_ring[1] = tedd1_max10Gring;
0148 high_rate_max_ring[2] = tedd2_max10Gring;
0149 high_rate_max_ring[3] = tedd2_max10Gring;
0150 high_rate_max_ring[4] = tedd2_max10Gring;
0151 }
0152
0153
0154 template <typename T>
0155 TTStubBuilder<T>::~TTStubBuilder() {}
0156
0157
0158 template <typename T>
0159 void TTStubBuilder<T>::beginRun(const edm::Run& run, const edm::EventSetup& iSetup) {
0160
0161 theStubFindingAlgoHandle = iSetup.getHandle(ttStubToken);
0162 ievt = 0;
0163 moduleStubs_CIC.clear();
0164 moduleStubs_MPA.clear();
0165 moduleStubs_CBC.clear();
0166 }
0167
0168
0169 template <typename T>
0170 void TTStubBuilder<T>::endRun(const edm::Run& run, const edm::EventSetup& iSetup) {}
0171
0172
0173 template <typename T>
0174 bool TTStubBuilder<T>::SortStubBendPairs(const std::pair<unsigned int, double>& left,
0175 const std::pair<unsigned int, double>& right) {
0176 return std::abs(left.second) < std::abs(right.second);
0177 }
0178
0179
0180 template <typename T>
0181 bool TTStubBuilder<T>::SortStubsBend(const TTStub<T>& left, const TTStub<T>& right) {
0182 return std::abs(left.bendFE()) < std::abs(right.bendFE());
0183 }
0184
0185
0186 template <>
0187 void TTStubBuilder<Ref_Phase2TrackerDigi_>::produce(edm::Event& iEvent, const edm::EventSetup& iSetup);
0188
0189 #endif