#!/usr/bin/env python # coding: utf-8 # # rf506_msgservice # Organization and simultaneous fits: tuning and customizing the ROOT.RooFit message logging facility # # # # # **Author:** Clemens Lange, Wouter Verkerke (C++ version) # This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Wednesday, April 17, 2024 at 11:19 AM. # In[1]: import ROOT # Create pdf # -------------------- # Construct gauss(x,m,s) # In[2]: x = ROOT.RooRealVar("x", "x", -10, 10) m = ROOT.RooRealVar("m", "m", 0, -10, 10) s = ROOT.RooRealVar("s", "s", 1, -10, 10) gauss = ROOT.RooGaussian("g", "g", x, m, s) # Construct poly(x,p0) # In[3]: p0 = ROOT.RooRealVar("p0", "p0", 0.01, 0.0, 1.0) poly = ROOT.RooPolynomial("p", "p", x, [p0]) # model = f*gauss(x) + (1-f)*poly(x) # In[4]: f = ROOT.RooRealVar("f", "f", 0.5, 0.0, 1.0) model = ROOT.RooAddPdf("model", "model", [gauss, poly], [f]) data = model.generate({x}, 10) # Print configuration of message service # ------------------------------------------ # Print streams configuration # In[5]: ROOT.RooMsgService.instance().Print() # Adding integration topic to existing INFO stream # --------------------------------------------------- # Print streams configuration # In[6]: ROOT.RooMsgService.instance().Print() # Add Integration topic to existing INFO stream # In[7]: ROOT.RooMsgService.instance().getStream(1).addTopic(ROOT.RooFit.Integration) # Construct integral over gauss to demonstrate message stream # In[8]: igauss = gauss.createIntegral({x}) igauss.Print() # Print streams configuration in verbose, also shows inactive streams # In[9]: ROOT.RooMsgService.instance().Print() # Remove stream # In[10]: ROOT.RooMsgService.instance().getStream(1).removeTopic(ROOT.RooFit.Integration) # Examples of pdf value tracing # ----------------------------------------------------------------------- # Show DEBUG level message on function tracing, ROOT.RooGaussian only # In[11]: ROOT.RooMsgService.instance().addStream(ROOT.RooFit.DEBUG, Topic=ROOT.RooFit.Tracing, ClassName="RooGaussian") # Perform a fit to generate some tracing messages # In[12]: model.fitTo(data, Verbose=True) # Reset message service to default stream configuration # In[13]: ROOT.RooMsgService.instance().reset() # Show DEBUG level message on function tracing on all objects, output to # file # In[14]: ROOT.RooMsgService.instance().addStream(ROOT.RooFit.DEBUG, Topic=ROOT.RooFit.Tracing, OutputFile="rf506_debug.log") # Perform a fit to generate some tracing messages # In[15]: model.fitTo(data, Verbose=True) # Reset message service to default stream configuration # In[16]: ROOT.RooMsgService.instance().reset() # Example of another debugging stream # --------------------------------------------------------------------- # Show DEBUG level messages on client/server link state management # In[17]: ROOT.RooMsgService.instance().addStream(ROOT.RooFit.DEBUG, Topic=ROOT.RooFit.LinkStateMgmt) ROOT.RooMsgService.instance().Print("v") # Clone composite pdf g to trigger some link state management activity # In[18]: gprime = gauss.cloneTree() gprime.Print() # Reset message service to default stream configuration # In[19]: ROOT.RooMsgService.instance().reset()