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

Public Member Functions

 ShowerTrackTrajToSpacePoint (const fhicl::ParameterSet &pset)
 
int CalculateElement (const art::Ptr< recob::PFParticle > &pfparticle, art::Event &Event, reco::shower::ShowerElementHolder &ShowerEleHolder) override
 
- Public 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="")
 
virtual void InitialiseProducers ()
 
void SetPtr (art::ProducesCollector *collector)
 
void InitaliseProducerPtr (reco::shower::ShowerProducedPtrsHolder &uniqueproducerPtrs)
 
virtual int AddAssociations (const art::Ptr< recob::PFParticle > &pfpPtr, art::Event &Event, reco::shower::ShowerElementHolder &ShowerEleHolder)
 

Private Attributes

float fMaxDist
 
art::InputTag fPFParticleLabel
 
int fVerbose
 
std::string fInitialTrackSpacePointsOutputLabel
 
std::string fInitialTrackHitsOutputLabel
 
std::string fInitialTrackInputTag
 
std::string fShowerStartPositionInputTag
 
std::string fInitialTrackSpacePointsInputTag
 

Additional Inherited Members

- Protected Member Functions inherited from ShowerRecoTools::IShowerTool
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)
 

Detailed Description

Definition at line 20 of file ShowerTrackTrajToSpacePoint_tool.cc.

Constructor & Destructor Documentation

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

Definition at line 43 of file ShowerTrackTrajToSpacePoint_tool.cc.

44  : IShowerTool(pset.get<fhicl::ParameterSet>("BaseTools"))
45  , fMaxDist(pset.get<float>("MaxDist"))
46  , fPFParticleLabel(pset.get<art::InputTag>("PFParticleLabel"))
47  , fVerbose(pset.get<int>("Verbose"))
49  pset.get<std::string>("InitialTrackSpacePointsOutputLabel"))
50  , fInitialTrackHitsOutputLabel(pset.get<std::string>("InitialTrackHitsOutputLabel"))
51  , fInitialTrackInputTag(pset.get<std::string>("InitialTrackInputTag"))
52  , fShowerStartPositionInputTag(pset.get<std::string>("ShowerStartPositionInputTag"))
53  , fInitialTrackSpacePointsInputTag(pset.get<std::string>("InitialTrackSpacePointsInputTag"))
54  {}
IShowerTool(const fhicl::ParameterSet &pset)
Definition: IShowerTool.h:29

Member Function Documentation

int ShowerRecoTools::ShowerTrackTrajToSpacePoint::CalculateElement ( const art::Ptr< recob::PFParticle > &  pfparticle,
art::Event &  Event,
reco::shower::ShowerElementHolder ShowerEleHolder 
)
overridevirtual

Implements ShowerRecoTools::IShowerTool.

Definition at line 57 of file ShowerTrackTrajToSpacePoint_tool.cc.

60  {
61 
62  //Check the Track has been defined
63  if (!ShowerEleHolder.CheckElement(fInitialTrackInputTag)) {
64  if (fVerbose)
65  mf::LogError("ShowerTrackTrajToSpacePoint") << "Initial track not set" << std::endl;
66  return 0;
67  }
68 
69  //Check the start position is set.
70  if (!ShowerEleHolder.CheckElement(fShowerStartPositionInputTag)) {
71  if (fVerbose)
72  mf::LogError("ShowerTrackTrajToSpacePoint")
73  << "Start position not set, returning " << std::endl;
74  return 0;
75  }
76 
77  //Check the Track Hits has been defined
78  if (!ShowerEleHolder.CheckElement(fInitialTrackSpacePointsInputTag)) {
79  if (fVerbose)
80  mf::LogError("ShowerTrackTrajToSpacePoint")
81  << "Initial track spacepoints not set" << std::endl;
82  return 0;
83  }
84 
85  //Get the start poistion
86  TVector3 ShowerStartPosition = {-999, -999, -999};
87  ShowerEleHolder.GetElement(fShowerStartPositionInputTag, ShowerStartPosition);
88 
89  //Get the initial track hits.
90  std::vector<art::Ptr<recob::SpacePoint>> intitaltrack_sp;
91  ShowerEleHolder.GetElement(fInitialTrackSpacePointsInputTag, intitaltrack_sp);
92 
93  //Get the track
94  recob::Track InitialTrack;
95  ShowerEleHolder.GetElement(fInitialTrackInputTag, InitialTrack);
96 
97  std::vector<art::Ptr<recob::SpacePoint>> new_intitaltrack_sp;
98  //Loop over the trajectory points
99  for (unsigned int traj = 0; traj < InitialTrack.NumberTrajectoryPoints(); ++traj) {
100 
101  //ignore bogus info.
102  auto flags = InitialTrack.FlagsAtPoint(traj);
103  if (flags.isSet(recob::TrajectoryPointFlagTraits::NoPoint)) { continue; }
104 
105  geo::Point_t TrajPositionPoint = InitialTrack.LocationAtPoint(traj);
106  TVector3 TrajPosition = {TrajPositionPoint.X(), TrajPositionPoint.Y(), TrajPositionPoint.Z()};
107 
108  geo::Point_t TrajPositionStartPoint = InitialTrack.LocationAtPoint(0);
109  TVector3 TrajPositionStart = {
110  TrajPositionStartPoint.X(), TrajPositionStartPoint.Y(), TrajPositionStartPoint.Z()};
111 
112  //Ignore values with 0 mag from the start position
113  if ((TrajPosition - TrajPositionStart).Mag() == 0) { continue; }
114  if ((TrajPosition - ShowerStartPosition).Mag() == 0) { continue; }
115 
116  float MinDist = 9999;
117  unsigned int index = 999;
118  for (unsigned int sp = 0; sp < intitaltrack_sp.size(); ++sp) {
119  //Find the spacepoint closest to the trajectory point.
120  art::Ptr<recob::SpacePoint> spacepoint = intitaltrack_sp[sp];
121  TVector3 pos =
122  IShowerTool::GetLArPandoraShowerAlg().SpacePointPosition(spacepoint) - TrajPosition;
123  if (pos.Mag() < MinDist && pos.Mag() < fMaxDist) {
124  MinDist = pos.Mag();
125  index = sp;
126  }
127  }
128 
129  if (index == 999) { continue; }
130  //Add the spacepoint to the track spacepoints.
131  new_intitaltrack_sp.push_back(intitaltrack_sp[index]);
132 
133  //Delete the spacepoint so it can not be used again.
134  intitaltrack_sp.erase(intitaltrack_sp.begin() + index);
135  }
136 
137  // Get the spacepoints
138  auto const spHandle = Event.getValidHandle<std::vector<recob::SpacePoint>>(fPFParticleLabel);
139 
140  // Get the hits associated with the space points
141  const art::FindOneP<recob::Hit>& fohsp =
142  ShowerEleHolder.GetFindOneP<recob::Hit>(spHandle, Event, fPFParticleLabel);
143 
144  //Save the corresponding hits
145  std::vector<art::Ptr<recob::Hit>> trackHits;
146  for (auto const& spacePoint : new_intitaltrack_sp) {
147  //Get the hits
148  const art::Ptr<recob::Hit> hit = fohsp.at(spacePoint.key());
149  trackHits.push_back(hit);
150  }
151 
152  //Save the spacepoints.
153  ShowerEleHolder.SetElement(new_intitaltrack_sp, fInitialTrackSpacePointsOutputLabel);
154  ShowerEleHolder.SetElement(trackHits, fInitialTrackHitsOutputLabel);
155 
156  return 0;
157  }
static constexpr Flag_t NoPoint
The trajectory point is not defined.
Point_t const & LocationAtPoint(size_t i) const
void SetElement(T &dataproduct, const std::string &Name, bool checktag=false)
size_t NumberTrajectoryPoints() const
Various functions related to the presence and the number of (valid) points.
const art::FindOneP< T1 > & GetFindOneP(const art::ValidHandle< std::vector< T2 > > &handle, const art::Event &evt, const art::InputTag &moduleTag)
process_name hit
Definition: cheaterreco.fcl:51
bool CheckElement(const std::string &Name) const
int GetElement(const std::string &Name, T &Element) const
const shower::LArPandoraShowerAlg & GetLArPandoraShowerAlg() const
Definition: IShowerTool.h:88
PointFlags_t const & FlagsAtPoint(size_t i) const
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:48
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:184
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a &quot;fitted&quot; track:
TVector3 SpacePointPosition(art::Ptr< recob::SpacePoint > const &sp) const

Member Data Documentation

std::string ShowerRecoTools::ShowerTrackTrajToSpacePoint::fInitialTrackHitsOutputLabel
private

Definition at line 37 of file ShowerTrackTrajToSpacePoint_tool.cc.

std::string ShowerRecoTools::ShowerTrackTrajToSpacePoint::fInitialTrackInputTag
private

Definition at line 38 of file ShowerTrackTrajToSpacePoint_tool.cc.

std::string ShowerRecoTools::ShowerTrackTrajToSpacePoint::fInitialTrackSpacePointsInputTag
private

Definition at line 40 of file ShowerTrackTrajToSpacePoint_tool.cc.

std::string ShowerRecoTools::ShowerTrackTrajToSpacePoint::fInitialTrackSpacePointsOutputLabel
private

Definition at line 36 of file ShowerTrackTrajToSpacePoint_tool.cc.

float ShowerRecoTools::ShowerTrackTrajToSpacePoint::fMaxDist
private

Definition at line 31 of file ShowerTrackTrajToSpacePoint_tool.cc.

art::InputTag ShowerRecoTools::ShowerTrackTrajToSpacePoint::fPFParticleLabel
private

Definition at line 33 of file ShowerTrackTrajToSpacePoint_tool.cc.

std::string ShowerRecoTools::ShowerTrackTrajToSpacePoint::fShowerStartPositionInputTag
private

Definition at line 39 of file ShowerTrackTrajToSpacePoint_tool.cc.

int ShowerRecoTools::ShowerTrackTrajToSpacePoint::fVerbose
private

Definition at line 34 of file ShowerTrackTrajToSpacePoint_tool.cc.


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