Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash in pat::MET when no Type-I uncertainties are added #11394

Merged
merged 1 commit into from
Oct 4, 2015

Conversation

blinkseb
Copy link
Contributor

Hello,

This PR fixes a crash I experienced when running on CMSSW 7.4.12 patch4. I manually create a new slimmedMETs using the following code snippet:

from JMEAnalysis.JetToolbox.jetToolbox_cff import jetToolbox
jetToolbox(process, 'ak4', 'ak4CHSJetSequence', 'out', PUMethod='CHS', runOnMC=not isData, miniAOD=True, addPUJetID=False)

from PhysicsTools.PatAlgos.tools.metTools import addMETCollection
process.load('RecoMET.METProducers.PFMET_cfi')

process.pfMet.src = cms.InputTag('packedPFCandidates')
addMETCollection(process, labelName='patPFMet', metSource='pfMet')


process.load('JetMETCorrections.Configuration.JetCorrectors_cff')
from JetMETCorrections.Type1MET.correctionTermsPfMetType1Type2_cff import corrPfMetType1
from JetMETCorrections.Type1MET.correctedMet_cff import pfMetT1

process.corrPfMetType1 = corrPfMetType1.clone(
        src = 'ak4PFJetsCHS',
        jetCorrLabel = 'ak4PFCHSL1FastL2L3Corrector' if not isData else 'ak4PFCHSL1FastL2L3ResidualCorrector',
        offsetCorrLabel = 'ak4PFCHSL1FastjetCorrector'
    )
    process.pfMetT1 = pfMetT1.clone(
        src = 'pfMet',
        srcCorrections = [cms.InputTag("corrPfMetType1", "type1")]
    )

addMETCollection(process, labelName='patMET', metSource='pfMetT1') # T1 MET

from PhysicsTools.PatAlgos.slimming.slimmedMETs_cfi import slimmedMETs
del slimmedMETs.caloMET

process.slimmedMETs = slimmedMETs.clone()

process.slimmedMETs.src = cms.InputTag("patMET")
process.slimmedMETs.rawVariation = cms.InputTag("patPFMet")

I explicitly do not want T1 uncertainties, I'm only interested in T1 met + Raw met.

When trying to access pat::MET::uncorPt() the code crash inside the pat::MET::findMETTotalShift.

This is because in this particular case, the uncertainties_ array is empty, because, since there's no Type1 uncertainties, the function setUncShift is never called by PATMETSlimmer.

This PR fixes both issues: first, it ensure that if uncertainties_ is empty, the code no longer crashed. Second, it fixes PATMETSlimmer by making sure setUncShift is called not matter the type of uncertainties.

This PR changes pat::MET::findMETTotalShift to prevent the crash by checking if uncertainties_ is empty.

If merged, it'll need to be backport to 7.5 and 7.4.

Thanks

@cmsbuild
Copy link
Contributor

A new Pull Request was created by @blinkseb (Sébastien Brochet) for CMSSW_7_6_X.

Fix crash in pat::MET when no Type-I uncertainties are added

It involves the following packages:

DataFormats/PatCandidates
PhysicsTools/PatAlgos

@cmsbuild, @vadler, @monttj can you please review it and eventually sign? Thanks.
@TaiSakuma, @imarches, @ahinzmann, @acaudron, @mmarionncern, @rappoccio, @jdolen, @nhanvtran, @schoef, @ferencek, @gpetruc, @mariadalfonso, @pvmulder this is something you requested to watch as well.
You can sign-off by replying to this message having '+1' in the first line of your reply.
You can reject by replying to this message having '-1' in the first line of your reply.
If you are a L2 or a release manager you can ask for tests by saying 'please test' in the first line of a comment.
@Degano you are the release manager for this.
You can merge this pull request by typing 'merge' in the first line of your comment.

@@ -94,11 +94,13 @@ void pat::PATMETSlimmer::maybeReadShifts(const edm::ParameterSet &basePSet, cons
}
else if(level==pat::MET::Smear) {
shifts_.push_back(OneMETShift(pat::MET::NoShift, level, baseTag, consumesCollector(), readFromMiniAOD, true, false, true));
shifts_.push_back(OneMETShift(pat::MET::NoShift, level, baseTag, consumesCollector(), readFromMiniAOD, false, true, true));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That line should be removed, as it will conflict with the storage of the MET type1, the way it is done, it will erase the type1MET to put the type1Smeared MET in place

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I wasn't sure about this one. I'll remove up, thanks!

@blinkseb blinkseb force-pushed the from-CMSSW_7_6_0_pre5 branch from a91fdd4 to 5a75f34 Compare September 21, 2015 12:04
@blinkseb
Copy link
Contributor Author

I updated the PR with @mmarionncern comments.

@cmsbuild
Copy link
Contributor

Pull request #11394 was updated. @cmsbuild, @vadler, @monttj can you please check and sign again.

@mmarionncern
Copy link

+1 for me

@mariadalfonso
Copy link
Contributor

@blinkseb Can you make a PR in the 74X and 75X we can aim to have it in an analysis release.

@monttj
Copy link
Contributor

monttj commented Sep 22, 2015

please test

@cmsbuild
Copy link
Contributor

The tests are being triggered in jenkins.

@blinkseb
Copy link
Contributor Author

@mariadalfonso I opened two new PR for 7.4.x ( #11413 ) and 7.5.x ( #11412 )

@lgray
Copy link
Contributor

lgray commented Sep 22, 2015

@blinkseb I only see the changes you mention in the PR description to pat::MET::findMETTotalShift, there are no changes to PATMETSlimmer in your commit history.

@blinkseb
Copy link
Contributor Author

@lgray See the discussion history with @mmarionncern ; those changes were not correct. I'll edit the PR description

@cmsbuild
Copy link
Contributor

@cmsbuild
Copy link
Contributor

@blinkseb
Copy link
Contributor Author

Any updates on this?

davidlange6 added a commit that referenced this pull request Oct 4, 2015
Fix crash in pat::MET when no Type-I uncertainties are added
@davidlange6 davidlange6 merged commit 1a67427 into cms-sw:CMSSW_7_6_X Oct 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants