Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
lar_content::ThreeDHitCreationAlgorithm Class Reference

ThreeDHitCreationAlgorithm::Algorithm class. More...

#include <ThreeDHitCreationAlgorithm.h>

Inheritance diagram for lar_content::ThreeDHitCreationAlgorithm:

Classes

class  ProtoHit
 Proto hits are temporary constructs to be used during iterative 3D hit procedure. More...
 
class  TrajectorySample
 Trajectory samples record the results of sampling a particles in a particular view. More...
 

Public Types

typedef std::vector< TrajectorySampleTrajectorySampleVector
 
typedef std::vector< ProtoHitProtoHitVector
 

Public Member Functions

 ThreeDHitCreationAlgorithm ()
 Default constructor. More...
 
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. More...
 

Private Types

typedef std::vector< HitCreationBaseTool * > HitCreationToolVector
 

Private Member Functions

pandora::StatusCode Run ()
 
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. More...
 
void IterativeTreatment (ProtoHitVector &protoHitVector) const
 Improve initial 3D hits by fitting proto hits and iteratively creating consisted 3D hit trajectory. More...
 
void ExtractResults (const ProtoHitVector &protoHitVector, double &chi2, pandora::CartesianPointVector &pointVector) const
 Extract key results from a provided proto hit vector. More...
 
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 trajectory. More...
 
double GetHitMovementChi2 (const ProtoHitVector &protoHitVector) const
 Receive a chi2 value indicating consistency of a list of proto hits with the original, input hit positions. More...
 
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 sliding fit trajectory. More...
 
void CreateThreeDHits (const ProtoHitVector &protoHitVector, pandora::CaloHitList &newThreeDHits) const
 Create new three dimensional hits from two dimensional hits. More...
 
void CreateThreeDHit (const ProtoHit &protoHit, const pandora::CaloHit *&pCaloHit3D) const
 Create a new three dimensional hit from a two dimensional hit. More...
 
bool CheckThreeDHit (const ProtoHit &protoHit) const
 Check that a new three dimensional position is not unphysical. More...
 
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 required. More...
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 

Private Attributes

HitCreationToolVector m_algorithmToolVector
 The algorithm tool vector. More...
 
std::string m_inputPfoListName
 The name of the input pfo list. More...
 
std::string m_outputCaloHitListName
 The name of the output calo hit list. More...
 
std::string m_outputClusterListName
 The name of the output cluster list. More...
 
bool m_iterateTrackHits
 Whether to enable iterative improvement of 3D hits for track trajectories. More...
 
bool m_iterateShowerHits
 Whether to enable iterative improvement of 3D hits for showers. More...
 
unsigned int m_slidingFitHalfWindow
 The sliding linear fit half window. More...
 
unsigned int m_nHitRefinementIterations
 The maximum number of hit refinement iterations. More...
 
double m_sigma3DFitMultiplier
 Multiplicative factor: sigmaUVW (same as sigmaHit and sigma2DFit) to sigma3DFit. More...
 
double m_iterationMaxChi2Ratio
 Max ratio between current and previous chi2 values to cease iterations. More...
 

Detailed Description

ThreeDHitCreationAlgorithm::Algorithm class.

Definition at line 27 of file ThreeDHitCreationAlgorithm.h.

Member Typedef Documentation

Definition at line 271 of file ThreeDHitCreationAlgorithm.h.

Definition at line 163 of file ThreeDHitCreationAlgorithm.h.

Definition at line 68 of file ThreeDHitCreationAlgorithm.h.

Constructor & Destructor Documentation

lar_content::ThreeDHitCreationAlgorithm::ThreeDHitCreationAlgorithm ( )

Default constructor.

Definition at line 27 of file ThreeDHitCreationAlgorithm.cc.

27  :
28  m_iterateTrackHits(true),
29  m_iterateShowerHits(false),
34 {
35 }
unsigned int m_slidingFitHalfWindow
The sliding linear fit half window.
unsigned int m_nHitRefinementIterations
The maximum number of hit refinement iterations.
bool m_iterateTrackHits
Whether to enable iterative improvement of 3D hits for track trajectories.
bool m_iterateShowerHits
Whether to enable iterative improvement of 3D hits for showers.
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.

Member Function Documentation

void lar_content::ThreeDHitCreationAlgorithm::AddThreeDHitsToPfo ( const pandora::ParticleFlowObject *const  pPfo,
const pandora::CaloHitList &  caloHitList 
) const
private

Add a specified list of three dimensional hits to a cluster in a pfo, creating the new cluster if required.

Parameters
pPfothe address of the pfo
caloHitListthe list of three dimensional hits

Definition at line 391 of file ThreeDHitCreationAlgorithm.cc.

392 {
393  if (caloHitList.empty())
394  throw StatusCodeException(STATUS_CODE_NOT_INITIALIZED);
395 
396  ClusterList threeDClusterList;
397  LArPfoHelper::GetThreeDClusterList(pPfo, threeDClusterList);
398 
399  if (!threeDClusterList.empty())
400  throw StatusCodeException(STATUS_CODE_FAILURE);
401 
402  const ClusterList *pClusterList(nullptr);
403  std::string clusterListName;
404  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::CreateTemporaryListAndSetCurrent(*this, pClusterList, clusterListName));
405 
406  PandoraContentApi::Cluster::Parameters parameters;
407  parameters.m_caloHitList.insert(parameters.m_caloHitList.end(), caloHitList.begin(), caloHitList.end());
408 
409  const Cluster *pCluster3D(nullptr);
410  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Cluster::Create(*this, parameters, pCluster3D));
411 
412  if (!pCluster3D || !pClusterList || pClusterList->empty())
413  throw StatusCodeException(STATUS_CODE_FAILURE);
414 
415  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList<Cluster>(*this, m_outputClusterListName));
416  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::AddToPfo(*this, pPfo, pCluster3D));
417 }
std::string string
Definition: nybbler.cc:12
std::string m_outputClusterListName
The name of the output cluster list.
static void GetThreeDClusterList(const pandora::ParticleFlowObject *const pPfo, pandora::ClusterList &clusterList)
Get the list of 3D clusters from an input pfo.
bool lar_content::ThreeDHitCreationAlgorithm::CheckThreeDHit ( const ProtoHit protoHit) const
private

Check that a new three dimensional position is not unphysical.

Parameters
protoHitthe proto hit
boolean

Definition at line 373 of file ThreeDHitCreationAlgorithm.cc.

374 {
375  try
376  {
377  // Check that corresponding pseudo layer is within range - TODO use full LArTPC geometry here
378  (void)PandoraContentApi::GetPlugins(*this)->GetPseudoLayerPlugin()->GetPseudoLayer(protoHit.GetPosition3D());
379  }
380  catch (StatusCodeException &)
381  {
382  return false;
383  }
384 
385  // TODO Check against detector geometry
386  return true;
387 }
void lar_content::ThreeDHitCreationAlgorithm::CreateThreeDHit ( const ProtoHit protoHit,
const pandora::CaloHit *&  pCaloHit3D 
) const
private

Create a new three dimensional hit from a two dimensional hit.

Parameters
protoHitthe proto hit containing all required information
pCaloHit3Dto receive the address of the new three dimensional calo hit

Definition at line 338 of file ThreeDHitCreationAlgorithm.cc.

339 {
340  if (!this->CheckThreeDHit(protoHit))
341  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
342 
343  PandoraContentApi::CaloHit::Parameters parameters;
344  parameters.m_positionVector = protoHit.GetPosition3D();
345  parameters.m_hitType = TPC_3D;
346 
347  const CaloHit *const pCaloHit2D(protoHit.GetParentCaloHit2D());
348  parameters.m_pParentAddress = static_cast<const void *>(pCaloHit2D);
349 
350  // TODO Check these parameters, especially new cell dimensions
351  parameters.m_cellThickness = pCaloHit2D->GetCellThickness();
352  parameters.m_cellGeometry = RECTANGULAR;
353  parameters.m_cellSize0 = pCaloHit2D->GetCellLengthScale();
354  parameters.m_cellSize1 = pCaloHit2D->GetCellLengthScale();
355  parameters.m_cellNormalVector = pCaloHit2D->GetCellNormalVector();
356  parameters.m_expectedDirection = pCaloHit2D->GetExpectedDirection();
357  parameters.m_nCellRadiationLengths = pCaloHit2D->GetNCellRadiationLengths();
358  parameters.m_nCellInteractionLengths = pCaloHit2D->GetNCellInteractionLengths();
359  parameters.m_time = pCaloHit2D->GetTime();
360  parameters.m_inputEnergy = pCaloHit2D->GetInputEnergy();
361  parameters.m_mipEquivalentEnergy = pCaloHit2D->GetMipEquivalentEnergy();
362  parameters.m_electromagneticEnergy = pCaloHit2D->GetElectromagneticEnergy();
363  parameters.m_hadronicEnergy = pCaloHit2D->GetHadronicEnergy();
364  parameters.m_isDigital = pCaloHit2D->IsDigital();
365  parameters.m_hitRegion = pCaloHit2D->GetHitRegion();
366  parameters.m_layer = pCaloHit2D->GetLayer();
367  parameters.m_isInOuterSamplingLayer = pCaloHit2D->IsInOuterSamplingLayer();
368  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::CaloHit::Create(*this, parameters, pCaloHit3D));
369 }
bool CheckThreeDHit(const ProtoHit &protoHit) const
Check that a new three dimensional position is not unphysical.
void lar_content::ThreeDHitCreationAlgorithm::CreateThreeDHits ( const ProtoHitVector protoHitVector,
pandora::CaloHitList &  newThreeDHits 
) const
private

Create new three dimensional hits from two dimensional hits.

Parameters
protoHitVectorthe input proto hit vector
newThreeDHitsto receive the addresses of the new three dimensional calo hits

Definition at line 322 of file ThreeDHitCreationAlgorithm.cc.

323 {
324  for (const ProtoHit &protoHit : protoHitVector)
325  {
326  const CaloHit *pCaloHit3D(nullptr);
327  this->CreateThreeDHit(protoHit, pCaloHit3D);
328 
329  if (!pCaloHit3D)
330  throw StatusCodeException(STATUS_CODE_FAILURE);
331 
332  newThreeDHits.push_back(pCaloHit3D);
333  }
334 }
void CreateThreeDHit(const ProtoHit &protoHit, const pandora::CaloHit *&pCaloHit3D) const
Create a new three dimensional hit from a two dimensional hit.
void lar_content::ThreeDHitCreationAlgorithm::ExtractResults ( const ProtoHitVector protoHitVector,
double &  chi2,
pandora::CartesianPointVector &  pointVector 
) const
private

Extract key results from a provided proto hit vector.

Parameters
protoHitVectorthe proto hit vector
chi2to receive the sum of the proto hit chi2 values
pointVectorto receive a vector of proto hit 3D positions

Definition at line 180 of file ThreeDHitCreationAlgorithm.cc.

181 {
182  chi2 = 0.;
183  pointVector.clear();
184 
185  for (const ProtoHit &protoHit : protoHitVector)
186  {
187  chi2 += protoHit.GetChi2();
188  pointVector.push_back(protoHit.GetPosition3D());
189  }
190 }
void lar_content::ThreeDHitCreationAlgorithm::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.

Parameters
inputCaloHitVectorthe input calo hit vector
hitTypethe hit type to filter upon
outputCaloHitVectorto receive the output calo hit vector

Definition at line 39 of file ThreeDHitCreationAlgorithm.cc.

40 {
41  for (const CaloHit *const pCaloHit : inputCaloHitVector)
42  {
43  if (hitType == pCaloHit->GetHitType())
44  outputCaloHitVector.push_back(pCaloHit);
45  }
46 }
double lar_content::ThreeDHitCreationAlgorithm::GetChi2WrtFit ( const ThreeDSlidingFitResult slidingFitResult,
const ProtoHitVector protoHitVector 
) const
private

Receive a chi2 value indicating consistency of a list of proto hits with a provided 3D sliding fit trajectory.

Parameters
slidingFitResultthe 3D sliding fit result
protoHitVectorthe proto hit vector
Returns
the chi2 value

Definition at line 194 of file ThreeDHitCreationAlgorithm.cc.

195 {
196  const double sigmaUVW(LArGeometryHelper::GetSigmaUVW(this->GetPandora()));
197  const double sigma3DFit(sigmaUVW * m_sigma3DFitMultiplier);
198 
199  double chi2WrtFit(0.);
200 
201  for (const ProtoHit &protoHit : protoHitVector)
202  {
203  CartesianVector pointOnFit(0.f, 0.f, 0.f);
204  const double rL(slidingFitResult.GetLongitudinalDisplacement(protoHit.GetPosition3D()));
205 
206  if (STATUS_CODE_SUCCESS != slidingFitResult.GetGlobalFitPosition(rL, pointOnFit))
207  continue;
208 
209  const double uFit(PandoraContentApi::GetPlugins(*this)->GetLArTransformationPlugin()->YZtoU(pointOnFit.GetY(), pointOnFit.GetZ()));
210  const double vFit(PandoraContentApi::GetPlugins(*this)->GetLArTransformationPlugin()->YZtoV(pointOnFit.GetY(), pointOnFit.GetZ()));
211  const double wFit(PandoraContentApi::GetPlugins(*this)->GetLArTransformationPlugin()->YZtoW(pointOnFit.GetY(), pointOnFit.GetZ()));
212 
213  const double outputU(PandoraContentApi::GetPlugins(*this)->GetLArTransformationPlugin()->YZtoU(
214  protoHit.GetPosition3D().GetY(), protoHit.GetPosition3D().GetZ()));
215  const double outputV(PandoraContentApi::GetPlugins(*this)->GetLArTransformationPlugin()->YZtoV(
216  protoHit.GetPosition3D().GetY(), protoHit.GetPosition3D().GetZ()));
217  const double outputW(PandoraContentApi::GetPlugins(*this)->GetLArTransformationPlugin()->YZtoW(
218  protoHit.GetPosition3D().GetY(), protoHit.GetPosition3D().GetZ()));
219 
220  const double deltaUFit(uFit - outputU), deltaVFit(vFit - outputV), deltaWFit(wFit - outputW);
221  chi2WrtFit += ((deltaUFit * deltaUFit) / (sigma3DFit * sigma3DFit)) + ((deltaVFit * deltaVFit) / (sigma3DFit * sigma3DFit)) +
222  ((deltaWFit * deltaWFit) / (sigma3DFit * sigma3DFit));
223  }
224 
225  return chi2WrtFit;
226 }
static float GetSigmaUVW(const pandora::Pandora &pandora, const float maxSigmaDiscrepancy=0.01)
Find the sigmaUVW value for the detector geometry.
double m_sigma3DFitMultiplier
Multiplicative factor: sigmaUVW (same as sigmaHit and sigma2DFit) to sigma3DFit.
double lar_content::ThreeDHitCreationAlgorithm::GetHitMovementChi2 ( const ProtoHitVector protoHitVector) const
private

Receive a chi2 value indicating consistency of a list of proto hits with the original, input hit positions.

Parameters
protoHitVectorthe proto hit vector
Returns
the chi2 value

Definition at line 230 of file ThreeDHitCreationAlgorithm.cc.

231 {
232  const double sigmaUVW(LArGeometryHelper::GetSigmaUVW(this->GetPandora()));
233  double hitMovementChi2(0.);
234 
235  for (const ProtoHit &protoHit : protoHitVector)
236  {
237  const CaloHit *const pCaloHit2D(protoHit.GetParentCaloHit2D());
238  const HitType hitType(pCaloHit2D->GetHitType());
239 
240  const CartesianVector projectedPosition(LArGeometryHelper::ProjectPosition(this->GetPandora(), protoHit.GetPosition3D(), hitType));
241  const double delta(static_cast<double>(pCaloHit2D->GetPositionVector().GetZ() - projectedPosition.GetZ()));
242 
243  hitMovementChi2 += (delta * delta) / (sigmaUVW * sigmaUVW);
244  }
245 
246  return hitMovementChi2;
247 }
static float GetSigmaUVW(const pandora::Pandora &pandora, const float maxSigmaDiscrepancy=0.01)
Find the sigmaUVW value for the detector geometry.
enum cvn::HType HitType
static pandora::CartesianVector ProjectPosition(const pandora::Pandora &pandora, const pandora::CartesianVector &position3D, const pandora::HitType view)
Project 3D position into a given 2D view.
void lar_content::ThreeDHitCreationAlgorithm::IterativeTreatment ( ProtoHitVector protoHitVector) const
private

Improve initial 3D hits by fitting proto hits and iteratively creating consisted 3D hit trajectory.

Parameters
protoHitVectorthe vector of proto hits, describing current state of 3D hit construction

Definition at line 138 of file ThreeDHitCreationAlgorithm.cc.

