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 18 of file ShowerTrackTrajToSpacePoint_tool.cc.

Constructor & Destructor Documentation

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

Definition at line 41 of file ShowerTrackTrajToSpacePoint_tool.cc.

42  : IShowerTool(pset.get<fhicl::ParameterSet>("BaseTools"))
43  , fMaxDist(pset.get<float>("MaxDist"))
44  , fPFParticleLabel(pset.get<art::InputTag>("PFParticleLabel"))
45  , fVerbose(pset.get<int>("Verbose"))
47  pset.get<std::string>("InitialTrackSpacePointsOutputLabel"))
48  , fInitialTrackHitsOutputLabel(pset.get<std::string>("InitialTrackHitsOutputLabel"))
49  , fInitialTrackInputTag(pset.get<std::string>("InitialTrackInputTag"))
50  , fShowerStartPositionInputTag(pset.get<std::string>("ShowerStartPositionInputTag"))
51  , fInitialTrackSpacePointsInputTag(pset.get<std::string>("InitialTrackSpacePointsInputTag"))
52  {}
std::string string
Definition: nybbler.cc:12
T get(std::string const &key) const
Definition: ParameterSet.h:271
IShowerTool(const fhicl::ParameterSet &pset)
Definition: IShowerTool.h:28

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 55 of file ShowerTrackTrajToSpacePoint_tool.cc.

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

Member Data Documentation

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

Definition at line 35 of file ShowerTrackTrajToSpacePoint_tool.cc.

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

Definition at line 36 of file ShowerTrackTrajToSpacePoint_tool.cc.

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

Definition at line 38 of file ShowerTrackTrajToSpacePoint_tool.cc.

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

Definition at line 34 of file ShowerTrackTrajToSpacePoint_tool.cc.

float ShowerRecoTools::ShowerTrackTrajToSpacePoint::fMaxDist
private

Definition at line 29 of file ShowerTrackTrajToSpacePoint_tool.cc.

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

Definition at line 31 of file ShowerTrackTrajToSpacePoint_tool.cc.

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

Definition at line 37 of file ShowerTrackTrajToSpacePoint_tool.cc.

int ShowerRecoTools::ShowerTrackTrajToSpacePoint::fVerbose
private

Definition at line 32 of file ShowerTrackTrajToSpacePoint_tool.cc.


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