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

Public Member Functions

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

Private Member Functions

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

int fVerbose
 
bool fUsePandoraVertex
 
std::string fInitialTrackSpacePointsInputLabel
 
std::string fShowerStartPositionInputLabel
 
std::string fInitialTrackInputLabel
 
std::string fShowerDirectionOutputLabel
 

Detailed Description

Definition at line 20 of file ShowerTrackSpacePointDirection_tool.cc.

Constructor & Destructor Documentation

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

Definition at line 43 of file ShowerTrackSpacePointDirection_tool.cc.

44  : IShowerTool(pset.get<fhicl::ParameterSet>("BaseTools"))
45  , fVerbose(pset.get<int>("Verbose"))
46  , fUsePandoraVertex(pset.get<bool>("UsePandoraVertex"))
47  , fInitialTrackSpacePointsInputLabel(pset.get<std::string>("InitialTrackSpacePointsInputLabel"))
48  , fShowerStartPositionInputLabel(pset.get<std::string>("ShowerStartPositionInputLabel"))
49  , fInitialTrackInputLabel(pset.get<std::string>("InitialTrackInputLabel"))
50  , fShowerDirectionOutputLabel(pset.get<std::string>("ShowerDirectionOutputLabel"))
51  {}
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::ShowerTrackSpacePointDirection::CalculateElement ( const art::Ptr< recob::PFParticle > &  pfparticle,
art::Event Event,
reco::shower::ShowerElementHolder ShowerEleHolder 
)
overridevirtual

Implements ShowerRecoTools::IShowerTool.

Definition at line 53 of file ShowerTrackSpacePointDirection_tool.cc.

References util::abs(), reco::shower::ShowerElementHolder::CheckElement(), DEFINE_ART_CLASS_TOOL, fInitialTrackInputLabel, fInitialTrackSpacePointsInputLabel, fShowerDirectionOutputLabel, fShowerStartPositionInputLabel, fUsePandoraVertex, fVerbose, reco::shower::ShowerElementHolder::GetElement(), reco::shower::ShowerElementHolder::SetElement(), recob::Track::Start(), X, Y, and Z.

57  {
58 
59  //Check the Track Hits has been defined
60  if (!ShowerEleHolder.CheckElement(fInitialTrackSpacePointsInputLabel)) {
61  if (fVerbose)
62  mf::LogError("ShowerTrackSpacePointDirection")
63  << "Initial track spacepoints not set" << std::endl;
64  return 0;
65  }
66 
67  //Check the start position is set.
69  if (fVerbose)
70  mf::LogError("ShowerTrackSpacePointDirection")
71  << "Start position not set, returning " << std::endl;
72  return 0;
73  }
74 
75  //Get the start poistion
76  geo::Point_t StartPosition = {-999, -999, -999};
77  if (fUsePandoraVertex) {
78  ShowerEleHolder.GetElement(fShowerStartPositionInputLabel, StartPosition);
79  }
80  else {
81  //Check the Tracks has been defined
82  if (!ShowerEleHolder.CheckElement(fInitialTrackInputLabel)) {
83  if (fVerbose)
84  mf::LogError("ShowerTrackSpacePointDirection") << "Initial track not set" << std::endl;
85  return 0;
86  }
87  recob::Track InitialTrack;
88  ShowerEleHolder.GetElement(fInitialTrackInputLabel, InitialTrack);
89  geo::Point_t Start_point = InitialTrack.Start();
90  StartPosition = {Start_point.X(), Start_point.Y(), Start_point.Z()};
91  }
92 
93  //Get the initial track hits.
94  std::vector<art::Ptr<recob::SpacePoint>> intitaltrack_sp;
95  ShowerEleHolder.GetElement(fInitialTrackSpacePointsInputLabel, intitaltrack_sp);
96 
97  //Calculate the mean direction and the the standard deviation
98  float sumX = 0, sumX2 = 0;
99  float sumY = 0, sumY2 = 0;
100  float sumZ = 0, sumZ2 = 0;
101 
102  //Get the spacepoints associated to the track hit
103  for (auto const& sp : intitaltrack_sp) {
104 
105  //Get the direction relative to the start positon
106  auto const pos = sp->position() - StartPosition;
107  if (pos.R() == 0) { continue; }
108 
109  sumX = pos.X();
110  sumX2 += pos.X() * pos.X();
111  sumY = pos.Y();
112  sumY2 += pos.Y() * pos.Y();
113  sumZ = pos.Z();
114  sumZ2 += pos.Z() * pos.Z();
115  }
116 
117  float NumSps = intitaltrack_sp.size();
118  auto const Mean = geo::Vector_t{sumX / NumSps, sumY / NumSps, sumZ / NumSps}.Unit();
119 
120  float RMSX = 999;
121  float RMSY = 999;
122  float RMSZ = 999;
123  if (sumX2 / NumSps - ((sumX / NumSps) * ((sumX / NumSps))) > 0) {
124  RMSX = std::sqrt(sumX2 / NumSps - ((sumX / NumSps) * ((sumX / NumSps))));
125  }
126  if (sumY2 / NumSps - ((sumY / NumSps) * ((sumY / NumSps))) > 0) {
127  RMSY = std::sqrt(sumY2 / NumSps - ((sumY / NumSps) * ((sumY / NumSps))));
128  }
129  if (sumZ2 / NumSps - ((sumZ / NumSps) * ((sumZ / NumSps))) > 0) {
130  RMSZ = std::sqrt(sumZ2 / NumSps - ((sumZ / NumSps) * ((sumZ / NumSps))));
131  }
132 
133  //Loop over the spacepoints and remove ones the relative direction is not within one sigma.
134  geo::Vector_t Direction_Mean = {0, 0, 0};
135  int N = 0;
136  for (auto const sp : intitaltrack_sp) {
137  auto const Direction = sp->position() - StartPosition;
138  if ((std::abs((Direction - Mean).X()) < 1 * RMSX) &&
139  (std::abs((Direction - Mean).Y()) < 1 * RMSY) &&
140  (std::abs((Direction - Mean).Z()) < 1 * RMSZ)) {
141  if (Direction.R() == 0) { continue; }
142  ++N;
143  Direction_Mean += Direction;
144  }
145  }
146 
147  if (N > 0) {
148  //Take the mean value
149  Direction_Mean = Direction_Mean.Unit();
150  ShowerEleHolder.SetElement(Direction_Mean, fShowerDirectionOutputLabel);
151  }
152  else {
153  if (fVerbose)
154  mf::LogError("ShowerTrackSpacePointDirection")
155  << "None of the points are within 1 sigma" << std::endl;
156  return 1;
157  }
158  return 0;
159  }
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
Float_t Y
Definition: plot.C:37
void SetElement(T &dataproduct, const std::string &Name, bool checktag=false)
constexpr auto abs(T v)
Returns the absolute value of the argument.
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
Float_t Z
Definition: plot.C:37
Point_t const & Start() const
Access to track position at different points.
Definition: Track.h:157
bool CheckElement(const std::string &Name) const
int GetElement(const std::string &Name, T &Element) const
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
Direction
Definition: types.h:12
Float_t X
Definition: plot.C:37
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
Definition: Track.h:49
const shower::LArPandoraShowerAlg& ShowerRecoTools::IShowerTool::GetLArPandoraShowerAlg ( ) const
inlineprotectedinherited

