Giter Site home page Giter Site logo

root_tools's Introduction

ROOT data analysis helper

This is a collection of packaged functions of frequently used data analysis methods.This tries to make the heavily routined code can be used repeatedly without rewritten (also prone to error), inspired by 1. The functions are implemented as wrapper around ROOT (version 6.24, 6.26 expected to behave similarily), either in python (to be used with PyROOT) or in ROOT macros.

the implementations are in: ToolsCollection.h (.py)

the 'tutorial' (actually I tested the functions in the file) are in: ToolsCollection_TestBench.h (.ipynb)

note:

you are recommended to use the ToolsCollection.h, either with another ROOT macro (or c++ based code) or in the PyROOT codes

currently i was writting in python and translate it into cpp file. if any problem arise in cpp, always check with the py file first.

1. to use with PyROOT,run for example:

from root_tools.ToolsCollection import fft
from root_tools.ToolsCollection import cut_th1d
from root_tools.ToolsCollection import identify_hist_peaks

1.1 if you want to import the whole collection (and plan to reload), use:

import importlib
tools = importlib.import_module("root_tools.ToolsCollection")
importlib.reload(tools)

1.2 if you do not plan to reload

import root_tools.ToolsCollection

so the function should be called in this way:

root_tools.ToolsCollection.fft(kwargs)

note: this repo is meant to be portable for now, instead of a full package. so if you import from other path, do something like:

import sys
sys.path.append("path/root_tools/")
from ToolsCollection import *

1.3 or using alias:

import root_tools.ToolsCollection as tools
tools.fft(kwargs)

2. for the ROOT macro, you can use it in two ways:

2.1 included in another ROOT macro (ROOT-based program file not yet tested)

just put:

#include "ToolsCollection.h"

in the program file

2.2 use with pyROOT (recommended over the python file import)

import ROOT
ROOT.gROOT.ProcessLine(".L ./ToolsCollection.h")
ROOT.fft(kwargs)

the following code also work. But I still need some times to understand the working of c++ compiler and root interpreter2

r.gInterpreter.Declare('# include "path/to/ToolsCollection.h"') // is path/to/* a good practice ?
# r.gROOT.ProcessLine('# include "ToolsCollection.h"') # also work. but which one is more easy to move to compiled version ?

3. known issues

  1. now the fft, residual only support TH1D. tried to use TH1 but got calling a protected constructor of class 'TH1' error maybe can overload the functions ?

Footnotes

  1. https://github.com/heymanwasup/OmegaFitting/blob/main/Fitter/functions.h

  2. https://root.cern.ch/root/htmldoc/guides/users-guide/ROOTUsersGuide.html#the-c-interpreter-cling

root_tools's People

Contributors

junkai2998 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.