Belle II Software  release-05-01-25
PIDPriors.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2018 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Umberto Tamponi (tamponi@to.infn.it) *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <TH2F.h>
12 #include <TAxis.h>
13 
14 #include <framework/gearbox/Unit.h>
15 #include <analysis/dbobjects/PIDPriorsTable.h>
16 #include <analysis/dbobjects/PIDPriors.h>
17 
18 using namespace Belle2;
19 
20 void PIDPriors::setPriors(const Const::ChargedStable& particle, TH2F* priorHistogram)
21 {
22  auto index = particle.getIndex();
23 
24  std::vector<float> xEdges;
25  std::vector<float> yEdges;
26 
27  auto& xaxis = *(priorHistogram->GetXaxis());
28  for (int i = xaxis.GetFirst(); i <= xaxis.GetLast(); ++i) {
29  xEdges.push_back(xaxis.GetBinLowEdge(i));
30  }
31  xEdges.push_back(xaxis.GetBinUpEdge(xaxis.GetLast()));
32 
33  auto& yaxis = *(priorHistogram->GetYaxis());
34  for (int i = yaxis.GetFirst(); i <= yaxis.GetLast(); ++i) {
35  yEdges.push_back(yaxis.GetBinLowEdge(i));
36  }
37  yEdges.push_back(yaxis.GetBinUpEdge(yaxis.GetLast()));
38 
39 
40  std::vector<float> prior;
41  std::vector<float> error;
42 
43  for (int ix = 0; ix < (int)xEdges.size() - 1; ix++) {
44  for (int iy = 0; iy < (int)yEdges.size() - 1; iy++) {
45  prior.push_back(priorHistogram->GetBinContent(ix + 1, iy + 1));
46  error.push_back(priorHistogram->GetBinError(ix + 1, iy + 1));
47  }
48  }
49 
50  m_priors[index].setBinEdges(xEdges, yEdges);
51  m_priors[index].setPriorsTable(prior);
52  m_priors[index].setErrorsTable(error);
53 
54  return;
55 };
56 
57 
58 
59 void PIDPriors::setPriors(const Const::ChargedStable& particle, TH2F* counts, TH2F* normalization)
60 {
61  TH2F* priorHistogram = static_cast<TH2F*>(counts->Clone());
62 
63  priorHistogram->Sumw2();
64  priorHistogram->Divide(normalization);
65 
66  setPriors(particle, priorHistogram);
67 };
68 
69 
70 
Belle2::PIDPriors::setPriors
void setPriors(const Const::ChargedStable &particle, const PIDPriorsTable &table)
Sets the prior table for a particle species from a PIDPriorsTable object.
Definition: PIDPriors.h:54
Belle2::PIDPriorsTable::setBinEdges
void setBinEdges(const std::vector< float > &binEdgesX, const std::vector< float > &binEdgesY)
Sets the bin edges arrays.
Definition: PIDPriorsTable.cc:18
Belle2::PIDPriorsTable::setPriorsTable
void setPriorsTable(const std::vector< float > &priors)
Sets the priors table from a 2D std::vector.
Definition: PIDPriorsTable.h:54
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::PIDPriors::m_priors
PIDPriorsTable m_priors[Const::ChargedStable::c_SetSize]
The array of PIDPiorsTable, one per particle species.
Definition: PIDPriors.h:224
Belle2::PIDPriorsTable::setErrorsTable
void setErrorsTable(const std::vector< float > &errors)
Sets the priors error table from a 2D std::vector.
Definition: PIDPriorsTable.h:65
Belle2::Const::ChargedStable
Provides a type-safe way to pass members of the chargedStableSet set.
Definition: Const.h:465