Filtering several files into one file using CloneTree

Hallo,
I try to filter some files and fill them into a new and smaller root file.
I use root_v5.16_slc4 on a linux machine.
My routine is working fine for one file, but when it enters the second file and try to fill the first entry into the new file I get a segmentation fault. I have attached a piece of my code.
Thank you very much for any idea what’s going wrong !

Regards Evelyn

TFile *newfile;
TTree *newtree;
if(tag_filename != "0")
{
	newfile = new TFile(tag_filename, "recreate");
	newfile->cd();
	newtree = dsgNTUP.GetChain()->CloneTree(0);
}

for(int i=0; i<dsgNTUP.GetNEvents(); i++)
//for(int i=0; i<100; i++)
{

//some code to do a selection …
if(TightTauFlag !=1 ) continue;

// new file should be filled

	if(tag_filename != "0")
	{
		newtree->Fill();
		numselevents++;
	}

}



if(tag_filename != "0")
{
	newtree->Print();
	newtree->AutoSave();
	newfile->cd();
	newfile->Close();
	delete newfile;
}

Error message:

*** Break *** segmentation violation
Using host libthread_db library “/lib/tls/i686/cmov/libthread_db.so.1”.
Attaching to program: /proc/1569/exe, process 1569
[Thread debugging using libthread_db enabled]
[New Thread -1247983936 (LWP 1569)]
0xffffe410 in __kernel_vsyscall ()
#1 0xb6133303 in waitpid () from /lib/tls/i686/cmov/libc.so.6
#2 0xb60db669 in strtold_l () from /lib/tls/i686/cmov/libc.so.6
#3 0xb61e2add in system () from /lib/tls/i686/cmov/libpthread.so.0
#4 0xb7a77a2d in TUnixSystem::Exec () from /opt/root_v5.16_slc4/lib/libCore.so
#5 0xb7a7c767 in TUnixSystem::StackTrace ()
from /opt/root_v5.16_slc4/lib/libCore.so
#6 0xb7a7c0ef in TUnixSystem::DispatchSignals ()
from /opt/root_v5.16_slc4/lib/libCore.so
#7 0xb7a7c22d in SigHandler () from /opt/root_v5.16_slc4/lib/libCore.so
#8 0xb7a74d90 in sighandler () from /opt/root_v5.16_slc4/lib/libCore.so
#9
#10 0xb64a677d in std::vector<long, std::allocator >::begin ()
from /afs/physik.uni-freiburg.de/home/schmidt/workspace_new/FrFW/build/lib/libFrFW.so.0
#11 0xb64a9634 in std::vector<long, std::allocator >::size ()
from /afs/physik.uni-freiburg.de/home/schmidt/workspace_new/FrFW/build/lib/libFrFW.so.0
#12 0xb64a9696 in ROOT::TCollectionProxyInfo::Type<std::vector<long, std::allocator > >::size ()
from /afs/physik.uni-freiburg.de/home/schmidt/workspace_new/FrFW/build/lib/libFrFW.so.0
#13 0xb726609e in TGenCollectionStreamer::Streamer ()
from /opt/root_v5.16_slc4/lib/libRIO.so
#14 0xb72444d5 in TCollectionStreamer::Streamer ()
from /opt/root_v5.16_slc4/lib/libRIO.so
#15 0xb7244c74 in TCollectionClassStreamer::operator() ()
from /opt/root_v5.16_slc4/lib/libRIO.so
#16 0xb7a54640 in TClass::Streamer () from /opt/root_v5.16_slc4/lib/libCore.so
#17 0xb723d157 in TBufferFile::WriteFastArray ()
from /opt/root_v5.16_slc4/lib/libRIO.so
#18 0xb72b3c9e in TStreamerInfo::WriteBufferAux<char**> ()
from /opt/root_v5.16_slc4/lib/libRIO.so
#19 0xb6974e9a in TBranchElement::FillLeaves ()
from /opt/root_v5.16_slc4/lib/libTree.so
#20 0xb696f822 in TBranch::Fill () from /opt/root_v5.16_slc4/lib/libTree.so
#21 0xb6973622 in TBranchElement::Fill ()
from /opt/root_v5.16_slc4/lib/libTree.so
#22 0xb69ae982 in TTree::Fill () from /opt/root_v5.16_slc4/lib/libTree.so
#23 0x0805b8c0 in SignalAnalysis::Run ()
#24 0xb63ee367 in TXAnalysisManager::Execute ()
from /afs/physik.uni-freiburg.de/home/schmidt/workspace_new/FrFW/build/lib/libFrFW.so.0
#25 0x08053cd6 in main ()

//some code to do a selection ..... if(TightTauFlag !=1 ) continue; How do you see the address to retrieve the information from the input tree?

Cheers,
Philippe

I am using a local framework to do my analysis - this allows to load different ntuples using the same analysis code.

I get the information from the input tree with the following lines

TXDataConfig cNTUP;

// the NTUP.cfg contains the variables that should be used
cNTUP.LoadFromFile(“NTUP.cfg”);

    TString tag_version = (options.Get("versionname"));   
TString tag_ntuple = (options.Get("ntuplename"));
TString tag_sim = (options.Get("simulationname"));
TString tag_filename = (options.Get("filename"));

TXDataSourceGeneric dsgNTUP(options.Get("treename"), cNTUP);

//Loading the input files
InjectFileSources(dsgNTUP);

//Binding the tau branch
dsgNTUP.Bind("Taus", "Taus", "Taus, " + tag_version + ", " + tag_ntuple +", " + tag_sim);

[quote]I am using a local framework to do my analysis - this allows to load different ntuples using the same analysis code.

//Binding the tau branch
dsgNTUP.Bind(“Taus”, “Taus”, "Taus, " + tag_version + “, " + tag_ntuple +”, " + tag_sim);[/quote]Unfortunately, the problem seems to be in the binding itself. My best guess is that there is std::vector in your data that is not correctly bound to a compiled std::vector (for example it might have been bound to an array of long instead).

So you may have to send this problem to the provider of the local framework and/or send me a complete running example so that I can reproduce the problem.

Cheers,
Philippe