Reading vectors from TTree

Dear all,

I created a TTree filled with vectors (in attachment) :

*Tree :tvec : Tree with vectors *
*Entries : 100 : Total = 1024021 bytes File Size = 532194 *

  •    :          : Tree compression factor =   1.91                       *
    

*Br 0 :angry: : vector *
*Entries : 100 : Total Size= 68170 bytes File Size = 39753 *
*Baskets : 3 : Basket Size= 32000 bytes Compression= 1.70 *

*Br 1 :y : vector *
*Entries : 100 : Total Size= 68170 bytes File Size = 41799 *
*Baskets : 3 : Basket Size= 32000 bytes Compression= 1.62 *

*Br 2 :z : vector *
*Entries : 100 : Total Size= 68170 bytes File Size = 33622 *
*Baskets : 3 : Basket Size= 32000 bytes Compression= 2.01 *

*Br 3 :vx : vector *
*Entries : 100 : Total Size= 68177 bytes File Size = 64168 *
*Baskets : 3 : Basket Size= 32000 bytes Compression= 1.06 *

*Br 4 :vy : vector *
*Entries : 100 : Total Size= 68177 bytes File Size = 63438 *
*Baskets : 3 : Basket Size= 32000 bytes Compression= 1.07 *

*Br 5 :vz : vector *
*Entries : 100 : Total Size= 68177 bytes File Size = 64949 *
*Baskets : 3 : Basket Size= 32000 bytes Compression= 1.04 *

*Br 6 :ax : vector *
*Entries : 100 : Total Size= 68177 bytes File Size = 1421 *
*Baskets : 3 : Basket Size= 32000 bytes Compression= 47.65 *

*Br 7 :ay : vector *
*Entries : 100 : Total Size= 68177 bytes File Size = 1421 *
*Baskets : 3 : Basket Size= 32000 bytes Compression= 47.65 *

*Br 8 :az : vector *
*Entries : 100 : Total Size= 68177 bytes File Size = 1421 *
*Baskets : 3 : Basket Size= 32000 bytes Compression= 47.65 *

*Br 9 :time : vector *
*Entries : 100 : Total Size= 68191 bytes File Size = 4115 *
*Baskets : 3 : Basket Size= 32000 bytes Compression= 16.46 *

*Br 10 :Field_x : vector *
*Entries : 100 : Total Size= 68212 bytes File Size = 48368 *
*Baskets : 3 : Basket Size= 32000 bytes Compression= 1.40 *

*Br 11 :Field_y : vector *
*Entries : 100 : Total Size= 68212 bytes File Size = 48544 *
*Baskets : 3 : Basket Size= 32000 bytes Compression= 1.40 *

*Br 12 :Field_z : vector *
*Entries : 100 : Total Size= 68212 bytes File Size = 57848 *
*Baskets : 3 : Basket Size= 32000 bytes Compression= 1.17 *

*Br 13 :Field_y_ext : vector *
*Entries : 100 : Total Size= 68240 bytes File Size = 1574 *
*Baskets : 3 : Basket Size= 32000 bytes Compression= 43.04 *

*Br 14 :z_bunch : vector *
*Entries : 100 : Total Size= 68212 bytes File Size = 58313 *
*Baskets : 3 : Basket Size= 32000 bytes Compression= 1.16 *

And I try to read it with the routine in attachment, but it crashes.
Could someone tell me how to read it, please?

Thanks.
Plot.C (4.51 KB)
Results.root (525 KB)

1 Like

Hello again,

now it works (run2() in the attached file), but if I get the entries of 2 branche (run()), I get that the values for the 2 branches are the same, while using the Scan I see they are different. 

Could someone give a look, please?

Thx!

Franciuska
Plot.C (4.16 KB)

// Warning: your code assumes that sizes of both vectors are ALWAYS exactly the same
cout << history_ps_x_all_part[i][j]<< " " << history_ps_y_all_part[i][j]<<endl;

BTW. Right before returning from your function, you should do:
// cleanup
delete f; // automatically deletes “t”, too
delete x;
delete y;

1 Like

Sorry, I was meaning, when I run “run()”, NOT “run2()”

Read my lips:
cout << history_ps_x_all_part[i][j]<< " " << history_ps_y_all_part[i][j]<<endl;

Ops… :open_mouth: :blush: :blush: :blush:

Thanks a lot…