Reading and Writing a Tree

Hi

I am trying to read a Tree and write a pariticular Branch from that Tree into a new Tree. I kept the code simple, but I am not sure what mistake I am making in it. I have here my code and the output that i get. Please suggest. Thanks

Macro

//Macro for writing a branch from oldtree(Told) to a newtree(T)

#include <TH2.h>
#include <TH3.h>
#include <TH1F.h>
#include <TH1.h>
#include <TMath.h>
#include <iostream>
#include <TStyle.h>
#include <TCanvas.h>
#include <TNtuple.h>
#include <TROOT.h>
#include <TChain.h>
#include <TFile.h>
#include <TTree.h>

void test4(){


//gROOT->Reset();

   TFile *oldfile = new TFile("/net/g20/ph/1/hxn075000/DM/Period_K/dataK_0.root");
   TTree *oldtree = (TTree*)oldfile->Get("Told");

   vector<float> *dieltrk_m;  //Branch variable which must be copied to new tree
   Int_t ntt;
   Int_t nevts = 0;
   vector<float> *mass;       //Varibale which gets the value dieltrk_m

   Int_t a = 0;
//   dieltrk_m = 0;
//   mass = 0;

   TBranch        *b_dieltrk_m;
   TBranch        *b_ntt;
   TBranch        *b_mass;

   oldtree->SetBranchAddress("dieltrk_m", &dieltrk_m, &b_dieltrk_m);
   oldtree->SetBranchAddress("ntt", &ntt, &b_ntt);


   //Create a new file and a tree in new file
   TFile *newfile = new TFile("test4.root","recreate");
   TTree *newtree = new TTree("T", "Mytree");

   newtree->Branch("mass", &mass);

   Long64_t nentries = oldtree->GetEntries();
   Long64_t nb = 0;

Printf("Before event loop");

   for(Long64_t i=0;i<nentries;i++) {
     Long64_t ientry = oldtree->LoadTree(i);
     if(ientry<0) break;
     nb += oldtree->GetEntry(i);

     Printf("Before ntt loop");

     for(Int_t j=0;j<ntt;j++) {
        Printf("ntt=%d, j=%d", ntt, j);
        mass[j] = dieltrk_m[j];
        Printf("%f", &dieltrk_m[j]);
        Printf("%f", (*mass)[j]);
        }
   }


   newtree->Fill();
   newtree->Print();
   newfile->Write();

Printf("%d", nentries);

Output


root [0] .x test4.C
Note: File "iostream" already loaded
Before event loop
Before ntt loop
Before ntt loop
.
.(loop continues) 
.
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
ntt=1, j=0
21.088118
21.088118
Before ntt loop
Before ntt loop
.
.(loop continues)
.
Before ntt loop
Before ntt loop
Before ntt loop
ntt=6, j=0
0.361594
0.361594
ntt=6, j=1
Error: Symbol #include is not defined in current scope  test4.C:77:
Error: Symbol exception is not defined in current scope  test4.C:77:
Syntax Error: #include <exception> test4.C:77:
Error: Symbol G__exception is not defined in current scope  test4.C:77:
Error: type G__exception not defined FILE:/net/g20/ph/1/hxn075000/DM/Period_K/./test4.C LINE:77
*** Interpreter error recovered ***
   delete oldfile;
   delete newfile;
}

Try to re-run your macro with CINT’s “exception catching” switched on and as ACLiC-compiled:
root [0] .except
root [1] .x test4.C++

Hi Pepe,

I tried, this is the output

root [1] .except
G__catchexception=1
root [2] .x test4.C++
Info in <TUnixSystem::ACLiC>: creating shared library /net/g20/ph/1/hxn075000/DM/Period_K/./test4_C.so
/net/g20/ph/1/hxn075000/DM/Period_K/./test4.C: In function ‘void test4()’:
/net/g20/ph/1/hxn075000/DM/Period_K/./test4.C:39: warning: unused variable ‘b_mass’
Before event loop
Before ntt loop
Before ntt loop
Before ntt loop
.
. (loop continues)
.
Before ntt loop
Before ntt loop
Before ntt loop
ntt=1, j=0

 *** Break *** segmentation violation



===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
#0  0x0000003d6829a4d5 in waitpid () from /lib64/libc.so.6
#1  0x0000003d6823c481 in do_system () from /lib64/libc.so.6
#2  0x00002b52578edda9 in TUnixSystem::StackTrace() () from /net/g20/ph/1/kxr091000/root/lib/libCore.so
#3  0x00002b52578eb9c3 in TUnixSystem::DispatchSignals(ESignals) () from /net/g20/ph/1/kxr091000/root/lib/libCore.so
#4  <signal handler called>
#5  0x0000003d6827ad17 in memmove () from /lib64/libc.so.6
#6  0x00002b525acc3137 in float* std::__copy<true, std::random_access_iterator_tag>::copy<float>(float const*, float const*, float*) ()
   from /net/g20/ph/1/kxr091000/root/cint/cint/stl/vector.dll
#7  0x00002b525acc3f8f in float* std::__copy_aux<float const*, float*>(float const*, float const*, float*) ()
   from /net/g20/ph/1/kxr091000/root/cint/cint/stl/vector.dll
#8  0x00002b525acc40ca in __gnu_cxx::__normal_iterator<float*, std::vector<float, std::allocator<float> > > std::__copy_normal<true, true>::copy_n<__gnu_cxx::__normal_iterator<float const*, std::vector<float, std::allocator<float> > >, __gnu_cxx::__normal_iterator<float*, std::vector<float, std::allocator<float> > > >(__gnu_cxx::__normal_iterator<float const*, std::vector<float, std::allocator<float> > >, __gnu_cxx::__normal_iterator<float const*, std::vector<float, std::allocator<float> > >, __gnu_cxx::__normal_iterator<float*, std::vector<float, std::allocator<float> > >) ()
   from /net/g20/ph/1/kxr091000/root/cint/cint/stl/vector.dll
#9  0x00002b525acc4115 in __gnu_cxx::__normal_iterator<float*, std::vector<float, std::allocator<float> > > std::copy<__gnu_cxx::__normal_iterator<float const*, std::vector<float, std::allocator<float> > >, __gnu_cxx::__normal_iterator<float*, std::vector<float, std::allocator<float> > > >(__gnu_cxx::__normal_iterator<float const*, std::vector<float, std::allocator<float> > >, __gnu_cxx::__normal_iterator<float const*, std::vector<float, std::allocator<float> > >, __gnu_cxx::__normal_iterator<float*, std::vector<float, std::allocator<float> > >) ()
   from /net/g20/ph/1/kxr091000/root/cint/cint/stl/vector.dll
#10 0x00002b525acd69e5 in std::vector<float, std::allocator<float> >::operator=(std::vector<float, std::allocator<float> > const&) ()
   from /net/g20/ph/1/kxr091000/root/cint/cint/stl/vector.dll
#11 0x00002b525e405470 in test4() () from /net/g20/ph/1/hxn075000/DM/Period_K/./test4_C.so
#12 0x00002b525e4055a9 in G__test4_C_ACLiC_dict__0_1668(G__value*, char const*, G__param*, int) ()
   from /net/g20/ph/1/hxn075000/DM/Period_K/./test4_C.so
#13 0x00002b52580f1f5a in Cint::G__ExceptionWrapper(int (*)(G__value*, char const*, G__param*, int), G__value*, char*, G__param*, int) ()
   from /net/g20/ph/1/kxr091000/root/lib/libCint.so
#14 0x00002b525819e460 in G__execute_call () from /net/g20/ph/1/kxr091000/root/lib/libCint.so
#15 0x00002b52581a06e9 in G__call_cppfunc () from /net/g20/ph/1/kxr091000/root/lib/libCint.so
#16 0x00002b525817a5fe in G__interpret_func () from /net/g20/ph/1/kxr091000/root/lib/libCint.so
#17 0x00002b5258167e54 in G__getfunction () from /net/g20/ph/1/kxr091000/root/lib/libCint.so
#18 0x00002b525813d2d4 in G__getitem () from /net/g20/ph/1/kxr091000/root/lib/libCint.so
#19 0x00002b52581483c2 in G__getexpr () from /net/g20/ph/1/kxr091000/root/lib/libCint.so
#20 0x00002b525814f7d0 in G__calc_internal () from /net/g20/ph/1/kxr091000/root/lib/libCint.so
#21 0x00002b52581db91c in G__process_cmd () from /net/g20/ph/1/kxr091000/root/lib/libCint.so
#22 0x00002b52578d7397 in TCint::ProcessLine(char const*, TInterpreter::EErrorCode*) () from /net/g20/ph/1/kxr091000/root/lib/libCore.so
#23 0x00002b52578dc403 in TCint::ProcessLineSynch(char const*, TInterpreter::EErrorCode*) () from /net/g20/ph/1/kxr091000/root/lib/libCore.so
#24 0x00002b5257816461 in TApplication::ExecuteFile(char const*, int*, bool) () from /net/g20/ph/1/kxr091000/root/lib/libCore.so
#25 0x00002b525781421b in TApplication::ProcessLine(char const*, bool, int*) () from /net/g20/ph/1/kxr091000/root/lib/libCore.so
#26 0x00002b5258e58213 in TRint::HandleTermInput() () from /net/g20/ph/1/kxr091000/root/lib/libRint.so
#27 0x00002b5258e56c57 in TTermInputHandler::Notify() () from /net/g20/ph/1/kxr091000/root/lib/libRint.so
#28 0x00002b5258e5928d in TTermInputHandler::ReadNotify() () from /net/g20/ph/1/kxr091000/root/lib/libRint.so
#29 0x00002b52578ead43 in TUnixSystem::CheckDescriptors() () from /net/g20/ph/1/kxr091000/root/lib/libCore.so
#30 0x00002b52578eb3ec in TUnixSystem::DispatchOneEvent(bool) () from /net/g20/ph/1/kxr091000/root/lib/libCore.so
#31 0x00002b525786a316 in TSystem::InnerLoop() () from /net/g20/ph/1/kxr091000/root/lib/libCore.so
#32 0x00002b525786d181 in TSystem::Run() () from /net/g20/ph/1/kxr091000/root/lib/libCore.so
#33 0x00002b52578127df in TApplication::Run(bool) () from /net/g20/ph/1/kxr091000/root/lib/libCore.so
#34 0x00002b5258e58e80 in TRint::Run(bool) () from /net/g20/ph/1/kxr091000/root/lib/libRint.so
#35 0x000000000040100d in main ()
===========================================================


The lines below might hint at the cause of the crash.
If they do not help you then please submit a bug report at
http://root.cern.ch/bugs. Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.
===========================================================
#5  0x0000003d6827ad17 in memmove () from /lib64/libc.so.6
#6  0x00002b525acc3137 in float* std::__copy<true, std::random_access_iterator_tag>::copy<float>(float const*, float const*, float*) ()
   from /net/g20/ph/1/kxr091000/root/cint/cint/stl/vector.dll
#7  0x00002b525acc3f8f in float* std::__copy_aux<float const*, float*>(float const*, float const*, float*) ()
   from /net/g20/ph/1/kxr091000/root/cint/cint/stl/vector.dll
#8  0x00002b525acc40ca in __gnu_cxx::__normal_iterator<float*, std::vector<float, std::allocator<float> > > std::__copy_normal<true, true>::copy_n<__gnu_cxx::__normal_iterator<float const*, std::vector<float, std::allocator<float> > >, __gnu_cxx::__normal_iterator<float*, std::vector<float, std::allocator<float> > > >(__gnu_cxx::__normal_iterator<float const*, std::vector<float, std::allocator<float> > >, __gnu_cxx::__normal_iterator<float const*, std::vector<float, std::allocator<float> > >, __gnu_cxx::__normal_iterator<float*, std::vector<float, std::allocator<float> > >) ()
   from /net/g20/ph/1/kxr091000/root/cint/cint/stl/vector.dll
#9  0x00002b525acc4115 in __gnu_cxx::__normal_iterator<float*, std::vector<float, std::allocator<float> > > std::copy<__gnu_cxx::__normal_iterator<float const*, std::vector<float, std::allocator<float> > >, __gnu_cxx::__normal_iterator<float*, std::vector<float, std::allocator<float> > > >(__gnu_cxx::__normal_iterator<float const*, std::vector<float, std::allocator<float> > >, __gnu_cxx::__normal_iterator<float const*, std::vector<float, std::allocator<float> > >, __gnu_cxx::__normal_iterator<float*, std::vector<float, std::allocator<float> > >) ()
   from /net/g20/ph/1/kxr091000/root/cint/cint/stl/vector.dll
#10 0x00002b525acd69e5 in std::vector<float, std::allocator<float> >::operator=(std::vector<float, std::allocator<float> > const&) ()
   from /net/g20/ph/1/kxr091000/root/cint/cint/stl/vector.dll
#11 0x00002b525e405470 in test4() () from /net/g20/ph/1/hxn075000/DM/Period_K/./test4_C.so
===========================================================

Hi,

vector<float> *dieltrk_m; //Branch variable which must be copied to new tree Int_t ntt; Int_t nevts = 0; vector<float> *mass; //Varibale which gets the value dieltrk_mNote that you must initialize the pointer to 0: vector<float> *dieltrk_m = 0; //Branch variable which must be copied to new tree Int_t ntt; Int_t nevts = 0; vector<float> *mass = 0; //Varibale which gets the value dieltrk_motherwise your code will not work.

Cheers,
Philippe.

Hi,

I am getting the same output as i posted in my first post

Before ntt loop
Before ntt loop
Before ntt loop
ntt=6, j=0
0.361594
0.361594
ntt=6, j=1  <--------
Error: Symbol #include is not defined in current scope  test4.C:77:
Error: Symbol exception is not defined in current scope  test4.C:77:
Syntax Error: #include <exception> test4.C:77:
Error: Symbol G__exception is not defined in current scope  test4.C:77:
Error: type G__exception not defined FILE:/net/g20/ph/1/hxn075000/DM/Period_K/./test4.C LINE:77
*** Interpreter error recovered ***

The macro somehow works for first loop within ‘ntt’, during the second loop of ‘ntt’ it is giving that error!!?!? (Please note my arrow in the output). Am i correct? or is there any big mistake the logic of the macro itself?

Hi,

The macro looks okay … but this is a bit dependent on the content of the TTree.

I recommend that you run the following:valgrind root.exe -b -l -q test4.C+which should pinpoint the issue.

Cheers,
Philippe.

Hi

Here is the output for the command

