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 38 of file ObjectResolutionCalc.h.

Constructor & Destructor Documentation

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

Definition at line 11 of file ObjectResolutionCalc.cc.

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

11  : useNN_(useNN) {
12  edm::LogVerbatim("ObjectResolutionCalc") << ("ObjectResolutionCalc") << "=== Constructing a TopObjectResolutionCalc...";
13  resoFile_ = new TFile(resopath);
14  if (!resoFile_) 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]; obsName += "_NN";
25  if(name.Contains(obsName)){
26  network_[ro] = (TMultiLayerPerceptron*) resoFile_->GetKey(name)->ReadObj();
27  }
28  }
29  }
30  else
31  {
32  if(name.Contains("etabin") && (!name.Contains("etbin"))) {
33  for(int p=0; p<8; p++){
34  if(name.Contains(resObsName[p])){
35  TString etabin = name; etabin.Remove(0,etabin.Index("_")+1); etabin.Remove(0,etabin.Index("_")+7);
36  int etaBin = etabin.Atoi();
37  TH1F *tmp = (TH1F*) (resoFile_->GetKey(name)->ReadObj());
38  fResVsEt_[p][etaBin] = (TF1)(*(tmp -> GetFunction("F_"+name)));
39  }
40  }
41  }
42  }
43  }
44  // find etabin values
45  TH1F *tmpEta = (TH1F*) (resoFile_->GetKey("hEtaBins")->ReadObj());
46  for(int b=1; b<=tmpEta->GetNbinsX(); b++) etaBinVals_.push_back(tmpEta->GetXaxis()->GetBinLowEdge(b));
47  etaBinVals_.push_back(tmpEta->GetXaxis()->GetBinUpEdge(tmpEta->GetNbinsX()));
48  edm::LogVerbatim("ObjectResolutionCalc") << "Found "<<etaBinVals_.size()-1 << " eta-bins with edges: ( ";
49  for(size_t u=0; u<etaBinVals_.size(); u++) edm::LogVerbatim("ObjectResolutionCalc") << etaBinVals_[u]<<", ";
50  edm::LogVerbatim("ObjectResolutionCalc") << "\b\b )"<<std::endl;
51 
52  edm::LogVerbatim("ObjectResolutionCalc") << "=== done." << std::endl;
53 }
TMultiLayerPerceptron * network_[10]
std::vector< float > etaBinVals_
double b
Definition: hdecay.h:120
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
ObjectResolutionCalc::~ObjectResolutionCalc ( )

Definition at line 57 of file ObjectResolutionCalc.cc.

References resoFile_.

57  {
58  delete resoFile_;
59 }

Member Function Documentation

int ObjectResolutionCalc::etaBin ( float  eta)

Definition at line 70 of file ObjectResolutionCalc.cc.

References stringResolutionProvider_cfi::bin, reco::LeafCandidate::et(), reco::LeafCandidate::eta(), etaBinVals_, mps_fire::i, network_, haddnano::obj, obsRes(), operator()(), useNN_, and findQualityFiles::v.

Referenced by ObjectResolutionCalc().

70  {
71  int nrEtaBins = etaBinVals_.size()-1;
72  int bin = nrEtaBins-1;
73  for(int i=0; i<nrEtaBins; i++) {
74  if(fabs(eta) > etaBinVals_[i] && fabs(eta) < etaBinVals_[i+1]) bin = i;
75  }
76  return bin;
77 }
bin
set the eta bin as selection string.
std::vector< float > etaBinVals_
float ObjectResolutionCalc::obsRes ( int  obs,
int  eta,
float  eT 
)

Definition at line 62 of file ObjectResolutionCalc.cc.

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

Referenced by etaBin().

62  {
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 }
Definition: Electron.h:6
template<typename T >
void pat::ObjectResolutionCalc::operator() ( T obj)
inline

Definition at line 57 of file ObjectResolutionCalc.h.

Referenced by etaBin().

57 { }

Member Data Documentation

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

Definition at line 63 of file ObjectResolutionCalc.h.

Referenced by etaBin(), and ObjectResolutionCalc().

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

Definition at line 64 of file ObjectResolutionCalc.h.

Referenced by ObjectResolutionCalc(), and obsRes().

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

Definition at line 65 of file ObjectResolutionCalc.h.

Referenced by etaBin(), and ObjectResolutionCalc().

TFile* pat::ObjectResolutionCalc::resoFile_
private

Definition at line 62 of file ObjectResolutionCalc.h.

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

bool pat::ObjectResolutionCalc::useNN_
private

Definition at line 66 of file ObjectResolutionCalc.h.

Referenced by etaBin(), ObjectResolutionCalc(), and obsRes().