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 (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_, relval_steps::key, relativeConstraints::keys, mergeVDriftHistosByStation::name, network_, NULL, 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 = NULL;
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]
#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
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 newFWLiteAna::bin, etaBinVals_, and i.

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 }
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 62 of file ObjectResolutionCalc.cc.

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

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 }
T eta() const
template<typename T >
void pat::ObjectResolutionCalc::operator() ( T obj)
inline

Definition at line 57 of file ObjectResolutionCalc.h.

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 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 ObjectResolutionCalc(), and obsRes().