Ejemplo n.º 1
0
def reproduceJEC(process):
    '''
    Module that reproduces jet collections with the latest Jet Energy Corrections (JEC). Creates new colletions!
    For more details see https://twiki.cern.ch/twiki/bin/view/CMSPublic/WorkBookJetEnergyCorrections#CorrPatJets
    '''    
    print "=== CommonFragments.py:\n\tReproducing jet collections with latest JEC"
    
    from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import patJetCorrFactorsUpdated
    # PF AK4CHS jets
    if not hasattr(process, "JECpayloadAK4PFchs"):
        raise Exception("Error: Could not access process.JECpayloadAK4PFchs! Please load Jet_cfi.py before calling customizations")
    process.patJetCorrFactorsReapplyJECAK4CHS = patJetCorrFactorsUpdated.clone(
      src = cms.InputTag("slimmedJets"),
      levels = ['L1FastJet', 'L2Relative', 'L3Absolute'],
      payload = process.JECpayloadAK4PFchs.payload,  # Set in Jet_cfi.py
    ) 
    from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import patJetsUpdated
    process.patJetsReapplyJECAK4CHS = patJetsUpdated.clone(
      jetSource = cms.InputTag("slimmedJets"),
      jetCorrFactorsSource = cms.VInputTag(cms.InputTag("patJetCorrFactorsReapplyJECAK4CHS"))
    )

    # PUPPI jets
    if not hasattr(process, "JECpayloadAK4PFPuppi"):
        raise Exception("Error: Could not access process.JECpayloadAK4PFPuppi! Please load Jet_cfi.py before calling customizations")
    process.patJetCorrFactorsReapplyJECPuppi = patJetCorrFactorsUpdated.clone(
      src = cms.InputTag("slimmedJetsPuppi"),
      levels = ['L1FastJet', 'L2Relative', 'L3Absolute'],
      payload = process.JECpayloadAK4PFPuppi.payload,  # Set in Jet_cfi.py
    )
    from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import patJetsUpdated
    process.patJetsReapplyJECPuppi = patJetsUpdated.clone(
      jetSource = cms.InputTag("slimmedJetsPuppi"), 
      jetCorrFactorsSource = cms.VInputTag(cms.InputTag("patJetCorrFactorsReapplyJECPuppi"))
    )

    # Add processes to the sequence 
    process.CustomisationsSequence += process.patJetCorrFactorsReapplyJECAK4CHS
    process.CustomisationsSequence += process.patJetsReapplyJECAK4CHS
    process.CustomisationsSequence += process.patJetCorrFactorsReapplyJECPuppi
    process.CustomisationsSequence += process.patJetsReapplyJECPuppi

    return
Ejemplo n.º 2
0
def reproduceJEC(process):
    print "=== Customisation: reproducing jet collections with latest JEC"
    from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import patJetCorrFactorsUpdated
    # PF AK4CHS jets
    if not hasattr(process, "JECpayloadAK4PFchs"):
        raise Exception(
            "Error: Could not access process.JECpayloadAK4PFchs! Please load Jet_cfi.py before calling customizations"
        )
    process.patJetCorrFactorsReapplyJECAK4CHS = patJetCorrFactorsUpdated.clone(
        src=cms.InputTag("slimmedJets"),
        levels=['L1FastJet', 'L2Relative', 'L3Absolute'],
        payload=process.JECpayloadAK4PFchs.payload,  # Set in Jet_cfi.py
    )
    from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import patJetsUpdated
    process.patJetsReapplyJECAK4CHS = patJetsUpdated.clone(
        jetSource=cms.InputTag("slimmedJets"),
        jetCorrFactorsSource=cms.VInputTag(
            cms.InputTag("patJetCorrFactorsReapplyJECAK4CHS")))
    # PUPPI jets
    if not hasattr(process, "JECpayloadAK4PFPuppi"):
        raise Exception(
            "Error: Could not access process.JECpayloadAK4PFPuppi! Please load Jet_cfi.py before calling customizations"
        )
    process.patJetCorrFactorsReapplyJECPuppi = patJetCorrFactorsUpdated.clone(
        src=cms.InputTag("slimmedJetsPuppi"),
        levels=['L1FastJet', 'L2Relative', 'L3Absolute'],
        payload=process.JECpayloadAK4PFPuppi.payload,  # Set in Jet_cfi.py
    )
    from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import patJetsUpdated
    process.patJetsReapplyJECPuppi = patJetsUpdated.clone(
        jetSource=cms.InputTag("slimmedJetsPuppi"),
        jetCorrFactorsSource=cms.VInputTag(
            cms.InputTag("patJetCorrFactorsReapplyJECPuppi")))
    #process.reapplyJEC = cms.Sequence(process.patJetCorrFactorsReapplyJECAK4CHS +
    #                                  process.patJetsReapplyJECAK4CHS +
    #                                  process.patJetCorrFactorsReapplyJECPuppi +
    #                                  process.patJetsReapplyJECPuppi)
    process.CustomisationsSequence += process.patJetCorrFactorsReapplyJECAK4CHS
    process.CustomisationsSequence += process.patJetsReapplyJECAK4CHS
    process.CustomisationsSequence += process.patJetCorrFactorsReapplyJECPuppi
    process.CustomisationsSequence += process.patJetsReapplyJECPuppi
Ejemplo n.º 3
0
def reproduceJEC(process):
    print "=== Customisation: reproducing jet collections with latest JEC"
    from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import patJetCorrFactorsUpdated
    # PF AK4CHS jets
    if not hasattr(process, "JECpayloadAK4PFchs"):
        raise Exception("Error: Could not access process.JECpayloadAK4PFchs! Please load Jet_cfi.py before calling customizations")
    process.patJetCorrFactorsReapplyJECAK4CHS = patJetCorrFactorsUpdated.clone(
      src = cms.InputTag("slimmedJets"),
      levels = ['L1FastJet', 'L2Relative', 'L3Absolute'],
      payload = process.JECpayloadAK4PFchs.payload,  # Set in Jet_cfi.py
    ) 
    from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import patJetsUpdated
    process.patJetsReapplyJECAK4CHS = patJetsUpdated.clone(
      jetSource = cms.InputTag("slimmedJets"),
      jetCorrFactorsSource = cms.VInputTag(cms.InputTag("patJetCorrFactorsReapplyJECAK4CHS"))
    )
    # PUPPI jets
    if not hasattr(process, "JECpayloadAK4PFPuppi"):
        raise Exception("Error: Could not access process.JECpayloadAK4PFPuppi! Please load Jet_cfi.py before calling customizations")
    process.patJetCorrFactorsReapplyJECPuppi = patJetCorrFactorsUpdated.clone(
      src = cms.InputTag("slimmedJetsPuppi"),
      levels = ['L1FastJet', 'L2Relative', 'L3Absolute'],
      payload = process.JECpayloadAK4PFPuppi.payload,  # Set in Jet_cfi.py
    )
    from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import patJetsUpdated
    process.patJetsReapplyJECPuppi = patJetsUpdated.clone(
      jetSource = cms.InputTag("slimmedJetsPuppi"), 
      jetCorrFactorsSource = cms.VInputTag(cms.InputTag("patJetCorrFactorsReapplyJECPuppi"))
    )
    #process.reapplyJEC = cms.Sequence(process.patJetCorrFactorsReapplyJECAK4CHS +
    #                                  process.patJetsReapplyJECAK4CHS +
    #                                  process.patJetCorrFactorsReapplyJECPuppi +
    #                                  process.patJetsReapplyJECPuppi)
    process.CustomisationsSequence += process.patJetCorrFactorsReapplyJECAK4CHS
    process.CustomisationsSequence += process.patJetsReapplyJECAK4CHS
    process.CustomisationsSequence += process.patJetCorrFactorsReapplyJECPuppi
    process.CustomisationsSequence += process.patJetsReapplyJECPuppi
Ejemplo n.º 4
0
def customizeJetTools(process,jecLevels,jecFile,jecTag):

	process.load("CondCore.DBCommon.CondDBCommon_cfi")
	from CondCore.DBCommon.CondDBSetup_cfi import CondDBSetup
	process.jec = cms.ESSource("PoolDBESSource",
				   DBParameters = cms.PSet(
			messageLevel = cms.untracked.int32(0)
			),
				   timetype = cms.string('runnumber'),
				   toGet = cms.VPSet(
			cms.PSet(
				record = cms.string('JetCorrectionsRecord'),
				tag    = cms.string('JetCorrectorParametersCollection_%s'%jecTag),
				label  = cms.untracked.string('AK4PFchs')
				),


      	## here you add as many jet types as you need
      	## note that the tag name is specific for the particular sqlite file 
     	 ), 
      	connect = cms.string('sqlite_file:%s'%jecFile)
	)
	## add an es_prefer statement to resolve a possible conflict from simultaneous connection to a global tag
	process.es_prefer_jec = cms.ESPrefer('PoolDBESSource','jec')

	from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import patJetCorrFactorsUpdated
	process.patJetCorrFactorsReapplyJEC = patJetCorrFactorsUpdated.clone(
		src = cms.InputTag("slimmedJets"),
		levels = jecLevels,
		payload = 'AK4PFchs' ) # Make sure to choose the appropriate levels and payload here!
	
	from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import patJetsUpdated	
	process.slimmedJetsReapplyJEC = patJetsUpdated.clone(
		jetSource = cms.InputTag("slimmedJets"),
		jetCorrFactorsSource = cms.VInputTag(cms.InputTag("patJetCorrFactorsReapplyJEC"))
  	)

	#quark gluon discriminator
	process.load('RecoJets.JetProducers.QGTagger_cfi')
	process.QGTagger.srcJets          = cms.InputTag('slimmedJetsReapplyJEC')
	process.QGTagger.jetsLabel        = cms.string('QGL_AK4PFchs')        
	#process.QGTagger.jec              = cms.string('')
	process.QGTagger.systematicsLabel = cms.string('')     # Produce systematic smearings (not yet available, keep empty)

	
	#sequence to include
	process.customizeJetToolsSequence = cms.Sequence(process.patJetCorrFactorsReapplyJEC 
							 + process. slimmedJetsReapplyJEC
							 + process.QGTagger)
Ejemplo n.º 5
0
def customizeJetTools(process,jecLevels,jecFile,jecTag):

	process.load("CondCore.DBCommon.CondDBCommon_cfi")
	from CondCore.DBCommon.CondDBSetup_cfi import CondDBSetup
	process.jec = cms.ESSource("PoolDBESSource",
				   DBParameters = cms.PSet(
			messageLevel = cms.untracked.int32(0)
			),
				   timetype = cms.string('runnumber'),
				   toGet = cms.VPSet(
			cms.PSet(
				record = cms.string('JetCorrectionsRecord'),
				tag    = cms.string('JetCorrectorParametersCollection_%s'%jecTag),
				label  = cms.untracked.string('AK4PFchs')
				),


      	## here you add as many jet types as you need
      	## note that the tag name is specific for the particular sqlite file 
     	 ), 
      	connect = cms.string('sqlite_file:%s'%jecFile)
	)
	## add an es_prefer statement to resolve a possible conflict from simultaneous connection to a global tag
	process.es_prefer_jec = cms.ESPrefer('PoolDBESSource','jec')

	from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import patJetCorrFactorsUpdated
	process.patJetCorrFactorsReapplyJEC = patJetCorrFactorsUpdated.clone(
		src = cms.InputTag("slimmedJets"),
		levels = jecLevels,
		payload = 'AK4PFchs' ) # Make sure to choose the appropriate levels and payload here!
	
	from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import patJetsUpdated	
	process.slimmedJetsReapplyJEC = patJetsUpdated.clone(
		jetSource = cms.InputTag("slimmedJets"),
		jetCorrFactorsSource = cms.VInputTag(cms.InputTag("patJetCorrFactorsReapplyJEC"))
  	)

	#sequence to include
	process.customizeJetToolsSequence = cms.Sequence(process.patJetCorrFactorsReapplyJEC 
							 + process. slimmedJetsReapplyJEC)
Ejemplo n.º 6
0
        ## here you add as many jet types as you need
        ## note that the tag name is specific for the particular sqlite file
    ),
    connect=cms.string('sqlite:Summer15_25nsV7_DATA.db')
    # uncomment above tag lines and this comment to use MC JEC
    # connect = cms.string('sqlite:Summer12_V7_MC.db')
)
## add an es_prefer statement to resolve a possible conflict from simultaneous connection to a global tag
process.es_prefer_jec = cms.ESPrefer('PoolDBESSource', 'jec')

#Re-correcting pat::Jets and jets from MiniAOD

from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import patJetCorrFactorsUpdated
process.patJetCorrFactorsReapplyJEC = patJetCorrFactorsUpdated.clone(
    src=cms.InputTag("slimmedJetsPuppi"),
    levels=['L1FastJet', 'L2Relative', 'L3Absolute'],
    payload='AK4PFchs'
)  # Make sure to choose the appropriate levels and payload here!