Definition at line 82 of file IShowerTool.h.

Referenced by ShowerRecoTools::ShowerLengthPercentile::CalculateElement(), ShowerRecoTools::ShowerUnidirectiondEdx::CalculateElement(), ShowerRecoTools::Shower3DCylinderTrackHitFinder::CalculateElement(), ShowerRecoTools::ShowerPCAPropergationStartPosition::CalculateElement(), ShowerRecoTools::Shower2DLinearRegressionTrackHitFinder::CalculateElement(), ShowerRecoTools::ShowerPFPVertexStartPosition::CalculateElement(), ShowerRecoTools::ShowerDirectionCheater::CalculateElement(), ShowerRecoTools::ShowerPCADirection::CalculateElement(), ShowerRecoTools::ShowerIncrementalTrackHitFinder::CalculateElement(), ShowerRecoTools::ShowerTrajPointdEdx::CalculateElement(), ShowerRecoTools::ShowerPCADirection::CalculateShowerPCA(), ShowerRecoTools::Shower2DLinearRegressionTrackHitFinder::FindInitialTrackHits(), ShowerRecoTools::Shower3DCylinderTrackHitFinder::FindTrackSpacePoints(), ShowerRecoTools::ShowerIncrementalTrackHitFinder::FitSegmentAndCalculateResidual(), ShowerRecoTools::ShowerIncrementalTrackHitFinder::PruneFrontOfSPSPool(), ShowerRecoTools::ShowerIncrementalTrackHitFinder::PruneTrack(), ShowerRecoTools::ShowerIncrementalTrackHitFinder::RunTestOfIncrementalSpacePointFinder(), ShowerRecoTools::ShowerTrackPCADirection::ShowerPCAVector(), and ShowerRecoTools::ShowerIncrementalTrackHitFinder::ShowerPCAVector().

83  {
84  return fLArPandoraShowerAlg;
85  };
shower::LArPandoraShowerAlg fLArPandoraShowerAlg
Definition: IShowerTool.h:92
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

std::string ShowerRecoTools::ShowerTrackSpacePointDirection::fInitialTrackInputLabel
private

Definition at line 39 of file ShowerTrackSpacePointDirection_tool.cc.

Referenced by CalculateElement().

std::string ShowerRecoTools::ShowerTrackSpacePointDirection::fInitialTrackSpacePointsInputLabel
private

Definition at line 37 of file ShowerTrackSpacePointDirection_tool.cc.

Referenced by CalculateElement().

std::string ShowerRecoTools::ShowerTrackSpacePointDirection::fShowerDirectionOutputLabel
private

Definition at line 40 of file ShowerTrackSpacePointDirection_tool.cc.

Referenced by CalculateElement().

std::string ShowerRecoTools::ShowerTrackSpacePointDirection::fShowerStartPositionInputLabel
private

Definition at line 38 of file ShowerTrackSpacePointDirection_tool.cc.

Referenced by CalculateElement().

bool ShowerRecoTools::ShowerTrackSpacePointDirection::fUsePandoraVertex
private

Definition at line 33 of file ShowerTrackSpacePointDirection_tool.cc.

Referenced by CalculateElement().

int ShowerRecoTools::ShowerTrackSpacePointDirection::fVerbose
private

Definition at line 32 of file ShowerTrackSpacePointDirection_tool.cc.

Referenced by CalculateElement().


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