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

Protect against missing track info in MiniAOD #20741

Merged
merged 4 commits into from
Oct 12, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions RecoJets/JetProducers/src/PileupJetIdAlgo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ std::unique_ptr<const GBRForest> PileupJetIdAlgo::getMVA(const std::vector<std::
if( tmvaNames_[*it].empty() ) tmvaNames_[*it] = *it;
tmpTMVAReader.AddSpectator( *it, variables_[ tmvaNames_[*it] ].first );
}
reco::details::loadTMVAWeights(&tmpTMVAReader, tmvaMethod_.c_str(), tmvaWeights.c_str());
reco::details::loadTMVAWeights(&tmpTMVAReader, tmvaMethod_, tmvaWeights);
return( std::make_unique<const GBRForest> ( dynamic_cast<TMVA::MethodBDT*>( tmpTMVAReader.FindMVA(tmvaMethod_.c_str()) ) ) );
}

Expand All @@ -177,7 +177,7 @@ float PileupJetIdAlgo::getMVAval(const std::vector<std::string> &varList, const
float mvaval = -2;
std::vector<float> vars;
for(std::vector<std::string>::const_iterator it=varList.begin(); it!=varList.end(); ++it) {
std::pair<float *,float> var = variables_.at((*it).c_str());
std::pair<float *,float> var = variables_.at(*it);
vars.push_back( *var.first );
}
mvaval = reader->GetClassifier(vars.data());
Expand Down Expand Up @@ -391,12 +391,15 @@ PileupJetIdentifier PileupJetIdAlgo::computeIdVariables(const reco::Jet * jet, f
}
if(pfTrk==nullptr) { //protection against empty pointers for the miniAOD case
//To handle the electron case
if(lPF!=nullptr) {
if(isPacked) {
Copy link
Contributor

Choose a reason for hiding this comment

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

given that #20491 is merged, you could use the PackedCandidate::dz(point) and PackedCandidate::dxy(point) methods, which are available for all particles (hasTrackDetails is only needed to get the covariance, hitpattern or other more detailed information)

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 will change this. Was #20491 also backported to 93?

internalId_.d0_ = std::abs(lPack->dxy(vtx->position()));
internalId_.dZ_ = std::abs(lPack->dz(vtx->position()));
}
else if(lPF!=nullptr) {
pfTrk=(lPF->trackRef().get()==nullptr)?lPF->gsfTrackRef().get():lPF->trackRef().get();
internalId_.d0_ = std::abs(pfTrk->dxy(vtx->position()));
internalId_.dZ_ = std::abs(pfTrk->dz(vtx->position()));
}
const reco::Track& impactTrack = (lPack==nullptr)?(*pfTrk):(lPack->pseudoTrack());
internalId_.d0_ = std::abs(impactTrack.dxy(vtx->position()));
internalId_.dZ_ = std::abs(impactTrack.dz(vtx->position()));
}
else {
internalId_.d0_ = std::abs(pfTrk->dxy(vtx->position()));
Expand Down