65 mf::LogError(
"ShowerTrackHitDirection") <<
"Initial track hits not set" << std::endl;
73 <<
"Start position not set, returning " << std::endl;
86 mf::LogError(
"ShowerTrackHitDirection") <<
"Initial track not set" << std::endl;
92 StartPosition = {Start_point.X(), Start_point.Y(), Start_point.Z()};
103 std::vector<art::Ptr<recob::Hit>> InitialTrackHits;
107 float sumX = 0, sumX2 = 0;
108 float sumY = 0, sumY2 = 0;
109 float sumZ = 0, sumZ2 = 0;
112 std::vector<art::Ptr<recob::SpacePoint>> intitaltrack_sp;
113 for (
auto const hit : InitialTrackHits) {
114 std::vector<art::Ptr<recob::SpacePoint>> sps = fmsp.at(
hit.key());
115 for (
auto const sp : sps) {
116 intitaltrack_sp.push_back(sp);
119 auto const pos = sp->position() - StartPosition;
120 if (pos.R() == 0) {
continue; }
123 sumX2 += pos.X() * pos.X();
125 sumY2 += pos.Y() * pos.Y();
127 sumZ2 += pos.Z() * pos.Z();
131 float NumSps = intitaltrack_sp.size();
132 auto const Mean =
geo::Vector_t{sumX / NumSps, sumY / NumSps, sumZ / NumSps}.Unit();
137 if (sumX2 / NumSps - ((sumX / NumSps) * ((sumX / NumSps))) > 0) {
138 RMSX = std::sqrt(sumX2 / NumSps - ((sumX / NumSps) * ((sumX / NumSps))));
140 if (sumY2 / NumSps - ((sumY / NumSps) * ((sumY / NumSps))) > 0) {
141 RMSY = std::sqrt(sumY2 / NumSps - ((sumY / NumSps) * ((sumY / NumSps))));
143 if (sumZ2 / NumSps - ((sumZ / NumSps) * ((sumZ / NumSps))) > 0) {
144 RMSZ = std::sqrt(sumZ2 / NumSps - ((sumZ / NumSps) * ((sumZ / NumSps))));
150 for (
auto const sp : intitaltrack_sp) {
151 auto const Direction = sp->position() - StartPosition;
163 Direction_Mean = Direction_Mean.Unit();
169 <<
"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.
Declaration of signal hit object.
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
Detector simulation of raw signals on wires.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
decltype(auto) get(T &&obj)
ADL-aware version of std::to_string.
const art::FindManyP< T1 > & GetFindManyP(const art::ValidHandle< std::vector< T2 >> &handle, const art::Event &evt, const art::InputTag &moduleTag)
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track: