CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes

metUncertaintyTools::RunMEtUncertainties Class Reference

Inherits FWCore::GuiBrowsers::ConfigToolBase::ConfigToolBase.

List of all members.

Public Member Functions

def __call__
def __init__
def getDefaultParameters
def toolCode

Private Member Functions

def _addCorrPFMEt
def _addModuleToSequence
def _addNoPileUpPFMEt
def _addPATMEtProducer
def _addPFCandidatesForPFMEtInput
def _addPFMEtByMVA
def _addShiftedParticleCollections
def _addSmearedJets
def _getLeptonsForPFMEtInput
def _initializeInputTag
def _isValidInputTag
def _propagateMEtUncertainties

Private Attributes

 _comment
 _parameters

Static Private Attributes

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

Detailed Description

Shift energy of electrons, photons, muons, tau-jets and other jets
reconstructed in the event up/down,
in order to estimate effect of energy scale uncertainties on MET
   

Definition at line 12 of file metUncertaintyTools.py.


Constructor & Destructor Documentation

def metUncertaintyTools::RunMEtUncertainties::__init__ (   self)

Definition at line 20 of file metUncertaintyTools.py.

00021                       :
00022         ConfigToolBase.__init__(self)
00023         self.addParameter(self._defaultParameters, 'electronCollection', cms.InputTag('selectedPatElectrons'),
00024                           "Input electron collection", Type=cms.InputTag, acceptNoneValue=True)
00025         self.addParameter(self._defaultParameters, 'photonCollection', None, # CV: set to empty InputTag to avoid double-counting wrt. selectedPatElectrons collection
00026                           "Input photon collection", Type=cms.InputTag, acceptNoneValue=True)
00027         self.addParameter(self._defaultParameters, 'muonCollection', cms.InputTag('selectedPatMuons'),
00028                           "Input muon collection", Type=cms.InputTag, acceptNoneValue=True)
00029         self.addParameter(self._defaultParameters, 'tauCollection', cms.InputTag('selectedPatTaus'),
00030                           "Input tau collection", Type=cms.InputTag, acceptNoneValue=True)
00031         self.addParameter(self._defaultParameters, 'jetCollection', cms.InputTag('selectedPatJets'),
00032                           "Input jet collection", Type=cms.InputTag)
00033         self.addParameter(self._defaultParameters, 'dRjetCleaning', 0.5,
00034                           "Eta-phi distance for extra jet cleaning", Type=float)
00035         self.addParameter(self._defaultParameters, 'jetCorrLabel', "L3Absolute",
00036                           "NOTE: use 'L3Absolute' for MC/'L2L3Residual' for Data", Type=str)
00037         self.addParameter(self._defaultParameters, 'doSmearJets', True,
00038                           "Flag to enable/disable jet smearing to better match MC to Data", Type=bool)
00039         self.addParameter(self._defaultParameters, 'makeType1corrPFMEt', True,
00040                           "Flag to enable/disable sequence for Type 1 corrected PFMEt", Type=bool)
00041         self.addParameter(self._defaultParameters, 'makeType1p2corrPFMEt', True,
00042                           "Flag to enable/disable sequence for Type 1 + 2 corrected PFMEt", Type=bool)
00043         self.addParameter(self._defaultParameters, 'makePFMEtByMVA', False,
00044                           "Flag to enable/disable sequence for MVA-based PFMEt", Type=bool)
00045         self.addParameter(self._defaultParameters, 'makeNoPileUpPFMEt', False,
00046                           "Flag to enable/disable sequence for no-PU PFMEt", Type=bool)
00047         self.addParameter(self._defaultParameters, 'doApplyType0corr', False,
00048                           "Flag to enable/disable usage of Type-0 MET corrections", Type=bool)
00049         self.addParameter(self._defaultParameters, 'sysShiftCorrParameter', None,
00050                           "MET sys. shift correction parameters", Type=cms.PSet)
00051         self.addParameter(self._defaultParameters, 'doApplySysShiftCorr', False,
00052                           "Flag to enable/disable usage of MET sys. shift corrections", Type=bool)
00053         self.addParameter(self._defaultParameters, 'jetSmearFileName', 'PhysicsTools/PatUtils/data/pfJetResolutionMCtoDataCorrLUT.root',
00054                           "Name of ROOT file containing histogram with jet smearing factors", Type=str)
00055         self.addParameter(self._defaultParameters, 'jetSmearHistogram', 'pfJetResolutionMCtoDataCorrLUT',
00056                           "Name of histogram with jet smearing factors", Type=str)
00057         self.addParameter(self._defaultParameters, 'pfCandCollection', cms.InputTag('particleFlow'),
00058                           "Input PFCandidate collection", Type=cms.InputTag)
00059         self.addParameter(self._defaultParameters, 'jetCorrPayloadName', 'AK5PF',
00060                           "Use AK5PF for PFJets, AK5Calo for CaloJets", Type=str)
00061         self.addParameter(self._defaultParameters, 'varyByNsigmas', 1.0,
00062                           "Number of standard deviations by which energies are varied", Type=float)
00063         self.addParameter(self._defaultParameters, 'addToPatDefaultSequence', True,
00064                           "Flag to enable/disable that metUncertaintySequence is inserted into patDefaultSequence", Type=bool)
00065         self.addParameter(self._defaultParameters, 'outputModule', 'out',
00066                           "Module label of PoolOutputModule (empty label indicates no PoolOutputModule is to be configured)", Type=str)
00067         self.addParameter(self._defaultParameters, 'postfix', '',
00068                           "Technical parameter to identify the resulting sequence and its modules (allows multiple calls in a job)", Type=str)
00069         self._parameters=copy.deepcopy(self._defaultParameters)
00070         self._comment = ""


Member Function Documentation

def metUncertaintyTools::RunMEtUncertainties::__call__ (   self,
  process,
  electronCollection = None,
  photonCollection = None,
  muonCollection = None,
  tauCollection = None,
  jetCollection = None,
  dRjetCleaning = None,
  jetCorrLabel = None,
  doSmearJets = None,
  makeType1corrPFMEt = None,
  makeType1p2corrPFMEt = None,
  makePFMEtByMVA = None,
  makeNoPileUpPFMEt = None,
  doApplyType0corr = None,
  sysShiftCorrParameter = None,
  doApplySysShiftCorr = None,
  jetSmearFileName = None,
  jetSmearHistogram = None,
  pfCandCollection = None,
  jetCorrPayloadName = None,
  varyByNsigmas = None,
  addToPatDefaultSequence = None,
  outputModule = None,
  postfix = None 
)

Definition at line 1368 of file metUncertaintyTools.py.

01392                                                 :
01393         electronCollection = self._initializeInputTag(electronCollection, 'electronCollection')
01394         photonCollection = self._initializeInputTag(photonCollection, 'photonCollection')
01395         muonCollection = self._initializeInputTag(muonCollection, 'muonCollection')
01396         tauCollection = self._initializeInputTag(tauCollection, 'tauCollection')
01397         jetCollection = self._initializeInputTag(jetCollection, 'jetCollection')
01398         if jetCorrLabel is None:
01399             jetCorrLabel = self._defaultParameters['jetCorrLabel'].value
01400         if dRjetCleaning is None:
01401             dRjetCleaning = self._defaultParameters['dRjetCleaning'].value
01402         if doSmearJets is None:
01403             doSmearJets = self._defaultParameters['doSmearJets'].value
01404         if makeType1corrPFMEt is None:
01405             makeType1corrPFMEt = self._defaultParameters['makeType1corrPFMEt'].value
01406         if makeType1p2corrPFMEt is None:
01407             makeType1p2corrPFMEt = self._defaultParameters['makeType1p2corrPFMEt'].value
01408         if makePFMEtByMVA is None:
01409             makePFMEtByMVA = self._defaultParameters['makePFMEtByMVA'].value
01410         if makeNoPileUpPFMEt is None:
01411             makeNoPileUpPFMEt = self._defaultParameters['makeNoPileUpPFMEt'].value
01412         if doApplyType0corr is None:
01413             doApplyType0corr = self._defaultParameters['doApplyType0corr'].value
01414         if sysShiftCorrParameter is None:
01415             sysShiftCorrParameter = self._defaultParameters['sysShiftCorrParameter'].value
01416         if doApplySysShiftCorr is None:
01417             doApplySysShiftCorr = self._defaultParameters['doApplySysShiftCorr'].value
01418         if sysShiftCorrParameter is None:
01419             if doApplySysShiftCorr:
01420                 raise ValueError("MET sys. shift correction parameters must be specified explicitely !!")
01421             sysShiftCorrParameter = cms.PSet()
01422         if jetSmearFileName is None:
01423             jetSmearFileName = self._defaultParameters['jetSmearFileName'].value
01424         if jetSmearHistogram is None:
01425             jetSmearHistogram = self._defaultParameters['jetSmearHistogram'].value
01426         pfCandCollection = self._initializeInputTag(pfCandCollection, 'pfCandCollection')
01427         if jetCorrPayloadName is None:
01428             jetCorrPayloadName = self._defaultParameters['jetCorrPayloadName'].value
01429         if varyByNsigmas is None:
01430             varyByNsigmas = self._defaultParameters['varyByNsigmas'].value
01431         if  addToPatDefaultSequence is None:
01432             addToPatDefaultSequence = self._defaultParameters['addToPatDefaultSequence'].value
01433         if outputModule is None:
01434             outputModule = self._defaultParameters['outputModule'].value
01435         if postfix is None:
01436             postfix = self._defaultParameters['postfix'].value
01437 
01438         self.setParameter('electronCollection', electronCollection)
01439         self.setParameter('photonCollection', photonCollection)
01440         self.setParameter('muonCollection', muonCollection)
01441         self.setParameter('tauCollection', tauCollection)
01442         self.setParameter('jetCollection', jetCollection)
01443         self.setParameter('jetCorrLabel', jetCorrLabel)
01444         self.setParameter('dRjetCleaning', dRjetCleaning)
01445         self.setParameter('doSmearJets', doSmearJets)
01446         self.setParameter('makeType1corrPFMEt', makeType1corrPFMEt)
01447         self.setParameter('makeType1p2corrPFMEt', makeType1p2corrPFMEt)
01448         self.setParameter('makePFMEtByMVA', makePFMEtByMVA)
01449         self.setParameter('makeNoPileUpPFMEt', makeNoPileUpPFMEt)
01450         self.setParameter('doApplyType0corr', doApplyType0corr)
01451         self.setParameter('doApplySysShiftCorr', doApplySysShiftCorr)
01452         self.setParameter('sysShiftCorrParameter', sysShiftCorrParameter)
01453         self.setParameter('jetSmearFileName', jetSmearFileName)
01454         self.setParameter('jetSmearHistogram', jetSmearHistogram)
01455         self.setParameter('pfCandCollection', pfCandCollection)
01456         self.setParameter('jetCorrPayloadName', jetCorrPayloadName)
01457         self.setParameter('varyByNsigmas', varyByNsigmas)
01458         self.setParameter('addToPatDefaultSequence', addToPatDefaultSequence)
01459         self.setParameter('outputModule', outputModule)
01460         self.setParameter('postfix', postfix)
01461 
01462         self.apply(process)

def metUncertaintyTools::RunMEtUncertainties::_addCorrPFMEt (   self,
  process,
  metUncertaintySequence,
  shiftedParticleCollections,
  pfCandCollection,
  collectionsToKeep,
  doSmearJets,
  makeType1corrPFMEt,
  makeType1p2corrPFMEt,
  doApplyType0corr,
  sysShiftCorrParameter,
  doApplySysShiftCorr,
  jetCorrLabel,
  varyByNsigmas,
  postfix 
) [private]

Definition at line 429 of file metUncertaintyTools.py.

00441                               :
00442 
00443         if not (makeType1corrPFMEt or makeType1p2corrPFMEt):
00444             return
00445 
00446         if not hasattr(process, 'producePatPFMETCorrections'):
00447             process.load("PhysicsTools.PatUtils.patPFMETCorrections_cff")
00448 
00449         # If with empty postfix, make a backup of
00450         # process.producePatPFMETCorrections, because the original
00451         # sequence will be modified later in this function
00452         if postfix == "":
00453             configtools.cloneProcessingSnippet(process, process.producePatPFMETCorrections, "OriginalReserved")
00454         else:
00455             if postfix == "OriginalReserved":
00456                 raise ValueError("Postfix label '%s' is reserved for internal usage !!" % postfix)
00457 
00458             if hasattr(process, "producePatPFMETCorrectionsOriginalReserved"):
00459                 configtools.cloneProcessingSnippet(process, process.producePatPFMETCorrectionsOriginalReserved, postfix, removePostfix="OriginalReserved")
00460             else:
00461                 configtools.cloneProcessingSnippet(process, process.producePatPFMETCorrections, postfix)
00462 
00463         # add "nominal" (unshifted) pat::MET collections
00464         getattr(process, "pfCandsNotInJet"+postfix).bottomCollection = pfCandCollection
00465         getattr(process, "selectedPatJetsForMETtype1p2Corr"+postfix).src = shiftedParticleCollections['lastJetCollection']
00466         getattr(process, "selectedPatJetsForMETtype2Corr"+postfix).src = shiftedParticleCollections['lastJetCollection']
00467 
00468 
00469         if doApplySysShiftCorr:
00470             if not hasattr(process, 'pfMEtSysShiftCorrSequence'):
00471                 process.load("JetMETCorrections.Type1MET.pfMETsysShiftCorrections_cfi")
00472             if postfix != "":
00473                 configtools.cloneProcessingSnippet(process, process.pfMEtSysShiftCorrSequence, postfix)
00474 
00475             getattr(process, "pfMEtSysShiftCorr"+postfix).parameter = sysShiftCorrParameter
00476             metUncertaintySequence += getattr(process, "pfMEtSysShiftCorrSequence"+postfix)
00477 
00478         metUncertaintySequence += getattr(process, "producePatPFMETCorrections"+postfix)
00479 
00480         patType1correctionsCentralValue = [ cms.InputTag('patPFJetMETtype1p2Corr'+postfix, 'type1') ]
00481         if doApplyType0corr:
00482             patType1correctionsCentralValue.extend([ cms.InputTag('patPFMETtype0Corr'+postfix) ])
00483         if doApplySysShiftCorr:
00484             patType1correctionsCentralValue.extend([ cms.InputTag('pfMEtSysShiftCorr'+postfix) ])
00485         getattr(process, "patType1CorrectedPFMet"+postfix).srcType1Corrections = cms.VInputTag(patType1correctionsCentralValue)
00486         getattr(process, "patType1p2CorrectedPFMet"+postfix).srcType1Corrections = cms.VInputTag(patType1correctionsCentralValue)
00487 
00488         collectionsToKeep.extend([
00489             'patPFMet'+postfix,
00490             'patType1CorrectedPFMet'+postfix,
00491             'patType1p2CorrectedPFMet'+postfix])
00492 
00493         setattr(process, "selectedPatJetsForMETtype1p2CorrEnUp"+postfix,
00494           getattr(process, shiftedParticleCollections['jetCollectionEnUpForCorrMEt']).clone(
00495             src = cms.InputTag('selectedPatJetsForMETtype1p2Corr'+postfix)
00496         ))
00497         metUncertaintySequence += getattr(process, "selectedPatJetsForMETtype1p2CorrEnUp"+postfix)
00498         setattr(process, "selectedPatJetsForMETtype1p2CorrEnDown"+postfix,
00499           getattr(process, shiftedParticleCollections['jetCollectionEnDownForCorrMEt']).clone(
00500             src = cms.InputTag('selectedPatJetsForMETtype1p2Corr'+postfix)
00501         ))
00502         metUncertaintySequence += getattr(process, "selectedPatJetsForMETtype1p2CorrEnDown"+postfix)
00503         if makeType1p2corrPFMEt:
00504             setattr(process, "selectedPatJetsForMETtype2CorrEnUp"+postfix,
00505               getattr(process, shiftedParticleCollections['jetCollectionEnUpForCorrMEt']).clone(
00506                 src = cms.InputTag('selectedPatJetsForMETtype2Corr'+postfix)
00507             ))
00508             metUncertaintySequence += getattr(process, "selectedPatJetsForMETtype2CorrEnUp"+postfix)
00509             setattr(process, "selectedPatJetsForMETtype2CorrEnDown"+postfix,
00510               getattr(process, shiftedParticleCollections['jetCollectionEnDownForCorrMEt']).clone(
00511                 src = cms.InputTag('selectedPatJetsForMETtype2Corr'+postfix)
00512             ))
00513             metUncertaintySequence += getattr(process, "selectedPatJetsForMETtype2CorrEnDown"+postfix)
00514 
00515         if doSmearJets:
00516             setattr(process, "selectedPatJetsForMETtype1p2CorrResUp"+postfix,
00517               getattr(process, shiftedParticleCollections['jetCollectionResUp']).clone(
00518                 src = cms.InputTag('selectedPatJetsForMETtype1p2Corr'+postfix)
00519             ))
00520             metUncertaintySequence += getattr(process, "selectedPatJetsForMETtype1p2CorrResUp"+postfix)
00521             setattr(process, "selectedPatJetsForMETtype1p2CorrResDown"+postfix,
00522               getattr(process, shiftedParticleCollections['jetCollectionResDown']).clone(
00523                 src = cms.InputTag('selectedPatJetsForMETtype1p2Corr'+postfix)
00524             ))
00525             metUncertaintySequence += getattr(process, "selectedPatJetsForMETtype1p2CorrResDown"+postfix)
00526             if makeType1p2corrPFMEt:
00527                 setattr(process, "selectedPatJetsForMETtype2CorrResUp"+postfix,
00528                   getattr(process, shiftedParticleCollections['jetCollectionResUp']).clone(
00529                     src = cms.InputTag('selectedPatJetsForMETtype2Corr'+postfix)
00530                 ))
00531                 metUncertaintySequence += getattr(process, "selectedPatJetsForMETtype2CorrResUp"+postfix)
00532                 setattr(process, "selectedPatJetsForMETtype2CorrResDown"+postfix,
00533                   getattr(process, shiftedParticleCollections['jetCollectionResDown']).clone(
00534                     src = cms.InputTag('selectedPatJetsForMETtype2Corr'+postfix)
00535                 ))
00536                 metUncertaintySequence += getattr(process, "selectedPatJetsForMETtype2CorrResDown"+postfix)
00537 
00538         if doSmearJets:
00539             # apply MET smearing to "raw" (uncorrected) MET
00540             smearedPatPFMetSequence = cms.Sequence()
00541             setattr(process, "smearedPatPFMetSequence"+postfix, smearedPatPFMetSequence)
00542             setattr(process, "patPFMetForMEtUncertainty"+postfix, getattr(process, "patPFMet"+postfix).clone())
00543             smearedPatPFMetSequence += getattr(process, "patPFMetForMEtUncertainty"+postfix)
00544             setattr(process, "patPFMETcorrJetSmearing"+postfix, cms.EDProducer("ShiftedParticleMETcorrInputProducer",
00545                 srcOriginal = cms.InputTag(shiftedParticleCollections['cleanedJetCollection']),
00546                 srcShifted = cms.InputTag(shiftedParticleCollections['lastJetCollection'])
00547             ))
00548             smearedPatPFMetSequence += getattr(process, "patPFMETcorrJetSmearing"+postfix)
00549             getattr(process, "producePatPFMETCorrections"+postfix).replace(getattr(process, "patPFMet"+postfix), smearedPatPFMetSequence)
00550             setattr(process, "patPFMet"+postfix, getattr(process, "patType1CorrectedPFMet"+postfix).clone(
00551                 src = cms.InputTag('patPFMetForMEtUncertainty'+postfix),
00552                 srcType1Corrections = cms.VInputTag(
00553                     cms.InputTag('patPFMETcorrJetSmearing'+postfix)
00554                 )
00555             ))
00556             smearedPatPFMetSequence += getattr(process, "patPFMet"+postfix)
00557             metUncertaintySequence += smearedPatPFMetSequence
00558 
00559         # propagate shifts in jet energy to "raw" (uncorrected) and Type 1 corrected MET
00560         metCollectionsUp_DownForRawMEt = \
00561             self._propagateMEtUncertainties(
00562               process, shiftedParticleCollections['lastJetCollection'], "Jet", "En",
00563               shiftedParticleCollections['jetCollectionEnUpForRawMEt'], shiftedParticleCollections['jetCollectionEnDownForRawMEt'],
00564               getattr(process, "patPFMet"+postfix), metUncertaintySequence, postfix)
00565         collectionsToKeep.extend(metCollectionsUp_DownForRawMEt)
00566 
00567         metCollectionsUp_DownForCorrMEt = \
00568             self._propagateMEtUncertainties(
00569               process, shiftedParticleCollections['lastJetCollection'], "Jet", "En",
00570               shiftedParticleCollections['jetCollectionEnUpForCorrMEt'], shiftedParticleCollections['jetCollectionEnDownForCorrMEt'],
00571               getattr(process, "patType1CorrectedPFMet"+postfix), metUncertaintySequence, postfix)
00572         collectionsToKeep.extend(metCollectionsUp_DownForCorrMEt)
00573 
00574         # propagate shifts in jet energy to Type 1 + 2 corrected MET
00575         if makeType1p2corrPFMEt:
00576             setattr(process, "patPFJetMETtype1p2CorrEnUp"+postfix, getattr(process, "patPFJetMETtype1p2Corr"+postfix).clone(
00577                 src = cms.InputTag(getattr(process, "selectedPatJetsForMETtype1p2CorrEnUp"+postfix).label()),
00578                 jetCorrLabel = cms.string(jetCorrLabel)
00579             ))
00580             metUncertaintySequence += getattr(process, "patPFJetMETtype1p2CorrEnUp"+postfix)
00581             setattr(process, "patPFJetMETtype1p2CorrEnDown"+postfix, getattr(process, "patPFJetMETtype1p2CorrEnUp"+postfix).clone(
00582                 src = cms.InputTag(getattr(process, "selectedPatJetsForMETtype1p2CorrEnDown"+postfix).label())
00583             ))
00584             metUncertaintySequence += getattr(process, "patPFJetMETtype1p2CorrEnDown"+postfix)
00585             setattr(process, "patPFJetMETtype2CorrEnUp"+postfix, getattr(process, "patPFJetMETtype2Corr"+postfix).clone(
00586                 src = cms.InputTag('selectedPatJetsForMETtype2CorrEnUp'+postfix)
00587             ))
00588             metUncertaintySequence += getattr(process, "patPFJetMETtype2CorrEnUp"+postfix)
00589             setattr(process, "patPFJetMETtype2CorrEnDown"+postfix,  getattr(process, "patPFJetMETtype2Corr"+postfix).clone(
00590                 src = cms.InputTag('selectedPatJetsForMETtype2CorrEnDown'+postfix)
00591             ))
00592             metUncertaintySequence += getattr(process, "patPFJetMETtype2CorrEnDown"+postfix)
00593 
00594             patType1correctionsJetEnUp = [ cms.InputTag('patPFJetMETtype1p2CorrEnUp'+postfix, 'type1') ]
00595             if doApplyType0corr:
00596                 patType1correctionsJetEnUp.extend([ cms.InputTag('patPFMETtype0Corr'+postfix) ])
00597             if doApplySysShiftCorr:
00598                 patType1correctionsJetEnUp.extend([ cms.InputTag('pfMEtSysShiftCorr'+postfix) ])
00599             setattr(process, "patType1p2CorrectedPFMetJetEnUp"+postfix, getattr(process, "patType1p2CorrectedPFMet"+postfix).clone(
00600                 srcType1Corrections = cms.VInputTag(patType1correctionsJetEnUp),
00601                 srcUnclEnergySums = cms.VInputTag(
00602                     cms.InputTag('patPFJetMETtype1p2CorrEnUp'+postfix, 'type2' ),
00603                     cms.InputTag('patPFJetMETtype2CorrEnUp'+postfix,   'type2' ),
00604                     cms.InputTag('patPFJetMETtype1p2CorrEnUp'+postfix, 'offset'),
00605                     cms.InputTag('pfCandMETcorr'+postfix)
00606                 )
00607             ))
00608             metUncertaintySequence += getattr(process, "patType1p2CorrectedPFMetJetEnUp"+postfix)
00609             collectionsToKeep.append('patType1p2CorrectedPFMetJetEnUp'+postfix)
00610             patType1correctionsJetEnDown = [ cms.InputTag('patPFJetMETtype1p2CorrEnDown'+postfix, 'type1') ]
00611             if doApplyType0corr:
00612                 patType1correctionsJetEnDown.extend([ cms.InputTag('patPFMETtype0Corr'+postfix) ])
00613             if doApplySysShiftCorr:
00614                 patType1correctionsJetEnDown.extend([ cms.InputTag('pfMEtSysShiftCorr'+postfix) ])
00615             setattr(process, "patType1p2CorrectedPFMetJetEnDown"+postfix, getattr(process, "patType1p2CorrectedPFMetJetEnUp"+postfix).clone(
00616                 srcType1Corrections = cms.VInputTag(patType1correctionsJetEnDown),
00617                 srcUnclEnergySums = cms.VInputTag(
00618                     cms.InputTag('patPFJetMETtype1p2CorrEnDown'+postfix, 'type2' ),
00619                     cms.InputTag('patPFJetMETtype2CorrEnDown'+postfix,   'type2' ),
00620                     cms.InputTag('patPFJetMETtype1p2CorrEnDown'+postfix, 'offset'),
00621                     cms.InputTag('pfCandMETcorr'+postfix)
00622                 )
00623             ))
00624             metUncertaintySequence += getattr(process, "patType1p2CorrectedPFMetJetEnDown"+postfix)
00625             collectionsToKeep.append('patType1p2CorrectedPFMetJetEnDown'+postfix)
00626 
00627         if doSmearJets:
00628             # propagate shifts in jet resolution to "raw" (uncorrected) MET and Type 1 corrected MET
00629             for metProducer in [ getattr(process, "patPFMet"+postfix),
00630                                  getattr(process, "patType1CorrectedPFMet"+postfix) ]:
00631 
00632                 metCollectionsUp_Down = \
00633                     self._propagateMEtUncertainties(
00634                       process, shiftedParticleCollections['lastJetCollection'], "Jet", "Res",
00635                       shiftedParticleCollections['jetCollectionResUp'], shiftedParticleCollections['jetCollectionResDown'],
00636                       metProducer, metUncertaintySequence, postfix)
00637                 collectionsToKeep.extend(metCollectionsUp_Down)
00638 
00639             # propagate shifts in jet resolution to Type 1 + 2 corrected MET
00640             if makeType1p2corrPFMEt:
00641                 setattr(process, "patPFJetMETtype1p2CorrResUp"+postfix, getattr(process, "patPFJetMETtype1p2Corr"+postfix).clone(
00642                     src = cms.InputTag(getattr(process, "selectedPatJetsForMETtype1p2CorrResUp"+postfix).label()),
00643                     jetCorrLabel = cms.string(jetCorrLabel)
00644                 ))
00645                 metUncertaintySequence += getattr(process, "patPFJetMETtype1p2CorrResUp"+postfix)
00646                 setattr(process, "patPFJetMETtype1p2CorrResDown"+postfix, getattr(process, "patPFJetMETtype1p2CorrResUp"+postfix).clone(
00647                     src = cms.InputTag(getattr(process, "selectedPatJetsForMETtype1p2CorrResDown"+postfix).label())
00648                 ))
00649                 metUncertaintySequence += getattr(process, "patPFJetMETtype1p2CorrResDown"+postfix)
00650                 setattr(process, "patPFJetMETtype2CorrResUp"+postfix, getattr(process, "patPFJetMETtype2Corr"+postfix).clone(
00651                     src = cms.InputTag('selectedPatJetsForMETtype2CorrResUp'+postfix)
00652                 ))
00653                 metUncertaintySequence += getattr(process, "patPFJetMETtype2CorrResUp"+postfix)
00654                 setattr(process, "patPFJetMETtype2CorrResDown"+postfix, getattr(process, "patPFJetMETtype2Corr"+postfix).clone(
00655                     src = cms.InputTag('selectedPatJetsForMETtype2CorrResDown'+postfix)
00656                 ))
00657                 metUncertaintySequence += getattr(process, "patPFJetMETtype2CorrResDown"+postfix)
00658 
00659                 patType1correctionsJetResUp = [ cms.InputTag('patPFJetMETtype1p2CorrResUp'+postfix, 'type1') ]
00660                 if doApplyType0corr:
00661                     patType1correctionsJetResUp.extend([ cms.InputTag('patPFMETtype0Corr'+postfix) ])
00662                 if doApplySysShiftCorr:
00663                     patType1correctionsJetResUp.extend([ cms.InputTag('pfMEtSysShiftCorr'+postfix) ])
00664                 setattr(process, "patType1p2CorrectedPFMetJetResUp"+postfix,  getattr(process, "patType1p2CorrectedPFMet"+postfix).clone(
00665                     srcType1Corrections = cms.VInputTag(patType1correctionsJetResUp),
00666                     srcUnclEnergySums = cms.VInputTag(
00667                         cms.InputTag('patPFJetMETtype1p2CorrResUp'+postfix, 'type2' ),
00668                         cms.InputTag('patPFJetMETtype2CorrResUp'+postfix,   'type2' ),
00669                         cms.InputTag('patPFJetMETtype1p2CorrResUp'+postfix, 'offset'),
00670                         cms.InputTag('pfCandMETcorr'+postfix)
00671                     )
00672                 ))
00673                 metUncertaintySequence += getattr(process, "patType1p2CorrectedPFMetJetResUp"+postfix)
00674                 collectionsToKeep.append('patType1p2CorrectedPFMetJetResUp'+postfix)
00675                 patType1correctionsJetResDown = [ cms.InputTag('patPFJetMETtype1p2CorrResDown'+postfix, 'type1') ]
00676                 if doApplyType0corr:
00677                     patType1correctionsJetResDown.extend([ cms.InputTag('patPFMETtype0Corr'+postfix) ])
00678                 if doApplySysShiftCorr:
00679                     patType1correctionsJetResDown.extend([ cms.InputTag('pfMEtSysShiftCorr'+postfix) ])
00680                 setattr(process, "patType1p2CorrectedPFMetJetResDown"+postfix, getattr(process, "patType1p2CorrectedPFMetJetResUp"+postfix).clone(
00681                     srcType1Corrections = cms.VInputTag(patType1correctionsJetResDown),
00682                     srcUnclEnergySums = cms.VInputTag(
00683                         cms.InputTag('patPFJetMETtype1p2CorrResDown'+postfix, 'type2' ),
00684                         cms.InputTag('patPFJetMETtype2CorrResDown'+postfix,   'type2' ),
00685                         cms.InputTag('patPFJetMETtype1p2CorrResDown'+postfix, 'offset'),
00686                         cms.InputTag('pfCandMETcorr'+postfix)
00687                     )
00688                 ))
00689                 metUncertaintySequence += getattr(process, "patType1p2CorrectedPFMetJetResDown"+postfix)
00690                 collectionsToKeep.append('patType1p2CorrectedPFMetJetResDown'+postfix)
00691 
00692         #--------------------------------------------------------------------------------------------
00693         # shift "unclustered energy" (PFJets of Pt < 10 GeV plus PFCandidates not within jets)
00694         # and propagate effect of shift to (Type 1 as well as Type 1 + 2 corrected) MET
00695         #--------------------------------------------------------------------------------------------
00696 
00697         unclEnMETcorrections = [
00698             [ 'pfCandMETcorr'+postfix, [ '' ] ],
00699             [ 'patPFJetMETtype1p2Corr'+postfix, [ 'type2', 'offset' ] ],
00700             [ 'patPFJetMETtype2Corr'+postfix, [ 'type2' ] ],
00701         ]
00702         unclEnMETcorrectionsUp = []
00703         unclEnMETcorrectionsDown = []
00704         for srcUnclEnMETcorr in unclEnMETcorrections:
00705             moduleUnclEnMETcorrUp = cms.EDProducer("ShiftedMETcorrInputProducer",
00706                 src = cms.VInputTag(
00707                     [ cms.InputTag(srcUnclEnMETcorr[0], instanceLabel) for instanceLabel in srcUnclEnMETcorr[1] ]
00708                 ),
00709                 uncertainty = cms.double(0.10),
00710                 shiftBy = cms.double(+1.*varyByNsigmas)
00711             )
00712             baseName = srcUnclEnMETcorr[0]
00713             if postfix != "":
00714                 if baseName[-len(postfix):] == postfix:
00715                     baseName = baseName[0:-len(postfix)]
00716                 else:
00717                     raise StandardError("Tried to remove postfix %s from label %s, but it wasn't there" % (postfix, baseName))
00718             moduleUnclEnMETcorrUpName = "%sUnclusteredEnUp" % baseName
00719             moduleUnclEnMETcorrUpName += postfix
00720             setattr(process, moduleUnclEnMETcorrUpName, moduleUnclEnMETcorrUp)
00721             metUncertaintySequence += moduleUnclEnMETcorrUp
00722             unclEnMETcorrectionsUp.extend([ cms.InputTag(moduleUnclEnMETcorrUpName, instanceLabel)
00723                                             for instanceLabel in srcUnclEnMETcorr[1] ] )
00724             moduleUnclEnMETcorrDown = moduleUnclEnMETcorrUp.clone(
00725                 shiftBy = cms.double(-1.*varyByNsigmas)
00726             )
00727             moduleUnclEnMETcorrDownName = "%sUnclusteredEnDown" % baseName
00728             moduleUnclEnMETcorrDownName += postfix
00729             setattr(process, moduleUnclEnMETcorrDownName, moduleUnclEnMETcorrDown)
00730             metUncertaintySequence += moduleUnclEnMETcorrDown
00731             unclEnMETcorrectionsDown.extend([ cms.InputTag(moduleUnclEnMETcorrDownName, instanceLabel)
00732                                               for instanceLabel in srcUnclEnMETcorr[1] ] )
00733 
00734         # propagate shifts in jet energy/resolution to "raw" (uncorrected) MET
00735         setattr(process, "patPFMetUnclusteredEnUp"+postfix, getattr(process, "patType1CorrectedPFMet"+postfix).clone(
00736             src = cms.InputTag('patPFMet'+postfix),
00737             srcType1Corrections = cms.VInputTag(unclEnMETcorrectionsUp)
00738         ))
00739         metUncertaintySequence += getattr(process, "patPFMetUnclusteredEnUp"+postfix)
00740         collectionsToKeep.append('patPFMetUnclusteredEnUp'+postfix)
00741         setattr(process, "patPFMetUnclusteredEnDown"+postfix, getattr(process, "patPFMetUnclusteredEnUp"+postfix).clone(
00742             srcType1Corrections = cms.VInputTag(unclEnMETcorrectionsDown)
00743         ))
00744         metUncertaintySequence += getattr(process, "patPFMetUnclusteredEnDown"+postfix)
00745         collectionsToKeep.append('patPFMetUnclusteredEnDown'+postfix)
00746 
00747         # propagate shifts in jet energy/resolution to Type 1 corrected MET
00748         setattr(process, "patType1CorrectedPFMetUnclusteredEnUp"+postfix, getattr(process, "patType1CorrectedPFMet"+postfix).clone(
00749             src = cms.InputTag('patType1CorrectedPFMet'+postfix),
00750             srcType1Corrections = cms.VInputTag(unclEnMETcorrectionsUp)
00751         ))
00752         metUncertaintySequence += getattr(process, "patType1CorrectedPFMetUnclusteredEnUp"+postfix)
00753         collectionsToKeep.append('patType1CorrectedPFMetUnclusteredEnUp'+postfix)
00754         setattr(process, "patType1CorrectedPFMetUnclusteredEnDown"+postfix, getattr(process, "patType1CorrectedPFMetUnclusteredEnUp"+postfix).clone(
00755             srcType1Corrections = cms.VInputTag(unclEnMETcorrectionsDown)
00756         ))
00757         metUncertaintySequence += getattr(process, "patType1CorrectedPFMetUnclusteredEnDown"+postfix)
00758         collectionsToKeep.append('patType1CorrectedPFMetUnclusteredEnDown'+postfix)
00759 
00760         # propagate shifts in jet energy/resolution to Type 1 + 2 corrected MET
00761         if makeType1p2corrPFMEt:
00762             setattr(process, "patType1p2CorrectedPFMetUnclusteredEnUp"+postfix, getattr(process, "patType1p2CorrectedPFMet"+postfix).clone(
00763                 srcUnclEnergySums = cms.VInputTag(
00764                     cms.InputTag('patPFJetMETtype1p2Corr'+postfix,                'type2' ),
00765                     cms.InputTag('patPFJetMETtype1p2CorrUnclusteredEnUp'+postfix, 'type2' ),
00766                     cms.InputTag('patPFJetMETtype2Corr'+postfix,                  'type2' ),
00767                     cms.InputTag('patPFJetMETtype2CorrUnclusteredEnUp'+postfix,   'type2' ),
00768                     cms.InputTag('patPFJetMETtype1p2Corr'+postfix,                'offset'),
00769                     cms.InputTag('patPFJetMETtype1p2CorrUnclusteredEnUp'+postfix, 'offset'),
00770                     cms.InputTag('pfCandMETcorr'+postfix),
00771                     cms.InputTag('pfCandMETcorrUnclusteredEnUp'+postfix)
00772                 )
00773             ))
00774             metUncertaintySequence += getattr(process, "patType1p2CorrectedPFMetUnclusteredEnUp"+postfix)
00775             collectionsToKeep.append('patType1p2CorrectedPFMetUnclusteredEnUp'+postfix)
00776             setattr(process, "patType1p2CorrectedPFMetUnclusteredEnDown"+postfix, getattr(process, "patType1p2CorrectedPFMetUnclusteredEnUp"+postfix).clone(
00777                 srcUnclEnergySums = cms.VInputTag(
00778                     cms.InputTag('patPFJetMETtype1p2Corr'+postfix,                  'type2' ),
00779                     cms.InputTag('patPFJetMETtype1p2CorrUnclusteredEnDown'+postfix, 'type2' ),
00780                     cms.InputTag('patPFJetMETtype2Corr'+postfix,                    'type2' ),
00781                     cms.InputTag('patPFJetMETtype2CorrUnclusteredEnDown'+postfix,   'type2' ),
00782                     cms.InputTag('patPFJetMETtype1p2Corr'+postfix,                  'offset'),
00783                     cms.InputTag('patPFJetMETtype1p2CorrUnclusteredEnDown'+postfix, 'offset'),
00784                     cms.InputTag('pfCandMETcorr'+postfix),
00785                     cms.InputTag('pfCandMETcorrUnclusteredEnDown'+postfix)
00786                 )
00787             ))
00788             metUncertaintySequence += getattr(process, "patType1p2CorrectedPFMetUnclusteredEnDown"+postfix)
00789             collectionsToKeep.append('patType1p2CorrectedPFMetUnclusteredEnDown'+postfix)
00790 
00791         #--------------------------------------------------------------------------------------------
00792         # propagate shifted electron/photon, muon and tau-jet energies to MET
00793         #--------------------------------------------------------------------------------------------
00794 
00795         metProducers = [ getattr(process, "patPFMet"+postfix),
00796                          getattr(process, "patType1CorrectedPFMet"+postfix) ]
00797         if makeType1p2corrPFMEt:
00798             metProducers.append( getattr(process, "patType1p2CorrectedPFMet"+postfix) )
00799         for metProducer in metProducers:
00800 
00801             if self._isValidInputTag(shiftedParticleCollections['electronCollection']):
00802                 metCollectionsUp_Down = \
00803                     self._propagateMEtUncertainties(
00804                       process, shiftedParticleCollections['electronCollection'].value(), "Electron", "En",
00805                       shiftedParticleCollections['electronCollectionEnUp'], shiftedParticleCollections['electronCollectionEnDown'],
00806                       metProducer, metUncertaintySequence, postfix)
00807                 collectionsToKeep.extend(metCollectionsUp_Down)
00808 
00809             if self._isValidInputTag(shiftedParticleCollections['photonCollection']):
00810                 metCollectionsUp_Down = \
00811                     self._propagateMEtUncertainties(
00812                       process, shiftedParticleCollections['photonCollection'].value(), "Photon", "En",
00813                       shiftedParticleCollections['photonCollectionEnUp'], shiftedParticleCollections['photonCollectionEnDown'],
00814                       metProducer, metUncertaintySequence, postfix)
00815                 collectionsToKeep.extend(metCollectionsUp_Down)
00816 
00817             if self._isValidInputTag(shiftedParticleCollections['muonCollection']):
00818                 metCollectionsUp_Down = \
00819                     self._propagateMEtUncertainties(
00820                       process, shiftedParticleCollections['muonCollection'].value(), "Muon", "En",
00821                       shiftedParticleCollections['muonCollectionEnUp'], shiftedParticleCollections['muonCollectionEnDown'],
00822                       metProducer, metUncertaintySequence, postfix)
00823                 collectionsToKeep.extend(metCollectionsUp_Down)
00824 
00825             if self._isValidInputTag(shiftedParticleCollections['tauCollection']):
00826                 metCollectionsUp_Down = \
00827                     self._propagateMEtUncertainties(
00828                       process, shiftedParticleCollections['tauCollection'].value(), "Tau", "En",
00829                       shiftedParticleCollections['tauCollectionEnUp'], shiftedParticleCollections['tauCollectionEnDown'],
00830                       metProducer, metUncertaintySequence, postfix)
00831                 collectionsToKeep.extend(metCollectionsUp_Down)

