63 <<
"Initial track spacepoints not set" << std::endl;
71 <<
"Start position not set, returning " << std::endl;
84 mf::LogError(
"ShowerTrackSpacePointDirection") <<
"Initial track not set" << std::endl;
90 StartPosition = {Start_point.X(), Start_point.Y(), Start_point.Z()};
94 std::vector<art::Ptr<recob::SpacePoint>> intitaltrack_sp;
98 float sumX = 0, sumX2 = 0;
99 float sumY = 0, sumY2 = 0;
100 float sumZ = 0, sumZ2 = 0;
103 for (
auto const& sp : intitaltrack_sp) {
106 auto const pos = sp->position() - StartPosition;
107 if (pos.R() == 0) {
continue; }
110 sumX2 += pos.X() * pos.X();
112 sumY2 += pos.Y() * pos.Y();
114 sumZ2 += pos.Z() * pos.Z();
117 float NumSps = intitaltrack_sp.size();
118 auto const Mean =
geo::Vector_t{sumX / NumSps, sumY / NumSps, sumZ / NumSps}.Unit();
123 if (sumX2 / NumSps - ((sumX / NumSps) * ((sumX / NumSps))) > 0) {
124 RMSX = std::sqrt(sumX2 / NumSps - ((sumX / NumSps) * ((sumX / NumSps))));
126 if (sumY2 / NumSps - ((sumY / NumSps) * ((sumY / NumSps))) > 0) {
127 RMSY = std::sqrt(sumY2 / NumSps - ((sumY / NumSps) * ((sumY / NumSps))));
129 if (sumZ2 / NumSps - ((sumZ / NumSps) * ((sumZ / NumSps))) > 0) {
130 RMSZ = std::sqrt(sumZ2 / NumSps - ((sumZ / NumSps) * ((sumZ / NumSps))));
136 for (
auto const sp : intitaltrack_sp) {
137 auto const Direction = sp->position() - StartPosition;
149 Direction_Mean = Direction_Mean.Unit();
155 <<
"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.
void SetElement(T &dataproduct, const std::string &Name, bool checktag=false)
constexpr auto abs(T v)
Returns the absolute value of the argument.
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
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.
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track: