ROOT
Version master
master
v6.34
v6.32
v6.30
v6.28
v6.26
v6.24
v6.22
v6.20
v6.18
v6.16
v6.14
v6.12
v6.10
v6.08
v6.06
v6.04
Reference Guide
►
ROOT
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
Loading...
Searching...
No Matches
rf406_cattocatfuncs.py
2
## \ingroup tutorial_roofit_main
3
## \notebook -nodraw
4
## Data and categories: demonstration of discrete-discrete (invertable) functions
5
##
6
## \macro_code
7
## \macro_output
8
##
9
## \date February 2018
10
## \authors Clemens Lange, Wouter Verkerke (C++ version)
11
12
import
ROOT
13
14
15
# Construct two categories
16
# ----------------------------------------------
17
18
# Define a category with labels only
19
tagCat =
ROOT.RooCategory
(
"tagCat"
,
"Tagging category"
)
20
tagCat.defineType
(
"Lepton"
)
21
tagCat.defineType
(
"Kaon"
)
22
tagCat.defineType
(
"NetTagger-1"
)
23
tagCat.defineType
(
"NetTagger-2"
)
24
tagCat.Print
()
25
26
# Define a category with explicitly numbered states
27
b0flav =
ROOT.RooCategory
(
"b0flav"
,
"B0 flavour eigenstate"
, {
"B0"
: -1,
"B0bar"
: 1})
28
b0flav.Print
()
29
30
# Construct a dummy dataset with random values of tagCat and b0flav
31
x =
ROOT.RooRealVar
(
"x"
,
"x"
, 0, 10)
32
p =
ROOT.RooPolynomial
(
"p"
,
"p"
, x)
33
data =
p.generate
({x, b0flav, tagCat}, 10000)
34
35
# Create a cat -> cat mapping category
36
# ---------------------------------------------------------------------
37
38
# A RooMappedCategory is category.category mapping function based on string expression
39
# The constructor takes an input category an a default state name to which unassigned
40
# states are mapped
41
tcatType =
ROOT.RooMappedCategory
(
"tcatType"
,
"tagCat type"
, tagCat,
"Cut based"
)
42
43
# Enter fully specified state mappings
44
tcatType.map
(
"Lepton"
,
"Cut based"
)
45
tcatType.map
(
"Kaon"
,
"Cut based"
)
46
47
# Enter a wildcard expression mapping
48
tcatType.map
(
"NetTagger*"
,
"Neural Network"
)
49
50
# Make a table of the mapped category state multiplicit in data
51
mtable =
data.table
(tcatType)
52
mtable.Print
(
"v"
)
53
54
# Create a cat X cat product category
55
# ----------------------------------------------------------------------
56
57
# A SUPER-category is 'product' of _lvalue_ categories. The state names of a super
58
# category is a composite of the state labels of the input categories
59
b0Xtcat =
ROOT.RooSuperCategory
(
"b0Xtcat"
,
"b0flav X tagCat"
, {b0flav, tagCat})
60
61
# Make a table of the product category state multiplicity in data
62
stable =
data.table
(b0Xtcat)
63
stable.Print
(
"v"
)
64
65
# Since the super category is an lvalue, is explicitly possible
66
b0Xtcat.setLabel
(
"{B0bar;Lepton}"
)
67
68
# A MULTI-category is a 'product' of any category (function). The state names of a super
69
# category is a composite of the state labels of the input categories
70
b0Xttype =
ROOT.RooMultiCategory
(
"b0Xttype"
,
"b0flav X tagType"
, {b0flav, tcatType})
71
72
# Make a table of the product category state multiplicity in data
73
xtable =
data.table
(b0Xttype)
74
xtable.Print
(
"v"
)
TRangeDynCast
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Definition
TCollection.h:358
tutorials
roofit
roofit
rf406_cattocatfuncs.py
ROOT master - Reference Guide Generated on Thu Feb 20 2025 04:19:54 (GVA Time) using Doxygen 1.10.0