BmnRoot
Loading...
Searching...
No Matches
BmnEventCentrality.cxx
Go to the documentation of this file.
2
3BmnEventCentrality::BmnEventCentrality() : TNamed(), fClassProbability() {}
4
5BmnEventCentrality::BmnEventCentrality(const BmnEventCentrality& other) : TNamed(other), fClassProbability(other.fClassProbability) {
6 // Copy constructor: copies the class probability set
7}
8
10 if (this != &other) {
11 TNamed::operator=(other);
12 fClassProbability = other.fClassProbability; // Copy the class probability set
13 }
14 return *this;
15}
16
18 // Destructor: nothing to do as the set is cleaned up automatically
19}
20
22 return GetClass(BmnCentralityClass::Method::FHCalHodo); // Delegate to the method-specific function
23}
24
26 return GetProbability(BmnCentralityClass::Method::FHCalHodo); // Delegate to the method-specific function
27}
28
29const std::vector<float>& BmnEventCentrality::GetSoftCentrality() const {
30 return GetSoftCentrality(BmnCentralityClass::Method::FHCalHodo); // Delegate to the method-specific function
31}
32
33std::pair<int, float> BmnEventCentrality::GetClassProbabilityPair(BmnCentralityClass::Method method) const {
34 int candida = -1;
35 float proba = -1.0;
36 for (const auto& cls : fClassProbability) {
37 if (cls.GetMethod() == method) {
38 if (cls.GetProbability() > proba) {
39 proba = cls.GetProbability();
40 candida = cls.GetIndex();
41 }
42 }
43 }
44 return std::make_pair(candida, proba);
45}
46
48 return GetClassProbabilityPair(method).first;
49}
50
52 return GetClassProbabilityPair(method).second;
53}
54
56 // Convert fClassProbability to a std::vector<float>
57 static std::vector<float> probabilities;
58 probabilities.clear();
59 for (const auto& cls : fClassProbability) {
60 probabilities.push_back(cls.GetProbability());
61 }
62 return probabilities;
63}
64
65void BmnEventCentrality::SetCentrality(int cluster_id, float probability, BmnCentralityClass::Method method) {
66 // Add or update the class probability for the specified method
67 fClassProbability.insert({ cluster_id, probability, method });
68}
69
71 fClassProbability.clear(); // Clear the class probability set
72}
const std::vector< float > & GetSoftCentrality() const
void SetCentrality(int cluster_id, float probability, BmnCentralityClass::Method method)
BmnEventCentrality & operator=(const BmnEventCentrality &other)