Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-11-25 02:29:58

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