LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
ShowerRecoTools::Shower3DCylinderTrackHitFinder Class Reference
Inheritance diagram for ShowerRecoTools::Shower3DCylinderTrackHitFinder:
ShowerRecoTools::IShowerTool

Public Member Functions

 Shower3DCylinderTrackHitFinder (const fhicl::ParameterSet &pset)
 
int CalculateElement (const art::Ptr< recob::PFParticle > &pfparticle, art::Event &Event, reco::shower::ShowerElementHolder &ShowerEleHolder) override
 

Private Member Functions

std::vector< art::Ptr< recob::SpacePoint > > FindTrackSpacePoints (std::vector< art::Ptr< recob::SpacePoint >> &spacePoints, geo::Point_t const &showerStartPosition, geo::Vector_t const &showerDirection) const
 
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)
 
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)
 

Private Attributes

float fMaxProjectionDist
 
float fMaxPerpendicularDist
 
bool fForwardHitsOnly
 
art::InputTag fPFParticleLabel
 
int fVerbose
 
std::string fShowerStartPositionInputLabel
 
std::string fInitialTrackHitsOutputLabel
 
std::string fInitialTrackSpacePointsOutputLabel
 
std::string fShowerDirectionInputLabel
 

Detailed Description

Definition at line 22 of file Shower3DCylinderTrackHitFinder_tool.cc.

Constructor & Destructor Documentation

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

Definition at line 52 of file Shower3DCylinderTrackHitFinder_tool.cc.

53  : IShowerTool(pset.get<fhicl::ParameterSet>("BaseTools"))
54  , fMaxProjectionDist(pset.get<float>("MaxProjectionDist"))
55  , fMaxPerpendicularDist(pset.get<float>("MaxPerpendicularDist"))
56  , fForwardHitsOnly(pset.get<bool>("ForwardHitsOnly"))
57  , fPFParticleLabel(pset.get<art::InputTag>("PFParticleLabel"))
58  , fVerbose(pset.get<int>("Verbose"))
59  , fShowerStartPositionInputLabel(pset.get<std::string>("ShowerStartPositionInputLabel"))
60  , fInitialTrackHitsOutputLabel(pset.get<std::string>("InitialTrackHitsOutputLabel"))
62  pset.get<std::string>("InitialTrackSpacePointsOutputLabel"))
63  , fShowerDirectionInputLabel(pset.get<std::string>("ShowerDirectionInputLabel"))
64  {}
T get(std::string const &key) const
Definition: ParameterSet.h:314
IShowerTool(const fhicl::ParameterSet &pset)
Definition: IShowerTool.h:33

Member Function Documentation

virtual int ShowerRecoTools::IShowerTool::AddAssociations ( const art::Ptr< recob::PFParticle > &  pfpPtr,
art::Event Event,
reco::shower::ShowerElementHolder ShowerEleHolder 
)
inlinevirtualinherited
template<class T , class A , class B >
void ShowerRecoTools::IShowerTool::AddSingle ( A &  a,
B &  b,
std::string  Name 
)
inlineprotectedinherited

Definition at line 152 of file IShowerTool.h.

References reco::shower::ShowerProducedPtrsHolder::AddSingle().

153  {
154  UniquePtrs->AddSingle<T>(a, b, Name);
155  }
reco::shower::ShowerProducedPtrsHolder * UniquePtrs
Definition: IShowerTool.h:85
void AddSingle(A &a, B &b, const std::string &Name)
int ShowerRecoTools::Shower3DCylinderTrackHitFinder::CalculateElement ( const art::Ptr< recob::PFParticle > &  pfparticle,
art::Event Event,
reco::shower::ShowerElementHolder ShowerEleHolder 
)
overridevirtual

Implements ShowerRecoTools::IShowerTool.

Definition at line 66 of file Shower3DCylinderTrackHitFinder_tool.cc.

References reco::shower::ShowerElementHolder::CheckElement(), FindTrackSpacePoints(), fInitialTrackHitsOutputLabel, fInitialTrackSpacePointsOutputLabel, fPFParticleLabel, fShowerDirectionInputLabel, fShowerStartPositionInputLabel, fVerbose, reco::shower::ShowerElementHolder::GetElement(), reco::shower::ShowerElementHolder::GetFindManyP(), ShowerRecoTools::IShowerTool::GetLArPandoraShowerAlg(), art::ProductRetriever::getValidHandle(), art::Ptr< T >::key(), shower::LArPandoraShowerAlg::OrderShowerSpacePoints(), and reco::shower::ShowerElementHolder::SetElement().

