10 #include "art/Utilities/ToolMacros.h"
21 #include "TPrincipal.h"
23 namespace ShowerRecoTools {
38 std::vector<art::Ptr<recob::SpacePoint>>& spacePoints_pfp,
39 const art::FindManyP<recob::Hit>& fmh,
40 TVector3& ShowerCentre);
56 , fPFParticleLabel(pset.
get<art::InputTag>(
"PFParticleLabel"))
57 , fHitModuleLabel(pset.
get<art::InputTag>(
"HitModuleLabel"))
58 , fVerbose(pset.
get<int>(
"Verbose"))
59 , fChargeWeighted(pset.
get<
bool>(
"ChargeWeighted"))
60 , fMinPCAPoints(pset.
get<unsigned int>(
"MinPCAPoints"))
61 , fShowerStartPositionInputLabel(pset.
get<
std::string>(
"ShowerStartPositionInputLabel"))
62 , fInitialTrackSpacePointsInputLabel(pset.
get<
std::string>(
"InitialTrackSpacePointsInputLabel"))
63 , fShowerDirectionOutputLabel(pset.
get<
std::string>(
"ShowerDirectionOutputLabel"))
74 mf::LogError(
"ShowerTrackPCA") <<
"Start Position not set. Stopping" << std::endl;
80 mf::LogError(
"ShowerTrackPCA") <<
"TrackSpacePoints not set, returning " << std::endl;
85 auto const spHandle = Event.getValidHandle<std::vector<recob::SpacePoint>>(
fPFParticleLabel);
87 const art::FindManyP<recob::Hit>& fmh =
90 std::vector<art::Ptr<recob::SpacePoint>> trackSpacePoints;
96 mf::LogError(
"ShowerTrackPCA") <<
"Not enough spacepoints for PCA, returning " << std::endl;
100 auto const clockData =
101 art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(Event);
103 art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(Event, clockData);
106 TVector3 trackCentre;
110 TVector3 StartPositionVec = {-999, -999, -999};
112 TVector3 GeneralDir = (trackCentre - StartPositionVec).Unit();
115 double DotProduct = Eigenvector.Dot(GeneralDir);
118 if (DotProduct < 0) {
119 Eigenvector[0] = -Eigenvector[0];
120 Eigenvector[1] = -Eigenvector[1];
121 Eigenvector[2] = -Eigenvector[2];
124 TVector3 EigenvectorErr = {-999, -999, -999};
136 const art::FindManyP<recob::Hit>& fmh,
137 TVector3& ShowerCentre)
141 TPrincipal* pca =
new TPrincipal(3,
"");
143 float TotalCharge = 0;
150 for (
auto& sp : sps) {
157 sp_position = sp_position - ShowerCentre;
171 wht *= std::sqrt(Charge / TotalCharge);
175 sp_coord[0] = sp_position.X() * wht;
176 sp_coord[1] = sp_position.Y() * wht;
177 sp_coord[2] = sp_position.Z() * wht;
180 pca->AddRow(sp_coord);
184 pca->MakePrincipals();
187 const TMatrixD* Eigenvectors = pca->GetEigenVectors();
189 TVector3 Eigenvector = {(*Eigenvectors)[0][0], (*Eigenvectors)[1][0], (*Eigenvectors)[2][0]};
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
Declaration of signal hit object.
void SetElement(T &dataproduct, const std::string &Name, bool checktag=false)
double ElectronLifetime() const
const art::FindManyP< T1 > & GetFindManyP(const art::ValidHandle< std::vector< T2 > > &handle, const art::Event &evt, const art::InputTag &moduleTag)
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
Contains all timing reference information for the detector.
TVector3 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.
TVector3 SpacePointPosition(art::Ptr< recob::SpacePoint > const &sp) const