-
Notifications
You must be signed in to change notification settings - Fork 4.6k
[L1T] Phase-2, remove old simulation and adapt DQM #38442
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 53 commits
9dd2e94
4cbc1c6
bcd507b
d29fc58
37ba1b6
074cb8f
116e799
b3ffbca
32791da
170349d
8014545
4194565
719126d
1bb391e
8e50f64
79fea11
6cc466c
c4670bc
0691238
67b8dfd
26d8e9f
4663a87
e44c90e
3c558ba
85f2f6f
2ad4f29
0ce1e79
c34e04c
6548be4
511f54a
8df19dd
a5ce90d
205b320
292e0b5
1ebec17
f31bba4
55cf8c4
bf5c25e
4d3e135
e9f0e56
6103b6a
0debcd1
3666732
1f730ad
cf91f20
080a331
d097cfe
4aab568
a0ebbb8
64f5398
9de2c3a
b1a9974
17ec54c
18a540a
68b0ec3
54a25d8
fb2bed1
7d34786
cf2e7fa
4001553
eaa1447
e782cbb
7662e95
0731750
2f64a7a
5f68a0a
4a48d24
aef00e1
5c30bb2
5799459
5e891a8
338d63c
f6c5d02
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,206 @@ | ||
| #ifndef DQMOFFLINE_L1TRIGGER_L1TPHASE2MUONOFFLINE_H | ||
| #define DQMOFFLINE_L1TRIGGER_L1TPHASE2MUONOFFLINE_H | ||
|
|
||
| /** | ||
| * \file L1TPhase2MuonOffline.h | ||
| * | ||
| * \author S. Folgueras | ||
| * | ||
| */ | ||
|
|
||
| // DataFormats | ||
| #include "DataFormats/L1Trigger/interface/Muon.h" | ||
| #include "DataFormats/L1TMuonPhase2/interface/SAMuon.h" | ||
| #include "DataFormats/L1TMuonPhase2/interface/MuonStub.h" | ||
| #include "DataFormats/L1TMuonPhase2/interface/TrackerMuon.h" | ||
| #include "DataFormats/Candidate/interface/Candidate.h" | ||
| #include "DataFormats/HepMCCandidate/interface/GenParticle.h" | ||
| #include "DataFormats/L1Trigger/interface/L1MuonParticleFwd.h" | ||
| #include "DataFormats/L1Trigger/interface/L1MuonParticle.h" | ||
| #include "DataFormats/Math/interface/deltaR.h" | ||
| #include "DataFormats/Math/interface/deltaPhi.h" | ||
|
|
||
| // FWCore | ||
| #include "FWCore/Framework/interface/Frameworkfwd.h" | ||
| #include "FWCore/Framework/interface/ESHandle.h" | ||
| #include "FWCore/Framework/interface/Event.h" | ||
| #include "FWCore/Framework/interface/LuminosityBlock.h" | ||
| #include "FWCore/Framework/interface/MakerMacros.h" | ||
| #include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
| #include "FWCore/Framework/interface/EDAnalyzer.h" | ||
| #include "FWCore/ServiceRegistry/interface/Service.h" | ||
| #include "FWCore/MessageLogger/interface/MessageLogger.h" | ||
|
|
||
| // DQMServices | ||
| #include "DQMServices/Core/interface/DQMStore.h" | ||
| #include "DQMServices/Core/interface/DQMEDAnalyzer.h" | ||
|
|
||
| // HLTrigger | ||
| #include "HLTrigger/HLTcore/interface/HLTConfigProvider.h" | ||
|
|
||
| // Common tools | ||
| //#include "MuonAnalysis/MuonAssociators/interface/PropagateToMuon.h" | ||
| #include "TrackingTools/TransientTrack/interface/TransientTrack.h" | ||
| #include "TrackingTools/TransientTrack/interface/TrackTransientTrack.h" | ||
| #include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h" | ||
| #include "TrackingTools/PatternTools/interface/Trajectory.h" | ||
| #include "TrackingTools/Records/interface/TransientTrackRecord.h" | ||
| #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h" | ||
| #include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h" | ||
| #include "TrackingTools/Records/interface/TrackingComponentsRecord.h" | ||
| #include "TrackingTools/TrajectoryState/interface/FreeTrajectoryState.h" | ||
|
|
||
| #include <memory> | ||
| #include "TRegexp.h" | ||
| #include <utility> | ||
| #include <vector> | ||
|
|
||
| class GenMuonGMTPair; | ||
|
|
||
| // | ||
| // DQM class declaration | ||
| // | ||
|
|
||
| class L1TPhase2MuonOffline : public DQMEDAnalyzer { | ||
| public: | ||
| L1TPhase2MuonOffline(const edm::ParameterSet& ps); | ||
| ~L1TPhase2MuonOffline() override; | ||
|
|
||
| enum MuType { kSAMuon, kTkMuon, kNMuTypes }; | ||
| enum VarType { kPt, kEta, kPhi, kIso, kQual, kZ0, kD0, kNVarTypes }; | ||
| enum EffType { kEffPt, kEffPhi, kEffEta, kEffTypes }; | ||
| enum ResType { kResPt, kRes1OverPt, kResQOverPt, kResPhi, kResEta, kResCh, kNResTypes }; | ||
| enum EtaRegion { kEtaRegionAll, kEtaRegionBmtf, kEtaRegionOmtf, kEtaRegionEmtf, kNEtaRegions }; | ||
| enum QualLevel { kQualOpen, kQualDouble, kQualSingle, kNQualLevels }; | ||
|
|
||
| protected: | ||
| void dqmBeginRun(const edm::Run& run, const edm::EventSetup& iSetup) override; | ||
| void analyze(const edm::Event& e, const edm::EventSetup& c) override; | ||
|
|
||
| void bookControlHistos(DQMStore::IBooker&, MuType type); | ||
| void bookEfficiencyHistos(DQMStore::IBooker& ibooker, MuType type); | ||
| void bookResolutionHistos(DQMStore::IBooker& ibooker, MuType type); | ||
| void bookHistograms(DQMStore::IBooker& ibooker, const edm::Run& run, const edm::EventSetup& iSetup) override; | ||
|
|
||
| //Fill Histos | ||
| void fillControlHistos(); | ||
| void fillEfficiencyHistos(); | ||
| void fillResolutionHistos(); | ||
|
|
||
| private: | ||
| // Cut and Matching | ||
| void getMuonGmtPairs(edm::Handle<l1t::MuonBxCollection>& gmtCands); | ||
|
|
||
| // Handles and Tokens | ||
| edm::EDGetTokenT<l1t::SAMuonCollection> gmtMuonToken_; | ||
| edm::EDGetTokenT<l1t::TrackerMuonCollection> gmtTkMuonToken_; | ||
| edm::EDGetTokenT<std::vector<reco::GenParticle>> genParticleToken_; | ||
|
|
||
| edm::Handle<l1t::SAMuonCollection> gmtSAMuon_; | ||
| edm::Handle<l1t::TrackerMuonCollection> gmtTkMuon_; | ||
| edm::Handle<std::vector<reco::GenParticle>> genparticles_; | ||
|
|
||
| // PropagateToMuon muonpropagator_; | ||
|
|
||
| // vectors of enum values to loop over (and store quantities) | ||
| const std::vector<MuType> muonTypes_; | ||
| const std::vector<EffType> effTypes_; | ||
| const std::vector<ResType> resTypes_; | ||
| const std::vector<VarType> varTypes_; | ||
| const std::vector<EtaRegion> etaRegions_; | ||
| const std::vector<QualLevel> qualLevels_; | ||
|
|
||
| // maps with histogram name bits | ||
| std::map<EffType, std::string> effNames_; | ||
| std::map<EffType, std::string> effLabels_; | ||
| std::map<ResType, std::string> resNames_; | ||
| std::map<ResType, std::string> resLabels_; | ||
| std::map<EtaRegion, std::string> etaNames_; | ||
| std::map<QualLevel, std::string> qualNames_; | ||
| std::map<MuType, std::string> muonNames_; | ||
|
|
||
| // config params | ||
| std::string histFolder_; | ||
| std::vector<edm::ParameterSet> cutsVPSet_; | ||
|
|
||
| std::vector<double> effVsPtBins_; | ||
| std::vector<double> effVsPhiBins_; | ||
| std::vector<double> effVsEtaBins_; | ||
|
||
|
|
||
| bool useAtVtxCoord_; | ||
| bool isParticleGun_; | ||
|
||
| float maxGmtMuonDR_; | ||
|
|
||
| // Helper methods | ||
| void matchMuonsToGen(std::vector<const reco::GenParticle*> genmus); | ||
| std::vector<float> getHistBinsEff(EffType eff); | ||
| std::tuple<int, double, double> getHistBinsRes(ResType res); | ||
|
|
||
| // Keys for histogram maps | ||
| /*typedef std::tuple<MuType, ResType, EtaRegion, QualLevel> histoKeyResType_; | ||
| typedef std::tuple<MuType, EffType, int, EtaRegion, QualLevel> histoKeyEffType_; | ||
| typedef std::tuple<MuType, VarType> histoKeyVarType_; | ||
| */ | ||
| // Histograms and histogram containers | ||
| // std::map<std::tuple<MuType, EffType, int, EtaRegion, QualLevel>, MonitorElement*> efficiencyHistos_; | ||
| // std::map<std::tuple<MuType, ResType, EtaRegion, QualLevel>, MonitorElement*> resolutionHistos_; | ||
| // TH1F* efficiencyNum_[kNMuTypes][kNEtaRegions][kNQualLevels][kEffTypes]; | ||
| // TH1F* efficiencyDen_[kNMuTypes][kNEtaRegions][kNQualLevels][kEffTypes]; | ||
|
||
|
|
||
| MonitorElement* efficiencyNum_[kNMuTypes][kNEtaRegions][kNQualLevels][kEffTypes]; | ||
| MonitorElement* efficiencyDen_[kNMuTypes][kNEtaRegions][kNQualLevels][kEffTypes]; | ||
| MonitorElement* resolutionHistos_[kNMuTypes][kNEtaRegions][kNQualLevels][kNResTypes]; | ||
| MonitorElement* controlHistos_[kNMuTypes][kNVarTypes]; | ||
|
|
||
| // helper variables | ||
| std::vector<GenMuonGMTPair> gmtSAMuonPairs_; | ||
| std::vector<GenMuonGMTPair> gmtTkMuonPairs_; | ||
| std::vector<std::pair<int, QualLevel>> cuts_; | ||
|
|
||
| float lsb_pt; | ||
| float lsb_phi; | ||
| float lsb_eta; | ||
| float lsb_z0; | ||
| float lsb_d0; | ||
| }; | ||
|
|
||
| // | ||
| // helper class to manage GMT-GenMuon pairing | ||
| // | ||
| class GenMuonGMTPair { | ||
| public: | ||
| GenMuonGMTPair(const reco::GenParticle* mu, const l1t::L1Candidate* gmtmu); | ||
| GenMuonGMTPair(const GenMuonGMTPair& muongmtPair); | ||
| ~GenMuonGMTPair(){}; | ||
|
|
||
| float dR(); | ||
| float pt() const { return mu_->pt(); }; | ||
| float eta() const { return mu_->eta(); }; | ||
| float phi() const { return mu_->phi(); }; | ||
| int charge() const { return mu_->charge(); }; | ||
|
|
||
| // Now properties of the L1 candidate: | ||
| float gmtPt() const { return gmtmu_ ? gmtmu_->pt() : -1.; }; | ||
| float gmtEta() const { return gmtmu_ ? gmtEta_ : -5.; }; | ||
| float gmtPhi() const { return gmtmu_ ? gmtPhi_ : -5.; }; | ||
| int gmtCharge() const { return gmtmu_ ? gmtmu_->charge() : -5; }; | ||
| int gmtQual() const { return gmtmu_ ? gmtmu_->hwQual() : -1; }; | ||
|
|
||
| L1TPhase2MuonOffline::EtaRegion etaRegion() const; | ||
| double getDeltaVar(const L1TPhase2MuonOffline::ResType) const; | ||
| double getVar(const L1TPhase2MuonOffline::EffType) const; | ||
|
|
||
| private: | ||
| const reco::GenParticle* mu_; | ||
| const l1t::L1Candidate* gmtmu_; | ||
|
|
||
| // L1T muon eta and phi coordinates to be used | ||
| // Can be the coordinates from the 2nd muon station or from the vertex | ||
| float gmtEta_; | ||
| float gmtPhi_; | ||
|
|
||
| float muEta_; | ||
| float muPhi_; | ||
| }; | ||
|
|
||
| #endif | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| import FWCore.ParameterSet.Config as cms | ||
|
|
||
| # generate the efficiency strings for the DQMGenericClient from the pt and quality cuts | ||
| def generateEfficiencyStrings(ptQualCuts): | ||
| numDenDir = "nums_and_dens/" | ||
| varStrings = ['Pt', 'Eta', 'Phi'] | ||
| etaStrings = ['etaMin0_etaMax0p83', 'etaMin0p83_etaMax1p24', 'etaMin1p24_etaMax2p4', 'etaMin0_etaMax2p4'] | ||
| qualStrings = {'qualOpen', 'qualDouble', 'qualSingle'} | ||
| muonStrings = ['SAMuon','TkMuon'] | ||
|
|
||
| efficiencyStrings = [] | ||
|
|
||
| for muonString in muonStrings: | ||
| for qualString in qualStrings: | ||
| for etaString in etaStrings: | ||
| effNumDenPrefix = numDenDir+"Eff_"+muonString+"_"+etaString+"_"+qualString+"_" | ||
| effNamePrefix = "efficiencies/eff_"+muonString+"_"+etaString+"_"+qualString+"_" | ||
|
|
||
| for varString in varStrings: | ||
| effDenName = effNumDenPrefix+varString+"_Den" | ||
| effNumName = effNumDenPrefix+varString+"_Num" | ||
| effName = effNamePrefix+varString | ||
|
|
||
| efficiencyStrings.append(effName+" '"+effName+";;L1 muon efficiency' "+effNumName+" "+effDenName) | ||
| return efficiencyStrings | ||
|
|
||
| from DQMServices.Core.DQMEDHarvester import DQMEDHarvester | ||
| from DQMOffline.L1Trigger.L1TPhase2MuonOffline_cfi import ptQualCuts | ||
|
|
||
| l1tPhase2MuonEfficiency = DQMEDHarvester("DQMGenericClient", | ||
| subDirs = cms.untracked.vstring(["L1T/L1TPhase2/Muons/SAMuon","L1T/L1TPhase2/Muons/TkMuon"]), | ||
| efficiency = cms.vstring(), | ||
| efficiencyProfile = cms.untracked.vstring(generateEfficiencyStrings(ptQualCuts)), | ||
| resolution = cms.vstring(), | ||
| outputFileName = cms.untracked.string(""), | ||
| verbose = cms.untracked.uint32(4) | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| from builtins import range | ||
| import FWCore.ParameterSet.Config as cms | ||
|
|
||
| # define binning for efficiency plots | ||
| # pt | ||
| import itertools | ||
| effVsPtBins=list(itertools.chain(range(0, 30, 1), range(30, 50, 2), | ||
| range(50, 70, 5), range(70, 100, 10), | ||
| range(100, 200, 25), range(200, 300, 50), | ||
| range(300, 500, 100), range(500, 700, 200), | ||
| range(700, 1000, 300))) | ||
| effVsPtBins.append(1000) | ||
|
|
||
| # phi | ||
| nPhiBins = 34 | ||
| phiMin = -3.4 | ||
| phiMax = 3.4 | ||
| effVsPhiBins = [i*(phiMax-phiMin)/nPhiBins + phiMin for i in range(nPhiBins+1)] | ||
|
|
||
| # eta | ||
| nEtaBins = 50 | ||
| etaMin = -2.5 | ||
| etaMax = 2.5 | ||
| effVsEtaBins = [i*(etaMax-etaMin)/nEtaBins + etaMin for i in range(nEtaBins+1)] | ||
|
|
||
| # vtx | ||
| effVsVtxBins = range(0, 101) | ||
|
|
||
| # A list of pt cut + quality cut pairs for which efficiency plots should be made | ||
| ptQualCuts = [[22, 12], [15, 8], [3, 4]] | ||
| cutsPSets = [] | ||
| for ptQualCut in ptQualCuts: | ||
| cutsPSets.append(cms.untracked.PSet(ptCut = cms.untracked.int32(ptQualCut[0]), | ||
| qualCut = cms.untracked.int32(ptQualCut[1]))) | ||
|
|
||
| from DQMServices.Core.DQMEDAnalyzer import DQMEDAnalyzer | ||
| l1tPhase2MuonOffline = DQMEDAnalyzer('L1TPhase2MuonOffline', | ||
| histFolder = cms.untracked.string('L1T/L1TPhase2/Muons/'), | ||
| cuts = cms.untracked.VPSet(cutsPSets), | ||
| useL1AtVtxCoord = cms.untracked.bool(False), | ||
|
|
||
| genParticlesInputTag = cms.untracked.InputTag("genParticles"), | ||
| gmtMuonToken = cms.InputTag("L1SAMuonsGmt", "promptSAMuons"), | ||
| gmtTkMuonToken = cms.InputTag("L1TkMuonsGmt",""), | ||
|
|
||
| efficiencyVsPtBins = cms.untracked.vdouble(effVsPtBins), | ||
| efficiencyVsPhiBins = cms.untracked.vdouble(effVsPhiBins), | ||
| efficiencyVsEtaBins = cms.untracked.vdouble(effVsEtaBins), | ||
| efficiencyVsVtxBins = cms.untracked.vdouble(effVsVtxBins), | ||
| ) | ||
|
|
||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If not needed please remove it, thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done