Plotting difference between two branches of two ttree

Hello, I’ve some files like this WeTransfer - Send Large Files & Share Photos Online - Up to 2GB Free
by this macro I can plot the x position of hits on subdetectors (I.e. the branch xhit of the TTree LEMMA).

xhitb21.cpp (3.5 KB)

Now I should plot the difference of the branches xhit of two different files…
i.e. I should plot
xhit (stored in TTree of first file) - xhit (stored in the TTree of second file)

Is it possible?

Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided

If you want to simply use tree->Draw, you can just add the second tree as a friend of the first one, then draw the difference specifying from which tree to take each branch. Read how to do it here:
(especially 14.16.2 TTree::AddFriend)

Hello @dastudillo thank you.
So I wrote this macro using the TTree friend.

deltaxhitb21.cpp (2.8 KB)

and it looks like working, but I need a TCut…
i.e. I have to select negative muons from the first file and positive muons from the friend.

I wrote the two TCuts

TCut Idpmup = TString::Format("Idp==%d", mup).Data();
			TCut Idpmum = TString::Format("Idp==%d", mum).Data();

but I don’t know how to apply Idpmum only to main file and Idpmup only to the friend. Is it possible?

Instead, the TCut

TCut subdet = TString::Format("subdet==%d", subdett).Data();

must be applied to both the files, so I simply wrote
t->Draw(hhitstring, subdet);
similiarly to what I do when I’ve only a ROOT file

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.