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 28 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 15 of file ObjectResolutionCalc.cc.

References b, etaBin(), etaBinVals_, Exception, fResVsEt_, submitPVResolutionJobs::key, relativeConstraints::keys, edm::errors::LogicError, Skims_PA_cff::name, network_, AlCaHLTBitMon_ParallelJobs::p, resoFile_, createJobs::tmp, and useNN_.

15  : useNN_(useNN) {
16  edm::LogVerbatim("ObjectResolutionCalc")
17  << ("ObjectResolutionCalc") << "=== Constructing a TopObjectResolutionCalc...";
18  resoFile_ = new TFile(resopath);
19  if (!resoFile_)
21  << "ObjectResolutionCalc: no resolutions fits for this file available: " << resopath << "...";
22 
23  TString resObsName[8] = {"_ares", "_bres", "_cres", "_dres", "_thres", "_phres", "_etres", "_etares"};
24  TList* keys = resoFile_->GetListOfKeys();
25  TIter nextitem(keys);
26  TKey* key = nullptr;
27  while ((key = (TKey*)nextitem())) {
28  TString name = key->GetName();
29  if (useNN_) {
30  for (Int_t ro = 0; ro < 8; ro++) {
31  TString obsName = resObsName[ro];
32  obsName += "_NN";
33  if (name.Contains(obsName)) {
34  network_[ro] = (TMultiLayerPerceptron*)resoFile_->GetKey(name)->ReadObj();
35  }
36  }
37  } else {
38  if (name.Contains("etabin") && (!name.Contains("etbin"))) {
39  for (int p = 0; p < 8; p++) {
40  if (name.Contains(resObsName[p])) {
41  TString etabin = name;
42  etabin.Remove(0, etabin.Index("_") + 1);
43  etabin.Remove(0, etabin.Index("_") + 7);
44  int etaBin = etabin.Atoi();
45  TH1F* tmp = (TH1F*)(resoFile_->GetKey(name)->ReadObj());
46  fResVsEt_[p][etaBin] = (TF1)(*(tmp->GetFunction("F_" + name)));
47  }
48  }
49  }
50  }
51  }
52  // find etabin values
53  TH1F* tmpEta = (TH1F*)(resoFile_->GetKey("hEtaBins")->ReadObj());
54  for (int b = 1; b <= tmpEta->GetNbinsX(); b++)
55  etaBinVals_.push_back(tmpEta->GetXaxis()->GetBinLowEdge(b));
56  etaBinVals_.push_back(tmpEta->GetXaxis()->GetBinUpEdge(tmpEta->GetNbinsX()));
57  edm::LogVerbatim("ObjectResolutionCalc") << "Found " << etaBinVals_.size() - 1 << " eta-bins with edges: ( ";
58  for (size_t u = 0; u < etaBinVals_.size(); u++)
59  edm::LogVerbatim("ObjectResolutionCalc") << etaBinVals_[u] << ", ";
60  edm::LogVerbatim("ObjectResolutionCalc") << "\b\b )" << std::endl;
61 
62  edm::LogVerbatim("ObjectResolutionCalc") << "=== done." << std::endl;
63 }
Log< level::Info, true > LogVerbatim
TMultiLayerPerceptron * network_[10]
key
prepare the HTCondor submission files and eventually submit them
std::vector< float > etaBinVals_
double b
Definition: hdecay.h:120
tmp
align.sh
Definition: createJobs.py:716

◆ ~ObjectResolutionCalc()

ObjectResolutionCalc::~ObjectResolutionCalc ( )

Definition at line 66 of file ObjectResolutionCalc.cc.

References resoFile_.

66 { delete resoFile_; }

Member Function Documentation

◆ etaBin()

int ObjectResolutionCalc::etaBin ( float  eta)

Definition at line 76 of file ObjectResolutionCalc.cc.

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

Referenced by ObjectResolutionCalc().

76  {
77  int nrEtaBins = etaBinVals_.size() - 1;
78  int bin = nrEtaBins - 1;
79  for (int i = 0; i < nrEtaBins; i++) {
80  if (fabs(eta) > etaBinVals_[i] && fabs(eta) < etaBinVals_[i + 1]) {
81  bin = i;
82  break;
83  }
84  }
85  return bin;
86 }
std::vector< float > etaBinVals_

◆ obsRes()

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

Definition at line 68 of file ObjectResolutionCalc.cc.

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

68  {
69  if (useNN_)
71  "TopObjectResolutionCalc::obsRes should never be called when using a NN for resolutions.");
72  float res = fResVsEt_[obs][eta].Eval(eT);
73  return res;
74 }
Definition: Electron.h:6

◆ operator()()

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

Definition at line 46 of file ObjectResolutionCalc.h.

46 {}

Member Data Documentation

◆ etaBinVals_

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

Definition at line 51 of file ObjectResolutionCalc.h.

Referenced by etaBin(), and ObjectResolutionCalc().

◆ fResVsEt_

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

Definition at line 52 of file ObjectResolutionCalc.h.

Referenced by ObjectResolutionCalc(), and obsRes().

◆ network_

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

Definition at line 53 of file ObjectResolutionCalc.h.

Referenced by ObjectResolutionCalc().

◆ resoFile_

TFile* pat::ObjectResolutionCalc::resoFile_
private

Definition at line 50 of file ObjectResolutionCalc.h.

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

◆ useNN_

bool pat::ObjectResolutionCalc::useNN_
private

Definition at line 54 of file ObjectResolutionCalc.h.

Referenced by ObjectResolutionCalc(), and obsRes().