Belle II Software development
PXDClusterShapeClassifierPar.h
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#pragma once
9
10#include <TObject.h>
11#include <map>
12#include <vector>
13
14#include <pxd/dbobjects/PXDClusterOffsetPar.h>
15
16namespace Belle2 {
26 class PXDClusterShapeClassifierPar: public TObject {
27 public:
30
32 void addShapeLikelyhood(int shape_index, float likelyhood) {m_shape_likelyhoods[shape_index] = likelyhood;}
33
35 const std::map<int, float>& getShapeLikelyhoodMap() const { return m_shape_likelyhoods; }
36
38 const PXDClusterOffsetPar* getOffset(int shape_index, float eta) const
39 {
40 if (m_offsets.find(shape_index) == m_offsets.end()) {
41 return nullptr;
42 }
43 auto eta_index = getEtaIndex(shape_index, eta);
44 return &m_offsets.at(shape_index)[eta_index];
45 }
46
48 void addShape(int shape_index)
49 {
50 m_percentiles[shape_index] = std::vector<float>();
51 m_likelyhoods[shape_index] = std::vector<float>();
52 m_offsets[shape_index] = std::vector<PXDClusterOffsetPar>();
53 }
54
56 void addEtaPercentile(int shape_index, float percentile) {m_percentiles[shape_index].push_back(percentile);}
57
59 void addEtaLikelyhood(int shape_index, float likelyhood) {m_likelyhoods[shape_index].push_back(likelyhood);}
60
62 void addEtaOffset(int shape_index, PXDClusterOffsetPar& offset) { m_offsets[shape_index].push_back(offset);}
63
65 unsigned int getEtaIndex(int shape_index, float eta) const
66 {
67 auto etaPercentiles = m_percentiles.at(shape_index);
68 for (int i = etaPercentiles.size() - 1; i >= 0; --i) {
69 if (eta >= etaPercentiles[i])
70 return i;
71 }
72 return 0;
73 }
74
76 const std::map<int, std::vector<float>>& getPercentilesMap() const { return m_percentiles; }
77
79 const std::map<int, std::vector<float>>& getLikelyhoodMap() const { return m_likelyhoods; }
80
82 const std::map<int, std::vector<PXDClusterOffsetPar> >& getOffsetMap() const { return m_offsets; }
83
84 private:
86 std::map<int, std::vector<PXDClusterOffsetPar> > m_offsets;
88 std::map<int, std::vector<float>> m_percentiles;
90 std::map<int, std::vector<float>> m_likelyhoods;
92 std::map<int, float> m_shape_likelyhoods;
93
95 };
97} // end of namespace Belle2
The class for PXD cluster position offset payload.
The class for PXD cluster shape classifier payload.
ClassDef(PXDClusterShapeClassifierPar, 2)
ClassDef, must be the last term before the closing {}.
std::map< int, float > m_shape_likelyhoods
Map of shape likelyhoods.
void addShapeLikelyhood(int shape_index, float likelyhood)
Add shape likelyhood.
const std::map< int, std::vector< PXDClusterOffsetPar > > & getOffsetMap() const
Return offset map for position correction.
void addEtaLikelyhood(int shape_index, float likelyhood)
Add eta likelyhood to shape for position correction.
const PXDClusterOffsetPar * getOffset(int shape_index, float eta) const
Returns position offset if available, otherwise returns nullptr.
const std::map< int, std::vector< float > > & getPercentilesMap() const
Return percentiles map for position correction.
void addEtaPercentile(int shape_index, float percentile)
Add eta percentile to shape for position correction.
const std::map< int, std::vector< float > > & getLikelyhoodMap() const
Return likelyhood map for position correction.
unsigned int getEtaIndex(int shape_index, float eta) const
Get eta index for position correction.
std::map< int, std::vector< PXDClusterOffsetPar > > m_offsets
Map of position offsets (corrections)
void addShape(int shape_index)
Add shape for position correction.
std::map< int, std::vector< float > > m_likelyhoods
Map of likelyhoods
const std::map< int, float > & getShapeLikelyhoodMap() const
Return shape likelyhood map
std::map< int, std::vector< float > > m_percentiles
Map of percentiles
void addEtaOffset(int shape_index, PXDClusterOffsetPar &offset)
Add offset to shape for position correction.
Abstract base class for different kinds of events.