# Cannot plot RooDataSet entries

**URL:** <https://root-forum.cern.ch/t/cannot-plot-roodataset-entries/33714>\
**Category:** Newbie\
**Created:** [April 22, 2019, 3:02pm UTC](https://root-forum.cern.ch/t/cannot-plot-roodataset-entries/33714 "2019-04-22T15:02:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jenegger](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/e9a140/32.png) [@jenegger](https://root-forum.cern.ch/u/jenegger)\
**Post date:** [April 22, 2019, 3:02pm UTC](https://root-forum.cern.ch/t/cannot-plot-roodataset-entries/33714/1 "2019-04-22T15:02:30Z")

</div>

Hi experts,  
I have a question concerning the plotting of a dataset (RooDataSet) on RooFit. I have a dataset ‘complete\_lambda.root’ which contains the values of different observables. For my analysis cuts are used to bin the data in different regions.  
In this case I want to bin the dataset for the **observable ‘daughter\_\_bo0\_\_cm\_\_spp\_\_bc’**.  
The PROBLEM arises when I set the cut of the observable larger than 1.  
Here my straightforward code snippet:

```auto
import ROOT

variable_name = "M"
y = ROOT.RooRealVar(variable_name,variable_name,1.10,1.13,'GeV')

def my_dataset(path,filename, cuts,name, treename='variables'):
    branchname = variable_name
    sigmc_chain = ROOT.TChain(treename)
    nsig = sigmc_chain.Add(path+filename)
    sigmc_chain = sigmc_chain.CopyTree(cuts)
    sigmc_ds = ROOT.RooDataSet(name,name,sigmc_chain, ROOT.RooArgSet(y))
    return sigmc_ds

def my_multiplot(data_set, canvas_name):
    canvas = ROOT.TCanvas("canvas_analysis")
    frame = y.frame()
    print('hello from inside')
    data_set.plotOn(frame)
    frame.Draw()
    return canvas

full_data = my_dataset('/home/jenegger/protonproject/','complete_lambda.root','M > 1.10 && M < 1.13 && distance > 5 && 1 < daughter __bo0__ cm __spp__ bc < 2',"full_ds")

d = my_multiplot(full_data,'check_momentum')
d.Draw()

```

I used the function sumEntries(‘M’,‘0’) to check whether therere are some events in this range but it returns the value 0.0.  
When I change the range of the observable to : 0.995 \< daughter\_\_bo0\_\_cm\_\_spp\_\_bc \< 2  
… I get lots of events  
When I change the range of the observable to : 0.995 \< daughter\_\_bo0\_\_cm\_\_spp\_\_bc \< 1  
… I also get lots of events(but less)

So I substracted the both values ( 160274.0-124433.0 = 35841.0) -\> it is not equal 0!  
So I really don’t understand why I can’t plot anything which occurs between the range of 1 and 2of the observable?!

I also tried to make simple plots using root\_pandas and matplotlib as countercheck and there it works…  
(it plots exactly 35841events)

Thanks in advance  
Tobias

---

<div class="post-metadata">

**Author:** ![StephanH](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@StephanH](https://root-forum.cern.ch/u/StephanH)\
**Post date:** [April 23, 2019, 10:12am UTC](https://root-forum.cern.ch/t/cannot-plot-roodataset-entries/33714/2 "2019-04-23T10:12:58Z")

</div>

Hey Tobias,

I took the liberty to edit your post to frame the code in three “`”. In this way, it’s easier to read. I will have a look at the rest after lunch.

---

<div class="post-metadata">

**Author:** ![StephanH](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@StephanH](https://root-forum.cern.ch/u/StephanH)\
**Post date:** [April 23, 2019, 10:16am UTC](https://root-forum.cern.ch/t/cannot-plot-roodataset-entries/33714/3 "2019-04-23T10:16:10Z")

</div>

The problem is here:

> [@jenegger](#):
>
> && 1 \< daughter\_\_bo0\_\_cm\_\_spp\_\_bc \< 2

This expression is not doing what you think. You want to use  
`&& 1 < daughter __bo0__ cm __spp__ bc && daughter __bo0__ cm __spp__ bc < 2`  
to have it in the range [1, 2].  
I honestly don’t know how your expression is interpreted, because I don’t know the precedence (or associativity) of the operators. It might evaluate to something like  
`(1 < daughter __bo0__ cm __spp__ bc = true = 1) < 2`.

---

<div class="post-metadata">

**Author:** ![jenegger](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/e9a140/32.png) [@jenegger](https://root-forum.cern.ch/u/jenegger)\
**Post date:** [April 23, 2019, 10:35am UTC](https://root-forum.cern.ch/t/cannot-plot-roodataset-entries/33714/4 "2019-04-23T10:35:44Z")

</div>

StephanH thank you very much for your hint! Now it works perfectly fine. I substituted

> `1 < daughter __bo0__ cm __spp__ bc && daughter __bo0__ cm __spp__ bc < 2`

with:

> 1 \< daughter\_\_bo0\_\_cm\_\_spp\_\_bc && daughter\_\_bo0\_\_cm\_\_spp\_\_bc \< 2

Best regards  
Tobias
