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 ElPrimaryVertexFilter = 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 ElBestPV = cms.EDProducer( 
0016     "HighestSumP4PrimaryVertexSelector",
0017     src = cms.InputTag("ElPrimaryVertexFilter")
0018     )
0019 
0020 selectedElectrons = cms.EDFilter(
0021     "TauValElectronSelector",
0022     src = cms.InputTag('gedGsfElectrons'),
0023     cut = cms.string("pt > 25.0 && abs(eta) < 2.4 && isElectron"),
0024     filter = cms.bool(False)
0025     )
0026 
0027 ElectronsFromPV = cms.EDProducer(
0028     "GsfElectronFromPVSelector",
0029     srcElectron = cms.InputTag("selectedElectrons"),
0030     srcVertex   = cms.InputTag("ElBestPV"),
0031     max_dxy     = cms.double(0.01),
0032     max_dz      = cms.double(0.1)
0033     )
0034 
0035 idElectrons = cms.EDFilter(
0036     "TauValElectronSelector",
0037     src = cms.InputTag('ElectronsFromPV'),
0038     cut = cms.string('ecalDrivenSeed & isGsfCtfScPixChargeConsistent & isGsfScPixChargeConsistent & isGsfCtfChargeConsistent & !isEBEEGap & (isEB & sigmaIetaIeta<0.01 & abs(deltaPhiSuperClusterTrackAtVtx)<0.06 & abs(deltaEtaSuperClusterTrackAtVtx)<0.006 & hadronicOverEm<0.04 | isEE & sigmaIetaIeta<0.03 & abs(deltaPhiSuperClusterTrackAtVtx)<0.04 & abs(deltaEtaSuperClusterTrackAtVtx)<0.007 & hadronicOverEm<0.025)'),
0039     filter = cms.bool(False)
0040 )
0041 
0042 trackElectrons = cms.EDFilter(
0043     "TauValElectronSelector",
0044     src = cms.InputTag('idElectrons'),
0045     cut = cms.string('gsfTrack.isNonnull  && 0.7 < eSuperClusterOverP < 1.5'),
0046 #    cut = cms.string('gsfTrack.isNonnull && gsfTrack.hitPattern().numberOfLostHits(\'MISSING_INNER_HITS\') = 0 && 0.7 < eSuperClusterOverP < 1.5'),
0047     filter = cms.bool(False)
0048 )
0049 
0050 isolatedElectrons = cms.EDFilter(
0051     "TauValElectronSelector",
0052     src = cms.InputTag('trackElectrons'),
0053     cut = cms.string("(isEB & (dr04TkSumPt/pt + max(0.,dr04EcalRecHitSumEt-2.)/pt + dr04HcalTowerSumEt/pt < 0.10)) | (isEE & (dr04TkSumPt/pt + dr04EcalRecHitSumEt/pt + dr04HcalTowerSumEt/pt < 0.09))"),
0054     filter = cms.bool(False)
0055     )
0056 
0057 from SimGeneral.HepPDTESSource.pythiapdt_cfi import *
0058 
0059 ElGoodTracks = cms.EDFilter(
0060     "TrackSelector",
0061     src = cms.InputTag("generalTracks"), 
0062     cut = cms.string("pt > 5 && abs(eta) < 2.5"),
0063     filter = cms.bool(False)
0064     )
0065 
0066 ElIsoTracks = cms.EDProducer(
0067     "IsoTracks",
0068     src           = cms.InputTag("ElGoodTracks"),
0069     radius        = cms.double(0.3),
0070     SumPtFraction = cms.double(0.5)
0071     )
0072 
0073 ElTrackFromPV = cms.EDProducer(
0074     "TrackFromPVSelector",
0075     srcTrack   = cms.InputTag("ElIsoTracks"),
0076     srcVertex  = cms.InputTag("ElBestPV"),
0077     max_dxy    = cms.double(0.01),
0078     max_dz     = cms.double(0.1)
0079     )
0080 
0081 ElTrackCands  = cms.EDProducer(
0082     "ConcreteChargedCandidateProducer", 
0083     src  = cms.InputTag("ElTrackFromPV"),      
0084     particleType = cms.string("e+")     # this is needed to define a mass do not trust the sign, it is dummy
0085     )
0086 
0087 ZeeCandElectronTrack = cms.EDProducer(
0088     "CandViewShallowCloneCombiner",
0089     decay = cms.string("isolatedElectrons@+ ElTrackCands@-"), # it takes opposite sign collection, no matter if +- or -+
0090     cut   = cms.string("80 < mass < 100")
0091     )
0092 
0093 BestZee = cms.EDProducer(
0094     "BestMassZArbitrationProducer", # returns the Z with mass closest to 91.18 GeV
0095     ZCandidateCollection = cms.InputTag("ZeeCandElectronTrack")
0096     )
0097 
0098 ElZLegs  = cms.EDProducer(
0099     "CollectionFromZLegProducer", 
0100     ZCandidateCollection  = cms.InputTag("BestZee"),      
0101     )
0102 
0103 procAttributes = dir(proc) #Takes a snapshot of what there in the process
0104 helpers.cloneProcessingSnippet( proc, proc.TauValNumeratorAndDenominator, 'RealElectronsData') #clones the sequence inside the process with RealElectronsData postfix
0105 helpers.cloneProcessingSnippet( proc, proc.TauEfficiencies, 'RealElectronsData') #clones the sequence inside the process with RealElectronsData postfix
0106 helpers.massSearchReplaceAnyInputTag(proc.TauValNumeratorAndDenominatorRealElectronsData, 'kinematicSelectedTauValDenominator', cms.InputTag("ElZLegs","theProbeLeg")) #sets the correct input tag
0107 
0108 #adds to TauValNumeratorAndDenominator modules in the sequence RealElectronsData to the extention name
0109 zttLabeler = lambda module : SetValidationExtention(module, 'RealElectronsData')
0110 zttModifier = ApplyFunctionToSequence(zttLabeler)
0111 proc.TauValNumeratorAndDenominatorRealElectronsData.visit(zttModifier)
0112 
0113 binning = cms.PSet(
0114     pt = cms.PSet( nbins = cms.int32(10), min = cms.double(0.), max = cms.double(100.) ), #hinfo(75, 0., 150.)
0115     eta = cms.PSet( nbins = cms.int32(4), min = cms.double(-3.), max = cms.double(3.) ), #hinfo(60, -3.0, 3.0);
0116     phi = cms.PSet( nbins = cms.int32(4), min = cms.double(-180.), max = cms.double(180.) ), #hinfo(36, -180., 180.);
0117     pileup = cms.PSet( nbins = cms.int32(18), min = cms.double(0.), max = cms.double(72.) ),#hinfo(25, 0., 25.0);
0118     )
0119 zttModifier = ApplyFunctionToSequence(lambda m: setBinning(m,binning))
0120 proc.TauValNumeratorAndDenominatorRealElectronsData.visit(zttModifier)
0121 #-----------------------------------------
0122 
0123 #Set discriminators
0124 discs_to_retain = ['ByDecayModeFinding', 'ElectronRejection']
0125 proc.RunHPSValidationRealElectronsData.discriminators = cms.VPSet([p for p in proc.RunHPSValidationRealElectronsData.discriminators if any(disc in p.discriminator.value() for disc in discs_to_retain) ])
0126 
0127 #Sets the correct naming to efficiency histograms
0128 proc.efficienciesRealElectronsData.plots = Utils.SetPlotSequence(proc.TauValNumeratorAndDenominatorRealElectronsData)
0129 proc.efficienciesRealElectronsDataSummary = cms.EDProducer("TauDQMHistEffProducer",
0130     plots = cms.PSet(
0131         Summary = cms.PSet(
0132             denominator = cms.string('RecoTauV/hpsPFTauProducerRealElectronsData_Summary/#PAR#PlotDen'),
0133             efficiency = cms.string('RecoTauV/hpsPFTauProducerRealElectronsData_Summary/#PAR#Plot'),
0134             numerator = cms.string('RecoTauV/hpsPFTauProducerRealElectronsData_Summary/#PAR#PlotNum'),
0135             parameter = cms.vstring('summary'),
0136             stepByStep = cms.bool(True)
0137         ),
0138     )
0139 )
0140 
0141 #checks what's new in the process (the cloned sequences and modules in them)
0142 newProcAttributes = [x for x in dir(proc) if (x not in procAttributes) and (x.find('RealElectronsData') != -1)]
0143 
0144 #spawns a local variable with the same name as the proc attribute, needed for future process.load
0145 for newAttr in newProcAttributes:
0146     locals()[newAttr] = getattr(proc,newAttr)
0147 
0148 produceDenominatorRealElectronsData = cms.Sequence( cms.ignore(ElPrimaryVertexFilter) * ElBestPV *
0149                                                     ( (cms.ignore(selectedElectrons) * ElectronsFromPV * cms.ignore(idElectrons) * cms.ignore(trackElectrons) * cms.ignore(isolatedElectrons)) +
0150                                                       (cms.ignore(ElGoodTracks) * ElIsoTracks * ElTrackFromPV * ElTrackCands) ) *
0151                                                     ZeeCandElectronTrack *
0152                                                     BestZee *
0153                                                     ElZLegs 
0154                                                   )
0155 
0156 produceDenominator = cms.Sequence(produceDenominatorRealElectronsData)
0157 
0158 runTauValidationBatchMode = cms.Sequence(
0159       produceDenominatorRealElectronsData
0160       +TauValNumeratorAndDenominatorRealElectronsData
0161       )
0162 
0163 runTauValidation = cms.Sequence(
0164       runTauValidationBatchMode
0165       +TauEfficienciesRealElectronsData
0166       )