Created
January 20, 2016 10:31
-
-
Save jpata/6d76523e232990462ba0 to your computer and use it in GitHub Desktop.
cMVAv2 CMSSW 763 validation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ROOT | |
from DataFormats.FWLite import Events, Handle | |
events = Events ('exerciseIPartII_histos.root') | |
handle = Handle ('std::vector<pat::Jet>') | |
label = ("selectedPatJets") | |
for event in events: | |
event.getByLabel(label, handle) | |
jets = handle.product() | |
for jet in jets: | |
print jet.pt(), jet.hadronFlavour(), jet.bDiscriminator("pfCombinedMVAV2BJetTags"), jet.bDiscriminator("pfCombinedInclusiveSecondaryVertexV2BJetTags") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import FWCore.ParameterSet.Config as cms | |
from FWCore.ParameterSet.VarParsing import VarParsing | |
############################### | |
####### Parameters ############ | |
############################### | |
options = VarParsing ('python') | |
options.register('reportEvery', 1, | |
VarParsing.multiplicity.singleton, | |
VarParsing.varType.int, | |
"Report every N events (default is N=10)" | |
) | |
options.register('outputFilename', 'exerciseIPartII_histos.root', | |
VarParsing.multiplicity.singleton, | |
VarParsing.varType.string, | |
"Output file name" | |
) | |
options.register('wantSummary', True, | |
VarParsing.multiplicity.singleton, | |
VarParsing.varType.bool, | |
"Print out trigger and timing summary" | |
) | |
## 'maxEvents' is already registered by the Framework, changing default value | |
options.setDefault('maxEvents', 10000) | |
options.parseArguments() | |
process = cms.Process("USER") | |
process.load("Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff") | |
process.load("Configuration.Geometry.GeometryRecoDB_cff") | |
process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff") | |
from Configuration.AlCa.GlobalTag import GlobalTag | |
process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_mc') | |
process.load("FWCore.MessageService.MessageLogger_cfi") | |
process.MessageLogger.cerr.FwkReport.reportEvery = options.reportEvery | |
## Events to process | |
process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(options.maxEvents) ) | |
## Input files | |
process.source = cms.Source("PoolSource", | |
fileNames = cms.untracked.vstring( | |
'/store/mc/RunIIFall15MiniAODv1/TT_TuneCUETP8M1_13TeV-amcatnlo-pythia8/MINIAODSIM/PU25nsData2015v1_76X_mcRun2_asymptotic_v12-v1/30000/02D2C327-8FA6-E511-9BD1-0CC47A4D7668.root' | |
) | |
) | |
## Output file | |
process.TFileService = cms.Service("TFileService", | |
fileName = cms.string(options.outputFilename) | |
) | |
## Options and Output Report | |
process.options = cms.untracked.PSet( | |
wantSummary = cms.untracked.bool(options.wantSummary), | |
allowUnscheduled = cms.untracked.bool(True) | |
) | |
################################################# | |
## Remake jets | |
################################################# | |
## Filter out neutrinos from packed GenParticles | |
process.packedGenParticlesForJetsNoNu = cms.EDFilter("CandPtrSelector", src = cms.InputTag("packedGenParticles"), cut = cms.string("abs(pdgId) != 12 && abs(pdgId) != 14 && abs(pdgId) != 16")) | |
## Define GenJets | |
from RecoJets.JetProducers.ak4GenJets_cfi import ak4GenJets | |
process.ak4GenJetsNoNu = ak4GenJets.clone(src = 'packedGenParticlesForJetsNoNu') | |
## Select charged hadron subtracted packed PF candidates | |
process.pfCHS = cms.EDFilter("CandPtrSelector", src = cms.InputTag("packedPFCandidates"), cut = cms.string("fromPV")) | |
from RecoJets.JetProducers.ak4PFJets_cfi import ak4PFJets | |
## Define PFJetsCHS | |
process.ak4PFJetsCHS = ak4PFJets.clone(src = 'pfCHS', doAreaFastjet = True) | |
################################################# | |
## Remake PAT jets | |
################################################# | |
## b-tag discriminators | |
bTagDiscriminators = [ | |
'pfCombinedInclusiveSecondaryVertexV2BJetTags', | |
'pfCombinedMVAV2BJetTags' | |
] | |
from PhysicsTools.PatAlgos.tools.jetTools import * | |
## Switch the default PAT jet collection to the above-defined ak4PFJetsCHS | |
switchJetCollection( | |
process, | |
jetSource = cms.InputTag('ak4PFJetsCHS'), | |
pvSource = cms.InputTag('offlineSlimmedPrimaryVertices'), | |
pfCandidates = cms.InputTag('packedPFCandidates'), | |
svSource = cms.InputTag('slimmedSecondaryVertices'), | |
muSource = cms.InputTag('slimmedMuons'), | |
elSource = cms.InputTag('slimmedElectrons'), | |
btagDiscriminators = bTagDiscriminators, | |
jetCorrections = ('AK4PFchs', ['L1FastJet', 'L2Relative', 'L3Absolute'], 'None'), | |
genJetCollection = cms.InputTag('ak4GenJetsNoNu'), | |
genParticles = cms.InputTag('prunedGenParticles') | |
) | |
getattr(process,'selectedPatJets').cut = cms.string('pt > 10') # to match the selection for slimmedJets in MiniAOD | |
################################################# | |
## Let it run | |
process.p = cms.Path(process.selectedPatJets) | |
process.out = cms.OutputModule("PoolOutputModule", | |
fileName = cms.untracked.string(options.outputFilename), | |
outputCommands = cms.untracked.vstring(["keep *_selectedPatJets_*_*"]), | |
# SelectEvents = cms.untracked.PSet( | |
# SelectEvents = cms.vstring("p") | |
# ) | |
) | |
process.outpath = cms.EndPath(process.out) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
what are the csv cuts for pfCombinedMVAV2BJetTags?