CMS 3D CMS Logo

LikelihoodPdf Class Reference

#include <RecoEgamma/ElectronIdentification/interface/LikelihoodPdf.h>

List of all members.

Public Member Functions

std::string getName ()
 get PDF name
std::string getSpecies ()
 get PDF species
float getVal (float x, std::string catName="NOSPLIT", bool normalized=true)
 get Value of pdf at point x for class catName
void initFromDB (const ElectronLikelihoodCalibration *calibration)
 initialize PDFs from CondDB
 LikelihoodPdf (const char *name, const char *species, int ecalsubdet, int ptbin)
 LikelihoodPdf (const LikelihoodPdf &pdf)
 LikelihoodPdf ()
void split (std::map< std::string, float > splitFractions, bool splitPdf=false)
 split the pdf by category if splitPdf is true.
virtual ~LikelihoodPdf ()

Private Attributes

int _ecalsubdet
std::string _name
int _ptbin
std::string _species
std::map< std::string, const
PhysicsTools::Calibration::HistogramF * > 
_splitPdf
std::map< std::string,
std::string > 
_splitRule


Detailed Description

Definition at line 12 of file LikelihoodPdf.h.


Constructor & Destructor Documentation

LikelihoodPdf::LikelihoodPdf (  )  [inline]

Definition at line 15 of file LikelihoodPdf.h.

00015 {};

LikelihoodPdf::LikelihoodPdf ( const LikelihoodPdf pdf  )  [inline]

Definition at line 16 of file LikelihoodPdf.h.

00016 {}; 

LikelihoodPdf::LikelihoodPdf ( const char *  name,
const char *  species,
int  ecalsubdet,
int  ptbin 
)

Definition at line 9 of file LikelihoodPdf.cc.

References _ecalsubdet, _name, _ptbin, and _species.

00009                                                                                              {
00010   _name = std::string(name);
00011   _species = std::string(species);
00012   _ecalsubdet = ecalsubdet;
00013   _ptbin = ptbin;
00014 }

LikelihoodPdf::~LikelihoodPdf (  )  [virtual]

Definition at line 18 of file LikelihoodPdf.cc.

00018                               {
00019 }


Member Function Documentation

std::string LikelihoodPdf::getName ( void   )  [inline]

get PDF name

Definition at line 31 of file LikelihoodPdf.h.

References _name.

00031 { return _name; }

std::string LikelihoodPdf::getSpecies (  )  [inline]

get PDF species

Definition at line 34 of file LikelihoodPdf.h.

References _species.

00034 { return _species; }

float LikelihoodPdf::getVal ( float  x,
std::string  catName = "NOSPLIT",
bool  normalized = true 
)

get Value of pdf at point x for class catName

Definition at line 85 of file LikelihoodPdf.cc.

References _ecalsubdet, _name, _ptbin, _species, _splitPdf, PhysicsTools::Calibration::Histogram< Value_t, Axis_t >::binContent(), PhysicsTools::Calibration::Histogram< Value_t, Axis_t >::findBin(), PhysicsTools::Calibration::Histogram< Value_t, Axis_t >::normalization(), and PhysicsTools::Calibration::Histogram< Value_t, Axis_t >::value().

00086                                        {
00087   const PhysicsTools::Calibration::HistogramF *thePdf=0;
00088   if(_splitPdf.size()>1) {
00089     edm::LogInfo("LikelihoodPdf") << "The PDF " << _name
00090                                   << " is SPLITTED by category " << gsfClass;
00091     thePdf=_splitPdf.find(gsfClass)->second;
00092   }
00093   else {
00094     edm::LogInfo("LikelihoodPdf") << "The PDF " << _name
00095                                   << " is UNSPLITTED";
00096     thePdf=_splitPdf.find("NOSPLIT")->second;
00097   }
00098   
00099   float prob=-1;
00100 
00101   if(normalized)
00102     prob=thePdf->value(x)/thePdf->normalization();
00103   else
00104     prob=thePdf->value(x);
00105 
00106   edm::LogInfo("LikelihoodPdf") << "sanity check: PDF name = " << _name
00107                                 << " for species = " << _species
00108                                 << " for class = " << gsfClass 
00109                                 << " bin content = " << thePdf->binContent(thePdf->findBin(x))
00110                                 << " normalization = " << thePdf->normalization()
00111                                 << " prob = " << prob;
00112   edm::LogInfo("LikelihoodPdf") << "From likelihood with ecalsubdet = " << _ecalsubdet
00113                                 << " ptbin = " << _ptbin;
00114  
00115 
00116   return prob;
00117 }

void LikelihoodPdf::initFromDB ( const ElectronLikelihoodCalibration calibration  ) 

initialize PDFs from CondDB

