Belle II Software development
PDF1Dim Class Reference

Binned one dimensional PDF (a projection of PDF to time axis) More...

#include <PDF1Dim.h>

Public Member Functions

 PDF1Dim (const PDFConstructor &pdfConstructor, double binSize, double timeWindow)
 Full constructor.
 
double getBinSize () const
 Returns actual bin size used.
 
int getModuleID () const
 Returns slot number.
 
TH1F getHistogram (std::string name, std::string title) const
 Returns binned one dimensional PDF (projection to time axis)
 
const std::vector< double > & getPhotonTimes () const
 Returns photon times of selected photons in a given slot.
 
int getNumOfPhotons () const
 Returns number of photons.
 
double getExpectedSignal () const
 Returns expected number of signal photons.
 
double getExpectedDeltaPhotons () const
 Returns expected number of delta-ray photons.
 
double getExpectedBG () const
 Returns expected number of background photons.
 
double getTminPDF () const
 Returns minimal time of signal PDF.
 
double getTmaxPDF () const
 Returns maximal time of signal PDF.
 
double getTminFot () const
 Returns minimal time of selected photons.
 
double getTmaxFot () const
 Returns maximal time of selected photons.
 
double getMinT0 () const
 Returns lower edge of the T0 search region.
 
double getMaxT0 () const
 Returns upper edge of the T0 search region.
 
int getNumBinsT0 () const
 Returns number of bins the T0 search region.
 
double getLogL (double timeShift) const
 Returns log likelihood.
 

Private Attributes

int m_moduleID = 0
 slot number
 
int m_numBins = 0
 number of bins for signal PDF
 
double m_minTime = 0
 lower edge of the first bin
 
double m_maxTime = 0
 upper edge of the last bin
 
std::vector< double > m_times
 photon times, from a given slot
 
double m_tminPDF = 0
 minimal time of signal PDF
 
double m_tmaxPDF = 0
 maximal time of signal PDF
 
double m_tminFot = 0
 minimal time of photons
 
double m_tmaxFot = 0
 maximal time of photons
 
double m_minT0 = 0
 minimal T0
 
double m_maxT0 = 0
 maximal T0
 
int m_numBinsT0 = 0
 number of bins for T0 finder w/ same bin size as PDF
 
double m_expectedBG = 0
 expected number of background photons
 
double m_expectedSignal = 0
 expected number of signal photons
 
double m_expectedDelta = 0
 expected number of delta-ray photons
 
double m_bkg = 0
 background [photons/bin]
 
double m_binSize = 0
 bin size
 
std::vector< double > m_logF
 log(PDF) values
 
double m_logBkg = 0
 log(m_bkg)
 

Detailed Description

Binned one dimensional PDF (a projection of PDF to time axis)

Definition at line 25 of file PDF1Dim.h.

Constructor & Destructor Documentation

◆ PDF1Dim()

PDF1Dim ( const PDFConstructor pdfConstructor,
double  binSize,
double  timeWindow 
)

Full constructor.

Parameters
pdfConstructorreconstruction object
binSizeapproximate bin size (use getBinSize() to get the actual one)
timeWindowfull time window size

Definition at line 22 of file PDF1Dim.cc.

