# Plotting rapidity using root

**URL:** <https://root-forum.cern.ch/t/plotting-rapidity-using-root/33969>\
**Category:** Newbie\
**Created:** [May 9, 2019, 4:01am UTC](https://root-forum.cern.ch/t/plotting-rapidity-using-root/33969 "2019-05-09T04:01:34Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anjali](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/aeb1de/32.png) [@Anjali](https://root-forum.cern.ch/u/Anjali)\
**Post date:** [May 9, 2019, 4:01am UTC](https://root-forum.cern.ch/t/plotting-rapidity-using-root/33969/1 "2019-05-09T04:01:35Z")

</div>

I am trying to plot rapidity using root. [try3.c](https://root-forum.cern.ch/uploads/default/original/3X/1/3/137a4bb9ba0db295daea67200e108d230806bf54.c) (280 Bytes).This is my code. But while executing this I get an error Error: log param[0]=-16.0655 up:1.#INF low:0 out of range C:\root\trial\try3.c(1  
1)  
\*\*\* Interpreter error recovered \*\*\*  
how do i resolve this?

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [May 9, 2019, 6:48am UTC](https://root-forum.cern.ch/t/plotting-rapidity-using-root/33969/2 "2019-05-09T06:48:55Z")

</div>

Fix the reported warnings and then the error will disappear automatically:

```auto
root [0] .x try3.c 
Warning: Automatic variable E is allocated try3.c:10:
Warning: Automatic variable y is allocated try3.c:11:
Error: log param[0]=-16.0655 up:inf low:0 out of range try3.c:11:
***Interpreter error recovered***

```

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [May 9, 2019, 7:41am UTC](https://root-forum.cern.ch/t/plotting-rapidity-using-root/33969/3 "2019-05-09T07:41:24Z")

</div>

[try3.c](https://root-forum.cern.ch/uploads/default/original/3X/5/3/53ad101e705e391face26aaeb0aa9caaf8515912.c) (356 Bytes)

---

<div class="post-metadata">

**Author:** ![Anjali](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/aeb1de/32.png) [@Anjali](https://root-forum.cern.ch/u/Anjali)\
**Post date:** [May 9, 2019, 8:13am UTC](https://root-forum.cern.ch/t/plotting-rapidity-using-root/33969/4 "2019-05-09T08:13:28Z")

</div>

Sir what does this #Inf error mean?

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [May 9, 2019, 8:21am UTC](https://root-forum.cern.ch/t/plotting-rapidity-using-root/33969/5 "2019-05-09T08:21:34Z")

</div>

The macro I posted does not produce any error on my machine.  
Have you tried it ?

---

<div class="post-metadata">

**Author:** ![Anjali](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/aeb1de/32.png) [@Anjali](https://root-forum.cern.ch/u/Anjali)\
**Post date:** [May 9, 2019, 8:38am UTC](https://root-forum.cern.ch/t/plotting-rapidity-using-root/33969/6 "2019-05-09T08:38:58Z")

</div>

Yes sir, I tried it and it doesn’t produce any error. You added the auto keyword to h. But even after removing that auto keyword there isn’t any error but if I put a mass like .938 it’s giving the same error. Is log becoming infinity in this case?

Yours sincerely,

Anjali

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [May 9, 2019, 8:52am UTC](https://root-forum.cern.ch/t/plotting-rapidity-using-root/33969/7 "2019-05-09T08:52:09Z")

</div>

Try this:

```auto
void try3() {
   TH1D *h = new TH1D("h","rapidity",500,-500,500);
   Double_t y,m,px,py,pz,pt,p,E;
   m =.938;
   for (Int_t i=0;i<10000;i++) {
      gRandom->Rannor(px,py);
      gRandom->Rannor(pz,pt);
      p = -(px*px+py*py+pz*pz)+(pt*pt);
      E = sqrt((p*p)+(m*m));
      y =.5*log((E+pz)/(E-pz));
      h->Fill(y);
   }
   h->Draw();
}

```

It does not give me any error either.
