1 |
dmf |
1.1 |
#flake8: noqa
|
2 |
|
|
|
3 |
|
|
'''
|
4 |
|
|
>>-------------------------<<-
|
5 |
|
|
Diffractive Z NTuple Producer
|
6 |
|
|
>>-------------------------<<
|
7 |
|
|
|
8 |
|
|
Goal:
|
9 |
|
|
Produce your diffractive Z ntuple.
|
10 |
|
|
|
11 |
|
|
Usage:
|
12 |
|
|
cmsRun DiffractiveZPATTupleMultiple.py
|
13 |
|
|
|
14 |
|
|
Example:
|
15 |
|
|
cmsRun DiffractiveZPATTupleMulticrab.py Run=data_MuonA
|
16 |
|
|
|
17 |
|
|
Optional arguments:
|
18 |
|
|
Run = data_MuonA, data_MuonB, data_ElectronA, data_ElectronB, MC_none, MC_PU, MC_FlatWeight or MC_FlatWeight_and_PU
|
19 |
|
|
|
20 |
|
|
Authors: D. Figueiredo, R. Arciadiacono and N. Cartiglia
|
21 |
|
|
'''
|
22 |
|
|
|
23 |
|
|
import FWCore.ParameterSet.Config as cms
|
24 |
|
|
import os, sys
|
25 |
|
|
import atexit
|
26 |
|
|
|
27 |
|
|
from FWCore.ParameterSet.VarParsing import VarParsing
|
28 |
|
|
options = VarParsing ('analysis')
|
29 |
dmf |
1.3 |
options.register('Run','data_MuonA',VarParsing.multiplicity.singleton, VarParsing.varType.string,"Option to Run: data or MC.")
|
30 |
dmf |
1.1 |
options.parseArguments()
|
31 |
|
|
|
32 |
|
|
process = cms.Process("Analysis")
|
33 |
|
|
|
34 |
|
|
class config: pass
|
35 |
|
|
config.verbose = True
|
36 |
|
|
config.writeEdmOutput = False
|
37 |
|
|
config.outputTTreeFile = 'DiffractiveZDataPATTuple.root'
|
38 |
|
|
config.runPATSequences = True
|
39 |
|
|
config.comEnergy = 7000.0
|
40 |
|
|
config.trackAnalyzerName = 'trackHistoAnalyzer'
|
41 |
|
|
config.trackTagName = 'analysisTracks'
|
42 |
dmf |
1.3 |
config.NumberOfEvents = 100
|
43 |
dmf |
1.1 |
|
44 |
|
|
#
|
45 |
|
|
# Define Options to Run
|
46 |
|
|
#
|
47 |
|
|
######################################################################################
|
48 |
|
|
|
49 |
|
|
if options.Run == "data_MuonA":
|
50 |
|
|
print("")
|
51 |
|
|
print("###################")
|
52 |
|
|
print("Data Muon 2010 RunA")
|
53 |
|
|
print("###################")
|
54 |
|
|
print("")
|
55 |
|
|
config.globalTagNameData = 'GR_R_42_V23::All'
|
56 |
|
|
config.TriggerOn = True
|
57 |
|
|
triggerlist = 'HLT_Mu9','HLT_L1Mu20'
|
58 |
|
|
l1list = 'L1_ZeroBias','L1_SingleEG5'
|
59 |
|
|
config.runOnMC = False
|
60 |
|
|
config.runPUMC = False
|
61 |
|
|
config.runGen = False
|
62 |
|
|
|
63 |
|
|
elif options.Run == "data_MuonB":
|
64 |
|
|
print("")
|
65 |
|
|
print("###################")
|
66 |
|
|
print("Data Muon 2010 RunB")
|
67 |
|
|
print("###################")
|
68 |
|
|
print("")
|
69 |
dmf |
1.2 |
config.globalTagNameData = 'GR_R_42_V23::All'
|
70 |
dmf |
1.1 |
config.TriggerOn = True
|
71 |
|
|
triggerlist = 'HLT_Mu9','HLT_L1Mu20'
|
72 |
|
|
l1list = 'L1_ZeroBias','L1_SingleEG5'
|
73 |
|
|
config.runOnMC = False
|
74 |
|
|
config.runPUMC = False
|
75 |
|
|
config.runGen = False
|
76 |
|
|
|
77 |
|
|
elif options.Run == "data_ElectronA":
|
78 |
|
|
print("")
|
79 |
|
|
print("#######################")
|
80 |
|
|
print("Data Electron 2010 RunA")
|
81 |
|
|
print("#######################")
|
82 |
|
|
print("")
|
83 |
|
|
config.globalTagNameData = 'GR_R_42_V23::All'
|
84 |
|
|
config.TriggerOn = True
|
85 |
|
|
triggerlist = 'HLT_Photon10_L1R','HLT_Photon15_Cleaned_l1R'
|
86 |
|
|
l1list = 'L1_ZeroBias','L1_SingleEG5'
|
87 |
|
|
config.runOnMC = False
|
88 |
|
|
config.runPUMC = False
|
89 |
|
|
config.runGen = False
|
90 |
|
|
|
91 |
|
|
elif options.Run == "data_ElectronB":
|
92 |
|
|
print("")
|
93 |
|
|
print("#######################")
|
94 |
|
|
print("Data Electron 2010 RunB")
|
95 |
|
|
print("#######################")
|
96 |
|
|
print("")
|
97 |
dmf |
1.2 |
config.globalTagNameData = 'GR_R_42_V23::All'
|
98 |
dmf |
1.1 |
config.TriggerOn = True
|
99 |
dmf |
1.2 |
triggerlist = 'HLT_Ele15_SW_CaloEleId_L1R','HLT_Ele17_SW_CaloEleId_L1R','HLT_Ele17_SW_TightEleId_L1R'
|
100 |
dmf |
1.1 |
l1list = 'L1_ZeroBias','L1_SingleEG5'
|
101 |
|
|
config.runOnMC = False
|
102 |
|
|
config.runPUMC = False
|
103 |
|
|
config.runGen = False
|
104 |
|
|
|
105 |
|
|
elif options.Run == "MC_FlatWeight_and_PU":
|
106 |
|
|
print("")
|
107 |
|
|
print("#####################")
|
108 |
|
|
print("MC Flat Weight and PU")
|
109 |
|
|
print("#####################")
|
110 |
|
|
print("")
|
111 |
|
|
config.globalTagNameMC = 'START42_V17D::All'
|
112 |
|
|
config.TriggerOn = False
|
113 |
|
|
triggerlist = 'no_trigger','no_trigger'
|
114 |
|
|
l1list = 'no_trigger','no_trigger'
|
115 |
|
|
config.runOnMC = True
|
116 |
|
|
config.runPUMC = True
|
117 |
|
|
config.runGen = True
|
118 |
|
|
|
119 |
|
|
elif options.Run == "MC_FlatWeight":
|
120 |
|
|
print("")
|
121 |
|
|
print("##############")
|
122 |
|
|
print("MC Flat Weight")
|
123 |
|
|
print("##############")
|
124 |
|
|
print("")
|
125 |
|
|
config.globalTagNameMC = 'START42_V17D::All'
|
126 |
|
|
config.TriggerOn = False
|
127 |
|
|
triggerlist = 'no_trigger','no_trigger'
|
128 |
|
|
l1list = 'no_trigger','no_trigger'
|
129 |
|
|
config.runOnMC = True
|
130 |
|
|
config.runPUMC = False
|
131 |
|
|
config.runGen = True
|
132 |
|
|
|
133 |
|
|
elif options.Run == "MC_PU":
|
134 |
|
|
print("")
|
135 |
|
|
print("#####")
|
136 |
|
|
print("MC PU")
|
137 |
|
|
print("#####")
|
138 |
|
|
print("")
|
139 |
|
|
config.globalTagNameMC = 'START42_V17D::All'
|
140 |
|
|
config.TriggerOn = False
|
141 |
|
|
triggerlist = 'no_trigger','no_trigger'
|
142 |
|
|
l1list = 'no_trigger','no_trigger'
|
143 |
|
|
config.runOnMC = True
|
144 |
|
|
config.runPUMC = True
|
145 |
|
|
config.runGen = False
|
146 |
|
|
|
147 |
|
|
elif options.Run == "MC_none":
|
148 |
|
|
print("")
|
149 |
|
|
print("#######")
|
150 |
|
|
print("MC None")
|
151 |
|
|
print("#######")
|
152 |
|
|
print("")
|
153 |
|
|
config.globalTagNameMC = 'START42_V17D::All'
|
154 |
|
|
config.TriggerOn = False
|
155 |
|
|
triggerlist = 'no_trigger','no_trigger'
|
156 |
|
|
l1list = 'no_trigger','no_trigger'
|
157 |
|
|
config.runOnMC = True
|
158 |
|
|
config.runPUMC = False
|
159 |
|
|
config.runGen = False
|
160 |
|
|
|
161 |
|
|
else:
|
162 |
|
|
print("")
|
163 |
|
|
print("")
|
164 |
|
|
raise RuntimeError, "Unknown option. EXIT! YOU NEED TO SETUP WITH ONE OF THE CORRECT OPTIONS."
|
165 |
|
|
print("")
|
166 |
|
|
|
167 |
|
|
|
168 |
|
|
print("")
|
169 |
|
|
print(">>> Input Options:")
|
170 |
|
|
print("Run with MC: %s" % config.runOnMC)
|
171 |
|
|
print("Run MC with Pile Up: %s" % config.runPUMC)
|
172 |
|
|
print("Run MC with Flat Weight: %s" % config.runGen)
|
173 |
|
|
print("Run with Trigger: %s" % config.TriggerOn)
|
174 |
|
|
if not config.runOnMC:
|
175 |
|
|
print("Data Global Tag: " + config.globalTagNameData)
|
176 |
|
|
else:
|
177 |
|
|
print("MC Global Tag: " + config.globalTagNameMC)
|
178 |
|
|
print("")
|
179 |
|
|
|
180 |
|
|
#
|
181 |
|
|
# Define Triggers and Input Files
|
182 |
|
|
#
|
183 |
|
|
######################################################################################
|
184 |
|
|
|
185 |
|
|
if config.runOnMC:
|
186 |
|
|
config.l1Paths = (l1list)
|
187 |
|
|
config.hltPaths =(triggerlist)
|
188 |
|
|
config.inputFileName = '/storage1/dmf/TestSamples/PYTHIA6_QCD_15to3000_private_SL_RECO/QCD_Pt_15to3000_TuneZ2_Flat_7TeV_pythia6_cff_py_RAW2DIGI_L1Reco_RECO_233_3_nsm.root'
|
189 |
|
|
|
190 |
|
|
else:
|
191 |
|
|
config.l1Paths = (l1list)
|
192 |
|
|
config.hltPaths = (triggerlist)
|
193 |
|
|
config.inputFileName = '/storage1/dmf/TestSamples/MuRun2010/MuRunA2010.root'
|
194 |
|
|
|
195 |
|
|
#
|
196 |
|
|
# CMSSW Main Code
|
197 |
|
|
#
|
198 |
|
|
######################################################################################
|
199 |
|
|
|
200 |
|
|
process.load('FWCore.MessageService.MessageLogger_cfi')
|
201 |
|
|
|
202 |
|
|
process.options = cms.untracked.PSet(
|
203 |
|
|
wantSummary = cms.untracked.bool(False),
|
204 |
|
|
SkipEvent = cms.untracked.vstring('ProductNotFound')
|
205 |
|
|
)
|
206 |
|
|
|
207 |
|
|
process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(config.NumberOfEvents) )
|
208 |
|
|
|
209 |
|
|
process.source = cms.Source("PoolSource",
|
210 |
|
|
fileNames = cms.untracked.vstring( 'file:%s' % config.inputFileName )
|
211 |
|
|
)
|
212 |
|
|
|
213 |
|
|
|
214 |
|
|
#
|
215 |
|
|
# Output
|
216 |
|
|
#
|
217 |
|
|
######################################################################################
|
218 |
|
|
|
219 |
|
|
process.TFileService = cms.Service("TFileService",
|
220 |
|
|
fileName = cms.string(config.outputTTreeFile))
|
221 |
|
|
|
222 |
|
|
#
|
223 |
|
|
# Detector Conditions and Scales
|
224 |
|
|
#
|
225 |
|
|
######################################################################################
|
226 |
|
|
|
227 |
|
|
process.load('Configuration.StandardSequences.Services_cff')
|
228 |
|
|
process.load('Configuration.StandardSequences.GeometryExtended_cff')
|
229 |
|
|
process.load('Configuration.StandardSequences.MagneticField_38T_cff')
|
230 |
|
|
process.load('Configuration.StandardSequences.Reconstruction_cff')
|
231 |
|
|
process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
|
232 |
|
|
|
233 |
|
|
#
|
234 |
|
|
# Global Tag Input
|
235 |
|
|
#
|
236 |
|
|
######################################################################################
|
237 |
|
|
|
238 |
|
|
if config.runOnMC: process.GlobalTag.globaltag = config.globalTagNameMC
|
239 |
|
|
else: process.GlobalTag.globaltag = config.globalTagNameData
|
240 |
|
|
|
241 |
|
|
process.load('JetMETCorrections.Configuration.DefaultJEC_cff')
|
242 |
|
|
process.load('RecoJets.Configuration.RecoPFJets_cff')
|
243 |
|
|
process.load('RecoJets.Configuration.RecoJets_cff')
|
244 |
|
|
process.load('CommonTools/RecoAlgos/HBHENoiseFilterResultProducer_cfi')
|
245 |
|
|
|
246 |
|
|
#
|
247 |
|
|
# PAT Sequences
|
248 |
|
|
#
|
249 |
|
|
######################################################################################
|
250 |
|
|
|
251 |
|
|
if config.runPATSequences:
|
252 |
|
|
from ForwardAnalysis.Skimming.addPATSequences import addPATSequences
|
253 |
|
|
addPATSequences(process,config.runOnMC)
|
254 |
|
|
|
255 |
|
|
if config.runOnMC:
|
256 |
|
|
process.patTrigger.addL1Algos = cms.bool( False )
|
257 |
|
|
process.patJets.addTagInfos = cms.bool( False )
|
258 |
|
|
else:
|
259 |
|
|
process.patTrigger.addL1Algos = cms.bool( True )
|
260 |
|
|
process.patJets.addTagInfos = cms.bool( True )
|
261 |
|
|
|
262 |
|
|
from ForwardAnalysis.Utilities.addCastorRecHitCorrector import addCastorRecHitCorrector
|
263 |
|
|
addCastorRecHitCorrector(process)
|
264 |
|
|
|
265 |
|
|
#
|
266 |
|
|
# Remove PAT MCMatching for Data
|
267 |
|
|
#
|
268 |
|
|
######################################################################################
|
269 |
|
|
|
270 |
|
|
# load the standard PAT config
|
271 |
|
|
process.load("PhysicsTools.PatAlgos.patSequences_cff")
|
272 |
|
|
|
273 |
|
|
# load the coreTools of PAT
|
274 |
|
|
from PhysicsTools.PatAlgos.tools.coreTools import *
|
275 |
|
|
|
276 |
|
|
#if not config.runOnMC:
|
277 |
|
|
# removeMCMatching(process, ['All'])
|
278 |
|
|
|
279 |
|
|
#
|
280 |
|
|
# PAT Muons and Electrons WorkFlow
|
281 |
|
|
#
|
282 |
|
|
######################################################################################
|
283 |
|
|
|
284 |
|
|
from PhysicsTools.PatAlgos.mcMatchLayer0.electronMatch_cfi import *
|
285 |
|
|
from TrackingTools.TransientTrack.TransientTrackBuilder_cfi import *
|
286 |
|
|
from PhysicsTools.PatAlgos.producersLayer1.electronProducer_cfi import *
|
287 |
|
|
|
288 |
|
|
from PhysicsTools.PatAlgos.mcMatchLayer0.muonMatch_cfi import *
|
289 |
|
|
from TrackingTools.TransientTrack.TransientTrackBuilder_cfi import *
|
290 |
|
|
from PhysicsTools.PatAlgos.producersLayer1.muonProducer_cfi import *
|
291 |
|
|
|
292 |
|
|
#process.patElectrons.pvSrc="goodOfflinePrimaryVertices"
|
293 |
|
|
#process.patMuons.pvSrc="goodOfflinePrimaryVertices"
|
294 |
|
|
|
295 |
|
|
if not config.runOnMC:
|
296 |
|
|
|
297 |
|
|
process.makePatElectrons = cms.Sequence(
|
298 |
|
|
patElectrons
|
299 |
|
|
)
|
300 |
|
|
|
301 |
|
|
process.makePatMuons = cms.Sequence(
|
302 |
|
|
patMuons
|
303 |
|
|
)
|
304 |
|
|
|
305 |
|
|
else:
|
306 |
|
|
process.makePatElectrons = cms.Sequence(
|
307 |
|
|
electronMatch *
|
308 |
|
|
patElectrons
|
309 |
|
|
)
|
310 |
|
|
|
311 |
|
|
process.makePatMuons = cms.Sequence(
|
312 |
|
|
muonMatch*
|
313 |
|
|
patMuons
|
314 |
|
|
)
|
315 |
|
|
|
316 |
|
|
#
|
317 |
|
|
# PAT Isolation Variables
|
318 |
|
|
#
|
319 |
|
|
######################################################################################
|
320 |
|
|
|
321 |
|
|
#from PhysicsTools.PatAlgos.tools.muonTools import *
|
322 |
|
|
#addMuonUserIsolation(process)
|
323 |
|
|
|
324 |
|
|
#from PhysicsTools.PatAlgos.tools.electronTools import *
|
325 |
|
|
#addElectronUserIsolation(process)
|
326 |
|
|
|
327 |
|
|
#
|
328 |
|
|
# Open Common Modules
|
329 |
|
|
#
|
330 |
|
|
######################################################################################
|
331 |
|
|
|
332 |
|
|
process.load("ForwardAnalysis.AnalysisSequences.CommonModulesSequences_cff")
|
333 |
|
|
process.pfCandidateNoiseThresholds.src = "pfNoPileUpPFlow"
|
334 |
|
|
process.tracksTransverseRegion.JetTag = "selectedPatJetsPFlow"
|
335 |
|
|
|
336 |
|
|
#
|
337 |
|
|
# Import PSET for each Module
|
338 |
|
|
#
|
339 |
|
|
######################################################################################
|
340 |
|
|
|
341 |
|
|
from ForwardAnalysis.ForwardTTreeAnalysis.DiffractiveAnalysis_cfi import DiffractiveAnalysis
|
342 |
|
|
from ForwardAnalysis.DiffractiveZAnalysis.DiffractiveZAnalysis_cfi import DiffractiveZAnalysis
|
343 |
|
|
from ForwardAnalysis.ForwardTTreeAnalysis.PATTriggerInfo_cfi import PATTriggerInfo
|
344 |
|
|
|
345 |
|
|
#PATTriggerInfo.L1AlgoBitName = config.l1Paths
|
346 |
|
|
PATTriggerInfo.HLTAlgoBitName = config.hltPaths
|
347 |
|
|
PATTriggerInfo.runALLTriggerPath = True
|
348 |
|
|
|
349 |
|
|
#
|
350 |
|
|
# Define Analyzers
|
351 |
|
|
#
|
352 |
|
|
######################################################################################
|
353 |
|
|
|
354 |
|
|
process.diffractiveZAnalysisTTree = cms.EDAnalyzer("EventInfoDiffractiveDiffractiveZAnalysisTTree",
|
355 |
|
|
EventInfo = cms.PSet(
|
356 |
|
|
RunOnData = cms.untracked.bool(not config.runOnMC),
|
357 |
|
|
RunWithMCPU = cms.untracked.bool(config.runPUMC),
|
358 |
|
|
RunWithWeightGen = cms.untracked.bool(config.runGen)
|
359 |
|
|
),
|
360 |
|
|
DiffractiveAnalysis = DiffractiveAnalysis,
|
361 |
|
|
DiffractiveZAnalysis = DiffractiveZAnalysis
|
362 |
|
|
)
|
363 |
|
|
|
364 |
|
|
process.CommonHLTFilter.HLTPaths = config.hltPaths
|
365 |
|
|
|
366 |
|
|
process.diffractiveZAnalysisTTree.DiffractiveAnalysis.hltPath = ''
|
367 |
|
|
process.diffractiveZAnalysisTTree.DiffractiveAnalysis.trackTag = 'analysisTracks'
|
368 |
|
|
process.diffractiveZAnalysisTTree.DiffractiveAnalysis.vertexTag = "goodOfflinePrimaryVertices"
|
369 |
|
|
process.diffractiveZAnalysisTTree.DiffractiveAnalysis.particleFlowTag = "pfCandidateNoiseThresholds"
|
370 |
|
|
process.diffractiveZAnalysisTTree.DiffractiveAnalysis.jetTag = "selectedPatJetsPFlow"
|
371 |
dmf |
1.3 |
process.diffractiveZAnalysisTTree.DiffractiveAnalysis.accessCastorInfo = False
|
372 |
|
|
process.diffractiveZAnalysisTTree.DiffractiveAnalysis.accessZDCInfo = False
|
373 |
dmf |
1.1 |
|
374 |
|
|
process.diffractiveZAnalysisTTree.DiffractiveZAnalysis.hltPaths = config.hltPaths
|
375 |
|
|
if config.runOnMC:
|
376 |
|
|
process.diffractiveZAnalysisTTree.DiffractiveZAnalysis.RunMC = True
|
377 |
|
|
process.diffractiveZAnalysisTTree.DiffractiveZAnalysis.fCGeVCastor = 0.9375
|
378 |
|
|
else:
|
379 |
|
|
process.diffractiveZAnalysisTTree.DiffractiveZAnalysis.RunMC = False
|
380 |
|
|
process.diffractiveZAnalysisTTree.DiffractiveZAnalysis.fCGeVCastor = 0.015
|
381 |
|
|
|
382 |
|
|
#
|
383 |
|
|
# Define MC Access
|
384 |
|
|
#
|
385 |
|
|
######################################################################################
|
386 |
|
|
|
387 |
|
|
if config.runOnMC:
|
388 |
|
|
process.diffractiveZAnalysisTTree.DiffractiveAnalysis.accessMCInfo = True
|
389 |
|
|
process.gen_step = cms.Path(process.genChargedParticles+
|
390 |
|
|
process.genProtonDissociative*process.edmNtupleMxGen+
|
391 |
|
|
process.genStableParticles*
|
392 |
|
|
process.etaMaxGen+process.etaMinGen*
|
393 |
|
|
process.edmNtupleEtaMaxGen+process.edmNtupleEtaMinGen)
|
394 |
|
|
|
395 |
|
|
else:
|
396 |
|
|
process.diffractiveZAnalysisTTree.DiffractiveAnalysis.accessMCInfo = False
|
397 |
|
|
|
398 |
|
|
#
|
399 |
|
|
# Run Path.
|
400 |
|
|
# If TriggerOn = True (Run with trigger)
|
401 |
|
|
#
|
402 |
|
|
######################################################################################
|
403 |
|
|
|
404 |
|
|
process.pat_Producer = cms.Path(process.makePatElectrons + process.makePatMuons)
|
405 |
|
|
process.analysis_reco_step = cms.Path(process.analysisSequences)
|
406 |
|
|
process.castor_step = cms.Path(process.castorSequence)
|
407 |
|
|
|
408 |
|
|
|
409 |
|
|
if config.TriggerOn:
|
410 |
|
|
process.analysis_diffractiveDiffractiveZAnalysisPATTriggerInfoTTree_step = cms.Path(
|
411 |
|
|
process.eventSelectionHLT + process.diffractiveZAnalysisTTree)
|
412 |
|
|
|
413 |
|
|
else:
|
414 |
|
|
process.analysis_diffractiveDiffractiveZAnalysisPATTriggerInfoTTree_step = cms.Path(
|
415 |
|
|
process.eventSelection + process.diffractiveZAnalysisTTree)
|
416 |
|
|
|