Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:23:59

0001 from PhysicsTools.PatAlgos.patTemplate_cfg import cms, process, patAlgosToolsTask
0002 
0003 process.options.wantSummary = cms.untracked.bool(False) 
0004 
0005 # How many events to process
0006 process.maxEvents = cms.untracked.PSet( 
0007    input = cms.untracked.int32(10)
0008 )
0009 
0010 #configurable options =======================================================================
0011 runOnData=False
0012 usePrivateSQlite=False #use external JECs (sqlite file)
0013 useHFCandidates=True #create an additionnal NoHF slimmed MET collection if the option is set to false
0014 redoPuppi=False # rebuild puppiMET
0015 #===================================================================
0016 
0017 
0018 ### External JECs =====================================================================================================
0019 process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
0020 from Configuration.AlCa.autoCond import autoCond
0021 if runOnData:
0022   process.GlobalTag.globaltag = autoCond['run2_data']
0023 else:
0024   process.GlobalTag.globaltag = autoCond['run2_mc']
0025 
0026 if usePrivateSQlite:
0027     from CondCore.DBCommon.CondDBSetup_cfi import *
0028     import os
0029     if runOnData:
0030       era="Summer15_25nsV6_DATA"
0031     else:
0032       era="Summer15_25nsV6_MC"
0033       
0034     process.jec = cms.ESSource("PoolDBESSource",CondDBSetup,
0035                                connect = cms.string( "frontier://FrontierPrep/CMS_COND_PHYSICSTOOLS"),
0036                                toGet =  cms.VPSet(
0037             cms.PSet(
0038                 record = cms.string("JetCorrectionsRecord"),
0039                 tag = cms.string("JetCorrectorParametersCollection_"+era+"_AK4PF"),
0040                 label= cms.untracked.string("AK4PF")
0041                 ),
0042             cms.PSet(
0043                 record = cms.string("JetCorrectionsRecord"),
0044                 tag = cms.string("JetCorrectorParametersCollection_"+era+"_AK4PFchs"),
0045                 label= cms.untracked.string("AK4PFchs")
0046                 ),
0047             )
0048                                )
0049     process.es_prefer_jec = cms.ESPrefer("PoolDBESSource",'jec')
0050 
0051 
0052 
0053 ### =====================================================================================================
0054 # Define the input source
0055 fname = 'root://eoscms.cern.ch//store/relval/CMSSW_8_0_20/RelValTTbar_13/GEN-SIM-RECO/80X_mcRun2_asymptotic_2016_TrancheIV_v4_Tr4GT_v4-v1/00000/1E399A96-C47A-E611-A718-0025905B8572.root'
0056 
0057 # Define the input source
0058 process.source = cms.Source("PoolSource", 
0059     fileNames = cms.untracked.vstring([ fname ])
0060 )
0061 
0062 
0063 ### ---------------------------------------------------------------------------
0064 ### Removing the HF from the MET computation
0065 ### ---------------------------------------------------------------------------
0066 if not useHFCandidates:
0067     process.noHFCands = cms.EDFilter("CandPtrSelector",
0068                                      src=cms.InputTag("packedPFCandidates"),
0069                                      cut=cms.string("abs(pdgId)!=1 && abs(pdgId)!=2 && abs(eta)<3.0")
0070                                      )
0071     patAlgosToolsTask.add(process.noHFCands)
0072 
0073 #jets are rebuilt from those candidates by the tools, no need to do anything else
0074 ### =================================================================================
0075 
0076 from PhysicsTools.PatUtils.tools.runMETCorrectionsAndUncertainties import runMETCorrectionsAndUncertainties
0077 
0078 process.load("PhysicsTools.PatAlgos.producersLayer1.jetProducer_cff")
0079 patAlgosToolsTask.add(process.makePatJetsTask)
0080 
0081 process.load("PhysicsTools.PatAlgos.selectionLayer1.jetSelector_cfi")
0082 patAlgosToolsTask.add(process.selectedPatJets)
0083 
0084 #default configuration for miniAOD reprocessing, change the isData flag to run on data
0085 #for a full met computation, remove the pfCandColl input
0086 runMETCorrectionsAndUncertainties(process,
0087                            #isData=runOnData,
0088                            )
0089 
0090 if not useHFCandidates:
0091   runMETCorrectionsAndUncertainties(process,
0092                                     #isData=runOnData,
0093                                     pfCandColl=cms.InputTag("noHFCands"),
0094                                     reclusterJets=True, #needed for NoHF
0095                                     recoMetFromPFCs=True, #needed for NoHF
0096                                     postfix="NoHF"
0097                                     )
0098 
0099 if redoPuppi:
0100   from PhysicsTools.PatAlgos.slimming.puppiForMET_cff import makePuppiesFromMiniAOD
0101   makePuppiesFromMiniAOD( process );
0102 
0103   runMETCorrectionsAndUncertainties(process,
0104                              #isData=runOnData,
0105                              metType="Puppi",
0106                              recoMetFromPFCs=True, 
0107                              reclusterJets=True,
0108                              jetFlavor="AK4PFPuppi",
0109                              postfix="Puppi"
0110                              )
0111 
0112 if runOnData:
0113   from PhysicsTools.PatAlgos.tools.coreTools import runOnData
0114   runOnData( process )
0115 
0116 
0117 process.out.outputCommands = cms.untracked.vstring( "keep *_patPFMet*_*_*",
0118                                                     )
0119 process.out.fileName = cms.untracked.string('corMETMiniAOD.root')
0120   
0121 
0122 
0123 process.MINIAODSIMoutput_step = cms.EndPath(process.out)