Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-10-19 10:28:49

0001 import FWCore.ParameterSet.Config as cms
0002 
0003 from RecoTauTag.RecoTau.PFRecoTauDiscriminationByIsolation_cfi import *
0004 from RecoTauTag.RecoTau.PFRecoTauQualityCuts_cfi import PFTauQualityCuts
0005 from RecoTauTag.RecoTau.PFRecoTauDiscriminationByHPSSelection_cfi import hpsSelectionDiscriminator
0006 
0007 from RecoTauTag.RecoTau.PFTauPrimaryVertexProducer_cfi      import *
0008 from RecoTauTag.RecoTau.PFTauSecondaryVertexProducer_cfi    import *
0009 from RecoTauTag.RecoTau.PFTauTransverseImpactParameters_cfi import *
0010 
0011 from RecoTauTag.RecoTau.DeepTau_cfi import *
0012 
0013 from RecoTauTag.RecoTau.PFRecoTauPFJetInputs_cfi import PFRecoTauPFJetInputs
0014 ## DeltaBeta correction factor
0015 _ak4dBetaCorrection = 0.20
0016 
0017 def update(process):
0018     process.options.wantSummary = cms.untracked.bool(True)
0019 
0020     process.hltFixedGridRhoFastjetAllTau = cms.EDProducer( "FixedGridRhoProducerFastjet",
0021         gridSpacing = cms.double( 0.55 ),
0022         maxRapidity = cms.double( 5.0 ),
0023         pfCandidatesTag = cms.InputTag( "hltParticleFlowReg" )
0024     )
0025 
0026     PFTauQualityCuts.primaryVertexSrc = cms.InputTag("hltPixelVertices")
0027 
0028     ## Decay mode prediscriminant
0029     requireDecayMode = cms.PSet(
0030         BooleanOperator = cms.string("and"),
0031         decayMode = cms.PSet(
0032             Producer = cms.InputTag('hltHpsPFTauDiscriminationByDecayModeFindingNewDMsReg'),
0033             cut = cms.double(0.5)
0034         )
0035     )
0036 
0037     ## Cut based isolations dR=0.5
0038     process.hpsPFTauBasicDiscriminatorsForDeepTau = pfRecoTauDiscriminationByIsolation.clone(
0039         PFTauProducer = 'hltHpsL1JetsHLTForDeepTauInput',
0040         Prediscriminants = cms.PSet(  BooleanOperator = cms.string( "and" ) ),
0041         deltaBetaPUTrackPtCutOverride     = True, # Set the boolean = True to override.
0042         deltaBetaPUTrackPtCutOverride_val = 0.5,  # Set the value for new value.
0043         particleFlowSrc = 'hltParticleFlowReg',
0044         vertexSrc = PFTauQualityCuts.primaryVertexSrc,
0045         customOuterCone = PFRecoTauPFJetInputs.isolationConeSize,
0046         isoConeSizeForDeltaBeta = 0.8,
0047         deltaBetaFactor = "%0.4f"%(_ak4dBetaCorrection),
0048         qualityCuts = dict(isolationQualityCuts = dict(minTrackHits = 3, minGammaEt = 1.0, minTrackPt = 0.5)),
0049         IDdefinitions = [
0050             cms.PSet(
0051                 IDname = cms.string("ChargedIsoPtSum"),
0052                 ApplyDiscriminationByTrackerIsolation = cms.bool(True),
0053                 storeRawSumPt = cms.bool(True)
0054             ),
0055             cms.PSet(
0056                 IDname = cms.string("NeutralIsoPtSum"),
0057                 ApplyDiscriminationByECALIsolation = cms.bool(True),
0058                 storeRawSumPt = cms.bool(True)
0059             ),
0060             cms.PSet(
0061                 IDname = cms.string("NeutralIsoPtSumWeight"),
0062                 ApplyDiscriminationByWeightedECALIsolation = cms.bool(True),
0063                 storeRawSumPt = cms.bool(True),
0064                 UseAllPFCandsForWeights = cms.bool(True)
0065             ),
0066             cms.PSet(
0067                 IDname = cms.string("TauFootprintCorrection"),
0068                 storeRawFootprintCorrection = cms.bool(True)
0069             ),
0070             cms.PSet(
0071                 IDname = cms.string("PhotonPtSumOutsideSignalCone"),
0072                 storeRawPhotonSumPt_outsideSignalCone = cms.bool(True)
0073             ),
0074             cms.PSet(
0075                 IDname = cms.string("PUcorrPtSum"),
0076                 applyDeltaBetaCorrection = cms.bool(True),
0077                 storeRawPUsumPt = cms.bool(True)
0078             ),
0079         ],
0080     )
0081 
0082     ## Cut based isolations dR=0.3
0083     process.hpsPFTauBasicDiscriminatorsdR03ForDeepTau = process.hpsPFTauBasicDiscriminatorsForDeepTau.clone(
0084         customOuterCone = 0.3
0085     )
0086 
0087     process.hpsPFTauPrimaryVertexProducerForDeepTau = PFTauPrimaryVertexProducer.clone(
0088         PFTauTag = "hltHpsPFTauProducerReg",
0089         ElectronTag = "hltEgammaCandidates",
0090         MuonTag = "hltMuonsReg",
0091         PVTag = "hltPixelVertices",
0092         beamSpot = "hltOnlineBeamSpot",
0093         discriminators = [
0094             cms.PSet(
0095                 discriminator = cms.InputTag('hltHpsPFTauDiscriminationByDecayModeFindingNewDMsReg'),
0096                 selectionCut = cms.double(0.5)
0097             )
0098         ],
0099         cut = "pt > 18.0 & abs(eta) < 2.4",
0100         qualityCuts = PFTauQualityCuts
0101     )
0102 
0103     process.hpsPFTauSecondaryVertexProducerForDeepTau = PFTauSecondaryVertexProducer.clone(
0104         PFTauTag = "hltHpsPFTauProducerReg"
0105     )
0106     process.hpsPFTauTransverseImpactParametersForDeepTau = PFTauTransverseImpactParameters.clone(
0107         PFTauTag = "hltHpsPFTauProducerReg",
0108         PFTauPVATag = "hpsPFTauPrimaryVertexProducerForDeepTau",
0109         PFTauSVATag = "hpsPFTauSecondaryVertexProducerForDeepTau",
0110         useFullCalculation = True
0111     )
0112 
0113     chargedIsolationQualityCuts = PFTauQualityCuts.clone(
0114         isolationQualityCuts = cms.PSet(
0115             maxDeltaZ = cms.double( 0.2 ),
0116             minTrackPt = cms.double( 0.5 ),
0117             minGammaEt = cms.double( 0.5 ),
0118             minTrackHits = cms.uint32( 3 ),
0119             minTrackPixelHits = cms.uint32( 0 ),
0120             maxTrackChi2 = cms.double( 100.0 ),
0121             maxTransverseImpactParameter = cms.double( 0.1 ),
0122             useTracksInsteadOfPFHadrons = cms.bool( False )
0123         ),
0124         primaryVertexSrc = "hltPixelVertices",
0125         signalQualityCuts = cms.PSet(
0126             maxDeltaZ = cms.double( 0.2 ),
0127             minTrackPt = cms.double( 0.0 ),
0128             minGammaEt = cms.double( 0.5 ),
0129             minTrackHits = cms.uint32( 3 ),
0130             minTrackPixelHits = cms.uint32( 0 ),
0131             maxTrackChi2 = cms.double( 1000.0 ),
0132             maxTransverseImpactParameter = cms.double( 0.2 ),
0133             useTracksInsteadOfPFHadrons = cms.bool( False ),
0134             minNeutralHadronEt = cms.double( 1.0 )
0135         ),
0136         vxAssocQualityCuts = cms.PSet(
0137             minTrackPt = cms.double( 0.0 ),
0138             minGammaEt = cms.double( 0.5 ),
0139             minTrackHits = cms.uint32( 3 ),
0140             minTrackPixelHits = cms.uint32( 0 ),
0141             maxTrackChi2 = cms.double( 1000.0 ),
0142             maxTransverseImpactParameter = cms.double( 0.2 ),
0143             useTracksInsteadOfPFHadrons = cms.bool( False )
0144         ),
0145     )
0146 
0147     process.hltHpsL1JetsHLTForDeepTauInput = process.hltHpsL1JetsHLTDoublePFTauTrackPt1MediumChargedIsolationMatchReg.clone(
0148         L1TauTrigger = "hltL1sTauVeryBigOR",
0149         JetSrc = "hltHpsPFTauProducerReg",
0150         ReduceTauContent = False,
0151         KeepOriginalVertex = True,
0152     )
0153 
0154     file_names = [
0155         'core:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_core.pb',
0156         'inner:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_inner.pb',
0157         'outer:RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6_outer.pb',
0158     ]
0159 
0160     def getLinExpression(x1, x2, y1, y2):
0161         return "(((({3}-{2})/({1}-{0}))*(pt-{0}))+{2})".format(x1, x2, y1, y2)
0162 
0163     val1, val2 = ("0.49948551", "0.125")
0164     working_points = ["{0}*(pt < 35)+".format(val1)+getLinExpression("35", "300", val1, val2)+ "*(35 <= pt && pt < 300) + {0}*(pt >= 300)".format(val2)]
0165 
0166     process.deepTauProducer = DeepTau.clone(
0167         taus = 'hltHpsL1JetsHLTForDeepTauInput',
0168         pfcands = 'hltParticleFlowReg',
0169         vertices = 'hltPixelVertices',
0170         rho = 'hltFixedGridRhoFastjetAllTau',
0171         graph_file = file_names,
0172         disable_dxy_pca = True,
0173         is_online = True,
0174         pfTauTransverseImpactParameters = 'hpsPFTauTransverseImpactParametersForDeepTau',
0175         basicTauDiscriminators = 'hpsPFTauBasicDiscriminatorsForDeepTau',
0176         basicTauDiscriminatorsdR03 = 'hpsPFTauBasicDiscriminatorsdR03ForDeepTau',
0177         Prediscriminants = cms.PSet(  BooleanOperator = cms.string( "and" ) ),  
0178         VSeWP = working_points,
0179         VSmuWP = working_points,
0180         VSjetWP = working_points     
0181     )   
0182 
0183     # Add DeepTauProducer
0184     process.HLTHPSDeepTau35IsoPFTauSequenceReg = cms.Sequence(process.hpsPFTauPrimaryVertexProducerForDeepTau + process.hpsPFTauSecondaryVertexProducerForDeepTau + process.hpsPFTauTransverseImpactParametersForDeepTau + process.hltFixedGridRhoFastjetAllTau + process.hltHpsL1JetsHLTForDeepTauInput + process.hpsPFTauBasicDiscriminatorsForDeepTau + process.hpsPFTauBasicDiscriminatorsdR03ForDeepTau + process.deepTauProducer)
0185     
0186     process.hltHpsSelectedPFTausTrackPt1DeepTau35IsolationReg = process.hltHpsSelectedPFTausTrackPt1MediumChargedIsolationReg.clone(
0187         src = "hltHpsL1JetsHLTForDeepTauInput",
0188         discriminators = [
0189             # cms.PSet(  
0190             #     discriminator = cms.InputTag( "hltHpsPFTauTrackPt1DiscriminatorReg" ),
0191             #     selectionCut = cms.double( 0.5 )
0192             # )
0193         ],
0194         discriminatorContainers = [
0195             cms.PSet(  
0196                 discriminator = cms.InputTag( "deepTauProducer", "VSjet" ),
0197                 rawValues = cms.vstring(),
0198                 selectionCuts = cms.vdouble(),
0199                 workingPoints = cms.vstring(working_points),
0200             )
0201         ]
0202     )
0203 
0204     process.hltHpsDoublePFTau35TrackPt1DeepTau35IsolationReg = process.hltHpsDoublePFTau35TrackPt1MediumChargedIsolationReg.clone(
0205         inputTag = "hltHpsSelectedPFTausTrackPt1DeepTau35IsolationReg",
0206     )
0207 
0208     process.hltHpsL1JetsHLTDoublePFTauTrackPt1DeepTauMatchReg = process.hltHpsL1JetsHLTDoublePFTauTrackPt1MediumChargedIsolationMatchReg.clone(
0209         JetSrc = "hltHpsSelectedPFTausTrackPt1DeepTau35IsolationReg",
0210     )
0211 
0212     process.hltHpsDoublePFTau35TrackPt1DeepTauL1HLTMatchedReg = process.hltHpsDoublePFTau35TrackPt1MediumChargedIsolationL1HLTMatchedReg.clone(
0213         inputTag = "hltHpsL1JetsHLTDoublePFTauTrackPt1DeepTauMatchReg",
0214     )
0215 
0216     process.hltHpsDoublePFTau35TrackPt1DeepTau35IsolationDz02Reg = process.hltHpsDoublePFTau35TrackPt1MediumChargedIsolationDz02Reg.clone(
0217         JetSrc = "hltHpsL1JetsHLTDoublePFTauTrackPt1DeepTauMatchReg"
0218     )
0219 
0220     process.HLT_DoubleMediumChargedIsoPFTauHPS35_Trk1_eta2p1_Reg_v4.remove(process.HLTHPSMediumChargedIsoPFTauSequenceReg)
0221     process.HLT_DoubleMediumChargedIsoPFTauHPS35_Trk1_eta2p1_Reg_v4.remove(process.hltHpsSelectedPFTausTrackPt1MediumChargedIsolationReg)
0222     process.HLT_DoubleMediumChargedIsoPFTauHPS35_Trk1_eta2p1_Reg_v4.remove(process.hltHpsDoublePFTau35TrackPt1MediumChargedIsolationReg)
0223     process.HLT_DoubleMediumChargedIsoPFTauHPS35_Trk1_eta2p1_Reg_v4.remove(process.hltHpsL1JetsHLTDoublePFTauTrackPt1MediumChargedIsolationMatchReg)
0224     process.HLT_DoubleMediumChargedIsoPFTauHPS35_Trk1_eta2p1_Reg_v4.remove(process.hltHpsDoublePFTau35TrackPt1MediumChargedIsolationL1HLTMatchedReg)
0225     process.HLT_DoubleMediumChargedIsoPFTauHPS35_Trk1_eta2p1_Reg_v4.remove(process.hltHpsDoublePFTau35TrackPt1MediumChargedIsolationDz02Reg)
0226     process.HLT_DoubleMediumChargedIsoPFTauHPS35_Trk1_eta2p1_Reg_v4.remove(process.HLTEndSequence)
0227 
0228     process.HLT_DoubleMediumChargedIsoPFTauHPS35_Trk1_eta2p1_Reg_v4 += (process.HLTHPSDeepTau35IsoPFTauSequenceReg + process.hltHpsSelectedPFTausTrackPt1DeepTau35IsolationReg + process.hltHpsDoublePFTau35TrackPt1DeepTau35IsolationReg + process.hltHpsL1JetsHLTDoublePFTauTrackPt1DeepTauMatchReg + process.hltHpsDoublePFTau35TrackPt1DeepTauL1HLTMatchedReg + process.hltHpsDoublePFTau35TrackPt1DeepTau35IsolationDz02Reg + process.HLTEndSequence)
0229 
0230     return process