From fd0b8a5de1f3a3773b182855f5e4c6a81b91be99 Mon Sep 17 00:00:00 2001 From: Kevin Pedro Date: Fri, 4 May 2018 09:19:29 -0500 Subject: [PATCH 1/8] remove unused qjets --- python/jetToolbox_cff.py | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/python/jetToolbox_cff.py b/python/jetToolbox_cff.py index 2442b40a3b3..7a981eaac92 100644 --- a/python/jetToolbox_cff.py +++ b/python/jetToolbox_cff.py @@ -46,7 +46,6 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, addNsub=False, maxTau=4, addNsubSubjets=False, subjetMaxTau=4, addPUJetID=False, - addQJets=False, addQGTagger=False, QGjetsLabel='chs', addEnergyCorrFunc=False, addEnergyCorrFuncSubjets=False, @@ -906,26 +905,6 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, jetSeq += getattr(proc, mod["Nsubjettiness"]) toolsUsed.append( mod["Nsubjettiness"] ) - ###### QJetsAdder - ''' - if addQJets: - ### there must be a better way to do this random number introduction - setattr( proc, 'RandomNumberGeneratorService', cms.Service("RandomNumberGeneratorService", - QJetsAdderCA8 = cms.PSet(initialSeed = cms.untracked.uint32(7)), - QJetsAdderAK8 = cms.PSet(initialSeed = cms.untracked.uint32(31)), - QJetsAdderCA15 = cms.PSet(initialSeed = cms.untracked.uint32(76)), ) ) - - from RecoJets.JetProducers.qjetsadder_cfi import QJetsAdder - setattr( proc, 'QJetsAdder'+jetALGO, - QJetsAdder.clone( src = cms.InputTag(jetalgo+'PFJets'+PUMethod+postFix), - jetRad = cms.double( jetSize ), - jetAlgo = cms.string( jetALGO[0:2] ))) - elemToKeep += [ 'keep *_QJetsAdder'+jetALGO+'_*_*' ] - getattr( proc, patJets+jetALGO+'PF'+PUMethod).userData.userFloats.src += ['QJetsAdder'+jetALGO+':QjetsVolatility'] - jetSeq += getattr(proc, 'QJetsAdder'+jetALGO ) - toolsUsed.append( 'QJetsAdder'+jetALGO ) - ''' - ###### QGTagger if addQGTagger: if ( 'ak4' in jetalgo ) and ( PUMethod not in ['Puppi','CS','SK'] ) : From df09eb7369e6a2412c1dff7e3dd2db9748beb61e Mon Sep 17 00:00:00 2001 From: Kevin Pedro Date: Fri, 4 May 2018 09:25:14 -0500 Subject: [PATCH 2/8] fix some typos --- python/jetToolbox_cff.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/python/jetToolbox_cff.py b/python/jetToolbox_cff.py index 7a981eaac92..474630683fa 100644 --- a/python/jetToolbox_cff.py +++ b/python/jetToolbox_cff.py @@ -60,7 +60,7 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, ############################################################################### ####### Verifying some inputs and defining variables ############################################################################### - print '|---- jetToolbox: Initialyzing collection...' + print '|---- jetToolbox: Initializing collection...' if newPFCollection: print '|---- jetToolBox: Using '+ nameNewPFCollection +' as PFCandidates collection' supportedJetAlgos = { 'ak': 'AntiKt', 'ca' : 'CambridgeAachen', 'kt' : 'Kt' } recommendedJetAlgos = [ 'ak4', 'ak8', 'ca4', 'ca8', 'ca10', 'ca15' ] @@ -87,7 +87,7 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, ### Trick for uppercase/lowercase algo name jetALGO = jetAlgo.upper()+size jetalgo = jetAlgo.lower()+size - if jetalgo not in recommendedJetAlgos: print '|---- jetToolBox: CMS recommends the following jet algoritms: '+' '.join(recommendedJetAlgos)+'. You are using', jetalgo,'.' + if jetalgo not in recommendedJetAlgos: print '|---- jetToolBox: CMS recommends the following jet algorithms: '+' '.join(recommendedJetAlgos)+'. You are using', jetalgo,'.' ################################################################################# @@ -303,7 +303,7 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, if 'None' in JETCorrPayload: JEC = None else: JEC = ( JETCorrPayload.replace('CS','chs').replace('SK','chs') , JETCorrLevels, 'None' ) ### temporary #else: JEC = ( JETCorrPayload., JETCorrLevels, 'None' ) - print '|---- jetToolBox: Applying this corrections: '+str(JEC) + print '|---- jetToolBox: Applying these corrections: '+str(JEC) if addPrunedSubjets or addSoftDropSubjets or addCMSTopTagger: if 'None' in subJETCorrPayload: subJEC = None @@ -360,7 +360,7 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, return None if 'Puppi' in updateCollection: PUMethod='Puppi' JEC = ( JETCorrPayload, JETCorrLevels, 'None' ) ### temporary - print '|---- jetToolBox: Applying this corrections: '+str(JEC) + print '|---- jetToolBox: Applying these corrections: '+str(JEC) updateJetCollection( proc, postfix = postFix, @@ -372,7 +372,7 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, mod["PATJetsCorrFactors"] = 'patJetCorrFactors'+mod["PATJetsLabelPost"] getattr( proc, mod["PATJetsCorrFactors"] ).payload = JETCorrPayload getattr( proc, mod["PATJetsCorrFactors"] ).levels = JETCorrLevels - if bTagDiscriminators: print '|---- jetToolBox: Adding this bTagDiscriminators: '+str(bTagDiscriminators)+' in the jet collection.' + if bTagDiscriminators: print '|---- jetToolBox: Adding these bTagDiscriminators: '+str(bTagDiscriminators)+' in the jet collection.' patJets = 'updatedPatJets' patSubJets = '' mod["PATJets"] = patJets+mod["PATJetsLabelPost"] @@ -398,10 +398,10 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, getattr( proc, mod["PATSubjetsCorrFactors"] ).payload = subJETCorrPayload getattr( proc, mod["PATSubjetsCorrFactors"] ).levels = subJETCorrLevels patSubJets = 'updatedPatJets'+mod["PATSubjetsLabel"] - if bTagDiscriminators: print '|---- jetToolBox: Adding this bTagDiscriminators: '+str(bTagDiscriminators)+' in the subjet collection.' + if bTagDiscriminators: print '|---- jetToolBox: Adding these bTagDiscriminators: '+str(bTagDiscriminators)+' in the subjet collection.' if addPrunedSubjets or addSoftDropSubjets or addCMSTopTagger or addMassDrop or addHEPTopTagger or addPruning or addSoftDrop: - print '|---- jetToolBox: You are trying to add a groomer variable into a clustered jet collection. THIS IS NOT RECOMMENDED, it is recommended to recluster jets instead using a plain jetToolbox configuration. Please use this feature by your own risk.' + print '|---- jetToolBox: You are trying to add a groomer variable into a clustered jet collection. THIS IS NOT RECOMMENDED, it is recommended to recluster jets instead using a plain jetToolbox configuration. Please use this feature at your own risk.' mod["PFJetsOrUpdate"] = mod["PFJets"] if not updateCollection else updateCollection @@ -952,12 +952,12 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, ) ) - getattr( proc, mod["PATJets"]).userData.userFloats.src += [mod["PUJetIDEval"]+':fullDiscriminant'] - getattr( proc, mod["PATJets"]).userData.userInts.src += [mod["PUJetIDEval"]+':cutbasedId',mod["PUJetIDEval"]+':fullId'] - elemToKeep += ['keep *_'+mod["PUJetIDEval"]+'_*_*'] - toolsUsed.append( mod["PUJetIDEval"] ) + getattr( proc, mod["PATJets"]).userData.userFloats.src += [mod["PUJetIDEval"]+':fullDiscriminant'] + getattr( proc, mod["PATJets"]).userData.userInts.src += [mod["PUJetIDEval"]+':cutbasedId',mod["PUJetIDEval"]+':fullId'] + elemToKeep += ['keep *_'+mod["PUJetIDEval"]+'_*_*'] + toolsUsed.append( mod["PUJetIDEval"] ) else: - print '|---- jetToolBox: PUJetID is optimized for ak4 PFjets with CHS. NOT running PUJetID.' + print '|---- jetToolBox: PUJetID is optimized for ak4 PFjets with CHS. NOT running PUJetID.' ###### Energy Correlation Functions if addEnergyCorrFunc: From 62138ee842188dc49096c6a4074ddc5e23ed455d Mon Sep 17 00:00:00 2001 From: Kevin Pedro Date: Fri, 4 May 2018 09:29:51 -0500 Subject: [PATCH 3/8] use exceptions --- python/jetToolbox_cff.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/python/jetToolbox_cff.py b/python/jetToolbox_cff.py index 474630683fa..91bfe4ce19c 100644 --- a/python/jetToolbox_cff.py +++ b/python/jetToolbox_cff.py @@ -83,7 +83,7 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, jetSize = 0. if int(size) in range(0, 20): jetSize = int(size)/10. - else: print '|---- jetToolBox: jetSize has not a valid value. Insert a number between 1 and 20 after algorithm, like: AK8' + else: raise ValueError('|---- jetToolBox: jetSize has not a valid value. Insert a number between 1 and 20 after algorithm, like: AK8') ### Trick for uppercase/lowercase algo name jetALGO = jetAlgo.upper()+size jetalgo = jetAlgo.lower()+size @@ -355,9 +355,8 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, elLabel = 'slimmedElectrons' if not JETCorrPayload: - print '|---- jetToolBox: updateCollection option requires to add JETCorrPayload.' - print '|---- jetToolBox: EXITING.' - return None + raise ValueError('|---- jetToolBox: updateCollection option requires to add JETCorrPayload.') + if 'Puppi' in updateCollection: PUMethod='Puppi' JEC = ( JETCorrPayload, JETCorrLevels, 'None' ) ### temporary print '|---- jetToolBox: Applying these corrections: '+str(JEC) @@ -803,7 +802,8 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, elemToKeep += [ 'keep *_'+mod["PATJetsCMSTopTagPacked"]+'_*_*' ] toolsUsed.append( mod["PATJetsCMSTopTagPacked"] ) - else: print '|---- jetToolBox: CMS recommends CambridgeAachen for CMS Top Tagger, you are using '+algorithm+'. JetToolbox will not run CMS Top Tagger.' + else: + raise ValueError('|---- jetToolBox: CMS recommends CambridgeAachen for CMS Top Tagger, you are using '+algorithm+'. JetToolbox will not run CMS Top Tagger.') if addMassDrop : @@ -822,7 +822,8 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, jetSeq += getattr(proc, mod["PFJetsMassDrop"]) jetSeq += getattr(proc, mod["MassDropFilteredMass"]) toolsUsed.append( mod["MassDropFilteredMass"] ) - else: print '|---- jetToolBox: CMS recommends CambridgeAachen for Mass Drop, you are using '+algorithm+'. JetToolbox will not run Mass Drop.' + else: + raise ValueError('|---- jetToolBox: CMS recommends CambridgeAachen for Mass Drop, you are using '+algorithm+'. JetToolbox will not run Mass Drop.') if addHEPTopTagger: if ( jetSize >= 1. ) and ( 'CA' in jetALGO ): @@ -837,7 +838,8 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, jetSeq += getattr(proc, mod["PFJetsHEPTopTag"]) jetSeq += getattr(proc, mod["PFJetsHEPTopTagMass"]) toolsUsed.append( mod["PFJetsHEPTopTagMass"] ) - else: print '|---- jetToolBox: CMS recommends CambridgeAachen for HEPTopTagger, you are using '+algorithm+', and a jet cone size bigger than 1. JetToolbox will not run HEP TopTagger.' + else: + raise ValueError('|---- jetToolBox: CMS recommends CambridgeAachen w/ jet cone size > 1.0 for HEPTopTagger, you are using '+algorithm+'. JetToolbox will not run HEP TopTagger.') ####### Nsubjettiness if addNsub: @@ -882,8 +884,7 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, mod["NsubSubjets"] = mod["PATSubjetsPrunedLabel"] mod["NsubPATSubjets"] = mod["PATSubjetsPruned"] else: - print '|---- jetToolBox: Nsubjettiness of subjets needs a Subjet collection. Or create one using addSoftDropSubjets option, or updateCollection.' - return None + raise ValueError('|---- jetToolBox: Nsubjettiness of subjets needs a Subjet collection. Or create one using addSoftDropSubjets option, or updateCollection.') mod["Nsubjettiness"] = 'Nsubjettiness'+mod["NsubSubjets"] rangeTau = range(1,subjetMaxTau+1) @@ -923,7 +924,7 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, toolsUsed.append( mod["QGTagger"] ) else: - print '|---- jetToolBox: QGTagger is optimized for ak4 jets with CHS. NOT running QGTagger' + raise ValueError('|---- jetToolBox: QGTagger is optimized for ak4 jets with CHS. NOT running QGTagger') ####### Pileup JetID @@ -957,12 +958,12 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, elemToKeep += ['keep *_'+mod["PUJetIDEval"]+'_*_*'] toolsUsed.append( mod["PUJetIDEval"] ) else: - print '|---- jetToolBox: PUJetID is optimized for ak4 PFjets with CHS. NOT running PUJetID.' + raise ValueError('|---- jetToolBox: PUJetID is optimized for ak4 PFjets with CHS. NOT running PUJetID.') ###### Energy Correlation Functions if addEnergyCorrFunc: if PUMethod!="Puppi" or (addSoftDrop==False and addSoftDropSubjets==False): - raise ValueError("addEnergyCorrFunc only supported for Puppi w/ addSoftDrop or addSoftDropSubjets") + raise ValueError("|---- jetToolBox: addEnergyCorrFunc only supported for Puppi w/ addSoftDrop or addSoftDropSubjets") from RecoJets.JetProducers.ECF_cff import ecfNbeta1, ecfNbeta2 mod["ECFnb1"] = 'nb1'+mod["SubstructureLabel"]+'SoftDrop' mod["ECFnb2"] = 'nb2'+mod["SubstructureLabel"]+'SoftDrop' @@ -1011,7 +1012,7 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, if addEnergyCorrFuncSubjets: if PUMethod!="Puppi" or addSoftDropSubjets==False: - raise ValueError("addEnergyCorrFuncSubjets only supported for Puppi w/ addSoftDropSubjets") + raise ValueError("|---- jetToolBox: addEnergyCorrFuncSubjets only supported for Puppi w/ addSoftDropSubjets") from RecoJets.JetProducers.ECF_cff import ecfNbeta1, ecfNbeta2 mod["ECFnb1Subjets"] = 'nb1'+mod["SubstructureLabel"]+'SoftDropSubjets' mod["ECFnb2Subjets"] = 'nb2'+mod["SubstructureLabel"]+'SoftDropSubjets' From 4fb42b1e97d6424ae3fbce075e1c75ef2733a4ca Mon Sep 17 00:00:00 2001 From: Kevin Pedro Date: Fri, 4 May 2018 09:36:21 -0500 Subject: [PATCH 4/8] some future proofing --- python/jetToolbox_cff.py | 48 ++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/python/jetToolbox_cff.py b/python/jetToolbox_cff.py index 91bfe4ce19c..f10872549e9 100644 --- a/python/jetToolbox_cff.py +++ b/python/jetToolbox_cff.py @@ -60,8 +60,8 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, ############################################################################### ####### Verifying some inputs and defining variables ############################################################################### - print '|---- jetToolbox: Initializing collection...' - if newPFCollection: print '|---- jetToolBox: Using '+ nameNewPFCollection +' as PFCandidates collection' + print('|---- jetToolbox: Initializing collection...') + if newPFCollection: print('|---- jetToolBox: Using '+ nameNewPFCollection +' as PFCandidates collection') supportedJetAlgos = { 'ak': 'AntiKt', 'ca' : 'CambridgeAachen', 'kt' : 'Kt' } recommendedJetAlgos = [ 'ak4', 'ak8', 'ca4', 'ca8', 'ca10', 'ca15' ] payloadList = [ 'None', @@ -87,7 +87,7 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, ### Trick for uppercase/lowercase algo name jetALGO = jetAlgo.upper()+size jetalgo = jetAlgo.lower()+size - if jetalgo not in recommendedJetAlgos: print '|---- jetToolBox: CMS recommends the following jet algorithms: '+' '.join(recommendedJetAlgos)+'. You are using', jetalgo,'.' + if jetalgo not in recommendedJetAlgos: print('|---- jetToolBox: CMS recommends the following jet algorithms: '+' '.join(recommendedJetAlgos)+'. You are using '+jetalgo+' .') ################################################################################# @@ -137,7 +137,7 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, #### For MiniAOD if miniAOD: - print '|---- jetToolBox: JETTOOLBOX RUNNING ON MiniAOD FOR '+jetALGO+' JETS USING '+PUMethod + print('|---- jetToolBox: JETTOOLBOX RUNNING ON MiniAOD FOR '+jetALGO+' JETS USING '+PUMethod) genParticlesLabel = 'prunedGenParticles' pvLabel = 'offlineSlimmedPrimaryVertices' @@ -168,7 +168,7 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, #### For AOD else: - print '|---- jetToolBox: JETTOOLBOX RUNNING ON AOD FOR '+jetALGO+' JETS USING '+PUMethod + print('|---- jetToolBox: JETTOOLBOX RUNNING ON AOD FOR '+jetALGO+' JETS USING '+PUMethod) genParticlesLabel = 'genParticles' pvLabel = 'offlinePrimaryVertices' @@ -190,7 +190,7 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, if 'Puppi' in PUMethod: if ('puppi' in tmpPfCandName): srcForPFJets = pfCand - print '|---- jetToolBox: Not running puppi algorithm because keyword puppi was specified in nameNewPFCollection, but applying puppi corrections.' + print('|---- jetToolBox: Not running puppi algorithm because keyword puppi was specified in nameNewPFCollection, but applying puppi corrections.') else: proc.load('CommonTools.PileupAlgos.Puppi_cff') puppi.candName = cms.InputTag( pfCand ) @@ -216,7 +216,7 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, if ('sk' in tmpPfCandName): srcForPFJets = pfCand - print '|---- jetToolBox: Not running softkiller algorithm because keyword SK was specified in nameNewPFCollection, but applying SK corrections.' + print('|---- jetToolBox: Not running softkiller algorithm because keyword SK was specified in nameNewPFCollection, but applying SK corrections.') else: proc.load('CommonTools.PileupAlgos.softKiller_cfi') getattr( proc, 'softKiller' ).PFCandidates = cms.InputTag( pfCand ) @@ -254,7 +254,7 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, if miniAOD: if ('chs' in tmpPfCandName): srcForPFJets = pfCand - print '|---- jetToolBox: Not running CHS algorithm because keyword CHS was specified in nameNewPFCollection, but applying CHS corrections.' + print('|---- jetToolBox: Not running CHS algorithm because keyword CHS was specified in nameNewPFCollection, but applying CHS corrections.') else: setattr( proc, 'chs', cms.EDFilter('CandPtrSelector', src = cms.InputTag( pfCand ), cut = cms.string('fromPV')) ) jetSeq += getattr(proc, 'chs') @@ -303,7 +303,7 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, if 'None' in JETCorrPayload: JEC = None else: JEC = ( JETCorrPayload.replace('CS','chs').replace('SK','chs') , JETCorrLevels, 'None' ) ### temporary #else: JEC = ( JETCorrPayload., JETCorrLevels, 'None' ) - print '|---- jetToolBox: Applying these corrections: '+str(JEC) + print('|---- jetToolBox: Applying these corrections: '+str(JEC)) if addPrunedSubjets or addSoftDropSubjets or addCMSTopTagger: if 'None' in subJETCorrPayload: subJEC = None @@ -346,7 +346,7 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, if 'CS' in PUMethod: getattr( proc, mod["PATJets"] ).getJetMCFlavour = False # CS jets cannot be re-clustered from their constituents else: - print '|---- jetToolBox: JETTOOLBOX IS UPDATING '+updateCollection+' collection' + print('|---- jetToolBox: JETTOOLBOX IS UPDATING '+updateCollection+' collection') genParticlesLabel = 'prunedGenParticles' pvLabel = 'offlineSlimmedPrimaryVertices' svLabel = 'slimmedSecondaryVertices' @@ -359,7 +359,7 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, if 'Puppi' in updateCollection: PUMethod='Puppi' JEC = ( JETCorrPayload, JETCorrLevels, 'None' ) ### temporary - print '|---- jetToolBox: Applying these corrections: '+str(JEC) + print('|---- jetToolBox: Applying these corrections: '+str(JEC)) updateJetCollection( proc, postfix = postFix, @@ -371,14 +371,14 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, mod["PATJetsCorrFactors"] = 'patJetCorrFactors'+mod["PATJetsLabelPost"] getattr( proc, mod["PATJetsCorrFactors"] ).payload = JETCorrPayload getattr( proc, mod["PATJetsCorrFactors"] ).levels = JETCorrLevels - if bTagDiscriminators: print '|---- jetToolBox: Adding these bTagDiscriminators: '+str(bTagDiscriminators)+' in the jet collection.' + if bTagDiscriminators: print('|---- jetToolBox: Adding these bTagDiscriminators: '+str(bTagDiscriminators)+' in the jet collection.') patJets = 'updatedPatJets' patSubJets = '' mod["PATJets"] = patJets+mod["PATJetsLabelPost"] mod["selPATJets"] = selPatJets+mod["PATJetsLabelPost"] if updateCollectionSubjets: - print '|---- jetToolBox: JETTOOLBOX IS UPDATING '+updateCollectionSubjets+' collection for subjets/groomers.' + print('|---- jetToolBox: JETTOOLBOX IS UPDATING '+updateCollectionSubjets+' collection for subjets/groomers.') if 'SoftDrop' in updateCollectionSubjets: updateSubjetLabel = 'SoftDrop' else: updateSubjetLabel = 'Pruned' mod["PATSubjetsLabel"] = jetALGO+'PF'+PUMethod+postFix+updateSubjetLabel+'Packed' @@ -397,10 +397,10 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, getattr( proc, mod["PATSubjetsCorrFactors"] ).payload = subJETCorrPayload getattr( proc, mod["PATSubjetsCorrFactors"] ).levels = subJETCorrLevels patSubJets = 'updatedPatJets'+mod["PATSubjetsLabel"] - if bTagDiscriminators: print '|---- jetToolBox: Adding these bTagDiscriminators: '+str(bTagDiscriminators)+' in the subjet collection.' + if bTagDiscriminators: print('|---- jetToolBox: Adding these bTagDiscriminators: '+str(bTagDiscriminators)+' in the subjet collection.') if addPrunedSubjets or addSoftDropSubjets or addCMSTopTagger or addMassDrop or addHEPTopTagger or addPruning or addSoftDrop: - print '|---- jetToolBox: You are trying to add a groomer variable into a clustered jet collection. THIS IS NOT RECOMMENDED, it is recommended to recluster jets instead using a plain jetToolbox configuration. Please use this feature at your own risk.' + print('|---- jetToolBox: You are trying to add a groomer variable into a clustered jet collection. THIS IS NOT RECOMMENDED, it is recommended to recluster jets instead using a plain jetToolbox configuration. Please use this feature at your own risk.') mod["PFJetsOrUpdate"] = mod["PFJets"] if not updateCollection else updateCollection @@ -527,7 +527,7 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, ) jetSeq += getattr(proc, mod["packedPATJetsSoftDrop"]) elemToKeep += [ 'keep *_'+mod["packedPATJetsSoftDrop"]+'_*_*' ] - print '|---- jetToolBox: Creating '+mod["packedPATJetsSoftDrop"]+' collection with SoftDrop subjets.' + print('|---- jetToolBox: Creating '+mod["packedPATJetsSoftDrop"]+' collection with SoftDrop subjets.') @@ -646,7 +646,7 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, ) jetSeq += getattr(proc, mod["packedPATJetsPruned"]) elemToKeep += [ 'keep *_'+mod["packedPATJetsPruned"]+'_*_*' ] - print '|---- jetToolBox: Creating '+mod["packedPATJetsPruned"]+' collection with Pruned subjets.' + print('|---- jetToolBox: Creating '+mod["packedPATJetsPruned"]+' collection with Pruned subjets.') if addTrimming: @@ -878,7 +878,7 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, mod["NsubSubjets"] = mod["PATSubjetsSoftDropLabel"] mod["NsubPATSubjets"] = mod["PATSubjetsSoftDrop"] if updateCollectionSubjets: - print '|---- jetToolBox: Using updateCollection option. ASSUMING MINIAOD collection '+ updateCollectionSubjets +' for Nsubjettiness of subjets.' + print('|---- jetToolBox: Using updateCollection option. ASSUMING MINIAOD collection '+ updateCollectionSubjets +' for Nsubjettiness of subjets.') elif addPrunedSubjets: mod["NsubGroomer"] = mod["PFJetsPruned"] mod["NsubSubjets"] = mod["PATSubjetsPrunedLabel"] @@ -930,7 +930,7 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, ####### Pileup JetID if addPUJetID: if ( 'ak4' in jetalgo ) and ( PUMethod not in ['CS','SK'] ): - if PUMethod=="Puppi": print '|---- jetToolBox: PUJetID is not yet optimized for ak4 PFjets with PUPPI. USE ONLY FOR TESTING.' + if PUMethod=="Puppi": print('|---- jetToolBox: PUJetID is not yet optimized for ak4 PFjets with PUPPI. USE ONLY FOR TESTING.') from RecoJets.JetProducers.pileupjetidproducer_cfi import pileupJetIdCalculator,pileupJetIdEvaluator mod["PUJetIDCalc"] = mod["PATJetsLabelPost"]+'pileupJetIdCalculator' @@ -1046,9 +1046,9 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, elemToKeep += [ 'keep *_'+mod["selPATSubjets"]+'__*' ] - if len(toolsUsed) > 0 : print '|---- jetToolBox: Running '+', '.join(toolsUsed)+'.' - print '|---- jetToolBox: Creating '+mod["selPATJets"]+' collection.' - if updateCollectionSubjets: print '|---- jetToolBox: Creating '+mod["selPATSubjets"]+' collection.' + if len(toolsUsed) > 0 : print('|---- jetToolBox: Running '+', '.join(toolsUsed)+'.') + print('|---- jetToolBox: Creating '+mod["selPATJets"]+' collection.') + if updateCollectionSubjets: print('|---- jetToolBox: Creating '+mod["selPATSubjets"]+' collection.') ### "return" setattr(proc, jetSequence, jetSeq) @@ -1079,6 +1079,6 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, removeMCMatching(proc, names=['Jets'], outputModules=[outputFile]) if printModuleNames: - print '|---- jetToolBox: List of modules created (and other internal names):' + print('|---- jetToolBox: List of modules created (and other internal names):') for m in mod: - print ' '+m+' = '+mod[m] + print(' '+m+' = '+mod[m]) From 2d7f785b3cdbce7ce2f1333ff1b47e76ca2e639e Mon Sep 17 00:00:00 2001 From: Kevin Pedro Date: Fri, 4 May 2018 09:41:42 -0500 Subject: [PATCH 5/8] verbosity levels and control --- python/jetToolbox_cff.py | 49 ++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/python/jetToolbox_cff.py b/python/jetToolbox_cff.py index f10872549e9..6cc62d67aa7 100644 --- a/python/jetToolbox_cff.py +++ b/python/jetToolbox_cff.py @@ -49,7 +49,8 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, addQGTagger=False, QGjetsLabel='chs', addEnergyCorrFunc=False, addEnergyCorrFuncSubjets=False, - printModuleNames=False, + # 0 = no printouts, 1 = warnings only, 2 = warnings & info, 3 = warnings, info, debug + verbosity=2, ): runOnData = not runOnMC @@ -60,8 +61,8 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, ############################################################################### ####### Verifying some inputs and defining variables ############################################################################### - print('|---- jetToolbox: Initializing collection...') - if newPFCollection: print('|---- jetToolBox: Using '+ nameNewPFCollection +' as PFCandidates collection') + if verbosity>=2: print('|---- jetToolbox: Initializing collection...') + if newPFCollection and verbosity>=2: print('|---- jetToolBox: Using '+ nameNewPFCollection +' as PFCandidates collection') supportedJetAlgos = { 'ak': 'AntiKt', 'ca' : 'CambridgeAachen', 'kt' : 'Kt' } recommendedJetAlgos = [ 'ak4', 'ak8', 'ca4', 'ca8', 'ca10', 'ca15' ] payloadList = [ 'None', @@ -87,7 +88,7 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, ### Trick for uppercase/lowercase algo name jetALGO = jetAlgo.upper()+size jetalgo = jetAlgo.lower()+size - if jetalgo not in recommendedJetAlgos: print('|---- jetToolBox: CMS recommends the following jet algorithms: '+' '.join(recommendedJetAlgos)+'. You are using '+jetalgo+' .') + if jetalgo not in recommendedJetAlgos and verbosity>=1: print('|---- jetToolBox: CMS recommends the following jet algorithms: '+' '.join(recommendedJetAlgos)+'. You are using '+jetalgo+' .') ################################################################################# @@ -137,7 +138,7 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, #### For MiniAOD if miniAOD: - print('|---- jetToolBox: JETTOOLBOX RUNNING ON MiniAOD FOR '+jetALGO+' JETS USING '+PUMethod) + if verbosity>=2: print('|---- jetToolBox: JETTOOLBOX RUNNING ON MiniAOD FOR '+jetALGO+' JETS USING '+PUMethod) genParticlesLabel = 'prunedGenParticles' pvLabel = 'offlineSlimmedPrimaryVertices' @@ -168,7 +169,7 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, #### For AOD else: - print('|---- jetToolBox: JETTOOLBOX RUNNING ON AOD FOR '+jetALGO+' JETS USING '+PUMethod) + if verbosity>=2: print('|---- jetToolBox: JETTOOLBOX RUNNING ON AOD FOR '+jetALGO+' JETS USING '+PUMethod) genParticlesLabel = 'genParticles' pvLabel = 'offlinePrimaryVertices' @@ -190,7 +191,7 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, if 'Puppi' in PUMethod: if ('puppi' in tmpPfCandName): srcForPFJets = pfCand - print('|---- jetToolBox: Not running puppi algorithm because keyword puppi was specified in nameNewPFCollection, but applying puppi corrections.') + if verbosity>=1: print('|---- jetToolBox: Not running puppi algorithm because keyword puppi was specified in nameNewPFCollection, but applying puppi corrections.') else: proc.load('CommonTools.PileupAlgos.Puppi_cff') puppi.candName = cms.InputTag( pfCand ) @@ -216,7 +217,7 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, if ('sk' in tmpPfCandName): srcForPFJets = pfCand - print('|---- jetToolBox: Not running softkiller algorithm because keyword SK was specified in nameNewPFCollection, but applying SK corrections.') + if verbosity>=1: print('|---- jetToolBox: Not running softkiller algorithm because keyword SK was specified in nameNewPFCollection, but applying SK corrections.') else: proc.load('CommonTools.PileupAlgos.softKiller_cfi') getattr( proc, 'softKiller' ).PFCandidates = cms.InputTag( pfCand ) @@ -254,7 +255,7 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, if miniAOD: if ('chs' in tmpPfCandName): srcForPFJets = pfCand - print('|---- jetToolBox: Not running CHS algorithm because keyword CHS was specified in nameNewPFCollection, but applying CHS corrections.') + if verbosity>=1: print('|---- jetToolBox: Not running CHS algorithm because keyword CHS was specified in nameNewPFCollection, but applying CHS corrections.') else: setattr( proc, 'chs', cms.EDFilter('CandPtrSelector', src = cms.InputTag( pfCand ), cut = cms.string('fromPV')) ) jetSeq += getattr(proc, 'chs') @@ -303,7 +304,7 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, if 'None' in JETCorrPayload: JEC = None else: JEC = ( JETCorrPayload.replace('CS','chs').replace('SK','chs') , JETCorrLevels, 'None' ) ### temporary #else: JEC = ( JETCorrPayload., JETCorrLevels, 'None' ) - print('|---- jetToolBox: Applying these corrections: '+str(JEC)) + if verbosity>=2: print('|---- jetToolBox: Applying these corrections: '+str(JEC)) if addPrunedSubjets or addSoftDropSubjets or addCMSTopTagger: if 'None' in subJETCorrPayload: subJEC = None @@ -346,7 +347,7 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, if 'CS' in PUMethod: getattr( proc, mod["PATJets"] ).getJetMCFlavour = False # CS jets cannot be re-clustered from their constituents else: - print('|---- jetToolBox: JETTOOLBOX IS UPDATING '+updateCollection+' collection') + if verbosity>=2: print('|---- jetToolBox: JETTOOLBOX IS UPDATING '+updateCollection+' collection') genParticlesLabel = 'prunedGenParticles' pvLabel = 'offlineSlimmedPrimaryVertices' svLabel = 'slimmedSecondaryVertices' @@ -359,7 +360,7 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, if 'Puppi' in updateCollection: PUMethod='Puppi' JEC = ( JETCorrPayload, JETCorrLevels, 'None' ) ### temporary - print('|---- jetToolBox: Applying these corrections: '+str(JEC)) + if verbosity>=2: print('|---- jetToolBox: Applying these corrections: '+str(JEC)) updateJetCollection( proc, postfix = postFix, @@ -371,14 +372,14 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, mod["PATJetsCorrFactors"] = 'patJetCorrFactors'+mod["PATJetsLabelPost"] getattr( proc, mod["PATJetsCorrFactors"] ).payload = JETCorrPayload getattr( proc, mod["PATJetsCorrFactors"] ).levels = JETCorrLevels - if bTagDiscriminators: print('|---- jetToolBox: Adding these bTagDiscriminators: '+str(bTagDiscriminators)+' in the jet collection.') + if bTagDiscriminators and verbosity>=2: print('|---- jetToolBox: Adding these bTagDiscriminators: '+str(bTagDiscriminators)+' in the jet collection.') patJets = 'updatedPatJets' patSubJets = '' mod["PATJets"] = patJets+mod["PATJetsLabelPost"] mod["selPATJets"] = selPatJets+mod["PATJetsLabelPost"] if updateCollectionSubjets: - print('|---- jetToolBox: JETTOOLBOX IS UPDATING '+updateCollectionSubjets+' collection for subjets/groomers.') + if verbosity>=2: print('|---- jetToolBox: JETTOOLBOX IS UPDATING '+updateCollectionSubjets+' collection for subjets/groomers.') if 'SoftDrop' in updateCollectionSubjets: updateSubjetLabel = 'SoftDrop' else: updateSubjetLabel = 'Pruned' mod["PATSubjetsLabel"] = jetALGO+'PF'+PUMethod+postFix+updateSubjetLabel+'Packed' @@ -397,10 +398,10 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, getattr( proc, mod["PATSubjetsCorrFactors"] ).payload = subJETCorrPayload getattr( proc, mod["PATSubjetsCorrFactors"] ).levels = subJETCorrLevels patSubJets = 'updatedPatJets'+mod["PATSubjetsLabel"] - if bTagDiscriminators: print('|---- jetToolBox: Adding these bTagDiscriminators: '+str(bTagDiscriminators)+' in the subjet collection.') + if bTagDiscriminators and verbosity>=2: print('|---- jetToolBox: Adding these bTagDiscriminators: '+str(bTagDiscriminators)+' in the subjet collection.') if addPrunedSubjets or addSoftDropSubjets or addCMSTopTagger or addMassDrop or addHEPTopTagger or addPruning or addSoftDrop: - print('|---- jetToolBox: You are trying to add a groomer variable into a clustered jet collection. THIS IS NOT RECOMMENDED, it is recommended to recluster jets instead using a plain jetToolbox configuration. Please use this feature at your own risk.') + if verbosity>=1: print('|---- jetToolBox: You are trying to add a groomer variable into a clustered jet collection. THIS IS NOT RECOMMENDED, it is recommended to recluster jets instead using a plain jetToolbox configuration. Please use this feature at your own risk.') mod["PFJetsOrUpdate"] = mod["PFJets"] if not updateCollection else updateCollection @@ -527,7 +528,7 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, ) jetSeq += getattr(proc, mod["packedPATJetsSoftDrop"]) elemToKeep += [ 'keep *_'+mod["packedPATJetsSoftDrop"]+'_*_*' ] - print('|---- jetToolBox: Creating '+mod["packedPATJetsSoftDrop"]+' collection with SoftDrop subjets.') + if verbosity>=2: print('|---- jetToolBox: Creating '+mod["packedPATJetsSoftDrop"]+' collection with SoftDrop subjets.') @@ -646,7 +647,7 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, ) jetSeq += getattr(proc, mod["packedPATJetsPruned"]) elemToKeep += [ 'keep *_'+mod["packedPATJetsPruned"]+'_*_*' ] - print('|---- jetToolBox: Creating '+mod["packedPATJetsPruned"]+' collection with Pruned subjets.') + if verbosity>=2: print('|---- jetToolBox: Creating '+mod["packedPATJetsPruned"]+' collection with Pruned subjets.') if addTrimming: @@ -878,7 +879,7 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, mod["NsubSubjets"] = mod["PATSubjetsSoftDropLabel"] mod["NsubPATSubjets"] = mod["PATSubjetsSoftDrop"] if updateCollectionSubjets: - print('|---- jetToolBox: Using updateCollection option. ASSUMING MINIAOD collection '+ updateCollectionSubjets +' for Nsubjettiness of subjets.') + if verbosity>=2: print('|---- jetToolBox: Using updateCollection option. ASSUMING MINIAOD collection '+ updateCollectionSubjets +' for Nsubjettiness of subjets.') elif addPrunedSubjets: mod["NsubGroomer"] = mod["PFJetsPruned"] mod["NsubSubjets"] = mod["PATSubjetsPrunedLabel"] @@ -930,7 +931,7 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, ####### Pileup JetID if addPUJetID: if ( 'ak4' in jetalgo ) and ( PUMethod not in ['CS','SK'] ): - if PUMethod=="Puppi": print('|---- jetToolBox: PUJetID is not yet optimized for ak4 PFjets with PUPPI. USE ONLY FOR TESTING.') + if PUMethod=="Puppi" and verbosity>=1: print('|---- jetToolBox: PUJetID is not yet optimized for ak4 PFjets with PUPPI. USE ONLY FOR TESTING.') from RecoJets.JetProducers.pileupjetidproducer_cfi import pileupJetIdCalculator,pileupJetIdEvaluator mod["PUJetIDCalc"] = mod["PATJetsLabelPost"]+'pileupJetIdCalculator' @@ -1046,9 +1047,9 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, elemToKeep += [ 'keep *_'+mod["selPATSubjets"]+'__*' ] - if len(toolsUsed) > 0 : print('|---- jetToolBox: Running '+', '.join(toolsUsed)+'.') - print('|---- jetToolBox: Creating '+mod["selPATJets"]+' collection.') - if updateCollectionSubjets: print('|---- jetToolBox: Creating '+mod["selPATSubjets"]+' collection.') + if len(toolsUsed) > 0 and verbosity>=2: print('|---- jetToolBox: Running '+', '.join(toolsUsed)+'.') + if verbosity>=2: print('|---- jetToolBox: Creating '+mod["selPATJets"]+' collection.') + if updateCollectionSubjets and verbosity>=2: print('|---- jetToolBox: Creating '+mod["selPATSubjets"]+' collection.') ### "return" setattr(proc, jetSequence, jetSeq) @@ -1078,7 +1079,7 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, from PhysicsTools.PatAlgos.tools.coreTools import removeMCMatching removeMCMatching(proc, names=['Jets'], outputModules=[outputFile]) - if printModuleNames: + if verbosity>=3: print('|---- jetToolBox: List of modules created (and other internal names):') for m in mod: print(' '+m+' = '+mod[m]) From 85f31cd9cf256d98f2bb7b79dba9d7aea0fdc307 Mon Sep 17 00:00:00 2001 From: Kevin Pedro Date: Fri, 4 May 2018 10:42:47 -0500 Subject: [PATCH 6/8] btag discriminator improvements (None means none, separate for subjets, message printing) --- python/jetToolbox_cff.py | 46 +++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/python/jetToolbox_cff.py b/python/jetToolbox_cff.py index 6cc62d67aa7..ac4db45af93 100644 --- a/python/jetToolbox_cff.py +++ b/python/jetToolbox_cff.py @@ -32,8 +32,11 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, JETCorrPayload='', JETCorrLevels = [ 'None' ], GetJetMCFlavour=True, Cut = '', postFix='', - bTagDiscriminators = None, + # blank means default list of discriminators, None means none + bTagDiscriminators = '', bTagInfos = None, + subjetBTagDiscriminators = '', + subjetBTagInfos = None, subJETCorrPayload='', subJETCorrLevels = [ 'None' ], GetSubjetMCFlavour=True, CutSubjet = '', addPruning=False, zCut=0.1, rCut=0.5, addPrunedSubjets=False, @@ -114,26 +117,27 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, if runOnData: subJETCorrLevels.append('L2L3Residual') + ## b-tag discriminators + defaultBTagDiscriminators = [ + 'pfTrackCountingHighEffBJetTags', + 'pfTrackCountingHighPurBJetTags', + 'pfJetProbabilityBJetTags', + 'pfJetBProbabilityBJetTags', + 'pfSimpleSecondaryVertexHighEffBJetTags', + 'pfSimpleSecondaryVertexHighPurBJetTags', + 'pfCombinedSecondaryVertexV2BJetTags', + 'pfCombinedInclusiveSecondaryVertexV2BJetTags', + 'pfCombinedMVAV2BJetTags' + ] + if bTagDiscriminators is '': bTagDiscriminators = defaultBTagDiscriminators + if subjetBTagDiscriminators is '': subjetBTagDiscriminators = defaultBTagDiscriminators + mod["PATJetsLabel"] = jetALGO+'PF'+PUMethod mod["PATJetsLabelPost"] = mod["PATJetsLabel"]+postFix # some substructure quantities don't include the 'PF' in the name mod["SubstructureLabel"] = jetALGO+PUMethod+postFix if not updateCollection: - ## b-tag discriminators - if bTagDiscriminators is None: - bTagDiscriminators = [ - 'pfTrackCountingHighEffBJetTags', - 'pfTrackCountingHighPurBJetTags', - 'pfJetProbabilityBJetTags', - 'pfJetBProbabilityBJetTags', - 'pfSimpleSecondaryVertexHighEffBJetTags', - 'pfSimpleSecondaryVertexHighPurBJetTags', - 'pfCombinedSecondaryVertexV2BJetTags', - 'pfCombinedInclusiveSecondaryVertexV2BJetTags', - 'pfCombinedMVAV2BJetTags' - ] - mod["GenJetsNoNu"] = jetalgo+'GenJetsNoNu' #### For MiniAOD if miniAOD: @@ -372,7 +376,6 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, mod["PATJetsCorrFactors"] = 'patJetCorrFactors'+mod["PATJetsLabelPost"] getattr( proc, mod["PATJetsCorrFactors"] ).payload = JETCorrPayload getattr( proc, mod["PATJetsCorrFactors"] ).levels = JETCorrLevels - if bTagDiscriminators and verbosity>=2: print('|---- jetToolBox: Adding these bTagDiscriminators: '+str(bTagDiscriminators)+' in the jet collection.') patJets = 'updatedPatJets' patSubJets = '' mod["PATJets"] = patJets+mod["PATJetsLabelPost"] @@ -392,19 +395,22 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, fatJets = cms.InputTag( updateCollection ), rParam = jetSize, algo = jetALGO, - btagDiscriminators = bTagDiscriminators, + btagDiscriminators = subjetBTagDiscriminators, ) mod["PATSubjetsCorrFactors"] = 'patJetCorrFactors'+mod["PATSubjetsLabel"] getattr( proc, mod["PATSubjetsCorrFactors"] ).payload = subJETCorrPayload getattr( proc, mod["PATSubjetsCorrFactors"] ).levels = subJETCorrLevels patSubJets = 'updatedPatJets'+mod["PATSubjetsLabel"] - if bTagDiscriminators and verbosity>=2: print('|---- jetToolBox: Adding these bTagDiscriminators: '+str(bTagDiscriminators)+' in the subjet collection.') if addPrunedSubjets or addSoftDropSubjets or addCMSTopTagger or addMassDrop or addHEPTopTagger or addPruning or addSoftDrop: if verbosity>=1: print('|---- jetToolBox: You are trying to add a groomer variable into a clustered jet collection. THIS IS NOT RECOMMENDED, it is recommended to recluster jets instead using a plain jetToolbox configuration. Please use this feature at your own risk.') mod["PFJetsOrUpdate"] = mod["PFJets"] if not updateCollection else updateCollection + if bTagDiscriminators and verbosity>=2: print('|---- jetToolBox: Adding these btag discriminators: '+str(bTagDiscriminators)+' in the jet collection.') + if ( (addPrunedSubjets or addSoftDropSubjets) or (updateCollection and updateCollectionSubjets) ) and subjetBTagDiscriminators and verbosity>=2: + print('|---- jetToolBox: Adding these btag discriminators: '+str(subjetBTagDiscriminators)+' in the subjet collection.') + #### Groomers if addSoftDrop or addSoftDropSubjets: @@ -486,7 +492,7 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, svSource = cms.InputTag( svLabel ), muSource = cms.InputTag( muLabel ), elSource = cms.InputTag( elLabel ), - btagDiscriminators = bTagDiscriminators, + btagDiscriminators = subjetBTagDiscriminators, btagInfos = bTagInfos, genJetCollection = cms.InputTag( mod["GenJetsNoNuSoftDrop"],'SubJets'), getJetMCFlavour = GetSubjetMCFlavour, @@ -607,7 +613,7 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, elSource = cms.InputTag( elLabel ), getJetMCFlavour = GetSubjetMCFlavour, genParticles = cms.InputTag(genParticlesLabel), - btagDiscriminators = bTagDiscriminators, + btagDiscriminators = subjetBTagDiscriminators, btagInfos = bTagInfos, genJetCollection = cms.InputTag( mod["GenJetsNoNuPruned"],'SubJets'), explicitJTA = True, # needed for subjet b tagging From 2bd2fbc34bc662a198b9b5d9c600cf49407b69f9 Mon Sep 17 00:00:00 2001 From: Kevin Pedro Date: Fri, 4 May 2018 10:44:44 -0500 Subject: [PATCH 7/8] tweak initial printout --- python/jetToolbox_cff.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/jetToolbox_cff.py b/python/jetToolbox_cff.py index ac4db45af93..874f9c2aef6 100644 --- a/python/jetToolbox_cff.py +++ b/python/jetToolbox_cff.py @@ -64,7 +64,7 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, ############################################################################### ####### Verifying some inputs and defining variables ############################################################################### - if verbosity>=2: print('|---- jetToolbox: Initializing collection...') + if verbosity>=1: print('|---- jetToolbox: Initializing collection... (with postfix '+postFix+')') if newPFCollection and verbosity>=2: print('|---- jetToolBox: Using '+ nameNewPFCollection +' as PFCandidates collection') supportedJetAlgos = { 'ak': 'AntiKt', 'ca' : 'CambridgeAachen', 'kt' : 'Kt' } recommendedJetAlgos = [ 'ak4', 'ak8', 'ca4', 'ca8', 'ca10', 'ca15' ] From c88b26381de1f6d4efaf455464b3db38800d554e Mon Sep 17 00:00:00 2001 From: Kevin Pedro Date: Fri, 4 May 2018 10:50:42 -0500 Subject: [PATCH 8/8] option to disable task association and default root file creation --- python/jetToolbox_cff.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/python/jetToolbox_cff.py b/python/jetToolbox_cff.py index 874f9c2aef6..6db544ea0a1 100644 --- a/python/jetToolbox_cff.py +++ b/python/jetToolbox_cff.py @@ -52,6 +52,9 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, addQGTagger=False, QGjetsLabel='chs', addEnergyCorrFunc=False, addEnergyCorrFuncSubjets=False, + # set this to false to disable creation of jettoolbox.root + # then you need to associate the jetTask to a Path or EndPath manually in your config + associateTask=True, # 0 = no printouts, 1 = warnings only, 2 = warnings & info, 3 = warnings, info, debug verbosity=2, ): @@ -1066,19 +1069,19 @@ def jetToolbox( proc, jetType, jetSequence, outputFile, outputCommands = cms.untracked.vstring( elemToKeep ) ) ) ##### (Temporary?) fix to replace unschedule mode - if hasattr(proc, 'myTask'): - getattr( proc, 'myTask', cms.Task() ).add(*[getattr(proc,prod) for prod in proc.producers_()]) - getattr( proc, 'myTask', cms.Task() ).add(*[getattr(proc,filt) for filt in proc.filters_()]) + if hasattr(proc, 'jetTask'): + getattr( proc, 'jetTask', cms.Task() ).add(*[getattr(proc,prod) for prod in proc.producers_()]) + getattr( proc, 'jetTask', cms.Task() ).add(*[getattr(proc,filt) for filt in proc.filters_()]) else: - setattr( proc, 'myTask', cms.Task() ) - getattr( proc, 'myTask', cms.Task() ).add(*[getattr(proc,prod) for prod in proc.producers_()]) - getattr( proc, 'myTask', cms.Task() ).add(*[getattr(proc,filt) for filt in proc.filters_()]) - - if hasattr(proc, 'endpath'): - getattr( proc, 'endpath').associate( getattr( proc, 'myTask', cms.Task() ) ) - else: - setattr( proc, 'endpath', - cms.EndPath(getattr(proc, outputFile), getattr( proc, 'myTask', cms.Task() )) ) + setattr( proc, 'jetTask', cms.Task() ) + getattr( proc, 'jetTask', cms.Task() ).add(*[getattr(proc,prod) for prod in proc.producers_()]) + getattr( proc, 'jetTask', cms.Task() ).add(*[getattr(proc,filt) for filt in proc.filters_()]) + + if associateTask: + if hasattr(proc, 'endpath'): + getattr( proc, 'endpath').associate( getattr( proc, 'jetTask', cms.Task() ) ) + else: + setattr( proc, 'endpath', cms.EndPath(getattr(proc, outputFile), getattr( proc, 'jetTask', cms.Task() )) ) #### removing mc matching for data if runOnData: