Problems with CopyTree

Hey

I do have a tree with 34 mil. entries. But with one selection i can reduce the size.
So i tried to use

in a c++ Program to get a part of the tree.
I tried this before in root and it worked. But when i use it in a c++ program I get a segmentation fault.

In RootTalk I found an error what seemed to be similar:
root.cern.ch/root/roottalk/roottalk01/3324.html
and i loaded my vector class at the beginning but nothing changed.
anyone an idea?

best regards
Felix

Please post the shortest possible script reproducing your problem.

Rene


#include <iostream>
#include <rootIncludes.h>

//#include <strstream>
#include <sstream>
using namespace std;

int main (int argc, char **argv)
{

	string inputFileName;
	readArguments(argc,argv,inputFileName);

	// TApplication to visualize data during programm run
	TROOT _MakePad("MakePad", "Display ADC data"); // initialise ROOT
	gROOT->SetStyle("Plain");
	TApplication theApp("App", &argc,argv);
	gStyle->SetOptStat(1110);
	gStyle->SetPalette(1);

	TFile* file = new TFile(inputFileName.c_str());

	gSystem->Load("loadClasses_C");
	TTree *tree = (TTree*)(file->Get("tree"));

	TTree *newTree = tree->CopyTree("QDC_high[4]");
}

rootIncludes.h includes all interesting T*.h files.
gSystem->Load(“loadClasses_C”) load a class with a vector of doubles for the tree-structure.

Problem is that this is not a script, but a part of a c+±programm

HI,

You do not open/create the output file. Thus the CloneTree is attempting to store the new TTree in the input file which is write only (so things will go wrong … even if they did not, you would at be copying the TTree into memory … and then exit the process losing that work).

Cheers,
Philippe.