70  {
71 
72  //This is all based on the shower vertex being known. If it is not lets not do the track
73  if (!ShowerEleHolder.CheckElement(fShowerStartPositionInputLabel)) {
74  if (fVerbose)
75  mf::LogError("Shower3DCylinderTrackHitFinder")
76  << "Start position not set, returning " << std::endl;
77  return 1;
78  }
79  if (!ShowerEleHolder.CheckElement("ShowerDirection")) {
80  if (fVerbose)
81  mf::LogError("Shower3DCylinderTrackHitFinder")
82  << "Direction not set, returning " << std::endl;
83  return 1;
84  }
85 
86  geo::Point_t ShowerStartPosition = {-999, -999, -999};
87  ShowerEleHolder.GetElement(fShowerStartPositionInputLabel, ShowerStartPosition);
88 
89  geo::Vector_t ShowerDirection = {-999, -999, -999};
90  ShowerEleHolder.GetElement(fShowerDirectionInputLabel, ShowerDirection);
91 
92  // Get the assocated pfParicle Handle
93  auto const pfpHandle = Event.getValidHandle<std::vector<recob::PFParticle>>(fPFParticleLabel);
94 
95  // Get the spacepoint - PFParticle assn
97  ShowerEleHolder.GetFindManyP<recob::SpacePoint>(pfpHandle, Event, fPFParticleLabel);
98 
99  // Get the spacepoints
100  auto const spHandle = Event.getValidHandle<std::vector<recob::SpacePoint>>(fPFParticleLabel);
101 
102  // Get the hits associated with the space points
103  const art::FindManyP<recob::Hit>& fmhsp =
104  ShowerEleHolder.GetFindManyP<recob::Hit>(spHandle, Event, fPFParticleLabel);
105 
106  // Get the SpacePoints
107  std::vector<art::Ptr<recob::SpacePoint>> spacePoints = fmspp.at(pfparticle.key());
108 
109  //We cannot progress with no spacepoints.
110  if (spacePoints.empty()) {
111  if (fVerbose)
112  mf::LogError("Shower3DCylinderTrackHitFinder")
113  << "No space points, returning " << std::endl;
114  return 1;
115  }
116 
117  // Order the spacepoints
119  spacePoints, ShowerStartPosition, ShowerDirection);
120 
121  // Get only the space points from the track
122  auto trackSpacePoints = FindTrackSpacePoints(spacePoints, ShowerStartPosition, ShowerDirection);
123 
124  // Get the hits associated to the space points and seperate them by planes
125  std::vector<art::Ptr<recob::Hit>> trackHits;
126  for (auto const& spacePoint : trackSpacePoints) {
127  const art::Ptr<recob::Hit> hit = fmhsp.at(spacePoint.key()).front();
128  // const art::Ptr<recob::Hit> hit = fohsp.at(spacePoint.key());
129  trackHits.push_back(hit);
130  }
131 
132  ShowerEleHolder.SetElement(trackHits, fInitialTrackHitsOutputLabel);
133  ShowerEleHolder.SetElement(trackSpacePoints, fInitialTrackSpacePointsOutputLabel);
134 
135  return 0;
136  }
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
void SetElement(T &dataproduct, const std::string &Name, bool checktag=false)
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
key_type key() const noexcept
Definition: Ptr.h:166
bool CheckElement(const std::string &Name) const
std::vector< art::Ptr< recob::SpacePoint > > FindTrackSpacePoints(std::vector< art::Ptr< recob::SpacePoint >> &spacePoints, geo::Point_t const &showerStartPosition, geo::Vector_t const &showerDirection) const
int GetElement(const std::string &Name, T &Element) const
Detector simulation of raw signals on wires.
const shower::LArPandoraShowerAlg & GetLArPandoraShowerAlg() const
Definition: IShowerTool.h:82
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:180
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
void OrderShowerSpacePoints(std::vector< art::Ptr< recob::SpacePoint >> &showersps, geo::Point_t const &vertex, geo::Vector_t const &direction) const
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:46
const art::FindManyP< T1 > & GetFindManyP(const art::ValidHandle< std::vector< T2 >> &handle, const art::Event &evt, const art::InputTag &moduleTag)
std::vector< art::Ptr< recob::SpacePoint > > ShowerRecoTools::Shower3DCylinderTrackHitFinder::FindTrackSpacePoints ( std::vector< art::Ptr< recob::SpacePoint >> &  spacePoints,
geo::Point_t const &  showerStartPosition,
geo::Vector_t const &  showerDirection 
) const
private

Definition at line 138 of file Shower3DCylinderTrackHitFinder_tool.cc.

References util::abs(), DEFINE_ART_CLASS_TOOL, fForwardHitsOnly, fMaxPerpendicularDist, fMaxProjectionDist, ShowerRecoTools::IShowerTool::GetLArPandoraShowerAlg(), proj, shower::LArPandoraShowerAlg::SpacePointPerpendicular(), and shower::LArPandoraShowerAlg::SpacePointProjection().

