I have two root files. I want to choose those events from the second root file which are present in the first one. There are different numbers of entries in two root files but the variable is common, for which I want to extract the values. Here is my sample code, which seems to choose all the events from the second one, instead of those which are also available in the first one.
TChain is to add root files. I don’t want to add them. Instead, I want to show the resolution of a variable, let’s say mbc. For this I need to find the values of mbc from reconstruction level and subtract the values from generator level information. Let’s say I have 10K events in reconstruction level and 50K events in generator level. To get the resolution of the mbc, I need to choose those 10K events from generator level, which are also available in reconstruction level.
Even though I defined mbc for two trees, it doesn’t solve the problem.
With the condition, if(i == j){ mbc.setVal(s_mbc); myfile <<i<<"\t"<<j<<"\t"<<mbc.getVal()<<endl; }
I was expecting to choose only those events (i) of generator level, which are there in reconstruction level (j). Am I doing something wrong?
Yes, I am getting the output of i (generator level) loop only.
What is the correct way to get information of i loop, the events which are also present in j loop?
You have to read each event in the first tree and compare with all the events of the second tree. Maybe @eguiraud has a faster (or more clever) method with RDataFrame…
Hi,
if the values you need to compare all fit in memory (1 million doubles occupy less than 8 MB of RAM) I suggest you extract them as standard vectors and then just operate on those.
With RDataFrame you can get the values of the mbc variable for all events with: