Skip to content

Instantly share code, notes, and snippets.

@VanyaBelyaev
VanyaBelyaev / tst38.py
Created April 2, 2024 08:11
problme with pythoinns PDF for new ROOT/cppyy
import ROOT, math
print ( 'ROOT version %s' % ROOT.gROOT.GetVersion() )
ROOT.gInterpreter.Declare('''
#include "RooAbsPdf.h"
class PyPdf : public RooAbsPdf
{
public:
@VanyaBelyaev
VanyaBelyaev / tst_morph.py
Created January 29, 2023 14:41
test morphing
import ROOT, array
print ( 'ROOT version', ROOT.gROOT.GetVersion() )
x = ROOT.RooRealVar('x','x-variable' , 0 , 10 )
varset = ROOT.RooArgSet() ; varset.add ( x )
m0 = ROOT.RooFit.RooConst ( 5 )
s0 = ROOT.RooFit.RooConst ( 1 )
## generate data
ROOT version 6.27/01
(0.8357307706942926+0.5491393984360653j)
840456 function calls (839750 primitive calls) in 34.002 seconds
Ordered by: standard name
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 0.000 0.000 :0(AddCPPInstancePickling)
1 0.000 0.000 0.000 0.000 :0(AddDirectoryGetAttrPyz)
1 0.000 0.000 0.000 0.000 :0(AddDirectoryWritePyz)
@VanyaBelyaev
VanyaBelyaev / root627.txt
Created December 21, 2022 08:28
CPU performance for different verisons of ROOT
ROOT version 6.27/01
(0.8357307706942926+0.5491393984360653j)
840456 function calls (839750 primitive calls) in 34.003 seconds
Ordered by: standard name
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 0.000 0.000 :0(AddCPPInstancePickling)
1 0.000 0.000 0.000 0.000 :0(AddDirectoryGetAttrPyz)
1 0.000 0.000 0.000 0.000 :0(AddDirectoryWritePyz)
@VanyaBelyaev
VanyaBelyaev / root626.txt
Created December 21, 2022 08:25
CPU perfomance for various ROOT versions
ROOT version 6.26/04
(0.8357307706942926+0.5491393984360653j)
838190 function calls (837529 primitive calls) in 6.539 seconds
Ordered by: standard name
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 0.000 0.000 :0(AddCPPInstancePickling)
1 0.000 0.000 0.000 0.000 :0(AddDirectoryGetAttrPyz)
1 0.000 0.000 0.000 0.000 :0(AddDirectoryWritePyz)
import ROOT
ROOT.gInterpreter.Declare("""
#include <complex>
#include <cmath>
namespace Test {
double myfun ( const double a ) { return a ; }
std::complex<double> myfun ( const std::complex<double> a ) { return a ; }
}
""")
print ('ROOT version', ROOT.gROOT.GetVersion() )
@VanyaBelyaev
VanyaBelyaev / tst99.py
Created December 18, 2022 15:19
Wrong overload ROOT 6/27
import ROOT
ROOT.gInterpreter.Declare("""
#include <complex>
#include <cmath>
namespace Test {
double myfun ( const double a ) { return a ; }
std::complex<double> myfun ( const std::complex<double> a ) { return a ; }
}
""")
@VanyaBelyaev
VanyaBelyaev / tst_1.py
Created August 25, 2022 10:16
Treatment of errors for fits to unbinned/.binned/weighted datasets
import ROOT, random
## 1) create Gaussian fit models
xvar = ROOT.RooRealVar( 'x' , 'x-observable' , 0 , 10 )
mean = ROOT.RooRealVar( 'mean' , 'mean-value for Gaussian' , 5 , 2 , 8 )
sigma = ROOT.RooRealVar( 'sigma' , 'sigma-value for Gaussian' , 1 , 0.5 , 2.0 )
gauss = ROOT.RooGaussian( 'G' , 'Gaussian model' , xvar , mean , sigma )
## 2) create and fill dataste & histogram
#!/bin/bash
## 1. setup environment
## SUCCESS
## source /cvmfs/sft.cern.ch/lcg/views/LCG_97a/x86_64-centos7-gcc9-opt/setup.sh
## source /cvmfs/sft.cern.ch/lcg/views/LCG_97/x86_64-centos7-gcc9-opt/setup.sh
## source /cvmfs/sft.cern.ch/lcg/views/LCG_96b/x86_64-centos7-gcc9-opt/setup.sh
## source /cvmfs/sft.cern.ch/lcg/views/LCG_96a/x86_64-centos7-gcc8-opt/setup.sh
from __future__ import print_function
import ROOT
ROOT.gROOT.ProcessLine('''
#include <string>
#include <iostream>
class A
{
public: