From 6623bc07a8b07138bec5e63238975ce4cfe08df8 Mon Sep 17 00:00:00 2001 From: Karol Bunkowski Date: Wed, 18 Aug 2021 23:17:53 +0200 Subject: [PATCH] using unique_ptr for the GoldenPatternVec and many other changes combination of 4 commits: 1) GoldenPatternVec = std::vector > OMTFReconstruction::beginRun modified to adapted to the GoldenPatternVec and other changes added calss EmulationObserverBase PatternOptimizerBase::observeProcesorEmulation and findSimMuon moved there DataROOTDumper2 inherits from EmulationObserverBase, removing omtfGpResultsPdfSum and omtfGpResultsFiredLayers from OmtfEvent, removing gpResultsToPt removing DataROOTDumper EventCapture - goldenPatterns is pointer now removed OMTFSorterWithThreshold removed PatternsPtAssignment ProcessorBase::setGPs removed, code moved to constructor 2) added L1T_OmtfP1_ prefix in the include guards in header files 3) using ESWatcher in the OMTFReconstruction to prevent the patterns re-creation every run start (if the patterns are created from the EventSetup, and not directly from the xml) 4) L1TMuonOverlapPhase1TrackProducer inherits from edm::one::EDProducer with edm::one::WatchRuns customization --- .../interface/AlgoMuonBase.h | 6 +- .../interface/AngleConverterBase.h | 4 +- .../L1TMuonOverlapPhase1/interface/MuonStub.h | 6 +- .../interface/MuonStubMakerBase.h | 4 +- .../interface/MuonStubsInput.h | 6 +- .../interface/Omtf/AlgoMuon.h | 6 +- .../interface/Omtf/GhostBuster.h | 4 +- .../interface/Omtf/GhostBusterPreferRefDt.h | 4 +- .../interface/Omtf/GoldenPattern.h | 4 +- .../interface/Omtf/GoldenPatternBase.h | 7 +- .../interface/Omtf/GoldenPatternResult.h | 6 +- .../interface/Omtf/GoldenPatternWithStat.h | 4 +- .../interface/Omtf/IGhostBuster.h | 6 +- .../interface/Omtf/IOMTFEmulationObserver.h | 6 +- .../interface/Omtf/IProcessorEmulator.h | 6 +- .../interface/Omtf/OMTFConfiguration.h | 11 +- .../interface/Omtf/OMTFProcessor.h | 6 +- .../interface/Omtf/OMTFReconstruction.h | 7 +- .../interface/Omtf/OMTFSorter.h | 6 +- .../interface/Omtf/OMTFSorterWithThreshold.h | 33 ---- .../interface/Omtf/OMTFinput.h | 4 +- .../interface/Omtf/OMTFinputMaker.h | 4 +- .../interface/Omtf/OmtfAngleConverter.h | 6 +- .../interface/Omtf/OmtfName.h | 4 +- .../interface/Omtf/ProcessorBase.h | 24 +-- .../interface/Omtf/PtAssignmentBase.h | 6 +- .../interface/Omtf/SorterBase.h | 10 +- .../interface/Omtf/XMLConfigReader.h | 10 +- .../interface/Omtf/XMLConfigWriter.h | 7 +- .../interface/Omtf/XMLEventWriter.h | 6 +- .../interface/ProcConfigurationBase.h | 6 +- .../interface/RpcClusterization.h | 6 +- .../interface/StubResult.h | 6 +- .../interface/Tools/CandidateSimMuonMatcher.h | 6 +- .../interface/Tools/DataROOTDumper.h | 66 -------- .../interface/Tools/DataROOTDumper2.h | 29 +--- .../interface/Tools/EmulationObserverBase.h | 56 ++++++ .../interface/Tools/EventCapture.h | 12 +- .../interface/Tools/GpResultsToPt.h | 6 +- .../interface/Tools/OMTFConfigMaker.h | 4 +- .../interface/Tools/PatternGenerator.h | 8 +- .../interface/Tools/PatternOptimizer.h | 8 +- .../interface/Tools/PatternOptimizerBase.h | 40 ++--- .../interface/Tools/PatternsPtAssignment.h | 34 ---- .../interface/Tools/StubsSimHitsMatcher.h | 6 +- .../L1MuonOverlapPhase1ParamsDBProducer.h | 4 +- .../L1TMuonOverlapPhase1ParamsESProducer.h | 5 + .../L1TMuonOverlapPhase1TrackProducer.h | 16 +- .../src/Omtf/OMTFProcessor.cc | 4 +- .../src/Omtf/OMTFReconstruction.cc | 88 +++++----- .../src/Omtf/OMTFSorter.cc | 2 +- .../src/Omtf/OMTFSorterWithThreshold.cc | 160 ------------------ .../src/Omtf/ProcessorBase.cc | 26 +-- .../src/Omtf/XMLConfigReader.cc | 33 ++-- .../src/Omtf/XMLConfigWriter.cc | 8 +- .../src/Tools/CandidateSimMuonMatcher.cc | 5 +- .../src/Tools/DataROOTDumper.cc | 129 -------------- .../src/Tools/DataROOTDumper2.cc | 116 ++++--------- .../src/Tools/EmulationObserverBase.cc | 109 ++++++++++++ .../src/Tools/EventCapture.cc | 17 +- .../src/Tools/PatternGenerator.cc | 4 +- .../src/Tools/PatternOptimizer.cc | 34 ++-- .../src/Tools/PatternOptimizerBase.cc | 96 +---------- .../src/Tools/PatternsPtAssignment.cc | 69 -------- 64 files changed, 484 insertions(+), 957 deletions(-) delete mode 100644 L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFSorterWithThreshold.h delete mode 100644 L1Trigger/L1TMuonOverlapPhase1/interface/Tools/DataROOTDumper.h create mode 100644 L1Trigger/L1TMuonOverlapPhase1/interface/Tools/EmulationObserverBase.h delete mode 100644 L1Trigger/L1TMuonOverlapPhase1/interface/Tools/PatternsPtAssignment.h delete mode 100644 L1Trigger/L1TMuonOverlapPhase1/src/Omtf/OMTFSorterWithThreshold.cc delete mode 100644 L1Trigger/L1TMuonOverlapPhase1/src/Tools/DataROOTDumper.cc create mode 100644 L1Trigger/L1TMuonOverlapPhase1/src/Tools/EmulationObserverBase.cc delete mode 100644 L1Trigger/L1TMuonOverlapPhase1/src/Tools/PatternsPtAssignment.cc diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/AlgoMuonBase.h b/L1Trigger/L1TMuonOverlapPhase1/interface/AlgoMuonBase.h index 7e4decd04d2dd..2aa79a19a5f54 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/interface/AlgoMuonBase.h +++ b/L1Trigger/L1TMuonOverlapPhase1/interface/AlgoMuonBase.h @@ -5,8 +5,8 @@ * Author: Karol Bunkowski kbunkow@cern.ch */ -#ifndef INTERFACE_ALGOMUONBASE_H_ -#define INTERFACE_ALGOMUONBASE_H_ +#ifndef L1T_OmtfP1_ALGOMUONBASE_H_ +#define L1T_OmtfP1_ALGOMUONBASE_H_ #include "L1Trigger/L1TMuonOverlapPhase1/interface/ProcConfigurationBase.h" #include "L1Trigger/L1TMuonOverlapPhase1/interface/MuonStub.h" @@ -79,4 +79,4 @@ class AlgoMuonBase { std::vector > firedLayerBitsInBx; }; -#endif /* INTERFACE_ALGOMUONBASE_H_ */ +#endif /* L1T_OmtfP1_ALGOMUONBASE_H_ */ diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/AngleConverterBase.h b/L1Trigger/L1TMuonOverlapPhase1/interface/AngleConverterBase.h index bf7dabb37de7e..bce3913f63661 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/interface/AngleConverterBase.h +++ b/L1Trigger/L1TMuonOverlapPhase1/interface/AngleConverterBase.h @@ -1,5 +1,5 @@ -#ifndef ANGLECONVERTER_H -#define ANGLECONVERTER_H +#ifndef L1T_OmtfP1_ANGLECONVERTER_H +#define L1T_OmtfP1_ANGLECONVERTER_H #include "L1Trigger/L1TMuonOverlapPhase1/interface/ProcConfigurationBase.h" diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/MuonStub.h b/L1Trigger/L1TMuonOverlapPhase1/interface/MuonStub.h index 59c6945525e97..f1555b50289de 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/interface/MuonStub.h +++ b/L1Trigger/L1TMuonOverlapPhase1/interface/MuonStub.h @@ -7,8 +7,8 @@ * MuonStub - data structure for algorithm input */ -#ifndef MUONOVERLAP_MUONSTUB_H_ -#define MUONOVERLAP_MUONSTUB_H_ +#ifndef L1T_OmtfP1_MUONSTUB_H_ +#define L1T_OmtfP1_MUONSTUB_H_ #include #include @@ -87,4 +87,4 @@ typedef std::shared_ptr MuonStubPtr; typedef std::vector MuonStubPtrs1D; typedef std::vector MuonStubPtrs2D; -#endif /* MUONOVERLAP_MUONSTUB_H_ */ +#endif /* L1T_OmtfP1_MUONSTUB_H_ */ diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/MuonStubMakerBase.h b/L1Trigger/L1TMuonOverlapPhase1/interface/MuonStubMakerBase.h index b614adb662144..f4983b4d206a1 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/interface/MuonStubMakerBase.h +++ b/L1Trigger/L1TMuonOverlapPhase1/interface/MuonStubMakerBase.h @@ -1,5 +1,5 @@ -#ifndef L1TMUONOVERLAP_MUONSTUBMAKERBASE_H -#define L1TMUONOVERLAP_MUONSTUBMAKERBASE_H +#ifndef L1T_OmtfP1_MUONSTUBMAKERBASE_H +#define L1T_OmtfP1_MUONSTUBMAKERBASE_H #include "DataFormats/Common/interface/Handle.h" #include "DataFormats/CSCDigi/interface/CSCCorrelatedLCTDigiCollection.h" diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/MuonStubsInput.h b/L1Trigger/L1TMuonOverlapPhase1/interface/MuonStubsInput.h index 1c75363360bac..baef7fdc94026 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/interface/MuonStubsInput.h +++ b/L1Trigger/L1TMuonOverlapPhase1/interface/MuonStubsInput.h @@ -5,8 +5,8 @@ * Author: Karol Bunkowski kbunkow@cern.ch */ -#ifndef L1TMuonOverlapPhase1_MUONSTUBSINPUT_H_ -#define L1TMuonOverlapPhase1_MUONSTUBSINPUT_H_ +#ifndef L1T_OmtfP1_MUONSTUBSINPUT_H_ +#define L1T_OmtfP1_MUONSTUBSINPUT_H_ #include "L1Trigger/L1TMuonOverlapPhase1/interface/ProcConfigurationBase.h" #include "L1Trigger/L1TMuonOverlapPhase1/interface/MuonStub.h" @@ -50,4 +50,4 @@ class MuonStubsInput { MuonStubPtrs2D muonStubsInLayers; }; -#endif /* L1TMuonOverlapPhase1_MUONSTUBSINPUT_H_ */ +#endif /* L1T_OmtfP1_MUONSTUBSINPUT_H_ */ diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/AlgoMuon.h b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/AlgoMuon.h index 2b9df3da290d6..cbde067591321 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/AlgoMuon.h +++ b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/AlgoMuon.h @@ -1,5 +1,5 @@ -#ifndef AlgoMuon_H -#define AlgoMuon_H +#ifndef L1T_OmtfP1_AlgoMuon_H +#define L1T_OmtfP1_AlgoMuon_H #include "L1Trigger/L1TMuonOverlapPhase1/interface/AlgoMuonBase.h" #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GoldenPatternBase.h" @@ -138,4 +138,4 @@ class AlgoMuon : public AlgoMuonBase { typedef std::shared_ptr AlgoMuonPtr; typedef std::vector AlgoMuons; -#endif +#endif //L1T_OmtfP1_AlgoMuon_H diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GhostBuster.h b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GhostBuster.h index 01a0552631dbe..a650b4715de11 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GhostBuster.h +++ b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GhostBuster.h @@ -1,5 +1,5 @@ -#ifndef OMTF_GhostBuster_H -#define OMTF_GhostBuster_H +#ifndef L1T_OmtfP1_GhostBuster_H +#define L1T_OmtfP1_GhostBuster_H #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/AlgoMuon.h" #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/IGhostBuster.h" diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GhostBusterPreferRefDt.h b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GhostBusterPreferRefDt.h index 9f3dbcf8bdff6..9f221fa6578a2 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GhostBusterPreferRefDt.h +++ b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GhostBusterPreferRefDt.h @@ -1,5 +1,5 @@ -#ifndef OMTF_GhostBusterPreferRefDt_H -#define OMTF_GhostBusterPreferRefDt_H +#ifndef L1T_OmtfP1_GhostBusterPreferRefDt_H +#define L1T_OmtfP1_GhostBusterPreferRefDt_H #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/AlgoMuon.h" #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/IGhostBuster.h" diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GoldenPattern.h b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GoldenPattern.h index 365c4bcc5ffb1..135a05d719114 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GoldenPattern.h +++ b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GoldenPattern.h @@ -1,5 +1,5 @@ -#ifndef OMTF_GoldenPattern_H -#define OMTF_GoldenPattern_H +#ifndef L1T_OmtfP1_GoldenPattern_H +#define L1T_OmtfP1_GoldenPattern_H #include "boost/multi_array/base.hpp" #include "boost/multi_array.hpp" diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GoldenPatternBase.h b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GoldenPatternBase.h index 4a531c0193492..31faaa9d5b979 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GoldenPatternBase.h +++ b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GoldenPatternBase.h @@ -1,5 +1,5 @@ -#ifndef OMTF_GoldenPatternBase_H -#define OMTF_GoldenPatternBase_H +#ifndef L1T_OmtfP1_GoldenPatternBase_H +#define L1T_OmtfP1_GoldenPatternBase_H #include "boost/multi_array.hpp" #include "L1Trigger/L1TMuonOverlapPhase1/interface/MuonStub.h" @@ -156,6 +156,9 @@ class GoldenPatternBase { //second index: myOmtfConfig->nTestRefHits resultsArrayType results; }; + + +template using GoldenPatternVec = std::vector > ; ////////////////////////////////// ////////////////////////////////// #endif diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GoldenPatternResult.h b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GoldenPatternResult.h index 47b021d7851ec..58bd094ae162a 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GoldenPatternResult.h +++ b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GoldenPatternResult.h @@ -1,5 +1,5 @@ -#ifndef OMTF_GOLDENPATTERNRESULTS_H -#define OMTF_GOLDENPATTERNRESULTS_H +#ifndef L1T_OmtfP1_GOLDENPATTERNRESULTS_H +#define L1T_OmtfP1_GOLDENPATTERNRESULTS_H #include "L1Trigger/L1TMuonOverlapPhase1/interface/MuonStub.h" #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFConfiguration.h" @@ -136,4 +136,4 @@ class GoldenPatternResult { const OMTFConfiguration* omtfConfig = nullptr; }; -#endif //OMTF_GOLDENPATTERNRESULTS_H +#endif //L1T_OmtfP1_GOLDENPATTERNRESULTS_H diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GoldenPatternWithStat.h b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GoldenPatternWithStat.h index 321561a47faeb..e6f35f7fec361 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GoldenPatternWithStat.h +++ b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GoldenPatternWithStat.h @@ -1,5 +1,5 @@ -#ifndef OMTF_GoldenPatternWithStat_H -#define OMTF_GoldenPatternWithStat_H +#ifndef L1T_OmtfP1_GoldenPatternWithStat_H +#define L1T_OmtfP1_GoldenPatternWithStat_H #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GoldenPattern.h" #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFinput.h" diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/IGhostBuster.h b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/IGhostBuster.h index e11c0e176655c..472a063def77c 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/IGhostBuster.h +++ b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/IGhostBuster.h @@ -5,8 +5,8 @@ * Author: kbunkow */ -#ifndef OMTF_IGHOSTBUSTER_H_ -#define OMTF_IGHOSTBUSTER_H_ +#ifndef L1T_OmtfP1_IGHOSTBUSTER_H_ +#define L1T_OmtfP1_IGHOSTBUSTER_H_ #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/AlgoMuon.h" @@ -17,4 +17,4 @@ class IGhostBuster { virtual AlgoMuons select(AlgoMuons refHitCands, int charge = 0) = 0; }; -#endif /* OMTF_IGHOSTBUSTER_H_ */ +#endif /* L1T_OmtfP1_IGHOSTBUSTER_H_ */ diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/IOMTFEmulationObserver.h b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/IOMTFEmulationObserver.h index 0beee13f0eea0..543d6722bce4e 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/IOMTFEmulationObserver.h +++ b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/IOMTFEmulationObserver.h @@ -5,8 +5,8 @@ * Author: kbunkow */ -#ifndef OMTF_IOMTFRECONSTRUCTIONOBSERVER_H_ -#define OMTF_IOMTFRECONSTRUCTIONOBSERVER_H_ +#ifndef L1T_OmtfP1_IOMTFRECONSTRUCTIONOBSERVER_H_ +#define L1T_OmtfP1_IOMTFRECONSTRUCTIONOBSERVER_H_ #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/AlgoMuon.h" #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFinput.h" @@ -43,4 +43,4 @@ class IOMTFEmulationObserver { virtual void endJob() = 0; }; -#endif /* OMTF_IOMTFRECONSTRUCTIONOBSERVER_H_ */ +#endif /* L1T_OmtfP1_IOMTFRECONSTRUCTIONOBSERVER_H_ */ diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/IProcessorEmulator.h b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/IProcessorEmulator.h index 9960036245ad6..a035af373dbbc 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/IProcessorEmulator.h +++ b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/IProcessorEmulator.h @@ -5,8 +5,8 @@ * Author: kbunkow */ -#ifndef OMTF_IPROCESSOREMULATOR_H_ -#define OMTF_IPROCESSOREMULATOR_H_ +#ifndef L1T_OmtfP1_IPROCESSOREMULATOR_H_ +#define L1T_OmtfP1_IPROCESSOREMULATOR_H_ #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GhostBuster.h" #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GoldenPatternResult.h" @@ -51,4 +51,4 @@ class IProcessorEmulator { virtual void printInfo() const = 0; }; -#endif /* OMTF_IPROCESSOREMULATOR_H_ */ +#endif /* L1T_OmtfP1_IPROCESSOREMULATOR_H_ */ diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFConfiguration.h b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFConfiguration.h index 716d891aaaa34..2213bccc69d9d 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFConfiguration.h +++ b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFConfiguration.h @@ -1,5 +1,5 @@ -#ifndef OMTF_OMTFConfiguration_H -#define OMTF_OMTFConfiguration_H +#ifndef L1T_OmtfP1_OMTFConfiguration_H +#define L1T_OmtfP1_OMTFConfiguration_H #include #include @@ -7,7 +7,7 @@ #include #include -#undef BOOST_DISABLE_ASSERTS //TODO remove for production version +//#undef BOOST_DISABLE_ASSERTS //TODO remove for production version #include "boost/multi_array.hpp" #include "L1Trigger/L1TMuonOverlapPhase1/interface/ProcConfigurationBase.h" @@ -204,10 +204,9 @@ class OMTFConfiguration : public ProcConfigurationBase { static const unsigned int patternsInGroup = 4; - ///and this based on the actual goldenPats - //takes the groups from the kye, it should be set during xml reading, or creating the goldenPats + //takes the groups from the key, it should be set during xml reading, or creating the goldenPats template - vector2D getPatternGroups(const std::vector >& goldenPats) const { + vector2D getPatternGroups(const std::vector >& goldenPats) const { //unsigned int mergedCnt = 4; vector2D mergedPatterns; for (unsigned int iPat = 0; iPat < goldenPats.size(); iPat++) { diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFProcessor.h b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFProcessor.h index 5f869eea4fc8f..1a35a45cfe2f2 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFProcessor.h +++ b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFProcessor.h @@ -1,5 +1,5 @@ -#ifndef OMTF_OMTFProcessor_H -#define OMTF_OMTFProcessor_H +#ifndef L1T_OmtfP1_OMTFProcessor_H +#define L1T_OmtfP1_OMTFProcessor_H #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/AlgoMuon.h" #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GoldenPattern.h" @@ -46,7 +46,7 @@ class OMTFProcessor : public ProcessorBase, public IProcessor OMTFProcessor(OMTFConfiguration* omtfConfig, const edm::ParameterSet& edmCfg, edm::EventSetup const& evSetup, - const typename ProcessorBase::GoldenPatternVec& gps); + GoldenPatternVec&& gps); ~OMTFProcessor() override; diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFReconstruction.h b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFReconstruction.h index bfab3db463a23..1d3b522cdd23f 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFReconstruction.h +++ b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFReconstruction.h @@ -1,5 +1,5 @@ -#ifndef OMTFReconstruction_H -#define OMTFReconstruction_H +#ifndef L1T_OmtfP1_OMTFReconstruction_H +#define L1T_OmtfP1_OMTFReconstruction_H #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GhostBuster.h" #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/IOMTFEmulationObserver.h" @@ -18,6 +18,7 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Framework/interface/EDProducer.h" #include "FWCore/Utilities/interface/ESGetToken.h" +#include "FWCore/Framework/interface/ESWatcher.h" #include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambPhContainer.h" #include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambThContainer.h" @@ -76,6 +77,8 @@ class OMTFReconstruction { OMTFConfigMaker* m_OMTFConfigMaker; std::vector > observers; + + edm::ESWatcher omtfParamsRecordWatcher; }; #endif diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFSorter.h b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFSorter.h index 48933541a07c7..12a20963bef44 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFSorter.h +++ b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFSorter.h @@ -1,5 +1,5 @@ -#ifndef OMTF_OMTFSorter_H -#define OMTF_OMTFSorter_H +#ifndef L1T_OmtfP1_OMTFSorter_H +#define L1T_OmtfP1_OMTFSorter_H #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/SorterBase.h" #include @@ -17,7 +17,7 @@ class OMTFSorter : public SorterBase { ///as we allow two candidates with opposite charge from single 10deg region AlgoMuons::value_type sortRefHitResults(unsigned int procIndx, unsigned int iRefHit, - const std::vector >& gPatterns, + const GoldenPatternVec& gPatterns, int charge = 0) override; private: diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFSorterWithThreshold.h b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFSorterWithThreshold.h deleted file mode 100644 index 49c2591b92b3b..0000000000000 --- a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFSorterWithThreshold.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef OMTF_OMTFSorterWithThreshold_H -#define OMTF_OMTFSorterWithThreshold_H - -#include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GoldenPattern.h" -#include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/SorterBase.h" -#include - -template -class OMTFSorterWithThreshold : public SorterBase { -public: - enum Mode { bestGPByThresholdOnProbability2, bestGPByMaxGpProbability1 }; - OMTFSorterWithThreshold(const OMTFConfiguration* myOmtfConfig, Mode mode) : myOmtfConfig(myOmtfConfig), mode(mode) {} - - ~OMTFSorterWithThreshold() override {} - - ///Sort results from a single reference hit. - ///Select candidate with highest number of hit layers - ///Then select a candidate with largest likelihood value and given charge - ///as we allow two candidates with opposite charge from single 10deg region - AlgoMuons::value_type sortRefHitResults(unsigned int procIndx, - unsigned int iRefHit, - const std::vector >& gPatterns, - int charge = 0) override; - -private: - const OMTFConfiguration* myOmtfConfig; - - Mode mode = bestGPByThresholdOnProbability2; - - std::vector > gPatternsSortedByPt; -}; - -#endif diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFinput.h b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFinput.h index 6eb5f53d66448..b19b1e552f29d 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFinput.h +++ b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFinput.h @@ -1,5 +1,5 @@ -#ifndef OMTF_OMTFinput_H -#define OMTF_OMTFinput_H +#ifndef L1T_OmtfP1_OMTFinput_H +#define L1T_OmtfP1_OMTFinput_H #include "L1Trigger/L1TMuonOverlapPhase1/interface/MuonStubsInput.h" #include "L1Trigger/L1TMuonOverlapPhase1/interface/MuonStub.h" diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFinputMaker.h b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFinputMaker.h index f3fe23ab86551..2bfd3cc9ea348 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFinputMaker.h +++ b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFinputMaker.h @@ -1,5 +1,5 @@ -#ifndef OMTFinputMaker_H -#define OMTFinputMaker_H +#ifndef L1T_OmtfP1_OMTFinputMaker_H +#define L1T_OmtfP1_OMTFinputMaker_H #include "FWCore/Framework/interface/EventSetup.h" diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OmtfAngleConverter.h b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OmtfAngleConverter.h index d4bb92f838cd6..e265a26abd899 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OmtfAngleConverter.h +++ b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OmtfAngleConverter.h @@ -5,8 +5,8 @@ * Author: kbunkow */ -#ifndef OMTF_OMTFANGLECONVERTER_H_ -#define OMTF_OMTFANGLECONVERTER_H_ +#ifndef L1T_OmtfP1_OMTFANGLECONVERTER_H_ +#define L1T_OmtfP1_OMTFANGLECONVERTER_H_ #include "L1Trigger/L1TMuonOverlapPhase1/interface/AngleConverterBase.h" @@ -27,4 +27,4 @@ class OmtfAngleConverter : public AngleConverterBase { virtual int getGlobalEtaRpc(unsigned int rawid, const unsigned int &aDigi) const; }; -#endif /* INTERFACE_OMTF_OMTFANGLECONVERTER_H_ */ +#endif /* L1T_OmtfP1_OMTFANGLECONVERTER_H_ */ diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OmtfName.h b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OmtfName.h index 8e9165e11e80b..a535b738ce646 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OmtfName.h +++ b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OmtfName.h @@ -1,5 +1,5 @@ -#ifndef L1Trigger_L1TMuonOverlap_OmtfName_H -#define L1Trigger_L1TMuonOverlap_OmtfName_H +#ifndef L1Trigger_L1TMuonOverlapP1_OmtfName_H +#define L1Trigger_L1TMuonOverlapP1_OmtfName_H #include #include diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/ProcessorBase.h b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/ProcessorBase.h index f233320dd3268..8c4d0169fac04 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/ProcessorBase.h +++ b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/ProcessorBase.h @@ -5,8 +5,8 @@ * Author: kbunkow */ -#ifndef OMTF_PROCESSORBASE_H_ -#define OMTF_PROCESSORBASE_H_ +#ifndef L1T_OmtfP1_PROCESSORBASE_H_ +#define L1T_OmtfP1_PROCESSORBASE_H_ #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GoldenPatternBase.h" #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFConfiguration.h" @@ -20,22 +20,16 @@ class SimTrack; template class ProcessorBase { public: - typedef std::vector > GoldenPatternVec; - ProcessorBase(OMTFConfiguration* omtfConfig, const L1TMuonOverlapParams* omtfPatterns) : myOmtfConfig(omtfConfig) { configure(omtfConfig, omtfPatterns); }; - ProcessorBase(OMTFConfiguration* omtfConfig, const GoldenPatternVec& gps) : myOmtfConfig(omtfConfig) { - setGPs(gps); - //initPatternPtRange(true); is called in the setGPs - omtfConfig->setPatternPtRange(getPatternPtRange()); - }; + ProcessorBase(OMTFConfiguration* omtfConfig, GoldenPatternVec&& gps); virtual ~ProcessorBase() {} ///Return vector of GoldenPatterns - virtual const GoldenPatternVec& getPatterns() const { return theGPs; }; + virtual GoldenPatternVec& getPatterns() { return theGPs; }; ///Fill GP vec with patterns from CondFormats object virtual bool configure(OMTFConfiguration* omtfParams, const L1TMuonOverlapParams* omtfPatterns); @@ -43,8 +37,6 @@ class ProcessorBase { ///Add GoldenPattern to pattern vec. virtual void addGP(GoldenPatternType* aGP); - virtual void setGPs(const GoldenPatternVec& gps); - ///Reset all configuration parameters virtual void resetConfiguration(); @@ -55,13 +47,13 @@ class ProcessorBase { virtual void printInfo() const; protected: - ///vector holding Golden Patterns - GoldenPatternVec theGPs; - ///Configuration of the algorithm. This object ///does not contain the patterns data. const OMTFConfiguration* myOmtfConfig; + ///vector holding Golden Patterns + GoldenPatternVec theGPs; + ///Remove hits whis are outside input range ///for given processor and cone virtual MuonStubPtrs1D restrictInput(unsigned int iProcessor, @@ -72,4 +64,4 @@ class ProcessorBase { std::vector patternPts; }; -#endif /* OMTF_PROCESSORBASE_H_ */ +#endif /* L1T_OmtfP1_PROCESSORBASE_H_ */ diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/PtAssignmentBase.h b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/PtAssignmentBase.h index 52b8657f066e1..0a4b16ffa1e7d 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/PtAssignmentBase.h +++ b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/PtAssignmentBase.h @@ -5,8 +5,8 @@ * Author: kbunkow */ -#ifndef INTERFACE_OMTF_PTASSIGNMENTBASE_H_ -#define INTERFACE_OMTF_PTASSIGNMENTBASE_H_ +#ifndef L1T_OmtfP1_PTASSIGNMENTBASE_H_ +#define L1T_OmtfP1_PTASSIGNMENTBASE_H_ #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/AlgoMuon.h" @@ -25,4 +25,4 @@ class PtAssignmentBase { const OMTFConfiguration* omtfConfig = nullptr; }; -#endif /* INTERFACE_OMTF_PTASSIGNMENTBASE_H_ */ +#endif /* L1T_OmtfP1_PTASSIGNMENTBASE_H_ */ diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/SorterBase.h b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/SorterBase.h index b4b92e3b7215a..e4a67e4fdf445 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/SorterBase.h +++ b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/SorterBase.h @@ -5,8 +5,8 @@ * Author: kbunkow */ -#ifndef OMTF_SORTERBASE_H_ -#define OMTF_SORTERBASE_H_ +#ifndef L1T_OmtfP1_SORTERBASE_H_ +#define L1T_OmtfP1_SORTERBASE_H_ #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/AlgoMuon.h" #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GoldenPatternResult.h" @@ -23,7 +23,7 @@ class SorterBase { //iProcessor - continuous processor index [0...11] virtual AlgoMuons sortResults(unsigned int procIndx, - const std::vector >& gPatterns, + const GoldenPatternVec& gPatterns, int charge = 0) { AlgoMuons refHitCands; // for(auto itRefHit: procResults) refHitCands.push_back(sortRefHitResults(itRefHit,charge)); @@ -39,8 +39,8 @@ class SorterBase { ///as we allow two candidates with opposite charge from single 10deg region virtual AlgoMuons::value_type sortRefHitResults(unsigned int procIndx, unsigned int iRefHit, - const std::vector >& gPatterns, + const GoldenPatternVec& gPatterns, int charge = 0) = 0; }; -#endif /* OMTF_SORTERBASE_H_ */ +#endif /* L1T_OmtfP1_SORTERBASE_H_ */ diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/XMLConfigReader.h b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/XMLConfigReader.h index c9c6f07730754..1bbca04712956 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/XMLConfigReader.h +++ b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/XMLConfigReader.h @@ -1,7 +1,9 @@ -#ifndef OMTF_XMLConfigReader_H -#define OMTF_XMLConfigReader_H +#ifndef L1T_OmtfP1_XMLConfigReader_H +#define L1T_OmtfP1_XMLConfigReader_H #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFConfiguration.h" +#include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GoldenPatternBase.h" + #include "CondFormats/L1TObjects/interface/LUT.h" #include @@ -41,12 +43,12 @@ class XMLConfigReader { * it is needed in the readLUTs, as only with the empty patterns it is possible to obtain the patterns grouping from the LUTs in the L1TMuonOverlapParams */ template - std::vector > readPatterns(const L1TMuonOverlapParams& aConfig, + GoldenPatternVec readPatterns(const L1TMuonOverlapParams& aConfig, const std::string& patternsFile, bool buildEmptyPatterns, bool resetNumbering = true); template - std::vector > readPatterns(const L1TMuonOverlapParams& aConfig, + GoldenPatternVec readPatterns(const L1TMuonOverlapParams& aConfig, const std::vector& patternsFiles, bool buildEmptyPatterns); void readLUTs(std::vector luts, diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/XMLConfigWriter.h b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/XMLConfigWriter.h index bbe48bcf23c26..4ad29e0ab4a99 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/XMLConfigWriter.h +++ b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/XMLConfigWriter.h @@ -1,8 +1,9 @@ -#ifndef OMTF_XMLConfigWriter_H -#define OMTF_XMLConfigWriter_H +#ifndef L1T_OmtfP1_XMLConfigWriter_H +#define L1T_OmtfP1_XMLConfigWriter_H #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OmtfName.h" #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFConfiguration.h" +#include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GoldenPatternBase.h" #include #include @@ -52,7 +53,7 @@ class XMLConfigWriter { void writeGPData(GoldenPattern* aGP1, GoldenPattern* aGP2, GoldenPattern* aGP3, GoldenPattern* aGP4); template - void writeGPs(const std::vector >& goldenPats, std::string fName); + void writeGPs(const GoldenPatternVec& goldenPats, std::string fName); void writeConnectionsData(const std::vector >& measurements4D); diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/XMLEventWriter.h b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/XMLEventWriter.h index 1814b145c89a0..07dba334ded36 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/XMLEventWriter.h +++ b/L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/XMLEventWriter.h @@ -5,8 +5,8 @@ * Author: kbunkow */ -#ifndef INTERFACE_OMTF_XMLEVENTWRITER_H_ -#define INTERFACE_OMTF_XMLEVENTWRITER_H_ +#ifndef L1T_OmtfP1_XMLEVENTWRITER_H_ +#define L1T_OmtfP1_XMLEVENTWRITER_H_ #include "DataFormats/L1TMuon/interface/RegionalMuonCand.h" #include "DataFormats/L1TMuon/interface/RegionalMuonCandFwd.h" @@ -50,4 +50,4 @@ class XMLEventWriter : public IOMTFEmulationObserver { unsigned int eventId = 0; }; -#endif /* INTERFACE_OMTF_XMLEVENTWRITER_H_ */ +#endif /* L1T_OmtfP1_XMLEVENTWRITER_H_ */ diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/ProcConfigurationBase.h b/L1Trigger/L1TMuonOverlapPhase1/interface/ProcConfigurationBase.h index 652e33b4d0d73..6b7b609130945 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/interface/ProcConfigurationBase.h +++ b/L1Trigger/L1TMuonOverlapPhase1/interface/ProcConfigurationBase.h @@ -5,8 +5,8 @@ * Author: Karol Bunkowski kbunkow@cern.ch */ -#ifndef MUONOVERLAP_PROCCONFIGURATIONBASE_H_ -#define MUONOVERLAP_PROCCONFIGURATIONBASE_H_ +#ifndef L1T_OmtfP1_PROCCONFIGURATIONBASE_H_ +#define L1T_OmtfP1_PROCCONFIGURATIONBASE_H_ #include "FWCore/ParameterSet/interface/ParameterSet.h" class ProcConfigurationBase { @@ -96,4 +96,4 @@ class ProcConfigurationBase { bool fixCscGeometryOffset = false; }; -#endif /* INTERFACE_PROCCONFIGURATIONBASE_H_ */ +#endif /* L1T_OmtfP1_PROCCONFIGURATIONBASE_H_ */ diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/RpcClusterization.h b/L1Trigger/L1TMuonOverlapPhase1/interface/RpcClusterization.h index 849ac54c25a08..eda04cf5d0ff7 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/interface/RpcClusterization.h +++ b/L1Trigger/L1TMuonOverlapPhase1/interface/RpcClusterization.h @@ -5,8 +5,8 @@ * Author: kbunkow */ -#ifndef INTERFACE_RPCCLUSTERIZATION_H_ -#define INTERFACE_RPCCLUSTERIZATION_H_ +#ifndef L1T_OmtfP1_RPCCLUSTERIZATION_H_ +#define L1T_OmtfP1_RPCCLUSTERIZATION_H_ #include "DataFormats/MuonDetId/interface/RPCDetId.h" #include "DataFormats/RPCDigi/interface/RPCDigiCollection.h" @@ -54,4 +54,4 @@ class RpcClusterization { true; // if true no cluster is return if there is more clusters then maxClusterCnt (counted regardless of the size) }; -#endif /* INTERFACE_RPCCLUSTERIZATION_H_ */ +#endif /* L1T_OmtfP1_RPCCLUSTERIZATION_H_ */ diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/StubResult.h b/L1Trigger/L1TMuonOverlapPhase1/interface/StubResult.h index 357069eb021e2..4a2877db9c0e8 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/interface/StubResult.h +++ b/L1Trigger/L1TMuonOverlapPhase1/interface/StubResult.h @@ -5,8 +5,8 @@ * Author: Karol Bunkowski kbunkow@cern.ch */ -#ifndef INTERFACE_STUBRESULT_H_ -#define INTERFACE_STUBRESULT_H_ +#ifndef L1T_OmtfP1_STUBRESULT_H_ +#define L1T_OmtfP1_STUBRESULT_H_ #include "L1Trigger/L1TMuonOverlapPhase1/interface/MuonStub.h" #include @@ -55,4 +55,4 @@ class StubResult { typedef std::vector StubResults; -#endif /* INTERFACE_STUBRESULT_H_ */ +#endif /* L1T_OmtfP1_STUBRESULT_H_ */ diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/Tools/CandidateSimMuonMatcher.h b/L1Trigger/L1TMuonOverlapPhase1/interface/Tools/CandidateSimMuonMatcher.h index 61766d6ba507d..5641d216784e3 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/interface/Tools/CandidateSimMuonMatcher.h +++ b/L1Trigger/L1TMuonOverlapPhase1/interface/Tools/CandidateSimMuonMatcher.h @@ -5,8 +5,8 @@ * Author: kbunkow */ -#ifndef OMTF_TOOLS_MUONCANDIDATEMATCHER_H_ -#define OMTF_TOOLS_MUONCANDIDATEMATCHER_H_ +#ifndef L1T_OmtfP1_TOOLS_MUONCANDIDATEMATCHER_H_ +#define L1T_OmtfP1_TOOLS_MUONCANDIDATEMATCHER_H_ #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/AlgoMuon.h" #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/IOMTFEmulationObserver.h" @@ -190,4 +190,4 @@ class CandidateSimMuonMatcher : public IOMTFEmulationObserver { TH1D* deltaPhiPropCandStdDev = nullptr; }; -#endif /* OMTF_TOOLS_MUONCANDIDATEMATCHER_H_ */ +#endif /* L1T_OmtfP1_TOOLS_MUONCANDIDATEMATCHER_H_ */ diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/Tools/DataROOTDumper.h b/L1Trigger/L1TMuonOverlapPhase1/interface/Tools/DataROOTDumper.h deleted file mode 100644 index 942f5c1257d4a..0000000000000 --- a/L1Trigger/L1TMuonOverlapPhase1/interface/Tools/DataROOTDumper.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * DataROOTDumper.h - * - * Created on: Tue Apr 16 09:57:08 CEST 2019 - * Author: akalinow - */ - -#ifndef OMTF_DATAROOTDUMPER_H_ -#define OMTF_DATAROOTDUMPER_H_ - -#include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/IOMTFEmulationObserver.h" -#include "L1Trigger/L1TMuonOverlapPhase1/interface/Tools/PatternOptimizerBase.h" - -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "SimDataFormats/Track/interface/SimTrackContainer.h" - -#include "TMap.h" -#include "TArrayI.h" - -#include - -class TTree; - -struct OMTFEvent { -public: - double muonPt, muonEta, muonPhi; - int muonCharge; - - int omtfCharge, omtfProcessor, omtfScore; - double omtfPt, omtfEta, omtfPhi; - unsigned int omtfQuality, omtfRefLayer, omtfHitsWord; - - std::vector hits; - std::vector hitsQuality; -}; - -class DataROOTDumper : public PatternOptimizerBase { -public: - DataROOTDumper(const edm::ParameterSet& edmCfg, const OMTFConfiguration* omtfConfig); - - ~DataROOTDumper() override; - - void observeProcesorEmulation(unsigned int iProcessor, - l1t::tftype mtfType, - const std::shared_ptr& input, - const AlgoMuons& algoCandidates, - const AlgoMuons& gbCandidates, - const std::vector& candMuons) override; - - void observeEventEnd(const edm::Event& iEvent, - std::unique_ptr& finalCandidates) override; - - void endJob() override; - -private: - void initializeTTree(); - void saveTTree(); - - TFile* myFile; - TTree* myTree; - OMTFEvent myEvent; -}; - -#endif /* OMTF_DATAROOTDUMPER_H_ */ diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/Tools/DataROOTDumper2.h b/L1Trigger/L1TMuonOverlapPhase1/interface/Tools/DataROOTDumper2.h index a1fc9bcf8dc3a..d7104bdeea892 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/interface/Tools/DataROOTDumper2.h +++ b/L1Trigger/L1TMuonOverlapPhase1/interface/Tools/DataROOTDumper2.h @@ -5,12 +5,10 @@ * Author: kbunkow */ -#ifndef INTERFACE_TOOLS_DATAROOTDUMPER2_H_ -#define INTERFACE_TOOLS_DATAROOTDUMPER2_H_ +#ifndef L1T_OmtfP1_TOOLS_DATAROOTDUMPER2_H_ +#define L1T_OmtfP1_TOOLS_DATAROOTDUMPER2_H_ -#include "L1Trigger/L1TMuonOverlapPhase1/interface/Tools/GpResultsToPt.h" -#include "L1Trigger/L1TMuonOverlapPhase1/interface/Tools/PatternOptimizerBase.h" -#include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/IOMTFEmulationObserver.h" +#include "L1Trigger/L1TMuonOverlapPhase1/interface/Tools/EmulationObserverBase.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" @@ -19,6 +17,8 @@ #include "TMap.h" #include "TArrayI.h" +#include "TFile.h" +#include "TH2.h" #include @@ -55,19 +55,14 @@ struct OmtfEvent { std::vector hits; - boost::multi_array omtfGpResultsPdfSum; //[iREfHit][iGp] - boost::multi_array omtfGpResultsFiredLayers; //[iREfHit][iGp] - OmtfEvent(unsigned int nRefHits, unsigned int nGoldenPatterns) - : omtfGpResultsPdfSum(boost::extents[nRefHits][nGoldenPatterns]), - omtfGpResultsFiredLayers(boost::extents[nRefHits][nGoldenPatterns]) {} + //OmtfEvent() {} }; -class DataROOTDumper2 : public PatternOptimizerBase { +class DataROOTDumper2 : public EmulationObserverBase { public: DataROOTDumper2(const edm::ParameterSet& edmCfg, const OMTFConfiguration* omtfConfig, - const std::vector >& gps, std::string rootFileName); ~DataROOTDumper2() override; @@ -78,26 +73,20 @@ class DataROOTDumper2 : public PatternOptimizerBase { void endJob() override; private: - std::vector > gps; - void initializeTTree(std::string rootFileName); void saveTTree(); TFile* rootFile = nullptr; TTree* rootTree = nullptr; - OmtfEvent event; + OmtfEvent omtfEvent; unsigned int evntCnt = 0; TH1I* ptGenPos = nullptr; TH1I* ptGenNeg = nullptr; - bool dumpGpResults = false; - - GpResultsToPt* gpResultsToPt = nullptr; //TODO move to OmtfProcessor - std::vector hitVsPt; }; -#endif /* INTERFACE_TOOLS_DATAROOTDUMPER2_H_ */ +#endif /* L1T_OmtfP1_TOOLS_DATAROOTDUMPER2_H_ */ diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/Tools/EmulationObserverBase.h b/L1Trigger/L1TMuonOverlapPhase1/interface/Tools/EmulationObserverBase.h new file mode 100644 index 0000000000000..7e4b72ee35717 --- /dev/null +++ b/L1Trigger/L1TMuonOverlapPhase1/interface/Tools/EmulationObserverBase.h @@ -0,0 +1,56 @@ +/* + * EmulationObserverBase.h + * + * Created on: Aug 18, 2021 + * Author: kbunkow + */ + +#ifndef L1T_OmtfP1_TOOLS_EMULATIONOBSERVERBASE_H_ +#define L1T_OmtfP1_TOOLS_EMULATIONOBSERVERBASE_H_ + +#include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/IOMTFEmulationObserver.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "SimDataFormats/Track/interface/SimTrackContainer.h" + +class EmulationObserverBase : public IOMTFEmulationObserver { +public: + EmulationObserverBase(const edm::ParameterSet& edmCfg, const OMTFConfiguration* omtfConfig); + + virtual ~EmulationObserverBase(); + + void observeProcesorEmulation(unsigned int iProcessor, + l1t::tftype mtfType, + const std::shared_ptr& input, + const AlgoMuons& algoCandidates, + const AlgoMuons& gbCandidates, + const std::vector& candMuons) override; + + void observeEventBegin(const edm::Event& iEvent) override; + + //void observeEventEnd(const edm::Event& iEvent, + // std::unique_ptr& finalCandidates) override; + + //void endJob() override; + + const SimTrack* findSimMuon(const edm::Event& event, const SimTrack* previous = nullptr); + +protected: + edm::ParameterSet edmCfg; + const OMTFConfiguration* omtfConfig; + + const SimTrack* simMuon = nullptr; + + //candidate found by omtf in a given event + AlgoMuons::value_type omtfCand; + + l1t::RegionalMuonCand regionalMuonCand; + + //AlgoMuons algoCandidates; + + unsigned int candProcIndx = 0; +}; + +#endif /* INTERFACE_TOOLS_EMULATIONOBSERVERBASE_H_ */ diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/Tools/EventCapture.h b/L1Trigger/L1TMuonOverlapPhase1/interface/Tools/EventCapture.h index 8192a8b8e7f9f..df9f23524226b 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/interface/Tools/EventCapture.h +++ b/L1Trigger/L1TMuonOverlapPhase1/interface/Tools/EventCapture.h @@ -5,8 +5,8 @@ * Author: kbunkow */ -#ifndef OMTF_EVENTCAPTURE_H_ -#define OMTF_EVENTCAPTURE_H_ +#ifndef L1T_OmtfP1_EVENTCAPTURE_H_ +#define L1T_OmtfP1_EVENTCAPTURE_H_ #include "SimDataFormats/Track/interface/SimTrack.h" @@ -21,9 +21,9 @@ class EventCapture : public IOMTFEmulationObserver { public: EventCapture(const edm::ParameterSet& edmCfg, const OMTFConfiguration* omtfConfig, - const std::vector >& gps, CandidateSimMuonMatcher* candidateSimMuonMatcher, - const MuonGeometryTokens& muonGeometryTokens); + const MuonGeometryTokens& muonGeometryTokens, + const GoldenPatternVec* gps = nullptr); ~EventCapture() override; @@ -47,7 +47,7 @@ class EventCapture : public IOMTFEmulationObserver { edm::InputTag simTracksTag; const OMTFConfiguration* omtfConfig = nullptr; - std::vector > goldenPatterns; + const GoldenPatternVec* goldenPatterns = nullptr; CandidateSimMuonMatcher* candidateSimMuonMatcher = nullptr; @@ -60,4 +60,4 @@ class EventCapture : public IOMTFEmulationObserver { std::unique_ptr stubsSimHitsMatcher; }; -#endif /* OMTF_EVENTCAPTURE_H_ */ +#endif /* L1T_OmtfP1_EVENTCAPTURE_H_ */ diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/Tools/GpResultsToPt.h b/L1Trigger/L1TMuonOverlapPhase1/interface/Tools/GpResultsToPt.h index 9b0df8561193e..cc5e0e486a96b 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/interface/Tools/GpResultsToPt.h +++ b/L1Trigger/L1TMuonOverlapPhase1/interface/Tools/GpResultsToPt.h @@ -5,8 +5,8 @@ * Author: kbunkow */ -#ifndef INTERFACE_OMTF_GPRESULTSTOPT_H_ -#define INTERFACE_OMTF_GPRESULTSTOPT_H_ +#ifndef L1T_OmtfP1_GPRESULTSTOPT_H_ +#define L1T_OmtfP1_GPRESULTSTOPT_H_ #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GoldenPattern.h" #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/AlgoMuon.h" @@ -64,4 +64,4 @@ class GpResultsToPt { std::vector ptGenInPats; }; -#endif /* INTERFACE_OMTF_GPRESULTSTOPT_H_ */ +#endif /* L1T_OmtfP1_GPRESULTSTOPT_H_ */ diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/Tools/OMTFConfigMaker.h b/L1Trigger/L1TMuonOverlapPhase1/interface/Tools/OMTFConfigMaker.h index 4d5e60e1210ec..5988a89f1d905 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/interface/Tools/OMTFConfigMaker.h +++ b/L1Trigger/L1TMuonOverlapPhase1/interface/Tools/OMTFConfigMaker.h @@ -1,5 +1,5 @@ -#ifndef OMTF_OMTFConfigMaker_H -#define OMTF_OMTFConfigMaker_H +#ifndef L1T_OmtfP1_OMTFConfigMaker_H +#define L1T_OmtfP1_OMTFConfigMaker_H #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFConfiguration.h" #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GoldenPattern.h" diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/Tools/PatternGenerator.h b/L1Trigger/L1TMuonOverlapPhase1/interface/Tools/PatternGenerator.h index 8325cb5602ce3..78737f3169381 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/interface/Tools/PatternGenerator.h +++ b/L1Trigger/L1TMuonOverlapPhase1/interface/Tools/PatternGenerator.h @@ -5,8 +5,8 @@ * Author: kbunkow */ -#ifndef OMTF_PATTERNGENERATOR_H_ -#define OMTF_PATTERNGENERATOR_H_ +#ifndef L1T_OmtfP1_PATTERNGENERATOR_H_ +#define L1T_OmtfP1_PATTERNGENERATOR_H_ #include "L1Trigger/L1TMuonOverlapPhase1/interface/Tools/PatternOptimizerBase.h" @@ -14,7 +14,7 @@ class PatternGenerator : public PatternOptimizerBase { public: PatternGenerator(const edm::ParameterSet& edmCfg, const OMTFConfiguration* omtfConfig, - std::vector >& gps); + GoldenPatternVec& gps); ~PatternGenerator() override; @@ -44,4 +44,4 @@ class PatternGenerator : public PatternOptimizerBase { std::vector eventCntPerGp; }; -#endif /* OMTF_PATTERNGENERATOR_H_ */ +#endif /* L1T_OmtfP1_PATTERNGENERATOR_H_ */ diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/Tools/PatternOptimizer.h b/L1Trigger/L1TMuonOverlapPhase1/interface/Tools/PatternOptimizer.h index 3d44360bd3bfd..1e25a9fc4aeee 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/interface/Tools/PatternOptimizer.h +++ b/L1Trigger/L1TMuonOverlapPhase1/interface/Tools/PatternOptimizer.h @@ -5,8 +5,8 @@ * Author: kbunkow */ -#ifndef OMTF_PATTERNOPTIMIZER_H_ -#define OMTF_PATTERNOPTIMIZER_H_ +#ifndef L1T_OmtfP1_PATTERNOPTIMIZER_H_ +#define L1T_OmtfP1_PATTERNOPTIMIZER_H_ #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GoldenPatternWithStat.h" #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/IOMTFEmulationObserver.h" @@ -26,7 +26,7 @@ class PatternOptimizer : public PatternOptimizerBase { public: PatternOptimizer(const edm::ParameterSet& edmCfg, const OMTFConfiguration* omtfConfig, - std::vector >& gps); + GoldenPatternVec& gps); ~PatternOptimizer() override; /* virtual void observeProcesorEmulation(unsigned int iProcessor, l1t::tftype mtfType, const OMTFinput &input, @@ -135,4 +135,4 @@ class PatternOptimizer : public PatternOptimizerBase { void modifyPatterns1(double step); }; -#endif /* OMTF_PATTERNOPTIMIZER_H_ */ +#endif /* L1T_OmtfP1_PATTERNOPTIMIZER_H_ */ diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/Tools/PatternOptimizerBase.h b/L1Trigger/L1TMuonOverlapPhase1/interface/Tools/PatternOptimizerBase.h index 5e0bd799c309f..0b88dbfc4c5b7 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/interface/Tools/PatternOptimizerBase.h +++ b/L1Trigger/L1TMuonOverlapPhase1/interface/Tools/PatternOptimizerBase.h @@ -5,12 +5,11 @@ * Author: kbunkow */ -#ifndef OMTF_PATTERNOPTIMIZERBASE_H_ -#define OMTF_PATTERNOPTIMIZERBASE_H_ +#ifndef L1T_OmtfP1_PATTERNOPTIMIZERBASE_H_ +#define L1T_OmtfP1_PATTERNOPTIMIZERBASE_H_ +#include "L1Trigger/L1TMuonOverlapPhase1/interface/Tools/EmulationObserverBase.h" #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GoldenPatternWithStat.h" -#include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/IOMTFEmulationObserver.h" -#include #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" @@ -21,35 +20,33 @@ #include "TH2I.h" #include "TFile.h" -class PatternOptimizerBase : public IOMTFEmulationObserver { +#include + +class PatternOptimizerBase : public EmulationObserverBase { public: static double vxMuRate(double pt_GeV); static double vxIntegMuRate(double pt_GeV, double dpt, double etaFrom, double etaTo); - - PatternOptimizerBase(const edm::ParameterSet& edmCfg, const OMTFConfiguration* omtfConfig); - + PatternOptimizerBase(const edm::ParameterSet& edmCfg, const OMTFConfiguration* omtfConfig, - std::vector >& gps); + GoldenPatternVec& gps); ~PatternOptimizerBase() override; - void observeProcesorEmulation(unsigned int iProcessor, +/* void observeProcesorEmulation(unsigned int iProcessor, l1t::tftype mtfType, const std::shared_ptr& input, const AlgoMuons& algoCandidates, const AlgoMuons& gbCandidates, const std::vector& candMuons) override; - void observeEventBegin(const edm::Event& iEvent) override; + void observeEventBegin(const edm::Event& iEvent) override;*/ void observeEventEnd(const edm::Event& iEvent, std::unique_ptr& finalCandidates) override; void endJob() override; - const SimTrack* findSimMuon(const edm::Event& event, const SimTrack* previous = nullptr); - protected: void savePatternsInRoot(std::string rootFileName); @@ -59,20 +56,7 @@ class PatternOptimizerBase : public IOMTFEmulationObserver { virtual void saveHists(TFile& outfile){}; - edm::ParameterSet edmCfg; - const OMTFConfiguration* omtfConfig; - - std::vector > goldenPatterns; - - const SimTrack* simMuon = nullptr; - - //candidate found by omtf in a given event - AlgoMuons::value_type omtfCand; - l1t::RegionalMuonCand regionalMuonCand; - - AlgoMuons algoCandidates; - - unsigned int candProcIndx = 0; + GoldenPatternVec& goldenPatterns; //GoldenPatternResult omtfResult; //GoldenPatternResult exptResult; @@ -85,4 +69,4 @@ class PatternOptimizerBase : public IOMTFEmulationObserver { bool writeLayerStat = false; }; -#endif /* OMTF_PATTERNOPTIMIZERBASE_H_ */ +#endif /* L1T_OmtfP1_PATTERNOPTIMIZERBASE_H_ */ diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/Tools/PatternsPtAssignment.h b/L1Trigger/L1TMuonOverlapPhase1/interface/Tools/PatternsPtAssignment.h deleted file mode 100644 index 7cd78b48ff55d..0000000000000 --- a/L1Trigger/L1TMuonOverlapPhase1/interface/Tools/PatternsPtAssignment.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * PatternsPtAssignment.h - * - * Created on: Mar 9, 2020 - * Author: kbunkow - */ - -#ifndef INTERFACE_TOOLS_PATTERNSPTASSIGNMENT_H_ -#define INTERFACE_TOOLS_PATTERNSPTASSIGNMENT_H_ - -#include "L1Trigger/L1TMuonOverlapPhase1/interface/Tools/GpResultsToPt.h" -#include "L1Trigger/L1TMuonOverlapPhase1/interface/Tools/PatternOptimizerBase.h" - -class PatternsPtAssignment : public PatternOptimizerBase { -public: - PatternsPtAssignment(const edm::ParameterSet& edmCfg, - const OMTFConfiguration* omtfConfig, - const std::vector >& gps, - std::string rootFileName); - - ~PatternsPtAssignment() override; - - void observeEventEnd(const edm::Event& iEvent, - std::unique_ptr& finalCandidates) override; - - void endJob() override; - -private: - std::vector > gps; - - GpResultsToPt* gpResultsToPt = nullptr; -}; - -#endif /* INTERFACE_TOOLS_PATTERNSPTASSIGNMENT_H_ */ diff --git a/L1Trigger/L1TMuonOverlapPhase1/interface/Tools/StubsSimHitsMatcher.h b/L1Trigger/L1TMuonOverlapPhase1/interface/Tools/StubsSimHitsMatcher.h index 394d59e5acef7..62ab9600b7658 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/interface/Tools/StubsSimHitsMatcher.h +++ b/L1Trigger/L1TMuonOverlapPhase1/interface/Tools/StubsSimHitsMatcher.h @@ -5,8 +5,8 @@ * Author: kbunkow */ -#ifndef OMTF__TOOLS_STUBSSIMHITSMATCHER_H_ -#define OMTF__TOOLS_STUBSSIMHITSMATCHER_H_ +#ifndef L1T_OmtfP1_TOOLS_STUBSSIMHITSMATCHER_H_ +#define L1T_OmtfP1_TOOLS_STUBSSIMHITSMATCHER_H_ #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/AlgoMuon.h" #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFinput.h" @@ -101,4 +101,4 @@ class StubsSimHitsMatcher { TH2I* rhoByPdgId = nullptr; }; -#endif /* OMTF__TOOLS_STUBSSIMHITSMATCHER_H_ */ +#endif /* L1T_OmtfP1_TOOLS_STUBSSIMHITSMATCHER_H_ */ diff --git a/L1Trigger/L1TMuonOverlapPhase1/plugins/L1MuonOverlapPhase1ParamsDBProducer.h b/L1Trigger/L1TMuonOverlapPhase1/plugins/L1MuonOverlapPhase1ParamsDBProducer.h index ab4b857ed62c5..af2a73c2502bb 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/plugins/L1MuonOverlapPhase1ParamsDBProducer.h +++ b/L1Trigger/L1TMuonOverlapPhase1/plugins/L1MuonOverlapPhase1ParamsDBProducer.h @@ -1,5 +1,5 @@ -#ifndef L1MuonOverlapParamsDBProducer_H -#define L1MuonOverlapParamsDBProducer_H +#ifndef L1T_OmtfP1_L1MuonOverlapParamsDBProducer_H +#define L1T_OmtfP1_L1MuonOverlapParamsDBProducer_H #include diff --git a/L1Trigger/L1TMuonOverlapPhase1/plugins/L1TMuonOverlapPhase1ParamsESProducer.h b/L1Trigger/L1TMuonOverlapPhase1/plugins/L1TMuonOverlapPhase1ParamsESProducer.h index 5cc16c9778edf..4cdb49788bc21 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/plugins/L1TMuonOverlapPhase1ParamsESProducer.h +++ b/L1Trigger/L1TMuonOverlapPhase1/plugins/L1TMuonOverlapPhase1ParamsESProducer.h @@ -1,3 +1,6 @@ +#ifndef L1T_OmtfP1_L1TMuonOverlapPhase1ParamsESProducer_H +#define L1T_OmtfP1_L1TMuonOverlapPhase1ParamsESProducer_H + #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFConfiguration.h" #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/XMLConfigReader.h" @@ -34,3 +37,5 @@ class L1TMuonOverlapPhase1ParamsESProducer : public edm::ESProducer { L1TMuonOverlapParams params; L1TMuonOverlapParams patterns; }; + +#endif //L1T_OmtfP1_L1TMuonOverlapPhase1ParamsESProducer_H diff --git a/L1Trigger/L1TMuonOverlapPhase1/plugins/L1TMuonOverlapPhase1TrackProducer.h b/L1Trigger/L1TMuonOverlapPhase1/plugins/L1TMuonOverlapPhase1TrackProducer.h index f39067fd958c8..2afdfdba94d0a 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/plugins/L1TMuonOverlapPhase1TrackProducer.h +++ b/L1Trigger/L1TMuonOverlapPhase1/plugins/L1TMuonOverlapPhase1TrackProducer.h @@ -1,5 +1,5 @@ -#ifndef OMTFProducer_H -#define OMTFProducer_H +#ifndef L1T_OmtfP1_L1TMuonOverlapPhase1TrackProducer_H +#define L1T_OmtfP1_L1TMuonOverlapPhase1TrackProducer_H #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFinputMaker.h" #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFProcessor.h" @@ -12,14 +12,20 @@ #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/one/EDProducer.h" #include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambPhContainer.h" #include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambThContainer.h" #include "DataFormats/CSCDigi/interface/CSCCorrelatedLCTDigiCollection.h" #include "DataFormats/RPCDigi/interface/RPCDigiCollection.h" -class L1TMuonOverlapPhase1TrackProducer : public edm::EDProducer { +/** + * The OMTF emulator cannot be run in multiple threads, because GoldenPatternBase keeps GoldenPatternResult's + * which are then used in the GoldenPatternBase::finalise called at the end of OMTFProcessor::processInput. + * Also patterns generation relies on updating the statistics for the patterns + * This can be fixed, but requires some work. + */ +class L1TMuonOverlapPhase1TrackProducer : public edm::one::EDProducer { public: L1TMuonOverlapPhase1TrackProducer(const edm::ParameterSet&); @@ -31,6 +37,8 @@ class L1TMuonOverlapPhase1TrackProducer : public edm::EDProducer { void beginRun(edm::Run const& run, edm::EventSetup const& iSetup) override; + virtual void endRun(edm::Run const& run, edm::EventSetup const& iSetup) override {}; + void produce(edm::Event&, const edm::EventSetup&) override; private: diff --git a/L1Trigger/L1TMuonOverlapPhase1/src/Omtf/OMTFProcessor.cc b/L1Trigger/L1TMuonOverlapPhase1/src/Omtf/OMTFProcessor.cc index ec5d120d6fe17..487a5fdb5e2df 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/src/Omtf/OMTFProcessor.cc +++ b/L1Trigger/L1TMuonOverlapPhase1/src/Omtf/OMTFProcessor.cc @@ -40,8 +40,8 @@ template OMTFProcessor::OMTFProcessor(OMTFConfiguration* omtfConfig, const edm::ParameterSet& edmCfg, edm::EventSetup const& evSetup, - const typename ProcessorBase::GoldenPatternVec& gps) - : ProcessorBase(omtfConfig, gps) { + GoldenPatternVec&& gps) + : ProcessorBase(omtfConfig, std::forward >(gps) ) { init(edmCfg, evSetup); }; diff --git a/L1Trigger/L1TMuonOverlapPhase1/src/Omtf/OMTFReconstruction.cc b/L1Trigger/L1TMuonOverlapPhase1/src/Omtf/OMTFReconstruction.cc index 0591fcb7bee1f..99acf71dc541e 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/src/Omtf/OMTFReconstruction.cc +++ b/L1Trigger/L1TMuonOverlapPhase1/src/Omtf/OMTFReconstruction.cc @@ -6,7 +6,6 @@ #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/XMLEventWriter.h" #include "L1Trigger/L1TMuonOverlapPhase1/interface/ProcConfigurationBase.h" #include "L1Trigger/L1TMuonOverlapPhase1/interface/Tools/CandidateSimMuonMatcher.h" -#include "L1Trigger/L1TMuonOverlapPhase1/interface/Tools/DataROOTDumper.h" #include "L1Trigger/L1TMuonOverlapPhase1/interface/Tools/DataROOTDumper2.h" #include "L1Trigger/L1TMuonOverlapPhase1/interface/Tools/EventCapture.h" #include "L1Trigger/L1TMuonOverlapPhase1/interface/Tools/PatternGenerator.h" @@ -73,32 +72,37 @@ void OMTFReconstruction::beginRun(edm::Run const& run, bool buildPatternsFromXml = (edmParameterSet.exists("patternsXMLFile") || edmParameterSet.exists("patternsXMLFiles")); - bool firstRun = (omtfProc == nullptr); + edm::LogImportant("OMTFReconstruction") << "OMTFReconstruction::beginRun "<configure(omtfParams); + omtfParams = &(eventSetup.getData(omtfParamsEsToken)); + if (!omtfParams) { + edm::LogError("OMTFReconstruction") << "Could not retrieve parameters from Event Setup" << std::endl; + } + omtfConfig->configure(omtfParams); - //the parameters can be overwritten from the python config - omtfConfig->configureFromEdmParameterSet(edmParameterSet); + //the parameters can be overwritten from the python config + omtfConfig->configureFromEdmParameterSet(edmParameterSet); - inputMaker->initialize(edmParameterSet, eventSetup, muonGeometryTokens); + inputMaker->initialize(edmParameterSet, eventSetup, muonGeometryTokens); - //patterns from the edm::EventSetup are reloaded every beginRun - if (buildPatternsFromXml == false) { - edm::LogImportant("OMTFReconstruction") << "getting patterns from EventSetup" << std::endl; - if (processorType == "OMTFProcessor") - omtfProc = - std::make_unique >(omtfConfig.get(), edmParameterSet, eventSetup, omtfParams); + //patterns from the edm::EventSetup are reloaded every beginRun + if (buildPatternsFromXml == false) { + edm::LogImportant("OMTFReconstruction") << "getting patterns from EventSetup" << std::endl; + if (processorType == "OMTFProcessor") { + omtfProc = + std::make_unique >(omtfConfig.get(), edmParameterSet, eventSetup, omtfParams); + omtfProc->printInfo(); + } + } } } @@ -126,47 +130,36 @@ void OMTFReconstruction::beginRun(edm::Run const& run, //std::cout<<__FUNCTION__<<":"<<__LINE__<(*omtfParams, patternsXMLFiles, false); - if (processorType == "OMTFProcessor") { - omtfProc = std::make_unique >(omtfConfig.get(), edmParameterSet, eventSetup, gps); + omtfProc = std::make_unique >(omtfConfig.get(), edmParameterSet, eventSetup, + xmlReader.readPatterns(*omtfParams, patternsXMLFiles, false) ); } edm::LogImportant("OMTFReconstruction") - << "OMTFProcessor constructed. processorType " << processorType << ". GoldenPattern type: " << patternType - << " size: " << gps.size() << std::endl; - } else if (patternType == "GoldenPatternWithStat") { - std::cout << __FUNCTION__ << ":" << __LINE__ << std::endl; + << "OMTFProcessor constructed. processorType " << processorType << ". GoldenPattern type: " << patternType << std::endl; + } + else if (patternType == "GoldenPatternWithStat") { + //pattern generation is only possible if the processor is constructed only once per job + //PatternGenerator modifies the patterns!!! + if (processorType == "OMTFProcessor") { + omtfProc = std::make_unique >(omtfConfig.get(), edmParameterSet, eventSetup, + xmlReader.readPatterns(*omtfParams, patternsXMLFiles, false)); - auto gps = xmlReader.readPatterns(*omtfParams, patternsXMLFiles, false); + auto omtfProcGoldenPat = dynamic_cast*>(omtfProc.get()); - if (processorType == "OMTFProcessor") { if (edmParameterSet.exists("optimizePatterns") && edmParameterSet.getParameter("optimizePatterns")) { - observers.emplace_back(std::make_unique(edmParameterSet, omtfConfig.get(), gps)); + observers.emplace_back(std::make_unique(edmParameterSet, omtfConfig.get(), omtfProcGoldenPat->getPatterns())); } if (edmParameterSet.exists("generatePatterns") && edmParameterSet.getParameter("generatePatterns")) { - observers.emplace_back(std::make_unique(edmParameterSet, omtfConfig.get(), gps)); + observers.emplace_back(std::make_unique(edmParameterSet, omtfConfig.get(), omtfProcGoldenPat->getPatterns())); edm::LogImportant("OMTFReconstruction") << "generatePatterns: true " << std::endl; } - - omtfProc = - std::make_unique >(omtfConfig.get(), edmParameterSet, eventSetup, gps); } - } else if (patternType == "GoldenPatternWithThresh") { - std::cout << __FUNCTION__ << ":" << __LINE__ << std::endl; - auto gps = xmlReader.readPatterns(*omtfParams, patternsXMLFiles, false); - - omtfProc = - std::make_unique >(omtfConfig.get(), edmParameterSet, eventSetup, gps); - edm::LogImportant("OMTFReconstruction") - << "OMTFProcessor constructed. GoldenPattern type: " << patternType << " size: " << gps.size() << std::endl; } else { throw cms::Exception("OMTFReconstruction::beginRun: unknown GoldenPattern type: " + patternType); } - } - if (firstRun) { omtfProc->printInfo(); } @@ -186,6 +179,7 @@ void OMTFReconstruction::addObservers( edm::LogImportant("OMTFReconstruction")<<"OMTFReconstruction::addObservers "<("dumpResultToXML")) observers.emplace_back(std::make_unique( @@ -202,25 +196,23 @@ void OMTFReconstruction::addObservers( } } - if (edmParameterSet.exists("dumpResultToROOT")) - if (edmParameterSet.getParameter("dumpResultToROOT")) - observers.emplace_back(std::make_unique(edmParameterSet, omtfConfig.get())); - auto omtfProcGoldenPat = dynamic_cast*>(omtfProc.get()); if (omtfProcGoldenPat) { if (edmParameterSet.exists("eventCaptureDebug")) if (edmParameterSet.getParameter("eventCaptureDebug")) { observers.emplace_back(std::make_unique(edmParameterSet, omtfConfig.get(), - omtfProcGoldenPat->getPatterns(), candidateSimMuonMatcher, - muonGeometryTokens)); + muonGeometryTokens + //&(omtfProcGoldenPat->getPatterns() ), + //watch out, will crash if the proc is re-constructed from the DB after L1TMuonOverlapParamsRcd change + )); } if (edmParameterSet.exists("dumpHitsToROOT") && edmParameterSet.getParameter("dumpHitsToROOT")) { std::string rootFileName = edmParameterSet.getParameter("dumpHitsFileName"); observers.emplace_back(std::make_unique( - edmParameterSet, omtfConfig.get(), omtfProcGoldenPat->getPatterns(), rootFileName)); + edmParameterSet, omtfConfig.get(), rootFileName)); } } } diff --git a/L1Trigger/L1TMuonOverlapPhase1/src/Omtf/OMTFSorter.cc b/L1Trigger/L1TMuonOverlapPhase1/src/Omtf/OMTFSorter.cc index d3f6f56e78a3e..ceaf25408ee58 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/src/Omtf/OMTFSorter.cc +++ b/L1Trigger/L1TMuonOverlapPhase1/src/Omtf/OMTFSorter.cc @@ -18,7 +18,7 @@ template AlgoMuons::value_type OMTFSorter::sortRefHitResults( unsigned int procIndx, unsigned int iRefHit, - const std::vector >& gPatterns, + const GoldenPatternVec& gPatterns, int charge) { GoldenPatternType* bestGP = nullptr; //the GoldenPattern with the best result for this iRefHit //std::cout <<" ====== sortRefHitResults: " << std::endl; diff --git a/L1Trigger/L1TMuonOverlapPhase1/src/Omtf/OMTFSorterWithThreshold.cc b/L1Trigger/L1TMuonOverlapPhase1/src/Omtf/OMTFSorterWithThreshold.cc deleted file mode 100644 index 393747c077897..0000000000000 --- a/L1Trigger/L1TMuonOverlapPhase1/src/Omtf/OMTFSorterWithThreshold.cc +++ /dev/null @@ -1,160 +0,0 @@ -#include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFSorterWithThreshold.h" -#include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GoldenPatternWithStat.h" -#include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFConfiguration.h" - -#include -#include -#include -#include -#include - -#include "FWCore/MessageLogger/interface/MessageLogger.h" - -#include "L1Trigger/RPCTrigger/interface/RPCConst.h" -/////////////////////////////////////////////////////// -/////////////////////////////////////////////////////// -template -AlgoMuons::value_type OMTFSorterWithThreshold::sortRefHitResults( - unsigned int procIndx, - unsigned int iRefHit, - const std::vector >& gPatterns, - int charge) { - //this sorting is needed for the bestGPByThresholdOnProbability2 due to sum of the probabilities of gp with >= pt ten the current onegetGpProbability2 - if (gPatternsSortedByPt.empty()) { - gPatternsSortedByPt = gPatterns; - - auto customLess = [&](const std::shared_ptr& a, - const std::shared_ptr& b) -> bool { - if (a->key().thePt < b->key().thePt) - return true; - else if (a->key().thePt == b->key().thePt) { - if (a->key().theCharge > b->key().theCharge) - return true; - else if (a->key().theCharge == b->key().theCharge) { //matters for the empty patterns - if (a->key().theNumber < b->key().theNumber) - return true; - } - } - return false; - }; - - std::sort(gPatternsSortedByPt.rbegin(), gPatternsSortedByPt.rend(), customLess); - - for (auto& itGP : gPatternsSortedByPt) { - std::cout << __FUNCTION__ << " line " << __LINE__ << " " << itGP->key() << std::endl; - } - } - - GoldenPatternWithThresh* bestGP = nullptr; //the GoldenPattern with the best result for this iRefHit - // std::cout <<" ====== sortRefHitResults: " << std::endl; - - double p_deltaPhis1 = 0; - //Calculating p_deltaPhis = P(delta_phis) = Sum_pt P(delta_phis | ptMu == gpPt) * P(ptMu == gpPt) - denominator of the Bayes formula - unsigned int maxFiredLayerCnt = 0; - for (auto& itGP : gPatterns) { - GoldenPatternResult& result = itGP->getResults()[procIndx][iRefHit]; - if (!result.isValid()) - continue; - - if (charge != 0 && itGP->key().theCharge != charge) - continue; //charge==0 means ignore charge - - ///Accept only candidates with >2 hits - if (result.getFiredLayerCnt() < 3) //TODO - move 3 to the configuration?? - continue; - - //the class probability is stored in the pdf of refLayer, in the central bin, and is included in the getPdfWeigtSum() - //result.getFiredLayerCnt() = P(delta_phis | ptMu == gpPt) * P(ptMu == gpPt) - if (result.getFiredLayerCnt() > maxFiredLayerCnt) { - maxFiredLayerCnt = result.getFiredLayerCnt(); - p_deltaPhis1 = result.getPdfSum(); //cleaning p_deltaPhis acquired with the smaller number of fired layers - } else if (result.getFiredLayerCnt() == maxFiredLayerCnt) { - p_deltaPhis1 += result.getPdfSum(); - } - } - - double maxGpProbability1 = 0; - //std::cout<<__FUNCTION__<<" line "<<__LINE__<<" procIndx "<getResults()[procIndx][iRefHit]; - if (!result.isValid()) - continue; - - if (charge != 0 && itGP->key().theCharge != charge) - continue; //charge==0 means ignore charge - - ///Accept only candidates with >2 hits - if (result.getFiredLayerCnt() < 3) //TODO - move 3 to the configuration?? - continue; - - if (result.getFiredLayerCnt() < maxFiredLayerCnt) - continue; - - //calculating P(ptMu = gpPt | delta_phis) - //if(p_deltaPhis1 > 0) it is impossible that p_deltaPhis1 is 0 here - { - double gpProbability1 = result.getPdfSum() / p_deltaPhis1; - result.setGpProbability1(gpProbability1); - } - - //calculating P(ptMu >= gpPt | delta_phis) - p_deltaPhis2 += result.getPdfSum(); - /*if(p_deltaPhis2 > 0) { - double gpProbability2 = result.getPdfSum() / p_deltaPhis2; - result.setGpProbability2(gpProbability2); - }*/ - //if(p_deltaPhis1 > 0) - { - double gpProbability2 = p_deltaPhis2 / p_deltaPhis1; - result.setGpProbability2(gpProbability2); - } - - /* - int refLayerLogicNumber = myOmtfConfig->getRefToLogicNumber()[result.getRefLayer()]; - double ptProbability = itGP->pdfValue(refLayerLogicNumber, result.getRefLayer(), myOmtfConfig->nPdfBins()/2 ); - std::cout<<__FUNCTION__<<" line "<<__LINE__ << itGP->key()<<" refLayerLogicNumber "<= itGP->getThreshold(result.getRefLayer())) { - if (bestGP == nullptr) //|| itGP->key().thePt > bestGP->key().thePt - bestGP = itGP.get(); - else if (itGP->key().thePt == bestGP->key().thePt) { - if (result.getGpProbability1() > bestGP->getResults()[procIndx][iRefHit].getGpProbability1()) - bestGP = itGP.get(); - } - //we take the one with the highest (i.e. pt) among these with the same FiredLayerCnt (the loop is from the last pattern) - //std::cout<<__FUNCTION__<<" line "<<__LINE__ <<" "<key()<<" getGpProbability1 "<getThreshold(0)<<" FiredLayerCnt "< maxGpProbability1) { //max likelihood option, TODO - comment/uncomment if needed - maxGpProbability1 = result.getGpProbability1(); - bestGP = itGP.get(); - //std::cout<<__FUNCTION__<<" line "<<__LINE__ << " passed threshold "<getTreshold(result.getRefLayer() )<getResults()[procIndx][iRefHit], bestGP, iRefHit)); - //std::cout<<__FUNCTION__<<" line "<<__LINE__ <<" return: " << candidate << std::endl; - return candidate; - } else { - AlgoMuons::value_type candidate(new AlgoMuon()); - candidate->setRefHitNumber(iRefHit); - return candidate; - } -} - -template class OMTFSorterWithThreshold; -template class OMTFSorterWithThreshold; diff --git a/L1Trigger/L1TMuonOverlapPhase1/src/Omtf/ProcessorBase.cc b/L1Trigger/L1TMuonOverlapPhase1/src/Omtf/ProcessorBase.cc index 727a5092fbcf2..804906fca73f3 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/src/Omtf/ProcessorBase.cc +++ b/L1Trigger/L1TMuonOverlapPhase1/src/Omtf/ProcessorBase.cc @@ -17,6 +17,19 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Utilities/interface/Exception.h" +template +ProcessorBase::ProcessorBase(OMTFConfiguration* omtfConfig, GoldenPatternVec&& gps) : +myOmtfConfig(omtfConfig), theGPs(std::move(gps)) { + for (auto& gp : theGPs) { + gp->setConfig(myOmtfConfig); + } + + initPatternPtRange(true); + + //initPatternPtRange(true); is called in the setGPs + omtfConfig->setPatternPtRange(getPatternPtRange()); +}; + template void ProcessorBase::resetConfiguration() { theGPs.clear(); @@ -45,7 +58,7 @@ bool ProcessorBase::configure(OMTFConfiguration* omtfConfig, unsigned int address = 0; unsigned int iEta, iPt; int iCharge; - int meanDistPhiSize = myOmtfConfig->nLayers() * myOmtfConfig->nRefLayers() * myOmtfConfig->nGoldenPatterns(); + //int meanDistPhiSize = myOmtfConfig->nLayers() * myOmtfConfig->nRefLayers() * myOmtfConfig->nGoldenPatterns(); unsigned int group = 0; unsigned int indexInGroup = 0; @@ -129,17 +142,6 @@ void ProcessorBase::addGP(GoldenPatternType* aGP) { theGPs.emplace_back(std::unique_ptr(aGP)); } -//////////////////////////////////////////// -//////////////////////////////////////////// -template -void ProcessorBase::setGPs(const GoldenPatternVec& gps) { - theGPs = gps; - for (auto& gp : theGPs) { - gp->setConfig(myOmtfConfig); - } - - initPatternPtRange(true); -} //////////////////////////////////////////// //////////////////////////////////////////// template diff --git a/L1Trigger/L1TMuonOverlapPhase1/src/Omtf/XMLConfigReader.cc b/L1Trigger/L1TMuonOverlapPhase1/src/Omtf/XMLConfigReader.cc index 8848859e1898a..7aee031371744 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/src/Omtf/XMLConfigReader.cc +++ b/L1Trigger/L1TMuonOverlapPhase1/src/Omtf/XMLConfigReader.cc @@ -63,7 +63,7 @@ void XMLConfigReader::readLUTs(std::vector luts, const L1TMuonOverlapParams &aConfig, const std::vector &types) { ///Fill payload string - std::vector > aGPs = readPatterns(aConfig, patternsFiles, true); + auto aGPs = readPatterns(aConfig, patternsFiles, true); edm::LogVerbatim("OMTFReconstruction") << "XMLConfigReader::readLUTs: aGPs.size() " << aGPs.size() @@ -131,7 +131,7 @@ void XMLConfigReader::readLUTs(std::vector luts, unsigned int in = 0; int out = 0; - for (auto it : aGPs) { + for (auto& it : aGPs) { if (type == "iCharge") out = it->key().theCharge == -1 ? 0 : 1; //changing only -1 (negative charge) to 0 (to avoid negative numbers in LUT?) -N.B. that this is not the uGMT charge convention!!!! @@ -233,10 +233,10 @@ unsigned int XMLConfigReader::getPatternsVersion() const { ////////////////////////////////////////////////// ////////////////////////////////////////////////// template -std::vector > XMLConfigReader::readPatterns(const L1TMuonOverlapParams &aConfig, +GoldenPatternVec XMLConfigReader::readPatterns(const L1TMuonOverlapParams &aConfig, const std::string &patternsFile, bool buildEmptyPatterns, bool resetNumbering) { - std::vector > aGPs; + GoldenPatternVec aGPs; aGPs.clear(); XMLPlatformUtils::Initialize(); @@ -310,14 +310,15 @@ std::vector > XMLConfigReader::readPatterns(c ////////////////////////////////////////////////// ////////////////////////////////////////////////// template -std::vector > XMLConfigReader::readPatterns( +GoldenPatternVec XMLConfigReader::readPatterns( const L1TMuonOverlapParams &aConfig, const std::vector &patternsFiles, bool buildEmptyPatterns) { iGPNumber = 0; iPatternGroup = 0; - std::vector > aGPs; + GoldenPatternVec aGPs; for (auto aPatternsFile : patternsFiles) { auto tmpGPs = readPatterns(aConfig, aPatternsFile, buildEmptyPatterns, false); - aGPs.insert(aGPs.end(), tmpGPs.begin(), tmpGPs.end()); + for(auto& gp : tmpGPs) + aGPs.push_back(std::move(gp)); } return aGPs; } @@ -771,14 +772,20 @@ void XMLConfigReader::readConfig(L1TMuonOverlapParams *aConfig) const { // xercesc::XercesDOMParser *parser; // xercesc::DOMDocument* doc; -template std::vector > XMLConfigReader::readPatterns( +template GoldenPatternVec XMLConfigReader::readPatterns( const L1TMuonOverlapParams &aConfig, const std::string &patternsFile, bool buildEmptyPatterns, bool resetNumbering = true); -template std::vector > XMLConfigReader::readPatterns( - const L1TMuonOverlapParams &aConfig, const std::vector &patternsFiles, bool buildEmptyPatterns); +template GoldenPatternVec XMLConfigReader::readPatterns( + const L1TMuonOverlapParams &aConfig, const std::vector& patternsFiles, bool buildEmptyPatterns); -template std::vector > XMLConfigReader::readPatterns( +template GoldenPatternVec XMLConfigReader::readPatterns( const L1TMuonOverlapParams &aConfig, const std::string &patternsFile, bool buildEmptyPatterns, bool resetNumbering = true); -template std::vector > XMLConfigReader::readPatterns( - const L1TMuonOverlapParams &aConfig, const std::vector &patternsFiles, bool buildEmptyPatterns); +template GoldenPatternVec XMLConfigReader::readPatterns( + const L1TMuonOverlapParams &aConfig, const std::vector& patternsFiles, bool buildEmptyPatterns); + +/*template std::vector > XMLConfigReader::readPatterns( + const L1TMuonOverlapParams &aConfig, const std::string &patternsFile, bool buildEmptyPatterns, bool resetNumbering = true); + +template std::vector > XMLConfigReader::readPatterns( + const L1TMuonOverlapParams &aConfig, const std::vector &patternsFiles, bool buildEmptyPatterns);*/ diff --git a/L1Trigger/L1TMuonOverlapPhase1/src/Omtf/XMLConfigWriter.cc b/L1Trigger/L1TMuonOverlapPhase1/src/Omtf/XMLConfigWriter.cc index f1286700c1504..b7b4600e8f44c 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/src/Omtf/XMLConfigWriter.cc +++ b/L1Trigger/L1TMuonOverlapPhase1/src/Omtf/XMLConfigWriter.cc @@ -529,7 +529,7 @@ void XMLConfigWriter::writeGPData(GoldenPattern* aGP1, GoldenPattern* aGP2, Gold ////////////////////////////////////////////////// ////////////////////////////////////////////////// template -void XMLConfigWriter::writeGPs(const std::vector >& goldenPats, std::string fName) { +void XMLConfigWriter::writeGPs(const GoldenPatternVec& goldenPats, std::string fName) { initialiseXMLDocument("OMTF"); GoldenPattern* dummy = new GoldenPatternWithThresh(Key(0, 0, 0), myOMTFConfig); @@ -707,12 +707,12 @@ unsigned int XMLConfigWriter::findMaxInput(const OMTFConfiguration::vector1D& my } ///////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////// -template void XMLConfigWriter::writeGPs(const std::vector >& goldenPats, +template void XMLConfigWriter::writeGPs(const GoldenPatternVec& goldenPats, std::string fName); -template void XMLConfigWriter::writeGPs(const std::vector >& goldenPats, +template void XMLConfigWriter::writeGPs(const GoldenPatternVec& goldenPats, std::string fName); -template void XMLConfigWriter::writeGPs(const std::vector >& goldenPats, +template void XMLConfigWriter::writeGPs(const GoldenPatternVec& goldenPats, std::string fName); diff --git a/L1Trigger/L1TMuonOverlapPhase1/src/Tools/CandidateSimMuonMatcher.cc b/L1Trigger/L1TMuonOverlapPhase1/src/Tools/CandidateSimMuonMatcher.cc index f5b645c6098c0..4c628cb1665f8 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/src/Tools/CandidateSimMuonMatcher.cc +++ b/L1Trigger/L1TMuonOverlapPhase1/src/Tools/CandidateSimMuonMatcher.cc @@ -63,6 +63,7 @@ void CandidateSimMuonMatcher::beginRun(const edm::EventSetup& eventSetup) { //eventSetup.get().get(magField); //eventSetup.get().get("SteppingHelixPropagatorAlong", propagator); + //TODO use edm::ESWatcher magneticFieldRecordWatcher; magField = eventSetup.getHandle(magneticFieldEsToken); propagator = eventSetup.getHandle(propagatorEsToken); } @@ -91,8 +92,8 @@ bool simTrackIsMuonInOmtf(const SimTrack& simTrack) { } else return false; - if (simTrack.momentum().pt() < - 2.5) //in the overlap, the propagation of muons with pt less then ~3.2 fails - the actual threshold depends slightly on eta, + //in the overlap, the propagation of muons with pt less then ~3.2 fails - the actual threshold depends slightly on eta, + if (simTrack.momentum().pt() < 2.5) return false; LogTrace("l1tOmtfEventPrint") << "simTrackIsMuonInOmtf, simTrack type " << std::setw(3) << simTrack.type() << " pt " diff --git a/L1Trigger/L1TMuonOverlapPhase1/src/Tools/DataROOTDumper.cc b/L1Trigger/L1TMuonOverlapPhase1/src/Tools/DataROOTDumper.cc deleted file mode 100644 index ab7ffdaeae64e..0000000000000 --- a/L1Trigger/L1TMuonOverlapPhase1/src/Tools/DataROOTDumper.cc +++ /dev/null @@ -1,129 +0,0 @@ -/* - * DataROOTDumper.cc - * - * Created on: Tue Apr 16 09:57:08 CEST 2019 - * Author: akalinow - */ -#include "L1Trigger/L1TMuonOverlapPhase1/interface/Tools/DataROOTDumper.h" - -#include "FWCore/MessageLogger/interface/MessageLogger.h" - -#include -#include -#include "TFile.h" -#include "TTree.h" - -///////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////// -DataROOTDumper::DataROOTDumper(const edm::ParameterSet& edmCfg, const OMTFConfiguration* omtfConfig) - : PatternOptimizerBase(edmCfg, omtfConfig) { - initializeTTree(); -} -///////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////// -void DataROOTDumper::initializeTTree() { - myFile = new TFile("OMTFHits.root", "RECREATE"); - myTree = new TTree("OMTFHitsTree", ""); - myTree->Branch("muonPt", &myEvent.muonPt); - myTree->Branch("muonEta", &myEvent.muonEta); - myTree->Branch("muonPhi", &myEvent.muonPhi); - myTree->Branch("muonCharge", &myEvent.muonCharge); - - myTree->Branch("omtfPt", &myEvent.omtfPt); - myTree->Branch("omtfEta", &myEvent.omtfEta); - myTree->Branch("omtfPhi", &myEvent.omtfPhi); - myTree->Branch("omtfCharge", &myEvent.omtfCharge); - - myTree->Branch("omtfScore", &myEvent.omtfScore); - myTree->Branch("omtfQuality", &myEvent.omtfQuality); - myTree->Branch("omtfRefLayer", &myEvent.omtfRefLayer); - myTree->Branch("omtfProcessor", &myEvent.omtfProcessor); - - myTree->Branch("hits", &myEvent.hits); - myTree->Branch("hitsQuality", &myEvent.hitsQuality); -} -///////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////// -void DataROOTDumper::saveTTree() { - myFile->Write(); - delete myFile; - delete myTree; -} -///////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////// -DataROOTDumper::~DataROOTDumper() { saveTTree(); } -///////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////// -void DataROOTDumper::observeProcesorEmulation(unsigned int iProcessor, - l1t::tftype mtfType, - const std::shared_ptr& input, - const AlgoMuons& algoCandidates, - const AlgoMuons& gbCandidates, - const std::vector& candMuons) { - PatternOptimizerBase::observeProcesorEmulation(iProcessor, mtfType, input, algoCandidates, gbCandidates, candMuons); - - myEvent.omtfPt = 0; - - std::map hwAddrMap = regionalMuonCand.trackAddress(); - std::bitset<21> hitWord(hwAddrMap[0]); - std::vector tmpPhi, tmpQuality; - - if (omtfCand->getPt() > 0 && regionalMuonCand.hwPt() > 0 && regionalMuonCand.hwQual() >= 12) { - myEvent.omtfPt = (regionalMuonCand.hwPt() - 1) / 2.0; - myEvent.omtfEta = regionalMuonCand.hwEta() / 240. * 2.61; - myEvent.omtfPhi = regionalMuonCand.hwPhi(); - myEvent.omtfCharge = std::pow(-1, regionalMuonCand.hwSign()); - myEvent.omtfScore = hwAddrMap[2]; - myEvent.omtfQuality = regionalMuonCand.hwQual(); - myEvent.omtfRefLayer = hwAddrMap[1]; - myEvent.omtfHitsWord = hwAddrMap[0]; - myEvent.omtfProcessor = iProcessor; - - myEvent.hits.clear(); - myEvent.hitsQuality.clear(); - int phi, hwQuality, tmp, sign; - for (unsigned int iLogicLayer = 0; iLogicLayer < omtfConfig->nLayers(); ++iLogicLayer) { - for (unsigned int iHit = 0; iHit < omtfConfig->nInputs(); ++iHit) { - phi = input->getPhiHw(iLogicLayer, iHit); - if (phi != 5400) { - if (!input->getMuonStub(iLogicLayer, iHit)) - hwQuality = input->getMuonStub(iLogicLayer - 1, iHit)->qualityHw; - else - hwQuality = input->getMuonStub(iLogicLayer, iHit)->qualityHw; - if (phi < 0) { - sign = 1; - phi = std::abs(phi); - } else - sign = 0; - tmp = (phi << 10) + (iLogicLayer << 5) + iHit; - tmp *= std::pow(-1, sign); - myEvent.hits.push_back(tmp); - myEvent.hitsQuality.push_back((hwQuality << 10) + (iLogicLayer << 5) + iHit); - } - } - } - } -} -///////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////// -void DataROOTDumper::observeEventEnd(const edm::Event& iEvent, - std::unique_ptr& finalCandidates) { - //no sim muon or empty candidate - if (simMuon == nullptr) { - myEvent.muonPt = -999.0; - myTree->Fill(); - return; - } - - myEvent.muonPt = simMuon->momentum().pt(); - myEvent.muonEta = simMuon->momentum().eta(); - myEvent.muonPhi = simMuon->momentum().phi(); - myEvent.muonCharge = (abs(simMuon->type()) == 13) ? simMuon->type() / -13 : 0; - - myTree->Fill(); -} -///////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////// -void DataROOTDumper::endJob() {} -///////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////// diff --git a/L1Trigger/L1TMuonOverlapPhase1/src/Tools/DataROOTDumper2.cc b/L1Trigger/L1TMuonOverlapPhase1/src/Tools/DataROOTDumper2.cc index c70f9a2b96807..9749091cc32ca 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/src/Tools/DataROOTDumper2.cc +++ b/L1Trigger/L1TMuonOverlapPhase1/src/Tools/DataROOTDumper2.cc @@ -27,15 +27,14 @@ DataROOTDumper2::DataROOTDumper2(const edm::ParameterSet& edmCfg, const OMTFConfiguration* omtfConfig, - const std::vector >& gps, std::string rootFileName) - : PatternOptimizerBase(edmCfg, omtfConfig), gps(gps), event(omtfConfig->nTestRefHits(), gps.size()) { - edm::LogVerbatim("l1tOmtfEventPrint") << " gps.size() " << gps.size() << " omtfConfig->nTestRefHits() " + : EmulationObserverBase(edmCfg, omtfConfig) { + edm::LogVerbatim("l1tOmtfEventPrint") << " omtfConfig->nTestRefHits() " << omtfConfig->nTestRefHits() << " event.omtfGpResultsPdfSum.num_elements() " - << event.omtfGpResultsPdfSum.num_elements() << endl; + << endl; initializeTTree(rootFileName); - if (false) { //TODO!!!!!!!!!!!! +/* if (false) { //TODO!!!!!!!!!!!! gpResultsToPt = new GpResultsToPt(gps, omtfConfig); //TODO move to processor std::string fileName = edmCfg.getParameter("gpResultsToPtFile"); @@ -49,7 +48,7 @@ DataROOTDumper2::DataROOTDumper2(const edm::ParameterSet& edmCfg, edm::LogImportant("l1tOmtfEventPrint") << __FUNCTION__ << ": " << __LINE__ << " writing gpResultsToPt to file " << fileName << std::endl; inArch >> *gpResultsToPt; - } + }*/ edm::LogVerbatim("l1tOmtfEventPrint") << " DataROOTDumper2 created"<Branch("muonPt", &event.muonPt); - rootTree->Branch("muonEta", &event.muonEta); - rootTree->Branch("muonPhi", &event.muonPhi); - rootTree->Branch("muonCharge", &event.muonCharge); - - rootTree->Branch("omtfPt", &event.omtfPt); - rootTree->Branch("omtfEta", &event.omtfEta); - rootTree->Branch("omtfPhi", &event.omtfPhi); - rootTree->Branch("omtfCharge", &event.omtfCharge); - - rootTree->Branch("omtfScore", &event.omtfScore); - rootTree->Branch("omtfQuality", &event.omtfQuality); - rootTree->Branch("omtfRefLayer", &event.omtfRefLayer); - rootTree->Branch("omtfProcessor", &event.omtfProcessor); - - rootTree->Branch("omtfFiredLayers", &event.omtfFiredLayers); //<<<<<<<<<<<<<<<<<<<<<Branch("omtfPtCont", &event.omtfPtCont); + rootTree->Branch("muonPt", &omtfEvent.muonPt); + rootTree->Branch("muonEta", &omtfEvent.muonEta); + rootTree->Branch("muonPhi", &omtfEvent.muonPhi); + rootTree->Branch("muonCharge", &omtfEvent.muonCharge); - rootTree->Branch("hits", &event.hits); + rootTree->Branch("omtfPt", &omtfEvent.omtfPt); + rootTree->Branch("omtfEta", &omtfEvent.omtfEta); + rootTree->Branch("omtfPhi", &omtfEvent.omtfPhi); + rootTree->Branch("omtfCharge", &omtfEvent.omtfCharge); - if (dumpGpResults) { //TODO not finished, probably has no sense + rootTree->Branch("omtfScore", &omtfEvent.omtfScore); + rootTree->Branch("omtfQuality", &omtfEvent.omtfQuality); + rootTree->Branch("omtfRefLayer", &omtfEvent.omtfRefLayer); + rootTree->Branch("omtfProcessor", &omtfEvent.omtfProcessor); - unsigned int elementCnt = event.omtfGpResultsPdfSum.num_elements(); - rootTree->Branch("omtfGpResultsPdfSum", - event.omtfGpResultsPdfSum.data(), - ("omtfGpResultsPdfSum[" + to_string(elementCnt) + "]/F").c_str()); - - elementCnt = event.omtfGpResultsPdfSum.num_elements(); - rootTree->Branch("omtfGpResultsFiredLayers", - event.omtfGpResultsFiredLayers.data(), - ("omtfGpResultsFiredLayers[" + to_string(elementCnt) + "]/F").c_str()); - - edm::LogVerbatim("l1tOmtfEventPrint") << " dumpGpResults " - << " omtfGpResultsFiredLayers elementCnt " << elementCnt << std::endl; - - //rootTree->GetUserInfo()->Add(new TParameter("elementCnt", elementCnt)); - rootTree->GetUserInfo()->Add(new TObjString(("elementCnt:" + to_string(elementCnt)).c_str())); - } + rootTree->Branch("omtfFiredLayers", &omtfEvent.omtfFiredLayers); //<<<<<<<<<<<<<<<<<<<<<momentum().pt(); - event.muonEta = simMuon->momentum().eta(); + omtfEvent.muonPt = simMuon->momentum().pt(); + omtfEvent.muonEta = simMuon->momentum().eta(); /* if(abs(event.muonEta) < 0.8 || abs(event.muonEta) > 1.24) return;*/ - event.muonPhi = simMuon->momentum().phi(); - event.muonCharge = muonCharge; //TODO + omtfEvent.muonPhi = simMuon->momentum().phi(); + omtfEvent.muonCharge = muonCharge; //TODO if (omtfCand->getPt() > 0) { //&& omtfCand->getFiredLayerCnt() > 3 - event.omtfPt = (omtfCand->getPt() - 1) / 2.0; //TODO check - event.omtfEta = omtfCand->getEtaHw() / 240. * 2.61; - event.omtfPhi = omtfCand->getPhi(); - event.omtfCharge = std::pow(-1, regionalMuonCand.hwSign()); - event.omtfScore = omtfCand->getPdfSum(); - event.omtfQuality = regionalMuonCand.hwQual(); //omtfCand->getQ(); - event.omtfFiredLayers = omtfCand->getFiredLayerBits(); - event.omtfRefLayer = omtfCand->getRefLayer(); - event.omtfProcessor = candProcIndx; - - if (gpResultsToPt) - event.omtfPtCont = omtfConfig->hwPtToGev(gpResultsToPt->getValue(omtfCand, candProcIndx)); - - event.hits.clear(); + omtfEvent.omtfPt = (omtfCand->getPt() - 1) / 2.0; //TODO check + omtfEvent.omtfEta = omtfCand->getEtaHw() / 240. * 2.61; + omtfEvent.omtfPhi = omtfCand->getPhi(); + omtfEvent.omtfCharge = std::pow(-1, regionalMuonCand.hwSign()); + omtfEvent.omtfScore = omtfCand->getPdfSum(); + omtfEvent.omtfQuality = regionalMuonCand.hwQual(); //omtfCand->getQ(); + omtfEvent.omtfFiredLayers = omtfCand->getFiredLayerBits(); + omtfEvent.omtfRefLayer = omtfCand->getRefLayer(); + omtfEvent.omtfProcessor = candProcIndx; + + omtfEvent.hits.clear(); //unsigned int iRefHit = omtfCand->getRefHitNumber(); @@ -205,7 +177,7 @@ void DataROOTDumper2::observeEventEnd(const edm::Event& iEvent, if (hit.phiDist > 504 || hit.phiDist < -512) { edm::LogVerbatim("l1tOmtfEventPrint") - << " muonPt " << event.muonPt << " omtfPt " << event.omtfPt << " RefLayer " << event.omtfRefLayer + << " muonPt " << omtfEvent.muonPt << " omtfPt " << omtfEvent.omtfPt << " RefLayer " << omtfEvent.omtfRefLayer << " layer " << int(hit.layer) << " hit.phiDist " << hit.phiDist << " valid " << stubResult.getValid() << " !!!!!!!!!!!!!!!!!!!!!!!!" << endl; } @@ -216,7 +188,7 @@ void DataROOTDumper2::observeEventEnd(const edm::Event& iEvent, hit.z = cscId.chamber() % 2; } - event.hits.push_back(hit.rawData); + omtfEvent.hits.push_back(hit.rawData); } } @@ -225,24 +197,6 @@ void DataROOTDumper2::observeEventEnd(const edm::Event& iEvent, <<" hits.size "<getQ "<getQ()<<" !!!!!!!!!!!!!!!!!!aaa!!!!!!"<nTestRefHits(); iRefHit++) { - unsigned int iGP = 0; - for (auto& itGP : gps) { - if (itGP->key().thePt == 0) - continue; - - auto& result = itGP->getResults()[candProcIndx][iRefHit]; - - event.omtfGpResultsPdfSum[iRefHit][iGP] = result.getPdfSum(); - //result.getRefLayer(); - event.omtfGpResultsFiredLayers[iRefHit][iGP] = result.getFiredLayerBits(); - - iGP++; - } - } - } - rootTree->Fill(); evntCnt++; } diff --git a/L1Trigger/L1TMuonOverlapPhase1/src/Tools/EmulationObserverBase.cc b/L1Trigger/L1TMuonOverlapPhase1/src/Tools/EmulationObserverBase.cc new file mode 100644 index 0000000000000..b145368b8b45e --- /dev/null +++ b/L1Trigger/L1TMuonOverlapPhase1/src/Tools/EmulationObserverBase.cc @@ -0,0 +1,109 @@ +/* + * EmulationObserverBase.cc + * + * Created on: Aug 18, 2021 + * Author: kbunkow + */ + +#include "L1Trigger/L1TMuonOverlapPhase1/interface/Tools/EmulationObserverBase.h" + +#include "Math/VectorUtil.h" + +EmulationObserverBase::EmulationObserverBase(const edm::ParameterSet& edmCfg, const OMTFConfiguration* omtfConfig) +: edmCfg(edmCfg), omtfConfig(omtfConfig), simMuon(nullptr) { + +} + +EmulationObserverBase::~EmulationObserverBase() { + // TODO Auto-generated destructor stub +} + + +void EmulationObserverBase::observeProcesorEmulation(unsigned int iProcessor, + l1t::tftype mtfType, + const std::shared_ptr& input, + const AlgoMuons& algoCandidates, + const AlgoMuons& gbCandidates, + const std::vector& candMuons) { + unsigned int procIndx = omtfConfig->getProcIndx(iProcessor, mtfType); + + /* + double ptSim = simMuon->momentum().pt(); + int chargeSim = (abs(simMuon->type()) == 13) ? simMuon->type()/-13 : 0; + int patNum = omtfConfig->getPatternNum(ptSim, chargeSim); + GoldenPatternWithStat* exptCandGp = goldenPatterns.at(patNum).get(); // expected pattern +*/ + + //bool found = false; + + unsigned int i = 0; + for (auto& gbCandidate : gbCandidates) { + //int iRefHit = gbCandidate.getRefHitNumber(); + if (gbCandidate->getGoldenPatern() != nullptr && + gbCandidate->getGpResult().getFiredLayerCnt() > omtfCand->getGpResult().getFiredLayerCnt()) { + //edm::LogVerbatim("l1tOmtfEventPrint") <<__FUNCTION__<<":"<<__LINE__<<" gbCandidate "<getResults()[procIndx][iRefHit]; //TODO be carrefful, because in principle the results sored by the goldenPattern can be altered in one event. In phae I omtf this should not happened, but in OMTFProcessorTTMerger - yes + //exptResult = exptCandGp->getResults()[procIndx][iRefHit]; + candProcIndx = procIndx; + + regionalMuonCand = candMuons.at(i); + //should be good, as the regionalMuonCand is created for every gbCandidate in OMTFProcessor::getFinalcandidates + //found = true; + + //this->algoCandidates = algoCandidates; //TODO uncomment if needed + } + i++; + } + + //////////////////////debug printout///////////////////////////// + /*if(found) { + GoldenPatternWithStat* omtfCandGp = static_cast(omtfCand.getGoldenPatern()); + if( omtfCandGp->key().thePt > 100 && exptCandGp->key().thePt <= 15 ) { + //edm::LogVerbatim("l1tOmtfEventPrint") <key()<key()<getResults()[procIndx][iRefHit].getFiredLayerCnt() ) + { + edm::LogVerbatim("l1tOmtfEventPrint") <key()<getResults()[procIndx][iRefHit]<momentum().pt()<<" GeV "< simTks; + event.getByLabel(edmCfg.getParameter("simTracksTag"), simTks); + + //LogTrace("l1tOmtfEventPrint")<<__FUNCTION__<<" simTks->size() "<size()<::const_iterator it = simTks->begin(); it < simTks->end(); it++) { + const SimTrack& aTrack = *it; + if (!(aTrack.type() == 13 || aTrack.type() == -13)) + continue; + if (previous && ROOT::Math::VectorUtil::DeltaR(aTrack.momentum(), previous->momentum()) < 0.07) + continue; + if (!result || aTrack.momentum().pt() > result->momentum().pt()) + result = &aTrack; + } + return result; +} diff --git a/L1Trigger/L1TMuonOverlapPhase1/src/Tools/EventCapture.cc b/L1Trigger/L1TMuonOverlapPhase1/src/Tools/EventCapture.cc index 6b3352c08e55a..27cc76762c7ec 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/src/Tools/EventCapture.cc +++ b/L1Trigger/L1TMuonOverlapPhase1/src/Tools/EventCapture.cc @@ -20,9 +20,9 @@ EventCapture::EventCapture(const edm::ParameterSet& edmCfg, const OMTFConfiguration* omtfConfig, - const std::vector >& gps, CandidateSimMuonMatcher* candidateSimMuonMatcher, - const MuonGeometryTokens& muonGeometryTokens) + const MuonGeometryTokens& muonGeometryTokens, + const GoldenPatternVec* gps) : omtfConfig(omtfConfig), goldenPatterns(gps), candidateSimMuonMatcher(candidateSimMuonMatcher), @@ -264,18 +264,19 @@ void EventCapture::observeEventEnd(const edm::Event& iEvent, << board.name() << " " << *algoMuon << " RefHitNum " << algoMuon->getRefHitNumber() << std::endl; edm::LogVerbatim("l1tOmtfEventPrint") << algoMuon->getGpResult() << std::endl; - for (auto& gp : goldenPatterns) { - if (gp->key().thePt == 0) - continue; + if(goldenPatterns) //watch out with the golden patterns + for (auto& gp : *goldenPatterns) { + if (gp->key().thePt == 0) + continue; - //printing GoldenPatternResult, uncomment if needed - /*auto& gpResult = gp->getResults()[iProc][algoMuon->getRefHitNumber()]; + //printing GoldenPatternResult, uncomment if needed + /*auto& gpResult = gp->getResults()[iProc][algoMuon->getRefHitNumber()]; edm::LogVerbatim("l1tOmtfEventPrint") << " "<key() << " " //<< " refLayer: " << gpResult.getRefLayer() << "\t" << " Sum over layers: " << gpResult.getPdfSum() << "\t" << " Number of hits: " << gpResult.getFiredLayerCnt() << "\t" << std::endl;*/ - } + } edm::LogVerbatim("l1tOmtfEventPrint") << std::endl << std::endl; } } diff --git a/L1Trigger/L1TMuonOverlapPhase1/src/Tools/PatternGenerator.cc b/L1Trigger/L1TMuonOverlapPhase1/src/Tools/PatternGenerator.cc index 128984eee35fe..809d530f18fb1 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/src/Tools/PatternGenerator.cc +++ b/L1Trigger/L1TMuonOverlapPhase1/src/Tools/PatternGenerator.cc @@ -15,13 +15,11 @@ PatternGenerator::PatternGenerator(const edm::ParameterSet& edmCfg, const OMTFConfiguration* omtfConfig, - std::vector >& gps) + GoldenPatternVec& gps) : PatternOptimizerBase(edmCfg, omtfConfig, gps), eventCntPerGp(gps.size(), 0) { edm::LogImportant("l1tOmtfEventPrint") << "constructing PatternGenerator, type: " << edmCfg.getParameter("patternGenerator") << std::endl; - goldenPatterns = gps; - if (edmCfg.getParameter("patternGenerator") == "patternGen") initPatternGen(); } diff --git a/L1Trigger/L1TMuonOverlapPhase1/src/Tools/PatternOptimizer.cc b/L1Trigger/L1TMuonOverlapPhase1/src/Tools/PatternOptimizer.cc index bf6f6e3cce00e..5484cc7b51bdf 100644 --- a/L1Trigger/L1TMuonOverlapPhase1/src/Tools/PatternOptimizer.cc +++ b/L1Trigger/L1TMuonOverlapPhase1/src/Tools/PatternOptimizer.cc @@ -41,7 +41,7 @@ PatternOptimizer::PatternOptimizer(const edm::ParameterSet& edmCfg, const OMTFConfiguration* omtfConfig, - std::vector >& gps) + GoldenPatternVec& gps) : PatternOptimizerBase(edmCfg, omtfConfig, gps), //TODO set desire function here, see https://www.cprogramming.com/c++11/c++11-lambda-closures.html updateStatFunc([this](GoldenPatternWithStat* omtfCandGp, GoldenPatternWithStat* exptCandGp) { @@ -803,23 +803,23 @@ void PatternOptimizer::calculateThresholds(GoldenPatternWithStat* omtfCandGp, Go /* void PatternOptimizer::calculateThresholds(double targetEff) { - cout<<__FUNCTION__<<":"<<__LINE__<<" targetEff "<myOmtfConfig->nGoldenPatterns(); iPat++) { +// ostrName.str(""); +// ostrTitle.str(""); +// OMTFConfiguration::PatternPt patternPt = this->myOmtfConfig->getPatternPtRange(iPat); +// ostrName<<"gpProbabilityStat_GP_"< 0) +// gpProbabilityStat.emplace_back(TH1I(ostrName.str().c_str(), ostrTitle.str().c_str(), 100, 0., 1.)); //TODO find proper range +// else +// gpProbabilityStat.emplace_back(TH1I(ostrName.str().c_str(), ostrTitle.str().c_str(), 1, 0., 1.)); //to save some memory, for empty patterns just "empty" hits +// } - ostringstream ostrName; - ostringstream ostrTitle; - for(unsigned int iPat = 0; iPat < this->myOmtfConfig->nGoldenPatterns(); iPat++) { - ostrName.str(""); - ostrTitle.str(""); - OMTFConfiguration::PatternPt patternPt = this->myOmtfConfig->getPatternPtRange(iPat); - ostrName<<"gpProbabilityStat_GP_"< 0) - gpProbabilityStat.emplace_back(TH1I(ostrName.str().c_str(), ostrTitle.str().c_str(), 100, 0., 1.)); //TODO find proper range - else - gpProbabilityStat.emplace_back(TH1I(ostrName.str().c_str(), ostrTitle.str().c_str(), 1, 0., 1.)); //to save some memory, for empty patterns just "empty" hits - } - * //cout<<__FUNCTION__<<":"<<__LINE__<<" "<key()<<" omtfCand->getGpResult()\n"<getGpResult()<key()<<" exptResult\n"< >& gps) - : edmCfg(edmCfg), omtfConfig(omtfConfig), goldenPatterns(gps), simMuon(nullptr) { + GoldenPatternVec& gps) + : EmulationObserverBase(edmCfg, omtfConfig), goldenPatterns(gps) { // TODO Auto-generated constructor stub simMuPt = new TH1I("simMuPt", "simMuPt", goldenPatterns.size(), -0.5, goldenPatterns.size() - 0.5); @@ -110,73 +110,6 @@ void PatternOptimizerBase::printPatterns() { } } -void PatternOptimizerBase::observeProcesorEmulation(unsigned int iProcessor, - l1t::tftype mtfType, - const std::shared_ptr& input, - const AlgoMuons& algoCandidates, - const AlgoMuons& gbCandidates, - const std::vector& candMuons) { - unsigned int procIndx = omtfConfig->getProcIndx(iProcessor, mtfType); - - /* - double ptSim = simMuon->momentum().pt(); - int chargeSim = (abs(simMuon->type()) == 13) ? simMuon->type()/-13 : 0; - int patNum = omtfConfig->getPatternNum(ptSim, chargeSim); - GoldenPatternWithStat* exptCandGp = goldenPatterns.at(patNum).get(); // expected pattern -*/ - - //bool found = false; - - unsigned int i = 0; - for (auto& gbCandidate : gbCandidates) { - //int iRefHit = gbCandidate.getRefHitNumber(); - if (gbCandidate->getGoldenPatern() != nullptr && - gbCandidate->getGpResult().getFiredLayerCnt() > omtfCand->getGpResult().getFiredLayerCnt()) { - //edm::LogVerbatim("l1tOmtfEventPrint") <<__FUNCTION__<<":"<<__LINE__<<" gbCandidate "<getResults()[procIndx][iRefHit]; //TODO be carrefful, because in principle the results sored by the goldenPattern can be altered in one event. In phae I omtf this should not happened, but in OMTFProcessorTTMerger - yes - //exptResult = exptCandGp->getResults()[procIndx][iRefHit]; - candProcIndx = procIndx; - - regionalMuonCand = candMuons.at( - i); //should be good, as the regionalMuonCand is created for every gbCandidate in OMTFProcessor::getFinalcandidates - //found = true; - - this->algoCandidates = algoCandidates; - } - i++; - } - - //////////////////////debug printout///////////////////////////// - /*if(found) { - GoldenPatternWithStat* omtfCandGp = static_cast(omtfCand.getGoldenPatern()); - if( omtfCandGp->key().thePt > 100 && exptCandGp->key().thePt <= 15 ) { - //edm::LogVerbatim("l1tOmtfEventPrint") <key()<key()<getResults()[procIndx][iRefHit].getFiredLayerCnt() ) - { - edm::LogVerbatim("l1tOmtfEventPrint") <key()<getResults()[procIndx][iRefHit]<momentum().pt()<<" GeV "<& finalCandidates) { @@ -203,27 +136,6 @@ void PatternOptimizerBase::endJob() { savePatternsInRoot(fName); } -const SimTrack* PatternOptimizerBase::findSimMuon(const edm::Event& event, const SimTrack* previous) { - const SimTrack* result = nullptr; - if (edmCfg.exists("simTracksTag") == false) - return result; - - edm::Handle simTks; - event.getByLabel(edmCfg.getParameter("simTracksTag"), simTks); - - //LogTrace("l1tOmtfEventPrint")<<__FUNCTION__<<" simTks->size() "<size()<::const_iterator it = simTks->begin(); it < simTks->end(); it++) { - const SimTrack& aTrack = *it; - if (!(aTrack.type() == 13 || aTrack.type() == -13)) - continue; - if (previous && ROOT::Math::VectorUtil::DeltaR(aTrack.momentum(), previous->momentum()) < 0.07) - continue; - if (!result || aTrack.momentum().pt() > result->momentum().pt()) - result = &aTrack; - } - return result; -} - void PatternOptimizerBase::savePatternsInRoot(std::string rootFileName) { gStyle->SetOptStat(111111); TFile outfile(rootFileName.c_str(), "RECREATE"); diff --git a/L1Trigger/L1TMuonOverlapPhase1/src/Tools/PatternsPtAssignment.cc b/L1Trigger/L1TMuonOverlapPhase1/src/Tools/PatternsPtAssignment.cc deleted file mode 100644 index 02346cef46156..0000000000000 --- a/L1Trigger/L1TMuonOverlapPhase1/src/Tools/PatternsPtAssignment.cc +++ /dev/null @@ -1,69 +0,0 @@ -/* - * PatternsPtAssignment.cc - * - * Created on: Mar 9, 2020 - * Author: kbunkow - */ - -#include "L1Trigger/L1TMuonOverlapPhase1/interface/Tools/PatternsPtAssignment.h" - -#include "FWCore/MessageLogger/interface/MessageLogger.h" - -#include -#include -#include -#include -#include - -PatternsPtAssignment::PatternsPtAssignment(const edm::ParameterSet& edmCfg, - const OMTFConfiguration* omtfConfig, - const std::vector >& gps, - std::string rootFileName) - : PatternOptimizerBase(edmCfg, omtfConfig), gps(gps) { - gpResultsToPt = new GpResultsToPt(gps, omtfConfig, 1024); //TODO move to processor -} - -PatternsPtAssignment::~PatternsPtAssignment() { - // TODO Auto-generated destructor stub -} - -void PatternsPtAssignment::observeEventEnd(const edm::Event& iEvent, - std::unique_ptr& finalCandidates) { - int muonCharge = 0; - if (simMuon) { - if (abs(simMuon->momentum().eta()) < 0.8 || abs(simMuon->momentum().eta()) > 1.24) - return; - - muonCharge = (abs(simMuon->type()) == 13) ? simMuon->type() / -13 : 0; - } - - if (simMuon == nullptr || !omtfCand->isValid()) //no sim muon or empty candidate - return; - - /* for(auto algoCandidate: algoCandidates) { - if(algoCandidate->isValid()) - gpResultsToPt->updateStat(algoCandidate, candProcIndx, simMuon->momentum().pt(), muonCharge); - }*/ - - gpResultsToPt->updateStat(omtfCand, candProcIndx, simMuon->momentum().pt(), muonCharge); -} - -void PatternsPtAssignment::endJob() { - gpResultsToPt->caluateLutValues(); - - std::string fileName = edmCfg.getParameter("gpResultsToPtFile"); - std::ofstream ofs(fileName); - - boost::archive::text_oarchive outArch(ofs); - //boost::archive::text_oarchive txtOutArch(ofs); - - //const PdfModule* pdfModuleImpl = dynamic_cast(pdfModule); - // write class instance to archive - edm::LogImportant("l1tOmtfEventPrint") << __FUNCTION__ << ": " << __LINE__ << " writing gpResultsToPt to file " - << fileName << std::endl; - outArch << *gpResultsToPt; - //outArch << gpResultsToPt->getGpResultsToPtLuts(); - - //txtOutArch << (*pdfModuleImpl); - // archive and stream closed when destructors are called -}