3232 _pfParticleNetFromMiniAODAK4PuppiCentralJetTagsAll + _pfParticleNetFromMiniAODAK4PuppiForwardJetTagsAll +
3333 _pfUnifiedParticleTransformerAK4JetTagsAll + _pfUnifiedParticleTransformerAK4V1JetTagsAll
3434))
35- run2_nanoAOD_ANY .toModify (
36- bTagDiscriminatorsForAK4 ,
37- foo = bTagCSVV2 + bTagDeepCSV + bTagDeepJet + _pfParticleNetAK4JetTagsAll
38- )
3935bTagDiscriminatorsForAK4 = bTagDiscriminatorsForAK4 .foo .value ()
4036
4137
@@ -352,14 +348,6 @@ def AddBTaggingScores(proc, jetTableName=""):
352348 getattr (proc , jetTableName ).variables .btagDeepFlavCvL = DEEPJETVARS .btagDeepFlavCvL
353349 getattr (proc , jetTableName ).variables .btagDeepFlavCvB = DEEPJETVARS .btagDeepFlavCvB
354350
355- run2_nanoAOD_ANY .toModify (
356- getattr (proc , jetTableName ).variables ,
357- btagCSVV2 = Var ("bDiscriminator('pfCombinedInclusiveSecondaryVertexV2BJetTags')" ,float ,doc = " pfCombinedInclusiveSecondaryVertexV2 b-tag discriminator (aka CSVV2)" ,precision = 10 ),
358- btagDeepB = Var ("?(bDiscriminator('pfDeepCSVJetTags:probb')+bDiscriminator('pfDeepCSVJetTags:probbb'))>=0?bDiscriminator('pfDeepCSVJetTags:probb')+bDiscriminator('pfDeepCSVJetTags:probbb'):-1" ,float ,doc = "DeepCSV b+bb tag discriminator" ,precision = 10 ),
359- btagDeepCvL = Var ("?bDiscriminator('pfDeepCSVJetTags:probc')>=0?bDiscriminator('pfDeepCSVJetTags:probc')/(bDiscriminator('pfDeepCSVJetTags:probc')+bDiscriminator('pfDeepCSVJetTags:probudsg')):-1" , float ,doc = "DeepCSV c vs udsg discriminator" ,precision = 10 ),
360- btagDeepCvB = Var ("?bDiscriminator('pfDeepCSVJetTags:probc')>=0?bDiscriminator('pfDeepCSVJetTags:probc')/(bDiscriminator('pfDeepCSVJetTags:probc')+bDiscriminator('pfDeepCSVJetTags:probb')+bDiscriminator('pfDeepCSVJetTags:probbb')):-1" ,float ,doc = "DeepCSV c vs b+bb discriminator" ,precision = 10 )
361- )
362-
363351 return proc
364352
365353def AddDeepJetGluonLQuarkScores (proc , jetTableName = "" ):
@@ -640,19 +628,6 @@ def ReclusterAK4PuppiJets(proc, recoJA, runOnMC):
640628 #
641629 proc .corrT1METJetPuppiTable .cut = "pt>=8 && pt<15 && abs(eta)<9.9"
642630
643- #
644- # Jet table
645- #
646- # For Run-2 eras, the main AK4 jet collection in NanoAOD is the CHS collection
647- run2_nanoAOD_ANY .toModify (
648- proc .jetTable , name = "Jet"
649- ).toModify (
650- # So need to change the table name for AK4 puppi here
651- proc .jetPuppiTable ,
652- name = "JetPuppi" ,
653- src = cms .InputTag ("finalJetsPuppi" )
654- )
655-
656631 #
657632 # Jet table documentation
658633 #
@@ -790,14 +765,6 @@ def ReclusterAK4PuppiJets(proc, recoJA, runOnMC):
790765 proc .jetPuppiTable .variables .UParTAK4V1RegPtRawCorrNeutrino = UNIFIEDPARTAK4VARS .UParTAK4V1RegPtRawCorrNeutrino
791766 proc .jetPuppiTable .variables .UParTAK4V1RegPtRawRes = UNIFIEDPARTAK4VARS .UParTAK4V1RegPtRawRes
792767
793- #
794- # For Run-2 eras, don't need to save the low pt AK4 Puppi jet table for MET
795- #
796- run2_nanoAOD_ANY .toReplaceWith (
797- proc .jetPuppiForMETTask ,
798- proc .jetPuppiForMETTask .copyAndExclude ([proc .corrT1METJetPuppiTable ])
799- )
800-
801768 #
802769 # Save MC-only jet variables in jet table
803770 #
@@ -880,15 +847,6 @@ def ReclusterAK4CHSJets(proc, recoJA, runOnMC):
880847 proc .jetMCTable .cut = jetTableCut
881848 proc .jetTable .name = "JetCHS"
882849
883- #
884- # For Run-2 eras, the main AK4 jet collection in NanoAOD is the CHS collection
885- #
886- run2_nanoAOD_ANY .toModify (
887- proc .jetTable ,
888- src = cms .InputTag ("linkedObjects" ,"jets" ),
889- name = "Jet"
890- )
891-
892850 #
893851 # Jet table documentation
894852 #
@@ -960,38 +918,24 @@ def ReclusterAK4CHSJets(proc, recoJA, runOnMC):
960918 proc .jetTable .variables .hfadjacentEtaStripsSize = Var ("userInt('hfadjacentEtaStripsSize')" , int , doc = "eta size of the strips next to the central tower strip in HF (noise discriminating variable) " )
961919
962920 #
963- # Since AK4 Puppi jet is the main AK4 jet collection for Run-3 , disable
921+ # Since AK4 Puppi jet is the main AK4 jet collection for NanoV15 (Run2+Run3) , disable
964922 # b-jets/c-jets NN-based mass regression for AK4 CHS.
965923 #
966- (~ run2_nanoAOD_ANY ).toReplaceWith (
967- proc .jetUserDataTask ,
968- proc .jetUserDataTask .copyAndExclude ([proc .bJetVars ])
969- ).toReplaceWith (
970- proc .jetTablesTask ,
971- proc .jetTablesTask .copyAndExclude ([proc .bjetNN , proc .cjetNN ])
972- ).toModify (proc .updatedJetsWithUserData .userFloats ,
973- leadTrackPt = None ,
974- leptonPtRelv0 = None ,
975- leptonPtRelInvv0 = None ,
976- leptonDeltaR = None ,
977- vtxPt = None ,
978- vtxMass = None ,
979- vtx3dL = None ,
980- vtx3deL = None ,
981- ptD = None ,
982- ).toModify (
983- proc .updatedJetsWithUserData .userInts ,
984- vtxNtrk = None ,
985- leptonPdgId = None
986- ).toModify (
987- proc .jetTable , externalVariables = cms .PSet ()
988- ).toReplaceWith (
989- #
990- # For Run-3, don't need to save the low pt AK4 CHS jet table for MET
991- #
992- proc .jetForMETTask ,
993- proc .jetForMETTask .copyAndExclude ([proc .corrT1METJetTable ])
994- )
924+ proc .jetUserDataTask = proc .jetUserDataTask .copyAndExclude ([proc .bJetVars ])
925+ proc .jetTablesTask = proc .jetTablesTask .copyAndExclude ([proc .bjetNN , proc .cjetNN ])
926+ del proc .updatedJetsWithUserData .userFloats .leadTrackPt
927+ del proc .updatedJetsWithUserData .userFloats .leptonPtRelv0
928+ del proc .updatedJetsWithUserData .userFloats .leptonPtRelInvv0
929+ del proc .updatedJetsWithUserData .userFloats .leptonDeltaR
930+ del proc .updatedJetsWithUserData .userFloats .vtxPt
931+ del proc .updatedJetsWithUserData .userFloats .vtxMass
932+ del proc .updatedJetsWithUserData .userFloats .vtx3dL
933+ del proc .updatedJetsWithUserData .userFloats .vtx3deL
934+ del proc .updatedJetsWithUserData .userFloats .ptD
935+ del proc .updatedJetsWithUserData .userInts .vtxNtrk
936+ del proc .updatedJetsWithUserData .userInts .leptonPdgId
937+ proc .jetTable .externalVariables = cms .PSet ()
938+ proc .jetForMETTask = proc .jetForMETTask .copyAndExclude ([proc .corrT1METJetTable ])
995939
996940 #
997941 # Save MC-only jet variables in jet table
@@ -1191,7 +1135,7 @@ def ConfigureAK4GenJets(proc, genJA):
11911135 jmeNano_genjetRecluster_switch = cms .PSet (
11921136 doAK4 = cms .untracked .bool (False ),
11931137 )
1194- run3_nanoAOD_pre142X .toModify (jmeNano_genjetRecluster_switch ,
1138+ ( run2_nanoAOD_106Xv2 | run3_nanoAOD_pre142X ) .toModify (jmeNano_genjetRecluster_switch ,
11951139 doAK4 = True
11961140 )
11971141
@@ -1235,6 +1179,7 @@ def ConfigureAK4GenJets(proc, genJA):
12351179 filter = cms .bool (False )
12361180 )
12371181 proc .jetMCTask .add (proc .AK4GenJetsNoNu )
1182+ proc .genJetTable .src = "AK4GenJetsNoNu"
12381183 proc .genJetTable .cut = ""
12391184 proc .genJetTable .doc = "AK4 Gen jets (made with visible genparticles) with pt > 5 GeV. Sourced from slimmedGenJets"
12401185 proc .genJetFlavourTable .cut = proc .genJetTable .cut
@@ -1482,8 +1427,7 @@ def PrepJMECustomNanoAOD(process):
14821427
14831428 ###########################################################################
14841429 # Add jet tasks
1485- # By default for Run-3, add AK4 CHS jet tasks.
1486- # For Run-2 eras, add AK4 Puppi jet tasks
1430+ # By default for NanoV15 (Run2+Run3), add AK4 CHS jet tasks.
14871431 ###########################################################################
14881432 def addAK4JetTasks (proc , addAK4CHSJetTasks , addAK4PuppiJetTasks ):
14891433 if addAK4CHSJetTasks :
@@ -1500,10 +1444,6 @@ def addAK4JetTasks(proc, addAK4CHSJetTasks, addAK4PuppiJetTasks):
15001444 addAK4CHS_switch = cms .untracked .bool (True ),
15011445 addAK4Puppi_switch = cms .untracked .bool (False )
15021446 )
1503- run2_nanoAOD_ANY .toModify (jmeNano_addAK4JetTasks_switch ,
1504- addAK4CHS_switch = False ,
1505- addAK4Puppi_switch = True
1506- )
15071447 process = addAK4JetTasks (process ,
15081448 addAK4CHSJetTasks = jmeNano_addAK4JetTasks_switch .addAK4CHS_switch ,
15091449 addAK4PuppiJetTasks = jmeNano_addAK4JetTasks_switch .addAK4Puppi_switch ,
@@ -1529,5 +1469,11 @@ def addAK4JetTasks(proc, addAK4CHSJetTasks, addAK4PuppiJetTasks):
15291469 if runOnMC :
15301470 process .genWeightsTable .keepAllPSWeights = True
15311471
1532- return process
1472+ ###########################################################################
1473+ # Make sure that the Puppi weights are recomputed with the latest version
1474+ ###########################################################################
1475+ (run2_nanoAOD_106Xv2 | run3_nanoAOD_pre142X | nanoAOD_rePuppi ).toModify (
1476+ process , lambda p : RecomputePuppiWeights (p )
1477+ )
15331478
1479+ return process
0 commit comments