Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
ShowerPCAPropergationStartPosition_tool.cc
Go to the documentation of this file.
1//############################################################################
2//### Name: ShowerPCAPropergationStartPosition ###
3//### Author: Dominic Barker ###
4//### Date: 20.09.19 ###
5//### Description: Get the start position by back propergating the PCA ###
6//### to the pandora vertex. ###
7//############################################################################
8
9//Framework Includes
10#include "art/Utilities/ToolMacros.h"
11
12//LArSoft Includes
13#include "lardata/DetectorInfoServices/DetectorClocksService.h"
14#include "lardata/DetectorInfoServices/DetectorPropertiesService.h"
15#include "lardataobj/RecoBase/Hit.h"
16#include "lardataobj/RecoBase/PFParticle.h"
17#include "lardataobj/RecoBase/SpacePoint.h"
19
20namespace ShowerRecoTools {
21
23
24 public:
25 ShowerPCAPropergationStartPosition(const fhicl::ParameterSet& pset);
26
27 //Generic Direction Finder
28 int CalculateElement(const art::Ptr<recob::PFParticle>& pfparticle,
29 art::Event& Event,
30 reco::shower::ShowerElementHolder& ShowerEleHolder) override;
31
32 private:
33 //fcl parameters
34 art::InputTag fPFParticleLabel;
40 };
41
43 const fhicl::ParameterSet& pset)
44 : IShowerTool(pset.get<fhicl::ParameterSet>("BaseTools"))
45 , fPFParticleLabel(pset.get<art::InputTag>("PFParticleLabel"))
46 , fVerbose(pset.get<int>("Verbose"))
47 , fShowerStartPositionOutputLabel(pset.get<std::string>("ShowerStartPositionOutputLabel"))
48 , fShowerCentreInputLabel(pset.get<std::string>("ShowerCentreInputLabel"))
49 , fShowerDirectionInputLabel(pset.get<std::string>("ShowerDirectionInputLabel"))
50 , fShowerStartPositionInputLabel(pset.get<std::string>("ShowerStartPositionInputLabel"))
51 {}
52
54 const art::Ptr<recob::PFParticle>& pfparticle,
55 art::Event& Event,
56 reco::shower::ShowerElementHolder& ShowerEleHolder)
57 {
58
59 geo::Point_t ShowerCentre = {-999, -999, -999};
60
61 //Get the start position and direction and center
62 if (!ShowerEleHolder.CheckElement(fShowerStartPositionInputLabel)) {
63 if (fVerbose)
64 mf::LogError("ShowerPCAPropergationStartPosition")
65 << "Start position not set, returning " << std::endl;
66 return 1;
67 }
68 if (!ShowerEleHolder.CheckElement(fShowerDirectionInputLabel)) {
69 if (fVerbose)
70 mf::LogError("ShowerPCAPropergationStartPosition")
71 << "Direction not set, returning " << std::endl;
72 return 1;
73 }
74 if (!ShowerEleHolder.CheckElement(fShowerCentreInputLabel)) {
75
76 auto const clockData =
77 art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(Event);
78 auto const detProp =
79 art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(Event, clockData);
80
81 // Get the assocated pfParicle vertex PFParticles
82 auto const pfpHandle = Event.getValidHandle<std::vector<recob::PFParticle>>(fPFParticleLabel);
83
84 const art::FindManyP<recob::SpacePoint>& fmspp =
85 ShowerEleHolder.GetFindManyP<recob::SpacePoint>(pfpHandle, Event, fPFParticleLabel);
86
87 //Get the spacepoints handle and the hit assoication
88 auto const spHandle = Event.getValidHandle<std::vector<recob::SpacePoint>>(fPFParticleLabel);
89
90 const art::FindManyP<recob::Hit>& fmh =
91 ShowerEleHolder.GetFindManyP<recob::Hit>(spHandle, Event, fPFParticleLabel);
92
93 //SpacePoints
94 std::vector<art::Ptr<recob::SpacePoint>> spacePoints_pfp = fmspp.at(pfparticle.key());
95
96 //We cannot progress with no spacepoints.
97 if (spacePoints_pfp.empty()) return 1;
98
99 //Get the shower center
101 clockData, detProp, spacePoints_pfp, fmh);
102 }
103 else {
104 ShowerEleHolder.GetElement(fShowerCentreInputLabel, ShowerCentre);
105 }
106
107 geo::Point_t ShowerStartPosition = {-999, -999, -999};
108 ShowerEleHolder.GetElement(fShowerStartPositionInputLabel, ShowerStartPosition);
109
110 geo::Vector_t ShowerDirection = {-999, -999, -999};
111 ShowerEleHolder.GetElement(fShowerDirectionInputLabel, ShowerDirection);
112
113 //Get the projection
114 double projection = ShowerDirection.Dot(ShowerStartPosition - ShowerCentre);
115
116 //Get the position.
117 auto ShowerNewStartPosition = projection * ShowerDirection + ShowerCentre;
118 geo::Point_t ShowerNewStartPositionErr = {-999, -999, -999};
119
120 ShowerEleHolder.SetElement(
121 ShowerNewStartPosition, ShowerNewStartPositionErr, fShowerStartPositionOutputLabel);
122
123 return 0;
124 }
125
126}
127
const shower::LArPandoraShowerAlg & GetLArPandoraShowerAlg() const
Definition IShowerTool.h:82
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
const art::FindManyP< T1 > & GetFindManyP(const art::ValidHandle< std::vector< T2 > > &handle, const art::Event &evt, const art::InputTag &moduleTag)
void SetElement(T &dataproduct, const std::string &Name, bool checktag=false)
bool CheckElement(const std::string &Name) const
geo::Point_t ShowerCentre(std::vector< art::Ptr< recob::SpacePoint > > const &showersps) const