LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
ShowerTrackTrajPointDirection_tool.cc
Go to the documentation of this file.
1 //############################################################################
2 //### Name: ShowerTrackTrajPointDirection ###
3 //### Author: Dominic Barker ###
4 //### Date: 13.05.19 ###
5 //### Description: Tool for finding the shower direction using the ###
6 //### first trajectory of the initial track ###
7 //############################################################################
8 
9 //Framework Includes
11 
12 //LArSoft Includes
14 
16 
17 namespace ShowerRecoTools {
18 
20 
21  public:
23 
24  //Calculate the direction from the inital track
25  int CalculateElement(const art::Ptr<recob::PFParticle>& pfparticle,
26  art::Event& Event,
27  reco::shower::ShowerElementHolder& ShowerEleHolder) override;
28 
29  private:
30  //fcl
31  int fVerbose;
32  bool fUsePandoraVertex; //Direction from point defined as
33  //(Position of traj point - Vertex) rather than
34  //(Position of traj point - Track Start Point).
35  bool fUsePositonInfo; //Don't use the direction At point rather than definition
36  //above.
37  //((Position of traj point + 1) - (Position of traj point).
38  int fTrajPoint; //Trajectory point to get the direction from.
39 
43  };
44 
46  : IShowerTool(pset.get<fhicl::ParameterSet>("BaseTools"))
47  , fVerbose(pset.get<int>("Verbose"))
48  , fUsePandoraVertex(pset.get<bool>("UsePandoraVertex"))
49  , fUsePositonInfo(pset.get<bool>("UsePositonInfo"))
50  , fTrajPoint(pset.get<int>("TrajPoint"))
51  , fInitialTrackInputLabel(pset.get<std::string>("InitialTrackInputLabel"))
52  , fShowerStartPositionInputLabel(pset.get<std::string>("ShowerStartPositionInputLabel"))
53  , fShowerDirectionOutputLabel(pset.get<std::string>("ShowerDirectionOutputLabel"))
54  {}
55 
57  const art::Ptr<recob::PFParticle>& pfparticle,
58  art::Event& Event,
59  reco::shower::ShowerElementHolder& ShowerEleHolder)
60  {
61 
62  //Check the Track has been defined
63  if (!ShowerEleHolder.CheckElement(fInitialTrackInputLabel)) {
64  if (fVerbose)
65  mf::LogError("ShowerTrackTrajPointDirection") << "Initial track not set" << std::endl;
66  return 1;
67  }
68  recob::Track InitialTrack;
69  ShowerEleHolder.GetElement(fInitialTrackInputLabel, InitialTrack);
70 
71  if ((int)InitialTrack.NumberTrajectoryPoints() - 1 < fTrajPoint) {
72  if (fVerbose)
73  mf::LogError("ShowerTrackTrajPointDirection")
74  << "Less that fTrajPoint trajectory points, bailing." << std::endl;
75  fTrajPoint = InitialTrack.NumberTrajectoryPoints() - 1;
76  }
77 
78  //ignore bogus info.
79  auto flags = InitialTrack.FlagsAtPoint(fTrajPoint);
81  if (fVerbose)
82  mf::LogError("ShowerTrackTrajPointDirection")
83  << "Bogus trajectory point bailing." << std::endl;
84  return 1;
85  }
86 
88  //Get the difference between the point and the start position.
89  if (fUsePositonInfo) {
90  //Get the start position.
91  geo::Point_t StartPosition;
92  if (fUsePandoraVertex) {
93  //Check the Track has been defined
94  if (!ShowerEleHolder.CheckElement(fShowerStartPositionInputLabel)) {
95  if (fVerbose)
96  mf::LogError("ShowerTrackTrajPointDirection")
97  << "Shower start position not set" << std::endl;
98  return 1;
99  }
100  ShowerEleHolder.GetElement(fShowerStartPositionInputLabel, StartPosition);
101  }
102  else {
103  StartPosition = InitialTrack.Start();
104  }
105  //Get the specific trajectory point and look and and the direction from the start position
106  geo::Point_t TrajPosition = InitialTrack.LocationAtPoint(fTrajPoint);
107  Direction = (TrajPosition - StartPosition).Unit();
108  }
109  else {
110  //Use the direction of the trajection at tat point;
111  Direction = InitialTrack.DirectionAtPoint(fTrajPoint);
112  }
113 
114  geo::Vector_t DirectionErr = {-999, -999, -999};
115  ShowerEleHolder.SetElement(Direction, DirectionErr, fShowerDirectionOutputLabel);
116  return 0;
117  }
118 }
119 
#define DEFINE_ART_CLASS_TOOL(tool)
Definition: ToolMacros.h:42
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
Definition: geo_vectors.h:160
static constexpr Flag_t NoPoint
The trajectory point is not defined.
Point_t const & LocationAtPoint(size_t i) const
Access to track position at different points.
Definition: Track.h:160
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:136
STL namespace.
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
Point_t const & Start() const
Access to track position at different points.
Definition: Track.h:157
parameter set interface
bool CheckElement(const std::string &Name) const
Provides recob::Track data product.
int GetElement(const std::string &Name, T &Element) const
int CalculateElement(const art::Ptr< recob::PFParticle > &pfparticle, art::Event &Event, reco::shower::ShowerElementHolder &ShowerEleHolder) override
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:180
decltype(auto) get(T &&obj)
ADL-aware version of std::to_string.
Definition: StdUtils.h:120
PointFlags_t const & FlagsAtPoint(size_t i) const
Access to i-th TrajectoryPoint or its Flags.
Definition: Track.h:152
Vector_t DirectionAtPoint(size_t i) const
Access to track direction at different points.
Definition: Track.h:168
Direction
Definition: types.h:12
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