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 Member Functions | Private Attributes
LikelihoodPdfProduct Class Reference

#include <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 More...
 
void addSpecies (const char *name, float priorWeight=1.)
 add a species (hypothesis) to the likelihood, with a priori probability More...
 
float getRatio (const char *specName, const std::vector< float > &measurements, const std::string &) const
 get the likelihood ratio p(a priori) * L(specName) / L_tot More...
 
void initFromDB (const ElectronLikelihoodCalibration *calibration)
 initialize the PDFs from CondDB More...
 
 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 More...
 
 ~LikelihoodPdfProduct ()
 

Private Member Functions

float getSpeciesProb (const char *specName, const std::vector< float > &measurements, const std::string &gsfClass) const
 

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 
)
LikelihoodPdfProduct::~LikelihoodPdfProduct ( )

Definition at line 17 of file LikelihoodPdfProduct.cc.

References _specList.

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

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

49 {
50  std::vector<LikelihoodSpecies*>::const_iterator specItr;
51  for(specItr=_specList.begin();specItr!=_specList.end();specItr++) {
52  LikelihoodSpecies* species = *specItr;
53  if(strcmp(species->getName(),specname)==0) {
55  pdf->split(species->getSplitFractions(),splitPdf);
57  species->addPdf(pdf);
58  }
59  }
60 }
std::map< std::string, float > const & getSplitFractions() const
void initFromDB(const ElectronLikelihoodCalibration *calibration)
initialize PDFs from CondDB
std::vector< LikelihoodSpecies * > _specList
void split(const std::map< std::string, float > &splitFractions, bool splitPdf=false)
void addPdf(const LikelihoodPdf *pdf)
const char * getName() const
const ElectronLikelihoodCalibration * _calibration
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.

38 {
39  LikelihoodSpecies* species = new LikelihoodSpecies(name,priorWeight);
40  _specList.push_back(species);
41 }
std::vector< LikelihoodSpecies * > _specList
float LikelihoodPdfProduct::getRatio ( const char *  specName,
const std::vector< float > &  measurements,
const std::string &  gsfClass 
) const

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

83 {
84  float sigProb=0, bkgProb=0;
85  std::vector<LikelihoodSpecies*>::const_iterator specItr;
86  for(specItr=_specList.begin();specItr!=_specList.end();specItr++) {
87  const LikelihoodSpecies* species = *specItr;
88  std::map<std::string,float> const& splitFractions = species->getSplitFractions();
89  std::map<std::string,float>::const_iterator iter = splitFractions.find(gsfClass);
91  float splitFr= (splitFractions.size()==0) ? 1. : iter->second;
92  if(strcmp(species->getName(),specname)==0) {
93  sigProb=splitFr*getSpeciesProb(specname,measurements,gsfClass);
94  }
95  else {
96  bkgProb+=splitFr*getSpeciesProb(species->getName(),measurements,gsfClass);
97  }
98  }
99  if(sigProb+bkgProb>0)
100  return sigProb/(sigProb+bkgProb);
101  else
102  return -1.;
103 }
float getSpeciesProb(const char *specName, const std::vector< float > &measurements, const std::string &gsfClass) const
std::map< std::string, float > const & getSplitFractions() const
std::vector< LikelihoodSpecies * > _specList
const char * getName() const
float LikelihoodPdfProduct::getSpeciesProb ( const char *  specName,
const std::vector< float > &  measurements,
const std::string &  gsfClass 
) const
private

Definition at line 108 of file LikelihoodPdfProduct.cc.

References _specList, LikelihoodSpecies::getListOfPdfs(), LikelihoodSpecies::getName(), and LikelihoodSpecies::getPrior().

Referenced by getRatio().

111 {
112  float bareProb=1.;
113  float priorWeight=1.;
114  std::vector<LikelihoodSpecies*>::const_iterator specItr;
115  for(specItr=_specList.begin();specItr!=_specList.end();specItr++) {
116  const LikelihoodSpecies* species = *specItr;
117  if(strcmp(species->getName(),specName)==0) {
118  for(unsigned int ipdf=0; ipdf< species->getListOfPdfs().size(); ipdf++) {
119  bareProb*=species->getListOfPdfs()[ipdf]->getVal(measurements.at(ipdf),gsfClass);
120  }
121  priorWeight=species->getPrior();
122  break;
123  }
124  }
125  edm::LogInfo("LikelihoodPdfProduct") << "Species: " << specName
126  << " bare probability = " << bareProb
127  << " with a priori probability = " << priorWeight;
128  return priorWeight*bareProb;
129 }
std::vector< const LikelihoodPdf * > const & getListOfPdfs() const
std::vector< LikelihoodSpecies * > _specList
float getPrior() const
const char * getName() const
void LikelihoodPdfProduct::initFromDB ( const ElectronLikelihoodCalibration calibration)

initialize the PDFs from CondDB

Definition at line 29 of file LikelihoodPdfProduct.cc.

References _calibration.

30 {
31  _calibration=calibration;
32 }
const ElectronLikelihoodCalibration * _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(), LikelihoodSpecies::setSplitFraction(), and AlCaHLTBitMon_QueryRunRegistry::string.

66  {
67  std::vector<LikelihoodSpecies*>::const_iterator specItr;
68  for(specItr=_specList.begin();specItr!=_specList.end();specItr++) {
69  LikelihoodSpecies* species = *specItr;
70  if(strcmp(species->getName(),specname)==0) {
71  species->setSplitFraction( make_pair(std::string(catName), frac) );
72  break;
73  }
74  }
75 }
void setSplitFraction(std::pair< std::string, float > splitfrac)
std::vector< LikelihoodSpecies * > _specList
const char * getName() const

Member Data Documentation

const ElectronLikelihoodCalibration* LikelihoodPdfProduct::_calibration
private

Definition at line 36 of file LikelihoodPdfProduct.h.

Referenced by addPdf(), and initFromDB().

int LikelihoodPdfProduct::_ecalsubdet
private

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.

int LikelihoodPdfProduct::_ptbin
private

Definition at line 40 of file LikelihoodPdfProduct.h.

Referenced by addPdf(), and LikelihoodPdfProduct().

std::vector<LikelihoodSpecies*> LikelihoodPdfProduct::_specList
private