Skip to content

Instantly share code, notes, and snippets.

@jpata
Last active March 3, 2016 09:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpata/f41cd985153e42ae2dec to your computer and use it in GitHub Desktop.
Save jpata/f41cd985153e42ae2dec to your computer and use it in GitHub Desktop.
//compile as c++ -g `root-config --cflags --libs` CloneTreeCorruption.cc -o CloneTreeCorruption
#include "TFile.h"
#include "TTree.h"
int main(int argc, const char** argv) {
TFile* inf = new TFile("DoubleEG_Run2015D_v4_7_post.root");
TTree* intree = (TTree*)(inf->Get("mt2"));
ULong64_t evt;
intree->SetBranchAddress("evt", &evt);
TFile* outf = new TFile("out.root", "RECREATE");
TTree* outtree = intree->CloneTree(0);
outtree->SetAutoSave(10);
for (int i=0; i<intree->GetEntries(); i++) {
intree->GetEntry(i);
outtree->Fill();
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment