CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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
 add comments More...
 
 _parameters
 initialization of the base class More...
 

Static Private Attributes

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

Detailed Description

Tool to add a new jet collection to your PAT Tuple or to modify an existing one.

Definition at line 905 of file jetTools.py.

Constructor & Destructor Documentation

def jetTools.AddJetCollection.__init__ (   self)
Initialize elements of the class. Note that the tool needs to be derived from ConfigToolBase to be usable in the configEditor.

Definition at line 912 of file jetTools.py.

References heavyIonTools.ConfigureHeavyIons._defaultParameters, coreTools.RunOnData._defaultParameters, heavyIonTools.ProductionDefaults._defaultParameters, cmsswVersionTools.PickRelValInputFiles._defaultParameters, coreTools.RemoveMCMatching._defaultParameters, heavyIonTools.SelectionDefaults._defaultParameters, heavyIonTools.DisbaleMonteCarloDeps._defaultParameters, jetTools.AddJetCollection._defaultParameters, root::helper::RootFunctionAdapter< F, args >.addParameter(), root::helper::RootFunctionHelper< F, args, Tag >.addParameter(), ParameterMgr.addParameter(), fit::RootMinuit< Function >.addParameter(), DropBoxMetadata::Parameters.addParameter(), Python11ParameterSet.addParameter(), l1t::TriggerSystem.addParameter(), LutXml.addParameter(), ConfigToolBase.ConfigToolBase.addParameter(), and edm::ParameterSet.addParameter().

913  def __init__(self):
914  """
915  Initialize elements of the class. Note that the tool needs to be derived from ConfigToolBase to be usable in the configEditor.
916  """
917  ## initialization of the base class
918  ConfigToolBase.__init__(self)
919  ## add all parameters that should be known to the class
920  self.addParameter(self._defaultParameters,'labelName', 'UNDEFINED', "Label name of the new patJet collection.", str)
921  self.addParameter(self._defaultParameters,'postfix','', "Postfix from usePF2PAT.", str)
922  self.addParameter(self._defaultParameters,'btagPrefix','', "Prefix to be added to b-tag discriminator and TagInfo names", str)
923  self.addParameter(self._defaultParameters,'jetSource','', "Label of the input collection from which the new patJet collection should be created", cms.InputTag)
924  self.addParameter(self._defaultParameters,'pfCandidates',cms.InputTag('particleFlow'), "Label of the input collection for candidatecandidatese used in b-tagging", cms.InputTag)
925  self.addParameter(self._defaultParameters,'explicitJTA', False, "Use explicit jet-track association")
926  self.addParameter(self._defaultParameters,'pvSource',cms.InputTag('offlinePrimaryVertices'), "Label of the input collection for primary vertices used in b-tagging", cms.InputTag)
927  self.addParameter(self._defaultParameters,'svSource',cms.InputTag('inclusiveCandidateSecondaryVertices'), "Label of the input collection for IVF vertices used in b-tagging", cms.InputTag)
928  self.addParameter(self._defaultParameters,'elSource',cms.InputTag('gedGsfElectrons'), "Label of the input collection for electrons used in b-tagging", cms.InputTag)
929  self.addParameter(self._defaultParameters,'muSource',cms.InputTag('muons'), "Label of the input collection for muons used in b-tagging", cms.InputTag)
930  self.addParameter(self._defaultParameters,'runIVF', False, "Re-run IVF secondary vertex reconstruction")
931  self.addParameter(self._defaultParameters,'tightBTagNTkHits', False, "Enable legacy tight b-tag track selection")
932  self.addParameter(self._defaultParameters,'loadStdRecoBTag', False, "Load the standard reconstruction b-tagging modules")
933  self.addParameter(self._defaultParameters,'svClustering', False, "Secondary vertices ghost-associated to jets using jet clustering (mostly intended for subjets)")
934  self.addParameter(self._defaultParameters,'fatJets', cms.InputTag(''), "Fat jet collection used for secondary vertex clustering", cms.InputTag)
935  self.addParameter(self._defaultParameters,'groomedFatJets', cms.InputTag(''), "Groomed fat jet collection used for secondary vertex clustering", cms.InputTag)
936  self.addParameter(self._defaultParameters,'algo', 'AK', "Jet algorithm of the input collection from which the new patJet collection should be created")
937  self.addParameter(self._defaultParameters,'rParam', 0.4, "Jet size (distance parameter R used in jet clustering)")
938  self.addParameter(self._defaultParameters,'getJetMCFlavour', True, "Get jet MC truth flavour")
939  self.addParameter(self._defaultParameters,'genJetCollection', cms.InputTag("ak4GenJets"), "GenJet collection to match to", cms.InputTag)
940  self.addParameter(self._defaultParameters,'genParticles', cms.InputTag("genParticles"), "GenParticle collection to be used", cms.InputTag)
941  self.addParameter(self._defaultParameters,'jetCorrections',None, "Add all relevant information about jet energy corrections that you want to be added to your new patJet \
942  collection. The format has to be given in a python tuple of type: (\'AK4Calo\',[\'L2Relative\', \'L3Absolute\'], patMet). Here the first argument corresponds to the payload \
943  in the CMS Conditions database for the given jet collection; the second argument corresponds to the jet energy correction levels that you want to be embedded into your \
944  new patJet collection. This should be given as a list of strings. Available values are L1Offset, L1FastJet, L1JPTOffset, L2Relative, L3Absolute, L5Falvour, L7Parton; the \
945  third argument indicates whether MET(Type1/2) corrections should be applied corresponding to the new patJetCollection. If so a new patMet collection will be added to your PAT \
946  Tuple in addition to the raw patMet. This new patMet collection will have the MET(Type1/2) corrections applied. The argument can have the following types: \'type-1\' for \
947  type-1 corrected MET; \'type-2\' for type-1 plus type-2 corrected MET; \'\' or \'none\' if no further MET corrections should be applied to your MET. The arguments \'type-1\' \
948  and \'type-2\' are not case sensitive.", tuple, acceptNoneValue=True)
949  self.addParameter(self._defaultParameters,'btagDiscriminators',['None'], "If you are interested in btagging, in most cases just the labels of the btag discriminators that \
950  you are interested in is all relevant information that you need for a high level analysis. Add here all btag discriminators, that you are interested in as a list of strings. \
951  If this list is empty no btag discriminator information will be added to your new patJet collection.", allowedValues=(list(set().union(supportedBtagDiscr.keys(),supportedMetaDiscr.keys()))),Type=list)
952  self.addParameter(self._defaultParameters,'btagInfos',['None'], "The btagInfos objects contain all relevant information from which all discriminators of a certain \
953  type have been calculated. You might be interested in keeping this information for low level tests or to re-calculate some discriminators from hand. Note that this information \
954  on the one hand can be very space consuming and that it is not necessary to access the pre-calculated btag discriminator information that has been derived from it. Only in very \
955  special cases the btagInfos might really be needed in your analysis. Add here all btagInfos, that you are interested in as a list of strings. If this list is empty no btagInfos \
956  will be added to your new patJet collection.", allowedValues=supportedBtagInfos,Type=list)
957  self.addParameter(self._defaultParameters,'jetTrackAssociation',False, "Add JetTrackAssociation and JetCharge from reconstructed tracks to your new patJet collection. This \
958  switch is only of relevance if you don\'t add any btag information to your new patJet collection (btagDiscriminators or btagInfos) and still want this information added to \
959  your new patJetCollection. If btag information of any form is added to the new patJet collection this information will be added automatically.")
960  self.addParameter(self._defaultParameters,'outputModules',['out'],"Add a list of all output modules to which you would like the new jet collection to be added. Usually this is \
961  just one single output module with name \'out\', which corresponds also the default configuration of the tool. There is cases though where you might want to add this collection \
962  to more than one output module.")
963  ## set defaults
964  self._parameters=copy.deepcopy(self._defaultParameters)
965  ## add comments
966  self._comment = "This is a tool to add more patJet collectinos to your PAT Tuple or to re-configure the default collection. You can add and embed additional information like jet\
967  energy correction factors, btag information and generator match information to the new patJet collection depending on the parameters that you pass on to this function. Consult \
968  the descriptions of each parameter for more information."
_parameters
initialization of the base class
Definition: jetTools.py:963
_comment
add comments
Definition: jetTools.py:965

Member Function Documentation

def jetTools.AddJetCollection.__call__ (   self,
  process,
  labelName = None,
  postfix = None,
  btagPrefix = None,
  jetSource = None,
  pfCandidates = None,
  explicitJTA = None,
  pvSource = None,
  svSource = None,
  elSource = None,
  muSource = None,
  runIVF = None,
  tightBTagNTkHits = None,
  loadStdRecoBTag = None,
  svClustering = None,
  fatJets = None,
  groomedFatJets = None,
  algo = None,
  rParam = None,
  getJetMCFlavour = None,
  genJetCollection = None,
  genParticles = None,
  jetCorrections = None,
  btagDiscriminators = None,
  btagInfos = None,
  jetTrackAssociation = None,
  outputModules = None 
)
Function call wrapper. This will check the parameters and call the actual implementation that
can be found in toolCode via the base class function apply.

Definition at line 975 of file jetTools.py.

References heavyIonTools.ConfigureHeavyIons._defaultParameters, coreTools.RunOnData._defaultParameters, heavyIonTools.ProductionDefaults._defaultParameters, cmsswVersionTools.PickRelValInputFiles._defaultParameters, coreTools.RemoveMCMatching._defaultParameters, heavyIonTools.SelectionDefaults._defaultParameters, heavyIonTools.DisbaleMonteCarloDeps._defaultParameters, jetTools.AddJetCollection._defaultParameters, ProcessAcceleratorCUDA.ProcessAcceleratorCUDA.apply(), SignedImpactParameter3D.apply(), SignedDecayLength3D.apply(), SignedTransverseImpactParameter.apply(), gen::PhotosInterfaceBase.apply(), SurveyParameters.apply(), DummyOOTPileupCorrection.apply(), MatrixReader.MatrixReader.apply, gen::PhotosppInterface.apply(), gen::PhotosInterface.apply(), FWPSetCellEditor.apply(), BeamSpotAlignmentParameters.apply(), RigidBodyAlignmentParameters.apply(), DeviationsFromFileSensor2D.apply(), FWGUIEventFilter.apply(), AlignmentParameters.apply(), ConfigToolBase.ConfigToolBase.apply(), BowedSurfaceAlignmentParameters.apply(), OOTPileupCorrData.apply(), AbsOOTPileupCorrection.apply(), TwoBowedSurfacesAlignmentParameters.apply(), reco::modules::TrackerTrackHitFilter::Rule.apply(), cmsswVersionTools.PickRelValInputFiles.apply(), models.RegExp.apply(), npstat::ArrayND< Numeric, StackLen, StackDim >.apply(), npstat::ArrayND< Numeric >.apply(), Config.ProcessModifier.apply(), Config.ProcessAccelerator.apply(), Config.ProcessAcceleratorTest.apply(), Config.ProcessAcceleratorTest2.apply(), PedeReader.setParameter(), QIE8Simulator.setParameter(), AbsElectronicODERHS.setParameter(), SiStripLorentzAngleCalibration.setParameter(), SiPixelLorentzAngleCalibration.setParameter(), IntegratedCalibrationBase.setParameter(), SiStripBackplaneCalibration.setParameter(), fit::RootMinuit< Function >.setParameter(), and ConfigToolBase.ConfigToolBase.setParameter().

