Skip to content

Commit

Permalink
Throw when no resolution fits are available, instead of just issuing …
Browse files Browse the repository at this point in the history
…a LogError
  • Loading branch information
perrotta committed Mar 31, 2021
1 parent 1c56402 commit db40450
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
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

0 comments on commit db40450

Please sign in to comment.