File indexing completed on 2024-04-06 12:19:28
0001 #include "L1Trigger/CSCTrackFinder/plugins/CSCTFTrackProducer.h"
0002
0003 #include <vector>
0004 #include "DataFormats/L1CSCTrackFinder/interface/L1CSCTrackCollection.h"
0005 #include "DataFormats/CSCDigi/interface/CSCCorrelatedLCTDigiCollection.h"
0006 #include "DataFormats/L1CSCTrackFinder/interface/CSCTriggerContainer.h"
0007 #include "DataFormats/L1CSCTrackFinder/interface/TrackStub.h"
0008 #include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambPhContainer.h"
0009 #include "DataFormats/Common/interface/Handle.h"
0010 #include "FWCore/Framework/interface/Event.h"
0011 #include "FWCore/Framework/interface/EventSetup.h"
0012 #include "FWCore/Framework/interface/ESHandle.h"
0013 #include "CondFormats/L1TObjects/interface/L1MuTriggerScales.h"
0014 #include "CondFormats/L1TObjects/interface/L1MuTriggerPtScale.h"
0015
0016 CSCTFTrackProducer::CSCTFTrackProducer(const edm::ParameterSet& pset)
0017 : my_dtrc{},
0018 useDT{pset.getParameter<bool>("useDT")},
0019 TMB07{pset.getParameter<bool>("isTMB07")},
0020 readDtDirect{pset.getParameter<bool>("readDtDirect")},
0021 input_module{
0022 consumes<CSCCorrelatedLCTDigiCollection>(pset.getUntrackedParameter<edm::InputTag>("SectorReceiverInput"))},
0023 dt_producer{consumes<L1MuDTChambPhContainer>(pset.getUntrackedParameter<edm::InputTag>("DTproducer"))},
0024 directProd{
0025 consumes<CSCTriggerContainer<csctf::TrackStub> >(pset.getUntrackedParameter<edm::InputTag>("DtDirectProd"))},
0026 m_scalesToken(esConsumes<L1MuTriggerScales, L1MuTriggerScalesRcd>()),
0027 m_ptScaleToken(esConsumes<L1MuTriggerPtScale, L1MuTriggerPtScaleRcd>()),
0028 m_pDDToken(esConsumes<CSCGeometry, MuonGeometryRecord>()),
0029 sp_pset{pset.getParameter<edm::ParameterSet>("SectorProcessor")},
0030 m_builderTokens(CSCTFTrackBuilder::consumes(sp_pset, consumesCollector())) {
0031 m_scalesCacheID = 0ULL;
0032 m_ptScaleCacheID = 0ULL;
0033 produces<L1CSCTrackCollection>();
0034 produces<CSCTriggerContainer<csctf::TrackStub> >();
0035
0036
0037 usesResource("CSCSectorReceiverLUT");
0038
0039 usesResource("CSCTFSPCoreLogic");
0040
0041 usesResource("CSCTFPtLUT");
0042 }
0043
0044 void CSCTFTrackProducer::produce(edm::Event& e, const edm::EventSetup& c) {
0045
0046
0047 if (c.get<L1MuTriggerScalesRcd>().cacheIdentifier() != m_scalesCacheID ||
0048 c.get<L1MuTriggerPtScaleRcd>().cacheIdentifier() != m_ptScaleCacheID) {
0049 edm::ESHandle<L1MuTriggerScales> scales = c.getHandle(m_scalesToken);
0050
0051 edm::ESHandle<L1MuTriggerPtScale> ptScale = c.getHandle(m_ptScaleToken);
0052
0053 my_builder = std::make_unique<CSCTFTrackBuilder>(sp_pset, TMB07, scales.product(), ptScale.product());
0054 my_builder->initialize(c, m_builderTokens);
0055
0056 m_scalesCacheID = c.get<L1MuTriggerScalesRcd>().cacheIdentifier();
0057 m_ptScaleCacheID = c.get<L1MuTriggerPtScaleRcd>().cacheIdentifier();
0058 }
0059
0060
0061 edm::ESHandle<CSCGeometry> pDD = c.getHandle(m_pDDToken);
0062
0063 edm::Handle<CSCCorrelatedLCTDigiCollection> LCTs;
0064 std::unique_ptr<L1CSCTrackCollection> track_product(new L1CSCTrackCollection);
0065 e.getByToken(input_module, LCTs);
0066 std::unique_ptr<CSCTriggerContainer<csctf::TrackStub> > dt_stubs(new CSCTriggerContainer<csctf::TrackStub>);
0067
0068
0069
0070 CSCTriggerContainer<csctf::TrackStub> emulStub;
0071 if (readDtDirect == false) {
0072 edm::Handle<L1MuDTChambPhContainer> dttrig;
0073 e.getByToken(dt_producer, dttrig);
0074 emulStub = my_dtrc.process(dttrig.product());
0075 } else {
0076 edm::Handle<CSCTriggerContainer<csctf::TrackStub> > stubsFromDaq;
0077
0078 e.getByToken(directProd, stubsFromDaq);
0079 const CSCTriggerContainer<csctf::TrackStub>* stubPointer = stubsFromDaq.product();
0080 emulStub.push_many(*stubPointer);
0081 }
0082
0083 my_builder->buildTracks(LCTs.product(), (useDT ? &emulStub : nullptr), track_product.get(), dt_stubs.get());
0084
0085 e.put(std::move(track_product));
0086 e.put(std::move(dt_stubs));
0087 }