All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
ShowerRecoTools::ShowerPFPVertexStartPosition Class Reference
Inheritance diagram for ShowerRecoTools::ShowerPFPVertexStartPosition:
ShowerRecoTools::IShowerTool

Public Member Functions

 ShowerPFPVertexStartPosition (const fhicl::ParameterSet &pset)
 
int CalculateElement (const art::Ptr< recob::PFParticle > &pfparticle, art::Event &Event, reco::shower::ShowerElementHolder &ShowerEleHolder) override
 
- Public Member Functions inherited from ShowerRecoTools::IShowerTool
 IShowerTool (const fhicl::ParameterSet &pset)
 
virtual ~IShowerTool () noexcept=default
 
int RunShowerTool (const art::Ptr< recob::PFParticle > &pfparticle, art::Event &Event, reco::shower::ShowerElementHolder &ShowerEleHolder, std::string evd_display_name_append="")
 
virtual void InitialiseProducers ()
 
void SetPtr (art::ProducesCollector *collector)
 
void InitaliseProducerPtr (reco::shower::ShowerProducedPtrsHolder &uniqueproducerPtrs)
 
virtual int AddAssociations (const art::Ptr< recob::PFParticle > &pfpPtr, art::Event &Event, reco::shower::ShowerElementHolder &ShowerEleHolder)
 

Private Attributes

art::InputTag fPFParticleLabel
 
int fVerbose
 
std::string fShowerStartPositionOutputLabel
 
std::string fShowerDirectionInputLabel
 

Additional Inherited Members

- Protected Member Functions inherited from ShowerRecoTools::IShowerTool
const shower::LArPandoraShowerAlgGetLArPandoraShowerAlg () const
 
template<class T >
art::Ptr< T > GetProducedElementPtr (std::string Name, reco::shower::ShowerElementHolder &ShowerEleHolder, int iter=-1)
 
template<class T >
void InitialiseProduct (std::string Name, std::string InstanceName="")
 
template<class T , class A , class B >
void AddSingle (A &a, B &b, std::string Name)
 
int GetVectorPtrSize (std::string Name)
 
void PrintPtrs ()
 
void PrintPtr (std::string Name)
 

Detailed Description

Definition at line 23 of file ShowerPFPVertexStartPosition_tool.cc.

Constructor & Destructor Documentation

ShowerRecoTools::ShowerPFPVertexStartPosition::ShowerPFPVertexStartPosition ( const fhicl::ParameterSet &  pset)

Definition at line 41 of file ShowerPFPVertexStartPosition_tool.cc.

42  : IShowerTool(pset.get<fhicl::ParameterSet>("BaseTools"))
43  , fPFParticleLabel(pset.get<art::InputTag>("PFParticleLabel"))
44  , fVerbose(pset.get<int>("Verbose"))
45  , fShowerStartPositionOutputLabel(pset.get<std::string>("ShowerStartPositionOutputLabel"))
46  , fShowerDirectionInputLabel(pset.get<std::string>("ShowerDirectionInputLabel"))
47  {}
IShowerTool(const fhicl::ParameterSet &pset)
Definition: IShowerTool.h:29

Member Function Documentation

int ShowerRecoTools::ShowerPFPVertexStartPosition::CalculateElement ( const art::Ptr< recob::PFParticle > &  pfparticle,
art::Event &  Event,
reco::shower::ShowerElementHolder ShowerEleHolder 
)
overridevirtual

Implements ShowerRecoTools::IShowerTool.

Definition at line 50 of file ShowerPFPVertexStartPosition_tool.cc.

53  {
54 
55  // Get the assocated pfParicle vertex PFParticles
56  auto const pfpHandle = Event.getValidHandle<std::vector<recob::PFParticle>>(fPFParticleLabel);
57 
58  const art::FindManyP<recob::Vertex>& fmv =
59  ShowerEleHolder.GetFindManyP<recob::Vertex>(pfpHandle, Event, fPFParticleLabel);
60  // art::FindManyP<recob::Vertex> fmv(pfpHandle, Event, fPFParticleLabel);
61  if (!fmv.isValid()) {
62  throw cet::exception("ShowerPFPVertexStartPosition")
63  << "Vertex and PF particle association is somehow not valid. Stopping";
64  }
65 
66  std::vector<art::Ptr<recob::Vertex>> vtx_cand;
67  try {
68  vtx_cand = fmv.at(pfparticle.key());
69  }
70  catch (...) {
71  if (fVerbose)
72  mf::LogError("ShowerPFPVertexStartPosition") << "PFP-Vertex assan not set, returning";
73  return 1;
74  }
75  //If there is more than one then fail becuase I don't think that this can be the case
76  if (vtx_cand.size() != 1) {
77  if (fVerbose)
78  mf::LogError("ShowerPFPVertexStartPosition")
79  << "Wrong number of vertices: " << vtx_cand.size() << ", returning";
80  return 1;
81  }
82 
83  //If there is only one vertex good news we just say that is the start of the shower.
84  if (vtx_cand.size() == 1) {
85  art::Ptr<recob::Vertex> StartPositionVertex = vtx_cand[0];
86  double xyz[3] = {-999, -999, -999};
87  StartPositionVertex->XYZ(xyz);
88  TVector3 ShowerStartPosition = {xyz[0], xyz[1], xyz[2]};
89  TVector3 ShowerStartPositionErr = {-999, -999, -999};
90  ShowerEleHolder.SetElement(
91  ShowerStartPosition, ShowerStartPositionErr, fShowerStartPositionOutputLabel);
92  return 0;
93  }
94 
95  //If we there have none then use the direction to find the neutrino vertex
96  if (ShowerEleHolder.CheckElement(fShowerDirectionInputLabel)) {
97 
98  TVector3 ShowerDirection = {-999, -999, -999};
99  ShowerEleHolder.GetElement(fShowerDirectionInputLabel, ShowerDirection);
100 
101  const art::FindManyP<recob::SpacePoint>& fmspp =
102  ShowerEleHolder.GetFindManyP<recob::SpacePoint>(pfpHandle, Event, fPFParticleLabel);
103 
104  //Get the spacepoints handle and the hit assoication
105  auto const spHandle = Event.getValidHandle<std::vector<recob::SpacePoint>>(fPFParticleLabel);
106  const art::FindManyP<recob::Hit>& fmh =
107  ShowerEleHolder.GetFindManyP<recob::Hit>(spHandle, Event, fPFParticleLabel);
108 
109  //Get the spacepoints
110  std::vector<art::Ptr<recob::SpacePoint>> spacePoints_pfp = fmspp.at(pfparticle.key());
111 
112  //Cannot continue if we have no spacepoints
113  if (spacePoints_pfp.empty()) { return 0; }
114 
115  //Get the Shower Center
116  auto const clockData =
117  art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(Event);
118  auto const detProp =
119  art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(Event, clockData);
120 
121  TVector3 ShowerCentre = IShowerTool::GetLArPandoraShowerAlg().ShowerCentre(
122  clockData, detProp, spacePoints_pfp, fmh);
123 
124  //Order the Hits from the shower centre. The most negative will be the start position.
126  spacePoints_pfp, ShowerCentre, ShowerDirection);
127 
128  //Set the start position.
129  TVector3 ShowerStartPosition =
131 
132  TVector3 ShowerStartPositionErr = {-999, -999, -999};
133  ShowerEleHolder.SetElement(
134  ShowerStartPosition, ShowerStartPositionErr, fShowerStartPositionOutputLabel);
135 
136  return 0;
137  }
138 
139  if (fVerbose)
140  mf::LogWarning("ShowerPFPVertexStartPosition")
141  << "Start Position has not been set yet. If you are not calculating the start position "
142  "again then maybe you should stop";
143  return 0;
144  }
void OrderShowerSpacePoints(std::vector< art::Ptr< recob::SpacePoint >> &showersps, TVector3 const &vertex, TVector3 const &direction) const
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)
Definition of vertex object for LArSoft.
Definition: Vertex.h:35
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
TVector3 SpacePointPosition(art::Ptr< recob::SpacePoint > const &sp) const

Member Data Documentation

art::InputTag ShowerRecoTools::ShowerPFPVertexStartPosition::fPFParticleLabel
private

Definition at line 35 of file ShowerPFPVertexStartPosition_tool.cc.

std::string ShowerRecoTools::ShowerPFPVertexStartPosition::fShowerDirectionInputLabel
private

Definition at line 38 of file ShowerPFPVertexStartPosition_tool.cc.

std::string ShowerRecoTools::ShowerPFPVertexStartPosition::fShowerStartPositionOutputLabel
private

Definition at line 37 of file ShowerPFPVertexStartPosition_tool.cc.

int ShowerRecoTools::ShowerPFPVertexStartPosition::fVerbose
private

Definition at line 36 of file ShowerPFPVertexStartPosition_tool.cc.


The documentation for this class was generated from the following file: