CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 (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 40 of file ObjectResolutionCalc.h.

Constructor & Destructor Documentation

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

Definition at line 12 of file ObjectResolutionCalc.cc.

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

12  : useNN_(useNN) {
13  edm::LogVerbatim("ObjectResolutionCalc") << ("ObjectResolutionCalc") << "=== Constructing a TopObjectResolutionCalc...";
14  resoFile_ = new TFile(resopath);
15  if (!resoFile_) edm::LogError("ObjectResolutionCalc") << "No resolutions fits for this file available: "<<resopath<<"...";
16  TString resObsName[8] = {"_ares","_bres","_cres","_dres","_thres","_phres","_etres","_etares"};
17 
18  TList* keys = resoFile_->GetListOfKeys();
19  TIter nextitem(keys);
20  TKey* key = NULL;
21  while((key = (TKey*)nextitem())) {
22  TString name = key->GetName();
23  if(useNN_) {
24  for(Int_t ro=0; ro<8; ro++) {
25  TString obsName = resObsName[ro]; obsName += "_NN";
26  if(name.Contains(obsName)){
27  network_[ro] = (TMultiLayerPerceptron*) resoFile_->GetKey(name)->ReadObj();
28  }
29  }
30  }
31  else
32  {
33  if(name.Contains("etabin") && (!name.Contains("etbin"))) {
34  for(int p=0; p<8; p++){
35  if(name.Contains(resObsName[p])){
36  TString etabin = name; etabin.Remove(0,etabin.Index("_")+1); 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++) etaBinVals_.push_back(tmpEta->GetXaxis()->GetBinLowEdge(b));
48  etaBinVals_.push_back(tmpEta->GetXaxis()->GetBinUpEdge(tmpEta->GetNbinsX()));
49  edm::LogVerbatim("ObjectResolutionCalc") << "Found "<<etaBinVals_.size()-1 << " eta-bins with edges: ( ";
50  for(size_t u=0; u<etaBinVals_.size(); u++) edm::LogVerbatim("ObjectResolutionCalc") << etaBinVals_[u]<<", ";
51  edm::LogVerbatim("ObjectResolutionCalc") << "\b\b )"<<std::endl;
52 
53  edm::LogVerbatim("ObjectResolutionCalc") << "=== done." << std::endl;
54 }
TMultiLayerPerceptron * network_[10]
#define NULL
Definition: scimark2.h:8
std::vector< float > etaBinVals_
double b
Definition: hdecay.h:120
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
list key
Definition: combine.py:13
ObjectResolutionCalc::~ObjectResolutionCalc ( )

Definition at line 58 of file ObjectResolutionCalc.cc.

References resoFile_.

58  {
59  delete resoFile_;
60 }

Member Function Documentation

int ObjectResolutionCalc::etaBin ( float  eta)

Definition at line 71 of file ObjectResolutionCalc.cc.

References newFWLiteAna::bin, etaBinVals_, and i.

Referenced by ObjectResolutionCalc().

71  {
72  int nrEtaBins = etaBinVals_.size()-1;
73  int bin = nrEtaBins-1;
74  for(int i=0; i<nrEtaBins; i++) {
75  if(fabs(eta) > etaBinVals_[i] && fabs(eta) < etaBinVals_[i+1]) bin = i;
76  }
77  return bin;
78 }
int i
Definition: DBlmapReader.cc:9
T eta() const
std::vector< float > etaBinVals_
float ObjectResolutionCalc::obsRes ( int  obs,
int  eta,
float  eT 
)

Definition at line 63 of file ObjectResolutionCalc.cc.

References eta(), edm::hlt::Exception, fResVsEt_, edm::errors::LogicError, and useNN_.

63  {
65  "TopObjectResolutionCalc::obsRes should never be called when using a NN for resolutions." );
66  float res = fResVsEt_[obs][eta].Eval(eT);
67  return res;
68 }
T eta() const
template<typename T >
void pat::ObjectResolutionCalc::operator() ( T obj)
inline

Definition at line 59 of file ObjectResolutionCalc.h.

59 { }

Member Data Documentation

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

Definition at line 65 of file ObjectResolutionCalc.h.

Referenced by etaBin(), and ObjectResolutionCalc().

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

Definition at line 66 of file ObjectResolutionCalc.h.

Referenced by ObjectResolutionCalc(), and obsRes().

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

Definition at line 67 of file ObjectResolutionCalc.h.

Referenced by ObjectResolutionCalc().

TFile* pat::ObjectResolutionCalc::resoFile_
private

Definition at line 64 of file ObjectResolutionCalc.h.

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

bool pat::ObjectResolutionCalc::useNN_
private

Definition at line 68 of file ObjectResolutionCalc.h.

Referenced by ObjectResolutionCalc(), and obsRes().