ATLAS Offline Software
Loading...
Searching...
No Matches
ConstantContentBinMaker.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
7#include "GaudiKernel/MsgStream.h"
8
9#include <iostream>
10
11using namespace MuonCalib;
12
13//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
14//:: IMPLEMENTATION OF METHODS DEFINED IN THE CLASS ConstantContentBinMaker ::
15//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
16
17//*****************************************************************************
18
19//:::::::::::::::::
20//:: CONSTRUCTOR ::
21//:::::::::::::::::
22
24 const std::vector<DataPoint> & points,
25 const double epsilon)
26 : m_points (points),
27 m_epsilon (std::abs(epsilon))
28{
29}
30
31
33{
34 for (DataBin* b : m_bins) {
35 delete b;
36 }
37}
38
39
40//*****************************************************************************
41
42//::::::::::::::::::::::::::
43//:: METHOD binDataPoints ::
44//::::::::::::::::::::::::::
45
46bool ConstantContentBinMaker::binDataPoints(const unsigned int & bin_content,
47 std::vector<unsigned int> & ref_coord) {
48
50// VARIABLES //
52
53 unsigned int n_bins(static_cast<unsigned int>(
54 std::log(m_points.size()/static_cast<double>(bin_content))
55 /std::log(2.0)));
56 std::vector<unsigned int> splitting_axis(ref_coord);
57 unsigned int axis_counter(0);
58
60// RESET //
62 for (DataBin* b : m_bins) {
63 delete b;
64 }
65 m_bins.clear();
66
68// CHECK WHETHER THE IS SUFFICIENT DATA POINTS //
70
71 if (m_points.empty() || n_bins<2) {
72 MsgStream log(Athena::getMessageSvc(), "ConstantContentBinMaker");
73 log<< MSG::WARNING << "Class ConstantContentBinMaker, method binDataPoints: Too few data points for binning!"<<endmsg;
74 return false;
75 }
76
78// CHECK REFERENCE COORDINATE //
80
81 if (ref_coord.empty()) {
82 splitting_axis = std::vector<unsigned int>(
83 m_points[0].dataVector().rows());
84 for (unsigned int k=0; k<splitting_axis.size(); k++) {
85 splitting_axis[k] = k;
86 }
87 }
88
90// FILL A MOTHER BIN AND BIN THE DATA UNTIL THE REQUIRED BIN CONTENT IS //
91// REACHED. //
93
94// mother bin //
95 m_bins.push_back(new DataBin(m_points, m_epsilon));
96
97 for (unsigned int split=0; split<n_bins; split++) {
98 unsigned int nb_bins_so_far(m_bins.size());
99 for (unsigned int k=0; k<nb_bins_so_far; k++) {
100 m_bins.push_back(m_bins[k]->splitBin(
101 // cppcheck-suppress containerOutOfBounds; false positive
102 splitting_axis[axis_counter]));
103 axis_counter++;
104 if (axis_counter==splitting_axis.size()) {
105 axis_counter = 0;
106 }
107 }
108 }
109
110 return true;
111
112}
113
114//*****************************************************************************
115
116//::::::::::::::::::::
117//:: METHOD getBins ::
118//::::::::::::::::::::
119
120const std::vector<DataBin *> & ConstantContentBinMaker::getBins() const {
121
122 return m_bins;
123
124}
#define endmsg
const std::vector< DataBin * > & getBins() const
get the bins determined by the method "binDataPoints"
ConstantContentBinMaker(const std::vector< DataPoint > &points, const double epsilon)
Constructor.
bool binDataPoints(const unsigned int &bin_content, std::vector< unsigned int > &ref_coord)
group the data points into bins of equal content "bin_content"; returns true in case of success,...
singleton-like access to IMessageSvc via open function and helper
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177
IMessageSvc * getMessageSvc(bool quiet=false)
CscCalcPed - algorithm that finds the Cathode Strip Chamber pedestals from an RDO.
STL namespace.