File indexing completed on 2023-03-17 11:12:54
0001
0002
0003
0004
0005
0006
0007
0008 #include "L1Trigger/L1TMuonOverlapPhase1/interface/Tools/EmulationObserverBase.h"
0009
0010 #include "Math/VectorUtil.h"
0011
0012 EmulationObserverBase::EmulationObserverBase(const edm::ParameterSet& edmCfg, const OMTFConfiguration* omtfConfig)
0013 : edmCfg(edmCfg), omtfConfig(omtfConfig), simMuon(nullptr) {}
0014
0015 EmulationObserverBase::~EmulationObserverBase() {
0016
0017 }
0018
0019 void EmulationObserverBase::observeProcesorEmulation(unsigned int iProcessor,
0020 l1t::tftype mtfType,
0021 const std::shared_ptr<OMTFinput>& input,
0022 const AlgoMuons& algoCandidates,
0023 const AlgoMuons& gbCandidates,
0024 const std::vector<l1t::RegionalMuonCand>& candMuons) {
0025 unsigned int procIndx = omtfConfig->getProcIndx(iProcessor, mtfType);
0026
0027 unsigned int i = 0;
0028 for (auto& gbCandidate : gbCandidates) {
0029 if (gbCandidate->getGoldenPatern() != nullptr &&
0030 gbCandidate->getGpResult().getFiredLayerCnt() > omtfCand->getGpResult().getFiredLayerCnt()) {
0031
0032 omtfCand = gbCandidate;
0033
0034 candProcIndx = procIndx;
0035
0036
0037 regionalMuonCand = candMuons.at(i);
0038
0039
0040 }
0041 i++;
0042 }
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064 }
0065
0066 void EmulationObserverBase::observeEventBegin(const edm::Event& iEvent) {
0067 omtfCand.reset(new AlgoMuon());
0068 candProcIndx = 0xffff;
0069
0070 simMuon = findSimMuon(iEvent);
0071
0072 }
0073
0074 const SimTrack* EmulationObserverBase::findSimMuon(const edm::Event& event, const SimTrack* previous) {
0075 const SimTrack* result = nullptr;
0076 if (edmCfg.exists("simTracksTag") == false)
0077 return result;
0078
0079 edm::Handle<edm::SimTrackContainer> simTks;
0080 event.getByLabel(edmCfg.getParameter<edm::InputTag>("simTracksTag"), simTks);
0081
0082
0083 for (std::vector<SimTrack>::const_iterator it = simTks->begin(); it < simTks->end(); it++) {
0084 const SimTrack& aTrack = *it;
0085 if (!(aTrack.type() == 13 || aTrack.type() == -13))
0086 continue;
0087 if (previous && ROOT::Math::VectorUtil::DeltaR(aTrack.momentum(), previous->momentum()) < 0.07)
0088 continue;
0089 if (!result || aTrack.momentum().pt() > result->momentum().pt())
0090 result = &aTrack;
0091 }
0092 return result;
0093 }