CMS 3D CMS Logo

pat::ObjectResolutionCalc Class Reference

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

#include <PhysicsTools/PatUtils/interface/ObjectResolutionCalc.h>

List of all members.

Public Member Functions

int etaBin (float eta)
 ObjectResolutionCalc (TString resopath, bool useNN)
 ObjectResolutionCalc ()
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, lat::endl(), etaBin(), etaBinVals_, fResVsEt_, getDQMSummary::key, bookConverter::keys, name, network_, NULL, p, resoFile_, tmp, and useNN_.

00012                                                                               : useNN_(useNN) {
00013   edm::LogVerbatim("ObjectResolutionCalc") << ("ObjectResolutionCalc") << "=== Constructing a TopObjectResolutionCalc...";
00014   resoFile_ = new TFile(resopath);
00015   if (!resoFile_) edm::LogError("ObjectResolutionCalc") << "No resolutions fits for this file available: "<<resopath<<"...";
00016   TString  resObsName[8] = {"_ares","_bres","_cres","_dres","_thres","_phres","_etres","_etares"};
00017   
00018   TList* keys = resoFile_->GetListOfKeys();
00019   TIter nextitem(keys);
00020   TKey* key = NULL;
00021   while((key = (TKey*)nextitem())) {
00022     TString name = key->GetName();
00023     if(useNN_) {
00024       for(Int_t ro=0; ro<8; ro++) {
00025         TString obsName = resObsName[ro]; obsName += "_NN";
00026         if(name.Contains(obsName)){
00027           network_[ro] = (TMultiLayerPerceptron*) resoFile_->GetKey(name)->ReadObj();
00028         }
00029       }
00030     }
00031     else 
00032     { 
00033       if(name.Contains("etabin") && (!name.Contains("etbin"))) {
00034         for(int p=0; p<8; p++){
00035           if(name.Contains(resObsName[p])){
00036             TString etabin = name; etabin.Remove(0,etabin.Index("_")+1); etabin.Remove(0,etabin.Index("_")+7);
00037             int etaBin = etabin.Atoi();
00038             TH1F *tmp = (TH1F*) (resoFile_->GetKey(name)->ReadObj());
00039             fResVsEt_[p][etaBin] = (TF1)(*(tmp -> GetFunction("F_"+name)));
00040           }
00041         }
00042       }
00043     }
00044   }
00045   // find etabin values
00046   TH1F *tmpEta = (TH1F*) (resoFile_->GetKey("hEtaBins")->ReadObj());
00047   for(int b=1; b<=tmpEta->GetNbinsX(); b++) etaBinVals_.push_back(tmpEta->GetXaxis()->GetBinLowEdge(b));
00048   etaBinVals_.push_back(tmpEta->GetXaxis()->GetBinUpEdge(tmpEta->GetNbinsX()));
00049   edm::LogVerbatim("ObjectResolutionCalc") << "Found "<<etaBinVals_.size()-1  << " eta-bins with edges: ( ";
00050   for(size_t u=0; u<etaBinVals_.size(); u++) edm::LogVerbatim("ObjectResolutionCalc") << etaBinVals_[u]<<", ";
00051   edm::LogVerbatim("ObjectResolutionCalc") << "\b\b )"<<std::endl;
00052   
00053   edm::LogVerbatim("ObjectResolutionCalc") << "=== done." << std::endl;
00054 }

ObjectResolutionCalc::~ObjectResolutionCalc (  ) 

Definition at line 58 of file ObjectResolutionCalc.cc.

References resoFile_.

00058                                             {
00059   delete resoFile_;
00060 }


Member Function Documentation

int ObjectResolutionCalc::etaBin ( float  eta  ) 

Definition at line 71 of file ObjectResolutionCalc.cc.

References etaBinVals_, and i.

Referenced by ObjectResolutionCalc().

00071                                           {
00072   int nrEtaBins = etaBinVals_.size()-1;
00073   int bin = nrEtaBins-1;
00074   for(int i=0; i<nrEtaBins; i++) {
00075     if(fabs(eta) > etaBinVals_[i] && fabs(eta) < etaBinVals_[i+1]) bin = i;
00076   }
00077   return bin;
00078 }

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

Definition at line 63 of file ObjectResolutionCalc.cc.

References fResVsEt_, edm::errors::LogicError, res, and useNN_.

00063                                                              {
00064   if (useNN_) throw edm::Exception( edm::errors::LogicError, 
00065                                    "TopObjectResolutionCalc::obsRes should never be called when using a NN for resolutions." );
00066   float res = fResVsEt_[obs][eta].Eval(eT);
00067   return res;
00068 }

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

Definition at line 59 of file ObjectResolutionCalc.h.

00059 { }


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().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:49:42 2009 for CMSSW by  doxygen 1.5.4