Definition at line 60 of file LikelihoodPdf.cc.

References _name, _species, _splitPdf, _splitRule, ElectronLikelihoodCalibration::data, Exception, and histo.

Referenced by LikelihoodPdfProduct::addPdf().

00060                                                                           {
00061 
00062   std::map<std::string,std::string>::const_iterator ruleItr;
00063   for(ruleItr=_splitRule.begin();ruleItr!=_splitRule.end();ruleItr++) {
00064     // look for the requested PDF in the CondDB
00065     std::vector<ElectronLikelihoodCalibration::Entry>::const_iterator entryItr;
00066     bool foundPdf=false;
00067     for(entryItr=calibration->data.begin(); entryItr!=calibration->data.end(); entryItr++) {
00068       if(entryItr->category.label.compare(ruleItr->second)==0) { 
00069         const PhysicsTools::Calibration::HistogramF *histo = &(entryItr->histogram);
00070         _splitPdf.insert( std::make_pair(ruleItr->first,histo) );
00071         foundPdf=true;
00072       }
00073     }
00074     if(!foundPdf) {
00075       throw cms::Exception("LikelihoodPdf") << "The pdf requested: " << _name
00076                                             << " for species: " << _species
00077                                             << " is not present in the Conditions DB!";
00078     }
00079   }
00080 }

void LikelihoodPdf::split ( std::map< std::string, float >  splitFractions,
bool  splitPdf = false 
)

split the pdf by category if splitPdf is true.

split map is: <"class",classFraction> if splitPdf is false, pdf is splitted, but they are all equal (but allowing different priors)

use different a-priori probabilities and different PDFs depending by category

use different a-priori, but same PDFs for all categories

do not split at all (same PDF's, same a-priori for all categories)

Definition at line 24 of file LikelihoodPdf.cc.

References _ecalsubdet, _name, _ptbin, _species, and _splitRule.

Referenced by LikelihoodPdfProduct::addPdf().

00025                                     {
00026 
00027   char buffer[100];
00030   if(splitFractions.size()>0 && splitPdf) {
00031     std::map<std::string,float>::const_iterator splitCatItr;
00032     for(splitCatItr=splitFractions.begin();splitCatItr!=splitFractions.end();splitCatItr++) {
00033       sprintf(buffer,"%s_%s_subdet%d_ptbin%d_%s",_name.c_str(),_species.c_str(),_ecalsubdet,_ptbin,splitCatItr->first.c_str());
00034       std::string totPdfName = std::string(buffer);
00035       _splitRule.insert( std::make_pair(splitCatItr->first,totPdfName) );
00036     }
00037   }
00038 
00040   else if(splitFractions.size()>0) {
00041     std::map<std::string,float>::const_iterator splitCatItr;
00042     for(splitCatItr=splitFractions.begin();splitCatItr!=splitFractions.end();splitCatItr++) {
00043       sprintf(buffer,"%s_%s_subdet%d_ptbin%d",_name.c_str(),_species.c_str(),_ecalsubdet,_ptbin);
00044       std::string totPdfName = std::string(buffer);
00045       _splitRule.insert( std::make_pair(splitCatItr->first,totPdfName) );
00046     }
00047   }
00048 
00050   else {
00051       sprintf(buffer,"%s_%s_subdet%d_ptbin%d",_name.c_str(),_species.c_str(),_ecalsubdet,_ptbin);
00052       std::string totPdfName = std::string(buffer);
00053       _splitRule.insert( std::make_pair("NOSPLIT",totPdfName) );
00054   }
00055 }


Member Data Documentation

int LikelihoodPdf::_ecalsubdet [private]

Definition at line 42 of file LikelihoodPdf.h.

Referenced by getVal(), LikelihoodPdf(), and split().

std::string LikelihoodPdf::_name [private]

Definition at line 40 of file LikelihoodPdf.h.

Referenced by getName(), getVal(), initFromDB(), LikelihoodPdf(), and split().

int LikelihoodPdf::_ptbin [private]

Definition at line 43 of file LikelihoodPdf.h.

Referenced by getVal(), LikelihoodPdf(), and split().

std::string LikelihoodPdf::_species [private]

Definition at line 41 of file LikelihoodPdf.h.

Referenced by getSpecies(), getVal(), initFromDB(), LikelihoodPdf(), and split().

std::map<std::string,const PhysicsTools::Calibration::HistogramF*> LikelihoodPdf::_splitPdf [private]

Definition at line 45 of file LikelihoodPdf.h.

Referenced by getVal(), and initFromDB().

std::map<std::string,std::string> LikelihoodPdf::_splitRule [private]

Definition at line 46 of file LikelihoodPdf.h.

Referenced by initFromDB(), and split().


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