TTree->Fill() in several places

Dear experts,

I looked at the manual but I want a confirmation for this question:

  • I have a variable “var” which has a reference in 2 ttrees [1].
  • During my loop over the event I fill the trees 2 times at different places [2]
  • I wonder if the fill() will copy the var content in the tree, such that the 1st tree will be fill with x, and the second with y, or if both trees will have the last value of var which is y?

Regards

[2]

[code]for(int i=0; i<nevt; i++){

if(mutau){
var=x;
mutau->Fill();
}

if(etau){
var=y;
etau->Fill();
}

}// for[/code]

[1]

[code]int var;

mutau = new TTree(“mutau”, “mutau”);
mutau ->Branch(“var”, &var);

etau = new TTree(“etau”, “etau”);
etau ->Branch(“var”, &var);[/code]

[quote]- I wonder if the fill() will copy the var content in the tree, such that the 1st tree will be fill with x, and the second with y, or if both trees will have the last value of var which is y?
[/quote]The Fill makes a copy at the time of execution. So indeed you will have “the 1st tree will be fill with x, and the second with y”

Cheers,
Philippe.

Dear Philippe,
ok, thank you for your answer.
Regards