Skip to content

Instantly share code, notes, and snippets.

View dpiparo's full-sized avatar

Danilo Piparo dpiparo

  • CERN
  • Switzerland
View GitHub Profile
@dpiparo
dpiparo / repro3.C
Created July 14, 2020 08:46
Reproduce Memory higher memory usage in 6.20 and 6.22 when reading trees
void memory()
{
ProcInfo_t info;
gSystem->GetProcInfo(&info);
printf(" res memory = %g Mbytes\n",info.fMemResident/1024.);
}
int repro3() {
auto infiles = {
@dpiparo
dpiparo / repro.C
Created July 13, 2020 15:24
Reproduce a memory usageissue present when merging histograms appeared in 6.20
/**
Measured values on lxplus
source /cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.18.00/x86_64-centos7-gcc48-opt/bin/thisroot.sh
6.18 res memory = 1879.34 Mbytes
source /cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.20.00/x86_64-centos7-gcc48-opt/bin/thisroot.sh
6.20 res memory = 2951.23 Mbytes
source /cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.22.00/x86_64-centos7-gcc48-opt/bin/thisroot.sh
@dpiparo
dpiparo / edmraw2simpletree.C
Last active October 4, 2019 10:48
Simple macro to convert to a simple TTree the on disk representation of CMS raw data
#include <vector>
#include <iostream>
#include <TInterpreter.h>
#include <ROOT/RDataFrame.hxx>
// http://opendata.cern.ch/record/63
auto filename = "D66F223A-6A9C-E111-AF57-003048F118D4.root";
class FEDRawData
{
@dpiparo
dpiparo / stdarraytoplevel.C
Last active July 12, 2019 13:58
Support of std::array as top level type for a TTree branch
/**
The idea behind this code is to treat std::array as a C array also for top level
TTree branches. This is achieved with template code and works for nested
std::arrays too.
Only the types which can be put in a leaflist are supported, e.g. no std::array
of classes.
The idea is to intervene on two template methods of TTree:
- `Branch` for writing: when the user inputs the address of a std::array, the
code
automatically creates a branch for a C style array of the size of the array via
@dpiparo
dpiparo / bulkread.C
Last active March 3, 2019 04:02
Try Bulk read using existing ROOT IO low level interface
void write()
{
int n_muon;
float muon_pt[100];
TFile f("f.root", "RECREATE");
TTree t("t","t");
t.Branch("n_muon", &n_muon, "n_muon/I");
t.Branch("muon_pt", muon_pt, "muon_pt[n_muon]/F");
@dpiparo
dpiparo / readComparison.cpp
Last active February 22, 2019 15:39
Benchmark which shows that TTreeReader is as fast as SetBranchAddress when reading
#include "TTreeReader.h"
#include "TTreeReaderArray.h"
#include "TTree.h"
#include "TLeafF.h"
#include "TStopwatch.h"
#include "TFile.h"
#include "ROOT/TSeq.hxx"
#include <ROOT/RDataFrame.hxx>
#include <ROOT/RVec.hxx>
#include <iostream>
/*
This macro demonstrates how to dump columns of fundamental types and vectors
thereof into forest using rdf.
We achieve this using custom actions.
In order to run it: root -b -q rdf2forest.C
WARNING: enrich your LinkDef with these lines
#ifdef __CLING__
#include <TFile.h>
#include <TKey.h>
#include <iostream>
#include <string>
/*
To be ran with ACLIC: root writeSlice.C+
This allows ROOT to build the dictionaries for persistifying the objects. In order