Belle II Software development
PIDPriors.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <TH2F.h>
10#include <TAxis.h>
11
12#include <analysis/dbobjects/PIDPriorsTable.h>
13#include <analysis/dbobjects/PIDPriors.h>
14
15using namespace Belle2;
16
17void PIDPriors::setPriors(const Const::ChargedStable& particle, TH2F* priorHistogram)
18{
19 auto index = particle.getIndex();
20
21 std::vector<float> xEdges;
22 std::vector<float> yEdges;
23
24 auto& xaxis = *(priorHistogram->GetXaxis());
25 for (int i = xaxis.GetFirst(); i <= xaxis.GetLast(); ++i) {
26 xEdges.push_back(xaxis.GetBinLowEdge(i));
27 }
28 xEdges.push_back(xaxis.GetBinUpEdge(xaxis.GetLast()));
29
30 auto& yaxis = *(priorHistogram->GetYaxis());
31 for (int i = yaxis.GetFirst(); i <= yaxis.GetLast(); ++i) {
32 yEdges.push_back(yaxis.GetBinLowEdge(i));
33 }
34 yEdges.push_back(yaxis.GetBinUpEdge(yaxis.GetLast()));
35
36
37 std::vector<float> prior;
38 std::vector<float> error;
39
40 for (int ix = 0; ix < (int)xEdges.size() - 1; ix++) {
41 for (int iy = 0; iy < (int)yEdges.size() - 1; iy++) {
42 prior.push_back(priorHistogram->GetBinContent(ix + 1, iy + 1));
43 error.push_back(priorHistogram->GetBinError(ix + 1, iy + 1));
44 }
45 }
46
47 m_priors[index].setBinEdges(xEdges, yEdges);
48 m_priors[index].setPriorsTable(prior);
49 m_priors[index].setErrorsTable(error);
50
51 return;
52};
53
54
55
56void PIDPriors::setPriors(const Const::ChargedStable& particle, TH2F* counts, TH2F* normalization)
57{
58 TH2F* priorHistogram = static_cast<TH2F*>(counts->Clone());
59
60 priorHistogram->Sumw2();
61 priorHistogram->Divide(normalization);
62
63 setPriors(particle, priorHistogram);
64};
65
66
67
Provides a type-safe way to pass members of the chargedStableSet set.
Definition: Const.h:589
void setErrorsTable(const std::vector< float > &errors)
Sets the priors error table from a 2D std::vector.
void setBinEdges(const std::vector< float > &binEdgesX, const std::vector< float > &binEdgesY)
Sets the bin edges arrays.
void setPriorsTable(const std::vector< float > &priors)
Sets the priors table from a 2D std::vector.
PIDPriorsTable m_priors[Const::ChargedStable::c_SetSize]
The array of PIDPiorsTable, one per particle species.
Definition: PIDPriors.h:222
void setPriors(const Const::ChargedStable &particle, const PIDPriorsTable &table)
Sets the prior table for a particle species from a PIDPriorsTable object.
Definition: PIDPriors.h:52
Abstract base class for different kinds of events.