def metUncertaintyTools::RunMEtUncertainties::_addModuleToSequence (   self,
  process,
  module,
  moduleName_parts,
  sequence,
  postfix 
) [private]

Definition at line 74 of file metUncertaintyTools.py.

00075                                                                                         :
00076 
00077         if not len(moduleName_parts) > 0:
00078             raise ValueError("Empty list !!")
00079 
00080         moduleName = ""
00081 
00082         lastPart = None
00083         for part in moduleName_parts:
00084             if part is None or part == "":
00085                 continue
00086 
00087             part = part.replace("selected", "")
00088             part = part.replace("clean",    "")
00089 
00090             if lastPart is None:
00091                 moduleName += part[0].lower() + part[1:]
00092                 lastPart = part
00093             else:
00094                 if lastPart[-1].islower() or lastPart[-1].isdigit():
00095                     moduleName += part[0].capitalize() + part[1:]
00096                 else:
00097                     moduleName += part[0].lower() + part[1:]
00098                 lastPart = part
00099 
00100         moduleName += postfix
00101         setattr(process, moduleName, module)
00102 
00103         sequence += module
00104 
00105         return moduleName

def metUncertaintyTools::RunMEtUncertainties::_addNoPileUpPFMEt (   self,
  process,
  metUncertaintySequence,
  shiftedParticleCollections,
  pfCandCollection,
  collectionsToKeep,
  doSmearJets,
  makeNoPileUpPFMEt,
  varyByNsigmas,
  postfix 
) [private]

Definition at line 1106 of file metUncertaintyTools.py.

01113                                 :
01114 
01115         if not makeNoPileUpPFMEt:
01116             return
01117 
01118         if not hasattr(process, "noPileUpPFMEt"):
01119             process.load("JetMETCorrections.METPUSubtraction.noPileUpPFMET_cff")
01120 
01121         lastUncorrectedJetCollectionForNoPileUpPFMEt = 'ak5PFJets'
01122         lastCorrectedJetCollectionForNoPileUpPFMEt = 'calibratedAK5PFJetsForNoPileUpPFMEt'
01123         if postfix != "":
01124             configtools.cloneProcessingSnippet(process, process.noPileUpPFMEtSequence, postfix)
01125             lastCorrectedJetCollectionForNoPileUpPFMEt+= postfix
01126 
01127 
01128         if doSmearJets:
01129             process.load("RecoJets.Configuration.GenJetParticles_cff")
01130             metUncertaintySequence += process.genParticlesForJetsNoNu
01131             process.load("RecoJets.Configuration.RecoGenJets_cff")
01132             metUncertaintySequence += process.ak5GenJetsNoNu
01133             setattr(process, "smearedUncorrectedJetsForNoPileUpPFMEt"+postfix, cms.EDProducer("SmearedPFJetProducer",
01134                 src = cms.InputTag('ak5PFJets'),
01135                 jetCorrLabel = cms.string("ak5PFL1FastL2L3"),
01136                 dRmaxGenJetMatch = cms.string('TMath::Min(0.5, 0.1 + 0.3*TMath::Exp(-0.05*(genJetPt - 10.)))'),
01137                 sigmaMaxGenJetMatch = cms.double(5.),
01138                 inputFileName = cms.FileInPath('PhysicsTools/PatUtils/data/pfJetResolutionMCtoDataCorrLUT.root'),
01139                 lutName = cms.string('pfJetResolutionMCtoDataCorrLUT'),
01140                 jetResolutions = jetResolutions.METSignificance_params,
01141                 skipRawJetPtThreshold = cms.double(10.), # GeV
01142                 skipCorrJetPtThreshold = cms.double(1.e-2),
01143                 srcGenJets = cms.InputTag('ak5GenJetsNoNu'),
01144                 ##verbosity = cms.int32(1)
01145             ))
01146             metUncertaintySequence += getattr(process, "smearedUncorrectedJetsForNoPileUpPFMEt"+postfix)
01147             getattr(process, "calibratedAK5PFJetsForNoPileUpPFMEt"+postfix).src = cms.InputTag('smearedUncorrectedJetsForNoPileUpPFMEt'+postfix)
01148         metUncertaintySequence += getattr(process, "noPileUpPFMEtSequence"+postfix)
01149         self._addPATMEtProducer(process, metUncertaintySequence,
01150                                 'noPileUpPFMEt'+postfix, 'patPFMetNoPileUp', collectionsToKeep, postfix)
01151 
01152         for leptonCollection in [ [ 'Electron', 'En', 'electronCollection', 0.3 ],
01153                                   [ 'Photon',   'En', 'photonCollection',   0.3 ],
01154                                   [ 'Muon',     'En', 'muonCollection',     0.3 ],
01155                                   [ 'Tau',      'En', 'tauCollection',      0.3 ] ]:
01156             if self._isValidInputTag(shiftedParticleCollections[leptonCollection[2]]):
01157                 pfCandCollectionLeptonShiftUp, pfCandCollectionLeptonShiftDown = \
01158                   self._addPFCandidatesForPFMEtInput(
01159                     process, metUncertaintySequence,
01160                     shiftedParticleCollections['%s' % leptonCollection[2]], leptonCollection[0], leptonCollection[1],
01161                     shiftedParticleCollections['%s%sUp' % (leptonCollection[2], leptonCollection[1])], shiftedParticleCollections['%s%sDown' % (leptonCollection[2], leptonCollection[1])],
01162                     leptonCollection[3],
01163                     pfCandCollection, postfix)
01164                 modulePFCandidateToVertexAssociationShiftUp = process.pfCandidateToVertexAssociation.clone(
01165                     PFCandidateCollection = cms.InputTag(pfCandCollectionLeptonShiftUp)
01166                 )
01167                 modulePFCandidateToVertexAssociationShiftUpName = "pfCandidateToVertexAssociation%s%sUp" % (leptonCollection[0], leptonCollection[1])
01168                 modulePFCandidateToVertexAssociationShiftUpName += postfix
01169                 setattr(process, modulePFCandidateToVertexAssociationShiftUpName, modulePFCandidateToVertexAssociationShiftUp)
01170                 metUncertaintySequence += modulePFCandidateToVertexAssociationShiftUp
01171                 modulePFMEtDataLeptonShiftUp = getattr(process, "noPileUpPFMEtData"+postfix).clone(
01172                     srcPFCandidates = cms.InputTag(pfCandCollectionLeptonShiftUp),
01173                     srcPFCandToVertexAssociations = cms.InputTag(modulePFCandidateToVertexAssociationShiftUpName)
01174                 )
01175                 modulePFMEtDataLeptonShiftUpName = "noPileUpPFMEtData%s%sUp" % (leptonCollection[0], leptonCollection[1])
01176                 modulePFMEtDataLeptonShiftUpName += postfix
01177                 setattr(process, modulePFMEtDataLeptonShiftUpName, modulePFMEtDataLeptonShiftUp)
01178                 metUncertaintySequence += modulePFMEtDataLeptonShiftUp
01179                 modulePFMEtLeptonShiftUp = getattr(process, "noPileUpPFMEt"+postfix).clone(
01180                     srcMVAMEtData = cms.InputTag(modulePFMEtDataLeptonShiftUpName),
01181                     srcLeptons = cms.VInputTag(self._getLeptonsForPFMEtInput(
01182                       shiftedParticleCollections, leptonCollection[2], '%s%sUp' % (leptonCollection[2], leptonCollection[1]), postfix=postfix))
01183                 )
01184                 modulePFMEtLeptonShiftUpName = "noPileUpPFMEt%s%sUp" % (leptonCollection[0], leptonCollection[1])
01185                 modulePFMEtLeptonShiftUpName += postfix
01186                 setattr(process, modulePFMEtLeptonShiftUpName, modulePFMEtLeptonShiftUp)
01187                 metUncertaintySequence += modulePFMEtLeptonShiftUp
01188                 self._addPATMEtProducer(process, metUncertaintySequence,
01189                                         modulePFMEtLeptonShiftUpName, 'patPFMetNoPileUp%s%sUp' % (leptonCollection[0], leptonCollection[1]), collectionsToKeep, postfix)
01190                 modulePFCandidateToVertexAssociationShiftDown = modulePFCandidateToVertexAssociationShiftUp.clone(
01191                     PFCandidateCollection = cms.InputTag(pfCandCollectionLeptonShiftDown)
01192                 )
01193                 modulePFCandidateToVertexAssociationShiftDownName = "pfCandidateToVertexAssociation%s%sDown" % (leptonCollection[0], leptonCollection[1])
01194                 modulePFCandidateToVertexAssociationShiftDownName += postfix
01195                 setattr(process, modulePFCandidateToVertexAssociationShiftDownName, modulePFCandidateToVertexAssociationShiftDown)
01196                 metUncertaintySequence += modulePFCandidateToVertexAssociationShiftDown
01197                 modulePFMEtDataLeptonShiftDown = getattr(process, "noPileUpPFMEtData"+postfix).clone(
01198                     srcPFCandidates = cms.InputTag(pfCandCollectionLeptonShiftDown),
01199                     srcPFCandToVertexAssociations = cms.InputTag(modulePFCandidateToVertexAssociationShiftDownName)
01200                 )
01201                 modulePFMEtDataLeptonShiftDownName = "noPileUpPFMEtData%s%sDown" % (leptonCollection[0], leptonCollection[1])
01202                 modulePFMEtDataLeptonShiftDownName += postfix
01203                 setattr(process, modulePFMEtDataLeptonShiftDownName, modulePFMEtDataLeptonShiftDown)
01204                 metUncertaintySequence += modulePFMEtDataLeptonShiftDown
01205                 modulePFMEtLeptonShiftDown = getattr(process, "noPileUpPFMEt"+postfix).clone(
01206                     srcMVAMEtData = cms.InputTag(modulePFMEtDataLeptonShiftDownName),
01207                     srcLeptons = cms.VInputTag(self._getLeptonsForPFMEtInput(
01208                       shiftedParticleCollections, leptonCollection[2], '%s%sDown' % (leptonCollection[2], leptonCollection[1]), postfix=postfix))
01209                 )
01210                 modulePFMEtLeptonShiftDownName = "noPileUpPFMEt%s%sDown" % (leptonCollection[0], leptonCollection[1])
01211                 modulePFMEtLeptonShiftDownName += postfix
01212                 setattr(process, modulePFMEtLeptonShiftDownName, modulePFMEtLeptonShiftDown)
01213                 metUncertaintySequence += modulePFMEtLeptonShiftDown
01214                 self._addPATMEtProducer(process, metUncertaintySequence,
01215                                         modulePFMEtLeptonShiftDownName, 'patPFMetNoPileUp%s%sDown' % (leptonCollection[0], leptonCollection[1]), collectionsToKeep, postfix)
01216 
01217         if self._isValidInputTag(shiftedParticleCollections['jetCollection']):
01218             setattr(process, "uncorrectedJetsEnUpForNoPileUpPFMEt"+postfix, cms.EDProducer("ShiftedPFJetProducer",
01219                 src = cms.InputTag(lastUncorrectedJetCollectionForNoPileUpPFMEt),
01220                 jetCorrInputFileName = cms.FileInPath('PhysicsTools/PatUtils/data/Summer12_V2_DATA_AK5PF_UncertaintySources.txt'),
01221                 jetCorrUncertaintyTag = cms.string("SubTotalDataMC"),
01222                 addResidualJES = cms.bool(False),
01223                 jetCorrLabelUpToL3 = cms.string("ak5PFL1FastL2L3"),
01224                 jetCorrLabelUpToL3Res = cms.string("ak5PFL1FastL2L3Residual"),
01225                 shiftBy = cms.double(+1.*varyByNsigmas),
01226                 ##verbosity = cms.int32(1)
01227             ))
01228             metUncertaintySequence += getattr(process, "uncorrectedJetsEnUpForNoPileUpPFMEt"+postfix)
01229             setattr(process, "correctedJetsEnUpForNoPileUpPFMEt"+postfix, getattr(process, "uncorrectedJetsEnUpForNoPileUpPFMEt"+postfix).clone(
01230                 src = cms.InputTag(lastCorrectedJetCollectionForNoPileUpPFMEt),
01231                 addResidualJES = cms.bool(False),
01232                 shiftBy = cms.double(+1.*varyByNsigmas)
01233             ))
01234             metUncertaintySequence += getattr(process, "correctedJetsEnUpForNoPileUpPFMEt"+postfix)
01235             setattr(process, "puJetIdForNoPileUpPFMEtJetEnUp"+postfix, getattr(process, "puJetIdForNoPileUpPFMEt"+postfix).clone(
01236                 jets = cms.InputTag('correctedJetsEnUpForNoPileUpPFMEt'+postfix)
01237             ))
01238             metUncertaintySequence += getattr(process, "puJetIdForNoPileUpPFMEtJetEnUp"+postfix)
01239             setattr(process, "noPileUpPFMEtDataJetEnUp"+postfix, getattr(process, "noPileUpPFMEtData"+postfix).clone(
01240                 srcJets = cms.InputTag('correctedJetsEnUpForNoPileUpPFMEt'+postfix),
01241                 srcJetIds = cms.InputTag('puJetIdForNoPileUpPFMEtJetEnUp'+postfix, 'fullId')
01242             ))
01243             metUncertaintySequence += getattr(process, "noPileUpPFMEtDataJetEnUp"+postfix)
01244             setattr(process, "noPileUpPFMEtJetEnUp"+postfix, getattr(process, "noPileUpPFMEt"+postfix).clone(
01245                 srcMVAMEtData = cms.InputTag('noPileUpPFMEtDataJetEnUp'+postfix),
01246                 srcLeptons = cms.VInputTag(self._getLeptonsForPFMEtInput(shiftedParticleCollections, postfix=postfix))
01247             ))
01248             metUncertaintySequence += getattr(process, "noPileUpPFMEtJetEnUp"+postfix)
01249             self._addPATMEtProducer(process, metUncertaintySequence,
01250                                     'noPileUpPFMEtJetEnUp'+postfix, 'patPFMetNoPileUpJetEnUp', collectionsToKeep, postfix)
01251             setattr(process, "uncorrectedJetsEnDownForNoPileUpPFMEt"+postfix, getattr(process, "uncorrectedJetsEnUpForNoPileUpPFMEt"+postfix).clone(
01252                 shiftBy = cms.double(-1.*varyByNsigmas)
01253             ))
01254             metUncertaintySequence += getattr(process, "uncorrectedJetsEnDownForNoPileUpPFMEt"+postfix)
01255             setattr(process, "correctedJetsEnDownForNoPileUpPFMEt"+postfix, getattr(process, "correctedJetsEnUpForNoPileUpPFMEt"+postfix).clone(
01256                 shiftBy = cms.double(-1.*varyByNsigmas)
01257             ))
01258             metUncertaintySequence += getattr(process, "correctedJetsEnDownForNoPileUpPFMEt"+postfix)
01259             setattr(process, "puJetIdForNoPileUpPFMEtJetEnDown"+postfix, getattr(process, "puJetIdForNoPileUpPFMEt"+postfix).clone(
01260                 jets = cms.InputTag('correctedJetsEnDownForNoPileUpPFMEt'+postfix)
01261             ))
01262             metUncertaintySequence += getattr(process, "puJetIdForNoPileUpPFMEtJetEnDown"+postfix)
01263             setattr(process, "noPileUpPFMEtDataJetEnDown"+postfix, getattr(process, "noPileUpPFMEtData"+postfix).clone(
01264                 srcJets = cms.InputTag('correctedJetsEnDownForNoPileUpPFMEt'+postfix),
01265                 srcJetIds = cms.InputTag('puJetIdForNoPileUpPFMEtJetEnDown'+postfix, 'fullId')
01266             ))
01267             metUncertaintySequence += getattr(process, "noPileUpPFMEtDataJetEnDown"+postfix)
01268             setattr(process, "noPileUpPFMEtJetEnDown"+postfix, getattr(process, "noPileUpPFMEt"+postfix).clone(
01269                 srcMVAMEtData = cms.InputTag('noPileUpPFMEtDataJetEnDown'+postfix),
01270                 srcLeptons = cms.VInputTag(self._getLeptonsForPFMEtInput(shiftedParticleCollections, postfix=postfix))
01271             ))
01272             metUncertaintySequence += getattr(process, "noPileUpPFMEtJetEnDown"+postfix)
01273             self._addPATMEtProducer(process, metUncertaintySequence,
01274                                     'noPileUpPFMEtJetEnDown'+postfix, 'patPFMetNoPileUpJetEnDown', collectionsToKeep, postfix)
01275 
01276             if hasattr(process, "smearedUncorrectedJetsForNoPileUpPFMEt"+postfix):
01277                 setattr(process, "smearedCorrectedJetsForNoPileUpPFMEt"+postfix, getattr(process, "smearedUncorrectedJetsForNoPileUpPFMEt"+postfix).clone(
01278                     src = cms.InputTag('calibratedAK5PFJetsForNoPileUpPFMEt'+postfix),
01279                     jetCorrLabel = cms.string("")
01280                 ))
01281                 setattr(process, "correctedJetsResUpForNoPileUpPFMEt"+postfix, getattr(process, "smearedCorrectedJetsForNoPileUpPFMEt"+postfix).clone(
01282                     shiftBy = cms.double(-1.*varyByNsigmas)
01283                 ))
01284                 metUncertaintySequence += getattr(process, "correctedJetsResUpForNoPileUpPFMEt"+postfix)
01285                 setattr(process, "correctedJetsResDownForNoPileUpPFMEt"+postfix, getattr(process, "smearedCorrectedJetsForNoPileUpPFMEt"+postfix).clone(
01286                     shiftBy = cms.double(+1.*varyByNsigmas)
01287                 ))
01288                 metUncertaintySequence += getattr(process, "correctedJetsResDownForNoPileUpPFMEt"+postfix)
01289                 setattr(process, "puJetIdForNoPileUpPFMEtJetResUp"+postfix, getattr(process, "puJetIdForNoPileUpPFMEt"+postfix).clone(
01290                     jets = cms.InputTag('correctedJetsResUpForNoPileUpPFMEt'+postfix)
01291                 ))
01292                 metUncertaintySequence += getattr(process, "puJetIdForNoPileUpPFMEtJetResUp"+postfix)
01293                 setattr(process, "noPileUpPFMEtDataJetResUp"+postfix, getattr(process, "noPileUpPFMEtData"+postfix).clone(
01294                     srcJets = cms.InputTag('correctedJetsResUpForNoPileUpPFMEt'+postfix),
01295                     srcJetIds = cms.InputTag('puJetIdForNoPileUpPFMEtJetResUp'+postfix, 'fullId')
01296                 ))
01297                 metUncertaintySequence += getattr(process, "noPileUpPFMEtDataJetResUp"+postfix)
01298                 setattr(process, "noPileUpPFMEtJetResUp"+postfix, getattr(process, "noPileUpPFMEt"+postfix).clone(
01299                     srcMVAMEtData = cms.InputTag('noPileUpPFMEtDataJetResUp'+postfix),
01300                     srcLeptons = cms.VInputTag(self._getLeptonsForPFMEtInput(shiftedParticleCollections, postfix=postfix))
01301                 ))
01302                 metUncertaintySequence += getattr(process, "noPileUpPFMEtJetResUp"+postfix)
01303                 self._addPATMEtProducer(process, metUncertaintySequence,
01304                                         'noPileUpPFMEtJetResUp'+postfix, 'patPFMetNoPileUpJetResUp', collectionsToKeep, postfix)
01305                 setattr(process, "puJetIdForNoPileUpPFMEtJetResDown"+postfix, getattr(process, "puJetIdForNoPileUpPFMEt"+postfix).clone(
01306                     jets = cms.InputTag('correctedJetsResDownForNoPileUpPFMEt'+postfix)
01307                 ))
01308                 metUncertaintySequence += getattr(process, "puJetIdForNoPileUpPFMEtJetResDown"+postfix)
01309                 setattr(process, "noPileUpPFMEtDataJetResDown"+postfix, getattr(process, "noPileUpPFMEtData"+postfix).clone(
01310                     srcJets = cms.InputTag('correctedJetsResDownForNoPileUpPFMEt'+postfix),
01311                     srcJetIds = cms.InputTag('puJetIdForNoPileUpPFMEtJetResDown'+postfix, 'fullId')
01312                 ))
01313                 metUncertaintySequence += getattr(process, "noPileUpPFMEtDataJetResDown"+postfix)
01314                 setattr(process, "noPileUpPFMEtJetResDown"+postfix, getattr(process, "noPileUpPFMEt"+postfix).clone(
01315                     srcMVAMEtData = cms.InputTag('noPileUpPFMEtDataJetResDown'+postfix),
01316                     srcLeptons = cms.VInputTag(self._getLeptonsForPFMEtInput(shiftedParticleCollections, postfix=postfix))
01317                 ))
01318                 metUncertaintySequence += getattr(process, "noPileUpPFMEtJetResDown"+postfix)
01319                 self._addPATMEtProducer(process, metUncertaintySequence,
01320                                         'noPileUpPFMEtJetResDown'+postfix, 'patPFMetNoPileUpJetResDown', collectionsToKeep, postfix)
01321 
01322             setattr(process, "pfCandsUnclusteredEnUpForNoPileUpPFMEt"+postfix, cms.EDProducer("ShiftedPFCandidateProducerForNoPileUpPFMEt",
01323                 srcPFCandidates = cms.InputTag('particleFlow'),
01324                 srcJets = cms.InputTag('calibratedAK5PFJetsForNoPileUpPFMEt'+postfix),
01325                 jetCorrInputFileName = cms.FileInPath('PhysicsTools/PatUtils/data/Summer12_V2_DATA_AK5PF_UncertaintySources.txt'),
01326                 jetCorrUncertaintyTag = cms.string("SubTotalDataMC"),
01327                 minJetPt = cms.double(10.0),
01328                 shiftBy = cms.double(+1.*varyByNsigmas),
01329                 unclEnUncertainty = cms.double(0.10)
01330             ))
01331             metUncertaintySequence += getattr(process, "pfCandsUnclusteredEnUpForNoPileUpPFMEt"+postfix)
01332             setattr(process, "pfCandidateToVertexAssociationUnclusteredEnUpForNoPileUpPFMEt"+postfix, process.pfCandidateToVertexAssociation.clone(
01333                 PFCandidateCollection = cms.InputTag('pfCandsUnclusteredEnUpForNoPileUpPFMEt'+postfix)
01334             ))
01335             metUncertaintySequence += getattr(process, "pfCandidateToVertexAssociationUnclusteredEnUpForNoPileUpPFMEt"+postfix)
01336             setattr(process, "noPileUpPFMEtDataUnclusteredEnUp"+postfix, getattr(process, "noPileUpPFMEtData"+postfix).clone(
01337                 srcPFCandidates = cms.InputTag('pfCandsUnclusteredEnUpForNoPileUpPFMEt'+postfix),
01338                 srcPFCandToVertexAssociations = cms.InputTag('pfCandidateToVertexAssociationUnclusteredEnUpForNoPileUpPFMEt'+postfix),
01339             ))
01340             metUncertaintySequence += getattr(process, "noPileUpPFMEtDataUnclusteredEnUp"+postfix)
01341             setattr(process, "noPileUpPFMEtUnclusteredEnUp"+postfix, getattr(process, "noPileUpPFMEt"+postfix).clone(
01342                 srcMVAMEtData = cms.InputTag('noPileUpPFMEtDataUnclusteredEnUp'+postfix),
01343                 srcLeptons = cms.VInputTag(self._getLeptonsForPFMEtInput(shiftedParticleCollections, postfix=postfix))
01344             ))
01345             metUncertaintySequence += getattr(process, "noPileUpPFMEtUnclusteredEnUp"+postfix)
01346             self._addPATMEtProducer(process, metUncertaintySequence,
01347                                     'noPileUpPFMEtUnclusteredEnUp'+postfix, 'patPFMetNoPileUpUnclusteredEnUp', collectionsToKeep, postfix)
01348             setattr(process, "pfCandsUnclusteredEnDownForNoPileUpPFMEt"+postfix, getattr(process, "pfCandsUnclusteredEnUpForNoPileUpPFMEt"+postfix).clone(
01349                 shiftBy = cms.double(-1.*varyByNsigmas),
01350             ))
01351             metUncertaintySequence += getattr(process, "pfCandsUnclusteredEnDownForNoPileUpPFMEt"+postfix)
01352             setattr(process, "pfCandidateToVertexAssociationUnclusteredEnDownForNoPileUpPFMEt"+postfix, process.pfCandidateToVertexAssociation.clone(
01353                 PFCandidateCollection = cms.InputTag('pfCandsUnclusteredEnDownForNoPileUpPFMEt'+postfix)
01354             ))
01355             metUncertaintySequence += getattr(process, "pfCandidateToVertexAssociationUnclusteredEnDownForNoPileUpPFMEt"+postfix)
01356             setattr(process, "noPileUpPFMEtDataUnclusteredEnDown"+postfix, getattr(process, "noPileUpPFMEtData"+postfix).clone(
01357                 srcPFCandidates = cms.InputTag('pfCandsUnclusteredEnDownForNoPileUpPFMEt'+postfix),
01358                 srcPFCandToVertexAssociations = cms.InputTag('pfCandidateToVertexAssociationUnclusteredEnDownForNoPileUpPFMEt'+postfix),
01359             ))
01360             metUncertaintySequence += getattr(process, "noPileUpPFMEtDataUnclusteredEnDown"+postfix)
01361             setattr(process, "noPileUpPFMEtUnclusteredEnDown"+postfix, getattr(process, "noPileUpPFMEt"+postfix).clone(
01362                 srcMVAMEtData = cms.InputTag('noPileUpPFMEtDataUnclusteredEnDown'+postfix),
01363                 srcLeptons = cms.VInputTag(self._getLeptonsForPFMEtInput(shiftedParticleCollections, postfix=postfix))
01364             ))
01365             metUncertaintySequence += getattr(process, "noPileUpPFMEtUnclusteredEnDown"+postfix)
01366             self._addPATMEtProducer(process, metUncertaintySequence,
01367                                     'noPileUpPFMEtUnclusteredEnDown'+postfix, 'patPFMetNoPileUpUnclusteredEnDown', collectionsToKeep, postfix)

def metUncertaintyTools::RunMEtUncertainties::_addPATMEtProducer (   self,
  process,
  metUncertaintySequence,
  pfMEtCollection,
  patMEtCollection,
  collectionsToKeep,
  postfix 
) [private]

Definition at line 876 of file metUncertaintyTools.py.

00879                                                       :
00880 
00881         module = patMETs.clone(
00882             metSource = cms.InputTag(pfMEtCollection),
00883             addMuonCorrections = cms.bool(False),
00884             genMETSource = cms.InputTag('genMetTrue')
00885         )
00886         patMEtCollectionName = patMEtCollection+postfix
00887         setattr(process, patMEtCollectionName, module)
00888         metUncertaintySequence += module
00889         collectionsToKeep.append(patMEtCollectionName)

def metUncertaintyTools::RunMEtUncertainties::_addPFCandidatesForPFMEtInput (   self,
  process,
  metUncertaintySequence,
  particleCollection,
  particleType,
  shiftType,
  particleCollectionShiftUp,
  particleCollectionShiftDown,
  dRmatch,
  pfCandCollection,
  postfix 
) [private]

Definition at line 832 of file metUncertaintyTools.py.

00836                                                                 :
00837 
00838         srcUnshiftedObjects = particleCollection
00839         if isinstance(srcUnshiftedObjects, cms.InputTag):
00840             srcUnshiftedObjects = srcUnshiftedObjects.value()
00841         moduleShiftUp = cms.EDProducer("ShiftedPFCandidateProducerForPFMEtMVA",
00842             srcPFCandidates = pfCandCollection,
00843             srcUnshiftedObjects = cms.InputTag(srcUnshiftedObjects),
00844             srcShiftedObjects = cms.InputTag(particleCollectionShiftUp),
00845             dRmatch_PFCandidate = cms.double(dRmatch)
00846         )
00847         moduleNameShiftUp = "pfCandidates%s%sUpForMEtUncertainties" % (particleType, shiftType)
00848         moduleNameShiftUp += postfix
00849         setattr(process, moduleNameShiftUp, moduleShiftUp)
00850         metUncertaintySequence += moduleShiftUp
00851 
00852         moduleShiftDown = moduleShiftUp.clone(
00853             srcShiftedObjects = cms.InputTag(particleCollectionShiftDown)
00854         )
00855         moduleNameShiftDown = "pfCandidates%s%sDownForMEtUncertainties" % (particleType, shiftType)
00856         moduleNameShiftDown += postfix
00857         setattr(process, moduleNameShiftDown, moduleShiftDown)
00858         metUncertaintySequence += moduleShiftDown
00859 
00860         return ( moduleNameShiftUp, moduleNameShiftDown )

def metUncertaintyTools::RunMEtUncertainties::_addPFMEtByMVA (   self,
  process,
  metUncertaintySequence,
  shiftedParticleCollections,
  pfCandCollection,
  collectionsToKeep,
  doSmearJets,
  makePFMEtByMVA,
  varyByNsigmas,
  postfix 
) [private]

Definition at line 890 of file metUncertaintyTools.py.

