Skip to content

Commit

Permalink
Add utility function to calculate tracks momentum
Browse files Browse the repository at this point in the history
  • Loading branch information
dudarboh committed Sep 12, 2022
1 parent a7b74eb commit 397f594
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions src/cpp/include/UTIL/TrackTools.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef UTIL_TrackTools_H
#define UTIL_TrackTools_H 1

#include "EVENT/Track.h"
#include <array>

namespace UTIL{
/** Extract track momentum from its track parameters and magnetic field
* @author Bohdan Dudar
* @version August 2022
*/
std::array<double, 3> getTrackMomentum(const EVENT::Track* track, double bz);
}

#endif
17 changes: 17 additions & 0 deletions src/cpp/src/UTIL/TrackTools.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include "UTIL/TrackTools.h"
#include <cmath>

namespace UTIL{
std::array<double, 3> getTrackMomentum(const EVENT::Track* track, double bz){
std::array<double, 3> 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;
}
}

0 comments on commit 397f594

Please sign in to comment.