Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:33:18

0001 import FWCore.ParameterSet.Config as cms
0002 from Validation.RecoTau.RecoTauValidation_cfi import *
0003 import copy
0004 
0005 from RecoJets.Configuration.RecoPFJets_cff import *
0006 import PhysicsTools.PatAlgos.tools.helpers as helpers
0007 
0008 kinematicSelectedPFJets = cms.EDFilter(
0009     "TauValPFJetSelector",
0010     src = cms.InputTag('ak4PFJets'),
0011     cut = cms.string("pt > 15 & abs(eta) < 2.5"),
0012     filter = cms.bool(False)
0013     )
0014 
0015 PFJetsId = cms.EDFilter(
0016     "TauValPFJetSelector",
0017     src = cms.InputTag('kinematicSelectedPFJets'),
0018     cut = cms.string("chargedHadronEnergyFraction > 0.0 & neutralHadronEnergyFraction < 0.99 & neutralHadronEnergyFraction < 0.99 & chargedEmEnergyFraction < 0.99 & chargedEmEnergyFraction < 0.99 & neutralEmEnergyFraction < 0.99 & chargedMultiplicity > 0 & nConstituents > 1"),
0019     filter = cms.bool(False)
0020     )
0021 
0022 CleanedPFJets = cms.EDProducer("TauValJetViewCleaner",
0023     srcObject            = cms.InputTag( "kinematicSelectedPFJets" ),
0024     srcObjectsToRemove   = cms.VInputTag( cms.InputTag("muons"), cms.InputTag("gedGsfElectrons") ),
0025     deltaRMin            = cms.double(0.15)
0026 )
0027 
0028 procAttributes = dir(proc) #Takes a snapshot of what there in the process
0029 helpers.cloneProcessingSnippet( proc, proc.TauValNumeratorAndDenominator, 'RealData') #clones the sequence inside the process with RealData postfix
0030 helpers.cloneProcessingSnippet( proc, proc.TauEfficiencies, 'RealData') #clones the sequence inside the process with RealData postfix
0031 helpers.massSearchReplaceAnyInputTag(proc.TauValNumeratorAndDenominatorRealData, 'kinematicSelectedTauValDenominator', 'CleanedPFJets') #sets the correct input tag
0032 
0033 #adds to TauValNumeratorAndDenominator modules in the sequence RealData to the extention name
0034 zttLabeler = lambda module : SetValidationExtention(module, 'RealData')
0035 zttModifier = ApplyFunctionToSequence(zttLabeler)
0036 proc.TauValNumeratorAndDenominatorRealData.visit(zttModifier)
0037 
0038 binning = cms.PSet(
0039     pt = cms.PSet( nbins = cms.int32(25), min = cms.double(0.), max = cms.double(250.) ), #hinfo(75, 0., 150.)
0040     eta = cms.PSet( nbins = cms.int32(4), min = cms.double(-3.), max = cms.double(3.) ), #hinfo(60, -3.0, 3.0);
0041     phi = cms.PSet( nbins = cms.int32(4), min = cms.double(-180.), max = cms.double(180.) ), #hinfo(36, -180., 180.);
0042     pileup = cms.PSet( nbins = cms.int32(18), min = cms.double(0.), max = cms.double(72.) ),#hinfo(25, 0., 25.0);
0043     )
0044 zttModifier = ApplyFunctionToSequence(lambda m: setBinning(m,binning))
0045 proc.TauValNumeratorAndDenominatorRealData.visit(zttModifier)
0046 #-----------------------------------------
0047 
0048 #Set discriminators
0049 discs_to_retain = ['ByDecayModeFinding', 'CombinedIsolationDBSumPtCorr3Hits', 'IsolationMVArun2v1DBoldDMwLT', 'IsolationMVArun2v1DBnewDMwLT']
0050 proc.RunHPSValidationRealData.discriminators = cms.VPSet([p for p in proc.RunHPSValidationRealData.discriminators if any(disc in p.discriminator.value() for disc in discs_to_retain) ])
0051 
0052 #Sets the correct naming to efficiency histograms
0053 proc.efficienciesRealData.plots = Utils.SetPlotSequence(proc.TauValNumeratorAndDenominatorRealData)
0054 proc.efficienciesRealDataSummary = cms.EDProducer("TauDQMHistEffProducer",
0055     plots = cms.PSet(
0056         Summary = cms.PSet(
0057             denominator = cms.string('RecoTauV/standardValidation/hpsPFTauProducerRealData_Summary/#PAR#PlotDen'),
0058             efficiency = cms.string('RecoTauV/standardValidation/hpsPFTauProducerRealData_Summary/#PAR#Plot'),
0059             numerator = cms.string('RecoTauV/standardValidation/hpsPFTauProducerRealData_Summary/#PAR#PlotNum'),
0060             parameter = cms.vstring('summary'),
0061             stepByStep = cms.bool(True)
0062         ),
0063     )
0064 )
0065 
0066 #checks what's new in the process (the cloned sequences and modules in them)
0067 newProcAttributes = [x for x in dir(proc) if (x not in procAttributes) and (x.find('RealData') != -1)]
0068 
0069 #spawns a local variable with the same name as the proc attribute, needed for future process.load
0070 for newAttr in newProcAttributes:
0071     locals()[newAttr] = getattr(proc,newAttr)
0072 
0073 
0074 produceDenominatorRealData = cms.Sequence(
0075       cms.ignore(kinematicSelectedPFJets) *
0076       cms.ignore(PFJetsId) *
0077       CleanedPFJets
0078       )
0079 
0080 produceDenominator = cms.Sequence(produceDenominatorRealData)
0081 
0082 runTauValidationBatchMode = cms.Sequence(
0083       produceDenominatorRealData
0084       +TauValNumeratorAndDenominatorRealData
0085       )
0086 
0087 runTauValidation = cms.Sequence(
0088       runTauValidationBatchMode
0089       +TauEfficienciesRealData
0090       )