rf406_cattocatfuncs.C

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////
00002 //
00003 // 'DATA AND CATEGORIES' RooFit tutorial macro #406
00004 // 
00005 // Demonstration of discrete-->discrete (invertable) functions
00006 //
00007 //
00008 //
00009 // 07/2008 - Wouter Verkerke 
00010 // 
00011 /////////////////////////////////////////////////////////////////////////
00012 
00013 #ifndef __CINT__
00014 #include "RooGlobalFunc.h"
00015 #endif
00016 #include "RooRealVar.h"
00017 #include "RooDataSet.h"
00018 #include "RooPolynomial.h"
00019 #include "RooCategory.h"
00020 #include "RooMappedCategory.h"
00021 #include "RooMultiCategory.h"
00022 #include "RooSuperCategory.h"
00023 #include "Roo1DTable.h"
00024 #include "TCanvas.h"
00025 #include "TAxis.h"
00026 #include "RooPlot.h"
00027 using namespace RooFit ;
00028 
00029 
00030 void rf406_cattocatfuncs()
00031 {
00032   // C o n s t r u c t  t w o   c a t e g o r i e s
00033   // ----------------------------------------------
00034 
00035   // Define a category with labels only
00036   RooCategory tagCat("tagCat","Tagging category") ;
00037   tagCat.defineType("Lepton") ;
00038   tagCat.defineType("Kaon") ;
00039   tagCat.defineType("NetTagger-1") ;
00040   tagCat.defineType("NetTagger-2") ;
00041   tagCat.Print() ;
00042 
00043   // Define a category with explicitly numbered states
00044   RooCategory b0flav("b0flav","B0 flavour eigenstate") ;
00045   b0flav.defineType("B0",-1) ;
00046   b0flav.defineType("B0bar",1) ;
00047   b0flav.Print() ;
00048 
00049   // Construct a dummy dataset with random values of tagCat and b0flav
00050   RooRealVar x("x","x",0,10) ;
00051   RooPolynomial p("p","p",x) ;
00052   RooDataSet* data = p.generate(RooArgSet(x,b0flav,tagCat),10000) ;
00053 
00054 
00055 
00056   // 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 
00057   // ---------------------------------------------------------------------
00058 
00059   // A RooMappedCategory is category->category mapping function based on string expression
00060   // The constructor takes an input category an a default state name to which unassigned
00061   // states are mapped
00062   RooMappedCategory tcatType("tcatType","tagCat type",tagCat,"Cut based") ;
00063 
00064   // Enter fully specified state mappings
00065   tcatType.map("Lepton","Cut based") ;
00066   tcatType.map("Kaon","Cut based") ;
00067 
00068   // Enter a wilcard expression mapping
00069   tcatType.map("NetTagger*","Neural Network") ;
00070 
00071   // Make a table of the mapped category state multiplicit in data
00072   Roo1DTable* mtable = data->table(tcatType) ;
00073   mtable->Print("v") ;
00074 
00075 
00076 
00077   // 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 
00078   // ----------------------------------------------------------------------
00079 
00080   // A SUPER-category is 'product' of _lvalue_ categories. The state names of a super
00081   // category is a composite of the state labels of the input categories
00082   RooSuperCategory b0Xtcat("b0Xtcat","b0flav X tagCat",RooArgSet(b0flav,tagCat)) ;
00083 
00084   // Make a table of the product category state multiplicity in data
00085   Roo1DTable* stable = data->table(b0Xtcat) ;
00086   stable->Print("v") ;
00087 
00088   // Since the super category is an lvalue, assignment is explicitly possible
00089   b0Xtcat.setLabel("{B0bar;Lepton}") ;
00090 
00091 
00092 
00093   // A MULTI-category is a 'product' of any category (function). The state names of a super
00094   // category is a composite of the state labels of the input categories
00095   RooMultiCategory b0Xttype("b0Xttype","b0flav X tagType",RooArgSet(b0flav,tcatType)) ;
00096   
00097   // Make a table of the product category state multiplicity in data
00098   Roo1DTable* xtable = data->table(b0Xttype) ;
00099   xtable->Print("v") ;
00100 
00101 
00102 }

Generated on Tue Jul 5 15:45:06 2011 for ROOT_528-00b_version by  doxygen 1.5.1