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
LikelihoodPdf Class Reference

#include <LikelihoodPdf.h>

Public Member Functions

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

Private Member Functions

float normalization (const PhysicsTools::Calibration::HistogramF *thePdf) const
 

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.

15 {};
LikelihoodPdf::LikelihoodPdf ( const LikelihoodPdf pdf)
inline

Definition at line 16 of file LikelihoodPdf.h.

16 {};
LikelihoodPdf::LikelihoodPdf ( const char *  name,
const char *  species,
int  ecalsubdet,
int  ptbin 
)

Definition at line 9 of file LikelihoodPdf.cc.

References _ecalsubdet, _name, _ptbin, _species, and AlCaHLTBitMon_QueryRunRegistry::string.

9  {
11  _species = std::string(species);
12  _ecalsubdet = ecalsubdet;
13  _ptbin = ptbin;
14 }
std::string _species
Definition: LikelihoodPdf.h:43
std::string _name
Definition: LikelihoodPdf.h:42
LikelihoodPdf::~LikelihoodPdf ( )
virtual

Definition at line 18 of file LikelihoodPdf.cc.

18  {
19 }

Member Function Documentation

std::string const& LikelihoodPdf::getName ( void  ) const
inline

get PDF name

Definition at line 31 of file LikelihoodPdf.h.

References _name.

Referenced by plotting.Plot::draw().

31 { return _name; }
std::string _name
Definition: LikelihoodPdf.h:42
std::string const& LikelihoodPdf::getSpecies ( ) const
inline

get PDF species

Definition at line 34 of file LikelihoodPdf.h.

References _species.

34 { return _species; }
std::string _species
Definition: LikelihoodPdf.h:43
float LikelihoodPdf::getVal ( float  x,
std::string const &  catName = "NOSPLIT",
bool  normalized = true 
) const

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(), normalization(), PhysicsTools::Calibration::Histogram< Value_t, Axis_t >::normalization(), and PhysicsTools::Calibration::Histogram< Value_t, Axis_t >::value().

86  {
88  if(_splitPdf.size()>1) {
89  edm::LogInfo("LikelihoodPdf") << "The PDF " << _name
90  << " is SPLITTED by category " << gsfClass;
91  thePdf=_splitPdf.find(gsfClass)->second;
92  }
93  else {
94  edm::LogInfo("LikelihoodPdf") << "The PDF " << _name
95  << " is UNSPLITTED";
96  thePdf=_splitPdf.find("NOSPLIT")->second;
97  }
98 
99  float prob=-1;
100 
101  if(normalized)
102  // using thePdf->normalization() neglects the overflows... calculating it manually.
103  // prob=thePdf->value(x)/thePdf->normalization();
104  prob=thePdf->value(x)/normalization(thePdf);
105  else
106  prob=thePdf->value(x);
107 
108  edm::LogInfo("LikelihoodPdf") << "sanity check: PDF name = " << _name
109  << " for species = " << _species
110  << " for class = " << gsfClass
111  << " bin content = " << thePdf->binContent(thePdf->findBin(x))
112  << " normalization (std) = " << thePdf->normalization()
113  << " normalization (manual) = " << normalization(thePdf)
114  << " prob = " << prob;
115  edm::LogInfo("LikelihoodPdf") << "From likelihood with ecalsubdet = " << _ecalsubdet
116  << " ptbin = " << _ptbin;
117 
118 
119  return prob;
120 }
std::map< std::string, const PhysicsTools::Calibration::HistogramF * > _splitPdf
Definition: LikelihoodPdf.h:47
std::string _species
Definition: LikelihoodPdf.h:43
Value_t binContent(int bin) const
Definition: Histogram.h:69
std::string _name
Definition: LikelihoodPdf.h:42
float normalization(const PhysicsTools::Calibration::HistogramF *thePdf) const
Value_t value(Axis_t x) const
Definition: Histogram.h:70
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 timingPdfMaker::histo.

Referenced by LikelihoodPdfProduct::addPdf().

