All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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
10 #include "art/Utilities/ToolMacros.h"
11 
12 //LArSoft Includes
14 
15 namespace ShowerRecoTools {
16 
18 
19  public:
20  ShowerDirectionTopologyDecisionTool(const fhicl::ParameterSet& pset);
21 
22  //Generic Direction Finder
23  int CalculateElement(const art::Ptr<recob::PFParticle>& pfparticle,
24  art::Event& Event,
25  reco::shower::ShowerElementHolder& ShowerEleHolder) override;
26 
27  private:
28  int fVerbose;
29  float fAngleCut;
33  };
34 
36  const fhicl::ParameterSet& pset)
37  : IShowerTool(pset.get<fhicl::ParameterSet>("BaseTools"))
38  , fVerbose(pset.get<int>("Verbose"))
39  , fAngleCut(pset.get<float>("AngleCut"))
40  , fFirstDirectionInputLabel(pset.get<std::string>("FirstDirectionInputLabel"))
41  , fSecondDirectionInputLabel(pset.get<std::string>("SecondDirectionInputLabel"))
42  , fShowerDirectionOutputLabel(pset.get<std::string>("ShowerDirectionOutputLabel"))
43  {}
44 
45  int
47  const art::Ptr<recob::PFParticle>& pfparticle,
48  art::Event& Event,
49  reco::shower::ShowerElementHolder& ShowerEleHolder)
50  {
51 
52  //Check the relevent products
53  if (!ShowerEleHolder.CheckElement(fFirstDirectionInputLabel)) {
54  if (fVerbose)
55  mf::LogError("ShowerDirectionTopologyDecision")
56  << "fFirstDirectionInputLabel is is not set. Stopping.";
57  return 1;
58  }
59  if (!ShowerEleHolder.CheckElement(fSecondDirectionInputLabel)) {
60  if (fVerbose)
61  mf::LogError("ShowerDirectionTopologyDecision")
62  << "fSecondDirectionInputLabel is is not set. Stopping.";
63  return 1;
64  }
65 
66  //Get the relevent products
67  TVector3 FirstShowerDirection;
68  TVector3 FirstShowerDirectionError;
69  ShowerEleHolder.GetElementAndError(
70  fFirstDirectionInputLabel, FirstShowerDirection, FirstShowerDirectionError);
71 
72  TVector3 SecondShowerDirection;
73  TVector3 SecondShowerDirectionError;
74  ShowerEleHolder.GetElementAndError(
75  fSecondDirectionInputLabel, SecondShowerDirection, SecondShowerDirectionError);
76 
77  //Use the first tool if directions agree within the chosen angle
78  if (FirstShowerDirection.Angle(SecondShowerDirection) < fAngleCut) {
79  ShowerEleHolder.SetElement(
80  FirstShowerDirection, FirstShowerDirectionError, fShowerDirectionOutputLabel);
81  }
82  else {
83  ShowerEleHolder.SetElement(
84  SecondShowerDirection, SecondShowerDirectionError, fShowerDirectionOutputLabel);
85  }
86  return 0;
87  }
88 }
89 
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
void SetElement(T &dataproduct, const std::string &Name, bool checktag=false)
bool CheckElement(const std::string &Name) const
int GetElementAndError(const std::string &Name, T &Element, T2 &ElementErr) const