==18138== Command: root.exe -b -l -q test4.C++
==18138== 
root [0] 
Processing test4.C++...
Info in <TUnixSystem::ACLiC>: creating shared library /net/g20/ph/1/hxn075000/DM/Period_K/./test4_C.so
/net/g20/ph/1/hxn075000/DM/Period_K/./test4.C: In function ‘void test4()’:
/net/g20/ph/1/hxn075000/DM/Period_K/./test4.C:39: warning: unused variable ‘b_mass’
Before event loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
ntt=1, j=0
21.088118
21.088118
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
ntt=6, j=0
0.361594
0.361594
ntt=6, j=1
==18138== Invalid read of size 8
==18138==    at 0x9E3B23E: std::vector<float, std::allocator<float> >::begin() const (in /net/g20/ph/1/kxr091000/root/cint/cint/stl/vector.dll)
==18138==    by 0x9E4B410: std::vector<float, std::allocator<float> >::size() const (in /net/g20/ph/1/kxr091000/root/cint/cint/stl/vector.dll)
==18138==    by 0x9E748C7: std::vector<float, std::allocator<float> >::operator=(std::vector<float, std::allocator<float> > const&) (in /net/g20/ph/1/kxr091000/root/cint/cint/stl/vector.dll)
==18138==    by 0xC66446D: test4() (in /net/g20/ph/1/hxn075000/DM/Period_K/test4_C.so)
==18138==    by 0xC6645A8: G__test4_C_ACLiC_dict__0_1668(G__value*, char const*, G__param*, int) (in /net/g20/ph/1/hxn075000/DM/Period_K/test4_C.so)
==18138==    by 0x5695F59: Cint::G__ExceptionWrapper(int (*)(G__value*, char const*, G__param*, int), G__value*, char*, G__param*, int) (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x574245F: G__execute_call (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x57446E8: G__call_cppfunc (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x571E5FD: G__interpret_func (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x570BE53: G__getfunction (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x56E12D3: G__getitem (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x56EC3C1: G__getexpr (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==  Address 0x8459168 is 0 bytes after a block of size 24 alloc'd
==18138==    at 0x4A0695E: operator new(unsigned long) (vg_replace_malloc.c:220)
==18138==    by 0xA4E1D71: ROOT::new_vectorlEfloatgR(void*) (in /net/g20/ph/1/kxr091000/root/lib/libvectorDict.so)
==18138==    by 0x4E4EEAB: TClass::New(TClass::ENewType) const (in /net/g20/ph/1/kxr091000/root/lib/libCore.so)
==18138==    by 0xBBB3F62: TBranchElement::SetAddress(void*) (in /net/g20/ph/1/kxr091000/root/lib/libTree.so)
==18138==    by 0xBBFA64A: TTree::SetBranchAddress(char const*, void*, TBranch**) (in /net/g20/ph/1/kxr091000/root/lib/libTree.so)
==18138==    by 0xBBF14F1: TTree::SetBranchAddress(char const*, void*, TBranch**, TClass*, EDataType, bool) (in /net/g20/ph/1/kxr091000/root/lib/libTree.so)
==18138==    by 0xC664296: test4() (in /net/g20/ph/1/hxn075000/DM/Period_K/test4_C.so)
==18138==    by 0xC6645A8: G__test4_C_ACLiC_dict__0_1668(G__value*, char const*, G__param*, int) (in /net/g20/ph/1/hxn075000/DM/Period_K/test4_C.so)
==18138==    by 0x5695F59: Cint::G__ExceptionWrapper(int (*)(G__value*, char const*, G__param*, int), G__value*, char*, G__param*, int) (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x574245F: G__execute_call (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x57446E8: G__call_cppfunc (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x571E5FD: G__interpret_func (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138== 
==18138== Invalid read of size 8
==18138==    at 0x9E3B268: std::vector<float, std::allocator<float> >::end() const (in /net/g20/ph/1/kxr091000/root/cint/cint/stl/vector.dll)
==18138==    by 0x9E4B41D: std::vector<float, std::allocator<float> >::size() const (in /net/g20/ph/1/kxr091000/root/cint/cint/stl/vector.dll)
==18138==    by 0x9E748C7: std::vector<float, std::allocator<float> >::operator=(std::vector<float, std::allocator<float> > const&) (in /net/g20/ph/1/kxr091000/root/cint/cint/stl/vector.dll)
==18138==    by 0xC66446D: test4() (in /net/g20/ph/1/hxn075000/DM/Period_K/test4_C.so)
==18138==    by 0xC6645A8: G__test4_C_ACLiC_dict__0_1668(G__value*, char const*, G__param*, int) (in /net/g20/ph/1/hxn075000/DM/Period_K/test4_C.so)
==18138==    by 0x5695F59: Cint::G__ExceptionWrapper(int (*)(G__value*, char const*, G__param*, int), G__value*, char*, G__param*, int) (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x574245F: G__execute_call (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x57446E8: G__call_cppfunc (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x571E5FD: G__interpret_func (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x570BE53: G__getfunction (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x56E12D3: G__getitem (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x56EC3C1: G__getexpr (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==  Address 0x8459170 is 8 bytes after a block of size 24 alloc'd
==18138==    at 0x4A0695E: operator new(unsigned long) (vg_replace_malloc.c:220)
==18138==    by 0xA4E1D71: ROOT::new_vectorlEfloatgR(void*) (in /net/g20/ph/1/kxr091000/root/lib/libvectorDict.so)
==18138==    by 0x4E4EEAB: TClass::New(TClass::ENewType) const (in /net/g20/ph/1/kxr091000/root/lib/libCore.so)
==18138==    by 0xBBB3F62: TBranchElement::SetAddress(void*) (in /net/g20/ph/1/kxr091000/root/lib/libTree.so)
==18138==    by 0xBBFA64A: TTree::SetBranchAddress(char const*, void*, TBranch**) (in /net/g20/ph/1/kxr091000/root/lib/libTree.so)
==18138==    by 0xBBF14F1: TTree::SetBranchAddress(char const*, void*, TBranch**, TClass*, EDataType, bool) (in /net/g20/ph/1/kxr091000/root/lib/libTree.so)
==18138==    by 0xC664296: test4() (in /net/g20/ph/1/hxn075000/DM/Period_K/test4_C.so)
==18138==    by 0xC6645A8: G__test4_C_ACLiC_dict__0_1668(G__value*, char const*, G__param*, int) (in /net/g20/ph/1/hxn075000/DM/Period_K/test4_C.so)
==18138==    by 0x5695F59: Cint::G__ExceptionWrapper(int (*)(G__value*, char const*, G__param*, int), G__value*, char*, G__param*, int) (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x574245F: G__execute_call (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x57446E8: G__call_cppfunc (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x571E5FD: G__interpret_func (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138== 
==18138== Invalid read of size 8
==18138==    at 0x9E3B23E: std::vector<float, std::allocator<float> >::begin() const (in /net/g20/ph/1/kxr091000/root/cint/cint/stl/vector.dll)
==18138==    by 0x9E4B446: std::vector<float, std::allocator<float> >::capacity() const (in /net/g20/ph/1/kxr091000/root/cint/cint/stl/vector.dll)
==18138==    by 0x9E748D4: std::vector<float, std::allocator<float> >::operator=(std::vector<float, std::allocator<float> > const&) (in /net/g20/ph/1/kxr091000/root/cint/cint/stl/vector.dll)
==18138==    by 0xC66446D: test4() (in /net/g20/ph/1/hxn075000/DM/Period_K/test4_C.so)
==18138==    by 0xC6645A8: G__test4_C_ACLiC_dict__0_1668(G__value*, char const*, G__param*, int) (in /net/g20/ph/1/hxn075000/DM/Period_K/test4_C.so)
==18138==    by 0x5695F59: Cint::G__ExceptionWrapper(int (*)(G__value*, char const*, G__param*, int), G__value*, char*, G__param*, int) (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x574245F: G__execute_call (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x57446E8: G__call_cppfunc (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x571E5FD: G__interpret_func (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x570BE53: G__getfunction (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x56E12D3: G__getitem (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x56EC3C1: G__getexpr (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==  Address 0x7d1bb98 is 0 bytes after a block of size 24 alloc'd
==18138==    at 0x4A0695E: operator new(unsigned long) (vg_replace_malloc.c:220)
==18138==    by 0xA4E1D71: ROOT::new_vectorlEfloatgR(void*) (in /net/g20/ph/1/kxr091000/root/lib/libvectorDict.so)
==18138==    by 0x4E4EEAB: TClass::New(TClass::ENewType) const (in /net/g20/ph/1/kxr091000/root/lib/libCore.so)
==18138==    by 0xBBB3F62: TBranchElement::SetAddress(void*) (in /net/g20/ph/1/kxr091000/root/lib/libTree.so)
==18138==    by 0xBBFB8C9: TTree::BronchExec(char const*, char const*, void*, bool, int, int) (in /net/g20/ph/1/kxr091000/root/lib/libTree.so)
==18138==    by 0xBBF0FF9: TTree::Bronch(char const*, char const*, void*, int, int) (in /net/g20/ph/1/kxr091000/root/lib/libTree.so)
==18138==    by 0xC6643C2: test4() (in /net/g20/ph/1/hxn075000/DM/Period_K/test4_C.so)
==18138==    by 0xC6645A8: G__test4_C_ACLiC_dict__0_1668(G__value*, char const*, G__param*, int) (in /net/g20/ph/1/hxn075000/DM/Period_K/test4_C.so)
==18138==    by 0x5695F59: Cint::G__ExceptionWrapper(int (*)(G__value*, char const*, G__param*, int), G__value*, char*, G__param*, int) (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x574245F: G__execute_call (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x57446E8: G__call_cppfunc (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x571E5FD: G__interpret_func (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138== 
==18138== Invalid read of size 8
==18138==    at 0x9E4B44F: std::vector<float, std::allocator<float> >::capacity() const (in /net/g20/ph/1/kxr091000/root/cint/cint/stl/vector.dll)
==18138==    by 0x9E748D4: std::vector<float, std::allocator<float> >::operator=(std::vector<float, std::allocator<float> > const&) (in /net/g20/ph/1/kxr091000/root/cint/cint/stl/vector.dll)
==18138==    by 0xC66446D: test4() (in /net/g20/ph/1/hxn075000/DM/Period_K/test4_C.so)
==18138==    by 0xC6645A8: G__test4_C_ACLiC_dict__0_1668(G__value*, char const*, G__param*, int) (in /net/g20/ph/1/hxn075000/DM/Period_K/test4_C.so)
==18138==    by 0x5695F59: Cint::G__ExceptionWrapper(int (*)(G__value*, char const*, G__param*, int), G__value*, char*, G__param*, int) (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x574245F: G__execute_call (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x57446E8: G__call_cppfunc (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x571E5FD: G__interpret_func (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x570BE53: G__getfunction (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x56E12D3: G__getitem (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x56EC3C1: G__getexpr (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x56F37CF: G__calc_internal (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==  Address 0x7d1bba8 is not stack'd, malloc'd or (recently) free'd
==18138== 
==18138== Invalid read of size 8
==18138==    at 0x9E3B23E: std::vector<float, std::allocator<float> >::begin() const (in /net/g20/ph/1/kxr091000/root/cint/cint/stl/vector.dll)
==18138==    by 0x9E4B410: std::vector<float, std::allocator<float> >::size() const (in /net/g20/ph/1/kxr091000/root/cint/cint/stl/vector.dll)
==18138==    by 0x9E749AA: std::vector<float, std::allocator<float> >::operator=(std::vector<float, std::allocator<float> > const&) (in /net/g20/ph/1/kxr091000/root/cint/cint/stl/vector.dll)
==18138==    by 0xC66446D: test4() (in /net/g20/ph/1/hxn075000/DM/Period_K/test4_C.so)
==18138==    by 0xC6645A8: G__test4_C_ACLiC_dict__0_1668(G__value*, char const*, G__param*, int) (in /net/g20/ph/1/hxn075000/DM/Period_K/test4_C.so)
==18138==    by 0x5695F59: Cint::G__ExceptionWrapper(int (*)(G__value*, char const*, G__param*, int), G__value*, char*, G__param*, int) (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x574245F: G__execute_call (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x57446E8: G__call_cppfunc (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x571E5FD: G__interpret_func (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x570BE53: G__getfunction (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x56E12D3: G__getitem (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x56EC3C1: G__getexpr (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==  Address 0x7d1bb98 is 0 bytes after a block of size 24 alloc'd
==18138==    at 0x4A0695E: operator new(unsigned long) (vg_replace_malloc.c:220)
==18138==    by 0xA4E1D71: ROOT::new_vectorlEfloatgR(void*) (in /net/g20/ph/1/kxr091000/root/lib/libvectorDict.so)
==18138==    by 0x4E4EEAB: TClass::New(TClass::ENewType) const (in /net/g20/ph/1/kxr091000/root/lib/libCore.so)
==18138==    by 0xBBB3F62: TBranchElement::SetAddress(void*) (in /net/g20/ph/1/kxr091000/root/lib/libTree.so)
==18138==    by 0xBBFB8C9: TTree::BronchExec(char const*, char const*, void*, bool, int, int) (in /net/g20/ph/1/kxr091000/root/lib/libTree.so)
==18138==    by 0xBBF0FF9: TTree::Bronch(char const*, char const*, void*, int, int) (in /net/g20/ph/1/kxr091000/root/lib/libTree.so)
==18138==    by 0xC6643C2: test4() (in /net/g20/ph/1/hxn075000/DM/Period_K/test4_C.so)
==18138==    by 0xC6645A8: G__test4_C_ACLiC_dict__0_1668(G__value*, char const*, G__param*, int) (in /net/g20/ph/1/hxn075000/DM/Period_K/test4_C.so)
==18138==    by 0x5695F59: Cint::G__ExceptionWrapper(int (*)(G__value*, char const*, G__param*, int), G__value*, char*, G__param*, int) (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x574245F: G__execute_call (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x57446E8: G__call_cppfunc (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x571E5FD: G__interpret_func (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138== 
==18138== Invalid read of size 8
==18138==    at 0x9E3B268: std::vector<float, std::allocator<float> >::end() const (in /net/g20/ph/1/kxr091000/root/cint/cint/stl/vector.dll)
==18138==    by 0x9E4B41D: std::vector<float, std::allocator<float> >::size() const (in /net/g20/ph/1/kxr091000/root/cint/cint/stl/vector.dll)
==18138==    by 0x9E749AA: std::vector<float, std::allocator<float> >::operator=(std::vector<float, std::allocator<float> > const&) (in /net/g20/ph/1/kxr091000/root/cint/cint/stl/vector.dll)
==18138==    by 0xC66446D: test4() (in /net/g20/ph/1/hxn075000/DM/Period_K/test4_C.so)
==18138==    by 0xC6645A8: G__test4_C_ACLiC_dict__0_1668(G__value*, char const*, G__param*, int) (in /net/g20/ph/1/hxn075000/DM/Period_K/test4_C.so)
==18138==    by 0x5695F59: Cint::G__ExceptionWrapper(int (*)(G__value*, char const*, G__param*, int), G__value*, char*, G__param*, int) (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x574245F: G__execute_call (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x57446E8: G__call_cppfunc (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x571E5FD: G__interpret_func (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x570BE53: G__getfunction (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x56E12D3: G__getitem (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x56EC3C1: G__getexpr (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==  Address 0x7d1bba0 is 8 bytes after a block of size 24 alloc'd
==18138==    at 0x4A0695E: operator new(unsigned long) (vg_replace_malloc.c:220)
==18138==    by 0xA4E1D71: ROOT::new_vectorlEfloatgR(void*) (in /net/g20/ph/1/kxr091000/root/lib/libvectorDict.so)
==18138==    by 0x4E4EEAB: TClass::New(TClass::ENewType) const (in /net/g20/ph/1/kxr091000/root/lib/libCore.so)
==18138==    by 0xBBB3F62: TBranchElement::SetAddress(void*) (in /net/g20/ph/1/kxr091000/root/lib/libTree.so)
==18138==    by 0xBBFB8C9: TTree::BronchExec(char const*, char const*, void*, bool, int, int) (in /net/g20/ph/1/kxr091000/root/lib/libTree.so)
==18138==    by 0xBBF0FF9: TTree::Bronch(char const*, char const*, void*, int, int) (in /net/g20/ph/1/kxr091000/root/lib/libTree.so)
==18138==    by 0xC6643C2: test4() (in /net/g20/ph/1/hxn075000/DM/Period_K/test4_C.so)
==18138==    by 0xC6645A8: G__test4_C_ACLiC_dict__0_1668(G__value*, char const*, G__param*, int) (in /net/g20/ph/1/hxn075000/DM/Period_K/test4_C.so)
==18138==    by 0x5695F59: Cint::G__ExceptionWrapper(int (*)(G__value*, char const*, G__param*, int), G__value*, char*, G__param*, int) (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x574245F: G__execute_call (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x57446E8: G__call_cppfunc (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x571E5FD: G__interpret_func (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138== 
==18138== Invalid read of size 8
==18138==    at 0x9E306A8: __gnu_cxx::__normal_iterator<float*, std::vector<float, std::allocator<float> > >::__normal_iterator(float* const&) (in /net/g20/ph/1/kxr091000/root/cint/cint/stl/vector.dll)
==18138==    by 0x9E306F0: std::vector<float, std::allocator<float> >::begin() (in /net/g20/ph/1/kxr091000/root/cint/cint/stl/vector.dll)
==18138==    by 0x9E749BE: std::vector<float, std::allocator<float> >::operator=(std::vector<float, std::allocator<float> > const&) (in /net/g20/ph/1/kxr091000/root/cint/cint/stl/vector.dll)
==18138==    by 0xC66446D: test4() (in /net/g20/ph/1/hxn075000/DM/Period_K/test4_C.so)
==18138==    by 0xC6645A8: G__test4_C_ACLiC_dict__0_1668(G__value*, char const*, G__param*, int) (in /net/g20/ph/1/hxn075000/DM/Period_K/test4_C.so)
==18138==    by 0x5695F59: Cint::G__ExceptionWrapper(int (*)(G__value*, char const*, G__param*, int), G__value*, char*, G__param*, int) (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x574245F: G__execute_call (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x57446E8: G__call_cppfunc (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x571E5FD: G__interpret_func (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x570BE53: G__getfunction (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x56E12D3: G__getitem (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x56EC3C1: G__getexpr (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==  Address 0x7d1bb98 is 0 bytes after a block of size 24 alloc'd
==18138==    at 0x4A0695E: operator new(unsigned long) (vg_replace_malloc.c:220)
==18138==    by 0xA4E1D71: ROOT::new_vectorlEfloatgR(void*) (in /net/g20/ph/1/kxr091000/root/lib/libvectorDict.so)
==18138==    by 0x4E4EEAB: TClass::New(TClass::ENewType) const (in /net/g20/ph/1/kxr091000/root/lib/libCore.so)
==18138==    by 0xBBB3F62: TBranchElement::SetAddress(void*) (in /net/g20/ph/1/kxr091000/root/lib/libTree.so)
==18138==    by 0xBBFB8C9: TTree::BronchExec(char const*, char const*, void*, bool, int, int) (in /net/g20/ph/1/kxr091000/root/lib/libTree.so)
==18138==    by 0xBBF0FF9: TTree::Bronch(char const*, char const*, void*, int, int) (in /net/g20/ph/1/kxr091000/root/lib/libTree.so)
==18138==    by 0xC6643C2: test4() (in /net/g20/ph/1/hxn075000/DM/Period_K/test4_C.so)
==18138==    by 0xC6645A8: G__test4_C_ACLiC_dict__0_1668(G__value*, char const*, G__param*, int) (in /net/g20/ph/1/hxn075000/DM/Period_K/test4_C.so)
==18138==    by 0x5695F59: Cint::G__ExceptionWrapper(int (*)(G__value*, char const*, G__param*, int), G__value*, char*, G__param*, int) (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x574245F: G__execute_call (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x57446E8: G__call_cppfunc (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x571E5FD: G__interpret_func (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138== 
==18138== Invalid read of size 8
==18138==    at 0x9E3B268: std::vector<float, std::allocator<float> >::end() const (in /net/g20/ph/1/kxr091000/root/cint/cint/stl/vector.dll)
==18138==    by 0x9E749CA: std::vector<float, std::allocator<float> >::operator=(std::vector<float, std::allocator<float> > const&) (in /net/g20/ph/1/kxr091000/root/cint/cint/stl/vector.dll)
==18138==    by 0xC66446D: test4() (in /net/g20/ph/1/hxn075000/DM/Period_K/test4_C.so)
==18138==    by 0xC6645A8: G__test4_C_ACLiC_dict__0_1668(G__value*, char const*, G__param*, int) (in /net/g20/ph/1/hxn075000/DM/Period_K/test4_C.so)
==18138==    by 0x5695F59: Cint::G__ExceptionWrapper(int (*)(G__value*, char const*, G__param*, int), G__value*, char*, G__param*, int) (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x574245F: G__execute_call (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x57446E8: G__call_cppfunc (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x571E5FD: G__interpret_func (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x570BE53: G__getfunction (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x56E12D3: G__getitem (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x56EC3C1: G__getexpr (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x56F37CF: G__calc_internal (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==  Address 0x8459170 is 8 bytes after a block of size 24 alloc'd
==18138==    at 0x4A0695E: operator new(unsigned long) (vg_replace_malloc.c:220)
==18138==    by 0xA4E1D71: ROOT::new_vectorlEfloatgR(void*) (in /net/g20/ph/1/kxr091000/root/lib/libvectorDict.so)
==18138==    by 0x4E4EEAB: TClass::New(TClass::ENewType) const (in /net/g20/ph/1/kxr091000/root/lib/libCore.so)
==18138==    by 0xBBB3F62: TBranchElement::SetAddress(void*) (in /net/g20/ph/1/kxr091000/root/lib/libTree.so)
==18138==    by 0xBBFA64A: TTree::SetBranchAddress(char const*, void*, TBranch**) (in /net/g20/ph/1/kxr091000/root/lib/libTree.so)
==18138==    by 0xBBF14F1: TTree::SetBranchAddress(char const*, void*, TBranch**, TClass*, EDataType, bool) (in /net/g20/ph/1/kxr091000/root/lib/libTree.so)
==18138==    by 0xC664296: test4() (in /net/g20/ph/1/hxn075000/DM/Period_K/test4_C.so)
==18138==    by 0xC6645A8: G__test4_C_ACLiC_dict__0_1668(G__value*, char const*, G__param*, int) (in /net/g20/ph/1/hxn075000/DM/Period_K/test4_C.so)
==18138==    by 0x5695F59: Cint::G__ExceptionWrapper(int (*)(G__value*, char const*, G__param*, int), G__value*, char*, G__param*, int) (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x574245F: G__execute_call (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x57446E8: G__call_cppfunc (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x571E5FD: G__interpret_func (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138== 
==18138== Invalid read of size 8
==18138==    at 0x9E3B23E: std::vector<float, std::allocator<float> >::begin() const (in /net/g20/ph/1/kxr091000/root/cint/cint/stl/vector.dll)
==18138==    by 0x9E749D6: std::vector<float, std::allocator<float> >::operator=(std::vector<float, std::allocator<float> > const&) (in /net/g20/ph/1/kxr091000/root/cint/cint/stl/vector.dll)
==18138==    by 0xC66446D: test4() (in /net/g20/ph/1/hxn075000/DM/Period_K/test4_C.so)
==18138==    by 0xC6645A8: G__test4_C_ACLiC_dict__0_1668(G__value*, char const*, G__param*, int) (in /net/g20/ph/1/hxn075000/DM/Period_K/test4_C.so)
==18138==    by 0x5695F59: Cint::G__ExceptionWrapper(int (*)(G__value*, char const*, G__param*, int), G__value*, char*, G__param*, int) (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x574245F: G__execute_call (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x57446E8: G__call_cppfunc (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x571E5FD: G__interpret_func (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x570BE53: G__getfunction (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x56E12D3: G__getitem (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x56EC3C1: G__getexpr (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x56F37CF: G__calc_internal (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==  Address 0x8459168 is 0 bytes after a block of size 24 alloc'd
==18138==    at 0x4A0695E: operator new(unsigned long) (vg_replace_malloc.c:220)
==18138==    by 0xA4E1D71: ROOT::new_vectorlEfloatgR(void*) (in /net/g20/ph/1/kxr091000/root/lib/libvectorDict.so)
==18138==    by 0x4E4EEAB: TClass::New(TClass::ENewType) const (in /net/g20/ph/1/kxr091000/root/lib/libCore.so)
==18138==    by 0xBBB3F62: TBranchElement::SetAddress(void*) (in /net/g20/ph/1/kxr091000/root/lib/libTree.so)
==18138==    by 0xBBFA64A: TTree::SetBranchAddress(char const*, void*, TBranch**) (in /net/g20/ph/1/kxr091000/root/lib/libTree.so)
==18138==    by 0xBBF14F1: TTree::SetBranchAddress(char const*, void*, TBranch**, TClass*, EDataType, bool) (in /net/g20/ph/1/kxr091000/root/lib/libTree.so)
==18138==    by 0xC664296: test4() (in /net/g20/ph/1/hxn075000/DM/Period_K/test4_C.so)
==18138==    by 0xC6645A8: G__test4_C_ACLiC_dict__0_1668(G__value*, char const*, G__param*, int) (in /net/g20/ph/1/hxn075000/DM/Period_K/test4_C.so)
==18138==    by 0x5695F59: Cint::G__ExceptionWrapper(int (*)(G__value*, char const*, G__param*, int), G__value*, char*, G__param*, int) (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x574245F: G__execute_call (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x57446E8: G__call_cppfunc (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x571E5FD: G__interpret_func (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138== 
==18138== Invalid read of size 8
==18138==    at 0x9E306A8: __gnu_cxx::__normal_iterator<float*, std::vector<float, std::allocator<float> > >::__normal_iterator(float* const&) (in /net/g20/ph/1/kxr091000/root/cint/cint/stl/vector.dll)
==18138==    by 0x9E306D0: std::vector<float, std::allocator<float> >::end() (in /net/g20/ph/1/kxr091000/root/cint/cint/stl/vector.dll)
==18138==    by 0x9E74A06: std::vector<float, std::allocator<float> >::operator=(std::vector<float, std::allocator<float> > const&) (in /net/g20/ph/1/kxr091000/root/cint/cint/stl/vector.dll)
==18138==    by 0xC66446D: test4() (in /net/g20/ph/1/hxn075000/DM/Period_K/test4_C.so)
==18138==    by 0xC6645A8: G__test4_C_ACLiC_dict__0_1668(G__value*, char const*, G__param*, int) (in /net/g20/ph/1/hxn075000/DM/Period_K/test4_C.so)
==18138==    by 0x5695F59: Cint::G__ExceptionWrapper(int (*)(G__value*, char const*, G__param*, int), G__value*, char*, G__param*, int) (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x574245F: G__execute_call (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x57446E8: G__call_cppfunc (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x571E5FD: G__interpret_func (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x570BE53: G__getfunction (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x56E12D3: G__getitem (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x56EC3C1: G__getexpr (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==  Address 0x7d1bba0 is 8 bytes after a block of size 24 alloc'd
==18138==    at 0x4A0695E: operator new(unsigned long) (vg_replace_malloc.c:220)
==18138==    by 0xA4E1D71: ROOT::new_vectorlEfloatgR(void*) (in /net/g20/ph/1/kxr091000/root/lib/libvectorDict.so)
==18138==    by 0x4E4EEAB: TClass::New(TClass::ENewType) const (in /net/g20/ph/1/kxr091000/root/lib/libCore.so)
==18138==    by 0xBBB3F62: TBranchElement::SetAddress(void*) (in /net/g20/ph/1/kxr091000/root/lib/libTree.so)
==18138==    by 0xBBFB8C9: TTree::BronchExec(char const*, char const*, void*, bool, int, int) (in /net/g20/ph/1/kxr091000/root/lib/libTree.so)
==18138==    by 0xBBF0FF9: TTree::Bronch(char const*, char const*, void*, int, int) (in /net/g20/ph/1/kxr091000/root/lib/libTree.so)
==18138==    by 0xC6643C2: test4() (in /net/g20/ph/1/hxn075000/DM/Period_K/test4_C.so)
==18138==    by 0xC6645A8: G__test4_C_ACLiC_dict__0_1668(G__value*, char const*, G__param*, int) (in /net/g20/ph/1/hxn075000/DM/Period_K/test4_C.so)
==18138==    by 0x5695F59: Cint::G__ExceptionWrapper(int (*)(G__value*, char const*, G__param*, int), G__value*, char*, G__param*, int) (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x574245F: G__execute_call (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x57446E8: G__call_cppfunc (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x571E5FD: G__interpret_func (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138== 
==18138== Invalid read of size 8
==18138==    at 0x9E74ADC: std::vector<float, std::allocator<float> >::operator=(std::vector<float, std::allocator<float> > const&) (in /net/g20/ph/1/kxr091000/root/cint/cint/stl/vector.dll)
==18138==    by 0xC66446D: test4() (in /net/g20/ph/1/hxn075000/DM/Period_K/test4_C.so)
==18138==    by 0xC6645A8: G__test4_C_ACLiC_dict__0_1668(G__value*, char const*, G__param*, int) (in /net/g20/ph/1/hxn075000/DM/Period_K/test4_C.so)
==18138==    by 0x5695F59: Cint::G__ExceptionWrapper(int (*)(G__value*, char const*, G__param*, int), G__value*, char*, G__param*, int) (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x574245F: G__execute_call (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x57446E8: G__call_cppfunc (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x571E5FD: G__interpret_func (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x570BE53: G__getfunction (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x56E12D3: G__getitem (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x56EC3C1: G__getexpr (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x56F37CF: G__calc_internal (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x577F91B: G__process_cmd (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==  Address 0x7d1bb98 is 0 bytes after a block of size 24 alloc'd
==18138==    at 0x4A0695E: operator new(unsigned long) (vg_replace_malloc.c:220)
==18138==    by 0xA4E1D71: ROOT::new_vectorlEfloatgR(void*) (in /net/g20/ph/1/kxr091000/root/lib/libvectorDict.so)
==18138==    by 0x4E4EEAB: TClass::New(TClass::ENewType) const (in /net/g20/ph/1/kxr091000/root/lib/libCore.so)
==18138==    by 0xBBB3F62: TBranchElement::SetAddress(void*) (in /net/g20/ph/1/kxr091000/root/lib/libTree.so)
==18138==    by 0xBBFB8C9: TTree::BronchExec(char const*, char const*, void*, bool, int, int) (in /net/g20/ph/1/kxr091000/root/lib/libTree.so)
==18138==    by 0xBBF0FF9: TTree::Bronch(char const*, char const*, void*, int, int) (in /net/g20/ph/1/kxr091000/root/lib/libTree.so)
==18138==    by 0xC6643C2: test4() (in /net/g20/ph/1/hxn075000/DM/Period_K/test4_C.so)
==18138==    by 0xC6645A8: G__test4_C_ACLiC_dict__0_1668(G__value*, char const*, G__param*, int) (in /net/g20/ph/1/hxn075000/DM/Period_K/test4_C.so)
==18138==    by 0x5695F59: Cint::G__ExceptionWrapper(int (*)(G__value*, char const*, G__param*, int), G__value*, char*, G__param*, int) (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x574245F: G__execute_call (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x57446E8: G__call_cppfunc (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x571E5FD: G__interpret_func (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138== 
==18138== Invalid write of size 8
==18138==    at 0x9E74AEE: std::vector<float, std::allocator<float> >::operator=(std::vector<float, std::allocator<float> > const&) (in /net/g20/ph/1/kxr091000/root/cint/cint/stl/vector.dll)
==18138==    by 0xC66446D: test4() (in /net/g20/ph/1/hxn075000/DM/Period_K/test4_C.so)
==18138==    by 0xC6645A8: G__test4_C_ACLiC_dict__0_1668(G__value*, char const*, G__param*, int) (in /net/g20/ph/1/hxn075000/DM/Period_K/test4_C.so)
==18138==    by 0x5695F59: Cint::G__ExceptionWrapper(int (*)(G__value*, char const*, G__param*, int), G__value*, char*, G__param*, int) (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x574245F: G__execute_call (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x57446E8: G__call_cppfunc (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x571E5FD: G__interpret_func (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x570BE53: G__getfunction (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x56E12D3: G__getitem (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x56EC3C1: G__getexpr (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x56F37CF: G__calc_internal (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x577F91B: G__process_cmd (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==  Address 0x7d1bba0 is 8 bytes after a block of size 24 alloc'd
==18138==    at 0x4A0695E: operator new(unsigned long) (vg_replace_malloc.c:220)
==18138==    by 0xA4E1D71: ROOT::new_vectorlEfloatgR(void*) (in /net/g20/ph/1/kxr091000/root/lib/libvectorDict.so)
==18138==    by 0x4E4EEAB: TClass::New(TClass::ENewType) const (in /net/g20/ph/1/kxr091000/root/lib/libCore.so)
==18138==    by 0xBBB3F62: TBranchElement::SetAddress(void*) (in /net/g20/ph/1/kxr091000/root/lib/libTree.so)
==18138==    by 0xBBFB8C9: TTree::BronchExec(char const*, char const*, void*, bool, int, int) (in /net/g20/ph/1/kxr091000/root/lib/libTree.so)
==18138==    by 0xBBF0FF9: TTree::Bronch(char const*, char const*, void*, int, int) (in /net/g20/ph/1/kxr091000/root/lib/libTree.so)
==18138==    by 0xC6643C2: test4() (in /net/g20/ph/1/hxn075000/DM/Period_K/test4_C.so)
==18138==    by 0xC6645A8: G__test4_C_ACLiC_dict__0_1668(G__value*, char const*, G__param*, int) (in /net/g20/ph/1/hxn075000/DM/Period_K/test4_C.so)
==18138==    by 0x5695F59: Cint::G__ExceptionWrapper(int (*)(G__value*, char const*, G__param*, int), G__value*, char*, G__param*, int) (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x574245F: G__execute_call (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x57446E8: G__call_cppfunc (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138==    by 0x571E5FD: G__interpret_func (in /net/g20/ph/1/kxr091000/root/lib/libCint.so)
==18138== 
62.162682
62.162682
ntt=6, j=2
64.105583
64.105583
ntt=6, j=3
0.935039
0.935039
ntt=6, j=4
Error: Symbol #include is not defined in current scope  :0:
Error: Symbol exception is not defined in current scope  :0:
Syntax Error: #include <exception> :0:
Error: Symbol G__exception is not defined in current scope  :0:
Error: type G__exception not defined FILE: LINE:0
(void)0
*** Interpreter error recovered ***
==18138== 
==18138== HEAP SUMMARY:
==18138==     in use at exit: 8,519,814 bytes in 89,091 blocks
==18138==   total heap usage: 954,686 allocs, 865,595 frees, 81,723,728 bytes allocated
==18138== 
==18138== LEAK SUMMARY:
==18138==    definitely lost: 862 bytes in 10 blocks
==18138==    indirectly lost: 1,376 bytes in 24 blocks
==18138==      possibly lost: 1,141,135 bytes in 22,251 blocks
==18138==    still reachable: 7,376,441 bytes in 66,806 blocks
==18138==         suppressed: 0 bytes in 0 blocks
==18138== Rerun with --leak-check=full to see details of leaked memory
==18138== 
==18138== For counts of detected and suppressed errors, rerun with: -v
==18138== ERROR SUMMARY: 38 errors from 12 contexts (suppressed: 7 from

Hi Hari,

The problem is mass[j] = dieltrk_m[j];where mass and dieltrk_m are pointers and not objects.
Use either mass->at(j) = dieltrk_m->at(j);or (*mass)[j] = (*dieltrk_m)[j];Cheers,
Philippe.

Hi

I tried both way, but

==19101== Command: root.exe -b -l -q test4.C++
==19101== 
root [0] 
Processing test4.C++...
Info in <TUnixSystem::ACLiC>: creating shared library /net/g20/ph/1/hxn075000/DM/Period_K/./test4_C.so
/net/g20/ph/1/hxn075000/DM/Period_K/./test4.C: In function ‘void test4()’:
/net/g20/ph/1/hxn075000/DM/Period_K/./test4.C:40: warning: unused variable ‘b_mass’
Before event loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
ntt=1, j=0
Error: Symbol #include is not defined in current scope  :0:
Error: Symbol exception is not defined in current scope  :0:
Syntax Error: #include <exception> :0:
Error: Symbol G__exception is not defined in current scope  :0:
Error: type G__exception not defined FILE: LINE:0
(void)0
*** Interpreter error recovered ***
==19101== 
==19101== HEAP SUMMARY:
==19101==     in use at exit: 8,519,890 bytes in 89,090 blocks
==19101==   total heap usage: 954,709 allocs, 865,619 frees, 81,724,817 bytes allocated
==19101== 
==19101== LEAK SUMMARY:
==19101==    definitely lost: 862 bytes in 10 blocks
==19101==    indirectly lost: 1,332 bytes in 23 blocks
==19101==      possibly lost: 1,499,818 bytes in 27,290 blocks
==19101==    still reachable: 7,017,878 bytes in 61,767 blocks
==19101==         suppressed: 0 bytes in 0 blocks
==19101== Rerun with --leak-check=full to see details of leaked memory
==19101== 
==19101== For counts of detected and suppressed errors, rerun with: -v
==19101== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 7 from 7)

Hi,

Did you also change the Printf calls to use the right values? Did you verify that ntt and the size() of the vector agree (i.e. are the same value)?

Cheers,
Philippe.

Hi

Yes i did, FYR I have copied my updated macro and the recent output

Macro


#include <TH2.h>
#include <TH3.h>
#include <TH1F.h>
#include <TH1.h>
#include <TMath.h>
#include <iostream>
#include <TStyle.h>
#include <TCanvas.h>
#include <TNtuple.h>
#include <TROOT.h>
#include <TChain.h>
#include <TFile.h>
#include <TTree.h>


void test4(){


gROOT->Reset();

   TFile *oldfile = new TFile("/net/g20/ph/1/hxn075000/DM/Period_K/dataK_0.root");
   TTree *oldtree = (TTree*)oldfile->Get("LeptonJetTree");

   vector<float> *dieltrk_m = 0;
   Int_t ntt = 0;
   Int_t nevts = 0;
   vector<float> *mass = 0;

   TBranch        *b_dieltrk_m;
   TBranch        *b_ntt;
   TBranch        *b_nevts;
   TBranch        *b_mass;

   oldtree->SetBranchAddress("dieltrk_m", &dieltrk_m, &b_dieltrk_m);
   oldtree->SetBranchAddress("ntt", &ntt, &b_ntt);
   oldtree->SetBranchAddress("nevts", &nevts, &b_nevts);


   //Create a new file + a clone of old tree in new file
   TFile *newfile = new TFile("test4.root","recreate");
   TTree *newtree = new TTree("T", "Mytree");

   newtree->Branch("mass", &mass);

   Long64_t nentries = oldtree->GetEntries();
   Long64_t nb = 0;
   Long64_t nsig = 0;

Printf("Before event loop");

   for(Long64_t i=0;i<nentries;i++) {
     Long64_t ientry = oldtree->LoadTree(i);              
     if(ientry<0) break;

     nb += oldtree->GetEntry(i);
     nsig = dieltrk_m->size();

     Printf("Before ntt loop");

     for(Int_t j=0;j<ntt;j++) {
        Printf("ntt=%d, size=%d,  j=%d", ntt, nsig, j);
        mass->at(j) = dieltrk_m->at(j);
        Printf("dieltrk_m=%f,  mass=%f", (*dieltrk_m)[j], (*mass)[j]);
         }               
   }

Printf("3");

   newtree->Fill();
   newtree->Print();
   newfile->Write();

Printf("%d, %d", nentries, a);


   delete oldfile;
   delete newfile; 
}

Output

==19448== Memcheck, a memory error detector
==19448== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al.
==19448== Using Valgrind-3.5.0 and LibVEX; rerun with -h for copyright info
==19448== Command: root.exe -b -l -q test4.C++
==19448== 
root [0] 
Processing test4.C++...
Info in <TUnixSystem::ACLiC>: creating shared library /net/g20/ph/1/hxn075000/DM/Period_K/./test4_C.so
/net/g20/ph/1/hxn075000/DM/Period_K/./test4.C: In function ‘void test4()’:
/net/g20/ph/1/hxn075000/DM/Period_K/./test4.C:40: warning: unused variable ‘b_mass’
Before event loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
ntt=1, size=1,  j=0
Error: Symbol #include is not defined in current scope  :0:
Error: Symbol exception is not defined in current scope  :0:
Syntax Error: #include <exception> :0:
Error: Symbol G__exception is not defined in current scope  :0:
Error: type G__exception not defined FILE: LINE:0
(void)0
*** Interpreter error recovered ***
==19448== 
==19448== HEAP SUMMARY:
==19448==     in use at exit: 8,445,388 bytes in 88,025 blocks
==19448==   total heap usage: 865,066 allocs, 777,041 frees, 77,080,028 bytes allocated
==19448== 
==19448== LEAK SUMMARY:
==19448==    definitely lost: 862 bytes in 10 blocks
==19448==    indirectly lost: 1,332 bytes in 23 blocks
==19448==      possibly lost: 1,255,057 bytes in 23,559 blocks
==19448==    still reachable: 7,188,137 bytes in 64,433 blocks
==19448==         suppressed: 0 bytes in 0 blocks
==19448== Rerun with --leak-check=full to see details of leaked memory
==19448== 
==19448== For counts of detected and suppressed errors, rerun with: -v
==19448== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 7 from 7)

Hi,

The next problem is the setting of mass. std::vector does not support the notation vec[i] to insert a value you need to either use std::vector::push_back or resize it before hand (i.e. in your mass->resize(ntt) ) should fix the problem.

Cheers,
Philippe.

aahhhh!!! I think i found the bug…

I dont think i will have to define the variable ‘mass’ as a pointer. Now i changed

vector mass = 0
.
.
for(j=0; j<ntt; j++){
mass[j] = (*dieltrk_m)[j];
}

Now its running… :slight_smile:

:open_mouth: :blush: #-o
You’d better read at least: http://www.cplusplus.com/reference/stl/vector/operator%5B%5D/ and http://www.cplusplus.com/reference/stl/vector/push_back/ and http://www.cplusplus.com/reference/stl/vector/resize/
Try also to run this “trial” with ACLiC (i.e. “root [0] .x trial.cxx++”): [code]#include

void trial(void)
{
#if 1 /* 0 or 1 /
std::vector mass = 0; // WRONG (SYNTAX ERROR) !!!
#else /
0 or 1 /
std::vector mass(5); // CORRECT (5 ELEMENTS ALLOCATED) !!!
#endif /
0 or 1 */

#if 1 /* 0 or 1 /
int ntt = 10; // WRONG (10 IS TOO MANY) !!!
#else /
0 or 1 /
int ntt = mass.size(); // CORRECT (THE ACTUAL SIZE OF “mass”) !!!
#endif /
0 or 1 */

for(int j = 0; j < ntt; j++) {
mass[j] = j;
}

return;
}[/code]

Thanks Pepe and Philippe…

It didnt finish through completely. This time it stopped near ‘Fill()’

Output

Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
Before ntt loop
3

 *** Break *** segmentation violation



===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
#0  0x00002ba4b6a0fdf5 in waitpid () from /lib64/libc.so.6
#1  0x00002ba4b69b3491 in do_system () from /lib64/libc.so.6
#2  0x00002ba4b4b2cda9 in TUnixSystem::StackTrace() () from /net/g20/ph/1/kxr091000/root/lib/libCore.so
#3  0x00002ba4b4b2a9c3 in TUnixSystem::DispatchSignals(ESignals) () from /net/g20/ph/1/kxr091000/root/lib/libCore.so
#4  <signal handler called>
#5  0x00002ba4b8c33320 in TBufferFile::WriteFastArray(float const*, int) () from /net/g20/ph/1/kxr091000/root/lib/libRIO.so
#6  0x00002ba4b8c5a336 in TGenCollectionStreamer::WritePrimitives(int, TBuffer&) () from /net/g20/ph/1/kxr091000/root/lib/libRIO.so
#7  0x00002ba4b8c5cbcb in TGenCollectionStreamer::Streamer(TBuffer&) () from /net/g20/ph/1/kxr091000/root/lib/libRIO.so
#8  0x00002ba4b8c398c7 in TCollectionStreamer::Streamer(TBuffer&, void*, int, TClass*) () from /net/g20/ph/1/kxr091000/root/lib/libRIO.so
#9  0x00002ba4b8c32526 in TBufferFile::WriteFastArray(void*, TClass const*, int, TMemberStreamer*) () from /net/g20/ph/1/kxr091000/root/lib/libRIO.so
#10 0x00002ba4b8cf7d1e in int TStreamerInfo::WriteBufferAux<char**>(TBuffer&, char** const&, int, int, int, int) ()
   from /net/g20/ph/1/kxr091000/root/lib/libRIO.so
#11 0x00002ba4bb4f0405 in TBranchElement::FillLeaves(TBuffer&) () from /net/g20/ph/1/kxr091000/root/lib/libTree.so
#12 0x00002ba4bb4e9840 in TBranch::Fill() () from /net/g20/ph/1/kxr091000/root/lib/libTree.so
#13 0x00002ba4bb4ee061 in TBranchElement::Fill() () from /net/g20/ph/1/kxr091000/root/lib/libTree.so
#14 0x00002ba4bb52fd50 in TTree::Fill() () from /net/g20/ph/1/kxr091000/root/lib/libTree.so
#15 0x00002ba4bb5a012d in G__G__Tree_109_0_44(G__value*, char const*, G__param*, int) () from /net/g20/ph/1/kxr091000/root/lib/libTree.so
#16 0x00002ba4b5330f5a in Cint::G__ExceptionWrapper(int (*)(G__value*, char const*, G__param*, int), G__value*, char*, G__param*, int) ()
   from /net/g20/ph/1/kxr091000/root/lib/libCint.so
#17 0x00002ba4b53dd460 in G__execute_call () from /net/g20/ph/1/kxr091000/root/lib/libCint.so
#18 0x00002ba4b53df6e9 in G__call_cppfunc () from /net/g20/ph/1/kxr091000/root/lib/libCint.so
#19 0x00002ba4b53b95fe in G__interpret_func () from /net/g20/ph/1/kxr091000/root/lib/libCint.so
#20 0x00002ba4b53a6ce6 in G__getfunction () from /net/g20/ph/1/kxr091000/root/lib/libCint.so
#21 0x00002ba4b5494cf3 in G__getstructmem () from /net/g20/ph/1/kxr091000/root/lib/libCint.so
#22 0x00002ba4b548a61d in G__getvariable () from /net/g20/ph/1/kxr091000/root/lib/libCint.so
#23 0x00002ba4b537c16c in G__getitem () from /net/g20/ph/1/kxr091000/root/lib/libCint.so
#24 0x00002ba4b53873c2 in G__getexpr () from /net/g20/ph/1/kxr091000/root/lib/libCint.so
#25 0x00002ba4b540c83f in G__exec_statement () from /net/g20/ph/1/kxr091000/root/lib/libCint.so
#26 0x00002ba4b53bb56f in G__interpret_func () from /net/g20/ph/1/kxr091000/root/lib/libCint.so
#27 0x00002ba4b53a6e54 in G__getfunction () from /net/g20/ph/1/kxr091000/root/lib/libCint.so
#28 0x00002ba4b537c2d4 in G__getitem () from /net/g20/ph/1/kxr091000/root/lib/libCint.so
#29 0x00002ba4b53873c2 in G__getexpr () from /net/g20/ph/1/kxr091000/root/lib/libCint.so
#30 0x00002ba4b538e7d0 in G__calc_internal () from /net/g20/ph/1/kxr091000/root/lib/libCint.so
#31 0x00002ba4b541a91c in G__process_cmd () from /net/g20/ph/1/kxr091000/root/lib/libCint.so
#32 0x00002ba4b4b16397 in TCint::ProcessLine(char const*, TInterpreter::EErrorCode*) () from /net/g20/ph/1/kxr091000/root/lib/libCore.so
#33 0x00002ba4b4b1b403 in TCint::ProcessLineSynch(char const*, TInterpreter::EErrorCode*) () from /net/g20/ph/1/kxr091000/root/lib/libCore.so
#34 0x00002ba4b4a55461 in TApplication::ExecuteFile(char const*, int*, bool) () from /net/g20/ph/1/kxr091000/root/lib/libCore.so
#35 0x00002ba4b4a5321b in TApplication::ProcessLine(char const*, bool, int*) () from /net/g20/ph/1/kxr091000/root/lib/libCore.so
#36 0x00002ba4b6097d0b in TRint::Run(bool) () from /net/g20/ph/1/kxr091000/root/lib/libRint.so
#37 0x000000000040100d in main ()
===========================================================


The lines below might hint at the cause of the crash.
If they do not help you then please submit a bug report at
http://root.cern.ch/bugs. Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.
===========================================================
#5  0x00002ba4b8c33320 in TBufferFile::WriteFastArray(float const*, int) () from /net/g20/ph/1/kxr091000/root/lib/libRIO.so
#6  0x00002ba4b8c5a336 in TGenCollectionStreamer::WritePrimitives(int, TBuffer&) () from /net/g20/ph/1/kxr091000/root/lib/libRIO.so
#7  0x00002ba4b8c5cbcb in TGenCollectionStreamer::Streamer(TBuffer&) () from /net/g20/ph/1/kxr091000/root/lib/libRIO.so
#8  0x00002ba4b8c398c7 in TCollectionStreamer::Streamer(TBuffer&, void*, int, TClass*) () from /net/g20/ph/1/kxr091000/root/lib/libRIO.so
#9  0x00002ba4b8c32526 in TBufferFile::WriteFastArray(void*, TClass const*, int, TMemberStreamer*) () from /net/g20/ph/1/kxr091000/root/lib/libRIO.so
#10 0x00002ba4b8cf7d1e in int TStreamerInfo::WriteBufferAux<char**>(TBuffer&, char** const&, int, int, int, int) ()
   from /net/g20/ph/1/kxr091000/root/lib/libRIO.so
#11 0x00002ba4bb4f0405 in TBranchElement::FillLeaves(TBuffer&) () from /net/g20/ph/1/kxr091000/root/lib/libTree.so
#12 0x00002ba4bb4e9840 in TBranch::Fill() () from /net/g20/ph/1/kxr091000/root/lib/libTree.so
#13 0x00002ba4bb4ee061 in TBranchElement::Fill() () from /net/g20/ph/1/kxr091000/root/lib/libTree.so
#14 0x00002ba4bb52fd50 in TTree::Fill() () from /net/g20/ph/1/kxr091000/root/lib/libTree.so
===========================================================


Root > Function test4() busy flag cleared

As you can see the last thing printed before Segmentation fault is ‘3’, which i have in my macro…

Hi.

[quote]Now its running…[/quote]by luck only though … you still need to resize the mass vector and/or push_back to it (and yes … you also needed to actually create the vector rather than setting the pointer to zero … switching to using an object here is fine too).

Cheers,
Philippe.

Thanks Pepe and Philippe,

Your suggestion of resizing my ‘mass’ vector and defining it as
vector mass(10);
worked. Thanks a lot.

If I am not asking too much, can you point me to some reference/tutorial macro which talks about
’Reading from multiple root files having same Tree structure located in different directories and writing out few branches into a new Tree’’. Something like an extention to my current macro. Thanks

Hardcoding 10 is not a good idea.
Looking at your code, I believe you should: // ... vector<float> mass; // create an "empty" vector // ... nsig = dieltrk_m->size(); // ... // .. now ... either ... // mass.resize(nsig); // always the same size as "dieltrk_m" // ... or maybe better ... mass.resize(ntt); // always the minimal required size of "ntt" // ... are you sure that "ntt" is always less or equal to "nsig"? for(j = 0; j < ntt; j++) mass[j] = (*dieltrk_m)[j]; // ...

Hi Pepe,

Okay, instead of hardcoding the mass to 10, I will keep it open.

On a second thought, I just realized that ‘ntt’ is nothing but dieltrk_m->size(), on the root file I am reading ntt is created as a branch. I can use either ntt or dieltrk_m->size() invariably!
In shoft ntt = dieltrk_m->size() --> always…

if “mass” is an exact copy of “dieltrk_m”, why do you create it in the first place?
Why don’t you simply re-use the “dieltrk_m” pointer?
Something like:
newtree->Branch(“mass”, &dieltrk_m);