LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
ShowerDirectionTopologyDecision_tool.cc
Go to the documentation of this file.
1 //############################################################################
2 //### Name: ShowerDirectionTopologyDecisionTool ###
3 //### Author: Dom Barker ###
4 //### Date: 13.05.19 ###
5 //### Description: Decision tool to pick direction based on angular ###
6 //### seperation of two candidate direction vectors ###
7 //############################################################################
8 
9 //Framework Includes
11 
12 //LArSoft Includes
14 
15 #include "Math/VectorUtil.h"
16 
17 namespace ShowerRecoTools {
18 
20 
21  public:
23 
24  //Generic Direction Finder
25  int CalculateElement(const art::Ptr<recob::PFParticle>& pfparticle,
26  art::Event& Event,
27  reco::shower::ShowerElementHolder& ShowerEleHolder) override;
28 
29  private:
30  int fVerbose;
31  float fAngleCut;
35  };
36 
38  const fhicl::ParameterSet& pset)
39  : IShowerTool(pset.get<fhicl::ParameterSet>("BaseTools"))
40  , fVerbose(pset.get<int>("Verbose"))
41  , fAngleCut(pset.get<float>("AngleCut"))
42  , fFirstDirectionInputLabel(pset.get<std::string>("FirstDirectionInputLabel"))
43  , fSecondDirectionInputLabel(pset.get<std::string>("SecondDirectionInputLabel"))
44  , fShowerDirectionOutputLabel(pset.get<std::string>("ShowerDirectionOutputLabel"))
45  {}
46 
48  const art::Ptr<recob::PFParticle>& pfparticle,
49  art::Event& Event,
50  reco::shower::ShowerElementHolder& ShowerEleHolder)
51  {
52 
53  //Check the relevent products
54  if (!ShowerEleHolder.CheckElement(fFirstDirectionInputLabel)) {
55  if (fVerbose)
56  mf::LogError("ShowerDirectionTopologyDecision")
57  << "fFirstDirectionInputLabel is is not set. Stopping.";
58  return 1;
59  }
60  if (!ShowerEleHolder.CheckElement(fSecondDirectionInputLabel)) {
61  if (fVerbose)
62  mf::LogError("ShowerDirectionTopologyDecision")
63  << "fSecondDirectionInputLabel is is not set. Stopping.";
64  return 1;
65  }
66 
67  //Get the relevent products
68  geo::Vector_t FirstShowerDirection;
69  geo::Vector_t FirstShowerDirectionError;
70  ShowerEleHolder.GetElementAndError(
71  fFirstDirectionInputLabel, FirstShowerDirection, FirstShowerDirectionError);
72 
73  geo::Vector_t SecondShowerDirection;
74  geo::Vector_t SecondShowerDirectionError;
75  ShowerEleHolder.GetElementAndError(
76  fSecondDirectionInputLabel, SecondShowerDirection, SecondShowerDirectionError);
77 
78  //Use the first tool if directions agree within the chosen angle
79  if (ROOT::Math::VectorUtil::Angle(FirstShowerDirection, SecondShowerDirection) < fAngleCut) {
80  ShowerEleHolder.SetElement(
81  FirstShowerDirection, FirstShowerDirectionError, fShowerDirectionOutputLabel);
82  }
83  else {
84  ShowerEleHolder.SetElement(
85  SecondShowerDirection, SecondShowerDirectionError, fShowerDirectionOutputLabel);
86  }
87  return 0;
88  }
89 }
90 
#define DEFINE_ART_CLASS_TOOL(tool)
Definition: ToolMacros.h:42
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
int CalculateElement(const art::Ptr< recob::PFParticle > &pfparticle, art::Event &Event, reco::shower::ShowerElementHolder &ShowerEleHolder) override
void SetElement(T &dataproduct, const std::string &Name, bool checktag=false)
STL namespace.
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
parameter set interface
bool CheckElement(const std::string &Name) const
decltype(auto) get(T &&obj)
ADL-aware version of std::to_string.
Definition: StdUtils.h:120
int GetElementAndError(const std::string &Name, T &Element, T2 &ElementErr) const