21 #include "TPrincipal.h" 73 mf::LogError(
"ShowerTrackPCA") <<
"Start Position not set. Stopping" << std::endl;
79 mf::LogError(
"ShowerTrackPCA") <<
"TrackSpacePoints not set, returning " << std::endl;
89 std::vector<art::Ptr<recob::SpacePoint>> trackSpacePoints;
95 mf::LogError(
"ShowerTrackPCA") <<
"Not enough spacepoints for PCA, returning " << std::endl;
99 auto const clockData =
106 auto Eigenvector =
ShowerPCAVector(clockData, detProp, trackSpacePoints, fmh, trackCentre);
111 auto const GeneralDir = (trackCentre - StartPositionVec).Unit();
114 double DotProduct = Eigenvector.Dot(GeneralDir);
117 if (DotProduct < 0) { Eigenvector *= -1.; }
134 TPrincipal pca(3,
"");
136 float TotalCharge = 0;
143 for (
auto& sp : sps) {
148 auto const sp_position = sp->position() - ShowerCentre;
162 wht *= std::sqrt(Charge / TotalCharge);
166 sp_coord[0] = sp_position.X() * wht;
167 sp_coord[1] = sp_position.Y() * wht;
168 sp_coord[2] = sp_position.Z() * wht;
171 pca.AddRow(sp_coord);
175 pca.MakePrincipals();
178 const TMatrixD* Eigenvectors = pca.GetEigenVectors();
180 return {(*Eigenvectors)[0][0], (*Eigenvectors)[1][0], (*Eigenvectors)[2][0]};
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)
double ElectronLifetime() const
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
double SpacePointTime(art::Ptr< recob::SpacePoint > const &sp, art::FindManyP< recob::Hit > const &fmh) const
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
bool CheckElement(const std::string &Name) const
int GetElement(const std::string &Name, T &Element) const
double SpacePointCharge(art::Ptr< recob::SpacePoint > const &sp, art::FindManyP< recob::Hit > const &fmh) const
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.
Contains all timing reference information for the detector.
geo::Point_t ShowerCentre(std::vector< art::Ptr< recob::SpacePoint >> const &showersps) const
2D representation of charge deposited in the TDC/wire plane
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.
const art::FindManyP< T1 > & GetFindManyP(const art::ValidHandle< std::vector< T2 >> &handle, const art::Event &evt, const art::InputTag &moduleTag)