22 :
23 m_moduleID(pdfConstructor.getModuleID()), m_minTime(TOPRecoManager::getMinTime()),
25 {
26
27 if (binSize <= 0) B2FATAL("TOP::PDF1Dim: bin size must be positive");
28 if (not pdfConstructor.isValid()) {
29 B2ERROR("TOP::PDF1Dim: PDFConstructor is not valid, cannot continue");
30 return;
31 }
32
33 // binning
34 m_numBins = (m_maxTime - m_minTime) / binSize + 1;
36
37 // photon times
38 for (const auto& hit : pdfConstructor.getSelectedHits()) {
39 m_times.push_back(hit.time);
40 }
41 if (not m_times.empty()) {
42 std::sort(m_times.begin(), m_times.end());
43 m_tminFot = m_times.front();
44 m_tmaxFot = m_times.back();
45 }
46
47 m_expectedSignal = pdfConstructor.getExpectedSignalPhotons();
48 m_expectedDelta = pdfConstructor.getExpectedDeltaPhotons();
49 m_expectedBG = std::max(pdfConstructor.getBkgRate() * timeWindow, 0.1);
50
51 // temporary histogram to make 1D projection of PDF
52 TH1F pdfHisto("pdf_temporary", "", m_numBins, m_minTime, m_maxTime);
53
54 // first add background and delta-ray PDF's
55 m_bkg = m_expectedBG / timeWindow * m_binSize;
56 const auto& deltaRayPDF = pdfConstructor.getDeltaRayPDF();
57 for (int i = 0; i < m_numBins; i++) {
58 double t = pdfHisto.GetBinCenter(i + 1);
59 pdfHisto.SetBinContent(i + 1, m_bkg + m_expectedDelta * deltaRayPDF.getPDFValue(t) * m_binSize);
60 }
61
62 // then fill signal PDF
63 bool start = true;
64 for (const auto& pixelPDF : pdfConstructor.getSignalPDF()) {
65 for (const auto& peak : pixelPDF.getPDFPeaks()) {
66 pdfHisto.Fill(peak.t0, m_expectedSignal * peak.nph);
67 if (start) {
68 start = false;
69 m_tminPDF = peak.t0;
70 m_tmaxPDF = peak.t0;
71 }
72 m_tminPDF = std::min(m_tminPDF, peak.t0);
73 m_tmaxPDF = std::max(m_tmaxPDF, peak.t0);
74 }
75 }
76
77 // finally make look-up table for log(PDF)
78 for (int i = 0; i < m_numBins; i++) {
79 m_logF.push_back(log(pdfHisto.GetBinContent(i + 1)));
80 }
81 m_logBkg = log(m_bkg);
82
83 // determine T0 search region
85 double maxT0 = m_tmaxFot - m_tminPDF;
86 m_numBinsT0 = std::max(int((maxT0 - m_minT0) / m_binSize), 3) + 1;
88
89 }
int m_numBinsT0
number of bins for T0 finder w/ same bin size as PDF
Definition: PDF1Dim.h:151
double m_binSize
bin size
Definition: PDF1Dim.h:157
double m_expectedSignal
expected number of signal photons
Definition: PDF1Dim.h:153
double m_tmaxPDF
maximal time of signal PDF
Definition: PDF1Dim.h:146
double m_tmaxFot
maximal time of photons
Definition: PDF1Dim.h:148
double m_logBkg
log(m_bkg)
Definition: PDF1Dim.h:159
double m_expectedDelta
expected number of delta-ray photons
Definition: PDF1Dim.h:154
double m_maxTime
upper edge of the last bin
Definition: PDF1Dim.h:142
double m_minTime
lower edge of the first bin
Definition: PDF1Dim.h:141
double m_maxT0
maximal T0
Definition: PDF1Dim.h:150
int m_numBins
number of bins for signal PDF
Definition: PDF1Dim.h:140
int m_moduleID
slot number
Definition: PDF1Dim.h:139
double m_expectedBG
expected number of background photons
Definition: PDF1Dim.h:152
std::vector< double > m_times
photon times, from a given slot
Definition: PDF1Dim.h:144
double m_tminPDF
minimal time of signal PDF
Definition: PDF1Dim.h:145
double m_bkg
background [photons/bin]
Definition: PDF1Dim.h:156
double m_minT0
minimal T0
Definition: PDF1Dim.h:149
std::vector< double > m_logF
log(PDF) values
Definition: PDF1Dim.h:158
double m_tminFot
minimal time of photons
Definition: PDF1Dim.h:147
static double getMaxTime()
Returns time window upper edge.
static double getMinTime()
Returns time window lower edge.

Member Function Documentation

◆ getBinSize()

double getBinSize ( ) const
inline

Returns actual bin size used.

Returns
bin size

Definition at line 41 of file PDF1Dim.h.

41{return m_binSize;}

◆ getExpectedBG()

double getExpectedBG ( ) const
inline

Returns expected number of background photons.

Returns
number of background photons

Definition at line 85 of file PDF1Dim.h.

85{return m_expectedBG;}

◆ getExpectedDeltaPhotons()

double getExpectedDeltaPhotons ( ) const
inline

Returns expected number of delta-ray photons.

Returns
number of delta-ray photons

Definition at line 79 of file PDF1Dim.h.

79{return m_expectedDelta;}

◆ getExpectedSignal()

double getExpectedSignal ( ) const
inline

Returns expected number of signal photons.

Returns
number of signal photons

Definition at line 73 of file PDF1Dim.h.

73{return m_expectedSignal;}

◆ getHistogram()

TH1F getHistogram ( std::string  name,
std::string  title 
) const

Returns binned one dimensional PDF (projection to time axis)

Parameters
namehistogram name
titlehistogram title
Returns
PDF (signal + background)

Definition at line 108 of file PDF1Dim.cc.

109 {
110 TH1F h(name.c_str(), title.c_str(), m_logF.size(), m_minTime, m_maxTime);
111 for (size_t i = 0; i < m_logF.size(); i++) {
112 h.SetBinContent(i + 1, exp(m_logF[i]));
113 }
114 return h;
115 }

◆ getLogL()

double getLogL ( double  timeShift) const

Returns log likelihood.

Parameters
timeShifttime shift of PDF
Returns
log likelihood

Definition at line 92 of file PDF1Dim.cc.

93 {
94 double logL = 0;
95 for (const auto& time : m_times) {
96 double f = m_logBkg;
97 double t = time - timeShift;
98 if (t >= m_minTime and t < m_maxTime) {
99 unsigned i = (t - m_minTime) / m_binSize;
100 if (i < m_logF.size()) f = m_logF[i];
101 }
102 logL += f;
103 }
104 return logL;
105 }

◆ getMaxT0()

double getMaxT0 ( ) const
inline

Returns upper edge of the T0 search region.

Returns
upper edge

Definition at line 121 of file PDF1Dim.h.

121{return m_maxT0;}

◆ getMinT0()

double getMinT0 ( ) const
inline

Returns lower edge of the T0 search region.

Returns
lower edge

Definition at line 115 of file PDF1Dim.h.

115{return m_minT0;}

◆ getModuleID()

int getModuleID ( ) const
inline

Returns slot number.

Returns
slot number

Definition at line 47 of file PDF1Dim.h.

47{return m_moduleID;}

◆ getNumBinsT0()

int getNumBinsT0 ( ) const
inline

Returns number of bins the T0 search region.

Bin size is the same as for PDF.

Returns
number of bins

Definition at line 127 of file PDF1Dim.h.

127{return m_numBinsT0;}

◆ getNumOfPhotons()

int getNumOfPhotons ( ) const
inline

Returns number of photons.

Returns
number of photons

Definition at line 67 of file PDF1Dim.h.

67{return m_times.size();}

◆ getPhotonTimes()

const std::vector< double > & getPhotonTimes ( ) const
inline

Returns photon times of selected photons in a given slot.

Returns
times of TOPDigit::c_Good digits

Definition at line 61 of file PDF1Dim.h.

61{return m_times;}

◆ getTmaxFot()

double getTmaxFot ( ) const
inline

Returns maximal time of selected photons.

Returns
maximal time

Definition at line 109 of file PDF1Dim.h.

109{return m_tmaxFot;}

◆ getTmaxPDF()

double getTmaxPDF ( ) const
inline

Returns maximal time of signal PDF.

Returns
maximal time

Definition at line 97 of file PDF1Dim.h.

97{return m_tmaxPDF;}

◆ getTminFot()

double getTminFot ( ) const
inline

Returns minimal time of selected photons.

Returns
minimal time

Definition at line 103 of file PDF1Dim.h.

103{return m_tminFot;}

◆ getTminPDF()

double getTminPDF ( ) const
inline

Returns minimal time of signal PDF.

Returns
minimal time

Definition at line 91 of file PDF1Dim.h.

91{return m_tminPDF;}

Member Data Documentation

◆ m_binSize

double m_binSize = 0
private

bin size

Definition at line 157 of file PDF1Dim.h.

◆ m_bkg

double m_bkg = 0
private

background [photons/bin]

Definition at line 156 of file PDF1Dim.h.

◆ m_expectedBG

double m_expectedBG = 0
private

expected number of background photons

Definition at line 152 of file PDF1Dim.h.

◆ m_expectedDelta

double m_expectedDelta = 0
private

expected number of delta-ray photons

Definition at line 154 of file PDF1Dim.h.

◆ m_expectedSignal

double m_expectedSignal = 0
private

expected number of signal photons

Definition at line 153 of file PDF1Dim.h.

◆ m_logBkg

double m_logBkg = 0
private

log(m_bkg)

Definition at line 159 of file PDF1Dim.h.

◆ m_logF

std::vector<double> m_logF
private

log(PDF) values

Definition at line 158 of file PDF1Dim.h.

◆ m_maxT0

double m_maxT0 = 0
private

maximal T0

Definition at line 150 of file PDF1Dim.h.

◆ m_maxTime

double m_maxTime = 0
private

upper edge of the last bin

Definition at line 142 of file PDF1Dim.h.

◆ m_minT0

double m_minT0 = 0
private

minimal T0

Definition at line 149 of file PDF1Dim.h.

◆ m_minTime

double m_minTime = 0
private

lower edge of the first bin

Definition at line 141 of file PDF1Dim.h.

◆ m_moduleID

int m_moduleID = 0
private

slot number

Definition at line 139 of file PDF1Dim.h.

◆ m_numBins

int m_numBins = 0
private

number of bins for signal PDF

Definition at line 140 of file PDF1Dim.h.

◆ m_numBinsT0

int m_numBinsT0 = 0
private

number of bins for T0 finder w/ same bin size as PDF

Definition at line 151 of file PDF1Dim.h.

◆ m_times

std::vector<double> m_times
private

photon times, from a given slot

Definition at line 144 of file PDF1Dim.h.

◆ m_tmaxFot

double m_tmaxFot = 0
private

maximal time of photons

Definition at line 148 of file PDF1Dim.h.

◆ m_tmaxPDF

double m_tmaxPDF = 0
private

maximal time of signal PDF

Definition at line 146 of file PDF1Dim.h.

◆ m_tminFot

double m_tminFot = 0
private

minimal time of photons

Definition at line 147 of file PDF1Dim.h.

◆ m_tminPDF

double m_tminPDF = 0
private

minimal time of signal PDF

Definition at line 145 of file PDF1Dim.h.


The documentation for this class was generated from the following files: