LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
ThreeDHitCreationAlgorithm.h
Go to the documentation of this file.
1 
8 #ifndef LAR_THREE_D_HIT_CREATION_ALGORITHM_H
9 #define LAR_THREE_D_HIT_CREATION_ALGORITHM_H 1
10 
11 #include "Pandora/Algorithm.h"
12 #include "Pandora/AlgorithmTool.h"
13 
14 #include <vector>
15 
16 namespace lar_content
17 {
18 
19 class HitCreationBaseTool;
20 class ThreeDSlidingFitResult;
21 
22 //------------------------------------------------------------------------------------------------------------------------------------------
23 
27 class ThreeDHitCreationAlgorithm : public pandora::Algorithm
28 {
29 public:
34  {
35  public:
39  TrajectorySample(const pandora::CartesianVector &position, const pandora::HitType hitType, const double sigma);
40 
46  const pandora::CartesianVector &GetPosition() const;
47 
54 
60  double GetSigma() const;
61 
62  private:
63  pandora::CartesianVector m_position;
65  double m_sigma;
66  };
67 
68  typedef std::vector<TrajectorySample> TrajectorySampleVector;
69 
73  class ProtoHit
74  {
75  public:
81  ProtoHit(const pandora::CaloHit *const pParentCaloHit2D);
82 
88  const pandora::CaloHit *GetParentCaloHit2D() const;
89 
95  bool IsPositionSet() const;
96 
104  const pandora::CartesianVector &GetPosition3D() const;
105 
113  double GetChi2() const;
114 
120  unsigned int GetNTrajectorySamples() const;
121 
129  const TrajectorySample &GetFirstTrajectorySample() const;
130 
138  const TrajectorySample &GetLastTrajectorySample() const;
139 
146  void SetPosition3D(const pandora::CartesianVector &position3D, const double chi2);
147 
153  void AddTrajectorySample(const TrajectorySample &trajectorySample);
154 
155  private:
156  const pandora::CaloHit *m_pParentCaloHit2D;
158  pandora::CartesianVector m_position3D;
159  double m_chi2;
160  TrajectorySampleVector m_trajectorySampleVector;
161  };
162 
163  typedef std::vector<ProtoHit> ProtoHitVector;
164 
169 
178  const pandora::CaloHitVector &inputCaloHitVector, const pandora::HitType hitType, pandora::CaloHitVector &outputCaloHitVector) const;
179 
180 private:
181  pandora::StatusCode Run();
182 
190  void SeparateTwoDHits(const pandora::ParticleFlowObject *const pPfo, const ProtoHitVector &protoHitVector,
191  pandora::CaloHitVector &remainingHitVector) const;
192 
198  void IterativeTreatment(ProtoHitVector &protoHitVector) const;
199 
207  void ExtractResults(const ProtoHitVector &protoHitVector, double &chi2, pandora::CartesianPointVector &pointVector) const;
208 
217  double GetChi2WrtFit(const ThreeDSlidingFitResult &slidingFitResult, const ProtoHitVector &protoHitVector) const;
218 
226  double GetHitMovementChi2(const ProtoHitVector &protoHitVector) const;
227 
234  void RefineHitPositions(const ThreeDSlidingFitResult &slidingFitResult, ProtoHitVector &protoHitVector) const;
235 
242  void CreateThreeDHits(const ProtoHitVector &protoHitVector, pandora::CaloHitList &newThreeDHits) const;
243 
250  void CreateThreeDHit(const ProtoHit &protoHit, const pandora::CaloHit *&pCaloHit3D) const;
251 
259  bool CheckThreeDHit(const ProtoHit &protoHit) const;
260 
267  void AddThreeDHitsToPfo(const pandora::ParticleFlowObject *const pPfo, const pandora::CaloHitList &caloHitList) const;
268 
269  pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle);
270 
271  typedef std::vector<HitCreationBaseTool *> HitCreationToolVector;
272  HitCreationToolVector m_algorithmToolVector;
273 
274  std::string m_inputPfoListName;
277 
280  unsigned int m_slidingFitHalfWindow;
284 };
285 
286 //------------------------------------------------------------------------------------------------------------------------------------------
287 
289  const pandora::CartesianVector &position, const pandora::HitType hitType, const double sigma) :
290  m_position(position),
291  m_hitType(hitType),
292  m_sigma(sigma)
293 {
294 }
295 
296 //------------------------------------------------------------------------------------------------------------------------------------------
297 
298 inline const pandora::CartesianVector &ThreeDHitCreationAlgorithm::TrajectorySample::GetPosition() const
299 {
300  return m_position;
301 }
302 
303 //------------------------------------------------------------------------------------------------------------------------------------------
304 
306 {
307  return m_hitType;
308 }
309 
310 //------------------------------------------------------------------------------------------------------------------------------------------
311 
313 {
314  return m_sigma;
315 }
316 
317 //------------------------------------------------------------------------------------------------------------------------------------------
318 //------------------------------------------------------------------------------------------------------------------------------------------
319 
320 inline ThreeDHitCreationAlgorithm::ProtoHit::ProtoHit(const pandora::CaloHit *const pParentCaloHit2D) :
321  m_pParentCaloHit2D(pParentCaloHit2D),
322  m_isPositionSet(false),
323  m_position3D(0.f, 0.f, 0.f),
324  m_chi2(std::numeric_limits<double>::max())
325 {
326 }
327 
328 //------------------------------------------------------------------------------------------------------------------------------------------
329 
330 inline const pandora::CaloHit *ThreeDHitCreationAlgorithm::ProtoHit::GetParentCaloHit2D() const
331 {
332  return m_pParentCaloHit2D;
333 }
334 
335 //------------------------------------------------------------------------------------------------------------------------------------------
336 
338 {
339  return m_isPositionSet;
340 }
341 
342 //------------------------------------------------------------------------------------------------------------------------------------------
343 
345 {
346  return m_trajectorySampleVector.size();
347 }
348 
349 //------------------------------------------------------------------------------------------------------------------------------------------
350 
351 inline void ThreeDHitCreationAlgorithm::ProtoHit::SetPosition3D(const pandora::CartesianVector &position3D, const double chi2)
352 {
353  m_position3D = position3D;
354  m_chi2 = chi2;
355  m_isPositionSet = true;
356 }
357 
358 //------------------------------------------------------------------------------------------------------------------------------------------
359 
361 {
362  m_trajectorySampleVector.push_back(trajectorySample);
363 }
364 
365 } // namespace lar_content
366 
367 #endif // #ifndef LAR_THREE_D_HIT_CREATION_ALGORITHM_H
void IterativeTreatment(ProtoHitVector &protoHitVector) const
Improve initial 3D hits by fitting proto hits and iteratively creating consisted 3D hit trajectory...
const pandora::CaloHit * m_pParentCaloHit2D
The address of the parent 2D calo hit.
Proto hits are temporary constructs to be used during iterative 3D hit procedure. ...
ProtoHit(const pandora::CaloHit *const pParentCaloHit2D)
Constructor.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
std::string m_inputPfoListName
The name of the input pfo list.
unsigned int m_slidingFitHalfWindow
The sliding linear fit half window.
bool CheckThreeDHit(const ProtoHit &protoHit) const
Check that a new three dimensional position is not unphysical.
std::vector< TrajectorySample > TrajectorySampleVector
unsigned int GetNTrajectorySamples() const
Get the number of trajectory samples.
const pandora::CaloHit * GetParentCaloHit2D() const
Get the address of the parent 2D calo hit.
std::string m_outputCaloHitListName
The name of the output calo hit list.
void SeparateTwoDHits(const pandora::ParticleFlowObject *const pPfo, const ProtoHitVector &protoHitVector, pandora::CaloHitVector &remainingHitVector) const
Get the list of 2D calo hits in a pfo for which 3D hits have and have not been created.
STL namespace.
void RefineHitPositions(const ThreeDSlidingFitResult &slidingFitResult, ProtoHitVector &protoHitVector) const
Refine the 3D hit positions (and chi2) for a list of proto hits, in accordance with a provided 3D sli...
bool IsPositionSet() const
Whether the proto hit position is set.
void CreateThreeDHit(const ProtoHit &protoHit, const pandora::CaloHit *&pCaloHit3D) const
Create a new three dimensional hit from a two dimensional hit.
double GetHitMovementChi2(const ProtoHitVector &protoHitVector) const
Receive a chi2 value indicating consistency of a list of proto hits with the original, input hit positions.
void AddTrajectorySample(const TrajectorySample &trajectorySample)
Add a trajectory sample.
unsigned int m_nHitRefinementIterations
The maximum number of hit refinement iterations.
TFile f
Definition: plotHisto.C:6
pandora::CartesianVector m_position
The sampling position.
std::string m_outputClusterListName
The name of the output cluster list.
double GetChi2WrtFit(const ThreeDSlidingFitResult &slidingFitResult, const ProtoHitVector &protoHitVector) const
Receive a chi2 value indicating consistency of a list of proto hits with a provided 3D sliding fit tr...
bool m_isPositionSet
Whether the output 3D position has been set.
bool m_iterateTrackHits
Whether to enable iterative improvement of 3D hits for track trajectories.
TrajectorySampleVector m_trajectorySampleVector
The trajectory sample vector.
pandora::CartesianVector m_position3D
The output 3D position.
bool m_iterateShowerHits
Whether to enable iterative improvement of 3D hits for showers.
TrajectorySample(const pandora::CartesianVector &position, const pandora::HitType hitType, const double sigma)
Constructor.
void CreateThreeDHits(const ProtoHitVector &protoHitVector, pandora::CaloHitList &newThreeDHits) const
Create new three dimensional hits from two dimensional hits.
pandora::HitType GetHitType() const
Get the sampling hit type.
const pandora::CartesianVector & GetPosition() const
Get the sampling position.
HitType
Definition: HitType.h:12
void ExtractResults(const ProtoHitVector &protoHitVector, double &chi2, pandora::CartesianPointVector &pointVector) const
Extract key results from a provided proto hit vector.
Trajectory samples record the results of sampling a particles in a particular view.
ThreeDHitCreationAlgorithm::Algorithm class.
HitCreationToolVector m_algorithmToolVector
The algorithm tool vector.
void SetPosition3D(const pandora::CartesianVector &position3D, const double chi2)
Set position 3D.
std::vector< HitCreationBaseTool * > HitCreationToolVector
double m_sigma3DFitMultiplier
Multiplicative factor: sigmaUVW (same as sigmaHit and sigma2DFit) to sigma3DFit.
double m_iterationMaxChi2Ratio
Max ratio between current and previous chi2 values to cease iterations.
void AddThreeDHitsToPfo(const pandora::ParticleFlowObject *const pPfo, const pandora::CaloHitList &caloHitList) const
Add a specified list of three dimensional hits to a cluster in a pfo, creating the new cluster if req...
void FilterCaloHitsByType(const pandora::CaloHitVector &inputCaloHitVector, const pandora::HitType hitType, pandora::CaloHitVector &outputCaloHitVector) const
Get the subset of a provided calo hit vector corresponding to a specified hit type.