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 18 of file ShowerPFPVertexStartPosition_tool.cc.

Constructor & Destructor Documentation

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

Definition at line 36 of file ShowerPFPVertexStartPosition_tool.cc.

37  : IShowerTool(pset.get<fhicl::ParameterSet>("BaseTools"))
38  , fPFParticleLabel(pset.get<art::InputTag>("PFParticleLabel"))
39  , fVerbose(pset.get<int>("Verbose"))
40  , fShowerStartPositionOutputLabel(pset.get<std::string>("ShowerStartPositionOutputLabel"))
41  , fShowerDirectionInputLabel(pset.get<std::string>("ShowerDirectionInputLabel"))
42  {}
std::string string
Definition: nybbler.cc:12
T get(std::string const &key) const
Definition: ParameterSet.h:271
IShowerTool(const fhicl::ParameterSet &pset)
Definition: IShowerTool.h:28

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 45 of file ShowerPFPVertexStartPosition_tool.cc.

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

Member Data Documentation

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

Definition at line 30 of file ShowerPFPVertexStartPosition_tool.cc.

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

Definition at line 33 of file ShowerPFPVertexStartPosition_tool.cc.

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

Definition at line 32 of file ShowerPFPVertexStartPosition_tool.cc.

int ShowerRecoTools::ShowerPFPVertexStartPosition::fVerbose
private

Definition at line 31 of file ShowerPFPVertexStartPosition_tool.cc.


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