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

Throw when no resolution fits are available in ObjectResolutionCalc #33316

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 1 addition & 8 deletions PhysicsTools/PatUtils/interface/ObjectResolutionCalc.h
Expand Up @@ -12,23 +12,16 @@
\version $Id: ObjectResolutionCalc.h,v 1.5 2008/10/08 19:19:25 gpetrucc Exp $
*/

#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Utilities/interface/Exception.h"

#include "DataFormats/PatCandidates/interface/Electron.h"
#include "DataFormats/PatCandidates/interface/Muon.h"
#include "DataFormats/PatCandidates/interface/Tau.h"
#include "DataFormats/PatCandidates/interface/MET.h"
#include "DataFormats/PatCandidates/interface/Jet.h"

#include "TF1.h"
#include "TH1.h"
#include "TFile.h"
#include "TKey.h"
#include "TString.h"
#include "TMultiLayerPerceptron.h"
#include "TString.h"

namespace pat {

Expand Down
15 changes: 12 additions & 3 deletions PhysicsTools/PatUtils/src/ObjectResolutionCalc.cc
Expand Up @@ -3,6 +3,12 @@

#include "PhysicsTools/PatUtils/interface/ObjectResolutionCalc.h"

#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Utilities/interface/Exception.h"

#include "TH1.h"
#include "TKey.h"

using namespace pat;

// constructor with path; default should not be used
Expand All @@ -11,9 +17,10 @@ ObjectResolutionCalc::ObjectResolutionCalc(const TString& resopath, bool useNN =
<< ("ObjectResolutionCalc") << "=== Constructing a TopObjectResolutionCalc...";
resoFile_ = new TFile(resopath);
if (!resoFile_)
edm::LogError("ObjectResolutionCalc") << "No resolutions fits for this file available: " << resopath << "...";
TString resObsName[8] = {"_ares", "_bres", "_cres", "_dres", "_thres", "_phres", "_etres", "_etares"};
throw edm::Exception(edm::errors::LogicError)
<< "ObjectResolutionCalc: no resolutions fits for this file available: " << resopath << "...";

TString resObsName[8] = {"_ares", "_bres", "_cres", "_dres", "_thres", "_phres", "_etres", "_etares"};
TList* keys = resoFile_->GetListOfKeys();
TIter nextitem(keys);
TKey* key = nullptr;
Expand Down Expand Up @@ -70,8 +77,10 @@ int ObjectResolutionCalc::etaBin(float eta) {
int nrEtaBins = etaBinVals_.size() - 1;
int bin = nrEtaBins - 1;
for (int i = 0; i < nrEtaBins; i++) {
if (fabs(eta) > etaBinVals_[i] && fabs(eta) < etaBinVals_[i + 1])
if (fabs(eta) > etaBinVals_[i] && fabs(eta) < etaBinVals_[i + 1]) {
bin = i;
break;
}
}
return bin;
}
Expand Down