CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes | Static Private Attributes
jetTools.AddJetCollection Class Reference
Inheritance diagram for jetTools.AddJetCollection:

Public Member Functions

def __call__
 
def __init__
 
def getDefaultParameters
 
def toolCode
 

Private Attributes

 _comment
 
 _parameters
 

Static Private Attributes

tuple _defaultParameters = dicttypes.SortedKeysDict()
 
string _label = 'addJetCollection'
 

Detailed Description

Add a new collection of jets. Takes the configuration from the
already configured standard jet collection as starting point;
replaces before calling addJetCollection will also affect the
new jet collections

Definition at line 501 of file jetTools.py.

Constructor & Destructor Documentation

def jetTools.AddJetCollection.__init__ (   self)

Definition at line 511 of file jetTools.py.

References electronTools.AddElectronUserIsolation._defaultParameters, editorTools.UserCodeTool._defaultParameters, heavyIonTools.ConfigureHeavyIons._defaultParameters, coreTools.RestrictInputToAOD._defaultParameters, cmsswVersionTools.Run52xOn51xTrigger._defaultParameters, Vispa.Plugins.ConfigEditor.ToolDataAccessor.ImportTool._defaultParameters, heavyIonTools.ProductionDefaults._defaultParameters, editorTools.ChangeSource._defaultParameters, coreTools.RunOnData._defaultParameters, cmsswVersionTools.PickRelValInputFiles._defaultParameters, coreTools.RemoveMCMatching._defaultParameters, heavyIonTools.SelectionDefaults._defaultParameters, heavyIonTools.DisbaleMonteCarloDeps._defaultParameters, jetTools.RunBTagging._defaultParameters, coreTools.RemoveAllPATObjectsBut._defaultParameters, coreTools.RemoveSpecificPATObjects._defaultParameters, coreTools.RemoveCleaning._defaultParameters, coreTools.AddCleaning._defaultParameters, jetTools.AddJetCollection._defaultParameters, ConfigToolBase.ConfigToolBase._defaultValue, GenObject.GenObject._defaultValue, root::helper::RootFunctionAdapter< F, args >.addParameter(), root::helper::RootFunctionHelper< F, args, Tag >.addParameter(), ParameterMgr.addParameter(), fit::RootMinuit< Function >.addParameter(), DropBoxMetadata::Parameters.addParameter(), PythonParameterSet.addParameter(), LutXml.addParameter(), ConfigToolBase.ConfigToolBase.addParameter(), and edm::ParameterSet.addParameter().

512  def __init__(self):
513  ConfigToolBase.__init__(self)
514  self.addParameter(self._defaultParameters,'jetCollection',self._defaultValue,'Input jet collection', cms.InputTag)
515  self.addParameter(self._defaultParameters,'algoLabel',self._defaultValue, "label to indicate the jet algorithm (e.g.'AK5')",str)
516  self.addParameter(self._defaultParameters,'typeLabel',self._defaultValue, "label to indicate the type of constituents (e.g. 'Calo', 'Pflow', 'Jpt', ...)",str)
517  self.addParameter(self._defaultParameters,'btagInfo',_defaultBTagInfos,"input btag info",allowedValues=_allowedBTagInfos,Type=list)
518  self.addParameter(self._defaultParameters,'btagdiscriminators',_defaultBTagDiscriminators,"input btag discriminators",allowedValues=_allowedBTagDiscriminators,Type=list)
519  self.addParameter(self._defaultParameters,'doJTA',True, "run b tagging sequence for new jet collection and add it to the new pat jet collection")
520  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)')
521  self.addParameter(self._defaultParameters,'jetCorrLabel',None, "payload and list of new jet correction labels, such as (\'AK5Calo\',[\'L2Relative\', \'L3Absolute\'])", tuple,acceptNoneValue=True )
522  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 colllection; at the moment it must be 'False' for non CaloJets otherwise the JetMET POG module crashes. ")
523  self.addParameter(self._defaultParameters,'doL1Cleaning',True, "copy also the producer modules for cleanLayer1 will be set to 'True' automatically when doL1Counters is 'True'")
524  self.addParameter(self._defaultParameters,'doL1Counters',False, "copy also the filter modules that accept/reject the event looking at the number of jets")
525  self.addParameter(self._defaultParameters,'rParam', 0.5, "Jet size (distance parameter R used in jet clustering)")
526  self.addParameter(self._defaultParameters,'getJetMCFlavour', True, "Get jet MC truth flavour")
527  self.addParameter(self._defaultParameters,'useLegacyFlavour', True, "Use legacy jet MC truth flavour")
528  self.addParameter(self._defaultParameters,'genJetCollection',cms.InputTag("ak5GenJets"), "GenJet collection to match to")
529  self.addParameter(self._defaultParameters,'doJetID',True, "add jetId variables to the added jet collection?")
530  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")
531  self.addParameter(self._defaultParameters,'standardAlgo',"AK5", "standard algorithm label of the collection from which the clones for the new jet collection will be taken from (note that this jet collection has to be available in the event before hand)")
532  self.addParameter(self._defaultParameters,'standardType',"Calo", "standard constituent type label of the collection from which the clones for the new jet collection will be taken from (note that this jet collection has to be available in the event before hand)")
533  self.addParameter(self._defaultParameters,'outputModules', ['out'], "output module labels, empty list of label indicates no output, default: ['out']")
535  self._parameters=copy.deepcopy(self._defaultParameters)
536  self._comment = ""

Member Function Documentation

def jetTools.AddJetCollection.__call__ (   self,
  process,
  jetCollection = None,
  algoLabel = None,
  typeLabel = None,
  doJTA = None,
  doBTagging = None,
  jetCorrLabel = None,
  doType1MET = None,
  doL1Cleaning = None,
  doL1Counters = None,
  rParam = None,
  getJetMCFlavour = None,
  useLegacyFlavour = None,
  genJetCollection = None,
  doJetID = None,
  jetIdLabel = None,
  outputModule = None,
  outputModules = None,
  btagInfo = None,
  btagdiscriminators = None 
)

Definition at line 561 of file jetTools.py.

References electronTools.AddElectronUserIsolation._defaultParameters, editorTools.UserCodeTool._defaultParameters, heavyIonTools.ConfigureHeavyIons._defaultParameters, coreTools.RestrictInputToAOD._defaultParameters, cmsswVersionTools.Run52xOn51xTrigger._defaultParameters, Vispa.Plugins.ConfigEditor.ToolDataAccessor.ImportTool._defaultParameters, heavyIonTools.ProductionDefaults._defaultParameters, editorTools.ChangeSource._defaultParameters, coreTools.RunOnData._defaultParameters, cmsswVersionTools.PickRelValInputFiles._defaultParameters, coreTools.RemoveMCMatching._defaultParameters, heavyIonTools.SelectionDefaults._defaultParameters, heavyIonTools.DisbaleMonteCarloDeps._defaultParameters, jetTools.RunBTagging._defaultParameters, coreTools.RemoveAllPATObjectsBut._defaultParameters, coreTools.RemoveSpecificPATObjects._defaultParameters, coreTools.RemoveCleaning._defaultParameters, coreTools.AddCleaning._defaultParameters, jetTools.AddJetCollection._defaultParameters, SignedImpactParameter3D.apply(), gen::PhotosInterfaceBase.apply(), SignedTransverseImpactParameter.apply(), SignedDecayLength3D.apply(), SurveyParameters.apply(), FWPSetCellEditor.apply(), gen::PhotosInterface.apply(), gen::PhotosInterface53XLegacy.apply(), cmsswVersionTools.Run52xOn51xTrigger.apply(), FWGUIEventFilter.apply(), DeviationsFromFileSensor2D.apply(), BeamSpotAlignmentParameters.apply(), RigidBodyAlignmentParameters.apply(), ConfigToolBase.ConfigToolBase.apply(), AlignmentParameters.apply(), BowedSurfaceAlignmentParameters.apply(), Vispa.Plugins.ConfigEditor.ToolDataAccessor.ImportTool.apply(), Vispa.Plugins.ConfigEditor.ToolDataAccessor.ApplyTool.apply(), TwoBowedSurfacesAlignmentParameters.apply(), Vispa.Gui.BoxContentDialog.BoxContentDialog.apply(), reco::modules::TrackerTrackHitFilter::Rule.apply(), Vispa.Plugins.ConfigEditor.ToolDialog.ToolDialog.apply(), reco::Add< T >.apply(), reco::Sub< T >.apply(), reco::Mul< T >.apply(), reco::Div< T >.apply(), reco::And< bool >.apply(), reco::Or< bool >.apply(), reco::Less< T >.apply(), cmsswVersionTools.PickRelValInputFiles.apply(), reco::LessEqual< T >.apply(), reco::More< T >.apply(), reco::MoreEqual< T >.apply(), reco::Equal< T >.apply(), jetTools.RunBTagging.apply(), jetTools.deprecatedOptionOutputModule(), ora::OraMainTable.setParameter(), ora::IMainTable.setParameter(), PedeReader.setParameter(), ora::PoolMainTable.setParameter(), fit::RootMinuit< Function >.setParameter(), and ConfigToolBase.ConfigToolBase.setParameter().

Referenced by jetTools.AddJetCollection.getDefaultParameters().

562  ):
563 
564  ## stop processing if 'outputModule' exists and show the new alternative
565  if not outputModule is None:
567  if jetCollection is None:
568  jetCollection=self._defaultParameters['jetCollection'].value
569  if algoLabel is None:
570  algoLabel=self._defaultParameters['algoLabel'].value
571  if typeLabel is None:
572  typeLabel=self._defaultParameters['typeLabel'].value
573  if doJTA is None:
574  doJTA=self._defaultParameters['doJTA'].value
575  if doBTagging is None:
576  doBTagging=self._defaultParameters['doBTagging'].value
577  if jetCorrLabel is None:
578  jetCorrLabel=self._defaultParameters['jetCorrLabel'].value
579  if doType1MET is None:
580  doType1MET=self._defaultParameters['doType1MET'].value
581  if doL1Cleaning is None:
582  doL1Cleaning=self._defaultParameters['doL1Cleaning'].value
583  if doL1Counters is None:
584  doL1Counters=self._defaultParameters['doL1Counters'].value
585  if rParam is None:
586  rParam=self._defaultParameters['rParam'].value
587  if getJetMCFlavour is None:
588  getJetMCFlavour=self._defaultParameters['getJetMCFlavour'].value
589  if useLegacyFlavour is None:
590  useLegacyFlavour=self._defaultParameters['useLegacyFlavour'].value
591  if genJetCollection is None:
592  genJetCollection=self._defaultParameters['genJetCollection'].value
593  if doJetID is None:
594  doJetID=self._defaultParameters['doJetID'].value
595  if jetIdLabel is None:
596  jetIdLabel=self._defaultParameters['jetIdLabel'].value
597  if outputModules is None:
598  outputModules=self._defaultParameters['outputModules'].value
599  if btagInfo is None:
600  btagInfo=self._defaultParameters['btagInfo'].value
601  if btagdiscriminators is None:
602  btagdiscriminators=self._defaultParameters['btagdiscriminators'].value
603 
604  self.setParameter('jetCollection',jetCollection)
605  self.setParameter('algoLabel',algoLabel)
606  self.setParameter('typeLabel',typeLabel)
607  self.setParameter('doJTA',doJTA)
608  self.setParameter('doBTagging',doBTagging)
609  self.setParameter('jetCorrLabel',jetCorrLabel)
610  self.setParameter('doType1MET',doType1MET)
611  self.setParameter('doL1Cleaning',doL1Cleaning)
612  self.setParameter('doL1Counters',doL1Counters)
613  self.setParameter('rParam',rParam)
614  self.setParameter('getJetMCFlavour',getJetMCFlavour)
615  self.setParameter('useLegacyFlavour',useLegacyFlavour)
616  self.setParameter('genJetCollection',genJetCollection)
617  self.setParameter('doJetID',doJetID)
618  self.setParameter('jetIdLabel',jetIdLabel)
619  self.setParameter('outputModules',outputModules)
620  self.setParameter('btagInfo',btagInfo)
621  self.setParameter('btagdiscriminators',btagdiscriminators)
622 
623  self.apply(process)
def deprecatedOptionOutputModule
Definition: jetTools.py:1512
def jetTools.AddJetCollection.getDefaultParameters (   self)

Definition at line 537 of file jetTools.py.

References jetTools.AddJetCollection.__call__(), electronTools.AddElectronUserIsolation._defaultParameters, editorTools.UserCodeTool._defaultParameters, heavyIonTools.ConfigureHeavyIons._defaultParameters, coreTools.RestrictInputToAOD._defaultParameters, cmsswVersionTools.Run52xOn51xTrigger._defaultParameters, Vispa.Plugins.ConfigEditor.ToolDataAccessor.ImportTool._defaultParameters, heavyIonTools.ProductionDefaults._defaultParameters, editorTools.ChangeSource._defaultParameters, coreTools.RunOnData._defaultParameters, cmsswVersionTools.PickRelValInputFiles._defaultParameters, coreTools.RemoveMCMatching._defaultParameters, heavyIonTools.SelectionDefaults._defaultParameters, heavyIonTools.DisbaleMonteCarloDeps._defaultParameters, jetTools.RunBTagging._defaultParameters, coreTools.RemoveAllPATObjectsBut._defaultParameters, coreTools.RemoveSpecificPATObjects._defaultParameters, coreTools.RemoveCleaning._defaultParameters, coreTools.AddCleaning._defaultParameters, and jetTools.AddJetCollection._defaultParameters.

Referenced by trigTools.SwitchOnTrigger.toolCode(), trigTools.SwitchOnTriggerStandAlone.toolCode(), trigTools.SwitchOnTriggerMatching.toolCode(), and trigTools.SwitchOnTriggerMatchingStandAlone.toolCode().

538  def getDefaultParameters(self):
539  return self._defaultParameters
def jetTools.AddJetCollection.toolCode (   self,
  process 
)

Definition at line 624 of file jetTools.py.

References editorTools.UserCodeTool._parameters, electronTools.AddElectronUserIsolation._parameters, heavyIonTools.ConfigureHeavyIons._parameters, coreTools.RestrictInputToAOD._parameters, Vispa.Plugins.ConfigEditor.ConfigDataAccessor.ConfigFolder._parameters, cmsswVersionTools.Run52xOn51xTrigger._parameters, Vispa.Plugins.ConfigEditor.ToolDataAccessor.ImportTool._parameters, heavyIonTools.ProductionDefaults._parameters, ConfigToolBase.ConfigToolBase._parameters, editorTools.ChangeSource._parameters, TAbsFitConstraint._parameters, TAbsFitParticle._parameters, coreTools.RunOnData._parameters, cmsswVersionTools.PickRelValInputFiles._parameters, coreTools.RemoveMCMatching._parameters, heavyIonTools.SelectionDefaults._parameters, heavyIonTools.DisbaleMonteCarloDeps._parameters, jetTools.RunBTagging._parameters, coreTools.RemoveAllPATObjectsBut._parameters, coreTools.RemoveSpecificPATObjects._parameters, coreTools.RemoveCleaning._parameters, coreTools.AddCleaning._parameters, jetTools.AddJetCollection._parameters, clone(), spr.find(), if(), helpers.jetCollectionString(), python.rootplot.root2matplotlib.replace(), and jetTools.unsupportedJetAlgorithm().

