TEntryList Subtract method

Dear experts,

I have a root file with a large number of entries. I am trying to split the file into signal and background files using truth-matching conditions. I start with some simple skimming to reduce unwanted events and then apply the TM conditions. First, I created an entry list using only the skim cuts then I made a signal-only entrylist by combining the skim cuts and TM cuts. In the third step, I subtract the signal entry list from the skimmed entry list to obtain the background entry list. I am attaching the code here

f1 = TFile("mixed.root");   
t1 = f1.Get("B0");

f_sig = TFile("Signal.root", "recreate");
t_sig = t1.CloneTree(0);

skim_cuts = "(DST_pi_p_COM > 0.055 && DST_pi_p_COM < 0.250  && l_p_COM > 1.2 && l_p_COM < 3.0 && R2 < 0.5)"  #very loose cuts; not same as analysis cuts
sig_cuts = " && ((id_B==511 && id_L==11  && mo_L==511 && id_D==413 && mo_D==511 && id_Pi==211 && mo_Pi==413) || (id_B==511 && id_L==13  && mo_L==511 && id_D==413 && mo_D==511 && id_Pi==211 && mo_Pi==413))"

#skim list
t1.Draw(">> skim_list", skim_cuts, "entrylist")
skim_list = gDirectory.Get("skim_list")

#signal list
t1.Draw(">> sig_list", skim_cuts + sig_cuts, "entrylist")
sig_list = gDirectory.Get("sig_list")

#bkg list

for i in range(0,sig_list.GetN()):
    entryNumber = t1.GetEntryNumber(i)
print("Signal.root created")


f_bkg = TFile("Background.root", "recreate");
t_bkg = t1.CloneTree(0);

for i in range(0,skim_list.GetN()):
    entryNumber = t1.GetEntryNumber(i)


print("Background.root created")

This indeed produces the correct signal.root but gives an error in the line

File "/home/krishnakumar/Desktop/Analysis/B0B0bar/ST/SignalMC/Test/Test/Split_mixed_sigandbkg.py", line 89, in <module>
TypeError: void TTree::SetEntryList(TEntryList* list, const char* opt = "") =>
    TypeError: could not convert argument 1

Can someone tell me how this can be corrected? Or are there any better way than this?

bkg_list should a TEntryList.
For example see this tutorial (in C++):

Sorry in the previous code it was indeed t1.SetEntryList(skim_list) not bkg_list (sorry again for the typo). It is still giving the same error. Since I have defined skim_list as TEntryList , doesn’t this line
produces a new skim_list that has all the entries from sig_list removed?

May be @pcanal will know.

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