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:
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:
ggtheta->Fill(gamma1, gamma2, relative_angle_degrees);
otherwise the code works okay.