976  def __call__(self,process,labelName=None,postfix=None,btagPrefix=None,jetSource=None,pfCandidates=None,explicitJTA=None,pvSource=None,svSource=None,elSource=None,muSource=None,runIVF=None,tightBTagNTkHits=None,loadStdRecoBTag=None,svClustering=None,fatJets=None,groomedFatJets=None,algo=None,rParam=None,getJetMCFlavour=None,genJetCollection=None,genParticles=None,jetCorrections=None,btagDiscriminators=None,btagInfos=None,jetTrackAssociation=None,outputModules=None):
977  """
978  Function call wrapper. This will check the parameters and call the actual implementation that
979  can be found in toolCode via the base class function apply.
980  """
981  if labelName is None:
982  labelName=self._defaultParameters['labelName'].value
983  self.setParameter('labelName', labelName)
984  if postfix is None:
985  postfix=self._defaultParameters['postfix'].value
986  self.setParameter('postfix', postfix)
987  if btagPrefix is None:
988  btagPrefix=self._defaultParameters['btagPrefix'].value
989  self.setParameter('btagPrefix', btagPrefix)
990  if jetSource is None:
991  jetSource=self._defaultParameters['jetSource'].value
992  self.setParameter('jetSource', jetSource)
993  if pfCandidates is None:
994  pfCandidates=self._defaultParameters['pfCandidates'].value
995  self.setParameter('pfCandidates', pfCandidates)
996  if explicitJTA is None:
997  explicitJTA=self._defaultParameters['explicitJTA'].value
998  self.setParameter('explicitJTA', explicitJTA)
999  if pvSource is None:
1000  pvSource=self._defaultParameters['pvSource'].value
1001  self.setParameter('pvSource', pvSource)
1002  if svSource is None:
1003  svSource=self._defaultParameters['svSource'].value
1004  self.setParameter('svSource', svSource)
1005  if elSource is None:
1006  elSource=self._defaultParameters['elSource'].value
1007  self.setParameter('elSource', elSource)
1008  if muSource is None:
1009  muSource=self._defaultParameters['muSource'].value
1010  self.setParameter('muSource', muSource)
1011  if runIVF is None:
1012  runIVF=self._defaultParameters['runIVF'].value
1013  self.setParameter('runIVF', runIVF)
1014  if tightBTagNTkHits is None:
1015  tightBTagNTkHits=self._defaultParameters['tightBTagNTkHits'].value
1016  self.setParameter('tightBTagNTkHits', tightBTagNTkHits)
1017  if loadStdRecoBTag is None:
1018  loadStdRecoBTag=self._defaultParameters['loadStdRecoBTag'].value
1019  self.setParameter('loadStdRecoBTag', loadStdRecoBTag)
1020  if svClustering is None:
1021  svClustering=self._defaultParameters['svClustering'].value
1022  self.setParameter('svClustering', svClustering)
1023  if fatJets is None:
1024  fatJets=self._defaultParameters['fatJets'].value
1025  self.setParameter('fatJets', fatJets)
1026  if groomedFatJets is None:
1027  groomedFatJets=self._defaultParameters['groomedFatJets'].value
1028  self.setParameter('groomedFatJets', groomedFatJets)
1029  if algo is None:
1030  algo=self._defaultParameters['algo'].value
1031  self.setParameter('algo', algo)
1032  if rParam is None:
1033  rParam=self._defaultParameters['rParam'].value
1034  self.setParameter('rParam', rParam)
1035  if getJetMCFlavour is None:
1036  getJetMCFlavour=self._defaultParameters['getJetMCFlavour'].value
1037  self.setParameter('getJetMCFlavour', getJetMCFlavour)
1038  if genJetCollection is None:
1039  genJetCollection=self._defaultParameters['genJetCollection'].value
1040  self.setParameter('genJetCollection', genJetCollection)
1041  if genParticles is None:
1042  genParticles=self._defaultParameters['genParticles'].value
1043  self.setParameter('genParticles', genParticles)
1044  if jetCorrections is None:
1045  jetCorrections=self._defaultParameters['jetCorrections'].value
1046  self.setParameter('jetCorrections', jetCorrections)
1047  if btagDiscriminators is None:
1048  btagDiscriminators=self._defaultParameters['btagDiscriminators'].value
1049  self.setParameter('btagDiscriminators', btagDiscriminators)
1050  if btagInfos is None:
1051  btagInfos=self._defaultParameters['btagInfos'].value
1052  self.setParameter('btagInfos', btagInfos)
1053  if jetTrackAssociation is None:
1054  jetTrackAssociation=self._defaultParameters['jetTrackAssociation'].value
1055  self.setParameter('jetTrackAssociation', jetTrackAssociation)
1056  if outputModules is None:
1057  outputModules=self._defaultParameters['outputModules'].value
1058  self.setParameter('outputModules', outputModules)
1059  self.apply(process)
def jetTools.AddJetCollection.getDefaultParameters (   self)
Return default parameters of the class

