56 auto const pfpHandle = Event.getValidHandle<std::vector<recob::PFParticle>>(
fPFParticleLabel);
58 const art::FindManyP<recob::Vertex>& fmv =
62 throw cet::exception(
"ShowerPFPVertexStartPosition")
63 <<
"Vertex and PF particle association is somehow not valid. Stopping";
66 std::vector<art::Ptr<recob::Vertex>> vtx_cand;
68 vtx_cand = fmv.at(pfparticle.key());
72 mf::LogError(
"ShowerPFPVertexStartPosition") <<
"PFP-Vertex assan not set, returning";
76 if (vtx_cand.size() != 1) {
78 mf::LogError(
"ShowerPFPVertexStartPosition")
79 <<
"Wrong number of vertices: " << vtx_cand.size() <<
", returning";
84 if (vtx_cand.size() == 1) {
85 art::Ptr<recob::Vertex> StartPositionVertex = vtx_cand[0];
86 double xyz[3] = {-999, -999, -999};
87 StartPositionVertex->XYZ(xyz);
88 TVector3 ShowerStartPosition = {xyz[0], xyz[1], xyz[2]};
89 TVector3 ShowerStartPositionErr = {-999, -999, -999};
98 TVector3 ShowerDirection = {-999, -999, -999};
101 const art::FindManyP<recob::SpacePoint>& fmspp =
105 auto const spHandle = Event.getValidHandle<std::vector<recob::SpacePoint>>(
fPFParticleLabel);
106 const art::FindManyP<recob::Hit>& fmh =
110 std::vector<art::Ptr<recob::SpacePoint>> spacePoints_pfp = fmspp.at(pfparticle.key());
113 if (spacePoints_pfp.empty()) {
return 0; }
116 auto const clockData =
117 art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(Event);
119 art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(Event, clockData);
122 clockData,
detProp, spacePoints_pfp, fmh);
126 spacePoints_pfp, ShowerCentre, ShowerDirection);
129 TVector3 ShowerStartPosition =
132 TVector3 ShowerStartPositionErr = {-999, -999, -999};
140 mf::LogWarning(
"ShowerPFPVertexStartPosition")
141 <<
"Start Position has not been set yet. If you are not calculating the start position "
142 "again then maybe you should stop";
void OrderShowerSpacePoints(std::vector< art::Ptr< recob::SpacePoint >> &showersps, TVector3 const &vertex, TVector3 const &direction) const
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)
Definition of vertex object for LArSoft.
bool CheckElement(const std::string &Name) const
int GetElement(const std::string &Name, T &Element) const
TVector3 ShowerCentre(std::vector< art::Ptr< recob::SpacePoint >> const &showersps) const
2D representation of charge deposited in the TDC/wire plane
TVector3 SpacePointPosition(art::Ptr< recob::SpacePoint > const &sp) const