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

Public Member Functions

 ShowerTrackDirection (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
 
bool fUsePositionInfo
 

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 19 of file ShowerTrackDirection_tool.cc.

Constructor & Destructor Documentation

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

Definition at line 40 of file ShowerTrackDirection_tool.cc.

41  : IShowerTool(pset.get<fhicl::ParameterSet>("BaseTools"))
42  , fVerbose(pset.get<int>("Verbose"))
43  , fUsePandoraVertex(pset.get<bool>("UsePandoraVertex"))
44  , fUsePositionInfo(pset.get<bool>("UsePositionInfo"))
45  {}
IShowerTool(const fhicl::ParameterSet &pset)
Definition: IShowerTool.h:29

Member Function Documentation

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

Implements ShowerRecoTools::IShowerTool.

Definition at line 48 of file ShowerTrackDirection_tool.cc.

51  {
52 
53  //Check the Track has been defined
54  if (!ShowerEleHolder.CheckElement("InitialTrack")) {
55  if (fVerbose) mf::LogError("ShowerTrackDirection") << "Initial track not set" << std::endl;
56  return 0;
57  }
58 
59  //Check the start position is set.
60  if (fUsePandoraVertex && !ShowerEleHolder.CheckElement("ShowerStartPosition")) {
61  if (fVerbose)
62  mf::LogError("ShowerTrackDirection") << "Start position not set, returning " << std::endl;
63  return 0;
64  }
65 
66  //Get the track
67  recob::Track InitialTrack;
68  ShowerEleHolder.GetElement("InitialTrack", InitialTrack);
69 
70  if (fUsePositionInfo) {
71  geo::Point_t StartPosition;
72  if (fUsePandoraVertex) {
73  TVector3 StartPosition_vec = {-999, -999, -999};
74  ShowerEleHolder.GetElement("ShowerStartPosition", StartPosition_vec);
75  StartPosition.SetCoordinates(
76  StartPosition_vec.X(), StartPosition_vec.Y(), StartPosition_vec.Z());
77  }
78  else {
79  StartPosition = InitialTrack.Start();
80  }
81 
82  //Calculate the mean direction and the the standard deviation
83  float sumX = 0, sumX2 = 0;
84  float sumY = 0, sumY2 = 0;
85  float sumZ = 0, sumZ2 = 0;
86  for (unsigned int traj = 0; traj < InitialTrack.NumberTrajectoryPoints(); ++traj) {
87 
88  //Ignore bogus flags.
89  auto flags = InitialTrack.FlagsAtPoint(traj);
92  continue;
93  }
94 
95  //Get the direction to the trajectory position.
96  geo::Vector_t TrajPosition = (InitialTrack.LocationAtPoint(traj) - StartPosition).Unit();
97  sumX += TrajPosition.X();
98  sumX2 += TrajPosition.X() * TrajPosition.X();
99  sumY += TrajPosition.Y();
100  sumY2 += TrajPosition.Y() * TrajPosition.Y();
101  sumZ += TrajPosition.Z();
102  sumZ2 += TrajPosition.Z() * TrajPosition.Z();
103  }
104 
105  float NumTraj = InitialTrack.NumberTrajectoryPoints();
106  geo::Vector_t Mean = {sumX / NumTraj, sumY / NumTraj, sumZ / NumTraj};
107  Mean = Mean.Unit();
108 
109  float RMSX = 999;
110  float RMSY = 999;
111  float RMSZ = 999;
112  if (sumX2 / NumTraj - ((sumX / NumTraj) * ((sumX / NumTraj))) > 0) {
113  RMSX = std::sqrt(sumX2 / NumTraj - ((sumX / NumTraj) * ((sumX / NumTraj))));
114  }
115  if (sumY2 / NumTraj - ((sumY / NumTraj) * ((sumY / NumTraj))) > 0) {
116  RMSY = std::sqrt(sumY2 / NumTraj - ((sumY / NumTraj) * ((sumY / NumTraj))));
117  }
118  if (sumZ2 / NumTraj - ((sumZ / NumTraj) * ((sumZ / NumTraj))) > 0) {
119  RMSZ = std::sqrt(sumZ2 / NumTraj - ((sumZ / NumTraj) * ((sumZ / NumTraj))));
120  }
121 
122  TVector3 Direction_Mean = {0, 0, 0};
123  int N = 0;
124  //Remove trajectory points from the mean that are not with one sigma.
125  for (unsigned int traj = 0; traj < InitialTrack.NumberTrajectoryPoints(); ++traj) {
126 
127  //Ignore bogus flags.
128  auto flags = InitialTrack.FlagsAtPoint(traj);
129  if (flags.isSet(recob::TrajectoryPointFlagTraits::NoPoint)) { continue; }
130 
131  //Get the direction of the trajectory point.
132  geo::Point_t TrajPosition = InitialTrack.LocationAtPoint(traj);
133  geo::Vector_t Direction = (TrajPosition - StartPosition).Unit();
134 
135  //Remove points not within 1RMS.
136  if ((std::abs((Direction - Mean).X()) < 1 * RMSX) &&
137  (std::abs((Direction - Mean).Y()) < 1 * RMSY) &&
138  (std::abs((Direction - Mean).Z()) < 1 * RMSZ)) {
139  TVector3 Direction_vec = {Direction.X(), Direction.Y(), Direction.Z()};
140  if (Direction_vec.Mag() == 0) { continue; }
141  Direction_Mean += Direction_vec;
142  ++N;
143  }
144  }
145 
146  //Take the mean value
147  if (N > 0) {
148  TVector3 Direction = Direction_Mean.Unit();
149  TVector3 DirectionErr = {RMSX, RMSY, RMSZ};
150  ShowerEleHolder.SetElement(Direction, DirectionErr, "ShowerDirection");
151  }
152  else {
153  if (fVerbose)
154  mf::LogError("ShowerTrackDirection")
155  << "None of the points are within 1 sigma" << std::endl;
156  return 1;
157  }
158 
159  return 0;
160  }
161  else { // if(fUsePositionInfo)
162 
163  float sumX = 0, sumX2 = 0;
164  float sumY = 0, sumY2 = 0;
165  float sumZ = 0, sumZ2 = 0;
166  for (unsigned int traj = 0; traj < InitialTrack.NumberTrajectoryPoints(); ++traj) {
167 
168  //Ignore bogus points
169  auto flags = InitialTrack.FlagsAtPoint(traj);
170  if (flags.isSet(recob::TrajectoryPointFlagTraits::NoPoint)) { continue; }
171 
172  //Get the direction.
173  geo::Vector_t Direction = InitialTrack.DirectionAtPoint(traj);
174  sumX += Direction.X();
175  sumX2 += Direction.X() * Direction.X();
176  sumY += Direction.Y();
177  sumY2 += Direction.Y() * Direction.Y();
178  sumZ += Direction.Z();
179  sumZ2 += Direction.Z() * Direction.Z();
180  }
181 
182  float NumTraj = InitialTrack.NumberTrajectoryPoints();
183  geo::Vector_t Mean = {sumX / NumTraj, sumY / NumTraj, sumZ / NumTraj};
184  Mean = Mean.Unit();
185 
186  float RMSX = 999;
187  float RMSY = 999;
188  float RMSZ = 999;
189  if (sumX2 / NumTraj - ((sumX / NumTraj) * ((sumX / NumTraj))) > 0) {
190  RMSX = std::sqrt(sumX2 / NumTraj - ((sumX / NumTraj) * ((sumX / NumTraj))));
191  }
192  if (sumY2 / NumTraj - ((sumY / NumTraj) * ((sumY / NumTraj))) > 0) {
193  RMSY = std::sqrt(sumY2 / NumTraj - ((sumY / NumTraj) * ((sumY / NumTraj))));
194  }
195  if (sumZ2 / NumTraj - ((sumZ / NumTraj) * ((sumZ / NumTraj))) > 0) {
196  RMSZ = std::sqrt(sumZ2 / NumTraj - ((sumZ / NumTraj) * ((sumZ / NumTraj))));
197  }
198 
199  //Remove trajectory points from the mean that are not with one sigma.
200  float N = 0.;
201  TVector3 Direction_Mean = {0, 0, 0};
202  for (unsigned int traj = 0; traj < InitialTrack.NumberTrajectoryPoints(); ++traj) {
203 
204  auto flags = InitialTrack.FlagsAtPoint(traj);
205  if (flags.isSet(recob::TrajectoryPointFlagTraits::NoPoint)) { continue; }
206 
207  geo::Vector_t Direction = InitialTrack.DirectionAtPoint(traj).Unit();
208  if ((std::abs((Direction - Mean).X()) < 1 * RMSX) &&
209  (std::abs((Direction - Mean).Y()) < 1 * RMSY) &&
210  (std::abs((Direction - Mean).Z()) < 1 * RMSZ)) {
211  TVector3 Direction_vec = {Direction.X(), Direction.Y(), Direction.Z()};
212  if (Direction_vec.Mag() == 0) { continue; }
213  Direction_Mean += Direction_vec;
214  ++N;
215  }
216  }
217 
218  //Take the mean value
219  if (N > 0) {
220  TVector3 Direction = Direction_Mean.Unit();
221  TVector3 DirectionErr = {RMSX, RMSY, RMSZ};
222  ShowerEleHolder.SetElement(Direction, DirectionErr, "ShowerDirection");
223  }
224  else {
225  if (fVerbose)
226  mf::LogError("ShowerTrackDirection")
227  << "None of the points are within 1 sigma" << std::endl;
228  return 1;
229  }
230  }
231  return 0;
232  }
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
Definition: geo_vectors.h:164
static constexpr Flag_t NoPoint
The trajectory point is not defined.
Point_t const & LocationAtPoint(size_t i) const
void SetElement(T &dataproduct, const std::string &Name, bool checktag=false)
size_t NumberTrajectoryPoints() const
Various functions related to the presence and the number of (valid) points.
then echo echo For and will not be changed by echo further linking echo echo B echo The symbol is in the uninitialized data multiple common symbols may appear with the echo same name If the symbol is defined the common echo symbols are treated as undefined references For more echo details on common see the discussion of warn common echo in *Note Linker see the discussion of warn common echo in *Note Linker such as a global int variable echo as opposed to a large global array echo echo I echo The symbol is an indirect reference to another symbol This echo is a GNU extension to the a out object file format which is echo rarely used echo echo N echo The symbol is a debugging symbol echo echo R echo The symbol is in a read only data section echo echo S echo The symbol is in an uninitialized data section for small echo objects echo echo T echo The symbol is in the the normal defined echo symbol is used with no error When a weak undefined symbol echo is linked and the symbol is not the value of the echo weak symbol becomes zero with no error echo echo W echo The symbol is a weak symbol that has not been specifically echo tagged as a weak object symbol When a weak defined symbol echo is linked with a normal defined the normal defined echo symbol is used with no error When a weak undefined symbol echo is linked and the symbol is not the value of the echo weak symbol becomes zero with no error echo echo echo The symbol is a stabs symbol in an a out object file In echo this the next values printed are the stabs other echo the stabs desc and the stab type Stabs symbols are echo used to hold debugging information For more echo see *Note or object file format specific echo echo For Mac OS X
T abs(T value)
Point_t const & Start() const
Access to track position at different points.
bool CheckElement(const std::string &Name) const
int GetElement(const std::string &Name, T &Element) const
static constexpr HitIndex_t InvalidHitIndex
Value marking an invalid hit index.
process_name largeant stream1 can override from command line with o or output physics producers generator N
PointFlags_t const & FlagsAtPoint(size_t i) const
Vector_t DirectionAtPoint(size_t i) 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:184
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a &quot;fitted&quot; track:

Member Data Documentation

bool ShowerRecoTools::ShowerTrackDirection::fUsePandoraVertex
private

Definition at line 32 of file ShowerTrackDirection_tool.cc.

bool ShowerRecoTools::ShowerTrackDirection::fUsePositionInfo
private

Definition at line 35 of file ShowerTrackDirection_tool.cc.

int ShowerRecoTools::ShowerTrackDirection::fVerbose
private

Definition at line 31 of file ShowerTrackDirection_tool.cc.


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