from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import patJetsUpdated
process.patJetsReapplyJEC = patJetsUpdated.clone(
    jetSource=cms.InputTag("slimmedJetsPuppi"),
    jetCorrFactorsSource=cms.VInputTag(
        cms.InputTag("patJetCorrFactorsReapplyJEC")))

#process.p = cms.Sequence( process.patJetCorrFactorsReapplyJEC + process.patJetsReapplyJEC )

## ============  THE NTUPLIZER!!!  ===============
process.MssmHbb = cms.EDAnalyzer(
    "Ntuplizer",
    MonteCarlo=cms.bool(False),
Ejemplo n.º 7
0
                label= cms.untracked.string("AK8PF")
                ),
            cms.PSet(
                record = cms.string("JetCorrectionsRecord"),
                tag = cms.string("JetCorrectorParametersCollection_"+era+"_AK8PFchs"),
                label= cms.untracked.string("AK8PFchs")
                ),
            )
                               )
    process.es_prefer_jec = cms.ESPrefer("PoolDBESSource",'jec')
    
    process.load("PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff")
    from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import patJetCorrFactorsUpdated, patJetsUpdated
    process.patJetCorrFactorsReapplyJEC = patJetCorrFactorsUpdated.clone(
      rho = cms.InputTag("fixedGridRhoFastjetAll"),
      src = cms.InputTag("slimmedJets"),
      
      levels = corrections )
    process.updatedPatJetsAK4 = patJetsUpdated.clone(
      jetSource = cms.InputTag("slimmedJets"),
      jetCorrFactorsSource = cms.VInputTag(cms.InputTag("patJetCorrFactorsReapplyJEC"))
      )
    
    process.patJetAK8CorrFactorsReapplyJEC = patJetCorrFactorsUpdated.clone(
      src = cms.InputTag("slimmedJetsAK8"),
      rho = cms.InputTag("fixedGridRhoFastjetAll"),
      levels = corrections )

    process.updatedPatJetsAK8 = patJetsUpdated.clone(
      jetSource = cms.InputTag("slimmedJetsAK8"),
      jetCorrFactorsSource = cms.VInputTag(cms.InputTag("patJetAK8CorrFactorsReapplyJEC"))
Ejemplo n.º 8
0
def setup_jets(process, cms, options, postfix="PFlow"):
    print '=' * 60
    print "Setting up Jets"
    print '=' * 60
    # use external JECs (sqlite file)
    usePrivateSQlite = options.useJECFromFile
    runOnData = options.isData
    '''
    application of residual corrections. Have to be set to True once the 13 TeV
    residual corrections are available. False to be kept meanwhile. Can be kept
    to False
    '''
    applyResiduals = options.applyResiduals

    # MC setup
    inputJetCorrLabel = ('AK4PFchs', ['L1FastJet', 'L2Relative', 'L3Absolute'])

    if runOnData:  # data set up
        if applyResiduals:
            inputJetCorrLabel = (
                'AK4PFchs', ['L1FastJet', 'L2Relative', 'L3Absolute', 'L2L3Residual'])
        else:
            inputJetCorrLabel = (
                'AK4PFchs', ['L1FastJet', 'L2Relative', 'L3Absolute'])

    # If you want to use other JEC files then put .db file in data/JEC/ and use option useJECFromFile=1 on command line
    if usePrivateSQlite:
        from CondCore.DBCommon.CondDBSetup_cfi import *
        import os
        era = "Fall15_25nsV2_"
        if runOnData:
            era += 'DATA'
        else:
            era += 'MC'
        dBFile = os.path.expandvars(
            "$CMSSW_BASE/src/BristolAnalysis/NTupleTools/data/JEC/" + era + ".db")
            # era + ".db")
        print 'Using JEC from DB: {0}'.format(dBFile)
        process.jec = cms.ESSource("PoolDBESSource", CondDBSetup,
                                   connect=cms.string(
                                       "sqlite_file:" + dBFile),
                                   toGet=cms.VPSet(
                                       cms.PSet(
                                           record=cms.string(
                                               "JetCorrectionsRecord"),
                                           tag=cms.string(
                                               "JetCorrectorParametersCollection_" + era + "_AK4PF"),
                                           label=cms.untracked.string("AK4PF")
                                       ),
                                       cms.PSet(
                                           record=cms.string(
                                               "JetCorrectionsRecord"),
                                           tag=cms.string(
                                               "JetCorrectorParametersCollection_" + era + "_AK4PFchs"),
                                           label=cms.untracked.string(
                                               "AK4PFchs")
                                       ),
                                   )
                                   )
        process.es_prefer_jec = cms.ESPrefer("PoolDBESSource", 'jec')


    print 'Using jet energy corrections: '
    print 'PF Jets'
    print inputJetCorrLabel

    if int(CMSSW_MAJOR_VERSION) < 8:
        from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import patJetCorrFactorsUpdated as updatedPatJetCorrFactors
    else:
        from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import updatedPatJetCorrFactors
    process.patJetCorrFactorsReapplyJEC = updatedPatJetCorrFactors.clone(
      src = cms.InputTag("slimmedJets"),
      levels = inputJetCorrLabel[1],
      payload = inputJetCorrLabel[0] ) # Make sure to choose the appropriate levels and payload here!

    if int(CMSSW_MAJOR_VERSION) < 8:
        from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import patJetsUpdated as updatedPatJets
    else:
        from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import updatedPatJets
    process.patJetsReapplyJEC = updatedPatJets.clone(
      jetSource = cms.InputTag("slimmedJets"),
      jetCorrFactorsSource = cms.VInputTag(cms.InputTag("patJetCorrFactorsReapplyJEC"))
      )

    process.reapplyJEC = cms.Sequence( process.patJetCorrFactorsReapplyJEC + process.patJetsReapplyJEC )
                tag=cms.string("JetCorrectorParametersCollection_" + era + "_AK4PFchs"),
                label=cms.untracked.string("AK4PFchs"),
            ),
        ),
    )
    process.es_prefer_jec = cms.ESPrefer("PoolDBESSource", "jec")

### =====================================================================================================


### ReRun JEC ===========================================================================================

from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import patJetCorrFactorsUpdated

process.patJetCorrFactorsReapplyJEC = patJetCorrFactorsUpdated.clone(
    src=cms.InputTag("slimmedJets"), levels=["L1FastJet", "L2Relative", "L3Absolute"], payload="AK4PFchs"
)  # Make sure to choose the appropriate levels and payload here!

from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import patJetsUpdated

process.patJetsReapplyJEC = patJetsUpdated.clone(
    jetSource=cms.InputTag("slimmedJets"),
    jetCorrFactorsSource=cms.VInputTag(cms.InputTag("patJetCorrFactorsReapplyJEC")),
)

### END ReRun JEC ======================================================================================

### PFMET Corrections ==================================================================================

### ---------------------------------------------------------------------------
### Removing the HF from the MET computation
Ejemplo n.º 10
0
def preprocess(process):
    '''pre-processing function for MC'''
    ################
    #Database for JEC
    process.load("CondCore.DBCommon.CondDBCommon_cfi")
    process.jec = cms.ESSource(
        "PoolDBESSource",
        CondDBSetup,
        connect=cms.string('sqlite:Summer15_25nsV6_DATA.db'),
        toGet=cms.VPSet(
            cms.PSet(
                record=cms.string('JetCorrectionsRecord'),
                tag=cms.string(
                    'JetCorrectorParametersCollection_Summer15_25nsV6_DATA_AK4PFchs'
                ),
                label=cms.untracked.string('AK4PFchs')),
            cms.PSet(
                record=cms.string('JetCorrectionsRecord'),
                tag=cms.string(
                    'JetCorrectorParametersCollection_Summer15_25nsV6_DATA_AK4PF'
                ),
                label=cms.untracked.string('AK4PF'))))
    # add an es_prefer statement to resolve a possible conflict from simultaneous connection to a global tag
    process.es_prefer_jec = cms.ESPrefer('PoolDBESSource', 'jec')

    ##to re-correct the jets
    from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import patJetCorrFactorsUpdated
    process.patJetCorrFactorsReapplyJEC = patJetCorrFactorsUpdated.clone(
        src=cms.InputTag("slimmedJets"),
        levels=['L1FastJet', 'L2Relative', 'L3Absolute', 'L2L3Residual'],
        payload='AK4PFchs'
    )  # Make sure to choose the appropriate levels and payload here!

    from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import patJetsUpdated
    process.patJetsReapplyJEC = patJetsUpdated.clone(
        jetSource=cms.InputTag("slimmedJets"),
        jetCorrFactorsSource=cms.VInputTag(
            cms.InputTag("patJetCorrFactorsReapplyJEC")))

    process.JetRecorrection = cms.Sequence(
        process.patJetCorrFactorsReapplyJEC + process.patJetsReapplyJEC)
    #############

    #############
    #MET without HF
    #
    #
    #
    process.noHFCands = cms.EDFilter(
        "CandPtrSelector",
        src=cms.InputTag("packedPFCandidates"),
        cut=cms.string("abs(pdgId)!=1 && abs(pdgId)!=2 && abs(eta)<3.0"))
    isdata = True
    #jetuncfile = 'CondFormats/JetMETObjects/data/Summer15_50nsV5_DATA_UncertaintySources_AK4PFchs.txt'
    #jetuncfile = 'CondFormats/JetMETObjects/data/Summer15_25nsV5_DATA_UncertaintySources_AK4PFchs.txt'
    jetuncfile = 'URNtuples/PATTools/data/Summer15_25nsV6_DATA_UncertaintySources_AK4PFchs.txt'

    from PhysicsTools.PatUtils.tools.runMETCorrectionsAndUncertainties import runMetCorAndUncFromMiniAOD
    runMetCorAndUncFromMiniAOD(
        process,
        jetColl="patJetsReapplyJEC",
        isData=isdata,
        postfix="v2",
        jecUncFile=jetuncfile,
    )
    process.patPFMetTxyCorrv2.vertexCollection = cms.InputTag(
        'offlineSlimmedPrimaryVertices')
    #process.slimmedMETsv2.t01Variation = cms.InputTag("slimmedMETs","","RECO")
    process.slimmedMETsv2.t01Variation = cms.InputTag("slimmedMETs", "")

    runMetCorAndUncFromMiniAOD(
        process,
        jetColl="patJetsReapplyJEC",
        isData=isdata,
        pfCandColl=cms.InputTag("noHFCands"),
        postfix="NoHFv2",
        jecUncFile=jetuncfile,
    )
    process.patPFMetTxyCorrNoHFv2.vertexCollection = cms.InputTag(
        'offlineSlimmedPrimaryVertices')
    process.slimmedMETsNoHFv2.t01Variation = cms.InputTag(
        "slimmedMETsNoHF", "")
    #
    #process.patPFMetT1T2Corrv2.jetCorrLabelRes = cms.InputTag("L3Absolute")
    #process.patPFMetT1T2SmearCorrv2.jetCorrLabelRes = cms.InputTag("L3Absolute")
    #process.patPFMetT2Corrv2.jetCorrLabelRes = cms.InputTag("L3Absolute")
    #process.patPFMetT2SmearCorrv2.jetCorrLabelRes = cms.InputTag("L3Absolute")
    #process.shiftedPatJetEnDownv2.jetCorrLabelUpToL3Res = cms.InputTag("ak4PFCHSL1FastL2L3Corrector")
    #process.shiftedPatJetEnUpv2.jetCorrLabelUpToL3Res = cms.InputTag("ak4PFCHSL1FastL2L3Corrector")

    process.patPFMetT1T2CorrNoHFv2.jetCorrLabelRes = cms.InputTag("L3Absolute")
    process.patPFMetT1T2SmearCorrNoHFv2.jetCorrLabelRes = cms.InputTag(
        "L3Absolute")
    process.patPFMetT2CorrNoHFv2.jetCorrLabelRes = cms.InputTag("L3Absolute")
    process.patPFMetT2SmearCorrNoHFv2.jetCorrLabelRes = cms.InputTag(
        "L3Absolute")

    if hasattr(process.slimmedMETsv2, 'caloMET'):
        del process.slimmedMETsv2.caloMET
    if hasattr(process.slimmedMETsNoHFv2, 'caloMET'):
        del process.slimmedMETsNoHFv2.caloMET

    ###################################
    #      THIS HAS TO BE ALWAYS KEPT!
    ###################################
    process.preprocessing = cms.Sequence()
    collections = {
        'muons':
        'slimmedMuons',
        'electrons':
        'slimmedElectrons',
        'photons':
        'slimmedPhotons',
        'jets':
        'slimmedJets'
        if not hasattr(process, 'patJetsReapplyJEC') else 'patJetsReapplyJEC',
        'vertices':
        'offlineSlimmedPrimaryVertices',
        'METs':
        'slimmedMETs'
        if not hasattr(process, 'slimmedMETsv2') else 'slimmedMETsv2',
        'NoHFMETs':
        'slimmedMETsNoHF'
        if not hasattr(process, 'slimmedMETsNoHFv2') else 'slimmedMETsNoHFv2',
        'genParticles':
        'prunedGenParticles',
    }
    return collections
Ejemplo n.º 11
0
def rerun_JECJER(process, opts, collections):
    'I will make my own correction, with blackjack and hookers! (cit.)'
    #re-run JEC
    process.newJECJER = cms.Sequence()
    process.patJetCorrFactorsReapplyJEC = patJetCorrFactorsUpdated.clone(
     src = cms.InputTag(collections['jets']),
     levels = cms.vstring('L1FastJet', 'L2Relative', 'L3Absolute') \
      if opts.isMC else \
      cms.vstring('L1FastJet', 'L2Relative', 'L3Absolute', 'L2L3Residual'),
     payload = 'AK4PFchs'
     )
    process.patJetCorrFactorsReapplyJEC.levels = cms.vstring(
        'L1FastJet', 'L2Relative', 'L3Absolute', 'L2L3Residual')
    process.newJECJER *= process.patJetCorrFactorsReapplyJEC

    process.slimmedJetsNewJEC = patJetsUpdated.clone(
        jetSource=cms.InputTag(collections['jets']),
        jetCorrFactorsSource=cms.VInputTag(
            cms.InputTag("patJetCorrFactorsReapplyJEC")))
    process.newJECJER *= process.slimmedJetsNewJEC
    collections['jets'] = 'slimmedJetsNewJEC'

    #
    # Reset MET
    #
    originalMET = collections['METs']
    if opts.isMC:
        process.genMet = cms.EDProducer("GenMETExtractor",
                                        metSource=cms.InputTag(
                                            collections['METs'], "",
                                            "@skipCurrentProcess"))
        process.newJECJER *= process.genMet

    process.uncorrectedMet = cms.EDProducer("RecoMETExtractor",
                                            correctionLevel=cms.string('raw'),
                                            metSource=cms.InputTag(
                                                collections['METs'], "",
                                                "@skipCurrentProcess"))
    process.newJECJER *= process.uncorrectedMet

    addMETCollection(process,
                     labelName="uncorrectedPatMet",
                     metSource="uncorrectedMet")
    if opts.isMC:
        process.uncorrectedPatMet.genMETSource = cms.InputTag('genMet')
    else:
        process.uncorrectedPatMet.addGenMET = False
    process.newJECJER *= process.uncorrectedPatMet  #probably not needed since unscheduled, but f**k it
    process.Type1CorrForNewJEC = cms.EDProducer(
        "PATPFJetMETcorrInputProducer",
        src=cms.InputTag('slimmedJetsNewJEC'),
        offsetCorrLabel=cms.InputTag("L1FastJet"),
        jetCorrLabel=cms.InputTag("L3Absolute"),  # for MC
        jetCorrLabelRes=cms.InputTag(
            "L2L3Residual"),  # for Data automatic switch
        type1JetPtThreshold=cms.double(15.0),
        skipEM=cms.bool(True),
        skipEMfractionThreshold=cms.double(0.90),
        skipMuons=cms.bool(True),
        skipMuonSelection=cms.string("isGlobalMuon | isStandAloneMuon")
        #WAS (in 7.6)
        #isMC = cms.bool(opts.isMC),
        #jetCorrLabel = cms.InputTag("L3Absolute"),
        #jetCorrLabelRes = cms.InputTag("L2L3Residual"),
        #offsetCorrLabel = cms.InputTag("L1FastJet"),
        #skipEM = cms.bool(True),
        #skipEMfractionThreshold = cms.double(0.9),
        #skipMuonSelection = cms.string('isGlobalMuon | isStandAloneMuon'),
        #skipMuons = cms.bool(True),
        #src = cms.InputTag("slimmedJetsNewJEC"),
        #type1JetPtThreshold = cms.double(15.0),
        #type2ExtraCorrFactor = cms.double(1.0),
        #type2ResidualCorrEtaMax = cms.double(9.9),
        #type2ResidualCorrLabel = cms.InputTag(""),
        #type2ResidualCorrOffset = cms.double(0.0)
    )
    process.newJECJER *= process.Type1CorrForNewJEC

    process.slimmedMETsNewJEC = cms.EDProducer(
        'CorrectedPATMETProducer',
        src=cms.InputTag('uncorrectedPatMet'),
        srcCorrections=cms.VInputTag(
            cms.InputTag('Type1CorrForNewJEC', 'type1')))
    process.newJECJER *= process.slimmedMETsNewJEC
    collections['METs'] = 'slimmedMETsNewJEC'

    if opts.isMC:
        #### Second, smear newly corrected jets
        process.slimmedJetsSmeared = cms.EDProducer(
            'SmearedPATJetProducer',
            src=cms.InputTag('slimmedJetsNewJEC'),
            enabled=cms.bool(True),
            rho=cms.InputTag("fixedGridRhoFastjetAll"),
            # Read from GT
            algopt=cms.string('AK4PFchs_pt'),
            algo=cms.string('AK4PFchs'),
            #or from txt file (DEPRECATED!)
            #resolutionFile  = cms.FileInPath('URNtuples/PATTools/data/Fall15_25nsV2_MC_PtResolution_AK4PFchs.txt'),
            #scaleFactorFile = cms.FileInPath('URNtuples/PATTools/data/Fall15_25nsV2_MC_SF_AK4PFchs.txt'),
            genJets=cms.InputTag('slimmedGenJets'),
            dRMax=cms.double(0.2),
            dPtMaxFactor=cms.double(3),
            variation=cms.int32(0),
            debug=cms.untracked.bool(False))
        process.newJECJER *= process.slimmedJetsSmeared

        METSmeared = shift_MET(process, process.newJECJER, 'Smeared',
                               'slimmedJetsSmeared')

        #
        # Compute shifts
        #
        # JES
        process.slimmedJetsNewJECJESUp = cms.EDProducer(
            "ShiftedPATJetProducer",
            addResidualJES=cms.bool(True),
            jetCorrLabelUpToL3=cms.InputTag("ak4PFCHSL1FastL2L3Corrector"),
            jetCorrLabelUpToL3Res=cms.InputTag(
                "ak4PFCHSL1FastL2L3ResidualCorrector"),
            jetCorrPayloadName=cms.string('AK4PFchs'),
            jetCorrUncertaintyTag=cms.string('Uncertainty'),
            shiftBy=cms.double(1.0),
            src=cms.InputTag(collections['jets']))
        process.newJECJER *= process.slimmedJetsNewJECJESUp
        METJESP = shift_MET(process, process.newJECJER, 'JESUp',
                            'slimmedJetsNewJECJESUp')

        process.slimmedJetsNewJECJESDown = process.slimmedJetsNewJECJESUp.clone(
            shiftBy=cms.double(-1.0))
        process.newJECJER *= process.slimmedJetsNewJECJESDown
        METJESM = shift_MET(process, process.newJECJER, 'JESDown',
                            'slimmedJetsNewJECJESDown')

        # JER
        process.slimmedJetsSmearedJERUp = process.slimmedJetsSmeared.clone(
            variation=cms.int32(1))
        process.newJECJER *= process.slimmedJetsSmearedJERUp
        METJERP = shift_MET(process, process.newJECJER, 'JERUp',
                            'slimmedJetsSmearedJERUp')

        process.slimmedJetsSmearedJERDown = process.slimmedJetsSmeared.clone(
            variation=cms.int32(-1))
        process.newJECJER *= process.slimmedJetsSmearedJERDown
        METJERM = shift_MET(process, process.newJECJER, 'JERDown',
                            'slimmedJetsSmearedJERDown')

    #common to data and MC
    # QGTagger
    qgDatabaseVersion = '80X'  # check https://twiki.cern.ch/twiki/bin/viewauth/CMS/QGDataBaseVersion
    from CondCore.DBCommon.CondDBSetup_cfi import CondDBSetup
    process.QGPoolDBESSource = cms.ESSource(
        "PoolDBESSource",
        CondDBSetup,
        toGet=cms.VPSet(),
        connect=cms.string('sqlite:QGL_80X.db'),
    )
    process.es_prefer_qgtagger = cms.ESPrefer("PoolDBESSource",
                                              "QGPoolDBESSource")

    for jet_type in ['AK4PFchs', 'AK4PFchs_antib']:
        process.QGPoolDBESSource.toGet.extend(
            cms.VPSet(
                cms.PSet(record=cms.string('QGLikelihoodRcd'),
                         tag=cms.string('QGLikelihoodObject_' +
                                        qgDatabaseVersion + '_' + jet_type),
                         label=cms.untracked.string('QGL_' + jet_type))))
    process.load('RecoJets.JetProducers.QGTagger_cfi')
    process.QGTagger.srcJets = cms.InputTag(collections['jets'])
    process.QGTagger.jetsLabel = cms.string('QGL_AK4PFchs')
    process.newJECJER *= process.QGTagger

    # Embed everything! (insert meme here)
    process.jetsNewJECAllEmbedded = cms.EDProducer(
        'PATJetsEmbedder',
        src=cms.InputTag(collections['jets']),
        trigMatches=cms.VInputTag(),
        trigPaths=cms.vstring(),
        floatMaps=cms.PSet(qgtag=cms.InputTag("QGTagger:qgLikelihood"), ),
        shiftNames=cms.vstring('JES+', 'JES-', 'JER', 'JER+', 'JER-')
        if opts.isMC else cms.vstring(),
        shiftedCollections=cms.VInputTag(
            cms.InputTag('slimmedJetsNewJECJESUp'),
            cms.InputTag('slimmedJetsNewJECJESDown'),
            cms.InputTag('slimmedJetsSmeared'),
            cms.InputTag('slimmedJetsSmearedJERUp'),
            cms.InputTag('slimmedJetsSmearedJERDown'),
        ) if opts.isMC else cms.VInputTag(),
    )
    collections['jets'] = 'jetsNewJECAllEmbedded'
    process.newJECJER *= process.jetsNewJECAllEmbedded

    process.METsNewJECAllEmbedded = cms.EDProducer(
        'PATMETEmbedder',
        src=cms.InputTag(collections['METs']),
        trigMatches=cms.VInputTag(),
        trigPaths=cms.vstring(),
        floatMaps=cms.PSet(),
        shiftNames=cms.vstring('ORIGINAL', 'JES+', 'JES-', 'JER', 'JER+',
                               'JER-') if opts.isMC else cms.vstring(),
        shiftedCollections=cms.VInputTag(
            cms.InputTag(originalMET),
            cms.InputTag(METJESP),
            cms.InputTag(METJESM),
            cms.InputTag(METSmeared),
            cms.InputTag(METJERP),
            cms.InputTag(METJERM),
        ) if opts.isMC else cms.VInputTag(),
    )
    collections['METs'] = 'METsNewJECAllEmbedded'
    process.newJECJER *= process.jetsNewJECAllEmbedded
    return collections, 'newJECJER'
Ejemplo n.º 12
0
        '/store/mc/RunIIFall15MiniAODv2/TT_TuneCUETP8M1_13TeV-powheg-pythia8/MINIAODSIM/PU25nsData2015v1_76X_mcRun2_asymptotic_v12_ext3-v1/00000/02837459-03C2-E511-8EA2-002590A887AC.root'
    ))

process.out = cms.OutputModule("PoolOutputModule",
                               outputCommands=cms.untracked.vstring('keep *'),
                               fileName=cms.untracked.string("output.root"))

# Jets

### First, apply new JEC over slimmedJets

from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import patJetCorrFactorsUpdated
from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import patJetsUpdated

process.patJetCorrFactorsReapplyJEC = patJetCorrFactorsUpdated.clone(
    src=cms.InputTag("slimmedJets"),
    levels=['L1FastJet', 'L2Relative', 'L3Absolute'],
    payload='AK4PFchs')

process.slimmedJetsNewJEC = patJetsUpdated.clone(
    jetSource=cms.InputTag("slimmedJets"),
    jetCorrFactorsSource=cms.VInputTag(
        cms.InputTag("patJetCorrFactorsReapplyJEC")))

#### Second, smear newly corrected jets

