Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:27:14

0001 import FWCore.ParameterSet.Config as cms
0002 
0003 process = cms.Process("rerunMVAIsolationOnMiniAOD")
0004 
0005 ## Geometry and Detector Conditions (needed for a few tau reco steps)
0006 process.load("Configuration.Geometry.GeometryRecoDB_cff")
0007 process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
0008 from Configuration.AlCa.GlobalTag import GlobalTag
0009 process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_mc')
0010 process.load("Configuration.StandardSequences.MagneticField_cff")
0011 
0012 process.load("FWCore.MessageService.MessageLogger_cfi")
0013 process.MessageLogger.cerr.FwkReport.reportEvery = 1
0014 process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1) )
0015 
0016 process.source = cms.Source("PoolSource",
0017     # replace 'myfile.root' with the source file you want to use
0018     fileNames = cms.untracked.vstring(
0019         'file:patMiniAOD_standard.root'
0020     )
0021 )
0022 
0023 process.TFileService = cms.Service("TFileService",
0024   fileName = cms.string('rerunTauID_miniAOD.root')
0025 )
0026 
0027 #from Configuration.AlCa.GlobalTag import GlobalTag
0028 #process.GlobalTag = GlobalTag(process.GlobalTag, '76X_mcRun2_asymptotic_RunIIFall15DR76_v1', '')
0029 
0030 from RecoTauTag.RecoTau.TauDiscriminatorTools import noPrediscriminants
0031 process.load('RecoTauTag.Configuration.loadRecoTauTagMVAsFromPrepDB_cfi')
0032 from RecoTauTag.RecoTau.PATTauDiscriminationByMVAIsolationRun2_cff import *
0033 from RecoTauTag.RecoTau.patTauDiscriminationAgainstElectronMVA6_cfi import *
0034 
0035 process.rerunDiscriminationByIsolationMVArun2v1raw = patDiscriminationByIsolationMVArun2v1raw.clone(
0036     PATTauProducer = cms.InputTag('slimmedTaus'),
0037     Prediscriminants = noPrediscriminants,
0038     loadMVAfromDB = cms.bool(True),
0039     ## run with old MVA training
0040     #mvaName = cms.string("RecoTauTag_tauIdMVADBoldDMwLTv1"),
0041     ## run with new MVA training
0042     mvaName = cms.string("RecoTauTag_tauIdMVAIsoDBoldDMwLT2016v1"),
0043     mvaOpt = cms.string("DBoldDMwLT"),
0044     verbosity = cms.int32(0)
0045 )
0046 
0047 process.rerunDiscriminationByIsolationMVArun2v1 = patDiscriminationByIsolationMVArun2v1.clone(
0048     PATTauProducer = cms.InputTag('slimmedTaus'),    
0049     Prediscriminants = noPrediscriminants,
0050     toMultiplex = cms.InputTag('rerunDiscriminationByIsolationMVArun2v1raw'),
0051     loadMVAfromDB = cms.bool(True),
0052     mvaOutput_normalization = cms.string("RecoTauTag_tauIdMVADBoldDMwLTv1_mvaOutput_normalization"),
0053     mapping = cms.VPSet(
0054         cms.PSet(
0055             category = cms.uint32(0),
0056             cut = cms.string("RecoTauTag_tauIdMVADBoldDMwLTv1"),
0057             variable = cms.string("pt"),
0058         )
0059     ),
0060     workingPoints = cms.vstring(
0061         "_WPEff90",
0062         "_WPEff80",
0063         "_WPEff70",
0064         "_WPEff60",
0065         "_WPEff50",
0066         "_WPEff40"
0067     )
0068 )
0069 
0070 process.rerunDiscriminationAgainstElectronMVA6 = patTauDiscriminationAgainstElectronMVA6.clone(
0071     PATTauProducer = cms.InputTag('slimmedTaus'),
0072     Prediscriminants = noPrediscriminants,
0073     #Prediscriminants = requireLeadTrack,
0074     srcElectrons = cms.InputTag('slimmedElectrons'),
0075     loadMVAfromDB = cms.bool(True),
0076     vetoEcalCracks = cms.bool(False),
0077     returnMVA = cms.bool(True),
0078     method = cms.string("BDTG"),
0079     mvaName_NoEleMatch_woGwoGSF_BL = cms.string("RecoTauTag_antiElectronMVA6v3_noeveto_gbr_NoEleMatch_woGwoGSF_BL"),
0080     mvaName_NoEleMatch_wGwoGSF_BL = cms.string("RecoTauTag_antiElectronMVA6v3_noeveto_gbr_NoEleMatch_wGwoGSF_BL"),
0081     mvaName_woGwGSF_BL = cms.string("RecoTauTag_antiElectronMVA6v3_noeveto_gbr_woGwGSF_BL"),
0082     mvaName_wGwGSF_BL = cms.string("RecoTauTag_antiElectronMVA6v3_noeveto_gbr_wGwGSF_BL"),
0083     mvaName_NoEleMatch_woGwoGSF_EC = cms.string("RecoTauTag_antiElectronMVA6v3_noeveto_gbr_NoEleMatch_woGwoGSF_EC"),
0084     mvaName_NoEleMatch_wGwoGSF_EC = cms.string("RecoTauTag_antiElectronMVA6v3_noeveto_gbr_NoEleMatch_wGwoGSF_EC"),
0085     mvaName_woGwGSF_EC = cms.string("RecoTauTag_antiElectronMVA6v3_noeveto_gbr_woGwGSF_EC"),
0086     mvaName_wGwGSF_EC = cms.string("RecoTauTag_antiElectronMVA6v3_noeveto_gbr_wGwGSF_EC"),
0087     minMVANoEleMatchWOgWOgsfBL = cms.double(0.0),
0088     minMVANoEleMatchWgWOgsfBL  = cms.double(0.0),
0089     minMVAWOgWgsfBL            = cms.double(0.0),
0090     minMVAWgWgsfBL             = cms.double(0.0),
0091     minMVANoEleMatchWOgWOgsfEC = cms.double(0.0),
0092     minMVANoEleMatchWgWOgsfEC  = cms.double(0.0),
0093     minMVAWOgWgsfEC            = cms.double(0.0),
0094     minMVAWgWgsfEC             = cms.double(0.0),
0095     usePhiAtEcalEntranceExtrapolation = cms.bool(True)
0096 )
0097 
0098 process.rerunMvaIsolation2SeqRun2 = cms.Sequence(
0099    process.rerunDiscriminationByIsolationMVArun2v1raw
0100    *process.rerunDiscriminationByIsolationMVArun2v1
0101 )
0102 
0103 process.rerunMVAIsolationOnMiniAOD = cms.EDAnalyzer('rerunMVAIsolationOnMiniAOD'
0104 )
0105 
0106 process.rerunMVAIsolationOnMiniAOD.verbosity = cms.int32(0)
0107 process.rerunMVAIsolationOnMiniAOD.additionalCollectionsAvailable = cms.bool(True)
0108 
0109 # embed new id's into tau
0110 def tauIDMVAinputs(module, wp):
0111     return cms.PSet(inputTag = cms.InputTag(module), workingPointIndex = cms.int32(-1 if wp=="raw" else -2 if wp=="category" else getattr(process, module).workingPoints.index(wp)))
0112 embedID = cms.EDProducer("PATTauIDEmbedder",
0113    src = cms.InputTag('slimmedTaus'),
0114    tauIDSources = cms.PSet(
0115       byIsolationMVArun2v1DBoldDMwLTrawNew = tauIDMVAinputs("rerunDiscriminationByIsolationMVArun2v1", "raw"),
0116       byVLooseIsolationMVArun2v1DBoldDMwLTNew = tauIDMVAinputs("rerunDiscriminationByIsolationMVArun2v1", "_WPEff90"),
0117       byLooseIsolationMVArun2v1DBoldDMwLTNew = tauIDMVAinputs("rerunDiscriminationByIsolationMVArun2v1", "_WPEff80"),
0118       byMediumIsolationMVArun2v1DBoldDMwLTNew = tauIDMVAinputs("rerunDiscriminationByIsolationMVArun2v1", "_WPEff70"),
0119       byTightIsolationMVArun2v1DBoldDMwLTNew = tauIDMVAinputs("rerunDiscriminationByIsolationMVArun2v1", "_WPEff60"),
0120       byVTightIsolationMVArun2v1DBoldDMwLTNew = tauIDMVAinputs("rerunDiscriminationByIsolationMVArun2v1", "_WPEff50"),
0121       byVVTightIsolationMVArun2v1DBoldDMwLTNew = tauIDMVAinputs("rerunDiscriminationByIsolationMVArun2v1", "_WPEff40"),
0122       againstElectronMVA6RawNew = tauIDMVAinputs("rerunDiscriminationAgainstElectronMVA6", "raw")
0123    ),
0124 )
0125 setattr(process, "newTauIDsEmbedded", embedID)
0126 
0127 ## added for mvaIsolation on miniAOD testing
0128 process.out = cms.OutputModule("PoolOutputModule",
0129                                fileName = cms.untracked.string('patTuple_newTauIDs.root'),
0130                                ## save only events passing the full path
0131                                #SelectEvents = cms.untracked.PSet( SelectEvents = cms.vstring('p') ),
0132                                ## save PAT output; you need a '*' to unpack the list of commands
0133                                ## 'patEventContent'
0134                                outputCommands = cms.untracked.vstring('drop *', "keep *_newTauIDsEmbedded_*_*")
0135                                )
0136 
0137 process.p = cms.Path(
0138    process.rerunMvaIsolation2SeqRun2
0139   *process.rerunDiscriminationAgainstElectronMVA6
0140   *process.newTauIDsEmbedded
0141   *process.rerunMVAIsolationOnMiniAOD
0142 )
0143 
0144 process.outpath = cms.EndPath(process.out)