[quote]Code:
ch.AddFriend(“tCorrectedData”);
ch.Draw(“Q2shift”);
I get the right number of entries, but a lot are equal to Zero. And I don’t know why…
[/quote]The problem is that the name ‘tCorrectedData’ is ambiguous and could refer to the TTree or the TChain (and it get the wrong). Instead use
ch.AddFriend(&ch2);
ch.Draw("Q2shift");
[quote]Ok, after all, it seems to me that friendship IS NOT recorded in root file.[/quote]It is:
root [0] TFile *_file0 = TFile::Open("dat_001.root")
root [1] tRawData->GetListOfFriends()->ls()
Friend Tree: tCorrectedData in file:However (and it is a bug) it does not seem to be used when you go through the TChain. I will check into that.
[quote=“pcanal”]The problem is that the name ‘tCorrectedData’ is ambiguous and could refer to the TTree or the TChain (and it get the wrong). Instead use
ch.AddFriend(&ch2);
ch.Draw("Q2shift");
[/quote]
Hey, this syntax works ??!!
It looks much more familiar to my (little) programming background. And it probably works elsewhere in my root scripts. Thanks a lot, it will probably help me to understand ROOT a bit further.
Great! Now I can automate all my data reduction process.
Thanks!
[quote][The friendship] is [recorded in the file]:
root [0] TFile *_file0 = TFile::Open("dat_001.root")
root [1] tRawData->GetListOfFriends()->ls()
Friend Tree: tCorrectedData in file:
However (and it is a bug) it does not seem to be used when you go through the TChain. I will check into that.
[/quote]This problem is now fixed in the CVS repository. This means that with your file the following now works:[code]TChain ch(“tRawData”);
ch.Add(“dat_001.root”);
ch.Add(“dat_002.root”);
ch.Add(“dat_003.root”);