Definition at line 969 of file jetTools.py.

References heavyIonTools.ConfigureHeavyIons._defaultParameters, coreTools.RunOnData._defaultParameters, heavyIonTools.ProductionDefaults._defaultParameters, cmsswVersionTools.PickRelValInputFiles._defaultParameters, coreTools.RemoveMCMatching._defaultParameters, heavyIonTools.SelectionDefaults._defaultParameters, heavyIonTools.DisbaleMonteCarloDeps._defaultParameters, and jetTools.AddJetCollection._defaultParameters.

970  def getDefaultParameters(self):
971  """
972  Return default parameters of the class
973  """
974  return self._defaultParameters
def jetTools.AddJetCollection.toolCode (   self,
  process 
)
Tool code implementation

Definition at line 1060 of file jetTools.py.

References heavyIonTools.ConfigureHeavyIons._parameters, coreTools.RunOnData._parameters, heavyIonTools.ProductionDefaults._parameters, ConfigToolBase.ConfigToolBase._parameters, TAbsFitConstraint._parameters, TAbsFitParticle._parameters, cmsswVersionTools.PickRelValInputFiles._parameters, coreTools.RemoveMCMatching._parameters, heavyIonTools.SelectionDefaults._parameters, heavyIonTools.DisbaleMonteCarloDeps._parameters, jetTools.AddJetCollection._parameters, helpers.addToProcessAndTask(), jetTools.checkJetCorrectionsFormat(), helpers.getPatAlgosToolsTask(), jetTools.setupBTagging(), jetTools.setupJetCorrections(), submitPVValidationJobs.split(), jetTools.undefinedLabelName(), and jetTools.unsupportedJetAlgorithm().

1061  def toolCode(self, process):
1062  """
1063  Tool code implementation
1064  """
1065  task = getPatAlgosToolsTask(process)
1066 
1067  ## initialize parameters
1068  labelName=self._parameters['labelName'].value
1069  postfix=self._parameters['postfix'].value
1070  btagPrefix=self._parameters['btagPrefix'].value
1071  jetSource=self._parameters['jetSource'].value
1072  pfCandidates=self._parameters['pfCandidates'].value
1073  explicitJTA=self._parameters['explicitJTA'].value
1074  pvSource=self._parameters['pvSource'].value
1075  svSource=self._parameters['svSource'].value
1076  elSource=self._parameters['elSource'].value
1077  muSource=self._parameters['muSource'].value
1078  runIVF=self._parameters['runIVF'].value
1079  tightBTagNTkHits=self._parameters['tightBTagNTkHits'].value
1080  loadStdRecoBTag=self._parameters['loadStdRecoBTag'].value
1081  svClustering=self._parameters['svClustering'].value
1082  fatJets=self._parameters['fatJets'].value
1083  groomedFatJets=self._parameters['groomedFatJets'].value
1084  algo=self._parameters['algo'].value
1085  rParam=self._parameters['rParam'].value
1086  getJetMCFlavour=self._parameters['getJetMCFlavour'].value
1087  genJetCollection=self._parameters['genJetCollection'].value
1088  genParticles=self._parameters['genParticles'].value
1089  jetCorrections=self._parameters['jetCorrections'].value
1090  btagDiscriminators=list(self._parameters['btagDiscriminators'].value)
1091  btagInfos=list(self._parameters['btagInfos'].value)
1092  jetTrackAssociation=self._parameters['jetTrackAssociation'].value
1093  outputModules=list(self._parameters['outputModules'].value)
1094 
1095  ## added jets must have a defined 'labelName'
1096  if labelName=='UNDEFINED':
1097  undefinedLabelName(self)
1098 
1099  ## a list of all producer modules, which are already known to process
1100  knownModules = process.producerNames().split()
1101  ## determine whether btagging information is required or not
1102  if btagDiscriminators.count('None')>0:
1103  btagDiscriminators.remove('None')
1104  if btagInfos.count('None')>0:
1105  btagInfos.remove('None')
1106  bTagging=(len(btagDiscriminators)>0 or len(btagInfos)>0)
1107  ## check if any legacy btag discriminators are being used
1108  infos = 0
1109  for info in btagInfos:
1110  if info.startswith('pf'): infos = infos + 1
1111  if 'softpf' in info.lower(): infos = infos + 1
1112  tags = 0
1113  for tag in btagDiscriminators:
1114  if tag.startswith('pf'): tags = tags + 1
1115  if 'softpf' in tag.lower(): tags = tags + 1
1116  bTaggingLegacy=(len(btagDiscriminators)>tags or len(btagInfos)>infos)
1117  ## construct postfix label for auxiliary modules; this postfix
1118  ## label will start with a capitalized first letter following
1119  ## the CMS naming conventions and for improved readablility
1120  _labelName=labelName[:1].upper()+labelName[1:]
1121 
1122  ## supported algo types are ak, ca, and kt
1123  _algo=''
1124  for x in ["ak", "ca", "kt"]:
1125  if x in algo.lower():
1126  _algo=supportedJetAlgos[x]
1127  break
1128  if _algo=='':
1130  ## add new patJets to process (keep instance for later further modifications)
1131  from PhysicsTools.PatAlgos.producersLayer1.jetProducer_cfi import _patJets as patJets
1132  if 'patJets'+_labelName+postfix in knownModules :
1133  _newPatJets=getattr(process, 'patJets'+_labelName+postfix)
1134  _newPatJets.jetSource=jetSource
1135  else :
1136  addToProcessAndTask('patJets'+_labelName+postfix, patJets.clone(jetSource=jetSource), process, task)
1137  _newPatJets=getattr(process, 'patJets'+_labelName+postfix)
1138  knownModules.append('patJets'+_labelName+postfix)
1139  ## add new selectedPatJets to process
1140  from PhysicsTools.PatAlgos.selectionLayer1.jetSelector_cfi import selectedPatJets
1141  if 'selectedPatJets'+_labelName+postfix in knownModules :
1142  _newSelectedPatJets=getattr(process, 'selectedPatJets'+_labelName+postfix)
1143  _newSelectedPatJets.src='patJets'+_labelName+postfix
1144  else :
1145  addToProcessAndTask('selectedPatJets'+_labelName+postfix,
1146  selectedPatJets.clone(src='patJets'+_labelName+postfix),
1147  process, task)
1148  knownModules.append('selectedPatJets'+_labelName+postfix)
1149 
1150  ## add new patJetPartonMatch to process
1151  from PhysicsTools.PatAlgos.mcMatchLayer0.jetMatch_cfi import patJetPartonMatch
1152  if 'patJetPartonMatch'+_labelName+postfix in knownModules :
1153  _newPatJetPartonMatch=getattr(process, 'patJetPartonMatch'+_labelName+postfix)
1154  _newPatJetPartonMatch.src=jetSource
1155  _newPatJetPartonMatch.matched=genParticles
1156  else :
1157  addToProcessAndTask('patJetPartonMatch'+_labelName+postfix,
1158  patJetPartonMatch.clone(src=jetSource, matched=genParticles),
1159  process, task)
1160  knownModules.append('patJetPartonMatch'+_labelName+postfix)
1161  ## add new patJetGenJetMatch to process
1162  from PhysicsTools.PatAlgos.mcMatchLayer0.jetMatch_cfi import patJetGenJetMatch
1163  if 'patJetGenJetMatch'+_labelName+postfix in knownModules :
1164  _newPatJetGenJetMatch=getattr(process, 'patJetGenJetMatch'+_labelName+postfix)
1165  _newPatJetGenJetMatch.src=jetSource
1166  _newPatJetGenJetMatch.maxDeltaR=rParam
1167  _newPatJetGenJetMatch.matched=genJetCollection
1168  else :
1169  addToProcessAndTask('patJetGenJetMatch'+_labelName+postfix,
1170  patJetGenJetMatch.clone(src=jetSource, maxDeltaR=rParam, matched=genJetCollection),
1171  process, task)
1172  knownModules.append('patJetGenJetMatch'+_labelName+postfix)
1173  ## modify new patJets collection accordingly
1174  _newPatJets.genJetMatch.setModuleLabel('patJetGenJetMatch'+_labelName+postfix)
1175  _newPatJets.genPartonMatch.setModuleLabel('patJetPartonMatch'+_labelName+postfix)
1176  ## get jet MC truth flavour if required by user
1177  if (getJetMCFlavour):
1178  ## legacy jet flavour (see https://twiki.cern.ch/twiki/bin/view/CMSPublic/SWGuideBTagMCTools)
1179  ## add new patJetPartonsLegacy to process
1180  from PhysicsTools.PatAlgos.mcMatchLayer0.jetFlavourId_cff import patJetPartonsLegacy
1181  if 'patJetPartonsLegacy'+postfix not in knownModules :
1182  addToProcessAndTask('patJetPartonsLegacy'+postfix, patJetPartonsLegacy.clone(src=genParticles),
1183  process, task)
1184  knownModules.append('patJetPartonsLegacy'+postfix)
1185  else:
1186  getattr(process, 'patJetPartonsLegacy'+postfix).src=genParticles
1187  ## add new patJetPartonAssociationLegacy to process
1188  from PhysicsTools.PatAlgos.mcMatchLayer0.jetFlavourId_cff import patJetPartonAssociationLegacy
1189  if 'patJetPartonAssociationLegacy'+_labelName+postfix in knownModules :
1190  _newPatJetPartonAssociation=getattr(process, 'patJetPartonAssociationLegacy'+_labelName+postfix)
1191  _newPatJetPartonAssociation.jets=jetSource
1192  else :
1193  addToProcessAndTask('patJetPartonAssociationLegacy'+_labelName+postfix,
1194  patJetPartonAssociationLegacy.clone(jets=jetSource), process, task)
1195  knownModules.append('patJetPartonAssociationLegacy'+_labelName+postfix)
1196  ## add new patJetPartonAssociationLegacy to process
1197  from PhysicsTools.PatAlgos.mcMatchLayer0.jetFlavourId_cff import patJetFlavourAssociationLegacy
1198  if 'patJetFlavourAssociationLegacy'+_labelName+postfix in knownModules :
1199  _newPatJetFlavourAssociation=getattr(process, 'patJetFlavourAssociationLegacy'+_labelName+postfix)
1200  _newPatJetFlavourAssociation.srcByReference='patJetPartonAssociationLegacy'+_labelName+postfix
1201  else:
1202  addToProcessAndTask('patJetFlavourAssociationLegacy'+_labelName+postfix,
1203  patJetFlavourAssociationLegacy.clone(
1204  srcByReference='patJetPartonAssociationLegacy'+_labelName+postfix),
1205  process, task)
1206  knownModules.append('patJetFlavourAssociationLegacy'+_labelName+postfix)
1207  ## modify new patJets collection accordingly
1208  _newPatJets.JetPartonMapSource.setModuleLabel('patJetFlavourAssociationLegacy'+_labelName+postfix)
1209  ## new jet flavour (see https://twiki.cern.ch/twiki/bin/view/CMSPublic/SWGuideBTagMCTools)
1210  ## add new patJetPartons to process
1212  if 'patJetPartons'+postfix not in knownModules :
1213  addToProcessAndTask('patJetPartons'+postfix, patJetPartons.clone(particles=genParticles), process, task)
1214  knownModules.append('patJetPartons'+postfix)
1215  else:
1216  getattr(process, 'patJetPartons'+postfix).particles=genParticles
1217  ## add new patJetFlavourAssociation to process
1218  from PhysicsTools.PatAlgos.mcMatchLayer0.jetFlavourId_cff import patJetFlavourAssociation
1219  if 'patJetFlavourAssociation'+_labelName+postfix in knownModules :
1220  _newPatJetFlavourAssociation=getattr(process, 'patJetFlavourAssociation'+_labelName+postfix)
1221  _newPatJetFlavourAssociation.jets=jetSource
1222  _newPatJetFlavourAssociation.jetAlgorithm=_algo
1223  _newPatJetFlavourAssociation.rParam=rParam
1224  _newPatJetFlavourAssociation.bHadrons=cms.InputTag("patJetPartons"+postfix,"bHadrons")
1225  _newPatJetFlavourAssociation.cHadrons=cms.InputTag("patJetPartons"+postfix,"cHadrons")
1226  _newPatJetFlavourAssociation.partons=cms.InputTag("patJetPartons"+postfix,"physicsPartons")
1227  _newPatJetFlavourAssociation.leptons=cms.InputTag("patJetPartons"+postfix,"leptons")
1228  else :
1229  addToProcessAndTask('patJetFlavourAssociation'+_labelName+postfix,
1230  patJetFlavourAssociation.clone(
1231  jets=jetSource,
1232  jetAlgorithm=_algo,
1233  rParam=rParam,
1234  bHadrons = cms.InputTag("patJetPartons"+postfix,"bHadrons"),
1235  cHadrons = cms.InputTag("patJetPartons"+postfix,"cHadrons"),
1236  partons = cms.InputTag("patJetPartons"+postfix,"physicsPartons"),
1237  leptons = cms.InputTag("patJetPartons"+postfix,"leptons")),
1238  process, task)
1239 
1240  knownModules.append('patJetFlavourAssociation'+_labelName+postfix)
1241  if 'Puppi' in jetSource.value() and pfCandidates.value() == 'particleFlow':
1242  _newPatJetFlavourAssociation=getattr(process, 'patJetFlavourAssociation'+_labelName+postfix)
1243  _newPatJetFlavourAssociation.weights = cms.InputTag("puppi")
1244  ## modify new patJets collection accordingly
1245  _newPatJets.JetFlavourInfoSource.setModuleLabel('patJetFlavourAssociation'+_labelName+postfix)
1246  ## if the jets is actually a subjet
1247  if fatJets != cms.InputTag('') and groomedFatJets != cms.InputTag(''):
1248  _newPatJetFlavourAssociation=getattr(process, 'patJetFlavourAssociation'+_labelName+postfix)
1249  _newPatJetFlavourAssociation.jets=fatJets
1250  _newPatJetFlavourAssociation.groomedJets=groomedFatJets
1251  _newPatJetFlavourAssociation.subjets=jetSource
1252  _newPatJets.JetFlavourInfoSource=cms.InputTag('patJetFlavourAssociation'+_labelName+postfix,'SubJets')
1253  else:
1254  _newPatJets.getJetMCFlavour = False
1255  _newPatJets.addJetFlavourInfo = False
1256 
1257  ## add jetTrackAssociation for legacy btagging (or jetTracksAssociation only) if required by user
1258  if (jetTrackAssociation or bTaggingLegacy):
1259  ## add new jetTracksAssociationAtVertex to process
1260  from RecoJets.JetAssociationProducers.ak4JTA_cff import ak4JetTracksAssociatorAtVertex, ak4JetTracksAssociatorExplicit
1261  if 'jetTracksAssociationAtVertex'+_labelName+postfix in knownModules :
1262  _newJetTracksAssociationAtVertex=getattr(process, 'jetTracksAssociatorAtVertex'+_labelName+postfix)
1263  _newJetTracksAssociationAtVertex.jets=jetSource
1264  _newJetTracksAssociationAtVertex.pvSrc=pvSource
1265  else:
1266  jetTracksAssociator=ak4JetTracksAssociatorAtVertex
1267  if explicitJTA:
1268  jetTracksAssociator=ak4JetTracksAssociatorExplicit
1269  addToProcessAndTask('jetTracksAssociatorAtVertex'+_labelName+postfix,
1270  jetTracksAssociator.clone(jets=jetSource,pvSrc=pvSource),
1271  process, task)
1272  knownModules.append('jetTracksAssociationAtVertex'+_labelName+postfix)
1273  ## add new patJetCharge to process
1275  if 'patJetCharge'+_labelName+postfix in knownModules :
1276  _newPatJetCharge=getattr(process, 'patJetCharge'+_labelName+postfix)
1277  _newPatJetCharge.src='jetTracksAssociatorAtVertex'+_labelName+postfix
1278  else:
1279  addToProcessAndTask('patJetCharge'+_labelName+postfix,
1280  patJetCharge.clone(src = 'jetTracksAssociatorAtVertex'+_labelName+postfix),
1281  process, task)
1282  knownModules.append('patJetCharge'+_labelName+postfix)
1283  ## modify new patJets collection accordingly
1284  _newPatJets.addAssociatedTracks=True
1285  _newPatJets.trackAssociationSource=cms.InputTag('jetTracksAssociatorAtVertex'+_labelName+postfix)
1286  _newPatJets.addJetCharge=True
1287  _newPatJets.jetChargeSource=cms.InputTag('patJetCharge'+_labelName+postfix)
1288  else:
1289  ## modify new patJets collection accordingly
1290  _newPatJets.addAssociatedTracks=False
1291  _newPatJets.trackAssociationSource=''
1292  _newPatJets.addJetCharge=False
1293  _newPatJets.jetChargeSource=''
1294  ## run btagging if required by user
1295  if (bTagging):
1296  setupBTagging(process, jetSource, pfCandidates, explicitJTA, pvSource, svSource, elSource, muSource, runIVF, tightBTagNTkHits, loadStdRecoBTag, svClustering, fatJets, groomedFatJets,
1297  _algo, rParam, btagDiscriminators, btagInfos, _newPatJets, _labelName, btagPrefix, postfix)
1298  else:
1299  _newPatJets.addBTagInfo = False
1300  _newPatJets.addTagInfos = False
1301  ## adjust output module; these collections will be empty anyhow, but we do it to stay clean
1302  for outputModule in outputModules:
1303  if hasattr(process,outputModule):
1304  getattr(process,outputModule).outputCommands.append("drop *_"+'selected'+_labelName+postfix+"_tagInfos_*")
1305 
1306  ## add jet correction factors if required by user
1307  if (jetCorrections != None):
1308  ## check the jet corrections format
1309  checkJetCorrectionsFormat(jetCorrections)
1310  ## setup jet energy corrections and MET corrections
1311  setupJetCorrections(process, knownModules, jetCorrections, jetSource, pvSource, _newPatJets, _labelName, postfix)
1312  else:
1313  ## switch jetCorrFactors off
1314  _newPatJets.addJetCorrFactors=False
1315 
1316 addJetCollection=AddJetCollection()
def setupJetCorrections
Definition: jetTools.py:26
def undefinedLabelName
Definition: jetTools.py:1929
def getPatAlgosToolsTask
Definition: helpers.py:13
_parameters
initialization of the base class
Definition: jetTools.py:963
def setupBTagging
Definition: jetTools.py:239
def checkJetCorrectionsFormat
Definition: jetTools.py:18
def unsupportedJetAlgorithm
Definition: jetTools.py:1936
def addToProcessAndTask
Definition: helpers.py:28

Member Data Documentation

jetTools.AddJetCollection._comment
private

add comments

Definition at line 965 of file jetTools.py.

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

Definition at line 910 of file jetTools.py.

Referenced by trackTools.MakeAODTrackCandidates.__call__(), runJetUncertainties.RunJetUncertainties.__call__(), metTools.AddMETCollection.__call__(), trackTools.MakePATTrackCandidates.__call__(), trigTools.SwitchOnTrigger.__call__(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.__call__(), trigTools.SwitchOnTriggerStandAlone.__call__(), tauTools.AddTauCollection.__call__(), trackTools.MakeTrackCandidates.__call__(), trigTools.SwitchOnTriggerMatching.__call__(), trigTools.SwitchOnTriggerMatchingStandAlone.__call__(), trigTools.SwitchOnTriggerMatchEmbedding.__call__(), jetTools.AddJetCollection.__call__(), jetTools.SwitchJetCollection.__call__(), jetTools.UpdateJetCollection.__call__(), jetTools.AddJetID.__call__(), jetTools.SetTagInfos.__call__(), metTools.AddMETCollection.__init__(), trackTools.MakeAODTrackCandidates.__init__(), runJetUncertainties.RunJetUncertainties.__init__(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.__init__(), trackTools.MakePATTrackCandidates.__init__(), trigTools.SwitchOnTrigger.__init__(), trigTools.SwitchOnTriggerStandAlone.__init__(), tauTools.AddTauCollection.__init__(), trackTools.MakeTrackCandidates.__init__(), trigTools.SwitchOnTriggerMatching.__init__(), trigTools.SwitchOnTriggerMatchingStandAlone.__init__(), trigTools.SwitchOnTriggerMatchEmbedding.__init__(), jetTools.AddJetCollection.__init__(), jetTools.SwitchJetCollection.__init__(), jetTools.UpdateJetCollection.__init__(), jetTools.AddJetID.__init__(), jetTools.SetTagInfos.__init__(), ConfigToolBase.ConfigToolBase.dumpPython(), ConfigToolBase.ConfigToolBase.getAllowedValues(), trackTools.MakeAODTrackCandidates.getDefaultParameters(), metTools.AddMETCollection.getDefaultParameters(), trackTools.MakePATTrackCandidates.getDefaultParameters(), trigTools.SwitchOnTrigger.getDefaultParameters(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.getDefaultParameters(), trigTools.SwitchOnTriggerStandAlone.getDefaultParameters(), tauTools.AddTauCollection.getDefaultParameters(), trackTools.MakeTrackCandidates.getDefaultParameters(), trigTools.SwitchOnTriggerMatching.getDefaultParameters(), trigTools.SwitchOnTriggerMatchingStandAlone.getDefaultParameters(), trigTools.SwitchOnTriggerMatchEmbedding.getDefaultParameters(), jetTools.AddJetCollection.getDefaultParameters(), jetTools.SwitchJetCollection.getDefaultParameters(), jetTools.UpdateJetCollection.getDefaultParameters(), jetTools.AddJetID.getDefaultParameters(), jetTools.SetTagInfos.getDefaultParameters(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.initializeInputTag(), ConfigToolBase.ConfigToolBase.reset(), and ConfigToolBase.ConfigToolBase.setParameter().

string jetTools.AddJetCollection._label = 'addJetCollection'
staticprivate

Definition at line 909 of file jetTools.py.

Referenced by validation.SimpleSample.digest(), validation.SimpleSample.label(), trigTools.SwitchOnTrigger.toolCode(), trigTools.SwitchOnTriggerStandAlone.toolCode(), trigTools.SwitchOnTriggerMatching.toolCode(), trigTools.SwitchOnTriggerMatchingStandAlone.toolCode(), and trigTools.SwitchOnTriggerMatchEmbedding.toolCode().

jetTools.AddJetCollection._parameters
private

initialization of the base class

add all parameters that should be known to the class set defaults

Definition at line 963 of file jetTools.py.

Referenced by runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.ak4JetReclustering(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.createMVAMETModule(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.createSmearedJetModule(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.extractMET(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.getCorrectedMET(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.getMETUncertainties(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.getUnclusteredVariationsForMVAMET(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.getVariations(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.jetCleaning(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.jetConfiguration(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.miniAODConfiguration(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.miniAODConfigurationPost(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.recomputeRawMetFromPfcs(), trackTools.MakeAODTrackCandidates.toolCode(), metTools.AddMETCollection.toolCode(), runJetUncertainties.RunJetUncertainties.toolCode(), trigTools.SwitchOnTrigger.toolCode(), trackTools.MakePATTrackCandidates.toolCode(), trigTools.SwitchOnTriggerStandAlone.toolCode(), tauTools.AddTauCollection.toolCode(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.toolCode(), trackTools.MakeTrackCandidates.toolCode(), trigTools.SwitchOnTriggerMatching.toolCode(), trigTools.SwitchOnTriggerMatchingStandAlone.toolCode(), trigTools.SwitchOnTriggerMatchEmbedding.toolCode(), jetTools.AddJetCollection.toolCode(), jetTools.SwitchJetCollection.toolCode(), jetTools.UpdateJetCollection.toolCode(), jetTools.AddJetID.toolCode(), jetTools.SetTagInfos.toolCode(), and runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.updateJECs().