625  def toolCode(self, process):
626 
627  jetCollection=self._parameters['jetCollection'].value
628  algoLabel=self._parameters['algoLabel'].value
629  typeLabel=self._parameters['typeLabel'].value
630  doJTA=self._parameters['doJTA'].value
631  doBTagging=self._parameters['doBTagging'].value
632  jetCorrLabel=self._parameters['jetCorrLabel'].value
633  doType1MET =self._parameters['doType1MET'].value
634  doL1Cleaning=self._parameters['doL1Cleaning'].value
635  doL1Counters=self._parameters['doL1Counters'].value
636  rParam=self._parameters['rParam'].value
637  getJetMCFlavour=self._parameters['getJetMCFlavour'].value
638  useLegacyFlavour=self._parameters['useLegacyFlavour'].value
639  genJetCollection=self._parameters['genJetCollection'].value
640  doJetID=self._parameters['doJetID'].value
641  jetIdLabel=self._parameters['jetIdLabel'].value
642  outputModules=self._parameters['outputModules'].value
643  btagInfo=self._parameters['btagInfo'].value
644  btagdiscriminators=self._parameters['btagdiscriminators'].value
645 
646  _algo=''
647  if not useLegacyFlavour:
648  ## supported algo types are ak, ca, and kt
649  for x in ["ak", "ca", "kt"]:
650  if algoLabel.lower().find(x)>-1:
651  _algo=supportedJetAlgos[x]
652  break
653  if _algo=='':
655 
656  ## create old module label from standardAlgo
657  ## and standardType and return
658  def oldLabel(prefix=''):
659  return jetCollectionString(prefix, '', '')
660 
661  ## create new module label from old module
662  ## label and return
663  def newLabel(oldLabel):
664  newLabel=oldLabel
665  oldLabel=oldLabel+algoLabel+typeLabel
666  return oldLabel
667 
668  ## clone module and add it to the patDefaultSequence
669  def addClone(hook, **replaceStatements):
670  ## create a clone of the hook with corresponding
671  ## parameter replacements
672  newModule = getattr(process, hook).clone(**replaceStatements)
673  ## add the module to the sequence
674  addModuleToSequence(hook, newModule)
675 
676  ## add module to the patDefaultSequence
677  def addModuleToSequence(hook, newModule):
678  hookModule = getattr(process, hook)
679  ## add the new module with standardAlgo &
680  ## standardType replaced in module label
681  setattr( process, newLabel(hook), newModule)
682  ## add new module to default sequence
683  ## just behind the hookModule
684  process.patDefaultSequence.replace( hookModule, hookModule*newModule )
685 
686  ## add a clone of patJets
687  addClone(oldLabel(), jetSource = jetCollection)
688  ## add a clone of selectedPatJets
689  addClone(oldLabel('selected'), src=cms.InputTag(newLabel(oldLabel())))
690  ## add a clone of cleanPatJets
691  if( doL1Cleaning ):
692  addClone(oldLabel('clean'), src=cms.InputTag(newLabel(oldLabel('selected'))))
693  ## add a clone of countPatJets
694  if( doL1Counters ):
695  if( doL1Cleaning ):
696  addClone(oldLabel('count'), src=cms.InputTag(newLabel(oldLabel('clean'))))
697  else:
698  addClone(oldLabel('count'), src=cms.InputTag(newLabel(oldLabel('selected'))))
699 
700  ## get attributes of new module
701  l1Jets = getattr(process, newLabel(oldLabel()))
702 
703  ## add a clone of gen jet matching
704  addClone('patJetPartonMatch', src = jetCollection)
705  addClone('patJetGenJetMatch', src = jetCollection, matched = genJetCollection)
706 
707  if (getJetMCFlavour):
708  l1Jets.getJetMCFlavour = True
709  l1Jets.useLegacyJetMCFlavour = useLegacyFlavour
710  if useLegacyFlavour:
711  ## legacy jet flavour (see https://twiki.cern.ch/twiki/bin/view/CMSPublic/SWGuideBTagMCTools)
712  ## add a clone of parton and flavour associations
713  addClone('patJetPartonAssociationLegacy', jets = jetCollection)
714  addClone('patJetFlavourAssociationLegacy', srcByReference = cms.InputTag(newLabel('patJetPartonAssociationLegacy')))
715  else:
716  ## new jet flavour (see https://twiki.cern.ch/twiki/bin/view/CMSPublic/SWGuideBTagMCTools)
717  from PhysicsTools.PatAlgos.mcMatchLayer0.jetFlavourId_cff import patJetFlavourAssociation
718  setattr(process, newLabel("patJetFlavourAssociation"), patJetFlavourAssociation.clone(jets=jetCollection, jetAlgorithm=_algo, rParam=rParam) )
719  getattr(process, "patDefaultSequence").replace( getattr(process, "patJetPartons"),
720  getattr(process, "patJetPartons")
721  + getattr(process, newLabel("patJetFlavourAssociation") ) #module that is not in patDefaultSequence
722  )
723  else:
724  l1Jets.getJetMCFlavour = False
725 
726  ## fix label for input tag
727  def fixInputTag(x): x.setModuleLabel(newLabel(x.moduleLabel))
728  ## fix label for vector of input tags
729  def fixVInputTag(x): x[0].setModuleLabel(newLabel(x[0].moduleLabel))
730 
731  ## provide allLayer1Jet inputs with individual labels
732  fixInputTag(l1Jets.genJetMatch)
733  fixInputTag(l1Jets.genPartonMatch)
734  fixInputTag(l1Jets.JetPartonMapSource)
735  fixInputTag(l1Jets.JetFlavourInfoSource)
736 
737  ## make VInputTag from strings
738  def vit(*args) : return cms.VInputTag( *[ cms.InputTag(x) for x in args ] )
739 
740  if (doJTA or doBTagging):
741  ## add clone of jet track association
742  ###process.load("RecoJets.JetAssociationProducers.ak5JTA_cff")
743  from RecoJets.JetAssociationProducers.ak5JTA_cff import ak5JetTracksAssociatorAtVertex
744  ## add jet track association module to processes
745  jtaLabel = 'jetTracksAssociatorAtVertex'+algoLabel+typeLabel
746  setattr( process, jtaLabel, ak5JetTracksAssociatorAtVertex.clone(jets = jetCollection) )
747  process.patDefaultSequence.replace(process.patJetCharge, getattr(process,jtaLabel)+process.patJetCharge)
748  l1Jets.trackAssociationSource = cms.InputTag(jtaLabel)
749  addClone('patJetCharge', src=cms.InputTag(jtaLabel)),
750  fixInputTag(l1Jets.jetChargeSource)
751  else:
752  ## switch embedding of track association and jet
753  ## charge estimate to 'False'
754  l1Jets.addAssociatedTracks = False
755  l1Jets.addJetCharge = False
756 
757  if (doBTagging):
758  ## define postfixLabel
759  postfixLabel=algoLabel+typeLabel
760  ## add b tagging sequence
761  (btagSeq, btagLabels) = runBTagging(process, jetCollection, postfixLabel,"", btagInfo,btagdiscriminators)
762  ## add b tagging sequence before running the allLayer1Jets modules
763  ## nedded only after first call to runBTagging(), existing sequence modified in place otherwise
764  if not btagSeq == None:
765  process.patDefaultSequence.replace(getattr(process,jtaLabel), getattr(process,jtaLabel)+btagSeq)
766  ## replace corresponding tags for pat jet production
767  l1Jets.trackAssociationSource = cms.InputTag(btagLabels['jta'])
768  l1Jets.tagInfoSources = cms.VInputTag( *[ cms.InputTag(x) for x in btagLabels['tagInfos'] ] )
769  l1Jets.discriminatorSources = cms.VInputTag( *[ cms.InputTag(x) for x in btagLabels['jetTags'] ] )
770  ## switch general b tagging info switch on
771  l1Jets.addBTagInfo = True
772  else:
773  ## switch general b tagging info switch off
774  l1Jets.addBTagInfo = False
775  ## adjust output
776  if len(outputModules) > 0:
777  for outMod in outputModules:
778  if hasattr(process,outMod):
779  getattr(process,outMod).outputCommands.append("drop *_"+newLabel(oldLabel('selected'))+"_tagInfos_*")
780  else:
781  raise KeyError, "process has no OutModule named", outMod
782 
783  if (doJetID):
784  l1Jets.addJetID = cms.bool(True)
785  jetIdLabelNew = jetIdLabel + 'JetID'
786  l1Jets.jetIDMap = cms.InputTag( jetIdLabelNew )
787  else :
788  l1Jets.addJetID = cms.bool(False)
789 
790  if (jetCorrLabel != None):
791  ## add clone of jet energy corrections;
792  ## catch a couple of exceptions first
793  if (jetCorrLabel == False ):
794  raise ValueError, "In addJetCollection 'jetCorrLabel' must be set to 'None', not 'False'"
795  if (jetCorrLabel == "None"):
796  raise ValueError, "In addJetCollection 'jetCorrLabel' must be set to 'None' (without quotes)"
797  ## check for the correct format
798  if type(jetCorrLabel) != type(('AK5Calo',['L2Relative'])):
799  raise ValueError, "In addJetCollection 'jetCorrLabel' must be 'None', or of type ('payload',['correction1', 'correction2'])"
800 
801  ## add clone of jetCorrFactors
802  addClone('patJetCorrFactors', src = jetCollection)
803  switchJetCorrLevels(process, jetCorrLabel = jetCorrLabel, postfix=algoLabel+typeLabel)
804  getattr(process, newLabel('patJets')).jetCorrFactorsSource = cms.VInputTag( cms.InputTag(newLabel('patJetCorrFactors')) )
805 
806  ## find out type of jet collection, switch type1MET corrections off for JPTJets
807  jetCollType = ''
808  if ( 'CaloJets' in jetCollection.getModuleLabel() ):
809  jetCollType = 'Calo'
810  elif ( 'PFJets' in jetCollection.getModuleLabel() or jetCollection.getModuleLabel().startswith('pfNo') or jetCollection.getModuleLabel() == 'particleFlow'):
811  jetCollType = 'PF'
812  else:
813  print '============================================='
814  print 'Type1MET corrections are switched off for '
815  print 'JPT Jets. Users are recommened to use tcMET '
816  print 'together with JPT jets. '
817  print '============================================='
818  doType1MET=False
819 
820  ## add a clone of the type1MET correction for the new jet collection
821  if (doType1MET):
822  ## create jet correctors for MET corrections
823  from JetMETCorrections.Configuration.JetCorrectionServicesAllAlgos_cff import ak5PFL1Fastjet, ak5PFL1Offset, ak5PFL2Relative, ak5PFL3Absolute, ak5PFResidual
824  setattr(process, jetCorrLabel[0]+'L1FastJet' , ak5PFL1Fastjet.clone ( algorithm=jetCorrLabel[0]
825  , srcRho=cms.InputTag(newLabel('kt6' + jetCollType + 'Jets'),'rho') ) )
826  setattr(process, jetCorrLabel[0]+'L1Offset' , ak5PFL1Offset.clone ( algorithm=jetCorrLabel[0] ) )
827  setattr(process, jetCorrLabel[0]+'L2Relative' , ak5PFL2Relative.clone( algorithm=jetCorrLabel[0] ) )
828  setattr(process, jetCorrLabel[0]+'L3Absolute' , ak5PFL3Absolute.clone( algorithm=jetCorrLabel[0] ) )
829  setattr(process, jetCorrLabel[0]+'L2L3Residual', ak5PFResidual.clone ( algorithm=jetCorrLabel[0] ) )
830  ## combinded corrections
831  setattr(process, jetCorrLabel[0]+'CombinedCorrector', cms.ESProducer( 'JetCorrectionESChain'
832  , correctors = cms.vstring() ) )
833 
834  for corrLbl in jetCorrLabel[1]:
835  if corrLbl != 'L1FastJet' and corrLbl != 'L1Offset' and corrLbl != 'L2Relative' and corrLbl != 'L3Absolute' and corrLbl != 'L2L3Residual':
836  print '========================================='
837  print ' Type1MET corrections are currently only '
838  print ' supported for the following corrections: '
839  print ' - L1FastJet'
840  print ' - L1Offset'
841  print ' - L2Relative'
842  print ' - L3Absolute'
843  print ' - L2L3Residual'
844  print ' But given was:'
845  print ' -', corrLbl
846  print '============================================='
847  raise ValueError, 'unsupported JEC for TypeI MET correction: '+corrLbl
848  else:
849  getattr(process, jetCorrLabel[0]+'CombinedCorrector').correctors.append(jetCorrLabel[0]+corrLbl)
850 
851  ## configuration of MET corrections
852  if jetCollType == 'Calo':
853  from JetMETCorrections.Type1MET.caloMETCorrections_cff import caloJetMETcorr,caloType1CorrectedMet,caloType1p2CorrectedMet,produceCaloMETCorrections
854 
855  setattr(process,jetCorrLabel[0]+'JetMETcorr', caloJetMETcorr.clone(srcMET = "corMetGlobalMuons"))
856  setattr(process,jetCorrLabel[0]+'Type1CorMet', caloType1CorrectedMet.clone(src = "corMetGlobalMuons"))
857  setattr(process,jetCorrLabel[0]+'Type1p2CorMet',caloType1p2CorrectedMet.clone(src = "corMetGlobalMuons"))
858 
859  getattr(process,jetCorrLabel[0]+'JetMETcorr' ).src = cms.InputTag(jetCollection.getModuleLabel())
860  if ('L1FastJet' in jetCorrLabel[1] or 'L1Fastjet' in jetCorrLabel[1]):
861  getattr(process,jetCorrLabel[0]+'JetMETcorr' ).offsetCorrLabel = cms.string(jetCorrLabel[0]+'L1FastJet')
862  elif ('L1Offset' in jetCorrLabel[1]):
863  getattr(process,jetCorrLabel[0]+'JetMETcorr' ).offsetCorrLabel = cms.string(jetCorrLabel[0]+'L1Offset')
864  else:
865  getattr(process,jetCorrLabel[0]+'JetMETcorr' ).offsetCorrLabel = cms.string('')
866  getattr(process,jetCorrLabel[0]+'JetMETcorr' ).jetCorrLabel = cms.string(jetCorrLabel[0]+'CombinedCorrector')
867 
868  getattr(process,jetCorrLabel[0]+'Type1CorMet' ).srcType1Corrections = cms.VInputTag(
869  cms.InputTag(jetCorrLabel[0]+'JetMETcorr', 'type1')
870  )
871 
872  getattr(process,jetCorrLabel[0]+'Type1p2CorMet').srcType1Corrections = cms.VInputTag(
873  cms.InputTag(jetCorrLabel[0]+'JetMETcorr', 'type1')
874  )
875  getattr(process,jetCorrLabel[0]+'Type1p2CorMet').srcUnclEnergySums = cms.VInputTag(
876  cms.InputTag(jetCorrLabel[0]+'JetMETcorr', 'type2'),
877  cms.InputTag(jetCorrLabel[0]+'JetMETcorr', 'offset'),
878  cms.InputTag('muonCaloMETcorr')
879  )
880 
881  ## add MET corrections to sequence
882  setattr(process,'patMETs'+jetCorrLabel[0],getattr(process,'patMETs').clone(metSource = cms.InputTag(jetCorrLabel[0]+'Type1CorMet'),addMuonCorrections = False))
883 
884  setattr(process,'produce'+jetCorrLabel[0]+'METCorrections',produceCaloMETCorrections.copy())
885  getattr(process,'produce'+jetCorrLabel[0]+'METCorrections').replace(getattr(process,'caloJetMETcorr'), getattr(process,jetCorrLabel[0]+'JetMETcorr'))
886  getattr(process,'produce'+jetCorrLabel[0]+'METCorrections').replace(getattr(process,'caloType1CorrectedMet'), getattr(process,jetCorrLabel[0]+'Type1CorMet'))
887  getattr(process,'produce'+jetCorrLabel[0]+'METCorrections').replace(getattr(process,'caloType1p2CorrectedMet'),getattr(process,jetCorrLabel[0]+'Type1p2CorMet'))
888 
889  process.patDefaultSequence.replace( getattr(process,'patMETs'+jetCorrLabel[0]),
890  getattr(process,'produce'+jetCorrLabel[0]+'METCorrections')
891  *getattr(process,'patMETs'+jetCorrLabel[0]))
892 
893  elif jetCollType == 'PF':
894  from JetMETCorrections.Type1MET.pfMETCorrections_cff import pfCandsNotInJet,pfJetMETcorr,pfCandMETcorr,pfType1CorrectedMet,pfType1p2CorrectedMet,producePFMETCorrections
895  setattr(process,jetCorrLabel[0]+'CandsNotInJet',pfCandsNotInJet.clone(topCollection = jetCollection))
896  setattr(process,jetCorrLabel[0]+'JetMETcorr', pfJetMETcorr.clone(src = jetCollection))
897  setattr(process,jetCorrLabel[0]+'CandMETcorr', pfCandMETcorr.clone(src = cms.InputTag(jetCorrLabel[0]+'CandsNotInJet')))
898  setattr(process,jetCorrLabel[0]+'Type1CorMet', pfType1CorrectedMet.clone())
899  setattr(process,jetCorrLabel[0]+'Type1p2CorMet',pfType1p2CorrectedMet.clone())
900 
901  if ('L1FastJet' in jetCorrLabel[1] or 'L1Fastjet' in jetCorrLabel[1]):
902  getattr(process,jetCorrLabel[0]+'JetMETcorr' ).offsetCorrLabel = cms.string(jetCorrLabel[0]+'L1FastJet')
903  elif ('L1Offset' in jetCorrLabel[1]):
904  getattr(process,jetCorrLabel[0]+'JetMETcorr' ).offsetCorrLabel = cms.string(jetCorrLabel[0]+'L1Offset')
905  else:
906  getattr(process,jetCorrLabel[0]+'JetMETcorr' ).offsetCorrLabel = cms.string('')
907  getattr(process,jetCorrLabel[0]+'JetMETcorr').jetCorrLabel = cms.string(jetCorrLabel[0]+'CombinedCorrector')
908 
909  getattr(process,jetCorrLabel[0]+'Type1CorMet').applyType0Corrections = cms.bool(False)
910  getattr(process,jetCorrLabel[0]+'Type1CorMet').srcType1Corrections = cms.VInputTag(
911  cms.InputTag(jetCorrLabel[0]+'JetMETcorr', 'type1')
912  )
913  getattr(process,jetCorrLabel[0]+'Type1p2CorMet').srcType1Corrections = cms.VInputTag(
914  cms.InputTag(jetCorrLabel[0]+'JetMETcorr', 'type1')
915  )
916  getattr(process,jetCorrLabel[0]+'Type1p2CorMet').applyType0Corrections = cms.bool(False)
917  getattr(process,jetCorrLabel[0]+'Type1p2CorMet').srcUnclEnergySums = cms.VInputTag(
918  cms.InputTag(jetCorrLabel[0]+'JetMETcorr', 'type2'),
919  cms.InputTag(jetCorrLabel[0]+'JetMETcorr', 'offset'),
920  cms.InputTag(jetCorrLabel[0]+'CandMETcorr')
921  )
922 
923  ## add MET corrections to sequence
924  setattr(process,'patMETs'+jetCorrLabel[0],getattr(process,'patMETs').clone(metSource = cms.InputTag(jetCorrLabel[0]+'Type1CorMet'),addMuonCorrections = False))
925 
926  setattr(process,'produce'+jetCorrLabel[0]+'METCorrections',producePFMETCorrections.copy())
927  getattr(process,'produce'+jetCorrLabel[0]+'METCorrections').replace(getattr(process,'pfCandsNotInJet'), getattr(process,jetCorrLabel[0]+'CandsNotInJet'))
928  getattr(process,'produce'+jetCorrLabel[0]+'METCorrections').replace(getattr(process,'pfJetMETcorr'), getattr(process,jetCorrLabel[0]+'JetMETcorr'))
929  getattr(process,'produce'+jetCorrLabel[0]+'METCorrections').replace(getattr(process,'pfCandMETcorr'), getattr(process,jetCorrLabel[0]+'CandMETcorr'))
930  getattr(process,'produce'+jetCorrLabel[0]+'METCorrections').replace(getattr(process,'pfType1CorrectedMet'), getattr(process,jetCorrLabel[0]+'Type1CorMet'))
931  getattr(process,'produce'+jetCorrLabel[0]+'METCorrections').replace(getattr(process,'pfType1p2CorrectedMet'),getattr(process,jetCorrLabel[0]+'Type1p2CorMet'))
932 
933  process.patDefaultSequence.replace( getattr(process,'patMETs'+jetCorrLabel[0]),
934  getattr(process,'produce'+jetCorrLabel[0]+'METCorrections')
935  *getattr(process,'patMETs'+jetCorrLabel[0]))
936 
937  else:
938  ## switch jetCorrFactors off
939  l1Jets.addJetCorrFactors = False
940 
941 addJetCollection=AddJetCollection()
942 
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
def jetCollectionString
Definition: helpers.py:222
____________________________________________________________________________||
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
def unsupportedJetAlgorithm
Definition: jetTools.py:1523
perl if(1 lt scalar(@::datatypes))
Definition: edlooper.cc:31
____________________________________________________________________________||

