Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:33:59

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 MuPrimaryVertexFilter = cms.EDFilter(
0009     "VertexSelector",
0010     src = cms.InputTag("offlinePrimaryVertices"),
0011     cut = cms.string("!isFake && ndof > 4 && abs(z) <= 24 && position.Rho <= 2"),
0012     filter = cms.bool(False)
0013     )
0014 
0015 MuBestPV = cms.EDProducer(
0016     "HighestSumP4PrimaryVertexSelector",
0017     src = cms.InputTag("MuPrimaryVertexFilter")
0018     )
0019 
0020 selectedMuons = cms.EDFilter(
0021     "MuonSelector",
0022     src = cms.InputTag('muons'),
0023     cut = cms.string("pt > 20.0 && abs(eta) < 2.1 && isGlobalMuon = 1 && isTrackerMuon = 1"),
0024     filter = cms.bool(False)
0025     )
0026 
0027 selectedMuonsIso = cms.EDFilter(
0028     "MuonSelector",
0029     src = cms.InputTag('selectedMuons'),
0030     cut = cms.string('(isolationR03().emEt + isolationR03().hadEt + isolationR03().sumPt)/pt < 0.15'),
0031     filter = cms.bool(False)
0032     )    
0033 
0034 MuonsFromPV = cms.EDProducer(
0035     "MuonFromPVSelector",
0036     srcMuon    = cms.InputTag("selectedMuonsIso"),
0037     srcVertex  = cms.InputTag("MuBestPV"),
0038     max_dxy    = cms.double(0.01),
0039     max_dz     = cms.double(0.1)
0040     )
0041 
0042 from SimGeneral.HepPDTESSource.pythiapdt_cfi import *
0043 
0044 MuGoodTracks = cms.EDFilter("TrackSelector",
0045     src = cms.InputTag("generalTracks"), 
0046     cut = cms.string("pt > 5 && abs(eta) < 2.5"),
0047     filter = cms.bool(False)
0048     )
0049 
0050 MuIsoTracks = cms.EDProducer(
0051     "IsoTracks",
0052     src           = cms.InputTag("MuGoodTracks"),
0053     radius        = cms.double(0.3),
0054     SumPtFraction = cms.double(0.5)
0055     )
0056 
0057 MuTrackFromPV = cms.EDProducer(
0058     "TrackFromPVSelector",
0059     srcTrack   = cms.InputTag("MuIsoTracks"),
0060     srcVertex  = cms.InputTag("MuBestPV"),
0061     max_dxy    = cms.double(0.01),
0062     max_dz     = cms.double(0.1)
0063     )
0064 
0065 MuTrackCands  = cms.EDProducer(
0066     "ConcreteChargedCandidateProducer", 
0067     src  = cms.InputTag("MuTrackFromPV"),      
0068     particleType = cms.string("mu+")     # this is needed to define a mass
0069     )
0070 
0071 ZmmCandMuonTrack = cms.EDProducer(
0072     "CandViewShallowCloneCombiner",
0073     decay = cms.string("MuonsFromPV@+ MuTrackCands@-"), # it takes opposite sign collection, no matter if +- or -+
0074     cut   = cms.string("80 < mass < 100")
0075     )
0076 
0077 BestZmm = cms.EDProducer("BestMassZArbitrationProducer", # returns the Z with mass closer to 91.18 GeV
0078     ZCandidateCollection = cms.InputTag("ZmmCandMuonTrack")
0079     )
0080 
0081 MuZLegs  = cms.EDProducer("CollectionFromZLegProducer", 
0082     ZCandidateCollection  = cms.InputTag("BestZmm"),      
0083     )
0084 
0085 procAttributes = dir(proc) #Takes a snapshot of what there in the process
0086 helpers.cloneProcessingSnippet( proc, proc.TauValNumeratorAndDenominator, 'RealMuonsData') #clones the sequence inside the process with RealMuonsData postfix
0087 helpers.cloneProcessingSnippet( proc, proc.TauEfficiencies, 'RealMuonsData') #clones the sequence inside the process with RealMuonsData postfix
0088 helpers.massSearchReplaceAnyInputTag(proc.TauValNumeratorAndDenominatorRealMuonsData, 'kinematicSelectedTauValDenominator',  cms.InputTag("MuZLegs","theProbeLeg")) #sets the correct input tag
0089 
0090 #adds to TauValNumeratorAndDenominator modules in the sequence RealMuonsData to the extention name
0091 zttLabeler = lambda module : SetValidationExtention(module, 'RealMuonsData')
0092 zttModifier = ApplyFunctionToSequence(zttLabeler)
0093 proc.TauValNumeratorAndDenominatorRealMuonsData.visit(zttModifier)
0094 
0095 binning = cms.PSet(
0096     pt = cms.PSet( nbins = cms.int32(10), min = cms.double(0.), max = cms.double(100.) ), #hinfo(75, 0., 150.)
0097     eta = cms.PSet( nbins = cms.int32(4), min = cms.double(-3.), max = cms.double(3.) ), #hinfo(60, -3.0, 3.0);
0098     phi = cms.PSet( nbins = cms.int32(4), min = cms.double(-180.), max = cms.double(180.) ), #hinfo(36, -180., 180.);
0099     pileup = cms.PSet( nbins = cms.int32(18), min = cms.double(0.), max = cms.double(72.) ),#hinfo(25, 0., 25.0);
0100     )
0101 zttModifier = ApplyFunctionToSequence(lambda m: setBinning(m,binning))
0102 proc.TauValNumeratorAndDenominatorRealMuonsData.visit(zttModifier)
0103 #-----------------------------------------
0104 
0105 #Set discriminators
0106 discs_to_retain = ['ByDecayModeFinding', 'MuonRejection']
0107 proc.RunHPSValidationRealMuonsData.discriminators = cms.VPSet([p for p in proc.RunHPSValidationRealMuonsData.discriminators if any(disc in p.discriminator.value() for disc in discs_to_retain) ])
0108 
0109 #Sets the correct naming to efficiency histograms
0110 proc.efficienciesRealMuonsData.plots = Utils.SetPlotSequence(proc.TauValNumeratorAndDenominatorRealMuonsData)
0111 proc.efficienciesRealMuonsDataSummary = cms.EDProducer("TauDQMHistEffProducer",
0112     plots = cms.PSet(
0113         Summary = cms.PSet(
0114             denominator = cms.string('RecoTauV/hpsPFTauProducerRealMuonsData_Summary/#PAR#PlotDen'),
0115             efficiency = cms.string('RecoTauV/hpsPFTauProducerRealMuonsData_Summary/#PAR#Plot'),
0116             numerator = cms.string('RecoTauV/hpsPFTauProducerRealMuonsData_Summary/#PAR#PlotNum'),
0117             parameter = cms.vstring('summary'),
0118             stepByStep = cms.bool(True)
0119         ),
0120     )
0121 )
0122 
0123 #checks what's new in the process (the cloned sequences and modules in them)
0124 newProcAttributes = [x for x in dir(proc) if (x not in procAttributes) and (x.find('RealMuonsData') != -1)]
0125 
0126 #spawns a local variable with the same name as the proc attribute, needed for future process.load
0127 for newAttr in newProcAttributes:
0128     locals()[newAttr] = getattr(proc,newAttr)
0129 
0130 produceDenominatorRealMuonsData = cms.Sequence(
0131                             cms.ignore(MuPrimaryVertexFilter) * MuBestPV *
0132                             ( ( cms.ignore(selectedMuons) * cms.ignore(selectedMuonsIso) * MuonsFromPV ) +
0133                               ( cms.ignore(MuGoodTracks) * MuIsoTracks * MuTrackFromPV * MuTrackCands ) ) *
0134                             ZmmCandMuonTrack *
0135                             BestZmm *
0136                             MuZLegs 
0137                             )
0138 
0139 produceDenominator = cms.Sequence(produceDenominatorRealMuonsData)
0140 
0141 runTauValidationBatchMode = cms.Sequence(
0142       produceDenominatorRealMuonsData
0143       +TauValNumeratorAndDenominatorRealMuonsData
0144       )
0145 
0146 runTauValidation = cms.Sequence(
0147       runTauValidationBatchMode
0148       +TauEfficienciesRealMuonsData
0149       )