Logo ROOT  
Reference Guide
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_roofit
3/// \notebook -nodraw
4/// Data and categories: demonstration of discrete-->discrete (invertible) functions
6/// \macro_output
7/// \macro_code
9/// \date July 2008
10/// \author Wouter Verkerke
12#include "RooRealVar.h"
13#include "RooDataSet.h"
14#include "RooPolynomial.h"
15#include "RooCategory.h"
16#include "RooMappedCategory.h"
17#include "RooMultiCategory.h"
18#include "RooSuperCategory.h"
19#include "Roo1DTable.h"
20#include "TCanvas.h"
21#include "TAxis.h"
22#include "RooPlot.h"
23using namespace RooFit;
27 // C o n s t r u c t t w o c a t e g o r i e s
28 // ----------------------------------------------
30 // Define a category with labels only
31 RooCategory tagCat("tagCat", "Tagging category");
32 tagCat.defineType("Lepton");
33 tagCat.defineType("Kaon");
34 tagCat.defineType("NetTagger-1");
35 tagCat.defineType("NetTagger-2");
36 tagCat.Print();
38 // Define a category with explicitly numbered states
39 RooCategory b0flav("b0flav", "B0 flavour eigenstate");
40 b0flav.defineType("B0", -1);
41 b0flav.defineType("B0bar", 1);
42 b0flav.Print();
44 // Construct a dummy dataset with random values of tagCat and b0flav
45 RooRealVar x("x", "x", 0, 10);
46 RooPolynomial p("p", "p", x);
47 RooDataSet *data = p.generate(RooArgSet(x, b0flav, tagCat), 10000);
49 // 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
50 // ---------------------------------------------------------------------
52 // A RooMappedCategory is category->category mapping function based on string expression
53 // The constructor takes an input category an a default state name to which unassigned
54 // states are mapped
55 RooMappedCategory tcatType("tcatType", "tagCat type", tagCat, "Cut based");
57 // Enter fully specified state mappings
58 tcatType.map("Lepton", "Cut based");
59 tcatType.map("Kaon", "Cut based");
61 // Enter a wilcard expression mapping
62 tcatType.map("NetTagger*", "Neural Network");
64 // Make a table of the mapped category state multiplicity in data
65 Roo1DTable *mtable = data->table(tcatType);
66 mtable->Print("v");
68 // 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
69 // ----------------------------------------------------------------------
71 // A SUPER-category is 'product' of _lvalue_ categories. The state names of a super
72 // category is a composite of the state labels of the input categories
73 RooSuperCategory b0Xtcat("b0Xtcat", "b0flav X tagCat", RooArgSet(b0flav, tagCat));
75 // Make a table of the product category state multiplicity in data
76 Roo1DTable *stable = data->table(b0Xtcat);
77 stable->Print("v");
79 // Since the super category is an lvalue, assignment is explicitly possible
80 b0Xtcat.setLabel("{B0bar;Lepton}");
82 // A MULTI-category is a 'product' of any category (function). The state names of a super
83 // category is a composite of the state labels of the input categories
84 RooMultiCategory b0Xttype("b0Xttype", "b0flav X tagType", RooArgSet(b0flav, tcatType));
86 // Make a table of the product category state multiplicity in data
87 Roo1DTable *xtable = data->table(b0Xttype);
88 xtable->Print("v");
Roo1DTable implements a one-dimensional table.
Definition: Roo1DTable.h:23
virtual void Print(Option_t *options=0) const
Print TNamed name and title.
Definition: Roo1DTable.h:50
virtual Roo1DTable * table(const RooArgSet &catSet, const char *cuts="", const char *opts="") const
Construct table for product of categories in catSet.
Definition: RooAbsData.cxx:749
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:29
RooCategory is an object to represent discrete states.
Definition: RooCategory.h:27
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:33
RooMappedCategory provides a category-to-category mapping defined by pattern matching on their state ...
RooMultiCategory connects several RooAbsCategory objects into a single category.
RooPolynomial implements a polynomial p.d.f of the form.
Definition: RooPolynomial.h:28
RooRealVar represents a variable that can be changed from the outside.
Definition: RooRealVar.h:39
The RooSuperCategory can join several RooAbsCategoryLValue objects into a single category.
Double_t x[n]
Definition: legend1.C:17
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...