61 <<
"Initial track spacepoints not set" <<
std::endl;
69 <<
"Start position not set, returning " <<
std::endl;
74 TVector3 StartPosition = {-999, -999, -999};
88 StartPosition = {Start_point.X(), Start_point.Y(), Start_point.Z()};
92 std::vector<art::Ptr<recob::SpacePoint>> intitaltrack_sp;
96 float sumX = 0, sumX2 = 0;
97 float sumY = 0, sumY2 = 0;
98 float sumZ = 0, sumZ2 = 0;
101 for (
auto const& sp : intitaltrack_sp) {
105 if (pos.Mag() == 0) {
continue; }
108 sumX2 += pos.X() * pos.X();
110 sumY2 += pos.Y() * pos.Y();
112 sumZ2 += pos.Z() * pos.Z();
115 float NumSps = intitaltrack_sp.size();
116 TVector3 Mean = {sumX / NumSps, sumY / NumSps, sumZ / NumSps};
122 if (sumX2 / NumSps - ((sumX / NumSps) * ((sumX / NumSps))) > 0) {
123 RMSX = std::sqrt(sumX2 / NumSps - ((sumX / NumSps) * ((sumX / NumSps))));
125 if (sumY2 / NumSps - ((sumY / NumSps) * ((sumY / NumSps))) > 0) {
126 RMSY = std::sqrt(sumY2 / NumSps - ((sumY / NumSps) * ((sumY / NumSps))));
128 if (sumZ2 / NumSps - ((sumZ / NumSps) * ((sumZ / NumSps))) > 0) {
129 RMSZ = std::sqrt(sumZ2 / NumSps - ((sumZ / NumSps) * ((sumZ / NumSps))));
133 TVector3 Direction_Mean = {0, 0, 0};
135 for (
auto const sp : intitaltrack_sp) {
138 if ((
std::abs((Direction - Mean).
X()) < 1 * RMSX) &&
139 (
std::abs((Direction - Mean).
Y()) < 1 * RMSY) &&
140 (
std::abs((Direction - Mean).
Z()) < 1 * RMSZ)) {
141 if (Direction.Mag() == 0) {
continue; }
149 TVector3 Direction = Direction_Mean.Unit();
155 <<
"None of the points are within 1 sigma" <<
std::endl;
void SetElement(T &dataproduct, const std::string &Name, bool checktag=false)
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
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.
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
QTextStream & endl(QTextStream &s)
TVector3 SpacePointPosition(art::Ptr< recob::SpacePoint > const &sp) const