Member Data Documentation

jetTools.AddJetCollection._comment
private

Definition at line 535 of file jetTools.py.

Referenced by metUncertaintyTools.RunMEtUncertainties.__init__().

tuple jetTools.AddJetCollection._defaultParameters = dicttypes.SortedKeysDict()
staticprivate

Definition at line 509 of file jetTools.py.

Referenced by photonTools.AddPhotonUserIsolation.__call__(), metTools.AddTcMET.__call__(), muonTools.AddMuonUserIsolation.__call__(), HiCoreTools.RestrictInputToAOD.__call__(), trackTools.MakeAODTrackCandidates.__call__(), metTools.AddPfMET.__call__(), HiCoreTools.RemoveMCMatching.__call__(), trackTools.MakePATTrackCandidates.__call__(), trigTools.SwitchOnTrigger.__call__(), HiCoreTools.RemoveAllPATObjectsBut.__call__(), HiCoreTools.RemoveSpecificPATObjects.__call__(), trigTools.SwitchOnTriggerStandAlone.__call__(), trackTools.MakeTrackCandidates.__call__(), HiCoreTools.RemoveCleaning.__call__(), trigTools.SwitchOnTriggerMatching.__call__(), HiCoreTools.AddCleaning.__call__(), tauTools.AddTauCollection.__call__(), trigTools.SwitchOnTriggerMatchingStandAlone.__call__(), jetTools.AddJetCollection.__call__(), trigTools.SwitchOnTriggerMatchEmbedding.__call__(), trigTools.RemoveCleaningFromTriggerMatching.__call__(), jetTools.SwitchJetCollection.__call__(), jetTools.AddJetID.__call__(), metUncertaintyTools.RunMEtUncertainties.__call__(), jetTools.SetTagInfos.__call__(), jetTools.SwitchJetCorrLevels.__call__(), photonTools.AddPhotonUserIsolation.__init__(), trackTools.MakeAODTrackCandidates.__init__(), metTools.AddTcMET.__init__(), muonTools.AddMuonUserIsolation.__init__(), HiCoreTools.RestrictInputToAOD.__init__(), metUncertaintyTools.RunMEtUncertainties.__init__(), HiCoreTools.RemoveMCMatching.__init__(), metTools.AddPfMET.__init__(), trackTools.MakePATTrackCandidates.__init__(), trigTools.SwitchOnTrigger.__init__(), HiCoreTools.RemoveAllPATObjectsBut.__init__(), HiCoreTools.RemoveSpecificPATObjects.__init__(), trigTools.SwitchOnTriggerStandAlone.__init__(), trackTools.MakeTrackCandidates.__init__(), HiCoreTools.RemoveCleaning.__init__(), trigTools.SwitchOnTriggerMatching.__init__(), HiCoreTools.AddCleaning.__init__(), tauTools.AddTauCollection.__init__(), trigTools.SwitchOnTriggerMatchingStandAlone.__init__(), jetTools.AddJetCollection.__init__(), trigTools.SwitchOnTriggerMatchEmbedding.__init__(), trigTools.RemoveCleaningFromTriggerMatching.__init__(), jetTools.SwitchJetCollection.__init__(), jetTools.AddJetID.__init__(), jetTools.SetTagInfos.__init__(), jetTools.SwitchJetCorrLevels.__init__(), metUncertaintyTools.RunMEtUncertainties._initializeInputTag(), ConfigToolBase.ConfigToolBase.dumpPython(), ConfigToolBase.ConfigToolBase.getAllowedValues(), photonTools.AddPhotonUserIsolation.getDefaultParameters(), metTools.AddTcMET.getDefaultParameters(), muonTools.AddMuonUserIsolation.getDefaultParameters(), HiCoreTools.RestrictInputToAOD.getDefaultParameters(), trackTools.MakeAODTrackCandidates.getDefaultParameters(), metTools.AddPfMET.getDefaultParameters(), HiCoreTools.RemoveMCMatching.getDefaultParameters(), metUncertaintyTools.RunMEtUncertainties.getDefaultParameters(), trackTools.MakePATTrackCandidates.getDefaultParameters(), trigTools.SwitchOnTrigger.getDefaultParameters(), HiCoreTools.RemoveAllPATObjectsBut.getDefaultParameters(), HiCoreTools.RemoveSpecificPATObjects.getDefaultParameters(), trigTools.SwitchOnTriggerStandAlone.getDefaultParameters(), trackTools.MakeTrackCandidates.getDefaultParameters(), HiCoreTools.RemoveCleaning.getDefaultParameters(), trigTools.SwitchOnTriggerMatching.getDefaultParameters(), HiCoreTools.AddCleaning.getDefaultParameters(), tauTools.AddTauCollection.getDefaultParameters(), trigTools.SwitchOnTriggerMatchingStandAlone.getDefaultParameters(), jetTools.AddJetCollection.getDefaultParameters(), trigTools.SwitchOnTriggerMatchEmbedding.getDefaultParameters(), trigTools.RemoveCleaningFromTriggerMatching.getDefaultParameters(), jetTools.SwitchJetCollection.getDefaultParameters(), jetTools.AddJetID.getDefaultParameters(), jetTools.SetTagInfos.getDefaultParameters(), jetTools.SwitchJetCorrLevels.getDefaultParameters(), ConfigToolBase.ConfigToolBase.reset(), and ConfigToolBase.ConfigToolBase.setParameter().

