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

#include <LikelihoodPdf.h>

Public Member Functions

std::string getName ()
 get PDF name More...
 
std::string getSpecies ()
 get PDF species More...
 
float getVal (float x, std::string catName="NOSPLIT", bool normalized=true)
 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 (std::map< std::string, float > splitFractions, bool splitPdf=false)
 
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.

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, and _species.

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

Definition at line 18 of file LikelihoodPdf.cc.

18  {
19 }

Member Function Documentation

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

get PDF name

Definition at line 31 of file LikelihoodPdf.h.

References _name.

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

get PDF species

Definition at line 34 of file LikelihoodPdf.h.

References _species.

34 { return _species; }
std::string _species
Definition: LikelihoodPdf.h:41
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().

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  prob=thePdf->value(x)/thePdf->normalization();
103  else
104  prob=thePdf->value(x);
105 
106  edm::LogInfo("LikelihoodPdf") << "sanity check: PDF name = " << _name
107  << " for species = " << _species
108  << " for class = " << gsfClass
109  << " bin content = " << thePdf->binContent(thePdf->findBin(x))
110  << " normalization = " << thePdf->normalization()
111  << " prob = " << prob;
112  edm::LogInfo("LikelihoodPdf") << "From likelihood with ecalsubdet = " << _ecalsubdet
113  << " ptbin = " << _ptbin;
114 
115 
116  return prob;
117 }
std::map< std::string, const PhysicsTools::Calibration::HistogramF * > _splitPdf
Definition: LikelihoodPdf.h:45
std::string _species
Definition: LikelihoodPdf.h:41
Value_t binContent(int bin) const
Definition: Histogram.h:61
std::string _name
Definition: LikelihoodPdf.h:40
Value_t value(Axis_t x) const
Definition: Histogram.h:62
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, edm::hlt::Exception, and trackerHits::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:45
tuple histo
Definition: trackerHits.py:12
std::string _species
Definition: LikelihoodPdf.h:41
std::string _name
Definition: LikelihoodPdf.h:40
std::map< std::string, std::string > _splitRule
Definition: LikelihoodPdf.h:46
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().

25  {
26 
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  sprintf(buffer,"%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  sprintf(buffer,"%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  sprintf(buffer,"%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:41
std::string _name
Definition: LikelihoodPdf.h:40
std::map< std::string, std::string > _splitRule
Definition: LikelihoodPdf.h:46

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