Skip to content

Instantly share code, notes, and snippets.

View eguiraud's full-sized avatar
👨‍💻

Enrico Guiraud eguiraud

👨‍💻
View GitHub Profile
@eguiraud
eguiraud / StreamMe.h
Created August 31, 2015 09:31
some snippets that send and receive C++ objects using ROOT streaming capabilities
#ifndef _STREAMME_
#define _STREAMME_
struct StreamMe {
explicit StreamMe(int _a) : a(_a) {};
StreamMe() : StreamMe(1) {};
int a;
std::vector<int> b;
};
@eguiraud
eguiraud / PoolBenchmark_compile.cxx
Created September 9, 2015 12:24
test and benchmarks for ROOT/core/multiproc
#include "TPool.h"
#include "TH1F.h"
#include "TRandom3.h"
#include "TStopwatch.h"
#include "TApplication.h"
#include <iostream>
#include <vector>
TObject *FillHisto(unsigned long long nEvents) {
TH1F *h = new TH1F("h","h",100,-3,3);
@eguiraud
eguiraud / templight_root_profile.sh
Created February 6, 2017 10:45
use templight to compile a root source and produce parsed profile info
#!/bin/bash
# N.B. requires gawk, recode, templight++ and templigt-convert to be in PATH
SRC="$1"
if [[ -z "${SRC}" ]]; then
exit 1
fi
FNAME=${SRC%.C}
FNAME=${FNAME%.cpp}
@eguiraud
eguiraud / DevGuide.md
Last active June 28, 2017 10:38
TDataFrame gists

TDataFrame developer guide, or "why the hell is it implemented like this"

Before delving in this utterly incomplete developers guide make sure you read the users guide here.

Overview

The important objects that are part of the TDataFrame framework are the following:

  • Helpers: all objects in TDFActionHelpers.{hxx,cxx}) are those that actually execute the actions. There is about one helper per possible action. These are full-blown objects because in general they need to store state (e.g. current value of Max of a branch), they must be thread-aware (i.e. they store one partial result per thread/slot) and they must perform finalising operations when the event-loop is terminated (e.g. merge of the partial results).
  • TDataFrameValue: (docs): an abstraction over the different kinds of branch values that the nodes in the TDataFrame framewor
/*
Proof of concept of a TDataFrame with a lot less templates.
Issues:
- circular dependency nightmare in which all the different nodes have to know about each other and call methods on
each other. Could be solved introducing a common parent class, but that would probably mean virtual dispatch?
*/
#include "TTreeReader.h"
#include "TTreeReaderValue.h"
@eguiraud
eguiraud / meta_utils.hpp
Last active April 25, 2017 09:22
misc metaprogramming utilities
#include <cstddef> // std::size_t
#include <type_traits> // std::decay, std::is_same
#include <vector> // need vector<bool> in is_container
namespace meta {
// lightweight storage for a collection of types
// differently from std::tuple, no instantiation of objects of stored types is performed
template <typename... Types>
struct type_list {
@eguiraud
eguiraud / interface_samples.cxx
Created May 18, 2017 22:20
TDataSource proposal
// TDataSource
//
// The problem it tries to solve:
// - accessing specific columns of any tabular data-set through a uniform interface
// - allow thread-safe parallel processing of the data (by slicing the data-set in nThreads pieces)
// - offer the simplest interface possible, ideally iterator-based
// 1. -- build the data source
TDataSource s("file.root");
@eguiraud
eguiraud / not_fn.cpp
Last active September 24, 2017 17:10
std::not_fn c++11 implementation
#include <type_traits> // std::decay
#include <utility> // std::forward, std::declval
namespace Internal {
template <typename F>
class not_fn_t {
typename std::decay<F>::type fFun;
public:
explicit not_fn_t(F &&f) : fFun(std::forward<F>(f)) {}

Summary of testing status of TDF features

(Date of last update can be checked with git log -- README.md)

Testing categories

Data types

To be tested both as input and as output:

P) primitives: bool, int, double
A) c-arrays of primitives

#include <vector>
#include <functional>
template<typename R, typename T>
std::function<std::vector<R>(std::vector<T>&)>
ApplyToVec(R(T::*m)()) {
auto applyToEach = [m](std::vector<T> &v) {
std::vector<R> r;
r.reserve(v.size());
for (auto &e : v) {