Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
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
10#include "art/Utilities/ToolMacros.h"
11
12//LArSoft Includes
14
15#include "lardataobj/RecoBase/Track.h"
16
17namespace ShowerRecoTools {
18
20
21 public:
22 ShowerTrackTrajPointDirection(const fhicl::ParameterSet& pset);
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
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);
80 if (flags.isSet(recob::TrajectoryPointFlagTraits::NoPoint)) {
81 if (fVerbose)
82 mf::LogError("ShowerTrackTrajPointDirection")
83 << "Bogus trajectory point bailing." << std::endl;
84 return 1;
85 }
86
87 geo::Vector_t Direction;
88 //Get the difference between the point and the start position.
89 if (fUsePositonInfo) {
90 //Get the start position.
91 geo::Point_t StartPosition;
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
int CalculateElement(const art::Ptr< recob::PFParticle > &pfparticle, art::Event &Event, reco::shower::ShowerElementHolder &ShowerEleHolder) override
int GetElement(const std::string &Name, T &Element) const
void SetElement(T &dataproduct, const std::string &Name, bool checktag=false)
bool CheckElement(const std::string &Name) const