LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
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
11 
12 //LArSoft Includes
19 
20 namespace ShowerRecoTools {
21 
23 
24  public:
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
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 
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 =
78  auto const detProp =
80 
81  // Get the assocated pfParicle vertex PFParticles
82  auto const pfpHandle = Event.getValidHandle<std::vector<recob::PFParticle>>(fPFParticleLabel);
83 
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 
#define DEFINE_ART_CLASS_TOOL(tool)
Definition: ToolMacros.h:42
int CalculateElement(const art::Ptr< recob::PFParticle > &pfparticle, art::Event &Event, reco::shower::ShowerElementHolder &ShowerEleHolder) override
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
Declaration of signal hit object.
void SetElement(T &dataproduct, const std::string &Name, bool checktag=false)
STL namespace.
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
parameter set interface
key_type key() const noexcept
Definition: Ptr.h:166
bool CheckElement(const std::string &Name) const
int GetElement(const std::string &Name, T &Element) const
const shower::LArPandoraShowerAlg & GetLArPandoraShowerAlg() const
Definition: IShowerTool.h:82
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
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
decltype(auto) get(T &&obj)
ADL-aware version of std::to_string.
Definition: StdUtils.h:120
geo::Point_t ShowerCentre(std::vector< art::Ptr< recob::SpacePoint >> const &showersps) const
Definition: MVAAlg.h:12
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:46
const art::FindManyP< T1 > & GetFindManyP(const art::ValidHandle< std::vector< T2 >> &handle, const art::Event &evt, const art::InputTag &moduleTag)