# TVectors3 Angle() method

**URL:** <https://root-forum.cern.ch/t/tvectors3-angle-method/58483>\
**Category:** Newbie\
**Tags:** root\
**Created:** [March 11, 2024, 11:14am UTC](https://root-forum.cern.ch/t/tvectors3-angle-method/58483 "2024-03-11T11:14:52Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ShiShi1122](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/45deac/32.png) [@ShiShi1122](https://root-forum.cern.ch/u/ShiShi1122)\
**Post date:** [March 11, 2024, 11:14am UTC](https://root-forum.cern.ch/t/tvectors3-angle-method/58483/1 "2024-03-11T11:14:52Z")

</div>

I am new to TVectors3 class and I am trying to calculate angle between two gammas like this:

```auto
relative_angle = gamma_v2.Angle(gamma_v1);

```

I would then like to filld a 3D histogram

```auto

                     relative_angle_degrees = relative_angle*(180/M_PI);

                     // cout << " " << gamma1 << " " << gamma2 << " " << relative_angle_degrees << endl;

                     ggtheta->Fill(gamma1,gamma2,relative_angle_degrees); //Filling it in degrees and not radians!

```

But whenever I try to run it it gives me the \*\*\* Break \*\*\* segmentation violation error. It prints out the angles fine but the problem arises while trying to fill the 3D histogram.  
Is there a particular way one needs to use the output of Angle?

---

<div class="post-metadata">

**Author:** ![jonas](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jonas/32/24756_2.png) [@jonas](https://root-forum.cern.ch/u/jonas)\
**Post date:** [March 11, 2024, 11:17am UTC](https://root-forum.cern.ch/t/tvectors3-angle-method/58483/2 "2024-03-11T11:17:42Z")

</div>

Welcome @ShiShi1122 to the ROOT forum!

For the information you give, it’s impossible to tell where the error is. Can you maybe share the full output of the error and your analysis script, so we can reproduce the problem and help?

Cheers,  
Jonas

---

<div class="post-metadata">

**Author:** ![ShiShi1122](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/45deac/32.png) [@ShiShi1122](https://root-forum.cern.ch/u/ShiShi1122)\
**Post date:** [March 11, 2024, 11:32am UTC](https://root-forum.cern.ch/t/tvectors3-angle-method/58483/3 "2024-03-11T11:32:07Z")

</div>

Here is the relevant part of the big script I have, hope it helps understand the issue better:  
I am not sure if the Angle() method returns a value or a pointer to the value:

```auto
for (int index_m = l + 1; index_m < static_cast<int>(detector.size()); index_m++) {
    gamma1 = calibrated_energies[l];
    gamma2 = calibrated_energies[index_m];

    if (gamma1 > 0 && gamma2 > 0 && (ts.at(l) - ts.at(index_m) < 10)) {
        gg->Fill(gamma1, gamma2);

        gamma_v1.SetMagThetaPhi(radius, thetas[l], phis[l]);
        gamma_v2.SetMagThetaPhi(radius, thetas[index_m], phis[index_m]);
        relative_angle = gamma_v2.Angle(gamma_v1);
        relative_angle_degrees = relative_angle * (180 / M_PI);

        // cout << " " << gamma1 << " " << gamma2 << " " << relative_angle_degrees << endl;

        ggtheta->Fill(gamma1, gamma2, relative_angle_degrees); // Filling it in degrees and not radians!
    }
}

```

And here is the full error:

\*\* Break \*\*\* segmentation violation  
Generating stack trace…  
0x00007f9f1350e869 in   
0x00007f9f23ce712e in   
0x00007f9f1f92d68a in cling::Interpreter::RunFunction(clang::FunctionDecl const\*, cling::Value\*) + 0x24a from /home/shishi/packages/root/root\_install/lib/libCling.so  
0x00007f9f1f92f06d in cling::Interpreter::EvaluateInternal(std::\_\_cxx11::basic\_string\<char, std::char\_traits, std::allocator \> const&, cling::CompilationOptions, cling::Value\*, cling::Transaction\*\*, unsigned long) + 0x15d from /home/shishi/packages/root/root\_install/lib/libCling.so  
0x00007f9f1f92f2fc in cling::Interpreter::process(std::\_\_cxx11::basic\_string\<char, std::char\_traits, std::allocator \> const&, cling::Value\*, cling::Transaction\*\*) + 0x13c from /home/shishi/packages/root/root\_install/lib/libCling.so  
0x00007f9f1f9be6df in cling::MetaProcessor::process(char const\*, cling::Interpreter::CompilationResult&, cling::Value\*) + 0x21f from /home/shishi/packages/root/root\_install/lib/libCling.so  
0x00007f9f1f89ae16 in from /home/shishi/packages/root/root\_install/lib/libCling.so  
0x00007f9f1f8ab0ad in TCling::ProcessLine(char const\*, TInterpreter::EErrorCode\*) at /home/shishi/packages/root/root-6.08.06/core/meta/src/TCling.cxx:2049 from /home/shishi/packages/root/root\_install/lib/libCling.so  
0x00007f9f2364c9c8 in TApplication::ProcessLine(char const\*, bool, int\*) at /home/shishi/packages/root/root-6.08.06/core/base/src/TApplication.cxx:1005 from /home/shishi/packages/root/root\_install/lib/libCore.so  
0x00007f9f23a9e3ce in TRint::ProcessLineNr(char const\*, char const\*, int\*) at /home/shishi/packages/root/root-6.08.06/core/rint/src/TRint.cxx:749 from /home/shishi/packages/root/root\_install/lib/libRint.so  
0x00007f9f23a9e71f in TRint::HandleTermInput() at /home/shishi/packages/root/root-6.08.06/core/rint/src/TRint.cxx:616 from /home/shishi/packages/root/root\_install/lib/libRint.so  
0x00007f9f2375a1ed in TUnixSystem::CheckDescriptors() at /home/shishi/packages/root/root-6.08.06/core/unix/src/TUnixSystem.cxx:1321 from /home/shishi/packages/root/root\_install/lib/libCore.so  
0x00007f9f2375b4bb in TUnixSystem::DispatchOneEvent(bool) at /home/shishi/packages/root/root-6.08.06/core/unix/src/TUnixSystem.cxx:1077 from /home/shishi/packages/root/root\_install/lib/libCore.so  
0x00007f9f236a83f4 in TSystem::InnerLoop() at /home/shishi/packages/root/root-6.08.06/core/base/src/TSystem.cxx:409 from /home/shishi/packages/root/root\_install/lib/libCore.so  
0x00007f9f236a700f in TSystem::Run() at /home/shishi/packages/root/root-6.08.06/core/base/src/TSystem.cxx:359 from /home/shishi/packages/root/root\_install/lib/libCore.so  
0x00007f9f23649f5f in TApplication::Run(bool) at /home/shishi/packages/root/root-6.08.06/core/base/src/TApplication.cxx:1158 from /home/shishi/packages/root/root\_install/lib/libCore.so  
0x00007f9f23a9fc3e in TRint::Run(bool) at /home/shishi/packages/root/root-6.08.06/core/rint/src/TRint.cxx:466 from /home/shishi/packages/root/root\_install/lib/libRint.so  
0x000055975bbc42fc in main + 0x4c from /home/shishi/packages/root/root\_install/bin/root.exe  
0x00007f9f226512e1 in \_\_libc\_start\_main + 0xf1 from /lib/x86\_64-linux-gnu/libc.so.6  
0x000055975bbc435a in \_start + 0x2a from /home/shishi/packages/root/root\_install/bin/root.exe

I only get the error when I try:

```auto
ggtheta->Fill(gamma1, gamma2, relative_angle_degrees); 

```

otherwise the code works okay.

---

<div class="post-metadata">

**Author:** ![jonas](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jonas/32/24756_2.png) [@jonas](https://root-forum.cern.ch/u/jonas)\
**Post date:** [March 11, 2024, 11:38am UTC](https://root-forum.cern.ch/t/tvectors3-angle-method/58483/4 "2024-03-11T11:38:59Z")

</div>

Looks like you have a messed up ROOT installation, like I can see for example at these lines here:

```auto
TRint::Run(bool) at ~/packages/root/root-6.08.06/core/rint/src/TRint.cxx:466 from ~/packages/root/root_install/lib/libRint.so
main + 0x4c from ~/packages/root/root_install/bin/root.exe
__libc_start_main + 0xf1 from /lib/x86_64-linux-gnu/libc.so.6
_start + 0x2a from ~/packages/root/root_install/bin/root.exe

```

You start ROOT from `root_install/bin`, but then it loads libraries from some very old ROOT version in `root/root-6.08.06`. Can that folder maybe be deleted, or can you avoid sourcing it in your environment?

---

<div class="post-metadata">

**Author:** ![ShiShi1122](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/45deac/32.png) [@ShiShi1122](https://root-forum.cern.ch/u/ShiShi1122)\
**Post date:** [March 11, 2024, 8:22pm UTC](https://root-forum.cern.ch/t/tvectors3-angle-method/58483/5 "2024-03-11T20:22:42Z")

</div>

I do not have a choice on changing the root as I am working on some old shared cluster which has very old version of Debian. Is there any other way to fix it w/o changing the version?

---

<div class="post-metadata">

**Author:** ![jonas](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jonas/32/24756_2.png) [@jonas](https://root-forum.cern.ch/u/jonas)\
**Post date:** [March 11, 2024, 8:25pm UTC](https://root-forum.cern.ch/t/tvectors3-angle-method/58483/6 "2024-03-11T20:25:44Z")

</div>

Hi! You don’t have to change the version you are currently using. You should just make sure there is not also this old 6.08 version sourced in your environment (e.g. by deleting this folder, or renaming it for the moment if you are afraid to break someone elses workflow). Or maybe the path to it is set in `.bashrc` and you can remove the line there?

Sorry there is no other solution, if you have multiple ROOT library directories in the library path, things are bound to break.