string jetTools.AddJetCollection._label = 'addJetCollection'
staticprivate

Definition at line 508 of file jetTools.py.

Referenced by trigTools.SwitchOnTrigger.toolCode(), trigTools.SwitchOnTriggerStandAlone.toolCode(), trigTools.SwitchOnTriggerMatching.toolCode(), trigTools.SwitchOnTriggerMatchingStandAlone.toolCode(), trigTools.SwitchOnTriggerMatchEmbedding.toolCode(), and trigTools.RemoveCleaningFromTriggerMatching.toolCode().

jetTools.AddJetCollection._parameters
private

Definition at line 534 of file jetTools.py.

Referenced by metUncertaintyTools.RunMEtUncertainties.__init__(), photonTools.AddPhotonUserIsolation.toolCode(), muonTools.AddMuonUserIsolation.toolCode(), metTools.AddTcMET.toolCode(), HiCoreTools.RestrictInputToAOD.toolCode(), trackTools.MakeAODTrackCandidates.toolCode(), metTools.AddPfMET.toolCode(), HiCoreTools.RemoveMCMatching.toolCode(), trackTools.MakePATTrackCandidates.toolCode(), trigTools.SwitchOnTrigger.toolCode(), HiCoreTools.RemoveAllPATObjectsBut.toolCode(), HiCoreTools.RemoveSpecificPATObjects.toolCode(), trigTools.SwitchOnTriggerStandAlone.toolCode(), trackTools.MakeTrackCandidates.toolCode(), HiCoreTools.RemoveCleaning.toolCode(), trigTools.SwitchOnTriggerMatching.toolCode(), HiCoreTools.AddCleaning.toolCode(), tauTools.AddTauCollection.toolCode(), trigTools.SwitchOnTriggerMatchingStandAlone.toolCode(), jetTools.AddJetCollection.toolCode(), trigTools.SwitchOnTriggerMatchEmbedding.toolCode(), trigTools.RemoveCleaningFromTriggerMatching.toolCode(), jetTools.SwitchJetCollection.toolCode(), jetTools.AddJetID.toolCode(), jetTools.SetTagInfos.toolCode(), jetTools.SwitchJetCorrLevels.toolCode(), and metUncertaintyTools.RunMEtUncertainties.toolCode().