CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
pat::ObjectResolutionCalc Class Reference

Class to calculate MC resolutions for pat objects. More...

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

Public Member Functions

int etaBin (float eta)
 
 ObjectResolutionCalc ()
 
 ObjectResolutionCalc (const TString &resopath, bool useNN)
 
float obsRes (int obs, int eta, float eT)
 
template<typename T >
void operator() (T &obj)
 
 ~ObjectResolutionCalc ()
 

Private Attributes

std::vector< float > etaBinVals_
 
TF1 fResVsEt_ [10][10]
 
TMultiLayerPerceptron * network_ [10]
 
TFile * resoFile_
 
bool useNN_
 

Detailed Description

Class to calculate MC resolutions for pat objects.

Author
Jan Heyninck, Petra Van Mulders, Christophe Delaere
Version
Id
ObjectResolutionCalc.h,v 1.5 2008/10/08 19:19:25 gpetrucc Exp

Definition at line 35 of file ObjectResolutionCalc.h.

Constructor & Destructor Documentation

◆ ObjectResolutionCalc() [1/2]

pat::ObjectResolutionCalc::ObjectResolutionCalc ( )

◆ ObjectResolutionCalc() [2/2]

ObjectResolutionCalc::ObjectResolutionCalc ( const TString &  resopath,
bool  useNN = false 
)

Definition at line 9 of file ObjectResolutionCalc.cc.

9  : useNN_(useNN) {
10  edm::LogVerbatim("ObjectResolutionCalc")
11  << ("ObjectResolutionCalc") << "=== Constructing a TopObjectResolutionCalc...";
12  resoFile_ = new TFile(resopath);
13  if (!resoFile_)
14  edm::LogError("ObjectResolutionCalc") << "No resolutions fits for this file available: " << resopath << "...";
15  TString resObsName[8] = {"_ares", "_bres", "_cres", "_dres", "_thres", "_phres", "_etres", "_etares"};
16 
17  TList* keys = resoFile_->GetListOfKeys();
18  TIter nextitem(keys);
19  TKey* key = nullptr;
20  while ((key = (TKey*)nextitem())) {
21  TString name = key->GetName();
22  if (useNN_) {
23  for (Int_t ro = 0; ro < 8; ro++) {
24  TString obsName = resObsName[ro];
25  obsName += "_NN";
26  if (name.Contains(obsName)) {
27  network_[ro] = (TMultiLayerPerceptron*)resoFile_->GetKey(name)->ReadObj();
28  }
29  }
30  } else {
31  if (name.Contains("etabin") && (!name.Contains("etbin"))) {
32  for (int p = 0; p < 8; p++) {
33  if (name.Contains(resObsName[p])) {
34  TString etabin = name;
35  etabin.Remove(0, etabin.Index("_") + 1);
36  etabin.Remove(0, etabin.Index("_") + 7);
37  int etaBin = etabin.Atoi();
38  TH1F* tmp = (TH1F*)(resoFile_->GetKey(name)->ReadObj());
39  fResVsEt_[p][etaBin] = (TF1)(*(tmp->GetFunction("F_" + name)));
40  }
41  }
42  }
43  }
44  }
45  // find etabin values
46  TH1F* tmpEta = (TH1F*)(resoFile_->GetKey("hEtaBins")->ReadObj());
47  for (int b = 1; b <= tmpEta->GetNbinsX(); b++)
48  etaBinVals_.push_back(tmpEta->GetXaxis()->GetBinLowEdge(b));
49  etaBinVals_.push_back(tmpEta->GetXaxis()->GetBinUpEdge(tmpEta->GetNbinsX()));
50  edm::LogVerbatim("ObjectResolutionCalc") << "Found " << etaBinVals_.size() - 1 << " eta-bins with edges: ( ";
51  for (size_t u = 0; u < etaBinVals_.size(); u++)
52  edm::LogVerbatim("ObjectResolutionCalc") << etaBinVals_[u] << ", ";
53  edm::LogVerbatim("ObjectResolutionCalc") << "\b\b )" << std::endl;
54 
55  edm::LogVerbatim("ObjectResolutionCalc") << "=== done." << std::endl;
56 }

References b, etaBin(), etaBinVals_, fResVsEt_, crabWrapper::key, relativeConstraints::keys, Skims_PA_cff::name, network_, AlCaHLTBitMon_ParallelJobs::p, resoFile_, tools::TF1, createJobs::tmp, and useNN_.

◆ ~ObjectResolutionCalc()

ObjectResolutionCalc::~ObjectResolutionCalc ( )

Definition at line 59 of file ObjectResolutionCalc.cc.

59 { delete resoFile_; }

References resoFile_.

Member Function Documentation

◆ etaBin()

int ObjectResolutionCalc::etaBin ( float  eta)

Definition at line 69 of file ObjectResolutionCalc.cc.

69  {
70  int nrEtaBins = etaBinVals_.size() - 1;
71  int bin = nrEtaBins - 1;
72  for (int i = 0; i < nrEtaBins; i++) {
73  if (fabs(eta) > etaBinVals_[i] && fabs(eta) < etaBinVals_[i + 1])
74  bin = i;
75  }
76  return bin;
77 }

References newFWLiteAna::bin, PVValHelper::eta, etaBinVals_, and mps_fire::i.

Referenced by ObjectResolutionCalc().

◆ obsRes()

float ObjectResolutionCalc::obsRes ( int  obs,
int  eta,
float  eT 
)

Definition at line 61 of file ObjectResolutionCalc.cc.

61  {
62  if (useNN_)
64  "TopObjectResolutionCalc::obsRes should never be called when using a NN for resolutions.");
65  float res = fResVsEt_[obs][eta].Eval(eT);
66  return res;
67 }

References PVValHelper::eta, Exception, fResVsEt_, edm::errors::LogicError, and useNN_.

◆ operator()()

template<typename T >
void pat::ObjectResolutionCalc::operator() ( T obj)
inline

Definition at line 53 of file ObjectResolutionCalc.h.

53 {}

Member Data Documentation

◆ etaBinVals_

std::vector<float> pat::ObjectResolutionCalc::etaBinVals_
private

Definition at line 58 of file ObjectResolutionCalc.h.

Referenced by etaBin(), and ObjectResolutionCalc().

◆ fResVsEt_

TF1 pat::ObjectResolutionCalc::fResVsEt_[10][10]
private

Definition at line 59 of file ObjectResolutionCalc.h.

Referenced by ObjectResolutionCalc(), and obsRes().

◆ network_

TMultiLayerPerceptron* pat::ObjectResolutionCalc::network_[10]
private

Definition at line 60 of file ObjectResolutionCalc.h.

Referenced by ObjectResolutionCalc().

◆ resoFile_

TFile* pat::ObjectResolutionCalc::resoFile_
private

Definition at line 57 of file ObjectResolutionCalc.h.

Referenced by ObjectResolutionCalc(), and ~ObjectResolutionCalc().

◆ useNN_

bool pat::ObjectResolutionCalc::useNN_
private

Definition at line 61 of file ObjectResolutionCalc.h.

Referenced by ObjectResolutionCalc(), and obsRes().

mps_fire.i
i
Definition: mps_fire.py:428
edm::errors::LogicError
Definition: EDMException.h:37
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
relativeConstraints.keys
keys
Definition: relativeConstraints.py:89
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
tools.TF1
TF1
Definition: tools.py:23
pat::ObjectResolutionCalc::resoFile_
TFile * resoFile_
Definition: ObjectResolutionCalc.h:57
pat::ObjectResolutionCalc::fResVsEt_
TF1 fResVsEt_[10][10]
Definition: ObjectResolutionCalc.h:59
PVValHelper::eta
Definition: PVValidationHelpers.h:69
b
double b
Definition: hdecay.h:118
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
res
Definition: Electron.h:6
pat::ObjectResolutionCalc::useNN_
bool useNN_
Definition: ObjectResolutionCalc.h:61
newFWLiteAna.bin
bin
Definition: newFWLiteAna.py:161
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
pat::ObjectResolutionCalc::etaBin
int etaBin(float eta)
Definition: ObjectResolutionCalc.cc:69
Exception
Definition: hltDiff.cc:246
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
pat::ObjectResolutionCalc::network_
TMultiLayerPerceptron * network_[10]
Definition: ObjectResolutionCalc.h:60
pat::ObjectResolutionCalc::etaBinVals_
std::vector< float > etaBinVals_
Definition: ObjectResolutionCalc.h:58
crabWrapper.key
key
Definition: crabWrapper.py:19
edm::Log
Definition: MessageLogger.h:70