139 {
140  const float layerPitch(LArGeometryHelper::GetWireZPitch(this->GetPandora()));
141  const unsigned int layerWindow(m_slidingFitHalfWindow);
142 
143  double originalChi2(0.);
144  CartesianPointVector currentPoints3D;
145  this->ExtractResults(protoHitVector, originalChi2, currentPoints3D);
146 
147  try
148  {
149  const ThreeDSlidingFitResult originalSlidingFitResult(&currentPoints3D, layerWindow, layerPitch);
150  const double originalChi2WrtFit(this->GetChi2WrtFit(originalSlidingFitResult, protoHitVector));
151  double currentChi2(originalChi2 + originalChi2WrtFit);
152 
153  unsigned int nIterations(0);
154 
155  while (nIterations++ < m_nHitRefinementIterations)
156  {
157  ProtoHitVector newProtoHitVector(protoHitVector);
158  const ThreeDSlidingFitResult newSlidingFitResult(&currentPoints3D, layerWindow, layerPitch);
159  this->RefineHitPositions(newSlidingFitResult, newProtoHitVector);
160 
161  double newChi2(0.);
162  CartesianPointVector newPoints3D;
163  this->ExtractResults(newProtoHitVector, newChi2, newPoints3D);
164 
165  if (newChi2 > m_iterationMaxChi2Ratio * currentChi2)
166  break;
167 
168  currentChi2 = newChi2;
169  currentPoints3D = newPoints3D;
170  protoHitVector = newProtoHitVector;
171  }
172  }
173  catch (const StatusCodeException &)
174  {
175  }
176 }
unsigned int m_slidingFitHalfWindow
The sliding linear fit half window.
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...
static float GetWireZPitch(const pandora::Pandora &pandora, const float maxWirePitchDiscrepancy=0.01)
Return the wire pitch.
unsigned int m_nHitRefinementIterations
The maximum number of hit refinement iterations.
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...
void ExtractResults(const ProtoHitVector &protoHitVector, double &chi2, pandora::CartesianPointVector &pointVector) const
Extract key results from a provided proto hit vector.
double m_iterationMaxChi2Ratio
Max ratio between current and previous chi2 values to cease iterations.
StatusCode lar_content::ThreeDHitCreationAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 463 of file ThreeDHitCreationAlgorithm.cc.

464 {
465  AlgorithmToolVector algorithmToolVector;
466  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ProcessAlgorithmToolList(*this, xmlHandle, "HitCreationTools", algorithmToolVector));
467 
468  for (AlgorithmToolVector::const_iterator iter = algorithmToolVector.begin(), iterEnd = algorithmToolVector.end(); iter != iterEnd; ++iter)
469  {
470  HitCreationBaseTool *const pHitCreationTool(dynamic_cast<HitCreationBaseTool *>(*iter));
471 
472  if (!pHitCreationTool)
473  return STATUS_CODE_INVALID_PARAMETER;
474 
475  m_algorithmToolVector.push_back(pHitCreationTool);
476  }
477 
478  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "InputPfoListName", m_inputPfoListName));
479  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "OutputCaloHitListName", m_outputCaloHitListName));
480  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "OutputClusterListName", m_outputClusterListName));
481 
482  PANDORA_RETURN_RESULT_IF_AND_IF(
483  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "IterateTrackHits", m_iterateTrackHits));
484 
485  PANDORA_RETURN_RESULT_IF_AND_IF(
486  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "IterateShowerHits", m_iterateShowerHits));
487 
488  PANDORA_RETURN_RESULT_IF_AND_IF(
489  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "SlidingFitHalfWindow", m_slidingFitHalfWindow));
490 
491  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
492  XmlHelper::ReadValue(xmlHandle, "NHitRefinementIterations", m_nHitRefinementIterations));
493 
494  PANDORA_RETURN_RESULT_IF_AND_IF(
495  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "Sigma3DFitMultiplier", m_sigma3DFitMultiplier));
496 
497  PANDORA_RETURN_RESULT_IF_AND_IF(
498  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "IterationMaxChi2Ratio", m_iterationMaxChi2Ratio));
499 
500  return STATUS_CODE_SUCCESS;
501 }
std::string m_inputPfoListName
The name of the input pfo list.
unsigned int m_slidingFitHalfWindow
The sliding linear fit half window.
std::string m_outputCaloHitListName
The name of the output calo hit list.
intermediate_table::const_iterator const_iterator
unsigned int m_nHitRefinementIterations
The maximum number of hit refinement iterations.
std::string m_outputClusterListName
The name of the output cluster list.
bool m_iterateTrackHits
Whether to enable iterative improvement of 3D hits for track trajectories.
bool m_iterateShowerHits
Whether to enable iterative improvement of 3D hits for showers.
HitCreationToolVector m_algorithmToolVector
The algorithm tool vector.
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 lar_content::ThreeDHitCreationAlgorithm::RefineHitPositions ( const ThreeDSlidingFitResult slidingFitResult,
ProtoHitVector protoHitVector 
) const
private

Refine the 3D hit positions (and chi2) for a list of proto hits, in accordance with a provided 3D sliding fit trajectory.

Parameters
slidingFitResultthe 3D sliding fit result
protoHitVectorthe proto hit vector, non const as proto hit properties will be updated

Definition at line 251 of file ThreeDHitCreationAlgorithm.cc.

252 {
253  const double sigmaUVW(LArGeometryHelper::GetSigmaUVW(this->GetPandora()));
254  const double sigmaFit(sigmaUVW); // ATTN sigmaFit and sigmaHit here should agree with treatment in HitCreation tools
255  const double sigmaHit(sigmaUVW);
256  const double sigma3DFit(sigmaUVW * m_sigma3DFitMultiplier);
257 
258  for (ProtoHit &protoHit : protoHitVector)
259  {
260  CartesianVector pointOnFit(0.f, 0.f, 0.f);
261  const double rL(slidingFitResult.GetLongitudinalDisplacement(protoHit.GetPosition3D()));
262 
263  if (STATUS_CODE_SUCCESS != slidingFitResult.GetGlobalFitPosition(rL, pointOnFit))
264  continue;
265 
266  const CaloHit *const pCaloHit2D(protoHit.GetParentCaloHit2D());
267  const HitType hitType(pCaloHit2D->GetHitType());
268 
269  const double uFit(PandoraContentApi::GetPlugins(*this)->GetLArTransformationPlugin()->YZtoU(pointOnFit.GetY(), pointOnFit.GetZ()));
270  const double vFit(PandoraContentApi::GetPlugins(*this)->GetLArTransformationPlugin()->YZtoV(pointOnFit.GetY(), pointOnFit.GetZ()));
271  const double wFit(PandoraContentApi::GetPlugins(*this)->GetLArTransformationPlugin()->YZtoW(pointOnFit.GetY(), pointOnFit.GetZ()));
272 
273  const double sigmaU((TPC_VIEW_U == hitType) ? sigmaHit : sigmaFit);
274  const double sigmaV((TPC_VIEW_V == hitType) ? sigmaHit : sigmaFit);
275  const double sigmaW((TPC_VIEW_W == hitType) ? sigmaHit : sigmaFit);
276 
277  CartesianVector position3D(0.f, 0.f, 0.f);
278  double chi2(std::numeric_limits<double>::max());
280 
281  if (protoHit.GetNTrajectorySamples() == 2)
282  {
283  u = (TPC_VIEW_U == hitType) ? pCaloHit2D->GetPositionVector().GetZ()
284  : (TPC_VIEW_U == protoHit.GetFirstTrajectorySample().GetHitType())
285  ? protoHit.GetFirstTrajectorySample().GetPosition().GetZ()
286  : protoHit.GetLastTrajectorySample().GetPosition().GetZ();
287  v = (TPC_VIEW_V == hitType) ? pCaloHit2D->GetPositionVector().GetZ()
288  : (TPC_VIEW_V == protoHit.GetFirstTrajectorySample().GetHitType())
289  ? protoHit.GetFirstTrajectorySample().GetPosition().GetZ()
290  : protoHit.GetLastTrajectorySample().GetPosition().GetZ();
291  w = (TPC_VIEW_W == hitType) ? pCaloHit2D->GetPositionVector().GetZ()
292  : (TPC_VIEW_W == protoHit.GetFirstTrajectorySample().GetHitType())
293  ? protoHit.GetFirstTrajectorySample().GetPosition().GetZ()
294  : protoHit.GetLastTrajectorySample().GetPosition().GetZ();
295  }
296  else if (protoHit.GetNTrajectorySamples() == 1)
297  {
298  u = PandoraContentApi::GetPlugins(*this)->GetLArTransformationPlugin()->YZtoU(
299  protoHit.GetPosition3D().GetY(), protoHit.GetPosition3D().GetZ());
300  v = PandoraContentApi::GetPlugins(*this)->GetLArTransformationPlugin()->YZtoV(
301  protoHit.GetPosition3D().GetY(), protoHit.GetPosition3D().GetZ());
302  w = PandoraContentApi::GetPlugins(*this)->GetLArTransformationPlugin()->YZtoW(
303  protoHit.GetPosition3D().GetY(), protoHit.GetPosition3D().GetZ());
304  }
305  else
306  {
307  std::cout << "ThreeDHitCreationAlgorithm::IterativeTreatment - Unexpected number of trajectory samples" << std::endl;
308  throw StatusCodeException(STATUS_CODE_FAILURE);
309  }
310 
312  PandoraContentApi::GetPlugins(*this)->GetLArTransformationPlugin()->GetMinChiSquaredYZ(
313  u, v, w, sigmaU, sigmaV, sigmaW, uFit, vFit, wFit, sigma3DFit, bestY, bestZ, chi2);
314  position3D.SetValues(pCaloHit2D->GetPositionVector().GetX(), static_cast<float>(bestY), static_cast<float>(bestZ));
315 
316  protoHit.SetPosition3D(position3D, chi2);
317  }
318 }
static float GetSigmaUVW(const pandora::Pandora &pandora, const float maxSigmaDiscrepancy=0.01)
Find the sigmaUVW value for the detector geometry.
enum cvn::HType HitType
static int max(int a, int b)
double m_sigma3DFitMultiplier
Multiplicative factor: sigmaUVW (same as sigmaHit and sigma2DFit) to sigma3DFit.
QTextStream & endl(QTextStream &s)
StatusCode lar_content::ThreeDHitCreationAlgorithm::Run ( )
private

