CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

LikelihoodPdfProduct Class Reference

#include <LikelihoodPdfProduct.h>

List of all members.

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=1.0)
 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

Detailed Description

Definition at line 12 of file LikelihoodPdfProduct.h.


Constructor & Destructor Documentation

LikelihoodPdfProduct::LikelihoodPdfProduct ( const char *  name,
int  ecalsubdet,
int  ptbin 
)

Definition at line 7 of file LikelihoodPdfProduct.cc.

References _ecalsubdet, _name, and _ptbin.

{
  _name=std::string(name);
  _ecalsubdet = ecalsubdet;
  _ptbin = ptbin;
}
LikelihoodPdfProduct::~LikelihoodPdfProduct ( )

Definition at line 17 of file LikelihoodPdfProduct.cc.

References _specList.

{
  // do the delete's 
  std::vector<LikelihoodSpecies*>::iterator specItr;
  for(specItr=_specList.begin(); specItr!=_specList.end(); specItr++) {
    delete *specItr;
  }
}

Member Function Documentation

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

{
  std::vector<LikelihoodSpecies*>::const_iterator specItr;
  for(specItr=_specList.begin();specItr!=_specList.end();specItr++) {
    LikelihoodSpecies* species = *specItr;
    if(strcmp(species->getName(),specname)==0) {
      LikelihoodPdf *pdf = new LikelihoodPdf(name,species->getName(),_ecalsubdet,_ptbin);
      pdf->split(species->getSplitFractions(),splitPdf);
      pdf->initFromDB(_calibration);
      species->addPdf(pdf);
    }
  }
}
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().

{
  LikelihoodSpecies* species = new LikelihoodSpecies(name,priorWeight);
  _specList.push_back(species);
}
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(), and LikelihoodSpecies::getSplitFractions().

Referenced by ElectronLikelihood::result(), and ElectronLikelihood::resultLog().

{
  float sigProb=0, bkgProb=0;
  std::vector<LikelihoodSpecies*>::const_iterator specItr;
  for(specItr=_specList.begin();specItr!=_specList.end();specItr++) {
    LikelihoodSpecies* species = *specItr;
    std::map<std::string,float> splitFractions = species->getSplitFractions();
    std::map<std::string,float>::iterator iter = splitFractions.find(gsfClass);
    float splitFr= (splitFractions.size()==0) ? 1. : iter->second;
    if(strcmp(species->getName(),specname)==0) {
      sigProb=splitFr*getSpeciesProb(specname,measurements,gsfClass);
    }
    else {
      bkgProb+=splitFr*getSpeciesProb(species->getName(),measurements,gsfClass);
    } 
  }
  if(sigProb+bkgProb>0)
    return sigProb/(sigProb+bkgProb);
  else
    return -1.;
}
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().

{
  float bareProb=1.;
  float priorWeight=1.;
  std::vector<LikelihoodSpecies*>::const_iterator specItr;
  for(specItr=_specList.begin();specItr!=_specList.end();specItr++) {
    LikelihoodSpecies* species = *specItr;
    if(strcmp(species->getName(),specName)==0) {
      for(unsigned int ipdf=0; ipdf< species->getListOfPdfs().size(); ipdf++) {
        bareProb*=species->getListOfPdfs().at(ipdf)->getVal(measurements.at(ipdf),gsfClass);
      }
      priorWeight=species->getPrior();
      break;
    }
  }
  edm::LogInfo("LikelihoodPdfProduct") << "Species: " << specName
                                       << " bare probability = " << bareProb
                                       << " with a priori probability = " << priorWeight;
  return priorWeight*bareProb;
}
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().

{
  _calibration=calibration;
}
void LikelihoodPdfProduct::setSplitFrac ( const char *  specname,
const char *  catName,
float  frac = 1.0 
)

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

                                                                    {
  std::vector<LikelihoodSpecies*>::const_iterator specItr;
  for(specItr=_specList.begin();specItr!=_specList.end();specItr++) {
    LikelihoodSpecies* species = *specItr;
    if(strcmp(species->getName(),specname)==0) {
      species->setSplitFraction( make_pair(std::string(catName), frac) );
      break;
    }
  }
}

Member Data Documentation

Definition at line 36 of file LikelihoodPdfProduct.h.

Referenced by addPdf(), and initFromDB().

Definition at line 39 of file LikelihoodPdfProduct.h.

Referenced by addPdf(), and LikelihoodPdfProduct().

std::string LikelihoodPdfProduct::_name [private]

Definition at line 35 of file LikelihoodPdfProduct.h.

Referenced by LikelihoodPdfProduct().

std::vector<float> LikelihoodPdfProduct::_priorList [private]

Definition at line 38 of file LikelihoodPdfProduct.h.

Definition at line 40 of file LikelihoodPdfProduct.h.

Referenced by addPdf(), and LikelihoodPdfProduct().