# EtaPhiVector

**URL:** <https://root-forum.cern.ch/t/etaphivector/52701>\
**Category:** Newbie\
**Created:** [December 8, 2022, 10:54pm UTC](https://root-forum.cern.ch/t/etaphivector/52701 "2022-12-08T22:54:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![abunka](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/d6d6ee/32.png) [@abunka](https://root-forum.cern.ch/u/abunka)\
**Post date:** [December 8, 2022, 10:54pm UTC](https://root-forum.cern.ch/t/etaphivector/52701/1 "2022-12-08T22:54:02Z")

</div>

Hello ROOTers,  
How would i go about creating an EtaPhiVector with randomly generated eta and phi values? I am currently trying a simple random number generation for a specific range for each of my two coordinates, and then setting the values in the vector:

```auto
TLorentzVector conePosition;
    //Random Cones
    for (int j = 0; j < 100; j++) {
        double randomPhi = m_ranNumGen->Uniform(2 * pi);
        double randomEta = m_ranNumGen->Uniform(4);
        conePosition.SetPhi(randomPhi);
        conePosition.SetEta(randomEta);

```

The problems I am having are:  
Currently, it is defined as just a TLorentzVector, not specifically EtaPhi. How would I change this?  
There does not appear to be a `SetEta()` to use in this case.

End goal is an object that I can use in `DeltaR()`

Thanks!

---

<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:** [December 9, 2022, 7:29am UTC](https://root-forum.cern.ch/t/etaphivector/52701/2 "2022-12-09T07:29:18Z")

</div>

[ROOT::Math::LorentzVector](https://root.cern/doc/master/classROOT_1_1Math_1_1LorentzVector.html)

[ROOT Reference Documentation → Functional Parts → Math → Physics Vectors](https://root.cern/doc/master/group__GenVector.html)

---

<div class="post-metadata">

**Author:** ![abunka](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/d6d6ee/32.png) [@abunka](https://root-forum.cern.ch/u/abunka)\
**Post date:** [December 9, 2022, 9:40pm UTC](https://root-forum.cern.ch/t/etaphivector/52701/3 "2022-12-09T21:40:57Z")

</div>

Using this I can create the vector as

‘’’  
double randomPhi = m\_ranNumGen-\>Uniform(2 \* pi);  
double randomEta = m\_ranNumGen-\>Uniform(4);  
ROOT::Math::PtEtaPhiMVector conePosition(0.0, randomEta, randomPhi, 0.0);  
‘’’

However, I cannot use `DeltaR()` with this, as I could with TLorentzVector

---

<div class="post-metadata">

**Author:** ![vpadulan](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/vpadulan/32/25315_2.png) [@vpadulan](https://root-forum.cern.ch/u/vpadulan)\
**Post date:** [December 10, 2022, 8:52am UTC](https://root-forum.cern.ch/t/etaphivector/52701/4 "2022-12-10T08:52:23Z")

</div>

Dear @abunka ,  
Please see also [ROOT: ROOT::Math::VectorUtil Namespace Reference](https://root.cern/doc/master/namespaceROOT_1_1Math_1_1VectorUtil.html) for a list of helper functions for physics vectors. For example

```python
>>> import ROOT
>>> randomPhi_1 = ROOT.gRandom.Uniform(2*ROOT.TMath.Pi())
>>> randomPhi_2 = ROOT.gRandom.Uniform(2*ROOT.TMath.Pi())
>>> randomEta_1 = ROOT.gRandom.Uniform(4)
>>> randomEta_2 = ROOT.gRandom.Uniform(4)
>>> conePosition_1 = ROOT.Math.PtEtaPhiMVector(0, randomEta_1, randomPhi_1, 0)
>>> conePosition_2 = ROOT.Math.PtEtaPhiMVector(0, randomEta_2, randomPhi_2, 0)
>>> ROOT.Math.VectorUtil.DeltaR(conePosition_1, conePosition_2)
2.849175649604809

```

Cheers,  
Vincenzo
