99 auto const pfpHandle = Event.getValidHandle<std::vector<recob::PFParticle>>(
fPFParticleLabel);
101 const art::FindManyP<recob::SpacePoint>& fmspp =
105 auto const spHandle = Event.getValidHandle<std::vector<recob::SpacePoint>>(
fPFParticleLabel);
107 const art::FindManyP<recob::Hit>& fmh =
111 std::vector<art::Ptr<recob::SpacePoint>> spacePoints_pfp = fmspp.at(pfparticle.key());
114 if (spacePoints_pfp.size() < 3) {
115 mf::LogWarning(
"ShowerPCADirection")
116 << spacePoints_pfp.size() <<
" spacepoints in shower, not calculating direction"
121 auto const clockData =
122 art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(Event);
124 art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(Event, clockData);
127 TVector3 ShowerCentre;
132 TVector3 ShowerCentreErr = {-999, -999, -999};
140 mf::LogError(
"ShowerPCADirection")
141 <<
"fUseStartPosition is set but ShowerStartPosition is not set. Bailing" << std::endl;
145 TVector3 StartPositionVec = {-999, -999, -999};
149 TVector3 GeneralDir = (ShowerCentre - StartPositionVec).Unit();
152 double DotProduct = PCADirection.Dot(GeneralDir);
155 if (DotProduct < 0) {
156 PCADirection[0] = -PCADirection[0];
157 PCADirection[1] = -PCADirection[1];
158 PCADirection[2] = -PCADirection[2];
162 TVector3 PCADirectionErr = {-999, -999, -999};
169 spacePoints_pfp, ShowerCentre, PCADirection,
fNSegments);
173 if (RMSGradient < -std::numeric_limits<double>::epsilon()) {
174 PCADirection[0] = -PCADirection[0];
175 PCADirection[1] = -PCADirection[1];
176 PCADirection[2] = -PCADirection[2];
180 TVector3 PCADirectionErr = {-999, -999, -999};
void SetElement(T &dataproduct, const std::string &Name, bool checktag=false)
const art::FindManyP< T1 > & GetFindManyP(const art::ValidHandle< std::vector< T2 > > &handle, const art::Event &evt, const art::InputTag &moduleTag)
double RMSShowerGradient(std::vector< art::Ptr< recob::SpacePoint >> &sps, const TVector3 &ShowerCentre, const TVector3 &Direction, const unsigned int nSegments) const
bool CheckElement(const std::string &Name) const
int GetElement(const std::string &Name, T &Element) const
2D representation of charge deposited in the TDC/wire plane