Skip to content

Commit 5cb06b2

Browse files
authored
Merge pull request #49381 from bfonta/met_valid_run3
Consider Run3 for the MET validation.
2 parents 57f28ce + 4d94d7b commit 5cb06b2

File tree

5 files changed

+39
-12
lines changed

5 files changed

+39
-12
lines changed
Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,27 @@
11
import FWCore.ParameterSet.Config as cms
2+
from functools import reduce
23

34
from HLTriggerOffline.JetMET.Validation.SingleJetValidation_cfi import *
45
from Validation.RecoJets.hltJetValidation_cff import *
56
from Validation.RecoMET.hltMETValidation_cff import *
67

8+
def sumModules(alist):
9+
return reduce(lambda x, y: x + y, alist)
10+
11+
met_run3_analyzers = [hltMetAnalyzerPF, hltMetAnalyzerPFCalo]
12+
met_ph2_analyzers = [hltMetAnalyzerPF, hltMetAnalyzerPFPuppi, hltMetTypeOneAnalyzerPFPuppi]
13+
714
##please do NOT include paths here!
815
HLTJetMETValSeq = cms.Sequence(
916
SingleJetValidation
1017
+ hltJetAnalyzerAK4PFPuppi
1118
+ hltJetAnalyzerAK4PF
1219
+ hltJetAnalyzerAK4PFCHS
13-
+ hltMetAnalyzerPF
14-
+ hltMetAnalyzerPFPuppi
15-
+ hltMetTypeOneAnalyzerPFPuppi
20+
+ sumModules(met_run3_analyzers)
1621
)
22+
23+
_phase2_HLTJetMETValSeq = HLTJetMETValSeq.copyAndExclude(met_run3_analyzers)
24+
_phase2_HLTJetMETValSeq += cms.Sequence(sumModules(met_ph2_analyzers))
25+
26+
from Configuration.Eras.Modifier_phase2_common_cff import phase2_common
27+
phase2_common.toReplaceWith(HLTJetMETValSeq, _phase2_HLTJetMETValSeq)

Validation/RecoMET/plugins/METTester.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ METTester::METTester(const edm::ParameterSet &iConfig) {
2929
genMETsCaloToken_ = consumes<reco::GenMETCollection>(edm::InputTag("genMetCalo"));
3030
}
3131

32-
pvToken_ = consumes<std::vector<reco::Vertex>>(iConfig.getParameter<edm::InputTag>("primaryVertices"));
32+
pvTokenTag_ = iConfig.getParameter<edm::InputTag>("primaryVertices");
33+
pvToken_ = consumes<std::vector<reco::Vertex>>(pvTokenTag_);
3334

3435
// Events variables
3536
mNvertex = nullptr;
@@ -223,7 +224,8 @@ void METTester::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup)
223224
edm::Handle<reco::VertexCollection> pvHandle;
224225
iEvent.getByToken(pvToken_, pvHandle);
225226
if (!pvHandle.isValid()) {
226-
edm::LogWarning("MissingInput") << __FUNCTION__ << ":" << __LINE__ << ":pvHandle handle not found!";
227+
edm::LogWarning("MissingInput") << __FUNCTION__ << ":" << __LINE__ << ": pvHandle handle with tag " << pvTokenTag_
228+
<< " not found!";
227229
return;
228230
}
229231
const int nvtx = pvHandle->size();

Validation/RecoMET/plugins/METTester.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class METTester : public DQMEDAnalyzer {
5959
edm::InputTag inputCaloMETLabel_;
6060

6161
// Tokens
62+
edm::InputTag pvTokenTag_;
6263
edm::EDGetTokenT<std::vector<reco::Vertex>> pvToken_;
6364
edm::EDGetTokenT<reco::CaloMETCollection> caloMETsToken_;
6465
edm::EDGetTokenT<reco::PFMETCollection> pfMETsToken_;

Validation/RecoMET/python/hltMETValidation_cff.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,34 @@
1313
from Validation.RecoMET.metTester_cfi import metTester as _metTester
1414
_hltMetTester = _metTester.clone(
1515
runDir = "HLT/JetMET/METValidation/",
16-
primaryVertices = 'hltPhase2PixelVertices',
16+
primaryVertices = 'hltPixelVertices',
1717
genMetTrue = 'genMetTrue',
1818
genMetCalo = 'genMetCalo',
1919
)
2020

21+
from Configuration.Eras.Modifier_phase2_common_cff import phase2_common
22+
phase2_common.toModify(_hltMetTester, primaryVertices = 'hltPhase2PixelVertices')
23+
2124
hltMetAnalyzerPF = _hltMetTester.clone(
22-
inputMETLabel = 'hltPFMET',
23-
METType = 'pf',
25+
inputMETLabel = 'hltPFMETProducer',
26+
METType = 'pf',
2427
)
28+
phase2_common.toModify(hltMetAnalyzerPF, inputMETLabel = 'hltPFMET')
2529

2630
hltMetAnalyzerPFPuppi = _hltMetTester.clone(
27-
inputMETLabel = 'hltPFPuppiMET',
31+
inputMETLabel = 'dummy (phase2-only)',
2832
METType = 'pf',
2933
)
34+
phase2_common.toModify(hltMetAnalyzerPFPuppi, inputMETLabel = 'hltPFPuppiMET')
3035

3136
hltMetTypeOneAnalyzerPFPuppi = _hltMetTester.clone(
32-
inputMETLabel = 'hltPFPuppiMETTypeOne',
37+
inputMETLabel = 'dummy (phase2-only)',
3338
METType = 'pf',
3439
)
40+
phase2_common.toModify(hltMetTypeOneAnalyzerPFPuppi, inputMETLabel = 'hltPFPuppiMETTypeOne')
3541

3642
hltMetAnalyzerPFCalo = _hltMetTester.clone(
37-
inputMETLabel = 'hltCaloMET',
43+
inputMETLabel = 'hltMet',
3844
METType = 'calo',
3945
)
40-
46+
phase2_common.toModify(hltMetAnalyzerPFCalo, inputMETLabel = 'hltCaloMET')

Validation/RecoMET/scripts/makeHLTMETValidationPlots.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python3
22

33
import os
4+
import shutil
45
import argparse
56
import numpy as np
67
import hist
@@ -26,6 +27,11 @@ def createDir(adir):
2627
os.makedirs(adir)
2728
return adir
2829

30+
def createIndexPHP(src, dest):
31+
php_file = os.path.join(src, 'index.php')
32+
if os.path.exists(php_file):
33+
shutil.copy(php_file, dest)
34+
2935
def checkRootDir(afile, adir):
3036
if not afile.Get(adir):
3137
raise RuntimeError(f"Directory '{adir}' not found in {afile}")
@@ -357,4 +363,5 @@ def __call__(self, parser, namespace, values, option_string=None):
357363
checkRootDir(afile, turnon_dir)
358364
vars1Dtrigger = ('TurnOngMET', 'TurnOngMETLow', 'TurnOnhMET', 'TurnOnhMETLow')
359365
outdir = createDir(os.path.join(args.odir, trigger))
366+
createIndexPHP(src=args.odir, dest=trigger)
360367
plot1Dtrigger(afile, turnon_dir, vars1Dtrigger, outdir=outdir, metType=METType[metType])

0 commit comments

Comments
 (0)