ROOT
master
Reference Guide
Loading...
Searching...
No Matches
TreeReadBuffer.h
Go to the documentation of this file.
1
/// \cond ROOFIT_INTERNAL
2
3
/*
4
* Project: RooFit
5
* Authors:
6
* Stephan Hageboeck, CERN 2020
7
*
8
* Copyright (c) 2022, CERN
9
*
10
* Redistribution and use in source and binary forms,
11
* with or without modification, are permitted according to the terms
12
* listed in LICENSE (http://roofit.sourceforge.net/license.txt)
13
*/
14
15
#ifndef RooFit_TreeReadBuffer_h
16
#define RooFit_TreeReadBuffer_h
17
18
#include <
TTree.h
>
19
20
struct
TreeReadBuffer
{
21
virtual
~TreeReadBuffer
() =
default
;
22
virtual
operator
double
() = 0;
23
virtual
operator
int
() = 0;
24
};
25
26
/// Helper for reading branches with various types from a TTree, and convert all to double.
27
template
<
typename
T>
28
struct
TypedTreeReadBuffer
final
:
public
TreeReadBuffer
{
29
operator
double
()
override
{
return
_value; }
30
operator
int
()
override
{
return
_value; }
31
T _value;
32
};
33
34
/// Create a TreeReadBuffer to hold the specified type, and attach to the branch passed as argument.
35
/// \tparam T Type of branch to be read.
36
/// \param[in] branchName Attach to this branch.
37
/// \param[in] tree Tree to attach to.
38
template
<
typename
T>
39
std::unique_ptr<TreeReadBuffer>
createTreeReadBuffer
(
const
TString
&
branchName
,
TTree
&tree)
40
{
41
auto
buf =
new
TypedTreeReadBuffer<T>
();
42
tree.SetBranchAddress(
branchName.Data(), &buf->_value);
43
return
std::unique_ptr<TreeReadBuffer>(buf);
44
}
45
46
#endif
47
48
/// \endcond
TRangeDynCast
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Definition
TCollection.h:358
TTree.h
ROOT::Detail::TRangeCast
Definition
TCollection.h:311
TString
Basic string class.
Definition
TString.h:138
TTree
A TTree represents a columnar dataset.
Definition
TTree.h:89
double
int
TMVA_SOFIE_GNN_Parser.tree
tree
Definition
TMVA_SOFIE_GNN_Parser.py:176
roofit
roofitcore
src
TreeReadBuffer.h
ROOT master - Reference Guide Generated on Fri Sep 5 2025 15:04:34 (GVA Time) using Doxygen 1.10.0