61 mf::LogError(
"ShowerTrackDirection") <<
"Start position not set, returning " << std::endl;
67 ShowerEleHolder.
GetElement(
"InitialTrack", InitialTrack);
73 StartPosition = InitialTrack.
Start();
77 float sumX = 0, sumX2 = 0;
78 float sumY = 0, sumY2 = 0;
79 float sumZ = 0, sumZ2 = 0;
91 sumX += TrajPosition.X();
92 sumX2 += TrajPosition.X() * TrajPosition.X();
93 sumY += TrajPosition.Y();
94 sumY2 += TrajPosition.Y() * TrajPosition.Y();
95 sumZ += TrajPosition.Z();
96 sumZ2 += TrajPosition.Z() * TrajPosition.Z();
100 geo::Vector_t Mean = {sumX / NumTraj, sumY / NumTraj, sumZ / NumTraj};
106 if (sumX2 / NumTraj - ((sumX / NumTraj) * ((sumX / NumTraj))) > 0) {
107 RMSX = std::sqrt(sumX2 / NumTraj - ((sumX / NumTraj) * ((sumX / NumTraj))));
109 if (sumY2 / NumTraj - ((sumY / NumTraj) * ((sumY / NumTraj))) > 0) {
110 RMSY = std::sqrt(sumY2 / NumTraj - ((sumY / NumTraj) * ((sumY / NumTraj))));
112 if (sumZ2 / NumTraj - ((sumZ / NumTraj) * ((sumZ / NumTraj))) > 0) {
113 RMSZ = std::sqrt(sumZ2 / NumTraj - ((sumZ / NumTraj) * ((sumZ / NumTraj))));
116 TVector3 Direction_Mean = {0, 0, 0};
130 if (
auto MeanSubtractedDir = Direction - Mean; (
std::abs(MeanSubtractedDir.X()) < RMSX) &&
131 (
std::abs(MeanSubtractedDir.Y()) < RMSY) &&
132 (
std::abs(MeanSubtractedDir.Z()) < RMSZ)) {
133 if (Direction.R() == 0) {
continue; }
134 Direction_Mean += geo::vect::convertTo<TVector3>(
Direction);
143 ShowerEleHolder.
SetElement(Direction, DirectionErr,
"ShowerDirection");
148 <<
"None of the points are within 1 sigma" << std::endl;
156 float sumX = 0, sumX2 = 0;
157 float sumY = 0, sumY2 = 0;
158 float sumZ = 0, sumZ2 = 0;
167 sumX += Direction.X();
168 sumX2 += Direction.X() * Direction.X();
169 sumY += Direction.Y();
170 sumY2 += Direction.Y() * Direction.Y();
171 sumZ += Direction.Z();
172 sumZ2 += Direction.Z() * Direction.Z();
176 geo::Vector_t Mean = {sumX / NumTraj, sumY / NumTraj, sumZ / NumTraj};
182 if (sumX2 / NumTraj - ((sumX / NumTraj) * ((sumX / NumTraj))) > 0) {
183 RMSX = std::sqrt(sumX2 / NumTraj - ((sumX / NumTraj) * ((sumX / NumTraj))));
185 if (sumY2 / NumTraj - ((sumY / NumTraj) * ((sumY / NumTraj))) > 0) {
186 RMSY = std::sqrt(sumY2 / NumTraj - ((sumY / NumTraj) * ((sumY / NumTraj))));
188 if (sumZ2 / NumTraj - ((sumZ / NumTraj) * ((sumZ / NumTraj))) > 0) {
189 RMSZ = std::sqrt(sumZ2 / NumTraj - ((sumZ / NumTraj) * ((sumZ / NumTraj))));
194 TVector3 Direction_Mean = {0, 0, 0};
201 if ((
std::abs((Direction - Mean).
X()) < 1 * RMSX) &&
202 (
std::abs((Direction - Mean).
Y()) < 1 * RMSY) &&
203 (
std::abs((Direction - Mean).
Z()) < 1 * RMSZ)) {
204 TVector3 Direction_vec = {Direction.X(), Direction.Y(), Direction.Z()};
205 if (Direction_vec.Mag() == 0) {
continue; }
206 Direction_Mean += Direction_vec;
215 ShowerEleHolder.
SetElement(Direction, DirectionErr,
"ShowerDirection");
220 <<
"None of the points are within 1 sigma" << std::endl;
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
static constexpr Flag_t NoPoint
The trajectory point is not defined.
Point_t const & LocationAtPoint(size_t i) const
Access to track position at different points.
void SetElement(T &dataproduct, const std::string &Name, bool checktag=false)
size_t NumberTrajectoryPoints() const
Various functions related to the presence and the number of (valid) points.
constexpr auto abs(T v)
Returns the absolute value of the argument.
::geo::Vector_t toVector(Vector const &v)
Convert the specified vector into a geo::Vector_t.
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
Point_t const & Start() const
Access to track position at different points.
bool CheckElement(const std::string &Name) const
Provides recob::Track data product.
int GetElement(const std::string &Name, T &Element) const
static constexpr HitIndex_t InvalidHitIndex
Value marking an invalid hit index.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
decltype(auto) get(T &&obj)
ADL-aware version of std::to_string.
PointFlags_t const & FlagsAtPoint(size_t i) const
Access to i-th TrajectoryPoint or its Flags.
Vector_t DirectionAtPoint(size_t i) const
Access to track direction at different points.
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track: