Public Member Functions | Private Attributes | List of all members
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 Attributes

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

Additional Inherited Members

- Private 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)
 
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 17 of file ShowerTrackSpacePointDirection_tool.cc.

Constructor & Destructor Documentation

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

Definition at line 40 of file ShowerTrackSpacePointDirection_tool.cc.

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

Implements ShowerRecoTools::IShowerTool.

Definition at line 51 of file ShowerTrackSpacePointDirection_tool.cc.

55  {
56 
57  //Check the Track Hits has been defined
58  if (!ShowerEleHolder.CheckElement(fInitialTrackSpacePointsInputLabel)) {
59  if (fVerbose)
60  mf::LogError("ShowerTrackSpacePointDirection")
61  << "Initial track spacepoints not set" << std::endl;
62  return 0;
63  }
64 
65  //Check the start position is set.
67  if (fVerbose)
68  mf::LogError("ShowerTrackSpacePointDirection")
69  << "Start position not set, returning " << std::endl;
70  return 0;
71  }
72 
73  //Get the start poistion
74  TVector3 StartPosition = {-999, -999, -999};
75  if (fUsePandoraVertex) {
76  ShowerEleHolder.GetElement(fShowerStartPositionInputLabel, StartPosition);
77  }
78  else {
79  //Check the Tracks has been defined
80  if (!ShowerEleHolder.CheckElement(fInitialTrackInputLabel)) {
81  if (fVerbose)
82  mf::LogError("ShowerTrackSpacePointDirection") << "Initial track not set" << std::endl;
83  return 0;
84  }
85  recob::Track InitialTrack;
86  ShowerEleHolder.GetElement(fInitialTrackInputLabel, InitialTrack);
87  geo::Point_t Start_point = InitialTrack.Start();
88  StartPosition = {Start_point.X(), Start_point.Y(), Start_point.Z()};
89  }
90 
91  //Get the initial track hits.
92  std::vector<art::Ptr<recob::SpacePoint>> intitaltrack_sp;
93  ShowerEleHolder.GetElement(fInitialTrackSpacePointsInputLabel, intitaltrack_sp);
94 
95  //Calculate the mean direction and the the standard deviation
96  float sumX = 0, sumX2 = 0;
97  float sumY = 0, sumY2 = 0;
98  float sumZ = 0, sumZ2 = 0;
99 
100  //Get the spacepoints associated to the track hit
101  for (auto const& sp : intitaltrack_sp) {
102 
103  //Get the direction relative to the start positon
104  TVector3 pos = IShowerTool::GetLArPandoraShowerAlg().SpacePointPosition(sp) - StartPosition;
105  if (pos.Mag() == 0) { continue; }
106 
107  sumX = pos.X();
108  sumX2 += pos.X() * pos.X();
109  sumY = pos.Y();
110  sumY2 += pos.Y() * pos.Y();
111  sumZ = pos.Z();
112  sumZ2 += pos.Z() * pos.Z();
113  }
114 
115  float NumSps = intitaltrack_sp.size();
116  TVector3 Mean = {sumX / NumSps, sumY / NumSps, sumZ / NumSps};
117  Mean = Mean.Unit();
118 
119  float RMSX = 999;
120  float RMSY = 999;
121  float RMSZ = 999;
122  if (sumX2 / NumSps - ((sumX / NumSps) * ((sumX / NumSps))) > 0) {
123  RMSX = std::sqrt(sumX2 / NumSps - ((sumX / NumSps) * ((sumX / NumSps))));
124  }
125  if (sumY2 / NumSps - ((sumY / NumSps) * ((sumY / NumSps))) > 0) {
126  RMSY = std::sqrt(sumY2 / NumSps - ((sumY / NumSps) * ((sumY / NumSps))));
127  }
128  if (sumZ2 / NumSps - ((sumZ / NumSps) * ((sumZ / NumSps))) > 0) {
129  RMSZ = std::sqrt(sumZ2 / NumSps - ((sumZ / NumSps) * ((sumZ / NumSps))));
130  }
131 
132  //Loop over the spacepoints and remove ones the relative direction is not within one sigma.
133  TVector3 Direction_Mean = {0, 0, 0};
134  int N = 0;
135  for (auto const sp : intitaltrack_sp) {
136  TVector3 Direction =
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.Mag() == 0) { continue; }
142  ++N;
143  Direction_Mean += Direction;
144  }
145  }
146 
147  if (N > 0) {
148  //Take the mean value
149  TVector3 Direction = Direction_Mean.Unit();
150  ShowerEleHolder.SetElement(Direction, 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  }
void SetElement(T &dataproduct, const std::string &Name, bool checktag=false)
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
T abs(T value)
Point_t const & Start() const
Access to track position at different points.
Definition: Track.h:123
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
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:184
Direction
Definition: AssnsIter.h:13
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
QTextStream & endl(QTextStream &s)
TVector3 SpacePointPosition(art::Ptr< recob::SpacePoint > const &sp) const

Member Data Documentation

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

Definition at line 36 of file ShowerTrackSpacePointDirection_tool.cc.

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

Definition at line 34 of file ShowerTrackSpacePointDirection_tool.cc.

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

Definition at line 37 of file ShowerTrackSpacePointDirection_tool.cc.

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

Definition at line 35 of file ShowerTrackSpacePointDirection_tool.cc.

bool ShowerRecoTools::ShowerTrackSpacePointDirection::fUsePandoraVertex
private

Definition at line 30 of file ShowerTrackSpacePointDirection_tool.cc.

int ShowerRecoTools::ShowerTrackSpacePointDirection::fVerbose
private

Definition at line 29 of file ShowerTrackSpacePointDirection_tool.cc.


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