# Drawing histograms from branches with cuts and weights

Hello all,
This might be a stupid question but I shall ask anyway.
So I have a root file with a series of branches in a ttree which I grab (I am only taking exerts from my code here)

I then within a loop over various eta bins try to draw various plots with cuts on branches, for example the first and simplest plot is as follows where I just make cuts to take ranges in the eta distribution.

```for (int ieta = 0; ieta < neta; ieta++) { TH1F *htemp3 = new TH1F("htemp3","htemp3",100,etalow[ieta],etahigh[ieta]); t->Draw(Form("TMath::Abs(BQuarkEta)>>htemp3"),Form("%f < TMath::Abs(BQuarkEta) && TMath::Abs(BQuarkEta< %f)", etalow[ieta],etahigh[ieta])); ........ }```

This is the form of how I make all of my various pt/eta cut distributions from my TTrees branches. I then take values from these histograms or fit them and take values from that etc. etc. etc. This all works fine. My problem is that I need to take into account the positive and negative weights from MC@NLO which I have stored in another branch of my tree. I am not sure how to Draw my histograms with cuts and at the same time fill them with the weights?
If anyone could tell me what simple step I am missing I would be very grateful!
Cheers!
Al

the result of the selection is a weight in general.
if you have an expression of the form “x>0 && y<0” then the result is 0 or 1. Only the non null values are put in the histogram.
if you have a selection like “myweight*(x>0 && y<0)” the result is either 0 or myweight. All entries passing
the condition will be histogrammed with weight=myweight.

see doc of TTree::Draw

Rene

Thank you.
I had missed that bit of the documentation. This solution
works fine for me!
Cheers,
Al