60  {
61 
62  std::map<std::string,std::string>::const_iterator ruleItr;
63  for(ruleItr=_splitRule.begin();ruleItr!=_splitRule.end();ruleItr++) {
64  // look for the requested PDF in the CondDB
65  std::vector<ElectronLikelihoodCalibration::Entry>::const_iterator entryItr;
66  bool foundPdf=false;
67  for(entryItr=calibration->data.begin(); entryItr!=calibration->data.end(); entryItr++) {
68  if(entryItr->category.label.compare(ruleItr->second)==0) {
69  const PhysicsTools::Calibration::HistogramF *histo = &(entryItr->histogram);
70  _splitPdf.insert( std::make_pair(ruleItr->first,histo) );
71  foundPdf=true;
72  }
73  }
74  if(!foundPdf) {
75  throw cms::Exception("LikelihoodPdf") << "The pdf requested: " << _name
76  << " for species: " << _species
77  << " is not present in the Conditions DB!";
78  }
79  }
80 }
std::map< std::string, const PhysicsTools::Calibration::HistogramF * > _splitPdf
Definition: LikelihoodPdf.h:47
std::string _species
Definition: LikelihoodPdf.h:43
std::string _name
Definition: LikelihoodPdf.h:42
std::map< std::string, std::string > _splitRule
Definition: LikelihoodPdf.h:48
float LikelihoodPdf::normalization ( const PhysicsTools::Calibration::HistogramF thePdf) const
private

Definition at line 124 of file LikelihoodPdf.cc.

References PhysicsTools::Calibration::Histogram< Value_t, Axis_t >::binContent(), i, and PhysicsTools::Calibration::Histogram< Value_t, Axis_t >::numberOfBins().

Referenced by getVal().

124  {
125  int nBins = thePdf->numberOfBins();
126  float sum=0.;
127  for(int i=0; i<=nBins+1; i++) {
128  sum += thePdf->binContent(i);
129  }
130  return sum;
131 }
int i
Definition: DBlmapReader.cc:9
Value_t binContent(int bin) const
Definition: Histogram.h:69
void LikelihoodPdf::split ( const 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, _splitRule, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by LikelihoodPdfProduct::addPdf().

25  {
26 // std::map<std::string,float>splitFractions = _splitFractions;
27  char buffer[100];
30  if(splitFractions.size()>0 && splitPdf) {
31  std::map<std::string,float>::const_iterator splitCatItr;
32  for(splitCatItr=splitFractions.begin();splitCatItr!=splitFractions.end();splitCatItr++) {
33  snprintf(buffer, 100, "%s_%s_subdet%d_ptbin%d_%s",_name.c_str(),_species.c_str(),_ecalsubdet,_ptbin,splitCatItr->first.c_str());
34  std::string totPdfName = std::string(buffer);
35  _splitRule.insert( std::make_pair(splitCatItr->first,totPdfName) );
36  }
37  }
38 
40  else if(splitFractions.size()>0) {
41  std::map<std::string,float>::const_iterator splitCatItr;
42  for(splitCatItr=splitFractions.begin();splitCatItr!=splitFractions.end();splitCatItr++) {
43  snprintf(buffer, 100, "%s_%s_subdet%d_ptbin%d",_name.c_str(),_species.c_str(),_ecalsubdet,_ptbin);
44  std::string totPdfName = std::string(buffer);
45  _splitRule.insert( std::make_pair(splitCatItr->first,totPdfName) );
46  }
47  }
48 
50  else {
51  snprintf(buffer, 100, "%s_%s_subdet%d_ptbin%d",_name.c_str(),_species.c_str(),_ecalsubdet,_ptbin);
52  std::string totPdfName = std::string(buffer);
53  _splitRule.insert( std::make_pair("NOSPLIT",totPdfName) );
54  }
55 }
std::string _species
Definition: LikelihoodPdf.h:43
std::string _name
Definition: LikelihoodPdf.h:42
std::map< std::string, std::string > _splitRule
Definition: LikelihoodPdf.h:48

Member Data Documentation

int LikelihoodPdf::_ecalsubdet
private

Definition at line 44 of file LikelihoodPdf.h.

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

std::string LikelihoodPdf::_name
private
int LikelihoodPdf::_ptbin
private

Definition at line 45 of file LikelihoodPdf.h.

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

std::string LikelihoodPdf::_species
private

Definition at line 43 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 47 of file LikelihoodPdf.h.

Referenced by getVal(), and initFromDB().

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

Definition at line 48 of file LikelihoodPdf.h.

Referenced by initFromDB(), and split().