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 |
options.register('Run','MC_none',VarParsing.multiplicity.singleton, VarParsing.varType.string,"Option to Run: data or MC.")
|
30 |
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 |
config.NumberOfEvents = 100
|
43 |
config.sys = False
|
44 |
|
45 |
#
|
46 |
# Define Options to Run
|
47 |
#
|
48 |
######################################################################################
|
49 |
|
50 |
if options.Run == "data_MuonP1":
|
51 |
print("")
|
52 |
print("###################")
|
53 |
print("Data Muon 2010 P1")
|
54 |
print("###################")
|
55 |
print("")
|
56 |
config.globalTagNameData = 'GR_R_42_V23::All'
|
57 |
config.TriggerOn = True
|
58 |
triggerlist = 'HLT_Mu9','HLT_DoubleMu3'
|
59 |
l1list = 'L1_ZeroBias','L1_SingleEG5'
|
60 |
config.runOnMC = False
|
61 |
config.runPUMC = False
|
62 |
config.runGen = False
|
63 |
|
64 |
elif options.Run == "data_MuonP2":
|
65 |
print("")
|
66 |
print("###################")
|
67 |
print("Data Muon 2010 P2")
|
68 |
print("###################")
|
69 |
print("")
|
70 |
config.globalTagNameData = 'GR_R_42_V23::All'
|
71 |
config.TriggerOn = True
|
72 |
triggerlist = 'HLT_Mu15','HLT_DoubleMu5_v*'
|
73 |
l1list = 'L1_ZeroBias','L1_SingleEG5'
|
74 |
config.runOnMC = False
|
75 |
config.runPUMC = False
|
76 |
config.runGen = False
|
77 |
|
78 |
elif options.Run == "data_ElectronP1":
|
79 |
print("")
|
80 |
print("#######################")
|
81 |
print("Data Electron 2010 P1")
|
82 |
print("#######################")
|
83 |
print("")
|
84 |
config.globalTagNameData = 'GR_R_42_V23::All'
|
85 |
config.TriggerOn = True
|
86 |
triggerlist = 'HLT_Photon10_L1R','HLT_Photon15_Cleaned_L1R','HLT_Ele15_SW_CaloEleId_L1R','HLT_Ele17_SW_CaloEleId_L1R','HLT_Ele17_SW_TightEleId_L1R','HLT_Ele22_SW_TighterCaloIdIsol_L1R_v1','HLT_Ele22_SW_TighterCaloIdIsol_L1R_v2'
|
87 |
l1list = 'L1_ZeroBias','L1_SingleEG5'
|
88 |
config.runOnMC = False
|
89 |
config.runPUMC = False
|
90 |
config.runGen = False
|
91 |
|
92 |
elif options.Run == "data_ElectronP2":
|
93 |
print("")
|
94 |
print("#######################")
|
95 |
print("Data Electron 2010 P2")
|
96 |
print("#######################")
|
97 |
print("")
|
98 |
config.globalTagNameData = 'GR_R_42_V23::All'
|
99 |
config.TriggerOn = True
|
100 |
triggerlist = 'HLT_Photon10_L1R','HLT_Photon15_Cleaned_L1R','HLT_Ele15_SW_CaloEleId_L1R','HLT_Ele17_SW_CaloEleId_L1R','HLT_Ele17_SW_TightEleId_L1R','HLT_Ele22_SW_TighterCaloIdIsol_L1R_v1','HLT_Ele22_SW_TighterCaloIdIsol_L1R_v2'
|
101 |
l1list = 'L1_ZeroBias','L1_SingleEG5'
|
102 |
config.runOnMC = False
|
103 |
config.runPUMC = False
|
104 |
config.runGen = False
|
105 |
|
106 |
elif options.Run == "MC_FlatWeight_and_PU":
|
107 |
print("")
|
108 |
print("#####################")
|
109 |
print("MC Flat Weight and PU")
|
110 |
print("#####################")
|
111 |
print("")
|
112 |
config.globalTagNameMC = 'START42_V17D::All'
|
113 |
config.TriggerOn = False
|
114 |
triggerlist = 'no_trigger','no_trigger'
|
115 |
l1list = 'no_trigger','no_trigger'
|
116 |
config.runOnMC = True
|
117 |
config.runPUMC = True
|
118 |
config.runGen = True
|
119 |
|
120 |
elif options.Run == "MC_FlatWeight":
|
121 |
print("")
|
122 |
print("##############")
|
123 |
print("MC Flat Weight")
|
124 |
print("##############")
|
125 |
print("")
|
126 |
config.globalTagNameMC = 'START42_V17D::All'
|
127 |
config.TriggerOn = False
|
128 |
triggerlist = 'no_trigger','no_trigger'
|
129 |
l1list = 'no_trigger','no_trigger'
|
130 |
config.runOnMC = True
|
131 |
config.runPUMC = False
|
132 |
config.runGen = True
|
133 |
|
134 |
elif options.Run == "MC_PU":
|
135 |
print("")
|
136 |
print("#####")
|
137 |
print("MC PU")
|
138 |
print("#####")
|
139 |
print("")
|
140 |
config.globalTagNameMC = 'START42_V17D::All'
|
141 |
config.TriggerOn = False
|
142 |
triggerlist = 'no_trigger','no_trigger'
|
143 |
l1list = 'no_trigger','no_trigger'
|
144 |
config.runOnMC = True
|
145 |
config.runPUMC = True
|
146 |
config.runGen = False
|
147 |
|
148 |
elif options.Run == "MC_none":
|
149 |
print("")
|
150 |
print("#######")
|
151 |
print("MC None")
|
152 |
print("#######")
|
153 |
print("")
|
154 |
config.globalTagNameMC = 'START42_V17D::All'
|
155 |
config.TriggerOn = False
|
156 |
triggerlist = 'no_trigger','no_trigger'
|
157 |
l1list = 'no_trigger','no_trigger'
|
158 |
config.runOnMC = True
|
159 |
config.runPUMC = False
|
160 |
config.runGen = False
|
161 |
|
162 |
else:
|
163 |
print("")
|
164 |
print("")
|
165 |
raise RuntimeError, "Unknown option. EXIT! YOU NEED TO SETUP WITH ONE OF THE CORRECT OPTIONS."
|
166 |
print("")
|
167 |
|
168 |
|
169 |
print("")
|
170 |
print(">>> Input Options:")
|
171 |
print("Run with MC: %s" % config.runOnMC)
|
172 |
print("Run MC with Pile Up: %s" % config.runPUMC)
|
173 |
print("Run MC with Flat Weight: %s" % config.runGen)
|
174 |
print("Run with Trigger: %s" % config.TriggerOn)
|
175 |
if not config.runOnMC:
|
176 |
print("Data Global Tag: " + config.globalTagNameData)
|
177 |
else:
|
178 |
print("MC Global Tag: " + config.globalTagNameMC)
|
179 |
print("")
|
180 |
|
181 |
#
|
182 |
# Define Triggers and Input Files
|
183 |
#
|
184 |
######################################################################################
|
185 |
|
186 |
if config.runOnMC:
|
187 |
config.l1Paths = (l1list)
|
188 |
config.hltPaths =(triggerlist)
|
189 |
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'
|
190 |
|
191 |
else:
|
192 |
config.l1Paths = (l1list)
|
193 |
config.hltPaths = (triggerlist)
|
194 |
#config.inputFileName = '/storage1/dmf/TestSamples/MuRun2010/MuRunA2010.root'
|
195 |
config.inputFileName = '/storage1/dmf/TestSamples/Electron2010B/Electron2010B.root'
|
196 |
|
197 |
#
|
198 |
# CMSSW Main Code
|
199 |
#
|
200 |
######################################################################################
|
201 |
|
202 |
process.load('FWCore.MessageService.MessageLogger_cfi')
|
203 |
|
204 |
process.options = cms.untracked.PSet(
|
205 |
wantSummary = cms.untracked.bool(False),
|
206 |
SkipEvent = cms.untracked.vstring('ProductNotFound')
|
207 |
)
|
208 |
|
209 |
process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(config.NumberOfEvents) )
|
210 |
|
211 |
process.source = cms.Source("PoolSource",
|
212 |
fileNames = cms.untracked.vstring( 'file:%s' % config.inputFileName )
|
213 |
)
|
214 |
|
215 |
|
216 |
#
|
217 |
# Output
|
218 |
#
|
219 |
######################################################################################
|
220 |
|
221 |
process.TFileService = cms.Service("TFileService",
|
222 |
fileName = cms.string(config.outputTTreeFile))
|
223 |
|
224 |
#
|
225 |
# Detector Conditions and Scales
|
226 |
#
|
227 |
######################################################################################
|
228 |
|
229 |
process.load('Configuration.StandardSequences.Services_cff')
|
230 |
process.load('Configuration.StandardSequences.GeometryExtended_cff')
|
231 |
process.load('Configuration.StandardSequences.MagneticField_38T_cff')
|
232 |
process.load('Configuration.StandardSequences.Reconstruction_cff')
|
233 |
process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
|
234 |
|
235 |
#
|
236 |
# Global Tag Input
|
237 |
#
|
238 |
######################################################################################
|
239 |
|
240 |
if config.runOnMC: process.GlobalTag.globaltag = config.globalTagNameMC
|
241 |
else: process.GlobalTag.globaltag = config.globalTagNameData
|
242 |
|
243 |
process.load('JetMETCorrections.Configuration.DefaultJEC_cff')
|
244 |
process.load('RecoJets.Configuration.RecoPFJets_cff')
|
245 |
process.load('RecoJets.Configuration.RecoJets_cff')
|
246 |
process.load('CommonTools/RecoAlgos/HBHENoiseFilterResultProducer_cfi')
|
247 |
|
248 |
#
|
249 |
# PAT Sequences
|
250 |
#
|
251 |
######################################################################################
|
252 |
|
253 |
if config.runPATSequences:
|
254 |
from ForwardAnalysis.Skimming.addPATSequences import addPATSequences
|
255 |
addPATSequences(process,config.runOnMC)
|
256 |
|
257 |
if config.runOnMC:
|
258 |
process.patTrigger.addL1Algos = cms.bool( False )
|
259 |
process.patJets.addTagInfos = cms.bool( False )
|
260 |
else:
|
261 |
process.patTrigger.addL1Algos = cms.bool( True )
|
262 |
process.patJets.addTagInfos = cms.bool( True )
|
263 |
|
264 |
from ForwardAnalysis.Utilities.addCastorRecHitCorrector import addCastorRecHitCorrector
|
265 |
addCastorRecHitCorrector(process)
|
266 |
|
267 |
#
|
268 |
# Remove PAT MCMatching for Data
|
269 |
#
|
270 |
######################################################################################
|
271 |
|
272 |
# load the standard PAT config
|
273 |
process.load("PhysicsTools.PatAlgos.patSequences_cff")
|
274 |
|
275 |
# load the coreTools of PAT
|
276 |
from PhysicsTools.PatAlgos.tools.coreTools import *
|
277 |
|
278 |
#if not config.runOnMC:
|
279 |
# removeMCMatching(process, ['All'])
|
280 |
|
281 |
#
|
282 |
# PAT Muons and Electrons WorkFlow
|
283 |
#
|
284 |
######################################################################################
|
285 |
|
286 |
from PhysicsTools.PatAlgos.mcMatchLayer0.electronMatch_cfi import *
|
287 |
from TrackingTools.TransientTrack.TransientTrackBuilder_cfi import *
|
288 |
from PhysicsTools.PatAlgos.producersLayer1.electronProducer_cfi import *
|
289 |
|
290 |
from PhysicsTools.PatAlgos.mcMatchLayer0.muonMatch_cfi import *
|
291 |
from TrackingTools.TransientTrack.TransientTrackBuilder_cfi import *
|
292 |
from PhysicsTools.PatAlgos.producersLayer1.muonProducer_cfi import *
|
293 |
|
294 |
#process.patElectrons.pvSrc="goodOfflinePrimaryVertices"
|
295 |
#process.patMuons.pvSrc="goodOfflinePrimaryVertices"
|
296 |
|
297 |
if not config.runOnMC:
|
298 |
|
299 |
process.makePatElectrons = cms.Sequence(
|
300 |
patElectrons
|
301 |
)
|
302 |
|
303 |
process.makePatMuons = cms.Sequence(
|
304 |
patMuons
|
305 |
)
|
306 |
|
307 |
else:
|
308 |
process.makePatElectrons = cms.Sequence(
|
309 |
electronMatch *
|
310 |
patElectrons
|
311 |
)
|
312 |
|
313 |
process.makePatMuons = cms.Sequence(
|
314 |
muonMatch*
|
315 |
patMuons
|
316 |
)
|
317 |
|
318 |
#
|
319 |
# PAT Isolation Variables
|
320 |
#
|
321 |
######################################################################################
|
322 |
|
323 |
#from PhysicsTools.PatAlgos.tools.muonTools import *
|
324 |
#addMuonUserIsolation(process)
|
325 |
|
326 |
#from PhysicsTools.PatAlgos.tools.electronTools import *
|
327 |
#addElectronUserIsolation(process)
|
328 |
|
329 |
#
|
330 |
# Open Common Modules
|
331 |
#
|
332 |
######################################################################################
|
333 |
|
334 |
process.load("ForwardAnalysis.DiffractiveZAnalysis.diffractiveZAnalysisSequences_cff")
|
335 |
process.pfCandidateNoiseThresholds.src = "pfNoPileUpPFlow"
|
336 |
process.tracksTransverseRegion.JetTag = "selectedPatJetsPFlow"
|
337 |
|
338 |
#
|
339 |
# Import PSET for each Module
|
340 |
#
|
341 |
######################################################################################
|
342 |
|
343 |
from ForwardAnalysis.ForwardTTreeAnalysis.DiffractiveAnalysis_cfi import DiffractiveAnalysis
|
344 |
from ForwardAnalysis.DiffractiveZAnalysis.DiffractiveZAnalysis_cfi import DiffractiveZAnalysis
|
345 |
#from ForwardAnalysis.ForwardTTreeAnalysis.PATTriggerInfo_cfi import PATTriggerInfo
|
346 |
|
347 |
#PATTriggerInfo.L1AlgoBitName = config.l1Paths
|
348 |
#PATTriggerInfo.HLTAlgoBitName = config.hltPaths
|
349 |
#PATTriggerInfo.runALLTriggerPath = True
|
350 |
|
351 |
#
|
352 |
# Define Filter
|
353 |
#
|
354 |
######################################################################################
|
355 |
|
356 |
process.diffractiveZFilter = cms.EDFilter("diffractiveZFilter",
|
357 |
nLeptons = cms.untracked.int32(2),
|
358 |
muonTag = cms.untracked.InputTag("muons"),
|
359 |
electronTag = cms.untracked.InputTag("gsfElectrons")
|
360 |
)
|
361 |
|
362 |
|
363 |
#
|
364 |
# Define Analyzers
|
365 |
#
|
366 |
######################################################################################
|
367 |
|
368 |
process.diffractiveZHLTFilter.HLTPaths = config.hltPaths
|
369 |
|
370 |
process.diffractiveZAnalysisTTree = cms.EDAnalyzer("EventInfoDiffractiveDiffractiveZAnalysisTTree",
|
371 |
EventInfo = cms.PSet(
|
372 |
RunOnData = cms.untracked.bool(not config.runOnMC),
|
373 |
RunWithMCPU = cms.untracked.bool(config.runPUMC),
|
374 |
RunWithWeightGen = cms.untracked.bool(config.runGen)
|
375 |
),
|
376 |
DiffractiveAnalysis = DiffractiveAnalysis,
|
377 |
DiffractiveZAnalysis = DiffractiveZAnalysis
|
378 |
)
|
379 |
|
380 |
process.diffractiveZAnalysisTTree.DiffractiveZAnalysis.hltPaths = config.hltPaths
|
381 |
|
382 |
process.diffractiveZAnalysisTTree.DiffractiveAnalysis.hltPath = ''
|
383 |
process.diffractiveZAnalysisTTree.DiffractiveAnalysis.trackTag = 'analysisTracks'
|
384 |
process.diffractiveZAnalysisTTree.DiffractiveAnalysis.vertexTag = "goodOfflinePrimaryVertices"
|
385 |
process.diffractiveZAnalysisTTree.DiffractiveAnalysis.particleFlowTag = "pfCandidateNoiseThresholds"
|
386 |
process.diffractiveZAnalysisTTree.DiffractiveAnalysis.jetTag = "selectedPatJetsPFlow"
|
387 |
process.diffractiveZAnalysisTTree.DiffractiveAnalysis.accessCastorInfo = False
|
388 |
process.diffractiveZAnalysisTTree.DiffractiveAnalysis.accessZDCInfo = False
|
389 |
|
390 |
process.diffractiveZAnalysisTTreePFShiftedUp = process.diffractiveZAnalysisTTree.clone()
|
391 |
process.diffractiveZAnalysisTTreePFShiftedUp.DiffractiveAnalysis.particleFlowTag = "pfCandidateNoiseThresholdsShiftedUp"
|
392 |
process.diffractiveZAnalysisTTreePFShiftedUp.DiffractiveAnalysis.edmNtupleEtaMaxTag = "edmNtupleEtaMaxShiftedUp"
|
393 |
process.diffractiveZAnalysisTTreePFShiftedUp.DiffractiveAnalysis.edmNtupleEtaMinTag = "edmNtupleEtaMinShiftedUp"
|
394 |
process.diffractiveZAnalysisTTreePFShiftedUp.DiffractiveZAnalysis.pfTag = "pfCandidateNoiseThresholdsShiftedUp"
|
395 |
|
396 |
process.diffractiveZAnalysisTTreePFShiftedDown = process.diffractiveZAnalysisTTree.clone()
|
397 |
process.diffractiveZAnalysisTTreePFShiftedDown.DiffractiveAnalysis.particleFlowTag = "pfCandidateNoiseThresholdsShiftedDown"
|
398 |
process.diffractiveZAnalysisTTreePFShiftedDown.DiffractiveAnalysis.edmNtupleEtaMaxTag = "edmNtupleEtaMaxShiftedDown"
|
399 |
process.diffractiveZAnalysisTTreePFShiftedDown.DiffractiveAnalysis.edmNtupleEtaMinTag = "edmNtupleEtaMinShiftedDown"
|
400 |
process.diffractiveZAnalysisTTreePFShiftedDown.DiffractiveZAnalysis.pfTag = "pfCandidateNoiseThresholdsShiftedDown"
|
401 |
|
402 |
if config.runOnMC:
|
403 |
process.diffractiveZAnalysisTTree.DiffractiveZAnalysis.RunMC = True
|
404 |
process.diffractiveZAnalysisTTree.DiffractiveZAnalysis.fCGeVCastor = 0.9375
|
405 |
else:
|
406 |
process.diffractiveZAnalysisTTree.DiffractiveZAnalysis.RunMC = False
|
407 |
process.diffractiveZAnalysisTTree.DiffractiveZAnalysis.fCGeVCastor = 0.015
|
408 |
|
409 |
#
|
410 |
# Define MC Access
|
411 |
#
|
412 |
######################################################################################
|
413 |
|
414 |
if config.runOnMC:
|
415 |
process.diffractiveZAnalysisTTree.DiffractiveAnalysis.accessMCInfo = True
|
416 |
process.gen_step = cms.Path(process.genChargedParticles+
|
417 |
process.genProtonDissociative*process.edmNtupleMxGen+
|
418 |
process.genStableParticles*
|
419 |
process.etaMaxGen+process.etaMinGen*
|
420 |
process.edmNtupleEtaMaxGen+process.edmNtupleEtaMinGen)
|
421 |
|
422 |
else:
|
423 |
process.diffractiveZAnalysisTTree.DiffractiveAnalysis.accessMCInfo = False
|
424 |
|
425 |
#
|
426 |
# Run Path.
|
427 |
# If TriggerOn = True (Run with trigger)
|
428 |
#
|
429 |
######################################################################################
|
430 |
|
431 |
process.pat_Producer = cms.Path(process.makePatElectrons + process.makePatMuons)
|
432 |
process.castor_step = cms.Path(process.castorSequence)
|
433 |
|
434 |
if config.sys:
|
435 |
|
436 |
print(">> With Energy Scale.")
|
437 |
if config.TriggerOn:
|
438 |
print(">> With Trigger.")
|
439 |
process.analysis_diffractiveDiffractiveZAnalysisPATTriggerInfoTTree_step = cms.Path(
|
440 |
process.analysisSequencesShiftedUp + process.analysisSequencesShiftedDown + process.analysisSequences + process.diffractiveZFilter + process.eventSelectionHLT +
|
441 |
process.diffractiveZAnalysisTTreePFShiftedUp + process.diffractiveZAnalysisTTreePFShiftedDown + process.diffractiveZAnalysisTTree)
|
442 |
|
443 |
else:
|
444 |
print(">> No Trigger.")
|
445 |
process.analysis_diffractiveDiffractiveZAnalysisPATTriggerInfoTTree_step = cms.Path(
|
446 |
process.analysisSequencesShiftedUp + process.analysisSequencesShiftedDown + process.analysisSequences + process.diffractiveZFilter + process.eventSelection +
|
447 |
process.diffractiveZAnalysisTTreePFShiftedUp + process.diffractiveZAnalysisTTreePFShiftedDown + process.diffractiveZAnalysisTTree)
|
448 |
|
449 |
else:
|
450 |
|
451 |
print(">> No Energy Scale.")
|
452 |
if config.TriggerOn:
|
453 |
print(">> With Trigger.")
|
454 |
process.analysis_diffractiveDiffractiveZAnalysisPATTriggerInfoTTree_step = cms.Path(
|
455 |
process.analysisSequences + process.diffractiveZFilter + process.eventSelectionHLT + process.diffractiveZAnalysisTTree)
|
456 |
|
457 |
else:
|
458 |
print(">> No Trigger.")
|
459 |
process.analysis_diffractiveDiffractiveZAnalysisPATTriggerInfoTTree_step = cms.Path(
|
460 |
process.analysisSequences + process.diffractiveZFilter + process.eventSelection + process.diffractiveZAnalysisTTree)
|
461 |
|
462 |
|