All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ShowerRecoTools::ShowerPandoraSlidingFitTrackFinder Class Reference
Inheritance diagram for ShowerRecoTools::ShowerPandoraSlidingFitTrackFinder:
ShowerRecoTools::IShowerTool

Public Member Functions

 ShowerPandoraSlidingFitTrackFinder (const fhicl::ParameterSet &pset)
 
int CalculateElement (const art::Ptr< recob::PFParticle > &pfparticle, art::Event &Event, reco::shower::ShowerElementHolder &ShowerEleHolder) override
 

Private Member Functions

void InitialiseProducers () override
 
int AddAssociations (const art::Ptr< recob::PFParticle > &pfpPtr, art::Event &Event, reco::shower::ShowerElementHolder &ShowerEleHolder) override
 
- Private Member Functions inherited from ShowerRecoTools::IShowerTool
 IShowerTool (const fhicl::ParameterSet &pset)
 
virtual ~IShowerTool () noexcept=default
 
int RunShowerTool (const art::Ptr< recob::PFParticle > &pfparticle, art::Event &Event, reco::shower::ShowerElementHolder &ShowerEleHolder, std::string evd_display_name_append="")
 
void SetPtr (art::ProducesCollector *collector)
 
void InitaliseProducerPtr (reco::shower::ShowerProducedPtrsHolder &uniqueproducerPtrs)
 
const shower::LArPandoraShowerAlgGetLArPandoraShowerAlg () const
 
template<class T >
art::Ptr< T > GetProducedElementPtr (std::string Name, reco::shower::ShowerElementHolder &ShowerEleHolder, int iter=-1)
 
template<class T >
void InitialiseProduct (std::string Name, std::string InstanceName="")
 
template<class T , class A , class B >
void AddSingle (A &a, B &b, std::string Name)
 
int GetVectorPtrSize (std::string Name)
 
void PrintPtrs ()
 
void PrintPtr (std::string Name)
 

Private Attributes

art::ServiceHandle< geo::GeometryfGeom
 
int fVerbose
 
float fSlidingFitHalfWindow
 
float fMinTrajectoryPoints
 
std::string fInitialTrackOutputLabel
 
std::string fInitialTrackLengthOutputLabel
 
std::string fShowerStartPositionInputLabel
 
std::string fShowerDirectionInputLabel
 
std::string fInitialTrackSpacePointsInputLabel
 
std::string fInitialTrackHitsInputLabel
 

Detailed Description

Definition at line 27 of file ShowerPandoraSlidingFitTrackFinder_tool.cc.

Constructor & Destructor Documentation

ShowerRecoTools::ShowerPandoraSlidingFitTrackFinder::ShowerPandoraSlidingFitTrackFinder ( const fhicl::ParameterSet &  pset)

Definition at line 59 of file ShowerPandoraSlidingFitTrackFinder_tool.cc.

61  : IShowerTool(pset.get<fhicl::ParameterSet>("BaseTools"))
62  , fVerbose(pset.get<int>("Verbose"))
63  , fSlidingFitHalfWindow(pset.get<float>("SlidingFitHalfWindow"))
64  , fMinTrajectoryPoints(pset.get<float>("MinTrajectoryPoints"))
65  , fInitialTrackOutputLabel(pset.get<std::string>("InitialTrackOutputLabel"))
66  , fInitialTrackLengthOutputLabel(pset.get<std::string>("InitialTrackLengthOutputLabel"))
67  , fShowerStartPositionInputLabel(pset.get<std::string>("ShowerStartPositionInputLabel"))
68  , fShowerDirectionInputLabel(pset.get<std::string>("ShowerDirectionInputLabel"))
69  , fInitialTrackSpacePointsInputLabel(pset.get<std::string>("InitialTrackSpacePointsInputLabel"))
70  , fInitialTrackHitsInputLabel(pset.get<std::string>("InitialTrackHitsInputLabel"))
71  {}
IShowerTool(const fhicl::ParameterSet &pset)
Definition: IShowerTool.h:29

Member Function Documentation

int ShowerRecoTools::ShowerPandoraSlidingFitTrackFinder::AddAssociations ( const art::Ptr< recob::PFParticle > &  pfpPtr,
art::Event &  Event,
reco::shower::ShowerElementHolder ShowerEleHolder 
)
overrideprivatevirtual

Reimplemented from ShowerRecoTools::IShowerTool.

Definition at line 214 of file ShowerPandoraSlidingFitTrackFinder_tool.cc.

218  {
219 
220  //Check the track has been set
221  if (!ShowerEleHolder.CheckElement(fInitialTrackOutputLabel)) {
222  if (fVerbose)
223  mf::LogError("ShowerPandoraSlidingFitTrackFinderAddAssn")
224  << "Track not set so the assocation can not be made " << std::endl;
225  return 1;
226  }
227 
228  //Get the size of the ptr as it is.
229  int trackptrsize = GetVectorPtrSize(fInitialTrackOutputLabel);
230 
231  const art::Ptr<recob::Track> trackptr = GetProducedElementPtr<recob::Track>(
232  fInitialTrackOutputLabel, ShowerEleHolder, trackptrsize - 1);
233  const art::Ptr<recob::Shower> showerptr =
234  GetProducedElementPtr<recob::Shower>("shower", ShowerEleHolder);
235 
236  AddSingle<art::Assns<recob::Shower, recob::Track>>(showerptr, trackptr, "ShowerTrackAssn");
237 
238  std::vector<art::Ptr<recob::Hit>> TrackHits;
239  ShowerEleHolder.GetElement(fInitialTrackHitsInputLabel, TrackHits);
240 
241  for (auto const& TrackHit : TrackHits) {
242  AddSingle<art::Assns<recob::Track, recob::Hit>>(trackptr, TrackHit, "ShowerTrackHitAssn");
243  }
244 
245  return 0;
246  }
int GetVectorPtrSize(std::string Name)
Definition: IShowerTool.h:168
bool CheckElement(const std::string &Name) const
int ShowerRecoTools::ShowerPandoraSlidingFitTrackFinder::CalculateElement ( const art::Ptr< recob::PFParticle > &  pfparticle,
art::Event &  Event,
reco::shower::ShowerElementHolder ShowerEleHolder 
)
overridevirtual

Implements ShowerRecoTools::IShowerTool.

Definition at line 84 of file ShowerPandoraSlidingFitTrackFinder_tool.cc.

88  {
89  //This is all based on the shower vertex being known. If it is not lets not do the track
90  if (!ShowerEleHolder.CheckElement(fShowerStartPositionInputLabel)) {
91  if (fVerbose)
92  mf::LogError("ShowerPandoraSlidingFitTrackFinder")
93  << "Start position not set, returning " << std::endl;
94  return 1;
95  }
96  if (!ShowerEleHolder.CheckElement(fShowerDirectionInputLabel)) {
97  if (fVerbose)
98  mf::LogError("ShowerPandoraSlidingFitTrackFinder")
99  << "Direction not set, returning " << std::endl;
100  return 1;
101  }
102  if (!ShowerEleHolder.CheckElement(fInitialTrackSpacePointsInputLabel)) {
103  if (fVerbose)
104  mf::LogError("ShowerPandoraSlidingFitTrackFinder")
105  << "Initial Spacepoints not set, returning " << std::endl;
106  return 1;
107  }
108 
109  TVector3 ShowerStartPosition = {-999, -999, -999};
110  ShowerEleHolder.GetElement(fShowerStartPositionInputLabel, ShowerStartPosition);
111 
112  TVector3 ShowerDirection = {-999, -999, -999};
113  ShowerEleHolder.GetElement(fShowerDirectionInputLabel, ShowerDirection);
114 
115  std::vector<art::Ptr<recob::SpacePoint>> spacepoints;
116  ShowerEleHolder.GetElement(fInitialTrackSpacePointsInputLabel, spacepoints);
117 
118  // The track fitter tries to create a traj point from each spacepoint so if we don't have enough
119  // spacepoints we will not get enough traj points, so let's not even try
120  if (spacepoints.size() < fMinTrajectoryPoints) {
121  if (fVerbose)
122  mf::LogWarning("ShowerPandoraSlidingFitTrackFinder")
123  << "Insufficient space points points to build track: " << spacepoints.size();
124  return 1;
125  }
127  // 'wirePitchW` is here used only to provide length scale for binning hits and performing sliding/local linear fits.
128  const float wirePitchW(detType->WirePitchW());
129 
130  const pandora::CartesianVector vertexPosition(
131  ShowerStartPosition.X(), ShowerStartPosition.Y(), ShowerStartPosition.Z());
132 
133  pandora::CartesianPointVector cartesianPointVector;
134  for (const art::Ptr<recob::SpacePoint> spacePoint : spacepoints)
135  cartesianPointVector.emplace_back(
136  pandora::CartesianVector(spacePoint->XYZ()[0], spacePoint->XYZ()[1], spacePoint->XYZ()[2]));
137 
138  lar_content::LArTrackStateVector trackStateVector;
139  pandora::IntVector indexVector;
140  try {
142  vertexPosition,
144  wirePitchW,
145  trackStateVector,
146  &indexVector);
147  }
148  catch (const pandora::StatusCodeException&) {
149  if (fVerbose)
150  mf::LogWarning("ShowerPandoraSlidingFitTrackFinder")
151  << "Unable to extract sliding fit trajectory" << std::endl;
152  return 1;
153  }
154  if (trackStateVector.size() < fMinTrajectoryPoints) {
155  if (fVerbose)
156  mf::LogWarning("ShowerPandoraSlidingFitTrackFinder")
157  << "Insufficient input trajectory points to build track: " << trackStateVector.size();
158  return 1;
159  }
160 
161  if (trackStateVector.empty())
162  throw cet::exception("ShowerPandoraSlidingFitTrackFinder")
163  << "BuildTrack - No input trajectory points provided " << std::endl;
164 
168 
169  for (const lar_content::LArTrackState& trackState : trackStateVector) {
170  xyz.emplace_back(recob::tracking::Point_t(trackState.GetPosition().GetX(),
171  trackState.GetPosition().GetY(),
172  trackState.GetPosition().GetZ()));
173  pxpypz.emplace_back(recob::tracking::Vector_t(trackState.GetDirection().GetX(),
174  trackState.GetDirection().GetY(),
175  trackState.GetDirection().GetZ()));
176 
177  // Set flag NoPoint if point has bogus coordinates, otherwise use clean flag set
178  if (std::fabs(trackState.GetPosition().GetX() - util::kBogusF) <
179  std::numeric_limits<float>::epsilon() &&
180  std::fabs(trackState.GetPosition().GetY() - util::kBogusF) <
181  std::numeric_limits<float>::epsilon() &&
182  std::fabs(trackState.GetPosition().GetZ() - util::kBogusF) <
183  std::numeric_limits<float>::epsilon()) {
186  }
187  else {
188  flags.emplace_back(recob::TrajectoryPointFlags());
189  }
190  }
191 
192  // note from gc: eventually we should produce a TrackTrajectory, not a Track with empty covariance matrix and bogus chi2, etc.
193  recob::Track InitialTrack = recob::Track(
194  recob::TrackTrajectory(std::move(xyz), std::move(pxpypz), std::move(flags), false),
200  pfparticle.key());
201 
202  ShowerEleHolder.SetElement(InitialTrack, fInitialTrackOutputLabel);
203 
204  TVector3 Start = {InitialTrack.Start().X(), InitialTrack.Start().Y(), InitialTrack.Start().Z()};
205  TVector3 End = {InitialTrack.End().X(), InitialTrack.End().Y(), InitialTrack.End().Z()};
206  float tracklength = (Start - End).Mag();
207 
208  ShowerEleHolder.SetElement(tracklength, fInitialTrackLengthOutputLabel);
209 
210  return 0;
211  }
static constexpr Flag_t NoPoint
The trajectory point is not defined.
ROOT::Math::SMatrix< Double32_t, 5, 5, ROOT::Math::MatRepSym< Double32_t, 5 > > SMatrixSym55
Definition: TrackingTypes.h:85
LArTrackState class.
Definition: LArPfoObjects.h:29
Empty interface to map pandora to specifics in the LArSoft geometry.
void SetElement(T &dataproduct, const std::string &Name, bool checktag=false)
static void GetSlidingFitTrajectory(const pandora::CartesianPointVector &pointVector, const pandora::CartesianVector &vertexPosition, const unsigned int layerWindow, const float layerPitch, LArTrackStateVector &trackStateVector, pandora::IntVector *const pIndexVector=nullptr)
Apply 3D sliding fit to a set of 3D points and return track trajectory.
constexpr int kBogusI
obviously bogus integer value
std::vector< int > IntVector
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< Coord_t >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space. See recob::tracking::Coord_t for more details on the ...
Definition: TrackingTypes.h:29
Point_t const & Start() const
Access to track position at different points.
A trajectory in space reconstructed from hits.
bool CheckElement(const std::string &Name) const
std::vector< Vector_t > Momenta_t
Type of momentum list.
Definition: TrackingTypes.h:35
std::vector< PointFlags_t > Flags_t
Type of point flag list.
int GetElement(const std::string &Name, T &Element) const
static constexpr HitIndex_t InvalidHitIndex
Value marking an invalid hit index.
std::vector< Point_t > Positions_t
Type of trajectory point list.
Definition: TrackingTypes.h:32
LArPandoraDetectorType * GetDetectorType()
Factory class that returns the correct detector type interface.
constexpr float kBogusF
obviously bogus float value
Point_t const & End() const
TrackCollectionProxyElement< TrackCollProxy > Track
Proxy to an element of a proxy collection of recob::Track objects.
std::vector< LArTrackState > LArTrackStateVector
Definition: LArPfoObjects.h:67
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< Coord_t >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space. See recob::tracking::Coord_t for more detai...
Definition: TrackingTypes.h:26
Set of flags pertaining a point of the track.
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a &quot;fitted&quot; track:
void ShowerRecoTools::ShowerPandoraSlidingFitTrackFinder::InitialiseProducers ( )
overrideprivatevirtual

Reimplemented from ShowerRecoTools::IShowerTool.

Definition at line 74 of file ShowerPandoraSlidingFitTrackFinder_tool.cc.

75  {
76 
77  InitialiseProduct<std::vector<recob::Track>>(fInitialTrackOutputLabel);
78  InitialiseProduct<art::Assns<recob::Shower, recob::Track>>("ShowerTrackAssn");
79  InitialiseProduct<art::Assns<recob::Track, recob::Hit>>("ShowerTrackHitAssn");
80  }

Member Data Documentation

art::ServiceHandle<geo::Geometry> ShowerRecoTools::ShowerPandoraSlidingFitTrackFinder::fGeom
private

Definition at line 45 of file ShowerPandoraSlidingFitTrackFinder_tool.cc.

std::string ShowerRecoTools::ShowerPandoraSlidingFitTrackFinder::fInitialTrackHitsInputLabel
private

Definition at line 56 of file ShowerPandoraSlidingFitTrackFinder_tool.cc.

std::string ShowerRecoTools::ShowerPandoraSlidingFitTrackFinder::fInitialTrackLengthOutputLabel
private

Definition at line 52 of file ShowerPandoraSlidingFitTrackFinder_tool.cc.

std::string ShowerRecoTools::ShowerPandoraSlidingFitTrackFinder::fInitialTrackOutputLabel
private

Definition at line 51 of file ShowerPandoraSlidingFitTrackFinder_tool.cc.

std::string ShowerRecoTools::ShowerPandoraSlidingFitTrackFinder::fInitialTrackSpacePointsInputLabel
private

Definition at line 55 of file ShowerPandoraSlidingFitTrackFinder_tool.cc.

float ShowerRecoTools::ShowerPandoraSlidingFitTrackFinder::fMinTrajectoryPoints
private

Definition at line 50 of file ShowerPandoraSlidingFitTrackFinder_tool.cc.

std::string ShowerRecoTools::ShowerPandoraSlidingFitTrackFinder::fShowerDirectionInputLabel
private

Definition at line 54 of file ShowerPandoraSlidingFitTrackFinder_tool.cc.

std::string ShowerRecoTools::ShowerPandoraSlidingFitTrackFinder::fShowerStartPositionInputLabel
private

Definition at line 53 of file ShowerPandoraSlidingFitTrackFinder_tool.cc.

float ShowerRecoTools::ShowerPandoraSlidingFitTrackFinder::fSlidingFitHalfWindow
private

Definition at line 49 of file ShowerPandoraSlidingFitTrackFinder_tool.cc.

int ShowerRecoTools::ShowerPandoraSlidingFitTrackFinder::fVerbose
private

Definition at line 48 of file ShowerPandoraSlidingFitTrackFinder_tool.cc.


The documentation for this class was generated from the following file: