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
skim_list.Subtract(sig_list)

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

t_sig.Write("B0");   
f_sig.Close();

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

t1.SetEntryList(bkg_list)
for i in range(0,skim_list.GetN()):
    entryNumber = t1.GetEntryNumber(i)
    t1.GetEntry(entryNumber)
    t_bkg.Fill() 

t_bkg.Write("B0");   
f_bkg.Close();

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>
    t1.SetEntryList(bkg_list)
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++):
https://root.cern/doc/master/h1analysisProxy_8C.html

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
skim_list.Subtract(sig_list)
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.