diff --git a/src/cpp/CMakeLists.txt b/src/cpp/CMakeLists.txt index 640b6f3e7..a5d7f3cf2 100644 --- a/src/cpp/CMakeLists.txt +++ b/src/cpp/CMakeLists.txt @@ -120,6 +120,7 @@ SET( LCIO_UTIL_SRCS ./src/UTIL/PIDHandler.cc ./src/UTIL/ILDConf.cc ./src/UTIL/ProcessFlag.cc + ./src/UTIL/TrackTools.cc ) SET( LCIO_MT_SRCS diff --git a/src/cpp/include/UTIL/TrackTools.h b/src/cpp/include/UTIL/TrackTools.h new file mode 100644 index 000000000..234453663 --- /dev/null +++ b/src/cpp/include/UTIL/TrackTools.h @@ -0,0 +1,15 @@ +#ifndef UTIL_TrackTools_H +#define UTIL_TrackTools_H 1 + +#include "EVENT/Track.h" +#include + +namespace UTIL{ + /** Extract track momentum from its track parameters and magnetic field + * @author Bohdan Dudar + * @version August 2022 + */ + std::array getTrackMomentum(const EVENT::Track* track, double bz); +} + +#endif diff --git a/src/cpp/src/UTIL/TrackTools.cc b/src/cpp/src/UTIL/TrackTools.cc new file mode 100644 index 000000000..64394740c --- /dev/null +++ b/src/cpp/src/UTIL/TrackTools.cc @@ -0,0 +1,17 @@ +#include "UTIL/TrackTools.h" +#include + +namespace UTIL{ + std::array getTrackMomentum(const EVENT::Track* track, double bz){ + std::array mom; + double omega = track->getOmega(); + double phi = track->getPhi(); + double tanL = track->getTanLambda(); + double c_light = 299.792458; // mm/ns + double pt = (1e-6 * c_light * bz) / std::abs(omega); + mom[0] = pt*std::cos(phi); + mom[1] = pt*std::sin(phi); + mom[2] = pt*tanL; + return mom; + } +}