Definition at line 50 of file ThreeDHitCreationAlgorithm.cc.

51 {
52  const PfoList *pPfoList(nullptr);
53  PANDORA_RETURN_RESULT_IF_AND_IF(
54  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraContentApi::GetList(*this, m_inputPfoListName, pPfoList));
55 
56  if (!pPfoList || pPfoList->empty())
57  {
58  if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
59  std::cout << "ThreeDHitCreationAlgorithm: unable to find pfo list " << m_inputPfoListName << std::endl;
60 
61  return STATUS_CODE_SUCCESS;
62  }
63 
64  CaloHitList allNewThreeDHits;
65 
66  PfoVector pfoVector(pPfoList->begin(), pPfoList->end());
67  std::sort(pfoVector.begin(), pfoVector.end(), LArPfoHelper::SortByNHits);
68 
69  for (const ParticleFlowObject *const pPfo : pfoVector)
70  {
71  ProtoHitVector protoHitVector;
72 
73  for (HitCreationBaseTool *const pHitCreationTool : m_algorithmToolVector)
74  {
75  CaloHitVector remainingTwoDHits;
76  this->SeparateTwoDHits(pPfo, protoHitVector, remainingTwoDHits);
77 
78  if (remainingTwoDHits.empty())
79  break;
80 
81  pHitCreationTool->Run(this, pPfo, remainingTwoDHits, protoHitVector);
82  }
83 
85  this->IterativeTreatment(protoHitVector);
86 
87  if (protoHitVector.empty())
88  continue;
89 
90  CaloHitList newThreeDHits;
91  this->CreateThreeDHits(protoHitVector, newThreeDHits);
92  this->AddThreeDHitsToPfo(pPfo, newThreeDHits);
93 
94  allNewThreeDHits.insert(allNewThreeDHits.end(), newThreeDHits.begin(), newThreeDHits.end());
95  }
96 
97  if (!allNewThreeDHits.empty())
98  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList(*this, allNewThreeDHits, m_outputCaloHitListName));
99 
100  return STATUS_CODE_SUCCESS;
101 }
void IterativeTreatment(ProtoHitVector &protoHitVector) const
Improve initial 3D hits by fitting proto hits and iteratively creating consisted 3D hit trajectory...
static bool SortByNHits(const pandora::ParticleFlowObject *const pLhs, const pandora::ParticleFlowObject *const pRhs)
Sort pfos by number of constituent hits.
std::string m_inputPfoListName
The name of the input pfo list.
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.
static bool IsTrack(const pandora::ParticleFlowObject *const pPfo)
Return track flag based on Pfo Particle ID.
static bool IsShower(const pandora::ParticleFlowObject *const pPfo)
Return shower flag based on Pfo Particle ID.
bool m_iterateTrackHits
Whether to enable iterative improvement of 3D hits for track trajectories.
bool m_iterateShowerHits
Whether to enable iterative improvement of 3D hits for showers.
void CreateThreeDHits(const ProtoHitVector &protoHitVector, pandora::CaloHitList &newThreeDHits) const
Create new three dimensional hits from two dimensional hits.
HitCreationToolVector m_algorithmToolVector
The algorithm tool vector.
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...
QTextStream & endl(QTextStream &s)
void lar_content::ThreeDHitCreationAlgorithm::SeparateTwoDHits ( const pandora::ParticleFlowObject *const  pPfo,
const ProtoHitVector protoHitVector,
pandora::CaloHitVector &  remainingHitVector 
) const
private

Get the list of 2D calo hits in a pfo for which 3D hits have and have not been created.

Parameters
pPfothe address of the pfo
protoHitVectorthe vector of proto hits, describing current state of 3D hit construction
remainingHitVectorto receive the vector of 2D calo hits for which 3D hits have not been created

Definition at line 105 of file ThreeDHitCreationAlgorithm.cc.

107 {
108  ClusterList twoDClusterList;
109  LArPfoHelper::GetTwoDClusterList(pPfo, twoDClusterList);
110  CaloHitList remainingHitList;
111 
112  for (const Cluster *const pCluster : twoDClusterList)
113  {
114  if (TPC_3D == LArClusterHelper::GetClusterHitType(pCluster))
115  throw StatusCodeException(STATUS_CODE_FAILURE);
116 
117  pCluster->GetOrderedCaloHitList().FillCaloHitList(remainingHitList);
118  }
119 
120  CaloHitSet remainingHitSet(remainingHitList.begin(), remainingHitList.end());
121 
122  for (const ProtoHit &protoHit : protoHitVector)
123  {
124  CaloHitSet::iterator eraseIter = remainingHitSet.find(protoHit.GetParentCaloHit2D());
125 
126  if (remainingHitSet.end() == eraseIter)
127  throw StatusCodeException(STATUS_CODE_FAILURE);
128 
129  remainingHitSet.erase(eraseIter);
130  }
131 
132  remainingHitVector.insert(remainingHitVector.end(), remainingHitSet.begin(), remainingHitSet.end());
133  std::sort(remainingHitVector.begin(), remainingHitVector.end(), LArClusterHelper::SortHitsByPosition);
134 }
intermediate_table::iterator iterator
static void GetTwoDClusterList(const pandora::ParticleFlowObject *const pPfo, pandora::ClusterList &clusterList)
Get the list of 2D clusters from an input pfo.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
static bool SortHitsByPosition(const pandora::CaloHit *const pLhs, const pandora::CaloHit *const pRhs)
Sort calo hits by their position (use Z, followed by X, followed by Y)

Member Data Documentation

HitCreationToolVector lar_content::ThreeDHitCreationAlgorithm::m_algorithmToolVector
private

The algorithm tool vector.

Definition at line 272 of file ThreeDHitCreationAlgorithm.h.

std::string lar_content::ThreeDHitCreationAlgorithm::m_inputPfoListName
private

The name of the input pfo list.

Definition at line 274 of file ThreeDHitCreationAlgorithm.h.

bool lar_content::ThreeDHitCreationAlgorithm::m_iterateShowerHits
private

Whether to enable iterative improvement of 3D hits for showers.

Definition at line 279 of file ThreeDHitCreationAlgorithm.h.

bool lar_content::ThreeDHitCreationAlgorithm::m_iterateTrackHits
private

Whether to enable iterative improvement of 3D hits for track trajectories.

Definition at line 278 of file ThreeDHitCreationAlgorithm.h.

double lar_content::ThreeDHitCreationAlgorithm::m_iterationMaxChi2Ratio
private

Max ratio between current and previous chi2 values to cease iterations.

Definition at line 283 of file ThreeDHitCreationAlgorithm.h.

unsigned int lar_content::ThreeDHitCreationAlgorithm::m_nHitRefinementIterations
private

The maximum number of hit refinement iterations.

Definition at line 281 of file ThreeDHitCreationAlgorithm.h.

std::string lar_content::ThreeDHitCreationAlgorithm::m_outputCaloHitListName
private

The name of the output calo hit list.

Definition at line 275 of file ThreeDHitCreationAlgorithm.h.

std::string lar_content::ThreeDHitCreationAlgorithm::m_outputClusterListName
private

The name of the output cluster list.

Definition at line 276 of file ThreeDHitCreationAlgorithm.h.

double lar_content::ThreeDHitCreationAlgorithm::m_sigma3DFitMultiplier
private

Multiplicative factor: sigmaUVW (same as sigmaHit and sigma2DFit) to sigma3DFit.

Definition at line 282 of file ThreeDHitCreationAlgorithm.h.

unsigned int lar_content::ThreeDHitCreationAlgorithm::m_slidingFitHalfWindow
private

The sliding linear fit half window.

Definition at line 280 of file ThreeDHitCreationAlgorithm.h.


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