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
14 
15 namespace ShowerRecoTools {
16 
18 
19  public:
21 
22  //Generic Direction Finder
23  int CalculateElement(const art::Ptr<recob::PFParticle>& pfparticle,
25  reco::shower::ShowerElementHolder& ShowerEleHolder) override;
26 
27  private:
28  //fcl parameters
30  int fVerbose;
35  };
36 
38  const fhicl::ParameterSet& pset)
39  : IShowerTool(pset.get<fhicl::ParameterSet>("BaseTools"))
40  , fPFParticleLabel(pset.get<art::InputTag>("PFParticleLabel"))
41  , fVerbose(pset.get<int>("Verbose"))
42  , fShowerStartPositionOutputLabel(pset.get<std::string>("ShowerStartPositionOutputLabel"))
43  , fShowerCentreInputLabel(pset.get<std::string>("ShowerCentreInputLabel"))
44  , fShowerDirectionInputLabel(pset.get<std::string>("ShowerDirectionInputLabel"))
45  , fShowerStartPositionInputLabel(pset.get<std::string>("ShowerStartPositionInputLabel"))
46  {}
47 
48  int
50  const art::Ptr<recob::PFParticle>& pfparticle,
51  art::Event& Event,
52  reco::shower::ShowerElementHolder& ShowerEleHolder)
53  {
54 
55  TVector3 ShowerCentre = {-999, -999, -999};
56 
57  //Get the start position and direction and center
58  if (!ShowerEleHolder.CheckElement(fShowerStartPositionInputLabel)) {
59  if (fVerbose)
60  mf::LogError("ShowerPCAPropergationStartPosition")
61  << "Start position not set, returning " << std::endl;
62  return 1;
63  }
64  if (!ShowerEleHolder.CheckElement(fShowerDirectionInputLabel)) {
65  if (fVerbose)
66  mf::LogError("ShowerPCAPropergationStartPosition")
67  << "Direction not set, returning " << std::endl;
68  return 1;
69  }
70  if (!ShowerEleHolder.CheckElement(fShowerCentreInputLabel)) {
71 
72  auto const clockData =
74  auto const detProp =
76 
77  // Get the assocated pfParicle vertex PFParticles
78  auto const pfpHandle = Event.getValidHandle<std::vector<recob::PFParticle>>(fPFParticleLabel);
79 
80  const art::FindManyP<recob::SpacePoint>& fmspp =
81  ShowerEleHolder.GetFindManyP<recob::SpacePoint>(pfpHandle, Event, fPFParticleLabel);
82 
83  //Get the spacepoints handle and the hit assoication
84  auto const spHandle = Event.getValidHandle<std::vector<recob::SpacePoint>>(fPFParticleLabel);
85 
86  const art::FindManyP<recob::Hit>& fmh =
87  ShowerEleHolder.GetFindManyP<recob::Hit>(spHandle, Event, fPFParticleLabel);
88 
89  //Spacepoints
90  std::vector<art::Ptr<recob::SpacePoint>> spacePoints_pfp = fmspp.at(pfparticle.key());
91 
92  //We cannot progress with no spacepoints.
93  if (spacePoints_pfp.empty()) return 1;
94 
95  //Get the shower center
97  clockData, detProp, spacePoints_pfp, fmh);
98  }
99  else {
100  ShowerEleHolder.GetElement(fShowerCentreInputLabel, ShowerCentre);
101  }
102 
103  TVector3 ShowerStartPosition = {-999, -999, -999};
104  ShowerEleHolder.GetElement(fShowerStartPositionInputLabel, ShowerStartPosition);
105 
106  TVector3 ShowerDirection = {-999, -999, -999};
107  ShowerEleHolder.GetElement(fShowerDirectionInputLabel, ShowerDirection);
108 
109  //Get the projection
110  double projection = ShowerDirection.Dot(ShowerStartPosition - ShowerCentre);
111 
112  //Get the position.
113  TVector3 ShowerNewStartPosition = projection * ShowerDirection + ShowerCentre;
114  TVector3 ShowerNewStartPositionErr = {-999, -999, -999};
115 
116  ShowerEleHolder.SetElement(
117  ShowerNewStartPosition, ShowerNewStartPositionErr, fShowerStartPositionOutputLabel);
118 
119  return 0;
120  }
121 
122 }
123 
#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
std::string string
Definition: nybbler.cc:12
void SetElement(T &dataproduct, const std::string &Name, bool checktag=false)
STL namespace.
const art::FindManyP< T1 > & GetFindManyP(const art::ValidHandle< std::vector< T2 > > &handle, const art::Event &evt, const art::InputTag &moduleTag)
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
key_type key() const noexcept
Definition: Ptr.h:216
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition: DataViewImpl.h:441
bool CheckElement(const std::string &Name) const
int GetElement(const std::string &Name, T &Element) const
const shower::LArPandoraShowerAlg & GetLArPandoraShowerAlg() const
Definition: IShowerTool.h:87
Definition: types.h:32
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 & get(AssnsNode< L, R, D > const &r)
Definition: AssnsNode.h:115
QTextStream & endl(QTextStream &s)