All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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
19 
20 namespace 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;
35  int fVerbose;
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 
53  int
55  const art::Ptr<recob::PFParticle>& pfparticle,
56  art::Event& Event,
57  reco::shower::ShowerElementHolder& ShowerEleHolder)
58  {
59 
60  TVector3 ShowerCentre = {-999, -999, -999};
61 
62  //Get the start position and direction and center
63  if (!ShowerEleHolder.CheckElement(fShowerStartPositionInputLabel)) {
64  if (fVerbose)
65  mf::LogError("ShowerPCAPropergationStartPosition")
66  << "Start position not set, returning " << std::endl;
67  return 1;
68  }
69  if (!ShowerEleHolder.CheckElement(fShowerDirectionInputLabel)) {
70  if (fVerbose)
71  mf::LogError("ShowerPCAPropergationStartPosition")
72  << "Direction not set, returning " << std::endl;
73  return 1;
74  }
75  if (!ShowerEleHolder.CheckElement(fShowerCentreInputLabel)) {
76 
77  auto const clockData =
78  art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(Event);
79  auto const detProp =
80  art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(Event, clockData);
81 
82  // Get the assocated pfParicle vertex PFParticles
83  auto const pfpHandle = Event.getValidHandle<std::vector<recob::PFParticle>>(fPFParticleLabel);
84 
85  const art::FindManyP<recob::SpacePoint>& fmspp =
86  ShowerEleHolder.GetFindManyP<recob::SpacePoint>(pfpHandle, Event, fPFParticleLabel);
87 
88  //Get the spacepoints handle and the hit assoication
89  auto const spHandle = Event.getValidHandle<std::vector<recob::SpacePoint>>(fPFParticleLabel);
90 
91  const art::FindManyP<recob::Hit>& fmh =
92  ShowerEleHolder.GetFindManyP<recob::Hit>(spHandle, Event, fPFParticleLabel);
93 
94  //SpacePoints
95  std::vector<art::Ptr<recob::SpacePoint>> spacePoints_pfp = fmspp.at(pfparticle.key());
96 
97  //We cannot progress with no spacepoints.
98  if (spacePoints_pfp.empty()) return 1;
99 
100  //Get the shower center
102  clockData, detProp, spacePoints_pfp, fmh);
103  }
104  else {
105  ShowerEleHolder.GetElement(fShowerCentreInputLabel, ShowerCentre);
106  }
107 
108  TVector3 ShowerStartPosition = {-999, -999, -999};
109  ShowerEleHolder.GetElement(fShowerStartPositionInputLabel, ShowerStartPosition);
110 
111  TVector3 ShowerDirection = {-999, -999, -999};
112  ShowerEleHolder.GetElement(fShowerDirectionInputLabel, ShowerDirection);
113 
114  //Get the projection
115  double projection = ShowerDirection.Dot(ShowerStartPosition - ShowerCentre);
116 
117  //Get the position.
118  TVector3 ShowerNewStartPosition = projection * ShowerDirection + ShowerCentre;
119  TVector3 ShowerNewStartPositionErr = {-999, -999, -999};
120 
121  ShowerEleHolder.SetElement(
122  ShowerNewStartPosition, ShowerNewStartPositionErr, fShowerStartPositionOutputLabel);
123 
124  return 0;
125  }
126 
127 }
128 
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
Definition: UtilFunc.cxx:42
int CalculateElement(const art::Ptr< recob::PFParticle > &pfparticle, art::Event &Event, reco::shower::ShowerElementHolder &ShowerEleHolder) override
Declaration of signal hit object.
void SetElement(T &dataproduct, const std::string &Name, bool checktag=false)
const art::FindManyP< T1 > & GetFindManyP(const art::ValidHandle< std::vector< T2 > > &handle, const art::Event &evt, const art::InputTag &moduleTag)
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
TVector3 ShowerCentre(std::vector< art::Ptr< recob::SpacePoint >> const &showersps) const
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:48
auto const detProp