#include <RecoEgamma/ElectronIdentification/interface/LikelihoodPdfProduct.h>
Public Member Functions | |
void | addPdf (const char *specname, const char *name, bool splitPdf=false) |
add a pdf for a species, splitted or not | |
void | addSpecies (const char *name, float priorWeight=1.) |
add a species (hypothesis) to the likelihood, with a priori probability | |
float | getRatio (const char *specName, std::vector< float > measurements, std::string) |
get the likelihood ratio p(a priori) * L(specName) / L_tot | |
void | initFromDB (const ElectronLikelihoodCalibration *calibration) |
initialize the PDFs from CondDB | |
LikelihoodPdfProduct (const char *name, int ecalsubdet, int ptbin) | |
void | setSplitFrac (const char *specname, const char *catName, float frac) |
set the fraction of one category for a given species | |
~LikelihoodPdfProduct () | |
Private Member Functions | |
float | getSpeciesProb (const char *specName, std::vector< float > measurements, std::string gsfClass) |
Private Attributes | |
const ElectronLikelihoodCalibration * | _calibration |
int | _ecalsubdet |
std::string | _name |
std::vector< float > | _priorList |
int | _ptbin |
std::vector< LikelihoodSpecies * > | _specList |
Definition at line 12 of file LikelihoodPdfProduct.h.
Definition at line 7 of file LikelihoodPdfProduct.cc.
References _ecalsubdet, _name, and _ptbin.
00009 { 00010 _name=std::string(name); 00011 _ecalsubdet = ecalsubdet; 00012 _ptbin = ptbin; 00013 }
LikelihoodPdfProduct::~LikelihoodPdfProduct | ( | ) |
Definition at line 17 of file LikelihoodPdfProduct.cc.
References _specList.
00018 { 00019 // do the delete's 00020 std::vector<LikelihoodSpecies*>::iterator specItr; 00021 for(specItr=_specList.begin(); specItr!=_specList.end(); specItr++) { 00022 delete *specItr; 00023 } 00024 }
void LikelihoodPdfProduct::addPdf | ( | const char * | specname, | |
const char * | name, | |||
bool | splitPdf = false | |||
) |
add a pdf for a species, splitted or not
Definition at line 46 of file LikelihoodPdfProduct.cc.
References _calibration, _ecalsubdet, _ptbin, _specList, LikelihoodSpecies::addPdf(), LikelihoodSpecies::getName(), LikelihoodSpecies::getSplitFractions(), LikelihoodPdf::initFromDB(), and LikelihoodPdf::split().
Referenced by ElectronLikelihood::Setup().
00049 { 00050 std::vector<LikelihoodSpecies*>::const_iterator specItr; 00051 for(specItr=_specList.begin();specItr!=_specList.end();specItr++) { 00052 LikelihoodSpecies* species = *specItr; 00053 if(strcmp(species->getName(),specname)==0) { 00054 LikelihoodPdf *pdf = new LikelihoodPdf(name,species->getName(),_ecalsubdet,_ptbin); 00055 pdf->split(species->getSplitFractions(),splitPdf); 00056 pdf->initFromDB(_calibration); 00057 species->addPdf(pdf); 00058 } 00059 } 00060 }
void LikelihoodPdfProduct::addSpecies | ( | const char * | name, | |
float | priorWeight = 1. | |||
) |
add a species (hypothesis) to the likelihood, with a priori probability
Definition at line 37 of file LikelihoodPdfProduct.cc.
References _specList.
Referenced by ElectronLikelihood::Setup().
00038 { 00039 LikelihoodSpecies* species = new LikelihoodSpecies(name,priorWeight); 00040 _specList.push_back(species); 00041 }
float LikelihoodPdfProduct::getRatio | ( | const char * | specName, | |
std::vector< float > | measurements, | |||
std::string | gsfClass | |||
) |
get the likelihood ratio p(a priori) * L(specName) / L_tot
if the pdf is not splitted, assign the split fraction = 1
Definition at line 80 of file LikelihoodPdfProduct.cc.
References _specList, LikelihoodSpecies::getName(), getSpeciesProb(), LikelihoodSpecies::getSplitFractions(), and iter.
Referenced by ElectronLikelihood::result().
00083 { 00084 float sigProb=0, bkgProb=0; 00085 std::vector<LikelihoodSpecies*>::const_iterator specItr; 00086 for(specItr=_specList.begin();specItr!=_specList.end();specItr++) { 00087 LikelihoodSpecies* species = *specItr; 00088 std::map<std::string,float> splitFractions = species->getSplitFractions(); 00089 std::map<std::string,float>::iterator iter = splitFractions.find(gsfClass); 00091 float splitFr= (splitFractions.size()==0) ? 1. : iter->second; 00092 if(strcmp(species->getName(),specname)==0) { 00093 sigProb=splitFr*getSpeciesProb(specname,measurements,gsfClass); 00094 } 00095 else { 00096 bkgProb+=splitFr*getSpeciesProb(species->getName(),measurements,gsfClass); 00097 } 00098 } 00099 if(sigProb+bkgProb>0) 00100 return sigProb/(sigProb+bkgProb); 00101 else 00102 return -1.; 00103 }
float LikelihoodPdfProduct::getSpeciesProb | ( | const char * | specName, | |
std::vector< float > | measurements, | |||
std::string | gsfClass | |||
) | [private] |
Definition at line 108 of file LikelihoodPdfProduct.cc.
References _specList, LikelihoodSpecies::getListOfPdfs(), LikelihoodSpecies::getName(), and LikelihoodSpecies::getPrior().
Referenced by getRatio().
00111 { 00112 float bareProb=1.; 00113 float priorWeight=1.; 00114 std::vector<LikelihoodSpecies*>::const_iterator specItr; 00115 for(specItr=_specList.begin();specItr!=_specList.end();specItr++) { 00116 LikelihoodSpecies* species = *specItr; 00117 if(strcmp(species->getName(),specName)==0) { 00118 for(unsigned int ipdf=0; ipdf< species->getListOfPdfs().size(); ipdf++) { 00119 bareProb*=species->getListOfPdfs().at(ipdf)->getVal(measurements.at(ipdf),gsfClass); 00120 } 00121 priorWeight=species->getPrior(); 00122 break; 00123 } 00124 } 00125 edm::LogInfo("LikelihoodPdfProduct") << "Species: " << specName 00126 << " bare probability = " << bareProb 00127 << " with a priori probability = " << priorWeight; 00128 return priorWeight*bareProb; 00129 }
void LikelihoodPdfProduct::initFromDB | ( | const ElectronLikelihoodCalibration * | calibration | ) |
initialize the PDFs from CondDB
Definition at line 29 of file LikelihoodPdfProduct.cc.
References _calibration.
Referenced by ElectronLikelihood::Setup().
00030 { 00031 _calibration=calibration; 00032 }
void LikelihoodPdfProduct::setSplitFrac | ( | const char * | specname, | |
const char * | catName, | |||
float | frac | |||
) |
set the fraction of one category for a given species
Definition at line 65 of file LikelihoodPdfProduct.cc.
References _specList, LikelihoodSpecies::getName(), and LikelihoodSpecies::setSplitFraction().
Referenced by ElectronLikelihood::Setup().
00066 { 00067 std::vector<LikelihoodSpecies*>::const_iterator specItr; 00068 for(specItr=_specList.begin();specItr!=_specList.end();specItr++) { 00069 LikelihoodSpecies* species = *specItr; 00070 if(strcmp(species->getName(),specname)==0) { 00071 species->setSplitFraction( make_pair(std::string(catName), frac) ); 00072 break; 00073 } 00074 } 00075 }
const ElectronLikelihoodCalibration* LikelihoodPdfProduct::_calibration [private] |
int LikelihoodPdfProduct::_ecalsubdet [private] |
Definition at line 39 of file LikelihoodPdfProduct.h.
Referenced by addPdf(), and LikelihoodPdfProduct().
std::string LikelihoodPdfProduct::_name [private] |
std::vector<float> LikelihoodPdfProduct::_priorList [private] |
Definition at line 38 of file LikelihoodPdfProduct.h.
int LikelihoodPdfProduct::_ptbin [private] |
Definition at line 40 of file LikelihoodPdfProduct.h.
Referenced by addPdf(), and LikelihoodPdfProduct().
std::vector<LikelihoodSpecies*> LikelihoodPdfProduct::_specList [private] |
Definition at line 37 of file LikelihoodPdfProduct.h.
Referenced by addPdf(), addSpecies(), getRatio(), getSpeciesProb(), setSplitFrac(), and ~LikelihoodPdfProduct().