00897                                :
00898 
00899         if not makePFMEtByMVA:
00900             return
00901 
00902         if not hasattr(process, "pfMEtMVA"):
00903             process.load("JetMETCorrections.METPUSubtraction.mvaPFMET_cff")
00904 
00905         lastUncorrectedJetCollectionForPFMEtByMVA = 'ak5PFJets'
00906         lastCorrectedJetCollectionForPFMEtByMVA = 'calibratedAK5PFJetsForPFMEtMVA'
00907         if postfix != "":
00908             configtools.cloneProcessingSnippet(process, process.pfMEtMVAsequence, postfix)
00909             lastCorrectedJetCollectionForPFMEtByMVA += postfix
00910 
00911         if doSmearJets:
00912             process.load("RecoJets.Configuration.GenJetParticles_cff")
00913             metUncertaintySequence += process.genParticlesForJetsNoNu
00914             process.load("RecoJets.Configuration.RecoGenJets_cff")
00915             metUncertaintySequence += process.ak5GenJetsNoNu
00916             setattr(process, "smearedUncorrectedJetsForPFMEtByMVA"+postfix, cms.EDProducer("SmearedPFJetProducer",
00917                 src = cms.InputTag('ak5PFJets'),
00918                 jetCorrLabel = cms.string("ak5PFL1FastL2L3"),
00919                 dRmaxGenJetMatch = cms.string('TMath::Min(0.5, 0.1 + 0.3*TMath::Exp(-0.05*(genJetPt - 10.)))'),
00920                 sigmaMaxGenJetMatch = cms.double(5.),
00921                 inputFileName = cms.FileInPath('PhysicsTools/PatUtils/data/pfJetResolutionMCtoDataCorrLUT.root'),
00922                 lutName = cms.string('pfJetResolutionMCtoDataCorrLUT'),
00923                 jetResolutions = jetResolutions.METSignificance_params,
00924                 skipRawJetPtThreshold = cms.double(10.), # GeV
00925                 skipCorrJetPtThreshold = cms.double(1.e-2),
00926                 srcGenJets = cms.InputTag('ak5GenJetsNoNu')
00927             ))
00928             metUncertaintySequence += getattr(process, "smearedUncorrectedJetsForPFMEtByMVA"+postfix)
00929             getattr(process, "calibratedAK5PFJetsForPFMEtMVA"+postfix).src = cms.InputTag('smearedUncorrectedJetsForPFMEtByMVA'+postfix)
00930             getattr(process, "pfMEtMVA"+postfix).srcUncorrJets = cms.InputTag('smearedUncorrectedJetsForPFMEtByMVA'+postfix)
00931             metUncertaintySequence += getattr(process, "calibratedAK5PFJetsForPFMEtMVA"+postfix)
00932             setattr(process, "smearedCorrectedJetsForPFMEtByMVA"+postfix, getattr(process, "smearedUncorrectedJetsForPFMEtByMVA"+postfix).clone(
00933                 src = cms.InputTag('calibratedAK5PFJetsForPFMEtMVA'+postfix),
00934                 jetCorrLabel = cms.string("")
00935             ))
00936             metUncertaintySequence += getattr(process, "smearedCorrectedJetsForPFMEtByMVA"+postfix)
00937             getattr(process, "pfMEtMVA"+postfix).srcCorrJets = cms.InputTag('smearedCorrectedJetsForPFMEtByMVA'+postfix)
00938             metUncertaintySequence += getattr(process, "pfMEtMVA"+postfix)
00939         else:
00940             metUncertaintySequence += getattr(process, "pfMEtMVAsequence"+postfix)
00941         self._addPATMEtProducer(process, metUncertaintySequence,
00942                                 'pfMEtMVA'+postfix, 'patPFMetMVA', collectionsToKeep, postfix)
00943 
00944         for leptonCollection in [ [ 'Electron', 'En', 'electronCollection', 0.3 ],
00945                                   [ 'Photon',   'En', 'photonCollection',   0.3 ],
00946                                   [ 'Muon',     'En', 'muonCollection',     0.3 ],
00947                                   [ 'Tau',      'En', 'tauCollection',      0.3 ] ]:
00948             if self._isValidInputTag(shiftedParticleCollections[leptonCollection[2]]):
00949                 pfCandCollectionLeptonShiftUp, pfCandCollectionLeptonShiftDown = \
00950                   self._addPFCandidatesForPFMEtInput(
00951                     process, metUncertaintySequence,
00952                     shiftedParticleCollections['%s' % leptonCollection[2]], leptonCollection[0], leptonCollection[1],
00953                     shiftedParticleCollections['%s%sUp' % (leptonCollection[2], leptonCollection[1])],
00954                     shiftedParticleCollections['%s%sDown' % (leptonCollection[2], leptonCollection[1])],
00955                     leptonCollection[3],
00956                     pfCandCollection, postfix)
00957                 modulePFMEtLeptonShiftUp = getattr(process, "pfMEtMVA"+postfix).clone(
00958                     srcPFCandidates = cms.InputTag(pfCandCollectionLeptonShiftUp),
00959                     srcLeptons = cms.VInputTag(self._getLeptonsForPFMEtInput(
00960                       shiftedParticleCollections, leptonCollection[2], '%s%sUp' % (leptonCollection[2], leptonCollection[1]), postfix=postfix))
00961                 )
00962                 modulePFMEtLeptonShiftUpName = "pfMEtMVA%s%sUp" % (leptonCollection[0], leptonCollection[1])
00963                 modulePFMEtLeptonShiftUpName += postfix
00964                 setattr(process, modulePFMEtLeptonShiftUpName, modulePFMEtLeptonShiftUp)
00965                 metUncertaintySequence += modulePFMEtLeptonShiftUp
00966                 self._addPATMEtProducer(process, metUncertaintySequence,
00967                                         modulePFMEtLeptonShiftUpName, 'patPFMetMVA%s%sUp' % (leptonCollection[0], leptonCollection[1]), collectionsToKeep, postfix)
00968                 modulePFMEtLeptonShiftDown = getattr(process, "pfMEtMVA"+postfix).clone(
00969                     srcPFCandidates = cms.InputTag(pfCandCollectionLeptonShiftDown),
00970                     srcLeptons = cms.VInputTag(self._getLeptonsForPFMEtInput(
00971                       shiftedParticleCollections, leptonCollection[2], '%s%sDown' % (leptonCollection[2], leptonCollection[1]), postfix=postfix))
00972                 )
00973                 modulePFMEtLeptonShiftDownName = "pfMEtMVA%s%sDown" % (leptonCollection[0], leptonCollection[1])
00974                 modulePFMEtLeptonShiftDownName += postfix
00975                 setattr(process, modulePFMEtLeptonShiftDownName, modulePFMEtLeptonShiftDown)
00976                 metUncertaintySequence += modulePFMEtLeptonShiftDown
00977                 self._addPATMEtProducer(process, metUncertaintySequence,
00978                                         modulePFMEtLeptonShiftDownName, 'patPFMetMVA%s%sDown' % (leptonCollection[0], leptonCollection[1]), collectionsToKeep, postfix)
00979 
00980         if self._isValidInputTag(shiftedParticleCollections['jetCollection']):
00981             setattr(process, "uncorrectedJetsEnUpForPFMEtByMVA"+postfix, cms.EDProducer("ShiftedPFJetProducer",
00982                 src = cms.InputTag(lastUncorrectedJetCollectionForPFMEtByMVA),
00983                 jetCorrInputFileName = cms.FileInPath('PhysicsTools/PatUtils/data/Summer12_V2_DATA_AK5PF_UncertaintySources.txt'),
00984                 jetCorrUncertaintyTag = cms.string("SubTotalDataMC"),
00985                 addResidualJES = cms.bool(True),
00986                 jetCorrLabelUpToL3 = cms.string("ak5PFL1FastL2L3"),
00987                 jetCorrLabelUpToL3Res = cms.string("ak5PFL1FastL2L3Residual"),
00988                 shiftBy = cms.double(+1.*varyByNsigmas)
00989             ))
00990             metUncertaintySequence += getattr(process, "uncorrectedJetsEnUpForPFMEtByMVA"+postfix)
00991             setattr(process, "uncorrectedJetsEnDownForPFMEtByMVA"+postfix, getattr(process, "uncorrectedJetsEnUpForPFMEtByMVA"+postfix).clone(
00992                 shiftBy = cms.double(-1.*varyByNsigmas)
00993             ))
00994             metUncertaintySequence += getattr(process, "uncorrectedJetsEnDownForPFMEtByMVA"+postfix)
00995             setattr(process, "correctedJetsEnUpForPFMEtByMVA"+postfix, getattr(process, "uncorrectedJetsEnUpForPFMEtByMVA"+postfix).clone(
00996                 src = cms.InputTag(lastCorrectedJetCollectionForPFMEtByMVA),
00997                 addResidualJES = cms.bool(False),
00998                 shiftBy = cms.double(+1.*varyByNsigmas)
00999             ))
01000             metUncertaintySequence += getattr(process, "correctedJetsEnUpForPFMEtByMVA"+postfix)
01001             setattr(process, "correctedJetsEnDownForPFMEtByMVA"+postfix, getattr(process, "correctedJetsEnUpForPFMEtByMVA"+postfix).clone(
01002                 shiftBy = cms.double(-1.*varyByNsigmas)
01003             ))
01004             metUncertaintySequence += getattr(process, "correctedJetsEnDownForPFMEtByMVA"+postfix)
01005             pfCandCollectionJetEnUp, pfCandCollectionJetEnDown = \
01006               self._addPFCandidatesForPFMEtInput(
01007                 process, metUncertaintySequence,
01008                 shiftedParticleCollections['lastJetCollection'], "Jet", "En",
01009                 shiftedParticleCollections['jetCollectionEnUpForCorrMEt'], shiftedParticleCollections['jetCollectionEnDownForCorrMEt'],
01010                 0.5,
01011                 pfCandCollection, postfix)
01012             setattr(process, "pfMEtMVAJetEnUp"+postfix, getattr(process, "pfMEtMVA").clone(
01013                 srcCorrJets = cms.InputTag('correctedJetsEnUpForPFMEtByMVA'+postfix),
01014                 srcUncorrJets = cms.InputTag('uncorrectedJetsEnUpForPFMEtByMVA'+postfix),
01015                 srcPFCandidates = cms.InputTag(pfCandCollectionJetEnUp),
01016                 srcLeptons = cms.VInputTag(self._getLeptonsForPFMEtInput(shiftedParticleCollections, postfix=postfix))
01017             ))
01018             metUncertaintySequence += getattr(process, "pfMEtMVAJetEnUp"+postfix)
01019             self._addPATMEtProducer(process, metUncertaintySequence,
01020                                     'pfMEtMVAJetEnUp'+postfix, 'patPFMetMVAJetEnUp', collectionsToKeep, postfix)
01021             setattr(process, "pfMEtMVAJetEnDown"+postfix, getattr(process, "pfMEtMVA"+postfix).clone(
01022                 srcCorrJets = cms.InputTag('correctedJetsEnDownForPFMEtByMVA'+postfix),
01023                 srcUncorrJets = cms.InputTag('uncorrectedJetsEnDownForPFMEtByMVA'+postfix),
01024                 srcPFCandidates = cms.InputTag(pfCandCollectionJetEnDown),
01025                 srcLeptons = cms.VInputTag(self._getLeptonsForPFMEtInput(shiftedParticleCollections, postfix=postfix))
01026             ))
01027             metUncertaintySequence += getattr(process, "pfMEtMVAJetEnDown"+postfix)
01028             self._addPATMEtProducer(process, metUncertaintySequence,
01029                                     'pfMEtMVAJetEnDown'+postfix, 'patPFMetMVAJetEnDown', collectionsToKeep, postfix)
01030 
01031             if hasattr(process, "smearedUncorrectedJetsForPFMEtByMVA"+postfix):
01032                 setattr(process, "uncorrectedJetsResUpForPFMEtByMVA"+postfix, getattr(process, "smearedUncorrectedJetsForPFMEtByMVA"+postfix).clone(
01033                     shiftBy = cms.double(-1.*varyByNsigmas)
01034                 ))
01035                 metUncertaintySequence += getattr(process, "uncorrectedJetsResUpForPFMEtByMVA"+postfix)
01036                 setattr(process, "uncorrectedJetsResDownForPFMEtByMVA"+postfix, getattr(process, "smearedUncorrectedJetsForPFMEtByMVA"+postfix).clone(
01037                     shiftBy = cms.double(+1.*varyByNsigmas)
01038                 ))
01039                 metUncertaintySequence += getattr(process, "uncorrectedJetsResDownForPFMEtByMVA"+postfix)
01040                 setattr(process, "correctedJetsResUpForPFMEtByMVA"+postfix, getattr(process, "smearedCorrectedJetsForPFMEtByMVA"+postfix).clone(
01041                     shiftBy = cms.double(-1.*varyByNsigmas)
01042                 ))
01043                 metUncertaintySequence += getattr(process, "correctedJetsResUpForPFMEtByMVA"+postfix)
01044                 setattr(process, "correctedJetsResDownForPFMEtByMVA"+postfix, getattr(process, "smearedCorrectedJetsForPFMEtByMVA"+postfix).clone(
01045                     shiftBy = cms.double(+1.*varyByNsigmas)
01046                 ))
01047                 metUncertaintySequence += getattr(process, "correctedJetsResDownForPFMEtByMVA"+postfix)
01048                 pfCandCollectionJetResUp, pfCandCollectionJetResDown = \
01049                   self._addPFCandidatesForPFMEtInput(
01050                     process, metUncertaintySequence,
01051                     shiftedParticleCollections['jetCollection'], "Jet", "Res",
01052                     shiftedParticleCollections['jetCollectionResUp'], shiftedParticleCollections['jetCollectionResDown'],
01053                     0.5,
01054                     pfCandCollection, postfix)
01055                 setattr(process, "pfMEtMVAJetResUp"+postfix, getattr(process, "pfMEtMVA"+postfix).clone(
01056                     srcCorrJets = cms.InputTag('correctedJetsResUpForPFMEtByMVA'+postfix),
01057                     srcUncorrJets = cms.InputTag('uncorrectedJetsResUpForPFMEtByMVA'+postfix),
01058                     srcPFCandidates = cms.InputTag(pfCandCollectionJetResUp),
01059                     srcLeptons = cms.VInputTag(self._getLeptonsForPFMEtInput(shiftedParticleCollections, postfix=postfix))
01060                 ))
01061                 metUncertaintySequence += getattr(process, "pfMEtMVAJetResUp"+postfix)
01062                 self._addPATMEtProducer(process, metUncertaintySequence,
01063                                        'pfMEtMVAJetResUp'+postfix, 'patPFMetMVAJetResUp', collectionsToKeep, postfix)
01064                 setattr(process, "pfMEtMVAJetResDown"+postfix, getattr(process, "pfMEtMVA"+postfix).clone(
01065                     srcCorrJets = cms.InputTag('correctedJetsResDownForPFMEtByMVA'+postfix),
01066                     srcUncorrJets = cms.InputTag('uncorrectedJetsResDownForPFMEtByMVA'+postfix),
01067                     srcPFCandidates = cms.InputTag(pfCandCollectionJetResDown),
01068                     srcLeptons = cms.VInputTag(self._getLeptonsForPFMEtInput(shiftedParticleCollections, postfix=postfix))
01069                 ))
01070                 metUncertaintySequence += getattr(process, "pfMEtMVAJetResDown"+postfix)
01071                 self._addPATMEtProducer(process, metUncertaintySequence,
01072                                         'pfMEtMVAJetResDown'+postfix, 'patPFMetMVAJetResDown', collectionsToKeep, postfix)
01073 
01074             setattr(process, "pfCandsNotInJetUnclusteredEnUpForPFMEtByMVA"+postfix, cms.EDProducer("ShiftedPFCandidateProducer",
01075                 src = cms.InputTag('pfCandsNotInJet'),
01076                 shiftBy = cms.double(+1.*varyByNsigmas),
01077                 uncertainty = cms.double(0.10)
01078             ))
01079             metUncertaintySequence += getattr(process, "pfCandsNotInJetUnclusteredEnUpForPFMEtByMVA"+postfix)
01080             setattr(process, "pfCandsNotInJetUnclusteredEnDownForPFMEtByMVA"+postfix, getattr(process, "pfCandsNotInJetUnclusteredEnUpForPFMEtByMVA"+postfix).clone(
01081                 shiftBy = cms.double(-1.*varyByNsigmas)
01082             ))
01083             metUncertaintySequence += getattr(process, "pfCandsNotInJetUnclusteredEnDownForPFMEtByMVA"+postfix)
01084             pfCandCollectionUnclusteredEnUp, pfCandCollectionUnclusteredEnDown = \
01085               self._addPFCandidatesForPFMEtInput(
01086                 process, metUncertaintySequence,
01087                 pfCandCollection, "Unclustered", "En",
01088                 'pfCandsNotInJetUnclusteredEnUpForPFMEtByMVA'+postfix, 'pfCandsNotInJetUnclusteredEnDownForPFMEtByMVA'+postfix, #fixme MM
01089                 0.01,
01090                 pfCandCollection, postfix)
01091             setattr(process, "pfMEtMVAUnclusteredEnUp"+postfix, getattr(process, "pfMEtMVA"+postfix).clone(
01092                 srcPFCandidates = cms.InputTag(pfCandCollectionUnclusteredEnUp),
01093                 srcLeptons = cms.VInputTag(self._getLeptonsForPFMEtInput(shiftedParticleCollections, postfix=postfix))
01094             ))
01095             metUncertaintySequence += getattr(process, "pfMEtMVAUnclusteredEnUp"+postfix)
01096             self._addPATMEtProducer(process, metUncertaintySequence,
01097                                     'pfMEtMVAUnclusteredEnUp'+postfix, 'patPFMetMVAUnclusteredEnUp', collectionsToKeep, postfix)
01098             setattr(process, "pfMEtMVAUnclusteredEnDown"+postfix, getattr(process, "pfMEtMVA"+postfix).clone(
01099                 srcPFCandidates = cms.InputTag(pfCandCollectionUnclusteredEnDown),
01100                 srcLeptons = cms.VInputTag(self._getLeptonsForPFMEtInput(shiftedParticleCollections, postfix=postfix))
01101             ))
01102             metUncertaintySequence += getattr(process, "pfMEtMVAUnclusteredEnDown"+postfix)
01103             self._addPATMEtProducer(process, metUncertaintySequence,
01104                                     'pfMEtMVAUnclusteredEnDown'+postfix, 'patPFMetMVAUnclusteredEnDown', collectionsToKeep, postfix)
01105 
# IN HERE
def metUncertaintyTools::RunMEtUncertainties::_addShiftedParticleCollections (   self,
  process,
  electronCollection,
  photonCollection,
  muonCollection,
  tauCollection,
  jetCollection,
  cleanedJetCollection,
  lastJetCollection,
  jetCollectionResUp,
  jetCollectionResDown,
  varyByNsigmas,
  postfix 
) [private]

Definition at line 219 of file metUncertaintyTools.py.

00228                                                :
00229 
00230         shiftedParticlesForMEtUncertainties = cms.Sequence()
00231         setattr(process, "shiftedParticlesForMEtUncertainties"+postfix, shiftedParticlesForMEtUncertainties)
00232 
00233         shiftedParticleCollections = {}
00234         shiftedParticleCollections['electronCollection'] = electronCollection
00235         shiftedParticleCollections['photonCollection'] = photonCollection
00236         shiftedParticleCollections['muonCollection'] = muonCollection
00237         shiftedParticleCollections['tauCollection'] = tauCollection
00238         shiftedParticleCollections['jetCollection'] = jetCollection
00239         shiftedParticleCollections['cleanedJetCollection'] = cleanedJetCollection
00240         shiftedParticleCollections['lastJetCollection'] = lastJetCollection
00241         shiftedParticleCollections['jetCollectionResUp'] = jetCollectionResUp
00242         shiftedParticleCollections['jetCollectionResDown'] = jetCollectionResDown
00243         collectionsToKeep = []
00244 
00245         #--------------------------------------------------------------------------------------------
00246         # produce collection of jets shifted up/down in energy
00247         #--------------------------------------------------------------------------------------------
00248 
00249         # in case of "raw" (uncorrected) MET,
00250         # add residual jet energy corrections in quadrature to jet energy uncertainties:
00251         # cf. https://twiki.cern.ch/twiki/bin/view/CMS/MissingETUncertaintyPrescription
00252         jetsEnUpForRawMEt = cms.EDProducer("ShiftedPATJetProducer",
00253             src = cms.InputTag(lastJetCollection),
00254             #jetCorrPayloadName = cms.string(jetCorrPayloadName),
00255             #jetCorrUncertaintyTag = cms.string('Uncertainty'),
00256             jetCorrInputFileName = cms.FileInPath('PhysicsTools/PatUtils/data/Summer12_V2_DATA_AK5PF_UncertaintySources.txt'),
00257             jetCorrUncertaintyTag = cms.string("SubTotalDataMC"),
00258             addResidualJES = cms.bool(True),
00259             jetCorrLabelUpToL3 = cms.string("ak5PFL1FastL2L3"),
00260             jetCorrLabelUpToL3Res = cms.string("ak5PFL1FastL2L3Residual"),
00261             shiftBy = cms.double(+1.*varyByNsigmas)
00262         )
00263         jetCollectionEnUpForRawMEt = \
00264           self._addModuleToSequence(process, jetsEnUpForRawMEt,
00265                                     [ "shifted", jetCollection.value(), "EnUpForRawMEt" ],
00266                                     shiftedParticlesForMEtUncertainties, postfix)
00267         shiftedParticleCollections['jetCollectionEnUpForRawMEt'] = jetCollectionEnUpForRawMEt
00268         collectionsToKeep.append(jetCollectionEnUpForRawMEt)
00269         jetsEnDownForRawMEt = jetsEnUpForRawMEt.clone(
00270             shiftBy = cms.double(-1.*varyByNsigmas)
00271         )
00272         jetCollectionEnDownForRawMEt = \
00273           self._addModuleToSequence(process, jetsEnDownForRawMEt,
00274                                     [ "shifted", jetCollection.value(), "EnDownForRawMEt" ],
00275                                     shiftedParticlesForMEtUncertainties, postfix)
00276         shiftedParticleCollections['jetCollectionEnDownForRawMEt'] = jetCollectionEnDownForRawMEt
00277         collectionsToKeep.append(jetCollectionEnDownForRawMEt)
00278 
00279         jetsEnUpForCorrMEt = jetsEnUpForRawMEt.clone(
00280             addResidualJES = cms.bool(False)
00281         )
00282         jetCollectionEnUpForCorrMEt = \
00283           self._addModuleToSequence(process, jetsEnUpForCorrMEt,
00284                                     [ "shifted", jetCollection.value(), "EnUpForCorrMEt" ],
00285                                     shiftedParticlesForMEtUncertainties, postfix)
00286         shiftedParticleCollections['jetCollectionEnUpForCorrMEt'] = jetCollectionEnUpForCorrMEt
00287         collectionsToKeep.append(jetCollectionEnUpForCorrMEt)
00288         jetsEnDownForCorrMEt = jetsEnUpForCorrMEt.clone(
00289             shiftBy = cms.double(-1.*varyByNsigmas)
00290         )
00291         jetCollectionEnDownForCorrMEt = \
00292           self._addModuleToSequence(process, jetsEnDownForCorrMEt,
00293                                     [ "shifted", jetCollection.value(), "EnDownForCorrMEt" ],
00294                                     shiftedParticlesForMEtUncertainties, postfix)
00295         shiftedParticleCollections['jetCollectionEnDownForCorrMEt'] = jetCollectionEnDownForCorrMEt
00296         collectionsToKeep.append(jetCollectionEnDownForCorrMEt)
00297 
00298         #--------------------------------------------------------------------------------------------
00299         # produce collection of electrons shifted up/down in energy
00300         #--------------------------------------------------------------------------------------------
00301 
00302         electronCollectionEnUp = None
00303         electronCollectionEnDown = None
00304         if self._isValidInputTag(electronCollection):
00305             electronsEnUp = cms.EDProducer("ShiftedPATElectronProducer",
00306                 src = electronCollection,
00307                 binning = cms.VPSet(
00308                     cms.PSet(
00309                         binSelection = cms.string('isEB'),
00310                         binUncertainty = cms.double(0.006)
00311                     ),
00312                     cms.PSet(
00313                         binSelection = cms.string('!isEB'),
00314                         binUncertainty = cms.double(0.015)
00315                     ),
00316                 ),
00317                 shiftBy = cms.double(+1.*varyByNsigmas)
00318             )
00319             electronCollectionEnUp = \
00320               self._addModuleToSequence(process, electronsEnUp,
00321                                         [ "shifted", electronCollection.value(), "EnUp" ],
00322                                         shiftedParticlesForMEtUncertainties, postfix)
00323             shiftedParticleCollections['electronCollectionEnUp'] = electronCollectionEnUp
00324             collectionsToKeep.append(electronCollectionEnUp)
00325             electronsEnDown = electronsEnUp.clone(
00326                 shiftBy = cms.double(-1.*varyByNsigmas)
00327             )
00328             electronCollectionEnDown = \
00329               self._addModuleToSequence(process, electronsEnDown,
00330                                         [ "shifted", electronCollection.value(), "EnDown" ],
00331                                         shiftedParticlesForMEtUncertainties, postfix)
00332             shiftedParticleCollections['electronCollectionEnDown'] = electronCollectionEnDown
00333             collectionsToKeep.append(electronCollectionEnDown)
00334 
00335         #--------------------------------------------------------------------------------------------
00336         # produce collection of (high Pt) photon candidates shifted up/down in energy
00337         #--------------------------------------------------------------------------------------------
00338 
00339         photonCollectionEnUp = None
00340         photonCollectionEnDown = None
00341         if self._isValidInputTag(photonCollection):
00342             photonsEnUp = cms.EDProducer("ShiftedPATPhotonProducer",
00343                 src = photonCollection,
00344                 binning = cms.VPSet(
00345                     cms.PSet(
00346                         binSelection = cms.string('isEB = true'),
00347                         binUncertainty = cms.double(0.01)
00348                     ),
00349                     cms.PSet(
00350                         binSelection = cms.string('isEB = false'),
00351                         binUncertainty = cms.double(0.025)
00352                     ),
00353                 ),
00354                 shiftBy = cms.double(+1.*varyByNsigmas)
00355             )
00356             photonCollectionEnUp = \
00357               self._addModuleToSequence(process, photonsEnUp,
00358                                         [ "shifted", photonCollection.value(), "EnUp" ],
00359                                         shiftedParticlesForMEtUncertainties, postfix)
00360             shiftedParticleCollections['photonCollectionEnUp'] = photonCollectionEnUp
00361             collectionsToKeep.append(photonCollectionEnUp)
00362             photonsEnDown = photonsEnUp.clone(
00363                 shiftBy = cms.double(-1.*varyByNsigmas)
00364             )
00365             photonCollectionEnDown = \
00366               self._addModuleToSequence(process, photonsEnDown,
00367                                         [ "shifted", photonCollection.value(), "EnDown" ],
00368                                         shiftedParticlesForMEtUncertainties, postfix)
00369             shiftedParticleCollections['photonCollectionEnDown'] = photonCollectionEnDown
00370             collectionsToKeep.append(photonCollectionEnDown)
00371 
00372         #--------------------------------------------------------------------------------------------
00373         # produce collection of muons shifted up/down in energy/momentum
00374         #--------------------------------------------------------------------------------------------
00375 
00376         muonCollectionEnUp = None
00377         muonCollectionEnDown = None
00378         if self._isValidInputTag(muonCollection):
00379             muonsEnUp = cms.EDProducer("ShiftedPATMuonProducer",
00380                 src = muonCollection,
00381                 uncertainty = cms.double(0.002),
00382                 shiftBy = cms.double(+1.*varyByNsigmas)
00383             )
00384             muonCollectionEnUp = \
00385               self._addModuleToSequence(process, muonsEnUp,
00386                                         [ "shifted", muonCollection.value(), "EnUp" ],
00387                                         shiftedParticlesForMEtUncertainties, postfix)
00388             shiftedParticleCollections['muonCollectionEnUp'] = muonCollectionEnUp
00389             collectionsToKeep.append(muonCollectionEnUp)
00390             muonsEnDown = muonsEnUp.clone(
00391                 shiftBy = cms.double(-1.*varyByNsigmas)
00392             )
00393             muonCollectionEnDown = \
00394               self._addModuleToSequence(process, muonsEnDown,
00395                                         [ "shifted", muonCollection.value(), "EnDown" ],
00396                                         shiftedParticlesForMEtUncertainties, postfix)
00397             shiftedParticleCollections['muonCollectionEnDown'] = muonCollectionEnDown
00398             collectionsToKeep.append(muonCollectionEnDown)
00399 
00400         #--------------------------------------------------------------------------------------------
00401         # produce collection of tau-jets shifted up/down in energy
00402         #--------------------------------------------------------------------------------------------
00403 
00404         tauCollectionEnUp = None
00405         tauCollectionEnDown = None
00406         if self._isValidInputTag(tauCollection):
00407             tausEnUp = cms.EDProducer("ShiftedPATTauProducer",
00408                 src = tauCollection,
00409                 uncertainty = cms.double(0.03),
00410                 shiftBy = cms.double(+1.*varyByNsigmas)
00411             )
00412             tauCollectionEnUp = \
00413               self._addModuleToSequence(process, tausEnUp,
00414                                         [ "shifted", tauCollection.value(), "EnUp" ],
00415                                         shiftedParticlesForMEtUncertainties, postfix)
00416             shiftedParticleCollections['tauCollectionEnUp'] = tauCollectionEnUp
00417             collectionsToKeep.append(tauCollectionEnUp)
00418             tausEnDown = tausEnUp.clone(
00419                 shiftBy = cms.double(-1.*varyByNsigmas)
00420             )
00421             tauCollectionEnDown = \
00422               self._addModuleToSequence(process, tausEnDown,
00423                                         [ "shifted", tauCollection.value(), "EnDown" ],
00424                                         shiftedParticlesForMEtUncertainties, postfix)
00425             shiftedParticleCollections['tauCollectionEnDown'] = tauCollectionEnDown
00426             collectionsToKeep.append(tauCollectionEnDown)
00427 
00428         return ( shiftedParticleCollections, collectionsToKeep )

def metUncertaintyTools::RunMEtUncertainties::_addSmearedJets (   self,
  process,
  jetCollection,
  smearedJetCollectionName_parts,
  jetSmearFileName,
  jetSmearHistogram,
  varyByNsigmas,
  shiftBy = None,
  postfix = "" 
) [private]

Definition at line 106 of file metUncertaintyTools.py.

00109                                                      :
00110 
00111         smearedJets = cms.EDProducer("SmearedPATJetProducer",
00112             src = cms.InputTag(jetCollection),
00113             dRmaxGenJetMatch = cms.string('TMath::Min(0.5, 0.1 + 0.3*TMath::Exp(-0.05*(genJetPt - 10.)))'),
00114             sigmaMaxGenJetMatch = cms.double(5.),
00115             inputFileName = cms.FileInPath(jetSmearFileName),
00116             lutName = cms.string(jetSmearHistogram),
00117             jetResolutions = jetResolutions.METSignificance_params,
00118             # CV: skip jet smearing for pat::Jets for which the jet-energy correction (JEC) factors are either very large or negative
00119             #     since both cases produce unphysically large tails in the Type 1 corrected MET distribution after the smearing,
00120             #
00121             #     e.g. raw jet:   energy = 50 GeV, eta = 2.86, pt =  1   GeV
00122             #          corr. jet: energy = -3 GeV            , pt = -0.1 GeV (JEC factor L1fastjet*L2*L3 = -17)
00123             #                     energy = 10 GeV for corrected jet after smearing
00124             #         --> smeared raw jet energy = -170 GeV !!
00125             #
00126             #         --> (corr. - raw) jet contribution to MET = -1 (-10) GeV before (after) smearing,
00127             #             even though jet energy got smeared by merely 1 GeV
00128             #
00129             skipJetSelection = cms.string(
00130                 'jecSetsAvailable & abs(energy - correctedP4("Uncorrected").energy) > (5.*min(energy, correctedP4("Uncorrected").energy))'
00131             ),
00132             skipRawJetPtThreshold = cms.double(10.), # GeV
00133             skipCorrJetPtThreshold = cms.double(1.e-2)
00134         )
00135         if shiftBy is not None:
00136             setattr(smearedJets, "shiftBy", cms.double(shiftBy*varyByNsigmas))
00137         smearedJetCollection = \
00138           self._addModuleToSequence(process, smearedJets,
00139                                     smearedJetCollectionName_parts,
00140                                     getattr(process, "metUncertaintySequence"+postfix), postfix)
00141 
00142         return smearedJetCollection

def metUncertaintyTools::RunMEtUncertainties::_getLeptonsForPFMEtInput (   self,
  shiftedParticleCollections,
  substituteKeyUnshifted = None,
  substituteKeyShifted = None,
  postfix = "" 
) [private]

Definition at line 861 of file metUncertaintyTools.py.

00862                                                                                                                                           :
00863         retVal = []
00864         for collectionName in [ 'electronCollection',
00865                                 'photonCollection',
00866                                 'muonCollection',
00867                                 'tauCollection' ]:
00868             if self._isValidInputTag(shiftedParticleCollections[collectionName]):
00869                 if substituteKeyUnshifted is not None and substituteKeyUnshifted in shiftedParticleCollections.keys() and \
00870                    substituteKeyShifted is not None and substituteKeyShifted in shiftedParticleCollections.keys() and \
00871                    shiftedParticleCollections[collectionName] == shiftedParticleCollections[substituteKeyUnshifted]:
00872                     retVal.append(cms.InputTag(shiftedParticleCollections[substituteKeyShifted]))
00873                 else:
00874                     retVal.append(shiftedParticleCollections[collectionName])
00875         return retVal

def metUncertaintyTools::RunMEtUncertainties::_initializeInputTag (   self,
  input,
  default 
) [private]

Definition at line 199 of file metUncertaintyTools.py.

00200                                                  :
00201         retVal = None
00202         if input is None:
00203             retVal = self._defaultParameters[default].value
00204         elif type(input) == str:
00205             retVal = cms.InputTag(input)
00206         else:
00207             retVal = input
00208         return retVal

def metUncertaintyTools::RunMEtUncertainties::_isValidInputTag (   input) [private]

Definition at line 210 of file metUncertaintyTools.py.

00211                                :
00212         input_str = input
00213         if isinstance(input, cms.InputTag):
00214             input_str = input.value()
00215         if input is None or input_str == '""':
00216             return False
00217         else:
00218             return True

def metUncertaintyTools::RunMEtUncertainties::_propagateMEtUncertainties (   self,
  process,
  particleCollection,
  particleType,
  shiftType,
  particleCollectionShiftUp,
  particleCollectionShiftDown,
  metProducer,
  sequence,
  postfix 
) [private]

Definition at line 143 of file metUncertaintyTools.py.

00146                                                                   :
00147 
00148         # produce MET correction objects
00149         # (sum of differences in four-momentum between original and up/down shifted particle collection)
00150         moduleMETcorrShiftUp = cms.EDProducer("ShiftedParticleMETcorrInputProducer",
00151             srcOriginal = cms.InputTag(particleCollection),
00152             srcShifted = cms.InputTag(particleCollectionShiftUp)
00153         )
00154         moduleMETcorrShiftUpName = "patPFMETcorr%s%sUp" % (particleType, shiftType)
00155         moduleMETcorrShiftUpName += postfix
00156         setattr(process, moduleMETcorrShiftUpName, moduleMETcorrShiftUp)
00157         sequence += moduleMETcorrShiftUp
00158         moduleMETcorrShiftDown = moduleMETcorrShiftUp.clone(
00159             srcShifted = cms.InputTag(particleCollectionShiftDown)
00160         )
00161         moduleMETcorrShiftDownName = "patPFMETcorr%s%sDown" % (particleType, shiftType)
00162         moduleMETcorrShiftDownName += postfix
00163         setattr(process, moduleMETcorrShiftDownName, moduleMETcorrShiftDown)
00164         sequence += moduleMETcorrShiftDown
00165 
00166         # propagate effects of up/down shifts to MET
00167         moduleMETshiftUp = metProducer.clone(
00168             src = cms.InputTag(metProducer.label()),
00169             srcType1Corrections = cms.VInputTag(
00170                 cms.InputTag(moduleMETcorrShiftUpName)
00171             )
00172         )
00173         metProducerLabel = metProducer.label()
00174         if postfix != "":
00175             if metProducerLabel[-len(postfix):] == postfix:
00176                 metProducerLabel = metProducerLabel[0:-len(postfix)]
00177             else:
00178                 raise StandardError("Tried to remove postfix %s from label %s, but it wasn't there" % (postfix, metProducerLabel))
00179         moduleMETshiftUpName = "%s%s%sUp" % (metProducerLabel, particleType, shiftType)
00180         moduleMETshiftUpName += postfix
00181         setattr(process, moduleMETshiftUpName, moduleMETshiftUp)
00182         sequence += moduleMETshiftUp
00183         moduleMETshiftDown = moduleMETshiftUp.clone(
00184             srcType1Corrections = cms.VInputTag(
00185                 cms.InputTag(moduleMETcorrShiftDownName)
00186             )
00187         )
00188         moduleMETshiftDownName = "%s%s%sDown" % (metProducerLabel, particleType, shiftType)
00189         moduleMETshiftDownName += postfix
00190         setattr(process, moduleMETshiftDownName, moduleMETshiftDown)
00191         sequence += moduleMETshiftDown
00192 
00193         metCollectionsUp_Down = [
00194             moduleMETshiftUpName,
00195             moduleMETshiftDownName
00196         ]
00197 
00198         return metCollectionsUp_Down

def metUncertaintyTools::RunMEtUncertainties::getDefaultParameters (   self)

Definition at line 71 of file metUncertaintyTools.py.

00072                                   :
00073         return self._defaultParameters

def metUncertaintyTools::RunMEtUncertainties::toolCode (   self,
  process 
)

Definition at line 1463 of file metUncertaintyTools.py.

01464                                :
01465         electronCollection = self._parameters['electronCollection'].value
01466         photonCollection = self._parameters['photonCollection'].value
01467         muonCollection = self._parameters['muonCollection'].value
01468         tauCollection = self._parameters['tauCollection'].value
01469         jetCollection = self._parameters['jetCollection'].value
01470         jetCorrLabel = self._parameters['jetCorrLabel'].value
01471         dRjetCleaning =  self._parameters['dRjetCleaning'].value
01472         doSmearJets = self._parameters['doSmearJets'].value
01473         makeType1corrPFMEt = self._parameters['makeType1corrPFMEt'].value
01474         makeType1p2corrPFMEt = self._parameters['makeType1p2corrPFMEt'].value
01475         makePFMEtByMVA = self._parameters['makePFMEtByMVA'].value
01476         makeNoPileUpPFMEt = self._parameters['makeNoPileUpPFMEt'].value
01477         doApplyType0corr = self._parameters['doApplyType0corr'].value
01478         sysShiftCorrParameter = self._parameters['sysShiftCorrParameter'].value
01479         doApplySysShiftCorr = self._parameters['doApplySysShiftCorr'].value
01480         jetSmearFileName = self._parameters['jetSmearFileName'].value
01481         jetSmearHistogram = self._parameters['jetSmearHistogram'].value
01482         pfCandCollection = self._parameters['pfCandCollection'].value
01483         jetCorrPayloadName = self._parameters['jetCorrPayloadName'].value
01484         varyByNsigmas = self._parameters['varyByNsigmas'].value
01485         addToPatDefaultSequence = self._parameters['addToPatDefaultSequence'].value
01486         outputModule = self._parameters['outputModule'].value
01487         postfix = self._parameters['postfix'].value
01488 
01489         metUncertaintySequence = cms.Sequence()
01490         setattr(process, "metUncertaintySequence"+postfix, metUncertaintySequence)
01491 
01492         collectionsToKeep = []
01493 
01494         # produce collection of jets not overlapping with reconstructed
01495         # electrons/photons, muons and tau-jet candidates
01496         jetsNotOverlappingWithLeptonsForMEtUncertainty = cms.EDProducer("PATJetCleaner",
01497             src = jetCollection,
01498             preselection = cms.string(''),
01499             checkOverlaps = cms.PSet(),
01500             finalCut = cms.string('')
01501         )
01502         numOverlapCollections = 0
01503         for collection in [
01504             [ 'electrons', electronCollection ],
01505             [ 'photons',   photonCollection   ],
01506             [ 'muons',     muonCollection     ],
01507             [ 'taus',      tauCollection      ] ]:
01508             if self._isValidInputTag(collection[1]):
01509                 setattr(jetsNotOverlappingWithLeptonsForMEtUncertainty.checkOverlaps, collection[0], cms.PSet(
01510                     src                 = collection[1],
01511                     algorithm           = cms.string("byDeltaR"),
01512                     preselection        = cms.string(""),
01513                     deltaR              = cms.double(0.5),
01514                     checkRecoComponents = cms.bool(False),
01515                     pairCut             = cms.string(""),
01516                     requireNoOverlaps   = cms.bool(True),
01517                 ))
01518                 numOverlapCollections = numOverlapCollections + 1
01519         lastJetCollection = jetCollection.value()
01520         if numOverlapCollections >= 1:
01521             lastJetCollection = \
01522               self._addModuleToSequence(process, jetsNotOverlappingWithLeptonsForMEtUncertainty,
01523                                         [ jetCollection.value(), "NotOverlappingWithLeptonsForMEtUncertainty" ],
01524                                         metUncertaintySequence, postfix)
01525         cleanedJetCollection = lastJetCollection
01526 
01527         # smear jet energies to account for difference in jet resolutions between MC and Data
01528         # (cf. JME-10-014 PAS)
01529         jetCollectionResUp = None
01530         jetCollectionResDown = None
01531         if doSmearJets:
01532             lastJetCollection = \
01533               self._addSmearedJets(process, cleanedJetCollection, [ "smeared", jetCollection.value() ],
01534                                    jetSmearFileName, jetSmearHistogram, varyByNsigmas, postfix=postfix)
01535 
01536             jetCollectionResUp = \
01537               self._addSmearedJets(process, cleanedJetCollection, [ "smeared", jetCollection.value(), "ResUp" ],
01538                                    jetSmearFileName, jetSmearHistogram, varyByNsigmas,
01539                                    -1., postfix=postfix)
01540             collectionsToKeep.append(jetCollectionResUp)
01541             jetCollectionResDown = \
01542               self._addSmearedJets(process, cleanedJetCollection, [ "smeared", jetCollection.value(), "ResDown" ],
01543                                    jetSmearFileName, jetSmearHistogram, varyByNsigmas,
01544                                    +1., postfix=postfix)
01545             collectionsToKeep.append(jetCollectionResDown)
01546 
01547         collectionsToKeep.append(lastJetCollection)
01548 
01549         #--------------------------------------------------------------------------------------------
01550         # produce collection of electrons/photons, muons, tau-jet candidates and jets
01551         # shifted up/down in energy by their respective energy uncertainties
01552         #--------------------------------------------------------------------------------------------
01553 
01554         shiftedParticleCollections, addCollectionsToKeep = \
01555           self._addShiftedParticleCollections(process,
01556                                               electronCollection,
01557                                               photonCollection,
01558                                               muonCollection,
01559                                               tauCollection,
01560                                               jetCollection, cleanedJetCollection, lastJetCollection,
01561                                               jetCollectionResUp, jetCollectionResDown,
01562                                               varyByNsigmas,
01563                                               postfix)
01564         metUncertaintySequence += getattr(process, "shiftedParticlesForMEtUncertainties"+postfix)
01565         collectionsToKeep.extend(addCollectionsToKeep)
01566 
01567         #--------------------------------------------------------------------------------------------
01568         # propagate shifted particle energies to Type 1 and Type 1 + 2 corrected PFMET
01569         #--------------------------------------------------------------------------------------------
01570 
01571         self._addCorrPFMEt(process, metUncertaintySequence,
01572                            shiftedParticleCollections, pfCandCollection,
01573                            collectionsToKeep,
01574                            doSmearJets,
01575                            makeType1corrPFMEt,
01576                            makeType1p2corrPFMEt,
01577                            doApplyType0corr,
01578                            sysShiftCorrParameter,
01579                            doApplySysShiftCorr,
01580                            jetCorrLabel,
01581                            varyByNsigmas,
01582                            postfix)
01583 
01584         #--------------------------------------------------------------------------------------------
01585         # propagate shifted particle energies to MVA-based PFMET
01586         #--------------------------------------------------------------------------------------------
01587 
01588         self._addPFMEtByMVA(process, metUncertaintySequence,
01589                             shiftedParticleCollections, pfCandCollection,
01590                             collectionsToKeep,
01591                             doSmearJets,
01592                             makePFMEtByMVA,
01593                             varyByNsigmas,
01594                             postfix)
01595 
01596         #--------------------------------------------------------------------------------------------
01597         # propagate shifted particle energies to no-PU PFMET
01598         #--------------------------------------------------------------------------------------------
01599 
01600         self._addNoPileUpPFMEt(process, metUncertaintySequence,
01601                                shiftedParticleCollections, pfCandCollection,
01602                                collectionsToKeep,
01603                                doSmearJets,
01604                                makeNoPileUpPFMEt,
01605                                varyByNsigmas,
01606                                postfix)
01607 
01608         # insert metUncertaintySequence into patDefaultSequence
01609         if addToPatDefaultSequence and process.options.allowUnscheduled == False:
01610             if not hasattr(process, "patDefaultSequence"):
01611                 raise ValueError("PAT default sequence is not defined !!")
01612             process.patDefaultSequence += metUncertaintySequence
01613 
01614         # add shifted + unshifted collections pf pat::Electrons/Photons,
01615         # Muons, Taus, Jets and MET to PAT-tuple event content
01616         if outputModule is not None and hasattr(process, outputModule):
01617             getattr(process, outputModule).outputCommands = _addEventContent(
01618                 getattr(process, outputModule).outputCommands,
01619                 [ 'keep *_%s_*_%s' % (collectionToKeep, process.name_()) for collectionToKeep in collectionsToKeep ])
01620 
01621 runMEtUncertainties=RunMEtUncertainties()

Member Data Documentation

Definition at line 20 of file metUncertaintyTools.py.

tuple metUncertaintyTools::RunMEtUncertainties::_defaultParameters = dicttypes.SortedKeysDict() [static, private]

Definition at line 19 of file metUncertaintyTools.py.

string metUncertaintyTools::RunMEtUncertainties::_label = 'runMEtUncertainties' [static, private]

Definition at line 18 of file metUncertaintyTools.py.

Definition at line 20 of file metUncertaintyTools.py.