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 <framework/gearbox/Unit.h>
13#include <analysis/dbobjects/PIDPriorsTable.h>
14#include <analysis/dbobjects/PIDPriors.h>
15
16using namespace Belle2;
17
18void PIDPriors::setPriors(const Const::ChargedStable& particle, TH2F* priorHistogram)
19{
20 auto index = particle.getIndex();
21
22 std::vector<float> xEdges;
23 std::vector<float> yEdges;
24
25 auto& xaxis = *(priorHistogram->GetXaxis());
26 for (int i = xaxis.GetFirst(); i <= xaxis.GetLast(); ++i) {
27 xEdges.push_back(xaxis.GetBinLowEdge(i));
28 }
29 xEdges.push_back(xaxis.GetBinUpEdge(xaxis.GetLast()));
30
31 auto& yaxis = *(priorHistogram->GetYaxis());
32 for (int i = yaxis.GetFirst(); i <= yaxis.GetLast(); ++i) {
33 yEdges.push_back(yaxis.GetBinLowEdge(i));
34 }
35 yEdges.push_back(yaxis.GetBinUpEdge(yaxis.GetLast()));
36
37
38 std::vector<float> prior;
39 std::vector<float> error;
40
41 for (int ix = 0; ix < (int)xEdges.size() - 1; ix++) {
42 for (int iy = 0; iy < (int)yEdges.size() - 1; iy++) {
43 prior.push_back(priorHistogram->GetBinContent(ix + 1, iy + 1));
44 error.push_back(priorHistogram->GetBinError(ix + 1, iy + 1));
45 }
46 }
47
48 m_priors[index].setBinEdges(xEdges, yEdges);
49 m_priors[index].setPriorsTable(prior);
50 m_priors[index].setErrorsTable(error);
51
52 return;
53};
54
55
56
57void PIDPriors::setPriors(const Const::ChargedStable& particle, TH2F* counts, TH2F* normalization)
58{
59 TH2F* priorHistogram = static_cast<TH2F*>(counts->Clone());
60
61 priorHistogram->Sumw2();
62 priorHistogram->Divide(normalization);
63
64 setPriors(particle, priorHistogram);
65};
66
67
68
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.