CMS 3D CMS Logo

particleFlowDQM_cff.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
2 import Validation.RecoParticleFlow.defaults_cfi as default
3 from Validation.RecoParticleFlow.defaults_cfi import ptbins, etabins, response_distribution_name, genjet_distribution_name, recojet_distribution_name, jetResponseDir, genjetDir, offsetDir
4 
5 #----- ----- ----- ----- ----- ----- ----- -----
6 #
7 # Auxiliary definitions
8 #
9 
10 def make_response_plot_pset(name, title, responseNbins, responseLow, responseHigh, ptBinLow, ptBinHigh, etaBinLow, etaBinHigh):
11  return cms.PSet(
12  name = cms.string(name),
13  title = cms.string(title),
14  responseNbins = cms.uint32(responseNbins),
15  responseLow = cms.double(responseLow),
16  responseHigh = cms.double(responseHigh),
17  ptBinLow = cms.double(ptBinLow),
18  ptBinHigh = cms.double(ptBinHigh),
19  etaBinLow = cms.double(etaBinLow),
20  etaBinHigh = cms.double(etaBinHigh),
21  )
22 
23 #Jet response is plotted in histograms which can be subdivided by pt and |eta| of the genjet.
24 #To minimize the amount of logic on the C++ side, we define all response plots here.
25 #Each plot has low and high pt and |eta| edges, the plot is filled only if the genjet
26 #is in the bin defined by the edges.
27 #It is your job here to make sure you define the bins in a non-overlapping way if
28 #you want to emulate a 2D map over (pT, |eta|) of 1D histograms.
29 def createResponsePlots(ptbins, etabins):
30  response_plots = []
31  #we always use a range [ibin, ibin+1)
32  for ietabin in range(len(etabins)-1):
33  for iptbin in range(len(ptbins)-1):
34 
35  response_plots += [make_response_plot_pset(
36  response_distribution_name(iptbin, ietabin),
37  "Jet response (pT/pTgen) in {0} <= pt < {1}, {2} <= |eta| < {3})".format(ptbins[iptbin], ptbins[iptbin+1], etabins[ietabin], etabins[ietabin+1]),
38  100, 0.0, 3.0, ptbins[iptbin], ptbins[iptbin+1], etabins[ietabin], etabins[ietabin+1]
39  )]
40  return response_plots
41 
42 def createGenJetPlots(ptbins, etabins):
43  plots = []
44  for ietabin in range(len(etabins)-1):
45  eta_low = etabins[ietabin]
46  eta_high = etabins[ietabin + 1]
47  plots += [
48  cms.PSet(
49  name = cms.string(genjet_distribution_name(ietabin)),
50  title = cms.string("GenJet pT ({0} <= |eta| <= {1})".format(eta_low, eta_high)),
51  ptBins = cms.vdouble(ptbins),
52  etaBinLow = cms.double(eta_low),
53  etaBinHigh = cms.double(eta_high),
54  )]
55  return plots
56 
57 def createRecoJetPlots(ptbins, etabins):
58  plots = []
59  for ietabin in range(len(etabins)-1):
60  eta_low = etabins[ietabin]
61  eta_high = etabins[ietabin + 1]
62  plots += [
63  cms.PSet(
64  name = cms.string(recojet_distribution_name(ietabin)),
65  title = cms.string("RecoJet ({0} <= |eta| <= {1})".format(eta_low, eta_high)),
66  ptBins = cms.vdouble(ptbins),
67  etaBinLow = cms.double(eta_low),
68  etaBinHigh = cms.double(eta_high),
69  )]
70  return plots
71 
72 #----- ----- ----- ----- ----- ----- ----- -----
73 #
74 # Config for analyzer and postprocessor
75 #
76 
77 name = "genjet_pt"
78 title = "genjet pt"
79 pfJetAnalyzerDQM = cms.EDProducer("PFJetAnalyzerDQM",
80 
81  #match these reco-jets to the gen-jets and compute jet response
82  recoJetCollection = cms.InputTag('slimmedJets'),
83  genJetCollection = cms.InputTag('slimmedGenJets'),
84  jetDeltaR = cms.double(0.2),
85 
86  # turn gen jets on or off
87  genJetsOn = cms.bool(True),
88  recoJetsOn = cms.bool(True),
89  responsePlots = cms.VPSet(createResponsePlots(ptbins, etabins)),
90  genJetPlots = cms.VPSet(createGenJetPlots(ptbins, etabins)),
91  recoJetPlots = cms.VPSet(createRecoJetPlots(ptbins, etabins)),
92 )
93 
94 pfPuppiJetAnalyzerDQM = pfJetAnalyzerDQM.clone(
95  recoJetCollection = 'slimmedJetsPuppi',
96  genJetsOn = False
97 )
98 
99 vjetResponseDir = [jetResponseDir + "slimmedJets/JEC/",
100  jetResponseDir + "slimmedJets/noJEC/",
101  jetResponseDir + "slimmedJetsPuppi/JEC/",
102  jetResponseDir + "slimmedJetsPuppi/noJEC/"]
103 
104 pfJetDQMPostProcessor = cms.EDProducer("PFJetDQMPostProcessor",
105 
106  jetResponseDir = cms.vstring( vjetResponseDir ),
107  genjetDir = cms.string( genjetDir ),
108  offsetDir = cms.string( offsetDir ),
109  ptBins = cms.vdouble( ptbins ),
110  etaBins = cms.vdouble( etabins ),
111  recoPtCut = cms.double(10. )
112 )
113 
114 
115 # PFCandidates
116 PFCandAnalyzerDQM = cms.EDProducer("PFCandidateAnalyzerDQM",
117  PFCandType = cms.InputTag("packedPFCandidates"),
118  etabins = cms.vdouble( default.etaBinsOffset ),
119  pdgKeys = cms.vuint32( default.pdgIDDict.keys() ),
120  pdgStrs = cms.vstring( default.pdgIDDict.values() )
121 )
122 
123 
124 #----- ----- ----- ----- ----- ----- ----- -----
def response_distribution_name(iptbin, ietabin)
Definition: defaults_cfi.py:9
def createRecoJetPlots(ptbins, etabins)
def createGenJetPlots(ptbins, etabins)
def recojet_distribution_name(ietabin)
Definition: defaults_cfi.py:18
def make_response_plot_pset(name, title, responseNbins, responseLow, responseHigh, ptBinLow, ptBinHigh, etaBinLow, etaBinHigh)
def genjet_distribution_name(ietabin)
Definition: defaults_cfi.py:14
def createResponsePlots(ptbins, etabins)