process.slimmedJetsSmeared = cms.EDProducer(
    'SmearedPATJetProducer',
    src=cms.InputTag('slimmedJetsNewJEC'),
    enabled=cms.bool(True),
    rho=cms.InputTag("fixedGridRhoAll"),
    resolutionFile=cms.FileInPath(
Ejemplo n.º 13
0
def customizeJets(process, coll, **kwargs):
    '''Customize jets'''
    isMC = kwargs.pop('isMC', False)
    jSrc = coll['jets']
    rhoSrc = coll['rho']

    # customization path
    process.jetCustomization = cms.Path()

    ######################
    ### recorrect jets ###
    ######################
    from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import patJetCorrFactorsUpdated
    process.patJetCorrFactorsReapplyJEC = patJetCorrFactorsUpdated.clone(
        src=cms.InputTag(jSrc),
        levels=['L1FastJet', 'L2Relative', 'L3Absolute'],
        payload='AK4PFchs')

    from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import patJetsUpdated
    process.patJetsReapplyJEC = patJetsUpdated.clone(
        jetSource=cms.InputTag(jSrc),
        jetCorrFactorsSource=cms.VInputTag(
            cms.InputTag("patJetCorrFactorsReapplyJEC")))

    process.jetCustomization *= process.patJetCorrFactorsReapplyJEC
    process.jetCustomization *= process.patJetsReapplyJEC
    jSrc = "patJetsReapplyJEC"

    #################
    ### embed ids ###
    #################
    process.jID = cms.EDProducer(
        "JetIdEmbedder",
        src=cms.InputTag(jSrc),
    )
    process.jetCustomization *= process.jID
    jSrc = "jID"

    #################
    ### embed rho ###
    #################
    process.jRho = cms.EDProducer(
        "JetRhoEmbedder",
        src=cms.InputTag(jSrc),
        rhoSrc=cms.InputTag(rhoSrc),
        label=cms.string("rho"),
    )
    jSrc = 'jRho'

    process.jetCustomization *= process.jRho

    ##########################
    ### embed jet gen jets ###
    ##########################
    if isMC:
        process.jGenJetMatching = cms.EDProducer(
            "JetGenJetEmbedder",
            src=cms.InputTag(jSrc),
            genJets=cms.InputTag("slimmedGenJets"),
            excludeLeptons=cms.bool(False),
            deltaR=cms.double(0.5),
        )
        jSrc = "jGenJetMatching"
        process.jetCustomization *= process.jGenJetMatching

    # add to schedule
    process.schedule.append(process.jetCustomization)

    coll['jets'] = jSrc

    return coll
Ejemplo n.º 14
0
                     label=cms.untracked.string("AK4PFchs")),
            cms.PSet(record=cms.string("JetCorrectionsRecord"),
                     tag=cms.string("JetCorrectorParametersCollection_" + era +
                                    "_AK8PF"),
                     label=cms.untracked.string("AK8PF")),
            cms.PSet(record=cms.string("JetCorrectionsRecord"),
                     tag=cms.string("JetCorrectorParametersCollection_" + era +
                                    "_AK8PFchs"),
                     label=cms.untracked.string("AK8PFchs")),
        ))
    process.es_prefer_jec = cms.ESPrefer("PoolDBESSource", 'jec')

    process.load("PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff")
    from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import patJetCorrFactorsUpdated, patJetsUpdated
    process.patJetCorrFactorsReapplyJEC = patJetCorrFactorsUpdated.clone(
        rho=cms.InputTag("fixedGridRhoFastjetAll"),
        src=cms.InputTag("slimmedJets"),
        levels=corrections)
    process.updatedPatJetsAK4 = patJetsUpdated.clone(
        jetSource=cms.InputTag("slimmedJets"),
        jetCorrFactorsSource=cms.VInputTag(
            cms.InputTag("patJetCorrFactorsReapplyJEC")))

    process.patJetAK8CorrFactorsReapplyJEC = patJetCorrFactorsUpdated.clone(
        src=cms.InputTag("slimmedJetsAK8"),
        rho=cms.InputTag("fixedGridRhoFastjetAll"),
        levels=corrections)

    process.updatedPatJetsAK8 = patJetsUpdated.clone(
        jetSource=cms.InputTag("slimmedJetsAK8"),
        jetCorrFactorsSource=cms.VInputTag(
            cms.InputTag("patJetAK8CorrFactorsReapplyJEC")))
Ejemplo n.º 15
0
        if isMC : 
            process.genMetExtractor.metSource= cms.InputTag("slimmedMETs", "", miniAODProcess)   
        process.slimmedMETs.t01Variation = cms.InputTag("slimmedMETs", "", miniAODProcess) 

    if not applyL2L3Residuals : 
        process.patPFMetT1T2Corr.jetCorrLabelRes = cms.InputTag("L3Absolute")
        process.patPFMetT1T2SmearCorr.jetCorrLabelRes = cms.InputTag("L3Absolute")
        process.patPFMetT2Corr.jetCorrLabelRes = cms.InputTag("L3Absolute")
        process.patPFMetT2SmearCorr.jetCorrLabelRes = cms.InputTag("L3Absolute")
        process.shiftedPatJetEnDown.jetCorrLabelUpToL3Res = cms.InputTag("ak4PFCHSL1FastL2L3Corrector")
        process.shiftedPatJetEnUp.jetCorrLabelUpToL3Res = cms.InputTag("ak4PFCHSL1FastL2L3Corrector")
        
    from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import patJetCorrFactorsUpdated
    process.patJetCorrFactorsReapplyJEC = patJetCorrFactorsUpdated.clone(
        src = cms.InputTag("slimmedJets"),
        levels = JECLevels,
        payload = 'AK4PFchs' 
    )

    from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import patJetsUpdated
    process.slimmedJetsRecorrected = patJetsUpdated.clone(
        jetSource = cms.InputTag("slimmedJets"),
        jetCorrFactorsSource = cms.VInputTag(cms.InputTag("patJetCorrFactorsReapplyJEC"))
    )
    jetCollName = "slimmedJetsRecorrected"

