31 if (binning ==
nullptr) {
36 std::vector<TAxis *> axes = binning->
GetAxes();
37 for (
size_t i = 0; i < axes.size(); i++) {
38 TAxis * axis = axes[i];
39 std::string axisName = axis->GetName();
48 int dims = axes.size();
49 Int_t * nbins =
new Int_t[dims];
50 Double_t * xmin =
new Double_t[dims];
51 Double_t * xmax =
new Double_t[dims];
54 TObjArray * cAxes =
new TObjArray();
57 for (
int i = 0; i < dims; i++) {
58 TAxis * axis = (TAxis *)axes[i];
59 TAxis * axisNew = (TAxis *)axis->Clone();
61 std::string name = axis->GetName();
62 NLogTrace(
"NBinningDef: Binning '%s': %d", name.c_str(), axis->GetNbins());
64 auto bins = std::make_unique<double[]>(axis->GetNbins() + 1);
67 bins[count++] = axis->GetBinLowEdge(1);
70 std::map<std::string, std::vector<std::vector<int>>> definition =
GetDefinition();
71 for (
auto & v : definition.at(name)) {
74 int n = v.size() > 1 ? v[1] : axis->GetNbins() / v[0];
75 for (
int i = 0; i < n; i++) {
77 if (iBin > axis->GetNbins()) {
80 bins[count++] = axis->GetBinUpEdge(iBin);
87 axisNew->Set(count - 1, bins.get());
91 for (
int i = 0; i < cAxes->GetEntries(); i++) {
92 TAxis * axis = (TAxis *)cAxes->At(i);
93 nbins[i] = axis->GetNbins();
95 xmax[i] = axis->GetNbins();
97 fContent =
new THnSparseL(
"content",
"content", dims, nbins, xmin, xmax);
100 for (
int i = 0; i < cAxes->GetEntries(); i++) {
101 TAxis * axis = (TAxis *)cAxes->At(i);
102 TAxis * axisContent =
fContent->GetAxis(i);
103 axisContent->SetName(axis->GetName());
104 axisContent->SetTitle(axis->GetTitle());
105 if (axis->IsVariableBinSize()) {
106 axisContent->Set(
fContent->GetAxis(i)->GetNbins(), axis->GetXbins()->GetArray());
109 axisContent->Set(axis->GetNbins(), axis->GetXmin(), axis->GetXmax());
112 if (axes[i]->IsAlphanumeric()) {
113 for (
int b = 1; b <= axis->GetNbins(); b++) {
114 NLogTrace(
"NBinningDef::NBinningDef: Setting bin label for axis '%s' bin %d: '%s'", axis->GetName(), b,
115 axis->GetBinLabel(b));
116 axisContent->SetBinLabel(b, axes[i]->GetBinLabel(b));
121 for (
size_t i = 0; i <
fBinning->GetAxes().size(); i++) {
124 NLogError(
"NBinningPoint::GetTitle: Axis %d is nullptr !!!", i);
129 for (
int i = 0; i < cAxes->GetEntries(); i++) {
130 TAxis * axis = (TAxis *)cAxes->At(i);
199 Int_t * c =
new Int_t[
fContent->GetNdimensions()];
200 auto task = [
this, c](
const std::vector<int> & coords) {
201 NLogTrace(
"NBinningDef::RefreshIdsFromContent: Processing coordinates %s",
NUtils::GetCoordsString(coords).c_str());
203 for (
int i = 0; i <
fContent->GetNdimensions(); i++) {
207 Long64_t
id =
fContent->GetBinContent(c);
209 NLogTrace(
"NBinningDef::RefreshIdsFromContent: -> Bin content: %lld",
id - 1);
210 fIds.push_back(
id - 1);
214 std::vector<int> mins(
fContent->GetNdimensions(), 1);
215 std::vector<int> maxs(
fContent->GetNdimensions());
216 for (
int i = 0; i <
fContent->GetNdimensions(); i++) {
217 TAxis * axis =
fContent->GetAxis(i);
218 NLogTrace(
"NBinningDef::RefreshIdsFromContent: Axis %d: name='%s' title='%s' nbins=%d min=%.3f max=%.3f", i,
219 axis->GetName(), axis->GetTitle(), axis->GetNbins(), axis->GetXmin(), axis->GetXmax());
220 maxs[i] = axis->GetNbins();
235 NLogTrace(
"NBinningDef::RefreshContentfomIds: Refreshing content from %zu IDs: %s",
fIds.size(),
241 for (
size_t i = 0; i <
fIds.size(); ++i) {
243 fBinning->GetPoint()->SetPointContentFromLinearIndex(
id);
246 Int_t * c =
new Int_t[
fContent->GetNdimensions()];
247 std::vector<Long64_t> newIds;
249 auto task = [
this, &newIds, c](
const std::vector<int> & coords) {
250 NLogTrace(
"NBinningDef::RefreshContentfomIds: Processing coordinates %s",
NUtils::GetCoordsString(coords).c_str());
252 for (
int i = 0; i <
fContent->GetNdimensions(); i++) {
256 Long64_t
id =
fContent->GetBinContent(c);
262 NLogTrace(
"NBinningDef::RefreshContentfomIds: -> Bin content: %lld",
id - 1);
263 fIds.push_back(
id - 1);
267 std::vector<int> mins(
fContent->GetNdimensions(), 1);
268 std::vector<int> maxs(
fContent->GetNdimensions());
269 for (
int i = 0; i <
fContent->GetNdimensions(); i++) {
270 TAxis * axis =
fContent->GetAxis(i);
271 NLogTrace(
"NBinningDef::RefreshContentfomIds: Axis %d: name='%s' title='%s' nbins=%d min=%.3f max=%.3f", i,
272 axis->GetName(), axis->GetTitle(), axis->GetNbins(), axis->GetXmin(), axis->GetXmax());
273 maxs[i] = axis->GetNbins();