Skip to content

Instantly share code, notes, and snippets.

View eguiraud's full-sized avatar
👨‍💻

Enrico Guiraud eguiraud

👨‍💻
View GitHub Profile
@eguiraud
eguiraud / sway.log
Created June 2, 2023 04:44
Sway log
00:00:00.000 [INFO] [sway/main.c:338] Sway version 1.8.1
00:00:00.000 [INFO] [sway/main.c:339] wlroots version 0.16.2
00:00:00.003 [INFO] [sway/main.c:120] Linux colin 6.1.31-1-lts #1 SMP PREEMPT_DYNAMIC Tue, 30 May 2023 14:36:16 +0000 x86_64 GNU/Linux
00:00:00.003 [INFO] [sway/main.c:136] Contents of /etc/lsb-release:
00:00:00.003 [INFO] [sway/main.c:120] DISTRIB_ID="Arch"
00:00:00.003 [INFO] [sway/main.c:120] DISTRIB_RELEASE="rolling"
00:00:00.003 [INFO] [sway/main.c:120] DISTRIB_DESCRIPTION="Arch Linux"
00:00:00.003 [INFO] [sway/main.c:136] Contents of /etc/os-release:
00:00:00.003 [INFO] [sway/main.c:120] NAME="Arch Linux"
00:00:00.003 [INFO] [sway/main.c:120] PRETTY_NAME="Arch Linux"
@eguiraud
eguiraud / array_column_ugly_first_version.cpp
Last active May 19, 2023 15:53
Bulk RDF with functor class
#include <ROOT/RDataFrame.hxx>
#include <ROOT/RVec.hxx>
#include <iostream>
using ROOT::RVecF;
using ROOT::RVecU;
struct ToolAdapter {
Tool tool;
@eguiraud
eguiraud / stateful_filter.py
Last active June 18, 2024 08:47
A thread-safe stateful Filter for RDataFrame
import ROOT
ROOT.gInterpreter.Declare("""
// A thread-safe stateful filter that lets only one event pass for each value of
// "category" (where "category" is a random character).
// It is using gCoreMutex, which is a read-write lock, to have a bit less contention between threads.
class FilterOnePerKind {
std::unordered_set<char> _seenCategories;
public:
bool operator()(char category) {
#include <ROOT/RDataFrame.hxx>
#include <TTreeReader.h>
#include <TCanvas.h>
#include <TTreeReaderValue.h>
#include <TChain.h>
#include <TFile.h>
#include <TTree.h>
#include <TH1D.h>
#include <iostream>
@eguiraud
eguiraud / Dockerfile
Created August 17, 2020 08:17
Docker image that mimics ROOT's conda nightly builds (and reproduces their failing tests)
FROM condaforge/linux-anvil-comp7:latest
WORKDIR /home/conda
RUN source /opt/conda/bin/activate && conda update -y --all && \
conda create -n root-nightly -c conda-forge -c https://root.cern/download/conda-nightly/latest root-nightly cmake make git
RUN source /opt/conda/bin/activate && conda activate root-nightly && \
git clone https://github.com/root-project/roottest.git && mkdir roottest_build && cd roottest_build && \
cmake -DPYTHON_EXECUTABLE_Development_Main=$(which python) -Ddataframe=ON ../roottest && cmake --build . -- -j4
#include <ROOT/RDataFrame.hxx>
#include <ROOT/TypeTraits.hxx>
#include <TEntryList.h>
#include <map>
#include <mutex>
#include <utility>
template <typename GroupFn, typename R = typename ROOT::TypeTraits::CallableTraits<GroupFn>::ret_type>
std::map<R, ROOT::RDF::RNode> GroupBy(ROOT::RDF::RNode df, GroupFn &&fn, const std::vector<std::string> &cols)
{
@eguiraud
eguiraud / numba_numpy_rvec.py
Last active March 31, 2020 13:07
RVecs as numpy arrays via numba in RDataFrame
import numba as nb
from numba.types import CPointer, Array, void
import ROOT
import numpy as np
import ctypes
def c_friendly_signature(args, ret):
"""Take a normalized numba signature, return a C-friendly signature:
array types are substituted with a pointer/size pair.
"""
@eguiraud
eguiraud / slow_rdf_jitting.cpp
Created March 18, 2020 15:14
example code that takes seconds to be jitted withing RDF, in compilable form
#include "ROOT/RDF/RLoopManager.hxx"
#include "ROOT/RDF/RJittedCustomColumn.hxx"
#include "ROOT/RDF/InterfaceUtils.hxx"
#include "ROOT/RDF/RBookedCustomColumns.hxx"
#include <memory>
using namespace std;
int main() {};
// Dataframe 0
#include <ROOT/TypeTraits.hxx>
#include <cassert>
#include <functional>
namespace ROOT {
namespace Internal {
template <typename... ArgTypes, typename F>
std::function<bool(ArgTypes...)> NotHelper(ROOT::TypeTraits::TypeList<ArgTypes...>, F &&f)
{
return std::function<bool(ArgTypes...)>([&](ArgTypes... args) { return !f(args...); });
@eguiraud
eguiraud / tdf_pipes.cpp
Last active January 25, 2018 17:33
proof of concept of TDF usage with pipe operators
#include <vector>
#include <ROOT/TDataFrame.hxx>
#include <TCanvas.h>
using namespace ROOT::Experimental;
template <typename TDF, typename OP>
auto operator|(TDF &d, OP &&op)
{
return op(d);
}