# Cut-String in Draw-Method for TChain

**URL:** <https://root-forum.cern.ch/t/cut-string-in-draw-method-for-tchain/56877>\
**Category:** Newbie\
**Tags:** tree, root\
**Created:** [October 26, 2023, 5:38pm UTC](https://root-forum.cern.ch/t/cut-string-in-draw-method-for-tchain/56877 "2023-10-26T17:38:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ankirchh](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/d26b3c/32.png) [@ankirchh](https://root-forum.cern.ch/u/ankirchh)\
**Post date:** [October 26, 2023, 5:38pm UTC](https://root-forum.cern.ch/t/cut-string-in-draw-method-for-tchain/56877/1 "2023-10-26T17:38:12Z")

</div>

Dear Experts,  
I have a problem with the Draw-Method and using a cut-string. I would like to do something like this:  
chain.Draw(“variable”,“(@el\_pt-\>size()==2 && el\_pt[1]\>25000)||(@mu\_pt-\>size()==2 && mu\_pt[1]\>25000)”);  
Following c++ logic this should give me all events with 2 electrons and the second electron should have at least 25 GeV or the same for muons, although events with 2 electrons have no muons and vice versa and therefore those vectors empty. But somehow this gives an empty histogram. In contrast using (@el\_pt-\>size()==2 && el\_pt[1]\>25000)||(mu\_pt-\>size()==2) works fine.  
What am I doing wrong by following the normal c++ logic of such logical statements?

---

<div class="post-metadata">

**Author:** ![pcanal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pcanal/32/12439_2.png) [@pcanal](https://root-forum.cern.ch/u/pcanal)\
**Post date:** [October 26, 2023, 6:39pm UTC](https://root-forum.cern.ch/t/cut-string-in-draw-method-for-tchain/56877/2 "2023-10-26T18:39:11Z")

</div>

I suppose that the whole expression is false if one of the element can not be evaluated at all.  
Try:

```auto
chain.Draw(“variable”,“(@el_pt->size()==2 && Alt$(el_pt[1],0) >25000)||(@mu_pt->size()==2 && Alt$(mu_pt[1],0)>25000)”);

```

---

<div class="post-metadata">

**Author:** ![ankirchh](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/d26b3c/32.png) [@ankirchh](https://root-forum.cern.ch/u/ankirchh)\
**Post date:** [October 26, 2023, 6:42pm UTC](https://root-forum.cern.ch/t/cut-string-in-draw-method-for-tchain/56877/3 "2023-10-26T18:42:44Z")

</div>

Can it be that the Draw-Method does not use short-circut evaluation?

---

<div class="post-metadata">

**Author:** ![ankirchh](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/d26b3c/32.png) [@ankirchh](https://root-forum.cern.ch/u/ankirchh)\
**Post date:** [October 26, 2023, 6:45pm UTC](https://root-forum.cern.ch/t/cut-string-in-draw-method-for-tchain/56877/4 "2023-10-26T18:45:51Z")

</div>

Thanks a lot! That works!
