Logo ROOT   6.16/01
Reference Guide
rf406_cattocatfuncs.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_roofit
3/// \notebook -nodraw
4/// 'DATA AND CATEGORIES' RooFit tutorial macro #406
5///
6/// Demonstration of discrete-->discrete (invertable) functions
7///
8/// \macro_output
9/// \macro_code
10/// \author 07/2008 - Wouter Verkerke
11
12
13#include "RooRealVar.h"
14#include "RooDataSet.h"
15#include "RooPolynomial.h"
16#include "RooCategory.h"
17#include "RooMappedCategory.h"
18#include "RooMultiCategory.h"
19#include "RooSuperCategory.h"
20#include "Roo1DTable.h"
21#include "TCanvas.h"
22#include "TAxis.h"
23#include "RooPlot.h"
24using namespace RooFit ;
25
26
28{
29 // C o n s t r u c t t w o c a t e g o r i e s
30 // ----------------------------------------------
31
32 // Define a category with labels only
33 RooCategory tagCat("tagCat","Tagging category") ;
34 tagCat.defineType("Lepton") ;
35 tagCat.defineType("Kaon") ;
36 tagCat.defineType("NetTagger-1") ;
37 tagCat.defineType("NetTagger-2") ;
38 tagCat.Print() ;
39
40 // Define a category with explicitly numbered states
41 RooCategory b0flav("b0flav","B0 flavour eigenstate") ;
42 b0flav.defineType("B0",-1) ;
43 b0flav.defineType("B0bar",1) ;
44 b0flav.Print() ;
45
46 // Construct a dummy dataset with random values of tagCat and b0flav
47 RooRealVar x("x","x",0,10) ;
48 RooPolynomial p("p","p",x) ;
49 RooDataSet* data = p.generate(RooArgSet(x,b0flav,tagCat),10000) ;
50
51
52
53 // C r e a t e a c a t - > c a t m a p p i n g c a t e g o r y
54 // ---------------------------------------------------------------------
55
56 // A RooMappedCategory is category->category mapping function based on string expression
57 // The constructor takes an input category an a default state name to which unassigned
58 // states are mapped
59 RooMappedCategory tcatType("tcatType","tagCat type",tagCat,"Cut based") ;
60
61 // Enter fully specified state mappings
62 tcatType.map("Lepton","Cut based") ;
63 tcatType.map("Kaon","Cut based") ;
64
65 // Enter a wilcard expression mapping
66 tcatType.map("NetTagger*","Neural Network") ;
67
68 // Make a table of the mapped category state multiplicity in data
69 Roo1DTable* mtable = data->table(tcatType) ;
70 mtable->Print("v") ;
71
72
73
74 // C r e a t e a c a t X c a t p r o d u c t c a t e g o r y
75 // ----------------------------------------------------------------------
76
77 // A SUPER-category is 'product' of _lvalue_ categories. The state names of a super
78 // category is a composite of the state labels of the input categories
79 RooSuperCategory b0Xtcat("b0Xtcat","b0flav X tagCat",RooArgSet(b0flav,tagCat)) ;
80
81 // Make a table of the product category state multiplicity in data
82 Roo1DTable* stable = data->table(b0Xtcat) ;
83 stable->Print("v") ;
84
85 // Since the super category is an lvalue, assignment is explicitly possible
86 b0Xtcat.setLabel("{B0bar;Lepton}") ;
87
88
89
90 // A MULTI-category is a 'product' of any category (function). The state names of a super
91 // category is a composite of the state labels of the input categories
92 RooMultiCategory b0Xttype("b0Xttype","b0flav X tagType",RooArgSet(b0flav,tcatType)) ;
93
94 // Make a table of the product category state multiplicity in data
95 Roo1DTable* xtable = data->table(b0Xttype) ;
96 xtable->Print("v") ;
97
98
99}
Roo1DTable implements a one-dimensional table.
Definition: Roo1DTable.h:24
virtual void Print(Option_t *options=0) const
Print TNamed name and title.
Definition: Roo1DTable.h:51
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:28
RooCategory represents a fundamental (non-derived) discrete value object.
Definition: RooCategory.h:24
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:31
RooMultiCategory consolidates several RooAbsCategory objects into a single category.
RooPolynomial implements a polynomial p.d.f of the form.
Definition: RooPolynomial.h:28
RooRealVar represents a fundamental (non-derived) real valued object.
Definition: RooRealVar.h:36
RooSuperCategory consolidates several RooAbsCategoryLValue objects into a single category.
Double_t x[n]
Definition: legend1.C:17