Belle II Software  release-05-01-25
PXDClusterShapeClassifierPar.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Benjamin Schwenker *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #pragma once
11 
12 #include <TObject.h>
13 #include <map>
14 #include <vector>
15 
16 #include <pxd/dbobjects/PXDClusterOffsetPar.h>
17 
18 namespace Belle2 {
28  class PXDClusterShapeClassifierPar: public TObject {
29  public:
32 
34  void addShapeLikelyhood(int shape_index, float likelyhood) {m_shape_likelyhoods[shape_index] = likelyhood;}
35 
37  const std::map<int, float>& getShapeLikelyhoodMap() const { return m_shape_likelyhoods; }
38 
40  const PXDClusterOffsetPar* getOffset(int shape_index, float eta) const
41  {
42  if (m_offsets.find(shape_index) == m_offsets.end()) {
43  return nullptr;
44  }
45  auto eta_index = getEtaIndex(shape_index, eta);
46  return &m_offsets.at(shape_index)[eta_index];
47  }
48 
50  void addShape(int shape_index)
51  {
52  m_percentiles[shape_index] = std::vector<float>();
53  m_likelyhoods[shape_index] = std::vector<float>();
54  m_offsets[shape_index] = std::vector<PXDClusterOffsetPar>();
55  }
56 
58  void addEtaPercentile(int shape_index, float percentile) {m_percentiles[shape_index].push_back(percentile);}
59 
61  void addEtaLikelyhood(int shape_index, float likelyhood) {m_likelyhoods[shape_index].push_back(likelyhood);}
62 
64  void addEtaOffset(int shape_index, PXDClusterOffsetPar& offset) { m_offsets[shape_index].push_back(offset);}
65 
67  unsigned int getEtaIndex(int shape_index, float eta) const
68  {
69  auto etaPercentiles = m_percentiles.at(shape_index);
70  for (int i = etaPercentiles.size() - 1; i >= 0; --i) {
71  if (eta >= etaPercentiles[i])
72  return i;
73  }
74  return 0;
75  }
76 
78  const std::map<int, std::vector<float>>& getPercentilesMap() const { return m_percentiles; }
79 
81  const std::map<int, std::vector<float>>& getLikelyhoodMap() const { return m_likelyhoods; }
82 
84  const std::map<int, std::vector<PXDClusterOffsetPar> >& getOffsetMap() const { return m_offsets; }
85 
86  private:
88  std::map<int, std::vector<PXDClusterOffsetPar> > m_offsets;
90  std::map<int, std::vector<float>> m_percentiles;
92  std::map<int, std::vector<float>> m_likelyhoods;
94  std::map<int, float> m_shape_likelyhoods;
95 
97  };
99 } // end of namespace Belle2
Belle2::PXDClusterShapeClassifierPar
The class for PXD cluster shape classifier payload.
Definition: PXDClusterShapeClassifierPar.h:36
Belle2::PXDClusterShapeClassifierPar::m_offsets
std::map< int, std::vector< PXDClusterOffsetPar > > m_offsets
Map of position offsets (corrections)
Definition: PXDClusterShapeClassifierPar.h:96
Belle2::PXDClusterShapeClassifierPar::m_shape_likelyhoods
std::map< int, float > m_shape_likelyhoods
Map of shape likelyhoods.
Definition: PXDClusterShapeClassifierPar.h:102
Belle2::PXDClusterShapeClassifierPar::addShapeLikelyhood
void addShapeLikelyhood(int shape_index, float likelyhood)
Add shape likelyhood.
Definition: PXDClusterShapeClassifierPar.h:42
Belle2::PXDClusterShapeClassifierPar::getOffsetMap
const std::map< int, std::vector< PXDClusterOffsetPar > > & getOffsetMap() const
Return offset map for position correction.
Definition: PXDClusterShapeClassifierPar.h:92
Belle2::PXDClusterShapeClassifierPar::getPercentilesMap
const std::map< int, std::vector< float > > & getPercentilesMap() const
Return percentiles map for position correction.
Definition: PXDClusterShapeClassifierPar.h:86
Belle2::PXDClusterShapeClassifierPar::m_likelyhoods
std::map< int, std::vector< float > > m_likelyhoods
Map of likelyhoods
Definition: PXDClusterShapeClassifierPar.h:100
Belle2::PXDClusterShapeClassifierPar::addEtaPercentile
void addEtaPercentile(int shape_index, float percentile)
Add eta percentile to shape for position correction.
Definition: PXDClusterShapeClassifierPar.h:66
Belle2::PXDClusterShapeClassifierPar::PXDClusterShapeClassifierPar
PXDClusterShapeClassifierPar()
Default constructor.
Definition: PXDClusterShapeClassifierPar.h:39
Belle2::PXDClusterShapeClassifierPar::ClassDef
ClassDef(PXDClusterShapeClassifierPar, 2)
ClassDef, must be the last term before the closing {}.
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::PXDClusterShapeClassifierPar::getEtaIndex
unsigned int getEtaIndex(int shape_index, float eta) const
Get eta index for position correction.
Definition: PXDClusterShapeClassifierPar.h:75
Belle2::PXDClusterShapeClassifierPar::getShapeLikelyhoodMap
const std::map< int, float > & getShapeLikelyhoodMap() const
Return shape likelyhood map
Definition: PXDClusterShapeClassifierPar.h:45
Belle2::PXDClusterShapeClassifierPar::addShape
void addShape(int shape_index)
Add shape for position correction.
Definition: PXDClusterShapeClassifierPar.h:58
Belle2::PXDClusterShapeClassifierPar::addEtaOffset
void addEtaOffset(int shape_index, PXDClusterOffsetPar &offset)
Add offset to shape for position correction.
Definition: PXDClusterShapeClassifierPar.h:72
Belle2::PXDClusterShapeClassifierPar::getLikelyhoodMap
const std::map< int, std::vector< float > > & getLikelyhoodMap() const
Return likelyhood map for position correction.
Definition: PXDClusterShapeClassifierPar.h:89
Belle2::PXDClusterShapeClassifierPar::getOffset
const PXDClusterOffsetPar * getOffset(int shape_index, float eta) const
Returns position offset if available, otherwise returns nullptr.
Definition: PXDClusterShapeClassifierPar.h:48
Belle2::PXDClusterShapeClassifierPar::addEtaLikelyhood
void addEtaLikelyhood(int shape_index, float likelyhood)
Add eta likelyhood to shape for position correction.
Definition: PXDClusterShapeClassifierPar.h:69
Belle2::PXDClusterShapeClassifierPar::m_percentiles
std::map< int, std::vector< float > > m_percentiles
Map of percentiles
Definition: PXDClusterShapeClassifierPar.h:98