Referenced by CalculateElement().

142  {
143 
144  // Make a vector to hold the output space points
145  std::vector<art::Ptr<recob::SpacePoint>> trackSpacePoints;
146 
147  for (const auto& spacePoint : spacePoints) {
148  // Calculate the projection along direction and perpendicular distance
149  // from "axis" of shower TODO: change alg to return a pair for efficiency
151  spacePoint, showerStartPosition, showerDirection);
153  spacePoint, showerStartPosition, showerDirection, proj);
154 
155  if (fForwardHitsOnly && proj < 0) continue;
156 
158  trackSpacePoints.push_back(spacePoint);
159  }
160  return trackSpacePoints;
161  }
constexpr auto abs(T v)
Returns the absolute value of the argument.
double SpacePointPerpendicular(art::Ptr< recob::SpacePoint > const &sp, geo::Point_t const &vertex, geo::Vector_t const &direction) const
double SpacePointProjection(art::Ptr< recob::SpacePoint > const &sp, geo::Point_t const &vertex, geo::Vector_t const &direction) const
const shower::LArPandoraShowerAlg & GetLArPandoraShowerAlg() const
Definition: IShowerTool.h:82
Float_t proj
Definition: plot.C:35
const shower::LArPandoraShowerAlg& ShowerRecoTools::IShowerTool::GetLArPandoraShowerAlg ( ) const
inlineprotectedinherited
template<class T >
art::Ptr<T> ShowerRecoTools::IShowerTool::GetProducedElementPtr ( std::string  Name,
reco::shower::ShowerElementHolder ShowerEleHolder,
int  iter = -1 
)
inlineprotectedinherited

Definition at line 102 of file IShowerTool.h.

References reco::shower::ShowerElementHolder::CheckElement(), reco::shower::ShowerProducedPtrsHolder::CheckUniqueProduerPtr(), reco::shower::ShowerProducedPtrsHolder::GetArtPtr(), and reco::shower::ShowerElementHolder::GetShowerNumber().

105  {
106 
107  //Check the element has been set
108  bool check_element = ShowerEleHolder.CheckElement(Name);
109  if (!check_element) {
110  throw cet::exception("IShowerTool") << "tried to get a element that does not exist. Failed "
111  "at making the art ptr for Element: "
112  << Name << std::endl;
113  }
114 
115  //Check the unique ptr has been set.
116  bool check_ptr = UniquePtrs->CheckUniqueProduerPtr(Name);
117  if (!check_ptr) {
118  throw cet::exception("IShowerTool")
119  << "tried to get a ptr that does not exist. Failed at making the art ptr for Element"
120  << Name;
121  }
122 
123  //Check if the user has defined an index if not just use the current shower index/
124  int index;
125  if (iter != -1) { index = iter; }
126  else {
127  index = ShowerEleHolder.GetShowerNumber();
128  }
129 
130  //Make the ptr
131  return UniquePtrs->GetArtPtr<T>(Name, index);
132  }
reco::shower::ShowerProducedPtrsHolder * UniquePtrs
Definition: IShowerTool.h:85
bool CheckUniqueProduerPtr(const std::string &Name) const
bool CheckElement(const std::string &Name) const
art::Ptr< T > GetArtPtr(const std::string &Name, const int &iter) const
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
int ShowerRecoTools::IShowerTool::GetVectorPtrSize ( std::string  Name)
inlineprotectedinherited
void ShowerRecoTools::IShowerTool::InitaliseProducerPtr ( reco::shower::ShowerProducedPtrsHolder uniqueproducerPtrs)
inlineinherited

Definition at line 68 of file IShowerTool.h.

69  {
70  UniquePtrs = &uniqueproducerPtrs;
71  }
reco::shower::ShowerProducedPtrsHolder * UniquePtrs
Definition: IShowerTool.h:85
virtual void ShowerRecoTools::IShowerTool::InitialiseProducers ( )
inlinevirtualinherited
template<class T >
void ShowerRecoTools::IShowerTool::InitialiseProduct ( std::string  Name,
std::string  InstanceName = "" 
)
inlineprotectedinherited

Definition at line 137 of file IShowerTool.h.

References art::ProducesCollector::produces(), and reco::shower::ShowerProducedPtrsHolder::SetShowerUniqueProduerPtr().

138  {
139 
140  if (collectorPtr == nullptr) {
141  mf::LogWarning("IShowerTool") << "The art::ProducesCollector ptr has not been set";
142  return;
143  }
144 
145  collectorPtr->produces<T>(InstanceName);
146  UniquePtrs->SetShowerUniqueProduerPtr(type<T>(), Name, InstanceName);
147  }
reco::shower::ShowerProducedPtrsHolder * UniquePtrs
Definition: IShowerTool.h:85
art::ProducesCollector * collectorPtr
Definition: IShowerTool.h:97
void produces(std::string const &instanceName={}, Persistable const persistable=Persistable::Yes)
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
int SetShowerUniqueProduerPtr(type< T >, const std::string &Name, const std::string &Instance="")
void ShowerRecoTools::IShowerTool::PrintPtr ( std::string  Name)
inlineprotectedinherited

Definition at line 162 of file IShowerTool.h.

References reco::shower::ShowerProducedPtrsHolder::PrintPtr().

Referenced by ShowerRecoTools::ShowerExampleTool::CalculateElement().

162 { UniquePtrs->PrintPtr(Name); }
reco::shower::ShowerProducedPtrsHolder * UniquePtrs
Definition: IShowerTool.h:85
void PrintPtr(const std::string &Name) const
void ShowerRecoTools::IShowerTool::PrintPtrs ( )
inlineprotectedinherited
int ShowerRecoTools::IShowerTool::RunShowerTool ( const art::Ptr< recob::PFParticle > &  pfparticle,
art::Event Event,
reco::shower::ShowerElementHolder ShowerEleHolder,
std::string  evd_display_name_append = "" 
)
inlineinherited

Definition at line 46 of file IShowerTool.h.

50  {
51 
52  int calculation_status = CalculateElement(pfparticle, Event, ShowerEleHolder);
53  if (calculation_status != 0) return calculation_status;
54  if (fRunEventDisplay) {
56  pfparticle, Event, ShowerEleHolder, evd_display_name_append);
57  }
58  return calculation_status;
59  }
void DebugEVD(art::Ptr< recob::PFParticle > const &pfparticle, art::Event const &Event, const reco::shower::ShowerElementHolder &ShowerEleHolder, std::string const &evd_disp_name_append="") const
virtual int CalculateElement(const art::Ptr< recob::PFParticle > &pfparticle, art::Event &Event, reco::shower::ShowerElementHolder &ShowerEleHolder)=0
const shower::LArPandoraShowerAlg & GetLArPandoraShowerAlg() const
Definition: IShowerTool.h:82
void ShowerRecoTools::IShowerTool::SetPtr ( art::ProducesCollector collector)
inlineinherited

Definition at line 65 of file IShowerTool.h.

65 { collectorPtr = collector; }
art::ProducesCollector * collectorPtr
Definition: IShowerTool.h:97

Member Data Documentation

bool ShowerRecoTools::Shower3DCylinderTrackHitFinder::fForwardHitsOnly
private

Definition at line 40 of file Shower3DCylinderTrackHitFinder_tool.cc.

Referenced by FindTrackSpacePoints().

std::string ShowerRecoTools::Shower3DCylinderTrackHitFinder::fInitialTrackHitsOutputLabel
private

Definition at line 47 of file Shower3DCylinderTrackHitFinder_tool.cc.

Referenced by CalculateElement().

std::string ShowerRecoTools::Shower3DCylinderTrackHitFinder::fInitialTrackSpacePointsOutputLabel
private

Definition at line 48 of file Shower3DCylinderTrackHitFinder_tool.cc.

Referenced by CalculateElement().

float ShowerRecoTools::Shower3DCylinderTrackHitFinder::fMaxPerpendicularDist
private

Definition at line 39 of file Shower3DCylinderTrackHitFinder_tool.cc.

Referenced by FindTrackSpacePoints().

float ShowerRecoTools::Shower3DCylinderTrackHitFinder::fMaxProjectionDist
private

Definition at line 38 of file Shower3DCylinderTrackHitFinder_tool.cc.

Referenced by FindTrackSpacePoints().

art::InputTag ShowerRecoTools::Shower3DCylinderTrackHitFinder::fPFParticleLabel
private

Definition at line 43 of file Shower3DCylinderTrackHitFinder_tool.cc.

Referenced by CalculateElement().

std::string ShowerRecoTools::Shower3DCylinderTrackHitFinder::fShowerDirectionInputLabel
private

Definition at line 49 of file Shower3DCylinderTrackHitFinder_tool.cc.

Referenced by CalculateElement().

std::string ShowerRecoTools::Shower3DCylinderTrackHitFinder::fShowerStartPositionInputLabel
private

Definition at line 46 of file Shower3DCylinderTrackHitFinder_tool.cc.

Referenced by CalculateElement().

int ShowerRecoTools::Shower3DCylinderTrackHitFinder::fVerbose
private

Definition at line 44 of file Shower3DCylinderTrackHitFinder_tool.cc.

Referenced by CalculateElement().


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