![]() |
![]() |
Inherits FWCore::GuiBrowsers::ConfigToolBase::ConfigToolBase.
Public Member Functions | |
def | __call__ |
def | __init__ |
def | getDefaultParameters |
def | toolCode |
Private Attributes | |
_comment | |
_parameters | |
Static Private Attributes | |
tuple | _defaultParameters = dicttypes.SortedKeysDict() |
string | _label = 'switchJetCollection35X' |
------------------------------------------------------------------ Switch the collection of jets in PAT from the default value to a new jet collection. This is a re-implementation to run the 36X version of PAT on 35X input samples. ------------------------------------------------------------------
Definition at line 558 of file cmsswVersionTools.py.
def cmsswVersionTools::SwitchJetCollection35X::__init__ | ( | self | ) |
Definition at line 569 of file cmsswVersionTools.py.
00570 : 00571 ConfigToolBase.__init__(self) 00572 self.addParameter(self._defaultParameters,'jetCollection',self._defaultValue,'Input jet collection', cms.InputTag) 00573 self.addParameter(self._defaultParameters,'doJTA',True, "run b tagging sequence for new jet collection and add it to the new pat jet collection") 00574 self.addParameter(self._defaultParameters,'doBTagging',True, 'run JetTracksAssociation and JetCharge and add it to the new pat jet collection (will autom. be true if doBTagging is set to true)') 00575 self.addParameter(self._defaultParameters,'jetCorrLabel',None, "algorithm and type of JEC; use 'None' for no JEC; examples are ('AK5','Calo'), ('SC7','Calo'), ('KT4','PF')", tuple,acceptNoneValue=True) 00576 self.addParameter(self._defaultParameters,'doType1MET',True, "if jetCorrLabel is not 'None', set this to 'True' to redo the Type1 MET correction for the new jet colleection; at the moment it must be 'False' for non CaloJets otherwise the JetMET POG module crashes. ") 00577 self.addParameter(self._defaultParameters,'genJetCollection',cms.InputTag("ak5GenJets"), "GenJet collection to match to") 00578 self.addParameter(self._defaultParameters,'doJetID',True, "add jetId variables to the added jet collection") 00579 self.addParameter(self._defaultParameters,'jetIdLabel',"ak5", " specify the label prefix of the xxxJetID object; in general it is the jet collection tag like ak5, kt4 sc5, aso. For more information have a look to SWGuidePATTools#add_JetCollection") 00580 self.addParameter(self._defaultParameters,'postfix',"", "postfix of default sequence") 00581 00582 self._parameters=copy.deepcopy(self._defaultParameters) 00583 self._comment = ""
def cmsswVersionTools::SwitchJetCollection35X::__call__ | ( | self, | |
process, | |||
jetCollection = None , |
|||
doJTA = None , |
|||
doBTagging = None , |
|||
jetCorrLabel = None , |
|||
doType1MET = None , |
|||
genJetCollection = None , |
|||
doJetID = None , |
|||
jetIdLabel = None , |
|||
postfix = None |
|||
) |
Definition at line 587 of file cmsswVersionTools.py.
00597 : 00598 00599 if jetCollection is None: 00600 jetCollection=self._defaultParameters['jetCollection'].value 00601 if doJTA is None: 00602 doJTA=self._defaultParameters['doJTA'].value 00603 if doBTagging is None: 00604 doBTagging=self._defaultParameters['doBTagging'].value 00605 if jetCorrLabel is None: 00606 jetCorrLabel=self._defaultParameters['jetCorrLabel'].value 00607 if doType1MET is None: 00608 doType1MET=self._defaultParameters['doType1MET'].value 00609 if genJetCollection is None: 00610 genJetCollection=self._defaultParameters['genJetCollection'].value 00611 if doJetID is None: 00612 doJetID=self._defaultParameters['doJetID'].value 00613 if jetIdLabel is None: 00614 jetIdLabel=self._defaultParameters['jetIdLabel'].value 00615 if postfix is None: 00616 postfix=self._defaultParameters['postfix'].value 00617 00618 self.setParameter('jetCollection',jetCollection) 00619 self.setParameter('doJTA',doJTA) 00620 self.setParameter('doBTagging',doBTagging) 00621 self.setParameter('jetCorrLabel',jetCorrLabel) 00622 self.setParameter('doType1MET',doType1MET) 00623 self.setParameter('genJetCollection',genJetCollection) 00624 self.setParameter('doJetID',doJetID) 00625 self.setParameter('jetIdLabel',jetIdLabel) 00626 self.setParameter('postfix',postfix) 00627 00628 self.apply(process)
def cmsswVersionTools::SwitchJetCollection35X::getDefaultParameters | ( | self | ) |
Definition at line 584 of file cmsswVersionTools.py.
def cmsswVersionTools::SwitchJetCollection35X::toolCode | ( | self, | |
process | |||
) |
Definition at line 629 of file cmsswVersionTools.py.
00630 : 00631 jetCollection=self._parameters['jetCollection'].value 00632 doJTA=self._parameters['doJTA'].value 00633 doBTagging=self._parameters['doBTagging'].value 00634 jetCorrLabel=self._parameters['jetCorrLabel'].value 00635 doType1MET =self._parameters['doType1MET'].value 00636 genJetCollection=self._parameters['genJetCollection'].value 00637 doJetID=self._parameters['doJetID'].value 00638 jetIdLabel=self._parameters['jetIdLabel'].value 00639 postfix=self._parameters['postfix'].value 00640 00641 00642 ## save label of old input jet collection 00643 oldLabel = applyPostfix(process, "patJets", postfix).jetSource; 00644 00645 ## replace input jet collection for generator matches 00646 applyPostfix(process, "patJetPartonMatch", postfix).src = jetCollection 00647 applyPostfix(process, "patJetGenJetMatch", postfix).src = jetCollection 00648 applyPostfix(process, "patJetGenJetMatch", postfix).matched = genJetCollection 00649 applyPostfix(process, "patJetPartonAssociation", postfix).jets = jetCollection 00650 ## replace input jet collection for pat jet production 00651 applyPostfix(process, "patJets", postfix).jetSource = jetCollection 00652 00653 ## make VInputTag from strings 00654 def vit(*args) : return cms.VInputTag( *[ cms.InputTag(x) for x in args ] ) 00655 00656 if (doJTA or doBTagging): 00657 ## replace jet track association 00658 process.load("RecoJets.JetAssociationProducers.ak5JTA_cff") 00659 from RecoJets.JetAssociationProducers.ak5JTA_cff import ak5JetTracksAssociatorAtVertex 00660 setattr(process, "jetTracksAssociatorAtVertex"+postfix, ak5JetTracksAssociatorAtVertex.clone(jets = jetCollection)) 00661 getattr(process, "patDefaultSequence"+postfix).replace( 00662 applyPostfix(process, "patJetCharge", postfix), 00663 getattr(process, "jetTracksAssociatorAtVertex" + postfix) #module with postfix that is not n patDefaultSequence 00664 + applyPostfix(process, "patJetCharge", postfix) 00665 ) 00666 00667 applyPostfix(process, "patJetCharge", postfix).src = 'jetTracksAssociatorAtVertex'+postfix 00668 applyPostfix(process, "patJets", postfix).trackAssociationSource = 'jetTracksAssociatorAtVertex'+postfix 00669 else: 00670 ## remove the jet track association from the std 00671 ## sequence 00672 removeIfInSequence(process, "patJetCharge", "patDefaultSequence", postfix) 00673 ## switch embedding of track association and jet 00674 ## charge estimate to 'False' 00675 applyPostfix(process, "patJets", postfix).addAssociatedTracks = False 00676 applyPostfix(process, "patJets", postfix).addJetCharge = False 00677 00678 if (doBTagging): 00679 ## replace b tagging sequence; add postfix label 'AOD' as crab will 00680 ## crash when confronted with empy labels 00681 (btagSeq, btagLabels) = runBTagging35X(process, jetCollection, 'AOD',postfix) 00682 ## add b tagging sequence before running the allLayer1Jets modules 00683 getattr(process, "patDefaultSequence"+postfix).replace( 00684 getattr( process,"jetTracksAssociatorAtVertex"+postfix), 00685 getattr( process,"jetTracksAssociatorAtVertex"+postfix) + btagSeq 00686 ) 00687 00688 ## replace corresponding tags for pat jet production 00689 applyPostfix(process, "patJets", postfix).trackAssociationSource = btagLabels['jta'] 00690 applyPostfix(process, "patJets", postfix).tagInfoSources = cms.VInputTag( *[ cms.InputTag(x) for x in btagLabels['tagInfos'] ] ) 00691 applyPostfix(process, "patJets", postfix).discriminatorSources = cms.VInputTag( *[ cms.InputTag(x) for x in btagLabels['jetTags'] ] ) 00692 else: 00693 ## remove b tagging from the std sequence 00694 removeIfInSequence(process, "secondaryVertexNegativeTagInfos", "patDefaultSequence", postfix) 00695 removeIfInSequence(process, "simpleSecondaryVertexNegativeBJetTags", "patDefaultSequence", postfix) 00696 00697 ## switch embedding of b tagging for pat 00698 ## jet production to 'False' 00699 applyPostfix(process, "patJets", postfix).addBTagInfo = False 00700 00701 if (doJetID): 00702 jetIdLabelNew = jetIdLabel + 'JetID' 00703 applyPostfix(process, "patJets", postfix).jetIDMap = cms.InputTag( jetIdLabelNew ) 00704 else: 00705 applyPostfix(process, "patJets", postfix).addJetID = cms.bool(False) 00706 00707 00708 if (jetCorrLabel!=None): 00709 ## replace jet energy corrections; catch 00710 ## a couple of exceptions first 00711 if (jetCorrLabel == False ): 00712 raise ValueError, "In switchJetCollection 'jetCorrLabel' must be set to 'None', not 'False'" 00713 if (jetCorrLabel == "None"): 00714 raise ValueError, "In switchJetCollection 'jetCorrLabel' must be set to 'None' (without quotes)" 00715 ## check for the correct format 00716 if (type(jetCorrLabel)!=type(('AK5','Calo'))): 00717 raise ValueError, "In switchJetCollection 'jetCorrLabel' must be 'None', or of type ('Algo','Type')" 00718 00719 ## switch JEC parameters to the new jet collection 00720 applyPostfix(process, "patJetCorrFactors", postfix).jetSource = jetCollection 00721 switchJECParameters(applyPostfix(process, "patJetCorrFactors", postfix), jetCorrLabel[0], jetCorrLabel[1], oldAlgo='AK5',oldType='Calo') 00722 00723 ## switch type1MET corrections off for PFJets 00724 if( jetCollection.__str__().find('PFJets')>=0 ): 00725 print '=================================================' 00726 print 'Type1MET corrections are switched off for PFJets.' 00727 print 'of type %s%s.' % (jetCorrLabel[0].swapcase(), jetCorrLabel[1]) 00728 print 'Users are recommened to use pfMET together with ' 00729 print 'PFJets.' 00730 print '=================================================' 00731 doType1MET=False 00732 00733 ## redo the type1MET correction for the new jet collection 00734 if (doType1MET): 00735 ## in case there is no jet correction service in the paths add it 00736 ## as L2L3 if possible, as combined from L2 and L3 otherwise 00737 if not hasattr( process, '%s%sL2L3' % (jetCorrLabel[0].swapcase(), jetCorrLabel[1]) ): 00738 setattr( process, '%s%sL2L3' % (jetCorrLabel[0].swapcase(), jetCorrLabel[1]), 00739 cms.ESSource("JetCorrectionServiceChain", 00740 correctors = cms.vstring('%s%sL2Relative' % (jetCorrLabel[0].swapcase(), jetCorrLabel[1]), 00741 '%s%sL3Absolute' % (jetCorrLabel[0].swapcase(), jetCorrLabel[1]) 00742 ) 00743 ) 00744 ) 00745 ## configure the type1MET correction the following muonMET 00746 ## corrections have the metJESCorAK5CaloJet as input and 00747 ## are automatically correct 00748 applyPostfix(process, "metJESCorAK5CaloJet", postfix).inputUncorJetsLabel = jetCollection.value() 00749 applyPostfix(process, "metJESCorAK5CaloJet", postfix).corrector = '%s%sL2L3' % (jetCorrLabel[0].swapcase(), jetCorrLabel[1]) 00750 else: 00751 ## remove the jetCorrFactors from the std sequence 00752 process.patJetMETCorrections.remove(process.patJetCorrFactors) 00753 ## switch embedding of jetCorrFactors off 00754 ## for pat jet production 00755 applyPostfix(process, "patJets", postfix).addJetCorrFactors = False 00756 00757 00758 switchJetCollection35X=SwitchJetCollection35X() 00759
Definition at line 569 of file cmsswVersionTools.py.
tuple cmsswVersionTools::SwitchJetCollection35X::_defaultParameters = dicttypes.SortedKeysDict() [static, private] |
Definition at line 568 of file cmsswVersionTools.py.
string cmsswVersionTools::SwitchJetCollection35X::_label = 'switchJetCollection35X' [static, private] |
Definition at line 567 of file cmsswVersionTools.py.
Definition at line 569 of file cmsswVersionTools.py.