rf406_cattocatfuncs.cxx

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 "RooPlot.h"
00026 using namespace RooFit ;
00027 
00028 
00029 class TestBasic406 : public RooFitTestUnit
00030 {
00031 public: 
00032   TestBasic406(TFile* refFile, Bool_t writeRef, Int_t verbose) : RooFitTestUnit("Category-to-category functions",refFile,writeRef,verbose) {} ;
00033   Bool_t testCode() {
00034 
00035   // C o n s t r u c t  t w o   c a t e g o r i e s
00036   // ----------------------------------------------
00037 
00038   // Define a category with labels only
00039   RooCategory tagCat("tagCat","Tagging category") ;
00040   tagCat.defineType("Lepton") ;
00041   tagCat.defineType("Kaon") ;
00042   tagCat.defineType("NetTagger-1") ;
00043   tagCat.defineType("NetTagger-2") ;
00044 
00045   // Define a category with explicitly numbered states
00046   RooCategory b0flav("b0flav","B0 flavour eigenstate") ;
00047   b0flav.defineType("B0",-1) ;
00048   b0flav.defineType("B0bar",1) ;
00049 
00050   // Construct a dummy dataset with random values of tagCat and b0flav
00051   RooRealVar x("x","x",0,10) ;
00052   RooPolynomial p("p","p",x) ;
00053   RooDataSet* data = p.generate(RooArgSet(x,b0flav,tagCat),10000) ;
00054 
00055 
00056 
00057   // 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 
00058   // ---------------------------------------------------------------------
00059 
00060   // A RooMappedCategory is category->category mapping function based on string expression
00061   // The constructor takes an input category an a default state name to which unassigned
00062   // states are mapped
00063   RooMappedCategory tcatType("tcatType","tagCat type",tagCat,"Cut based") ;
00064 
00065   // Enter fully specified state mappings
00066   tcatType.map("Lepton","Cut based") ;
00067   tcatType.map("Kaon","Cut based") ;
00068 
00069   // Enter a wilcard expression mapping
00070   tcatType.map("NetTagger*","Neural Network") ;
00071 
00072   // Make a table of the mapped category state multiplicit in data
00073   Roo1DTable* mtable = data->table(tcatType) ;
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 
00087   // Since the super category is an lvalue, assignment is explicitly possible
00088   b0Xtcat.setLabel("{B0bar;Lepton}") ;
00089 
00090 
00091 
00092   // A MULTI-category is a 'product' of any category (function). The state names of a super
00093   // category is a composite of the state labels of the input categories
00094   RooMultiCategory b0Xttype("b0Xttype","b0flav X tagType",RooArgSet(b0flav,tcatType)) ;
00095   
00096   // Make a table of the product category state multiplicity in data
00097   Roo1DTable* xtable = data->table(b0Xttype) ;
00098 
00099   regTable(mtable,"rf406_mtable") ;
00100   regTable(stable,"rf406_stable") ;
00101   regTable(xtable,"rf406_xtable") ;
00102 
00103   delete data ;
00104 
00105   return kTRUE ;
00106   }
00107 
00108 } ;

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