ROOT
master
Reference Guide
Loading...
Searching...
No Matches
RNTupleDrawVisitor.cxx
Go to the documentation of this file.
1
/// \file RNTupleDrawVisitor.cxx
2
/// \ingroup NTuple
3
/// \author Sergey Linev <S.Linev@gsi.de>, Jakob Blomer <jblomer@cern.ch>
4
/// \date 2025-07-24
5
6
/*************************************************************************
7
* Copyright (C) 1995-2025, Rene Brun and Fons Rademakers. *
8
* All rights reserved. *
9
* *
10
* For the licensing terms see $ROOTSYS/LICENSE. *
11
* For the list of contributors see $ROOTSYS/README/CREDITS. *
12
*************************************************************************/
13
14
#include <
ROOT/RNTupleDrawVisitor.hxx
>
15
16
#include <
TH1F.h
>
17
18
#include <algorithm>
19
#include <cmath>
20
#include <cstddef>
21
#include <memory>
22
#include <utility>
23
24
void
ROOT::Internal::RNTupleDrawVisitor::TestHistBuffer
()
25
{
26
std::size_t
len
=
fHist
->GetBufferLength();
27
auto
buf =
fHist
->GetBuffer();
28
29
if
(!buf || (
len
< 5))
30
return
;
31
32
double
min = buf[1];
33
double
max = buf[1];
34
bool
is_integer =
true
;
35
36
for
(std::size_t
n
= 0;
n
<
len
; ++
n
) {
37
double
v
= buf[2 + 2 *
n
];
38
max = std::max(max,
v
);
39
min = std::min(min,
v
);
40
double
_
;
41
if
(std::abs(std::modf(
v
, &
_
)) > 1
e
-5) {
42
is_integer =
false
;
43
break
;
44
}
45
}
46
47
// special case when only integer values in short range - better binning
48
if
(is_integer && (max - min < 100)) {
49
max += 2;
50
if
(min > 1)
51
min -= 2;
52
int
npoints = std::nearbyint(max - min);
53
std::unique_ptr<TH1>
h1
= std::make_unique<TH1F>(
fHist
->GetName(),
fHist
->GetTitle(), npoints, min, max);
54
h1
->SetDirectory(
nullptr
);
55
for
(
size_t
n
= 0;
n
<
len
; ++
n
)
56
h1
->Fill(buf[2 + 2 *
n
], buf[1 + 2 *
n
]);
57
std::swap(
fHist
,
h1
);
58
}
59
}
RNTupleDrawVisitor.hxx
e
#define e(i)
Definition
RSha256.hxx:103
len
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Definition
TGWin32VirtualXProxy.cxx:249
TH1F.h
_
#define _(A, B)
Definition
cfortran.h:108
ROOT::Internal::RNTupleDrawVisitor::fHist
std::unique_ptr< TH1 > fHist
Definition
RNTupleDrawVisitor.hxx:36
ROOT::Internal::RNTupleDrawVisitor::TestHistBuffer
void TestHistBuffer()
Test collected entries if it looks like integer values and one can use better binning.
Definition
RNTupleDrawVisitor.cxx:24
n
const Int_t n
Definition
legend1.C:16
h1
TH1F * h1
Definition
legend1.C:5
v
@ v
Definition
rootcling_impl.cxx:3554
tree
ntuplebrowse
src
RNTupleDrawVisitor.cxx
ROOTmaster - Reference Guide Generated on Tue May 19 2026 19:40:20 (GVA Time) using Doxygen 1.13.2