Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-01-26 04:12:39

0001 from __future__ import print_function
0002 ##____________________________________________________________________________||
0003 from PhysicsTools.PatAlgos.patTemplate_cfg import *
0004 
0005 import FWCore.ParameterSet.VarParsing as VarParsing
0006 options = VarParsing.VarParsing ('standard')
0007 
0008 options.register('GlobalTag', "GR_R_52_V7::All", VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.string, "GlobaTTag to use (otherwise default Pat GT is used)")
0009 options.register('mcInfo', False, VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.int, "process MonteCarlo data, default is data")
0010 options.register('jetCorrections', 'L2Relative', VarParsing.VarParsing.multiplicity.list, VarParsing.VarParsing.varType.string, "Level of jet corrections to use: Note the factors are read from DB via GlobalTag")
0011 options.jetCorrections.append('L3Absolute')
0012 options.register('doJetPFchs', True, VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.int, "process MonteCarlo data, default is data")
0013 
0014 options.register('hltName', 'HLT', VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.string, "HLT menu to use for trigger matching, e.g., HLT, REDIGI311X")
0015 options.register('mcVersion', '', VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.string, "'36X' for example. Used for specific MC fix")
0016 options.register('jetTypes', 'AK5PF', VarParsing.VarParsing.multiplicity.list, VarParsing.VarParsing.varType.string, "Additional jet types that will be produced (AK5Calo and AK5PF, cross cleaned in PF2PAT, are included anyway)")
0017 #options.jetTypes.append('AK5Calo')
0018 options.register('hltSelection', '*', VarParsing.VarParsing.multiplicity.list, VarParsing.VarParsing.varType.string, "hlTriggers (OR) used to filter events. for data: ''HLT_Mu9', 'HLT_IsoMu9', 'HLT_IsoMu13_v*''; for MC, HLT_Mu9")
0019 options.register('addKeep', '', VarParsing.VarParsing.multiplicity.list, VarParsing.VarParsing.varType.string, "Additional keep and drop statements to trim the event content")
0020 
0021 options.register('dataVersion', '', VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.string, "'36X' for example. Used for specific DATA fix")
0022 
0023 options.register('debug', False, VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.int, "switch on/off debug mode")
0024 
0025 options.register('type', 'METScanning', VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.string, "key output type string")
0026 
0027 options.register('dataTier', 'AOD', VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.string, "data tier string, e.g., AOD, RECO")
0028 
0029 options.parseArguments()
0030 options._tagOrder =[]
0031 
0032 print(options)
0033 
0034 #-- Message Logger ------------------------------------------------------------
0035 process.MessageLogger.cerr.FwkReport.reportEvery = 1
0036 if options.debug:
0037    process.MessageLogger.cerr.FwkReport.reportEvery = 1
0038 
0039 #-- Input Source --------------------------------------------------------------
0040 if options.files:
0041    process.source.fileNames = options.files
0042 else:
0043    process.source.fileNames = [
0044 'file:pickevents_merged.root'
0045    ]
0046 
0047 process.source.inputCommands = cms.untracked.vstring( "keep *", "drop *_MEtoEDMConverter_*_*" )
0048 process.maxEvents.input = options.maxEvents
0049 
0050 # Calibration tag -----------------------------------------------------------
0051 if options.GlobalTag:
0052    process.GlobalTag.globaltag = options.GlobalTag
0053 
0054 # JEC
0055 if options.mcInfo == False: options.jetCorrections.append('L2L3Residual')
0056 options.jetCorrections.insert(0, 'L1FastJet')
0057 
0058 ##____________________________________________________________________________||
0059 process.options = cms.untracked.PSet(wantSummary = cms.untracked.bool(True))
0060 process.out.fileName = cms.untracked.string('skim.root')
0061 
0062 # load the PAT config
0063 process.load("PhysicsTools.PatAlgos.patSequences_cff")
0064 
0065 # Configure PAT to use PF2PAT instead of AOD sources
0066 # this function will modify the PAT sequences. It is currently 
0067 # not possible to run PF2PAT+PAT and standart PAT at the same time
0068 from PhysicsTools.PatAlgos.tools.pfTools import *
0069 
0070 # This is for PFCHS
0071 from PhysicsTools.SelectorUtils.pvSelector_cfi import pvSelector
0072 process.goodOfflinePrimaryVertices = cms.EDFilter(
0073     "PrimaryVertexObjectFilter",
0074     filterParams = pvSelector.clone( minNdof = cms.double(4.0), maxZ = cms.double(24.0) ),
0075     src=cms.InputTag('offlinePrimaryVertices')
0076 )
0077 
0078 postfix = "PFlow"
0079 jetAlgo="AK5"
0080 print("====> Configuring usePF2PAT : using AK5PFchs ...")
0081 print("See https://twiki.cern.ch/twiki/bin/view/CMSPublic/WorkBookJetEnergyCorrections#JetEnCorPFnoPU")
0082 usePF2PAT(process, runPF2PAT=True, jetAlgo=jetAlgo, runOnMC=options.mcInfo, postfix=postfix, jetCorrections=('AK5PFchs', options.jetCorrections))
0083 getattr(process,"pfPileUp"+postfix).enable = True
0084 getattr(process,"pfPileUp"+postfix).Vertices = 'goodOfflinePrimaryVertices'
0085 getattr(process,"pfPileUp"+postfix).checkClosestZVertex = False
0086 getattr(process,"pfJets"+postfix).doAreaFastjet = True
0087 getattr(process,"pfJets"+postfix).doRhoFastjet = False
0088 getattr(process,"patJetCorrFactors"+postfix).rho = cms.InputTag("kt6PFJets", "rho")
0089 
0090 process.load('RecoJets.JetProducers.kt4PFJets_cfi')
0091 process.kt6PFJets = process.kt4PFJets.clone( rParam = 0.6, doAreaFastjet = True, doRhoFastjet = True )
0092 
0093 # top projections in PF2PAT:
0094 getattr(process,"pfNoPileUp"+postfix).enable = True
0095 getattr(process,"pfNoMuon"+postfix).enable = True
0096 getattr(process,"pfNoElectron"+postfix).enable = True
0097 getattr(process,"pfNoTau"+postfix).enable = False
0098 getattr(process,"pfNoJet"+postfix).enable = True
0099 
0100 # verbose flags for the PF2PAT modules, if any:
0101 
0102 # Add the PV selector and KT6 producer to the sequence
0103 getattr(process,"patPF2PATSequence"+postfix).replace(
0104     getattr(process,"pfNoElectron"+postfix),
0105     getattr(process,"pfNoElectron"+postfix)*process.kt6PFJets )
0106 
0107 ##____________________________________________________________________________||
0108 process.primaryVertexFilter = cms.EDFilter(
0109     "VertexSelector",
0110     src = cms.InputTag("offlinePrimaryVertices"),
0111     cut = cms.string("!isFake && ndof > 4 && abs(z) <= 24 && position.Rho <= 2"),
0112     filter = cms.bool(True)
0113     )
0114 
0115 ##____________________________________________________________________________||
0116 process.noscraping = cms.EDFilter(
0117     "FilterOutScraping",
0118     applyfilter = cms.untracked.bool(True),
0119     debugOn = cms.untracked.bool(False),
0120     numtrack = cms.untracked.uint32(10),
0121     thresh = cms.untracked.double(0.25)
0122     )
0123 
0124 ##____________________________________________________________________________||
0125 process.load('CommonTools/RecoAlgos/HBHENoiseFilter_cfi')
0126 process.HBHENoiseFilter.minIsolatedNoiseSumE = cms.double(999999.)
0127 process.HBHENoiseFilter.minNumIsolatedNoiseChannels = cms.int32(999999)
0128 process.HBHENoiseFilter.minIsolatedNoiseSumEt = cms.double(999999.)
0129 
0130 ##____________________________________________________________________________||
0131 #process.load('RecoMET.METAnalyzers.CSCHaloFilter_cfi')
0132 
0133 ##____________________________________________________________________________||
0134 process.load("RecoMET.METFilters.hcalLaserEventFilter_cfi")
0135 process.hcalLaserEventFilter.vetoByRunEventNumber=cms.untracked.bool(False)
0136 process.hcalLaserEventFilter.vetoByHBHEOccupancy=cms.untracked.bool(True)
0137 
0138 ##____________________________________________________________________________||
0139 process.load('RecoMET.METFilters.EcalDeadCellTriggerPrimitiveFilter_cfi')
0140 process.EcalDeadCellTriggerPrimitiveFilter.debug = cms.bool(True)
0141 
0142 ##____________________________________________________________________________||
0143 process.load('RecoMET.METFilters.EcalDeadCellBoundaryEnergyFilter_cfi')
0144 
0145 process.load('RecoMET.METFilters.jetIDFailureFilter_cfi')
0146 process.jetIDFailure.MinJetPt  = cms.double(30.0)
0147 process.jetIDFailure.MaxJetEta = cms.double(999.0)
0148 
0149 process.goodVertices = cms.EDFilter(
0150   "VertexSelector",
0151   filter = cms.bool(False),
0152   src = cms.InputTag("offlinePrimaryVertices"),
0153   cut = cms.string("!isFake && ndof > 4 && abs(z) <= 24 && position.rho < 2")
0154 )
0155 
0156 process.load('RecoMET.METFilters.trackingFailureFilter_cfi')
0157 process.load('JetMETCorrections.Configuration.DefaultJEC_cff')
0158 #process.trackingFailureFilter.JetSource = cms.InputTag('ak5PFJets')
0159 #process.trackingFailureFilter.JetSource = cms.InputTag('ak5PFJetsL2L3Residual')
0160 
0161 process.load('RecoMET.METFilters.inconsistentMuonPFCandidateFilter_cfi')
0162 
0163 process.load('RecoMET.METFilters.greedyMuonPFCandidateFilter_cfi')
0164 
0165 ##____________________________________________________________________________||
0166 #process.RecovRecHitFilter = cms.EDFilter(
0167 #  "RecovRecHitFilter",
0168 #  EERecHitSource = cms.InputTag("ecalRecHit:EcalRecHitsEE"),
0169 #  MinRecovE = cms.double(30),
0170 #  TaggingMode = cms.bool(False)
0171 #)
0172 
0173 ##____________________________________________________________________________||
0174 ## Let it run
0175 #process.pf2patDUMMY = cms.Path(
0176 #    process.goodOfflinePrimaryVertices *
0177 #    getattr(process,"patPF2PATSequence"+postfix)
0178 #)
0179 
0180 process.load('RecoMET.METFilters.eeNoiseFilter_cfi')
0181 
0182 process.load('RecoMET/METAnalyzers/CSCHaloFilter_cfi')
0183 
0184 process.rejectRecov = cms.EDFilter(
0185   "RecovRecHitFilter",
0186   EERecHitSource = cms.InputTag("reducedEcalRecHitsEE"),
0187   MinRecovE = cms.double(30),
0188   TaggingMode=cms.bool(False)
0189 )
0190 
0191 process.Vertex = cms.Path(process.goodOfflinePrimaryVertices*getattr(process,"patPF2PATSequence"+postfix)*~process.primaryVertexFilter)
0192 process.Scraping = cms.Path(~process.noscraping)
0193 process.HBHENoise = cms.Path(~process.HBHENoiseFilter)
0194 process.CSCTightHalo = cms.Path(~process.CSCTightHaloFilter)
0195 process.RecovRecHit = cms.Path(~process.rejectRecov)
0196 
0197 process.HCALLaser = cms.Path(~process.hcalLaserEventFilter)
0198 process.ECALDeadCellTP = cms.Path(~process.EcalDeadCellTriggerPrimitiveFilter)
0199 process.ECALDeadCellBE = cms.Path(~process.EcalDeadCellBoundaryEnergyFilter)
0200 process.jetID = cms.Path(~process.jetIDFailure)
0201 process.trackingFailure = cms.Path(process.goodVertices*~process.trackingFailureFilter)
0202 process.inconsistentMuon = cms.Path(~process.inconsistentMuonPFCandidateFilter)
0203 process.greedyMuon = cms.Path(~process.greedyMuonPFCandidateFilter)
0204 process.eeNoise = cms.Path(~process.eeNoiseFilter)
0205 
0206 ##____________________________________________________________________________||
0207 process.hltTriggerSummaryAOD = cms.EDProducer(
0208     "TriggerSummaryProducerAOD",
0209     processName = cms.string( "@" )
0210     )
0211 
0212 ##____________________________________________________________________________||
0213 from PhysicsTools.PatAlgos.tools.trigTools import *
0214 switchOnTrigger(process)
0215 
0216 ##____________________________________________________________________________||
0217 process.patTriggerFilter = process.patTrigger.clone()
0218 process.patTriggerFilter.processName = cms.string('PAT')
0219 process.MessageLogger.suppressWarning += ['patTriggerFilter']
0220 
0221 process.outpath = cms.EndPath(
0222     process.patTrigger *
0223     process.hltTriggerSummaryAOD *
0224     process.patTriggerFilter *
0225     process.out
0226 )
0227 
0228 ##____________________________________________________________________________||
0229 from PhysicsTools.PatAlgos.patEventContent_cff import *
0230 process.out.outputCommands = cms.untracked.vstring(
0231     'drop *',
0232     'keep patTriggerPaths_patTrigger*_*_*',
0233 ) 
0234 process.out.SelectEvents = cms.untracked.PSet(SelectEvents = cms.vstring('*', '!*'))
0235 
0236 ##____________________________________________________________________________||