Issue with filling a TTree with an array

Hello, I have a problem in filling a Branch of a TTree with a variable
lenght array.
I have a TTree (named mom in the following code) with a Branch (named
Multi). In each entry of Multi I’ve the molteplicity value of an event.
I have an other TTree (named tree) which contains some branches (i.e.
Sigg and the event number). Each entry has stored the value of a
silicon signal of a particle.
I would like to generate a new TTree (t__matrice_new) with a branch
(Sigg_new) which contains an array. The array lenght must be equal to
the multiplicity of my event (so it must be equal to the value stored
in Multi), and it should contains the silicium signal values of all
the particles belonging to the same event.
I’ve written the following code:

Float_t *Sigg_new;
UInt_t Multiplicity;

//My new TTree
TTree *t__matrice_new;
t__matrice_new= new TTree(“t__matrice_new”,“Matrice Chio-Si new”);
t__matrice_new->Branch(“Multiplicity”, &Multiplicity, “Multiplicity/I”);
t__matrice_new->Branch(“Sigg_new”, &Sigg_new, “Sigg_new[Multiplicity]/F”);

UInt_t g=0;
UInt_t nentries_mom=(UInt_t)mom->GetEntries();
for(UInt_t i=0;i<nentries_mom;i++)

  //I allocate the memory and inizialize the array
  Sigg_new=(Float_t*)malloc(Multi * sizeof(int));

  for(UInt_t l=0;l<Multi;l++)

for(UInt_t k=g;k<g+Multi;k++)

  for(UInt_t uff=0;uff<Multi;uff++)

cout<<" si="<<Sigg_new[uff]<<endl;

My problem is:
the output of the last cout gives the correct values (es. 234.5), but with the
Scan() method I get different (uncorrect!) values (es. 5.6666e-33)… I’m not saving
the correct value, even if before to save them with Fill() I get the
right ones.
What is wrong?
Thanks in advance


PS sorry, probably I should post this topic on ROOT Discussion, but now I’m not able to delete it anymore


Thank you very much!