TTree Project() confusion

Hi,

I’m trying to use the Project() function in this way

TH1F *h0 = new TH1F("h0", "h0", 100, 0, 20000000);
TH1F *h1 = new TH1F("h1", "h1", 100, 0, 20000000);

sig_tree->Project("h0", "jet1_pt*event_weight"); 
bkg_tree->Project("h1", "jet1_pt*event_weight");

sigE = h0->Integral();
bkgE = h1->Integral();

though when I print the values I get the wrong numbers:

sig_entries = 5441 (from GetEntries())
bkg_entries = 1709220 (from GetEntries())
sigE = 5441
bkgE = 1709220

if instead I do

TH1F *h0 = new TH1F("h0", "h0", 100, 0, 20000000);
TH1F *h1 = new TH1F("h1", "h1", 100, 0, 20000000);

sig_tree->Project("h0", "jet1_pt", "event_weight"); 
bkg_tree->Project("h1", "jet1_pt", "event_weight");

sigE = h0->Integral();
bkgE = h1->Integral();

I can get the correct results:

sig_entries = 5441
bkg_entries = 1709220
sigE_noCut = 3970
bkgE_noCut = 203225

which is not what I expect from the documentation. I would expect that if I pass

varexp = jet1_pt*event_weight

I would get the correct result. In the end what I want to do is something like

varexp = jet1_pt*event_weight
selection = jet1_pt > 150 GeV

Thus I would expect that something like

TH1F *h0 = new TH1F("h0", "h0", 100, 0, 20000000);

sig_tree->Project("h0", "jet1_pt*event_weight", "jet1_pt>100");

should give me what I want but apparently this is not the case. Could you point me out where I’m being mistaken?

Thanks,

Gabriele

I’m just guessing here (not an official ROOT expert), but I think it’s because one method does not “fill” 0-weighted entries, it just skips over them. The other method does a fill operation with a weight of zero. As I said, just guessing, but maybe you can try to some tests to see if that’s right.

Note that you can combine expressions in the selection argument, I think you could do something like:

varexp = jet1_pt
selection = event_weight * (jet1_pt > 150 GeV)

Jean-François