# Create a set of objects to read from
process.selectedObjects = cms.EDProducer("PFCleaner",
    vertices = cms.InputTag("goodVertices"),
    pfcands = cms.InputTag("packedPFCandidates"),
    muons = cms.InputTag("slimmedMuons"),
Ejemplo n.º 16
0
def createProcess(
        runOnMC=True,
        channel='tau-mu',
        runSVFit=False,
        p4TransferFunctionFile='CMGTools/SVfitStandalone/data/svFitVisMassAndPtResolutionPDF.root',  # Christians's default. If not touched, it would default to this anyways
        integrateOverP4=False,
        scaleTau=0.):
    '''Set up CMSSW process to run MVA MET and SVFit.

    Args:
        runOnMC (bool): run on MC (access to gen-level products) or data
        channel (string): choose from 'tau-mu' 'di-tau' 'tau-ele' 'mu-ele' 
                          'all-separate' 'all'
        runSVFit (bool): enables the svfit mass reconstruction used for the 
                         H->tau tau analysis.
    '''

    sep_line = '-' * 70

    process = cms.Process("H2TAUTAU")

    # Adding jet collection
    process.load(
        'Configuration.StandardSequences.FrontierConditions_GlobalTag_condDBv2_cff'
    )
    process.GlobalTag.globaltag = '76X_mcRun2_asymptotic_RunIIFall15DR76_v1'
    if not runOnMC:
        process.GlobalTag.globaltag = '76X_dataRun2_16Dec2015_v0'

    process.load('Configuration.StandardSequences.GeometryRecoDB_cff')
    process.load('Configuration.StandardSequences.MagneticField_38T_cff')

    runMVAMET(process, jetCollectionPF="patJetsReapplyJEC")

    from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import patJetCorrFactorsUpdated
    process.patJetCorrFactorsReapplyJEC = patJetCorrFactorsUpdated.clone(
        src=cms.InputTag("slimmedJets"),
        levels=['L1FastJet', 'L2Relative', 'L3Absolute'],
        payload='AK4PFchs'
    )  # Make sure to choose the appropriate levels and payload here!

    if not runOnMC:
        process.patJetCorrFactorsReapplyJEC.levels += ['L2L3Residual']

    from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import patJetsUpdated
    process.patJetsReapplyJEC = patJetsUpdated.clone(
        jetSource=cms.InputTag("slimmedJets"),
        jetCorrFactorsSource=cms.VInputTag(
            cms.InputTag("patJetCorrFactorsReapplyJEC")))

    process.maxEvents = cms.untracked.PSet(input=cms.untracked.int32(-1))

    numberOfFilesToProcess = -1
    numberOfFilesToProcess = 1
    debugEventContent = False

    # increase to 1000 before running on the batch, to reduce size of log files
    # on your account
    reportInterval = 100

    print sep_line
    print 'channel', channel
    print 'runSVFit', runSVFit

    # Input & JSON             -------------------------------------------------

    # dataset_user = '******'
    # dataset_name = '/VBF_HToTauTau_M-125_13TeV-powheg-pythia6/Spring14dr-PU20bx25_POSTLS170_V5-v1/AODSIM/SS14/'
    # dataset_files = 'miniAOD-prod_PAT_.*root'

    if runOnMC:
        from CMGTools.H2TauTau.proto.samples.fall15.higgs_susy import HiggsSUSYGG160 as ggh160
        process.source = cms.Source(
            "PoolSource",
            noEventSort=cms.untracked.bool(True),
            duplicateCheckMode=cms.untracked.string("noDuplicateCheck"),
            fileNames=cms.untracked.vstring(ggh160.files))
    else:
        # from CMGTools.RootTools.samples.samples_13TeV_DATA2015 import SingleMuon_Run2015D_Promptv4
        process.source = cms.Source(
            "PoolSource",
            noEventSort=cms.untracked.bool(True),
            duplicateCheckMode=cms.untracked.string("noDuplicateCheck"),
            fileNames=cms.untracked.vstring(
                'root://eoscms.cern.ch//eos/cms/store/data/Run2015D/SingleMuon/MINIAOD/16Dec2015-v1/10000/FEA1FD2B-B5A8-E511-85F7-0025907B5048.root'
            )  # mu-tau
            #             fileNames = cms.untracked.vstring('root://eoscms.cern.ch//eos/cms/store/data/Run2015D/Tau/MINIAOD/16Dec2015-v1/00000/F8B6DB5A-69B0-E511-96D4-20CF305B0590.root') # tau-tau
        )

    if runOnMC:
        process.genEvtWeightsCounter = cms.EDProducer(
            'GenEvtWeightCounter', verbose=cms.untracked.bool(False))

    if numberOfFilesToProcess > 0:
        process.source.fileNames = process.source.fileNames[:
                                                            numberOfFilesToProcess]

    print 'Run on MC?', runOnMC, process.source.fileNames[0]

    if not runOnMC:
        print 'Running on data, setting up JSON file'
        json = setupJSON(process)

    # Message logger setup.
    process.load("FWCore.MessageLogger.MessageLogger_cfi")
    process.MessageLogger.cerr.FwkReport.reportEvery = reportInterval
    process.options = cms.untracked.PSet(wantSummary=cms.untracked.bool(True))

    process.options = cms.untracked.PSet(
        allowUnscheduled=cms.untracked.bool(True))

    pickEvents = False

    if pickEvents:
        process.pickEvents = cms.EDFilter(
            "PickEvents",
            # the original format to input run/event -based selection is described in :
            # DPGAnalysis/Skims/data/listrunev
            # and kept as default, for historical reasons
            RunEventList=cms.untracked.string(
                "CMGTools/H2TauTau/data/eventList.txt"),

            # run/lumiSection @json -based input of selection can be toggled (but not used in THIS example)
            IsRunLsBased=cms.bool(False),

            # json is not used in this example -> list of LS left empty
            LuminositySectionsBlockRange=cms.untracked.VLuminosityBlockRange(
                ()))

    # process.load('JetMETCorrections.Configuration.DefaultJEC_cff')
    # process.load('JetMETCorrections.Configuration.JetCorrectors_cff')

    # # if '25ns' in process.source.fileNames[0] or 'mcRun2_asymptotic_v2' in process.source.fileNames[0]:
    # print 'Using 25 ns MVA MET training'
    # for mvaMETCfg in [process.mvaMETTauMu, process.mvaMETTauEle, process.mvaMETDiMu, process.mvaMETDiTau, process.mvaMETMuEle]:
    #     mvaMETCfg.inputFileNames = cms.PSet(
    #     U     = cms.FileInPath('RecoMET/METPUSubtraction/data/gbru_7_4_X_miniAOD_25NS_July2015.root'),
    #     DPhi  = cms.FileInPath('RecoMET/METPUSubtraction/data/gbrphi_7_4_X_miniAOD_25NS_July2015.root'),
    #     CovU1 = cms.FileInPath('RecoMET/METPUSubtraction/data/gbru1cov_7_4_X_miniAOD_25NS_July2015.root'),
    #     CovU2 = cms.FileInPath('RecoMET/METPUSubtraction/data/gbru2cov_7_4_X_miniAOD_25NS_July2015.root')
    # )

    # load the channel paths -------------------------------------------

    process.MVAMET.requireOS = cms.bool(False)

    if channel == 'tau-mu':
        process.load('CMGTools.H2TauTau.objects.tauMuObjectsMVAMET_cff')
        if pickEvents:
            process.tauMuPath.insert(0, process.pickEvents)
        process.mvaMETTauMu = process.MVAMET.clone()
        process.mvaMETTauMu.srcLeptons = cms.VInputTag(
            "tauPreSelectionTauMu", "muonPreSelectionTauMu")
        process.mvaMETTauMu.MVAMETLabel = cms.string('mvaMETTauMu')
        process.cmgTauMu.metCollection = cms.InputTag('mvaMETTauMu',
                                                      'mvaMETTauMu')
        if not runSVFit:
            process.cmgTauMuCorSVFitPreSel.SVFitVersion = 0
        if integrateOverP4:
            process.cmgTauMuCorSVFitPreSel.integrateOverP4 = integrateOverP4
        if p4TransferFunctionFile:
            process.cmgTauMuCorSVFitPreSel.p4TransferFunctionFile = p4TransferFunctionFile
        if scaleTau:
            process.cmgTauMuCor.nSigma = scaleTau

    elif channel == 'tau-ele':
        process.load('CMGTools.H2TauTau.objects.tauEleObjectsMVAMET_cff')
        process.mvaMETTauEle = process.MVAMET.clone()
        process.mvaMETTauEle.srcLeptons = cms.VInputTag(
            "tauPreSelectionTauEle", "electronPreSelectionTauEle")
        process.mvaMETTauEle.MVAMETLabel = cms.string('mvaMETTauEle')
        process.cmgTauEle.metCollection = cms.InputTag('mvaMETTauEle',
                                                       'mvaMETTauEle')
        if not runSVFit:
            process.cmgTauEleCorSVFitPreSel.SVFitVersion = 0
        if integrateOverP4:
            process.cmgTauEleCorSVFitPreSel.integrateOverP4 = integrateOverP4
        if p4TransferFunctionFile:
            process.cmgTauEleCorSVFitPreSel.p4TransferFunctionFile = p4TransferFunctionFile

    elif channel == 'mu-ele':
        process.load('CMGTools.H2TauTau.objects.muEleObjectsMVAMET_cff')
        process.mvaMETMuEle = process.MVAMET.clone()
        process.mvaMETMuEle.srcLeptons = cms.VInputTag(
            "muonPreSelectionMuEle", "electronPreSelectionMuEle")
        process.mvaMETMuEle.MVAMETLabel = cms.string('mvaMETMuEle')
        process.cmgMuEle.metCollection = cms.InputTag('mvaMETMuEle',
                                                      'mvaMETMuEle')
        if not runSVFit:
            process.cmgMuEleCorSVFitPreSel.SVFitVersion = 0
        else:
            process.cmgMuEleCorSVFitPreSel.SVFitVersion = 2

    # elif channel == 'mu-ele':
    #     process.MVAMET.srcLeptons = cms.VInputTag("electronPreSelectionMuEle", "muonPreSelectionMuEle")
    #     # process.muEleSequence.insert(4, process.MVAMET)
    elif channel == 'di-tau':
        process.load('CMGTools.H2TauTau.objects.diTauObjectsMVAMET_cff')
        process.mvaMETDiTau = process.MVAMET.clone()
        process.mvaMETDiTau.srcLeptons = cms.VInputTag("tauPreSelectionDiTau",
                                                       "tauPreSelectionDiTau")
        process.mvaMETDiTau.MVAMETLabel = cms.string('mvaMETDiTau')
        process.cmgDiTau.metCollection = cms.InputTag('mvaMETDiTau',
                                                      'mvaMETDiTau')
        if not runSVFit:
            process.cmgDiTauCorSVFitPreSel.SVFitVersion = 0
        if integrateOverP4:
            process.cmgDiTauCorSVFitPreSel.integrateOverP4 = integrateOverP4
        if p4TransferFunctionFile:
            process.cmgDiTauCorSVFitPreSel.p4TransferFunctionFile = p4TransferFunctionFile

    # elif channel == 'di-mu':
    #     process.MVAMET.srcLeptons = cms.VInputTag("muonPreSelectionDiMu", "muonPreSelectionDiMu")
    #     # process.diMuSequence.insert(2, process.MVAMET)

    # OUTPUT definition ----------------------------------------------------------
    process.outpath = cms.EndPath()

    if runOnMC:
        #        pass
        process.genEvtWeightsCounterPath = cms.Path(
            process.genEvtWeightsCounter)
#        process.schedule.insert(0, process.genEvtWeightsCounterPath)

# Enable printouts like this:
# process.cmgTauMuCorSVFitPreSel.verbose = True

    oneFile = (channel == 'all')

    if channel == 'tau-mu' or 'all' in channel:
        addTauMuOutput(process,
                       debugEventContent,
                       addPreSel=False,
                       oneFile=oneFile)
    if channel == 'tau-ele' or 'all' in channel:
        addTauEleOutput(process,
                        debugEventContent,
                        addPreSel=False,
                        oneFile=oneFile)
    if channel == 'mu-ele' or 'all' in channel:
        addMuEleOutput(process,
                       debugEventContent,
                       addPreSel=False,
                       oneFile=oneFile)
    if channel == 'di-mu' or 'all' in channel:
        addDiMuOutput(process,
                      debugEventContent,
                      addPreSel=False,
                      oneFile=oneFile)
    if channel == 'di-tau' or 'all' in channel:
        addDiTauOutput(process,
                       debugEventContent,
                       addPreSel=False,
                       oneFile=oneFile)

    if not runOnMC:
        if channel == 'tau-mu' or 'all' in channel:
            process.tauMuSequence.remove(process.cmgTauMuCor)
            process.cmgTauMuTauPtSel.src = 'cmgTauMu'
        if channel == 'tau-ele' or 'all' in channel:
            process.tauEleSequence.remove(process.cmgTauEleCor)
            process.cmgTauEleTauPtSel.src = 'cmgTauEle'
        if channel == 'di-tau' or 'all' in channel:
            process.diTauSequence.remove(process.cmgDiTauCor)
            process.cmgDiTauTauPtSel.src = 'cmgDiTau'

    # if runSVFit:
    #     process.cmgTauMuCorSVFitPreSel.SVFitVersion = 2
    # process.cmgTauEleCorSVFitPreSel.SVFitVersion = 2
    # process.cmgDiTauCorSVFitPreSel.SVFitVersion = 2
    # process.cmgMuEleCorSVFitPreSel.SVFitVersion = 2
    # process.cmgDiMuCorSVFitPreSel.SVFitVersion = 2

    # else:
    #     process.cmgTauMuCorSVFitPreSel.SVFitVersion = 0
    # process.cmgTauEleCorSVFitPreSel.SVFitVersion = 0
    # process.cmgDiTauCorSVFitPreSel.SVFitVersion = 0
    # process.cmgMuEleCorSVFitPreSel.SVFitVersion = 0
    # process.cmgDiMuCorSVFitPreSel.SVFitVersion = 0

    # if integrateOverP4:
    #     process.cmgTauMuCorSVFitPreSel.integrateOverP4 = integrateOverP4
    #     process.cmgTauEleCorSVFitPreSel.integrateOverP4 = integrateOverP4
    #     process.cmgDiTauCorSVFitPreSel.integrateOverP4 = integrateOverP4
    #     process.cmgMuEleCorSVFitPreSel.integrateOverP4 = integrateOverP4

    # if p4TransferFunctionFile:
    #     process.cmgTauMuCorSVFitPreSel.p4TransferFunctionFile = p4TransferFunctionFile
    #     process.cmgTauEleCorSVFitPreSel.p4TransferFunctionFile = p4TransferFunctionFile
    #     process.cmgDiTauCorSVFitPreSel.p4TransferFunctionFile = p4TransferFunctionFile
    #     process.cmgMuEleCorSVFitPreSel.p4TransferFunctionFile = p4TransferFunctionFile

    print sep_line
    print 'INPUT:'
    print sep_line
    print process.source.fileNames
    print
    if not runOnMC:
        print 'json:', json
    print
    print sep_line
    print 'PROCESSING'
    print sep_line
    print 'runOnMC:', runOnMC
    print

    # from FWCore.ParameterSet.Utilities import convertToUnscheduled
    # convertToUnscheduled(process)

    return process
Ejemplo n.º 17
0
    jets=cms.InputTag("slimmedJets"),
    inputIsCorrected=True,
    applyJec=True,
    vertexes=cms.InputTag("offlineSlimmedPrimaryVertices"))
#print process.pileupJetIdUpdated.dumpConfig()

# apply new jet energy corrections
from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import patJetCorrFactorsUpdated
jecLevels = None
if IsMC:
    jecLevels = ['L1FastJet', 'L2Relative', 'L3Absolute']
else:
    jecLevels = ['L1FastJet', 'L2Relative', 'L3Absolute', 'L2L3Residual']
process.patJetCorrFactorsReapplyJEC = patJetCorrFactorsUpdated.clone(
    src=cms.InputTag("slimmedJets"),
    levels=jecLevels,
    payload=
    'AK4PFchs'  # Make sure to choose the appropriate levels and payload here!
)
from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import patJetsUpdated
process.patJetsReapplyJEC = patJetsUpdated.clone(
    jetSource=cms.InputTag("slimmedJets"),
    jetCorrFactorsSource=cms.VInputTag(
        cms.InputTag("patJetCorrFactorsReapplyJEC")))
process.patJetsReapplyJEC.userData.userFloats.src += [
    'pileupJetIdUpdated:fullDiscriminant'
]

process.jets = cms.EDFilter("PATJetRefSelector",
                            src=cms.InputTag("patJetsReapplyJEC"),
                            cut=cms.string(JETCUT))
##
Ejemplo n.º 18
0
        'HLT_DoubleJetsC112_DoubleBTagCSV0p9_DoublePFJetsC112MaxDeta1p6_v*',
    ),
    hltResults=cms.InputTag("TriggerResults", "", "HLT"),
    l1tResults=cms.InputTag(""),
    l1tIgnoreMask=cms.bool(False),
    l1techIgnorePrescales=cms.bool(False),
    daqPartitions=cms.uint32(1),
    throw=cms.bool(True))

## ============ RE-APPLY JET ENERGY CORRECTIONS ===============   BE CAREFUL!!!
## Enable below at cms.Path if needed
from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import patJetCorrFactorsUpdated

process.slimmedJetsCorrFactorsReapplyJEC = patJetCorrFactorsUpdated.clone(
    src=cms.InputTag("slimmedJets"),
    levels=['L1FastJet', 'L2Relative', 'L3Absolute'],
    payload='AK4PFchs'
)  # Make sure to choose the appropriate levels and payload here!

process.slimmedJetsPuppiCorrFactorsReapplyJEC = patJetCorrFactorsUpdated.clone(
    src=cms.InputTag("slimmedJetsPuppi"),
    levels=['L1FastJet', 'L2Relative', 'L3Absolute'],
    payload='AK4PFPuppi'
)  # Make sure to choose the appropriate levels and payload here!

process.slimmedJetsAK8PFCorrFactorsReapplyJEC = patJetCorrFactorsUpdated.clone(
    src=cms.InputTag("slimmedJetsAK8PFCHSSoftDropPacked", "SubJets", "RECO"),
    levels=['L1FastJet', 'L2Relative', 'L3Absolute'],
    payload='AK8PFchs'
)  # Make sure to choose the appropriate levels and payload here!
Ejemplo n.º 19
0
                                       tag    = cms.string("JetCorrectorParametersCollection_"+jecLabel+"_AK4PFchs"),
                                       label  = cms.untracked.string("AK4PFchs")
                                   ),
                        cms.PSet(
                            record = cms.string("JetCorrectionsRecord"),
                            tag    = cms.string("JetCorrectorParametersCollection_"+jecLabel+"_AK4PF"),
                            label  = cms.untracked.string("AK4PF")
                        )
                )
    )
    process.es_prefer_jec = cms.ESPrefer("PoolDBESSource","jec")
    ###### Jets 
    ## From https://twiki.cern.ch/twiki/bin/view/CMSPublic/WorkBookJetEnergyCorrections#CorrPatJets
    from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import patJetCorrFactorsUpdated
    process.patJetCorrFactorsReapplyJEC = patJetCorrFactorsUpdated.clone(
        src = cms.InputTag("slimmedJets"),
        levels = jecLevels,
        payload = 'AK4PFchs' ) # Make sure to choose the appropriate levels and payload here!

    from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import patJetsUpdated
    process.patJetsReapplyJEC = patJetsUpdated.clone(
        jetSource = cms.InputTag("slimmedJets"),
        jetCorrFactorsSource = cms.VInputTag(cms.InputTag("patJetCorrFactorsReapplyJEC"))
    )

    ###### Apply new JECs to MET
    ## From https://github.com/cms-met/cmssw/blob/METCorUnc74X/PhysicsTools/PatAlgos/test/corMETFromMiniAOD.py
    process.options = cms.untracked.PSet(
        allowUnscheduled = cms.untracked.bool(True),
        wantSummary = cms.untracked.bool(False)
    )
    from PhysicsTools.PatUtils.tools.runMETCorrectionsAndUncertainties import runMetCorAndUncFromMiniAOD
Ejemplo n.º 20
0
    hltResults = cms.InputTag( "TriggerResults", "", "HLT" ),
    l1tResults = cms.InputTag( "" ),
    l1tIgnoreMask = cms.bool( False ),
    l1techIgnorePrescales = cms.bool( False ),
    daqPartitions = cms.uint32( 1 ),
    throw = cms.bool( True )
)



## ============ RE-APPLY JET ENERGY CORRECTIONS ===============   BE CAREFUL!!!
## Enable below at cms.Path if needed 
from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import patJetCorrFactorsUpdated
process.slimmedJetsCorrFactorsReapplyJEC = patJetCorrFactorsUpdated.clone(
  src = cms.InputTag("slimmedJets"),
  levels = ['L1FastJet', 
            'L2Relative', 
            'L3Absolute'],
  payload = 'AK4PFchs' ) # Make sure to choose the appropriate levels and payload here!


process.slimmedJetsPuppiCorrFactorsReapplyJEC = patJetCorrFactorsUpdated.clone(
  src = cms.InputTag("slimmedJetsPuppi"),
  levels = ['L1FastJet', 
            'L2Relative', 
            'L3Absolute'],
  payload = 'AK4PFPuppi' ) # Make sure to choose the appropriate levels and payload here!
  
process.slimmedJetsAK8PFCorrFactorsReapplyJEC = patJetCorrFactorsUpdated.clone(
  src = cms.InputTag("slimmedJetsAK8PFCHSSoftDropPacked","SubJets","RECO"),
  levels = ['L1FastJet', 
            'L2Relative', 
process.out = cms.OutputModule("PoolOutputModule",
        outputCommands = cms.untracked.vstring('keep *'),
        fileName = cms.untracked.string("output.root")
        )

# Jets

### First, apply new JEC over slimmedJets

from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import patJetCorrFactorsUpdated
from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import patJetsUpdated

process.patJetCorrFactorsReapplyJEC = patJetCorrFactorsUpdated.clone(
        src = cms.InputTag("slimmedJets"),
        levels = ['L1FastJet', 'L2Relative', 'L3Absolute'],
        payload = 'AK4PFchs'
        )

process.slimmedJetsNewJEC = patJetsUpdated.clone(
        jetSource = cms.InputTag("slimmedJets"),
        jetCorrFactorsSource = cms.VInputTag(cms.InputTag("patJetCorrFactorsReapplyJEC"))
        )


#### Second, smear newly corrected jets

process.slimmedJetsSmeared = cms.EDProducer('SmearedPATJetProducer',
        src = cms.InputTag('slimmedJetsNewJEC'),
        enabled = cms.bool(True),
        rho = cms.InputTag("fixedGridRhoAll"),
                label= cms.untracked.string("AK4PFchs")
                ),
            )
                               )
    process.es_prefer_jec = cms.ESPrefer("PoolDBESSource",'jec')

### =====================================================================================================


### ReRun JEC ===========================================================================================

from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import patJetCorrFactorsUpdated
process.patJetCorrFactorsReapplyJEC = patJetCorrFactorsUpdated.clone(
  src = cms.InputTag("slimmedJets"),
  levels = ['L1FastJet', 
            'L2Relative', 
            'L3Absolute',
            'L2L3Residual'],
  payload = 'AK4PFchs' ) # Make sure to choose the appropriate levels and payload here!

from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import patJetsUpdated
process.patJetsReapplyJEC = patJetsUpdated.clone(
  jetSource = cms.InputTag("slimmedJets"),
  jetCorrFactorsSource = cms.VInputTag(cms.InputTag("patJetCorrFactorsReapplyJEC"))
)


### END ReRun JEC ======================================================================================

### PFMET Corrections ==================================================================================
Ejemplo n.º 23
0
            "slimmedMETs", "", miniAODProcess)

    if not applyL2L3Residuals:
        process.patPFMetT1T2Corr.jetCorrLabelRes = cms.InputTag("L3Absolute")
        process.patPFMetT1T2SmearCorr.jetCorrLabelRes = cms.InputTag(
            "L3Absolute")
        process.patPFMetT2Corr.jetCorrLabelRes = cms.InputTag("L3Absolute")
        process.patPFMetT2SmearCorr.jetCorrLabelRes = cms.InputTag(
            "L3Absolute")
        process.shiftedPatJetEnDown.jetCorrLabelUpToL3Res = cms.InputTag(
            "ak4PFCHSL1FastL2L3Corrector")
        process.shiftedPatJetEnUp.jetCorrLabelUpToL3Res = cms.InputTag(
            "ak4PFCHSL1FastL2L3Corrector")

    from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import patJetCorrFactorsUpdated
    process.patJetCorrFactorsReapplyJEC = patJetCorrFactorsUpdated.clone(
        src=cms.InputTag("slimmedJets"), levels=JECLevels, payload='AK4PFchs')

    from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import patJetsUpdated
    process.slimmedJetsRecorrected = patJetsUpdated.clone(
        jetSource=cms.InputTag("slimmedJets"),
        jetCorrFactorsSource=cms.VInputTag(
            cms.InputTag("patJetCorrFactorsReapplyJEC")))
    jetCollName = "slimmedJetsRecorrected"

# Create a set of objects to read from
process.selectedObjects = cms.EDProducer(
    "PFCleaner",
    vertices=cms.InputTag("goodVertices"),
    pfcands=cms.InputTag("packedPFCandidates"),
    muons=cms.InputTag("slimmedMuons"),
    electrons=cms.InputTag("slimmedElectrons"),
def makeTreeFromMiniAOD(process,
                        outfile,
                        reportfreq=10,
                        dataset="",
                        globaltag="",
                        geninfo=False,
                        tagname="RECO",
                        jsonfile="",
                        jecfile="",
                        doPDFs=False,
                        residual=False,
                        numevents=-1,
                        fastsim=False):

    #process = cms.Process("RA2EventSelection")
    ## ----------------------------------------------------------------------------------------------
    ## ----------------------------------------------------------------------------------------------
    ## Preamble
    ## ----------------------------------------------------------------------------------------------
    ## ----------------------------------------------------------------------------------------------
    process.load(
        "Configuration.StandardSequences.FrontierConditions_GlobalTag_condDBv2_cff"
    )
    process.GlobalTag.globaltag = globaltag

    print "function starts running ...."
    # log output
    # log output
    process.load("FWCore.MessageService.MessageLogger_cfi")
    process.MessageLogger.cerr.FwkReport.reportEvery = reportfreq
    process.options = cms.untracked.PSet(
        allowUnscheduled=cms.untracked.bool(True),
        wantSummary=cms.untracked.bool(True))

    # files to process
    import FWCore.PythonUtilities.LumiList as LumiList
    process.maxEvents = cms.untracked.PSet(
        input=cms.untracked.int32(numevents))
    print " printing reportfreq and numevents ........."
    print reportfreq
    print numevents

    # files to process
    process.source = cms.Source("PoolSource",
                                fileNames=cms.untracked.vstring(dataset))
    print len(jsonfile)
    if len(jsonfile) > 0:
        process.source.lumisToProcess = LumiList.LumiList(
            filename=jsonfile).getVLuminosityBlockRange()
    # output file

    process.TFileService = cms.Service("TFileService",
                                       fileName=cms.string(outfile + ".root"))
    # branches for treemaker
    VectorRecoCand = cms.vstring()
    VarsDouble = cms.vstring()
    VarsInt = cms.vstring()
    VarsBool = cms.vstring()
    VectorTLorentzVector = cms.vstring()
    VectorDouble = cms.vstring()
    VectorString = cms.vstring()
    VectorInt = cms.vstring()
    VectorBool = cms.vstring()

    # sequence for baseline producers
    process.Baseline = cms.Sequence()

    # configure treemaker

    from LeptoQuarkTreeMaker.LeptoQuarkTreeMaker.treeMaker import TreeMaker
    process.LQTreeMaker = TreeMaker.clone(
        TreeName=cms.string("SimpleTree"),
        VectorRecoCand=VectorRecoCand,
        VarsDouble=VarsDouble,
        VarsInt=VarsInt,
        VarsBool=VarsBool,
        VectorTLorentzVector=VectorTLorentzVector,
        VectorDouble=VectorDouble,
        VectorInt=VectorInt,
        VectorString=VectorString,
        VectorBool=VectorBool,
    )
    # get the JECs (disabled by default)
    # this requires the user to download the .db file from this twiki
    # https://twiki.cern.ch/twiki/bin/viewauth/CMS/JECDataMC
    if geninfo:
        from LeptoQuarkTreeMaker.WeightProducer.getWeightProducer_cff import getWeightProducer
        process.WeightProducer = getWeightProducer(process.source.fileNames[0])
        process.WeightProducer.Lumi = cms.double(
            1)  #default: 1 pb-1 (unit value)
        process.WeightProducer.FileNamePUDataDistribution = cms.string(
            "LeptoQuarkTreeMaker/Production/test/data/PileupHistograms_1117.root"
        )
        process.Baseline += process.WeightProducer
        VarsDouble.extend([
            'WeightProducer:weight(Weight)',
            'WeightProducer:xsec(CrossSection)',
            'WeightProducer:nevents(NumEvents)',
            'WeightProducer:TrueNumInteractions',
            'WeightProducer:PUweight(puWeight)',
            'WeightProducer:PUSysUp(puSysUp)',
            'WeightProducer:PUSysDown(puSysDown)'
        ])
        VarsInt.extend(['WeightProducer:NumInteractions'])
        '''
       from LeptoQuarkTreeMaker.Utils.JetEnergyResolution_cfi import JetEnergyResolution
       process.JetEnergyResolution = JetEnergyResolution.clone(
       jettag = cms.InputTag('slimmedJets')
       #  eletag = cms.InputTag('calibratedPatElectrons')
        # rhotag = cms.InputTag('fixedGridRhoFastjetAll')
       )

       process.Baseline += process.JetEnergyResolution
       VectorDouble.extend(['JetEnergyResolution:JERPtCorr(JERPtCorr)'])
              
       VectorDouble.extend(['JetEnergyResolution:JEREnergyCorr(JEREnergyCorr)'])
       VectorDouble.extend(['JetEnergyResolution:JERPtCorrSysUP(JERPtCorrSysUP)'])
       VectorDouble.extend(['JetEnergyResolution:JEREnergyCorrSysUP(JEREnergyCorrSysUP)'])
       VectorDouble.extend(['JetEnergyResolution:JERPtCorrSysDown(JERPtCorrSysDown)'])
       VectorDouble.extend(['JetEnergyResolution:JEREnergyCorrSysDown(JEREnergyCorrSysDown)'])
      
       '''

    ## ----------------------------------------------------------------------------------------------
    ## PDF weights for PDF systematics
    ## ----------------------------------------------------------------------------------------------
    if doPDFs:
        process.PDFWeights = cms.EDProducer('PDFWeightProducer')
        process.Baseline += process.PDFWeights
        VectorDouble.extend(
            ['PDFWeights:PDFweights', 'PDFWeights:ScaleWeights'])
        VectorInt.extend(['PDFWeights:PDFids'])

    process.goodVertices = cms.EDFilter(
        "VertexSelector",
        src=cms.InputTag("offlineSlimmedPrimaryVertices"),
        cut=cms.string(
            "!isFake && ndof > 4 && abs(z) < 24 && position.Rho < 2"),
        filter=cms.bool(False))
    from LeptoQuarkTreeMaker.Utils.primaryvertices_cfi import primaryvertices
    process.NVtx = primaryvertices.clone(
        VertexCollection=cms.InputTag('goodVertices'), )
    process.Baseline += process.NVtx
    VarsInt.extend(['NVtx'])
    # also store total number of vertices without quality checks
    process.nAllVertices = primaryvertices.clone(
        VertexCollection=cms.InputTag('offlineSlimmedPrimaryVertices'), )
    process.Baseline += process.nAllVertices
    VarsInt.extend(['nAllVertices'])

    JetTag = cms.InputTag('slimmedJets')
    METTag = cms.InputTag('slimmedMETs')

    if len(jecfile) > 0:
        #get name of JECs without any directories
        JECera = jecfile.split('/')[-1]
        JECPatch = cms.string('sqlite_file:' + jecfile + '.db')
        if os.getenv('GC_CONF'):
            JECPatch = cms.string('sqlite_file:../src/' + jecfile + '.db')

        process.load("CondCore.DBCommon.CondDBCommon_cfi")
        from CondCore.DBCommon.CondDBSetup_cfi import CondDBSetup
        process.jec = cms.ESSource(
            "PoolDBESSource",
            CondDBSetup,
            connect=JECPatch,
            toGet=cms.VPSet(
                cms.PSet(record=cms.string("JetCorrectionsRecord"),
                         tag=cms.string("JetCorrectorParametersCollection_" +
                                        JECera + "_AK4PFchs"),
                         label=cms.untracked.string("AK4PFchs")),
                cms.PSet(record=cms.string("JetCorrectionsRecord"),
                         tag=cms.string("JetCorrectorParametersCollection_" +
                                        JECera + "_AK4PF"),
                         label=cms.untracked.string("AK4PF"))))
        process.es_prefer_jec = cms.ESPrefer("PoolDBESSource", "jec")

        from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import patJetCorrFactorsUpdated
        process.patJetCorrFactorsReapplyJEC = patJetCorrFactorsUpdated.clone(
            src=cms.InputTag("slimmedJets"),
            levels=['L1FastJet', 'L2Relative', 'L3Absolute'],
            payload=
            'AK4PFchs'  # Make sure to choose the appropriate levels and payload here!
        )
        if residual:
            process.patJetCorrFactorsReapplyJEC.levels.append('L2L3Residual')

        from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import patJetsUpdated
        process.patJetsReapplyJEC = patJetsUpdated.clone(
            jetSource=cms.InputTag("slimmedJets"),
            jetCorrFactorsSource=cms.VInputTag(
                cms.InputTag("patJetCorrFactorsReapplyJEC")))

        process.Baseline += process.patJetCorrFactorsReapplyJEC
        process.Baseline += process.patJetsReapplyJEC

        JetTag = cms.InputTag('patJetsReapplyJEC')

        from PhysicsTools.PatUtils.tools.runMETCorrectionsAndUncertainties import runMetCorAndUncFromMiniAOD
        runMetCorAndUncFromMiniAOD(
            process,
            isData=not geninfo,  # controls gen met
            jetCollUnskimmed=JetTag.value(),
            jetColl=JetTag.value(),
            postfix="Update")
        if not residual:  #skip residuals for data if not used
            process.patPFMetT1T2CorrUpdate.jetCorrLabelRes = cms.InputTag(
                "L3Absolute")
            process.patPFMetT1T2SmearCorrUpdate.jetCorrLabelRes = cms.InputTag(
                "L3Absolute")
            process.patPFMetT2CorrUpdate.jetCorrLabelRes = cms.InputTag(
                "L3Absolute")
            process.patPFMetT2SmearCorrUpdate.jetCorrLabelRes = cms.InputTag(
                "L3Absolute")
            process.shiftedPatJetEnDownUpdate.jetCorrLabelUpToL3Res = cms.InputTag(
                "ak4PFCHSL1FastL2L3Corrector")
            process.shiftedPatJetEnUpUpdate.jetCorrLabelUpToL3Res = cms.InputTag(
                "ak4PFCHSL1FastL2L3Corrector")
        if hasattr(process, "slimmedMETsUpdate"):
            delattr(getattr(process, "slimmedMETsUpdate"), "caloMET")
        METTag = cms.InputTag('slimmedMETsUpdate', '', process.name_())

    process.goodPhotons = cms.EDProducer(
        "PhotonIDisoProducer",
        photonCollection=cms.untracked.InputTag("slimmedPhotons"),
        electronCollection=cms.untracked.InputTag("slimmedElectrons"),
        conversionCollection=cms.untracked.InputTag("reducedEgamma",
                                                    "reducedConversions",
                                                    tagname),
        beamspotCollection=cms.untracked.InputTag("offlineBeamSpot"),
        ecalRecHitsInputTag_EE=cms.InputTag("reducedEgamma",
                                            "reducedEERecHits"),
        ecalRecHitsInputTag_EB=cms.InputTag("reducedEgamma",
                                            "reducedEBRecHits"),
        rhoCollection=cms.untracked.InputTag("fixedGridRhoFastjetAll"),
        genParCollection=cms.untracked.InputTag("prunedGenParticles"),
        debug=cms.untracked.bool(False))
    process.Baseline += process.goodPhotons
    # good photon tag is InputTag('goodPhotons','bestPhoton')
    VectorRecoCand.append("goodPhotons:bestPhoton")
    #VectorRecoCand.append("goodPhotons:bestPhotonLoose")
    VectorRecoCand.append("goodPhotons:SimplePhoton")

    VarsInt.append("goodPhotons:NumPhotons")

    if not fastsim:  # MET filters are not run for fastsim samples

        from LeptoQuarkTreeMaker.Utils.filterdecisionproducer_cfi import filterDecisionProducer
        process.METFilters = filterDecisionProducer.clone(
            trigTagArg1=cms.string('TriggerResults'),
            trigTagArg2=cms.string(''),
            trigTagArg3=cms.string(tagname),
            filterName=cms.string("Flag_METFilters"),
        )
        process.Baseline += process.METFilters
        VarsInt.extend(['METFilters'])

        #process.CSCTightHaloFilter = filterDecisionProducer.clone(
        #    trigTagArg1 = cms.string('TriggerResults'),
        #    trigTagArg2 = cms.string(''),
        #    trigTagArg3 = cms.string(tagname),
        #    filterName  = cms.string("Flag_CSCTightHaloFilter"),
        #)
        #process.Baseline += process.CSCTightHaloFilter
        #VarsInt.extend(['CSCTightHaloFilter'])

        #run beam halo filter from text list of events
        from LeptoQuarkTreeMaker.Utils.getEventListFilter_cff import getEventListFilter
        process.CSCTightHaloFilter = getEventListFilter(
            process.source.fileNames[0], "Dec01", "csc2015")
        process.Baseline += process.CSCTightHaloFilter
        VarsBool.extend(['CSCTightHaloFilter'])

        #process.HBHENoiseFilter = filterDecisionProducer.clone(
        #    trigTagArg1 = cms.string('TriggerResults'),
        #    trigTagArg2 = cms.string(''),
        #    trigTagArg3 = cms.string(tagname),
        #    filterName  = cms.string("Flag_HBHENoiseFilter"),
        #)
        #process.Baseline += process.HBHENoiseFilter
        #VarsInt.extend(['HBHENoiseFilter'])

        #rerun HBHE noise filter manually
        process.load('CommonTools.RecoAlgos.HBHENoiseFilterResultProducer_cfi')
        process.HBHENoiseFilterResultProducer.minZeros = cms.int32(99999)
        process.HBHENoiseFilterResultProducer.IgnoreTS4TS5ifJetInLowBVRegion = cms.bool(
            False)
        process.HBHENoiseFilterResultProducer.defaultDecision = cms.string(
            "HBHENoiseFilterResultRun2Loose")
        process.Baseline += process.HBHENoiseFilterResultProducer
        VarsBool.extend([
            'HBHENoiseFilterResultProducer:HBHENoiseFilterResult(HBHENoiseFilter)'
        ])
        #add HBHE iso noise filter
        VarsBool.extend([
            'HBHENoiseFilterResultProducer:HBHEIsoNoiseFilterResult(HBHEIsoNoiseFilter)'
        ])

        process.EcalDeadCellTriggerPrimitiveFilter = filterDecisionProducer.clone(
            trigTagArg1=cms.string('TriggerResults'),
            trigTagArg2=cms.string(''),
            trigTagArg3=cms.string(tagname),
            filterName=cms.string("Flag_EcalDeadCellTriggerPrimitiveFilter"),
        )
        process.Baseline += process.EcalDeadCellTriggerPrimitiveFilter
        VarsInt.extend(['EcalDeadCellTriggerPrimitiveFilter'])

        process.eeBadScFilter = filterDecisionProducer.clone(
            trigTagArg1=cms.string('TriggerResults'),
            trigTagArg2=cms.string(''),
            trigTagArg3=cms.string(tagname),
            filterName=cms.string("Flag_eeBadScFilter"),
        )
        process.Baseline += process.eeBadScFilter
        VarsInt.extend(['eeBadScFilter'])

        #run eeBadSc4 filter from text list of events
        process.eeBadSc4Filter = getEventListFilter(
            process.source.fileNames[0], "Dec01", "ecalscn1043093")
        process.Baseline += process.eeBadSc4Filter
        VarsBool.extend(['eeBadSc4Filter'])

    from LeptoQuarkTreeMaker.Utils.MuonProducer_cfi import MuonProducer
    process.MuonProducer = MuonProducer.clone(
        muontag=cms.InputTag('slimmedMuons')
        # rhotag = cms.InputTag('fixedGridRhoFastjetAll')
    )
    process.Baseline += process.MuonProducer
    VectorDouble.extend(['MuonProducer:Eta(Muon_Eta)'])
    VectorInt.extend(['MuonProducer:mCharge(Muon_Charge)'])
    VectorDouble.extend(['MuonProducer:mPt(Muon_Pt)'])
    VectorDouble.extend(['MuonProducer:mPhi(Muon_Phi)'])
    VectorDouble.extend(['MuonProducer:tEta(Tau_Eta)'])
    VectorDouble.extend(['MuonProducer:tPt(Tau_Pt)'])
    VectorDouble.extend(['MuonProducer:tPhi(Tau_Phi)'])

    process.RandomNumberGeneratorService = cms.Service(
        "RandomNumberGeneratorService",
        calibratedPatElectrons=cms.PSet(
            initialSeed=cms.untracked.uint32(1),
            engineName=cms.untracked.string('TRandom3')),
        calibratedElectrons=cms.PSet(
            initialSeed=cms.untracked.uint32(1),
            engineName=cms.untracked.string('TRandom3')),
    )

    process.load('EgammaAnalysis.ElectronTools.calibratedElectronsRun2_cfi')

    process.calibratedPatElectrons.electrons = cms.InputTag('slimmedElectrons')
    process.calibratedPatElectrons.gbrForestName = cms.string(
        "gedelectron_p4combination_25ns")
    process.calibratedPatElectrons.isMC = cms.bool(True)
    process.calibratedPatElectrons.isSynchronization = cms.bool(False)
    process.calibratedPatElectrons.correctionFile = cms.string("Prompt2015")
    process.Baseline += process.calibratedPatElectrons

    from LeptoQuarkTreeMaker.Utils.HEEPProducer_cfi import HEEPProducer
    process.HEEPProducer = HEEPProducer.clone(
        #  eletag = cms.InputTag('slimmedElectrons')
        eletag=cms.InputTag('calibratedPatElectrons')

        # rhotag = cms.InputTag('fixedGridRhoFastjetAll')
    )
    process.Baseline += process.HEEPProducer
    VectorDouble.extend(['HEEPProducer:trackiso(Electron_trackiso)'])
    VectorDouble.extend(['HEEPProducer:Eta(Electron_Eta)'])
    VectorDouble.extend(['HEEPProducer:Et(Electron_Et)'])
    VectorDouble.extend(['HEEPProducer:DeltaEtain(Electron_DeltaEtain)'])
    VectorDouble.extend(['HEEPProducer:DeltaPhiin(Electron_DeltaPhiin)'])
    VectorDouble.extend(['HEEPProducer:HbE(Electron_HOverE)'])
    VectorDouble.extend(['HEEPProducer:SiEtaiEta(Electron_SiEtaiEta)'])
    VectorDouble.extend(['HEEPProducer:Ecaliso(Electron_Ecaliso)'])
    VectorDouble.extend(['HEEPProducer:HD1iso(Electron_HD1iso)'])
    VectorDouble.extend(['HEEPProducer:HD2iso(Electron_HD2iso)'])
    VectorBool.extend(['HEEPProducer:ecalDriven(Electron_ecalDriven)'])
    VectorDouble.extend(['HEEPProducer:e25max(Electron_e25max)'])
    VectorDouble.extend(['HEEPProducer:e55(Electron_e55)'])
    VectorDouble.extend(['HEEPProducer:e25bye55(Electron_e25bye55)'])
    VectorDouble.extend(['HEEPProducer:DeltaEtaSeed(Electron_DeltaEtaSeed)'])
    VectorDouble.extend(['HEEPProducer:rho(rho)'])
    VectorInt.extend(['HEEPProducer:Charge(Electron_Charge)'])
    VectorDouble.extend(['HEEPProducer:ePt(Electron_Pt)'])
    VectorDouble.extend(['HEEPProducer:e15(Electron_e15)'])
    VectorDouble.extend(['HEEPProducer:ecalEnergy(Electron_ecalEnergy)'])
    VectorDouble.extend(
        ['HEEPProducer:full55SiEtaiEta(Electron_full55SiEtaiEta)'])
    VectorDouble.extend(['HEEPProducer:sce25max(Electron_sce25max)'])
    VectorDouble.extend(['HEEPProducer:sce55(Electron_sce55)'])
    VectorDouble.extend(['HEEPProducer:sce25bye55(Electron_sce25bye55)'])
    VectorDouble.extend(['HEEPProducer:e15bye55(Electron_e15bye55)'])
    VectorDouble.extend([
        'HEEPProducer:DeltaEtaSeedscandTrack(Electron_DeltaEtaSeedscandTrack)'
    ])
    VectorDouble.extend(['HEEPProducer:Phi(Electron_Phi)'])
    VectorDouble.extend(['HEEPProducer:eEnergy(Electron_Energy)'])
    VectorDouble.extend(['HEEPProducer:dxy(dxy)'])
    VectorInt.extend(['HEEPProducer:losthits(Electron_losthits)'])
    VectorDouble.extend(['HEEPProducer:ePz(Electron_Pz)'])
    VectorDouble.extend(['HEEPProducer:eTheta(Electron_Theta)'])
    VectorDouble.extend(['HEEPProducer:ePx(Electron_Px)'])
    VectorDouble.extend(['HEEPProducer:ePy(Electron_Py)'])
    VectorDouble.extend(
        ['HEEPProducer:normalizedChi2(Electron_normalizedChi2)'])
    VectorInt.extend(['HEEPProducer:PDGID(PDGID)'])
    VectorInt.extend(['HEEPProducer:gencharge(gencharge)'])
    VectorDouble.extend(['HEEPProducer:genPt(genPt)'])
    VectorDouble.extend(['HEEPProducer:genEta(genEta)'])
    VectorDouble.extend(['HEEPProducer:genPhi(genPhi)'])
    VectorDouble.extend(['HEEPProducer:genEnergy(genEnergy)'])
    VectorInt.extend(['HEEPProducer:motherPDGID(motherPDGID)'])
    VectorInt.extend(['HEEPProducer:elstatus(elstatus)'])
    VectorDouble.extend(['HEEPProducer:PtHEEP(Electron_PtHEEP)'])
    VectorDouble.extend(['HEEPProducer:scEtaa(Electron_scEtaa)'])
    VectorDouble.extend(['HEEPProducer:scEta(Electron_scEta)'])

    from LeptoQuarkTreeMaker.Utils.triggerproducer_cfi import triggerProducer
    process.TriggerProducer = triggerProducer.clone(
        trigTagArg1=cms.string('TriggerResults'),
        trigTagArg2=cms.string(''),
        trigTagArg3=cms.string('HLT'),
        prescaleTagArg1=cms.string('patTrigger'),
        prescaleTagArg2=cms.string(''),
        prescaleTagArg3=cms.string(''),
        triggerNameList=cms.vstring(  # list of trigger names
            'HLT_Photon135_PFMET100_JetIdCleaned_v',
            'HLT_Photon22_R9Id90_HE10_Iso40_EBOnly_PFMET40_v',
            'HLT_Photon22_R9Id90_HE10_Iso40_EBOnly_VBF_v',
            'HLT_Photon250_NoHE_v',
            'HLT_Photon300_NoHE_v',
            'HLT_Photon26_R9Id85_OR_CaloId24b40e_Iso50T80L_Photon16_AND_HE10_R9Id65_Eta2_Mass60_v',
            'HLT_Photon36_R9Id85_OR_CaloId24b40e_Iso50T80L_Photon22_AND_HE10_R9Id65_Eta2_Mass15_v',
            'HLT_Photon36_R9Id90_HE10_Iso40_EBOnly_PFMET40_v',
            'HLT_Photon36_R9Id90_HE10_Iso40_EBOnly_VBF_v',
            'HLT_Photon50_R9Id90_HE10_Iso40_EBOnly_PFMET40_v',
            'HLT_Photon50_R9Id90_HE10_Iso40_EBOnly_VBF_v',
            'HLT_Photon75_R9Id90_HE10_Iso40_EBOnly_PFMET40_v',
            'HLT_Photon75_R9Id90_HE10_Iso40_EBOnly_VBF_v',
            'HLT_Photon90_R9Id90_HE10_Iso40_EBOnly_PFMET40_v',
            'HLT_Photon90_R9Id90_HE10_Iso40_EBOnly_VBF_v',
            'HLT_Photon120_R9Id90_HE10_Iso40_EBOnly_PFMET40_v',
            'HLT_Photon120_R9Id90_HE10_Iso40_EBOnly_VBF_v',
            'HLT_Photon90_CaloIdL_PFHT500_v',
            'HLT_Photon90_CaloIdL_PFHT600_v',
            'HLT_Photon500_v',
            'HLT_Photon600_v',
            'HLT_Photon22_v',
            'HLT_Photon30_v',
            'HLT_Photon36_v',
            'HLT_Photon50_v',
            'HLT_Photon75_v',
            'HLT_Photon90_v',
            'HLT_Photon120_v',
            'HLT_Photon175_v',
            'HLT_Photon165_HE10_v',
            'HLT_Ele22_eta2p1_WPLoose_Gsf_v',
            'HLT_Ele22_eta2p1_WPTight_Gsf_v',
            'HLT_Ele30WP60_SC4_Mass55_v',
            'HLT_Ele30WP60_Ele8_Mass55_v',
            'HLT_Ele23_WPLoose_Gsf_v',
            'HLT_Ele27_WPLoose_Gsf_v',
            'HLT_Ele27_eta2p1_WPLoose_Gsf_v',
            'HLT_Ele27_eta2p1_WPTight_Gsf_v',
            'HLT_Ele32_eta2p1_WPTight_Gsf_v',
            'HLT_Ele35_CaloIdVT_GsfTrkIdT_PFJet150_PFJet50_v',
            'HLT_Ele45_CaloIdVT_GsfTrkIdT_PFJet200_PFJet50_v',
            'HLT_Ele105_CaloIdVT_GsfTrkIdT_v',
            'HLT_Ele12_CaloIdL_TrackIdL_IsoVL_PFJet30_v',
            'HLT_Ele23_CaloIdL_TrackIdL_IsoVL_PFJet30_v',
            'HLT_Ele33_CaloIdL_TrackIdL_IsoVL_PFJet30_v',
            'HLT_Ele23_Ele12_CaloIdL_TrackIdL_IsoVL_DZ_v',
            'HLT_Ele17_Ele12_CaloIdL_TrackIdL_IsoVL_DZ_v',
            'HLT_Ele23_Ele12_CaloIdL_TrackIdL_IsoVL_v',
            'HLT_Ele17_Ele12_CaloIdL_TrackIdL_IsoVL_v',
            'HLT_Ele23_CaloIdL_TrackIdL_IsoVL_v',
            'HLT_Ele17_CaloIdL_TrackIdL_IsoVL_v',
            'HLT_Ele12_CaloIdL_TrackIdL_IsoVL_v',
            'HLT_Ele27_eta2p1_WPLoose_Gsf_HT200_v',
            'HLT_Ele15_IsoVVVL_PFHT350_PFMET50_v',
            'HLT_Ele15_IsoVVVL_PFHT600_v',
            'HLT_Ele15_IsoVVVL_PFHT350_v',
            'HLT_Ele8_CaloIdM_TrackIdM_PFJet30_v',
            'HLT_Ele12_CaloIdM_TrackIdM_PFJet30_v',
            'HLT_Ele23_CaloIdM_TrackIdM_PFJet30_v',
            'HLT_Ele33_CaloIdM_TrackIdM_PFJet30_v',
            'HLT_Ele115_CaloIdVT_GsfTrkIdT_v',
            'HLT_DoubleEle33_CaloIdL_GsfTrkIdVL_v',
        ))
    process.Baseline += process.TriggerProducer
    VectorInt.extend(
        ['TriggerProducer:TriggerPass', 'TriggerProducer:TriggerPrescales'])
    VectorString.extend(['TriggerProducer:TriggerNames'])
    VectorDouble.extend(['TriggerProducer:objectPt'])
    VectorDouble.extend(['TriggerProducer:objecteta'])
    VectorDouble.extend(['TriggerProducer:objectphi'])
    VectorDouble.extend(['TriggerProducer:objectE'])
    ''' 
    SkipTag = cms.VInputTag(
        cms.InputTag('LeptonsNew:IdIsoMuon'),
        cms.InputTag('LeptonsNew:IdIsoElectron')
    )
    '''
    SkipTag = cms.VInputTag()

    from LeptoQuarkTreeMaker.LeptoQuarkTreeMaker.makeJetVars import makeJetVars
    process = makeJetVars(
        process,
        sequence="Baseline",
        JetTag=JetTag,
        suff='',
        #       fastsim=False,
        skipGoodJets=False,
        storeProperties=2,
        SkipTag=SkipTag)

    if geninfo:
        from LeptoQuarkTreeMaker.Utils.JetEnergyResolution_cfi import JetEnergyResolution
        process.JetEnergyResolution = JetEnergyResolution.clone(
            # jettag = cms.InputTag('slimmedJets')
            jettag=JetTag)

        process.Baseline += process.JetEnergyResolution
        VectorDouble.extend(['JetEnergyResolution:JERPtCorr(JERPtCorr)'])

        VectorDouble.extend(
            ['JetEnergyResolution:JEREnergyCorr(JEREnergyCorr)'])
        VectorDouble.extend(
            ['JetEnergyResolution:JERPtCorrSysUP(JERPtCorrSysUP)'])
        VectorDouble.extend(
            ['JetEnergyResolution:JEREnergyCorrSysUP(JEREnergyCorrSysUP)'])
        VectorDouble.extend(
            ['JetEnergyResolution:JERPtCorrSysDown(JERPtCorrSysDown)'])
        VectorDouble.extend(
            ['JetEnergyResolution:JEREnergyCorrSysDown(JEREnergyCorrSysDown)'])
        VectorDouble.extend(['JetEnergyResolution:JERPhi(JERPhi)'])
        VectorDouble.extend(['JetEnergyResolution:JEREta(JEREta)'])

    from LeptoQuarkTreeMaker.Utils.jetuncertainty_cfi import JetUncertaintyProducer

    #JEC unc up
    process.patJetsJECup = JetUncertaintyProducer.clone(JetTag=JetTag,
                                                        jecUncDir=cms.int32(1))
    process.Baseline += process.patJetsJECup
    #get the JEC factor and unc from here
    VectorDouble.extend([
        'patJetsJECup:jecFactor(Jets_jecFactor)',
        'patJetsJECup:jecUnc(Jets_jecUnc)'
    ])
    process = makeJetVars(process,
                          sequence="Baseline",
                          JetTag=cms.InputTag("patJetsJECup"),
                          suff='JECup',
                          skipGoodJets=False,
                          storeProperties=1,
                          SkipTag=SkipTag)

    #JEC unc down
    process.patJetsJECdown = JetUncertaintyProducer.clone(
        JetTag=JetTag, jecUncDir=cms.int32(-1))
    process.Baseline += process.patJetsJECdown
    process = makeJetVars(process,
                          sequence="Baseline",
                          JetTag=cms.InputTag("patJetsJECdown"),
                          suff='JECdown',
                          skipGoodJets=False,
                          storeProperties=1,
                          SkipTag=SkipTag)

    from LeptoQuarkTreeMaker.Utils.metdouble_cfi import metdouble
    process.MET = metdouble.clone(
        METTag=cms.InputTag('slimmedMETs'),  #METTag,
        GenMETTag=cms.InputTag(
            "slimmedMETs", "",
            tagname),  #original collection used deliberately here
        JetTag=cms.InputTag('slimmedJets'),
        geninfo=cms.untracked.bool(geninfo),
    )
    process.Baseline += process.MET
    VarsDouble.extend([
        'MET:Pt(METPt)', 'MET:Phi(METPhi)', 'MET:CaloPt(CaloMETPt)',
        'MET:CaloPhi(CaloMETPhi)'
    ])

    process.WriteTree = cms.Path(
        process.Baseline *
        #   process.AdditionalSequence *
        #        process.dump *
        process.LQTreeMaker)

    return process
Ejemplo n.º 25
0
#                tag    = cms.string('JER_DATAMCSF_Summer15_25nsV6_AK4PFchs'),
#                label  = cms.untracked.string('AK4PFchs')
#                ),
#        ),
#        connect = cms.string(jetDBFile)
#)
#process.es_prefer_jer = cms.ESPrefer('PoolDBESSource', 'jer')

# Apply jet energy corrections:
#   https://twiki.cern.ch/twiki/bin/view/CMSPublic/WorkBookJetEnergyCorrections#CorrPatJets
# This should load them from the global tag
from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import patJetCorrFactorsUpdated

process.patJetCorrFactorsReapplyJEC = patJetCorrFactorsUpdated.clone(
    src=cms.InputTag("slimmedJets"),
    levels=['L1FastJet', 'L2Relative', 'L3Absolute',
            'L2L3Residuals'],  #Do we need / can we have this here?
    payload='AK4PFchs'
)  # Make sure to choose the appropriate levels and payload here!
from PhysicsTools.PatAlgos.producersLayer1.jetUpdater_cff import patJetsUpdated

process.patJetsReapplyJEC = patJetsUpdated.clone(
    jetSource=cms.InputTag("slimmedJets"),
    jetCorrFactorsSource=cms.VInputTag(
        cms.InputTag("patJetCorrFactorsReapplyJEC")))

##----------------------------------------------------------------------------------------------------
## MET Re-Corrections and Uncertainties
## https://twiki.cern.ch/twiki/bin/view/CMS/MissingETUncertaintyPrescription
## https://twiki.cern.ch/twiki/bin/view/CMSPublic/SWGuidePATTools#METSysTools
##----------------------------------------------------------------------------------------------------
postfix = 'Recorrected'