LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
lar_content::BeamParticleIdTool Class Reference

BeamParticleIdTool class. More...

#include "BeamParticleIdTool.h"

Inheritance diagram for lar_content::BeamParticleIdTool:
lar_content::SliceIdBaseTool

Classes

class  Plane
 Plane class. More...
 

Public Member Functions

 BeamParticleIdTool ()
 Default constructor. More...
 
void SelectOutputPfos (const pandora::Algorithm *const pAlgorithm, const SliceHypotheses &beamSliceHypotheses, const SliceHypotheses &crSliceHypotheses, pandora::PfoList &selectedPfos)
 Select which reconstruction hypotheses to use; neutrino outcomes or cosmic-ray muon outcomes for each slice. More...
 

Private Types

typedef std::vector< PlanePlaneVector
 

Private Member Functions

pandora::StatusCode Initialize ()
 
void GetSelectedCaloHits (const pandora::CaloHitList &inputCaloHitList, pandora::CaloHitList &outputCaloHitList, float &closestHitToFaceDistance) const
 Select a given fraction of a slice's calo hits that are closest to the beam spot. More...
 
void GetTPCIntercepts (const pandora::CartesianVector &a0, const pandora::CartesianVector &majorAxis, pandora::CartesianVector &interceptOne, pandora::CartesianVector &interceptTwo) const
 Find the intercepts of a line with the protoDUNE detector. More...
 
bool IsContained (const pandora::CartesianVector &spacePoint) const
 Check if a given 3D spacepoint is inside the global TPC volume. More...
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 

Private Attributes

bool m_selectAllBeamParticles
 First approach: select all beam particles, as opposed to selecting all cosmics. More...
 
bool m_selectOnlyFirstSliceBeamParticles
 First approach: select first slice beam particles, cosmics for all subsequent slices. More...
 
float m_tpcMinX
 Global TPC volume minimum x extent. More...
 
float m_tpcMaxX
 Global TPC volume maximum x extent. More...
 
float m_tpcMinY
 Global TPC volume minimum y extent. More...
 
float m_tpcMaxY
 Global TPC volume maximum y extent. More...
 
float m_tpcMinZ
 Global TPC volume minimum z extent. More...
 
float m_tpcMaxZ
 Global TPC volume maximum z extent. More...
 
pandora::CartesianVector m_beamTPCIntersection
 Intersection of beam and global TPC volume. More...
 
pandora::CartesianVector m_beamDirection
 Beam direction. More...
 
PlaneVector m_tpcPlanes
 Vector of all planes making up global TPC volume. More...
 
float m_projectionIntersectionCut
 Projection intersection distance cut, used in beam event selection. More...
 
float m_closestDistanceCut
 Closest distance (of hit to beam spot), used in beam event selection. More...
 
float m_angleToBeamCut
 Angle between major axis and beam direction, used in beam event selection. More...
 
float m_selectedFraction
 Fraction of hits to use in 3D cluster fits. More...
 
unsigned int m_nSelectedHits
 Minimum number of hits to use in 3D cluster fits. More...
 

Detailed Description

BeamParticleIdTool class.

Definition at line 20 of file BeamParticleIdTool.h.

Member Typedef Documentation

Definition at line 91 of file BeamParticleIdTool.h.

Constructor & Destructor Documentation

lar_content::BeamParticleIdTool::BeamParticleIdTool ( )

Default constructor.

Definition at line 21 of file BeamParticleIdTool.cc.

21  :
24  m_tpcMinX(std::numeric_limits<float>::max()),
25  m_tpcMaxX(-std::numeric_limits<float>::max()),
26  m_tpcMinY(std::numeric_limits<float>::max()),
27  m_tpcMaxY(-std::numeric_limits<float>::max()),
28  m_tpcMinZ(std::numeric_limits<float>::max()),
29  m_tpcMaxZ(-std::numeric_limits<float>::max()),
30  m_beamTPCIntersection(0.f, 0.f, 0.f),
31  m_beamDirection(0.f, 0.f, 0.f),
34  m_angleToBeamCut(150.f * M_PI / 180.f),
36  m_nSelectedHits(100)
37 {
38 }
pandora::CartesianVector m_beamTPCIntersection
Intersection of beam and global TPC volume.
bool m_selectAllBeamParticles
First approach: select all beam particles, as opposed to selecting all cosmics.
float m_closestDistanceCut
Closest distance (of hit to beam spot), used in beam event selection.
float m_tpcMaxX
Global TPC volume maximum x extent.
float m_tpcMinZ
Global TPC volume minimum z extent.
float m_tpcMaxZ
Global TPC volume maximum z extent.
TFile f
Definition: plotHisto.C:6
float m_angleToBeamCut
Angle between major axis and beam direction, used in beam event selection.
bool m_selectOnlyFirstSliceBeamParticles
First approach: select first slice beam particles, cosmics for all subsequent slices.
unsigned int m_nSelectedHits
Minimum number of hits to use in 3D cluster fits.
float m_selectedFraction
Fraction of hits to use in 3D cluster fits.
float m_projectionIntersectionCut
Projection intersection distance cut, used in beam event selection.
float m_tpcMaxY
Global TPC volume maximum y extent.
pandora::CartesianVector m_beamDirection
Beam direction.
float m_tpcMinY
Global TPC volume minimum y extent.
float m_tpcMinX
Global TPC volume minimum x extent.

Member Function Documentation

void lar_content::BeamParticleIdTool::GetSelectedCaloHits ( const pandora::CaloHitList &  inputCaloHitList,
pandora::CaloHitList &  outputCaloHitList,
float &  closestHitToFaceDistance 
) const
private

Select a given fraction of a slice's calo hits that are closest to the beam spot.

Parameters
inputCaloHitListall calo hits in slice
outputCaloHitListto receive the list of selected calo hits
closestHitToFaceDistanceto receive the distance of closest hit to beam spot

Definition at line 180 of file BeamParticleIdTool.cc.

References f, m_beamTPCIntersection, m_nSelectedHits, and m_selectedFraction.

Referenced by SelectOutputPfos().

181 {
182  if (inputCaloHitList.empty())
183  throw StatusCodeException(STATUS_CODE_NOT_INITIALIZED);
184 
185  typedef std::pair<const CaloHit *, float> HitDistancePair;
186  typedef std::vector<HitDistancePair> HitDistanceVector;
187  HitDistanceVector hitDistanceVector;
188 
189  for (const CaloHit *const pCaloHit : inputCaloHitList)
190  hitDistanceVector.emplace_back(pCaloHit, (pCaloHit->GetPositionVector() - m_beamTPCIntersection).GetMagnitudeSquared());
191 
192  std::sort(hitDistanceVector.begin(), hitDistanceVector.end(),
193  [](const HitDistancePair &lhs, const HitDistancePair &rhs) -> bool { return (lhs.second < rhs.second); });
194  closestHitToFaceDistance = std::sqrt(hitDistanceVector.front().second);
195 
196  const unsigned int nInputHits(inputCaloHitList.size());
197  const unsigned int nSelectedCaloHits(nInputHits < m_nSelectedHits
198  ? nInputHits
199  : static_cast<unsigned int>(std::round(static_cast<float>(nInputHits) * m_selectedFraction / 100.f + 0.5f)));
200 
201  for (const HitDistancePair &hitDistancePair : hitDistanceVector)
202  {
203  outputCaloHitList.push_back(hitDistancePair.first);
204 
205  if (outputCaloHitList.size() >= nSelectedCaloHits)
206  break;
207  }
208 }
pandora::CartesianVector m_beamTPCIntersection
Intersection of beam and global TPC volume.
TFile f
Definition: plotHisto.C:6
unsigned int m_nSelectedHits
Minimum number of hits to use in 3D cluster fits.
float m_selectedFraction
Fraction of hits to use in 3D cluster fits.
void lar_content::BeamParticleIdTool::GetTPCIntercepts ( const pandora::CartesianVector &  a0,
const pandora::CartesianVector &  majorAxis,
pandora::CartesianVector &  interceptOne,
pandora::CartesianVector &  interceptTwo 
) const
private

Find the intercepts of a line with the protoDUNE detector.

Parameters
a0a point on the line in question
majorAxisthe direction of the line in question
interceptOneto receive the first intersection between line and protoDUNE detector
interceptTwoto receive the second intersection between line and protoDUNE detector

Definition at line 212 of file BeamParticleIdTool.cc.

References IsContained(), and m_tpcPlanes.

Referenced by SelectOutputPfos().

214 {
215  CartesianPointVector intercepts;
216  const CartesianVector lineUnitVector(lineDirection.GetUnitVector());
217 
218  for (const Plane &plane : m_tpcPlanes)
219  {
220  const CartesianVector intercept(plane.GetLineIntersection(a0, lineUnitVector));
221 
222  if (this->IsContained(intercept))
223  intercepts.push_back(intercept);
224  }
225 
226  if (intercepts.size() == 2)
227  {
228  interceptOne = intercepts.at(0);
229  interceptTwo = intercepts.at(1);
230  }
231  else
232  {
233  throw StatusCodeException(STATUS_CODE_NOT_ALLOWED);
234  }
235 }
bool IsContained(const pandora::CartesianVector &spacePoint) const
Check if a given 3D spacepoint is inside the global TPC volume.
#define a0
recob::tracking::Plane Plane
Definition: TrackState.h:17
PlaneVector m_tpcPlanes
Vector of all planes making up global TPC volume.
StatusCode lar_content::BeamParticleIdTool::Initialize ( )
private

Definition at line 133 of file BeamParticleIdTool.cc.

References f, m_tpcMaxX, m_tpcMaxY, m_tpcMaxZ, m_tpcMinX, m_tpcMinY, m_tpcMinZ, and m_tpcPlanes.

134 {
135  // Get global TPC geometry information
136  const LArTPCMap &larTPCMap(this->GetPandora().GetGeometry()->GetLArTPCMap());
137  const LArTPC *const pFirstLArTPC(larTPCMap.begin()->second);
138  float parentMinX(pFirstLArTPC->GetCenterX() - 0.5f * pFirstLArTPC->GetWidthX());
139  float parentMaxX(pFirstLArTPC->GetCenterX() + 0.5f * pFirstLArTPC->GetWidthX());
140  float parentMinY(pFirstLArTPC->GetCenterY() - 0.5f * pFirstLArTPC->GetWidthY());
141  float parentMaxY(pFirstLArTPC->GetCenterY() + 0.5f * pFirstLArTPC->GetWidthY());
142  float parentMinZ(pFirstLArTPC->GetCenterZ() - 0.5f * pFirstLArTPC->GetWidthZ());
143  float parentMaxZ(pFirstLArTPC->GetCenterZ() + 0.5f * pFirstLArTPC->GetWidthZ());
144 
145  for (const LArTPCMap::value_type &mapEntry : larTPCMap)
146  {
147  const LArTPC *const pLArTPC(mapEntry.second);
148  parentMinX = std::min(parentMinX, pLArTPC->GetCenterX() - 0.5f * pLArTPC->GetWidthX());
149  parentMaxX = std::max(parentMaxX, pLArTPC->GetCenterX() + 0.5f * pLArTPC->GetWidthX());
150  parentMinY = std::min(parentMinY, pLArTPC->GetCenterY() - 0.5f * pLArTPC->GetWidthY());
151  parentMaxY = std::max(parentMaxY, pLArTPC->GetCenterY() + 0.5f * pLArTPC->GetWidthY());
152  parentMinZ = std::min(parentMinZ, pLArTPC->GetCenterZ() - 0.5f * pLArTPC->GetWidthZ());
153  parentMaxZ = std::max(parentMaxZ, pLArTPC->GetCenterZ() + 0.5f * pLArTPC->GetWidthZ());
154  }
155  m_tpcMinX = parentMinX;
156  m_tpcMaxX = parentMaxX;
157  m_tpcMinY = parentMinY;
158  m_tpcMaxY = parentMaxY;
159  m_tpcMinZ = parentMinZ;
160  m_tpcMaxZ = parentMaxZ;
161 
162  const CartesianVector normalTop(0.f, 0.f, 1.f), pointTop(0.f, 0.f, m_tpcMaxZ);
163  const CartesianVector normalBottom(0.f, 0.f, -1.f), pointBottom(0.f, 0.f, m_tpcMinZ);
164  const CartesianVector normalRight(1.f, 0.f, 0.f), pointRight(m_tpcMaxX, 0.f, 0.f);
165  const CartesianVector normalLeft(-1.f, 0.f, 0.f), pointLeft(m_tpcMinX, 0.f, 0.f);
166  const CartesianVector normalBack(0.f, 1.f, 0.f), pointBack(0.f, m_tpcMaxY, 0.f);
167  const CartesianVector normalFront(0.f, -1.f, 0.f), pointFront(0.f, m_tpcMinY, 0.f);
168  m_tpcPlanes.emplace_back(normalTop, pointTop);
169  m_tpcPlanes.emplace_back(normalBottom, pointBottom);
170  m_tpcPlanes.emplace_back(normalRight, pointRight);
171  m_tpcPlanes.emplace_back(normalLeft, pointLeft);
172  m_tpcPlanes.emplace_back(normalBack, pointBack);
173  m_tpcPlanes.emplace_back(normalFront, pointFront);
174 
175  return STATUS_CODE_SUCCESS;
176 }
float m_tpcMaxX
Global TPC volume maximum x extent.
float m_tpcMinZ
Global TPC volume minimum z extent.
float m_tpcMaxZ
Global TPC volume maximum z extent.
TFile f
Definition: plotHisto.C:6
float m_tpcMaxY
Global TPC volume maximum y extent.
float m_tpcMinY
Global TPC volume minimum y extent.
PlaneVector m_tpcPlanes
Vector of all planes making up global TPC volume.
float m_tpcMinX
Global TPC volume minimum x extent.
bool lar_content::BeamParticleIdTool::IsContained ( const pandora::CartesianVector &  spacePoint) const
private

Check if a given 3D spacepoint is inside the global TPC volume.

Parameters
spacePoint

Definition at line 239 of file BeamParticleIdTool.cc.

References m_tpcMaxX, m_tpcMaxY, m_tpcMaxZ, m_tpcMinX, m_tpcMinY, and m_tpcMinZ.

Referenced by GetTPCIntercepts().

240 {
241  if ((m_tpcMinX - spacePoint.GetX() > std::numeric_limits<float>::epsilon()) ||
242  (spacePoint.GetX() - m_tpcMaxX > std::numeric_limits<float>::epsilon()) ||
243  (m_tpcMinY - spacePoint.GetY() > std::numeric_limits<float>::epsilon()) ||
244  (spacePoint.GetY() - m_tpcMaxY > std::numeric_limits<float>::epsilon()) ||
245  (m_tpcMinZ - spacePoint.GetZ() > std::numeric_limits<float>::epsilon()) ||
246  (spacePoint.GetZ() - m_tpcMaxZ > std::numeric_limits<float>::epsilon()))
247  {
248  return false;
249  }
250 
251  return true;
252 }
float m_tpcMaxX
Global TPC volume maximum x extent.
float m_tpcMinZ
Global TPC volume minimum z extent.
float m_tpcMaxZ
Global TPC volume maximum z extent.
float m_tpcMaxY
Global TPC volume maximum y extent.
float m_tpcMinY
Global TPC volume minimum y extent.
float m_tpcMinX
Global TPC volume minimum x extent.
StatusCode lar_content::BeamParticleIdTool::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 283 of file BeamParticleIdTool.cc.

References f, m_angleToBeamCut, m_beamDirection, m_beamTPCIntersection, m_closestDistanceCut, m_nSelectedHits, m_projectionIntersectionCut, m_selectAllBeamParticles, m_selectedFraction, and m_selectOnlyFirstSliceBeamParticles.

284 {
285  PANDORA_RETURN_RESULT_IF_AND_IF(
286  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "SelectAllBeamParticles", m_selectAllBeamParticles));
287 
288  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
289  XmlHelper::ReadValue(xmlHandle, "SelectOnlyFirstSliceBeamParticles", m_selectOnlyFirstSliceBeamParticles));
290 
292  {
293  std::cout << "BeamParticleIdTool::ReadSettings - cannot use both SelectAllBeamParticles and SelectOnlyFirstSliceBeamParticles simultaneously"
294  << std::endl;
295  return STATUS_CODE_INVALID_PARAMETER;
296  }
297 
298  FloatVector beamTPCIntersection;
299  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
300  XmlHelper::ReadVectorOfValues(xmlHandle, "BeamTPCIntersection", beamTPCIntersection));
301 
302  if (3 == beamTPCIntersection.size())
303  {
304  m_beamTPCIntersection.SetValues(beamTPCIntersection.at(0), beamTPCIntersection.at(1), beamTPCIntersection.at(2));
305  }
306  else if (!beamTPCIntersection.empty())
307  {
308  std::cout << "BeamParticleIdTool::ReadSettings - invalid BeamTPCIntersection specified " << std::endl;
309  return STATUS_CODE_INVALID_PARAMETER;
310  }
311  else
312  {
313  // Default for protoDUNE.
314  m_beamTPCIntersection.SetValues(-33.051, 461.06, 0);
315  }
316 
317  FloatVector beamDirection;
318  PANDORA_RETURN_RESULT_IF_AND_IF(
319  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadVectorOfValues(xmlHandle, "BeamDirection", beamDirection));
320 
321  if (3 == beamDirection.size())
322  {
323  m_beamDirection.SetValues(beamDirection.at(0), beamDirection.at(1), beamDirection.at(2));
324  }
325  else if (!beamDirection.empty())
326  {
327  std::cout << "BeamParticleIdTool::ReadSettings - invalid BeamDirection specified " << std::endl;
328  return STATUS_CODE_INVALID_PARAMETER;
329  }
330  else
331  {
332  // Default for protoDUNE.
333  const float thetaXZ0(-11.844f * M_PI / 180.f);
334  m_beamDirection.SetValues(std::sin(thetaXZ0), 0, std::cos(thetaXZ0));
335  }
336 
337  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
338  XmlHelper::ReadValue(xmlHandle, "ProjectionIntersectionCut", m_projectionIntersectionCut));
339 
340  PANDORA_RETURN_RESULT_IF_AND_IF(
341  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "ClosestDistanceCut", m_closestDistanceCut));
342 
343  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "AngleToBeamCut", m_angleToBeamCut));
344 
345  PANDORA_RETURN_RESULT_IF_AND_IF(
346  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "SelectedFraction", m_selectedFraction));
347 
348  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "NSelectedHits", m_nSelectedHits));
349 
350  return STATUS_CODE_SUCCESS;
351 }
pandora::CartesianVector m_beamTPCIntersection
Intersection of beam and global TPC volume.
bool m_selectAllBeamParticles
First approach: select all beam particles, as opposed to selecting all cosmics.
float m_closestDistanceCut
Closest distance (of hit to beam spot), used in beam event selection.
TFile f
Definition: plotHisto.C:6
float m_angleToBeamCut
Angle between major axis and beam direction, used in beam event selection.
bool m_selectOnlyFirstSliceBeamParticles
First approach: select first slice beam particles, cosmics for all subsequent slices.
unsigned int m_nSelectedHits
Minimum number of hits to use in 3D cluster fits.
float m_selectedFraction
Fraction of hits to use in 3D cluster fits.
float m_projectionIntersectionCut
Projection intersection distance cut, used in beam event selection.
pandora::CartesianVector m_beamDirection
Beam direction.
void lar_content::BeamParticleIdTool::SelectOutputPfos ( const pandora::Algorithm *const  pAlgorithm,
const SliceHypotheses nuSliceHypotheses,
const SliceHypotheses crSliceHypotheses,
pandora::PfoList &  selectedPfos 
)
virtual

Select which reconstruction hypotheses to use; neutrino outcomes or cosmic-ray muon outcomes for each slice.

Parameters
pAlgorithmthe address of the master instance, used to access MCParticles when in training mode
nuSliceHypothesesthe parent pfos representing the neutrino outcome for each slice
crSliceHypothesesthe parent pfos representing the cosmic-ray muon outcome for each slice
sliceNuPfosto receive the list of selected pfos

Implements lar_content::SliceIdBaseTool.

Definition at line 42 of file BeamParticleIdTool.cc.

References f, lar_content::LArPfoHelper::GetAllConnectedPfos(), lar_content::LArPfoHelper::GetCaloHits(), GetSelectedCaloHits(), GetTPCIntercepts(), m_angleToBeamCut, m_beamDirection, m_beamTPCIntersection, m_closestDistanceCut, m_projectionIntersectionCut, m_selectAllBeamParticles, m_selectOnlyFirstSliceBeamParticles, and lar_content::LArPcaHelper::RunPca().

44 {
45  if (beamSliceHypotheses.size() != crSliceHypotheses.size())
46  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
47 
48  // First, simple approach
50  {
51  for (unsigned int sliceIndex = 0, nSlices = beamSliceHypotheses.size(); sliceIndex < nSlices; ++sliceIndex)
52  {
53  const PfoList &sliceOutput((m_selectAllBeamParticles || (m_selectOnlyFirstSliceBeamParticles && (0 == sliceIndex)))
54  ? beamSliceHypotheses.at(sliceIndex)
55  : crSliceHypotheses.at(sliceIndex));
56 
57  const float score(m_selectAllBeamParticles || (m_selectOnlyFirstSliceBeamParticles && (0 == sliceIndex)) ? 1.f : -1.f);
58 
59  for (const ParticleFlowObject *const pPfo : sliceOutput)
60  {
61  object_creation::ParticleFlowObject::Metadata metadata;
62  metadata.m_propertiesToAdd["TestBeamScore"] = score;
63  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ParticleFlowObject::AlterMetadata(*pAlgorithm, pPfo, metadata));
64  }
65 
66  selectedPfos.insert(selectedPfos.end(), sliceOutput.begin(), sliceOutput.end());
67  }
68 
69  return;
70  }
71 
72  // Now start to examine topology of beam slice hypotheses
73  for (unsigned int sliceIndex = 0, nSlices = beamSliceHypotheses.size(); sliceIndex < nSlices; ++sliceIndex)
74  {
75  bool usebeamHypothesis(false);
76 
77  try
78  {
79  PfoList allConnectedPfoList;
80  LArPfoHelper::GetAllConnectedPfos(beamSliceHypotheses.at(sliceIndex), allConnectedPfoList);
81 
82  CaloHitList caloHitList3D;
83  LArPfoHelper::GetCaloHits(allConnectedPfoList, TPC_3D, caloHitList3D);
84 
85  CaloHitList selectedCaloHitList;
86  float closestDistance(std::numeric_limits<float>::max());
87  this->GetSelectedCaloHits(caloHitList3D, selectedCaloHitList, closestDistance);
88 
89  if (!selectedCaloHitList.empty())
90  {
91  CartesianVector centroidSel(0.f, 0.f, 0.f);
92  LArPcaHelper::EigenVectors eigenVecsSel;
93  LArPcaHelper::EigenValues eigenValuesSel(0.f, 0.f, 0.f);
94  LArPcaHelper::RunPca(selectedCaloHitList, centroidSel, eigenValuesSel, eigenVecsSel);
95 
96  const CartesianVector &majorAxisSel(eigenVecsSel.front());
97  const float supplementaryAngleToBeam(majorAxisSel.GetOpeningAngle(m_beamDirection));
98 
99  CartesianVector interceptOne(0.f, 0.f, 0.f), interceptTwo(0.f, 0.f, 0.f);
100  this->GetTPCIntercepts(centroidSel, majorAxisSel, interceptOne, interceptTwo);
101 
102  const float separationOne((interceptOne - m_beamTPCIntersection).GetMagnitude());
103  const float separationTwo((interceptTwo - m_beamTPCIntersection).GetMagnitude());
104 
105  if ((std::min(separationOne, separationTwo) < m_projectionIntersectionCut) && (closestDistance < m_closestDistanceCut) &&
106  (supplementaryAngleToBeam > m_angleToBeamCut))
107  {
108  usebeamHypothesis = true;
109  }
110  }
111  }
112  catch (const StatusCodeException &)
113  {
114  usebeamHypothesis = false;
115  }
116 
117  const PfoList &sliceOutput(usebeamHypothesis ? beamSliceHypotheses.at(sliceIndex) : crSliceHypotheses.at(sliceIndex));
118  selectedPfos.insert(selectedPfos.end(), sliceOutput.begin(), sliceOutput.end());
119 
120  const float score(usebeamHypothesis ? 1.f : -1.f);
121 
122  for (const ParticleFlowObject *const pPfo : sliceOutput)
123  {
124  object_creation::ParticleFlowObject::Metadata metadata;
125  metadata.m_propertiesToAdd["TestBeamScore"] = score;
126  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ParticleFlowObject::AlterMetadata(*pAlgorithm, pPfo, metadata));
127  }
128  }
129 }
pandora::CartesianVector m_beamTPCIntersection
Intersection of beam and global TPC volume.
bool m_selectAllBeamParticles
First approach: select all beam particles, as opposed to selecting all cosmics.
pandora::CartesianVector EigenValues
Definition: LArPcaHelper.h:24
void GetSelectedCaloHits(const pandora::CaloHitList &inputCaloHitList, pandora::CaloHitList &outputCaloHitList, float &closestHitToFaceDistance) const
Select a given fraction of a slice&#39;s calo hits that are closest to the beam spot. ...
float m_closestDistanceCut
Closest distance (of hit to beam spot), used in beam event selection.
TFile f
Definition: plotHisto.C:6
float m_angleToBeamCut
Angle between major axis and beam direction, used in beam event selection.
bool m_selectOnlyFirstSliceBeamParticles
First approach: select first slice beam particles, cosmics for all subsequent slices.
void GetTPCIntercepts(const pandora::CartesianVector &a0, const pandora::CartesianVector &majorAxis, pandora::CartesianVector &interceptOne, pandora::CartesianVector &interceptTwo) const
Find the intercepts of a line with the protoDUNE detector.
static void RunPca(const T &t, pandora::CartesianVector &centroid, EigenValues &outputEigenValues, EigenVectors &outputEigenVectors)
Run principal component analysis using input calo hits (TPC_VIEW_U,V,W or TPC_3D; all treated as 3D p...
std::vector< pandora::CartesianVector > EigenVectors
Definition: LArPcaHelper.h:25
float m_projectionIntersectionCut
Projection intersection distance cut, used in beam event selection.
pandora::CartesianVector m_beamDirection
Beam direction.
static void GetAllConnectedPfos(const pandora::PfoList &inputPfoList, pandora::PfoList &outputPfoList)
Get a flat list of all pfos, recursively including all daughters and parents associated with those pf...
static void GetCaloHits(const pandora::PfoList &pfoList, const pandora::HitType &hitType, pandora::CaloHitList &caloHitList)
Get a list of calo hits of a particular hit type from a list of pfos.

Member Data Documentation

float lar_content::BeamParticleIdTool::m_angleToBeamCut
private

Angle between major axis and beam direction, used in beam event selection.

Definition at line 107 of file BeamParticleIdTool.h.

Referenced by ReadSettings(), and SelectOutputPfos().

pandora::CartesianVector lar_content::BeamParticleIdTool::m_beamDirection
private

Beam direction.

Definition at line 102 of file BeamParticleIdTool.h.

Referenced by ReadSettings(), and SelectOutputPfos().

pandora::CartesianVector lar_content::BeamParticleIdTool::m_beamTPCIntersection
private

Intersection of beam and global TPC volume.

Definition at line 101 of file BeamParticleIdTool.h.

Referenced by GetSelectedCaloHits(), ReadSettings(), and SelectOutputPfos().

float lar_content::BeamParticleIdTool::m_closestDistanceCut
private

Closest distance (of hit to beam spot), used in beam event selection.

Definition at line 106 of file BeamParticleIdTool.h.

Referenced by ReadSettings(), and SelectOutputPfos().

unsigned int lar_content::BeamParticleIdTool::m_nSelectedHits
private

Minimum number of hits to use in 3D cluster fits.

Definition at line 109 of file BeamParticleIdTool.h.

Referenced by GetSelectedCaloHits(), and ReadSettings().

float lar_content::BeamParticleIdTool::m_projectionIntersectionCut
private

Projection intersection distance cut, used in beam event selection.

Definition at line 105 of file BeamParticleIdTool.h.

Referenced by ReadSettings(), and SelectOutputPfos().

bool lar_content::BeamParticleIdTool::m_selectAllBeamParticles
private

First approach: select all beam particles, as opposed to selecting all cosmics.

Definition at line 93 of file BeamParticleIdTool.h.

Referenced by ReadSettings(), and SelectOutputPfos().

float lar_content::BeamParticleIdTool::m_selectedFraction
private

Fraction of hits to use in 3D cluster fits.

Definition at line 108 of file BeamParticleIdTool.h.

Referenced by GetSelectedCaloHits(), and ReadSettings().

bool lar_content::BeamParticleIdTool::m_selectOnlyFirstSliceBeamParticles
private

First approach: select first slice beam particles, cosmics for all subsequent slices.

Definition at line 94 of file BeamParticleIdTool.h.

Referenced by ReadSettings(), and SelectOutputPfos().

float lar_content::BeamParticleIdTool::m_tpcMaxX
private

Global TPC volume maximum x extent.

Definition at line 96 of file BeamParticleIdTool.h.

Referenced by Initialize(), and IsContained().

float lar_content::BeamParticleIdTool::m_tpcMaxY
private

Global TPC volume maximum y extent.

Definition at line 98 of file BeamParticleIdTool.h.

Referenced by Initialize(), and IsContained().

float lar_content::BeamParticleIdTool::m_tpcMaxZ
private

Global TPC volume maximum z extent.

Definition at line 100 of file BeamParticleIdTool.h.

Referenced by Initialize(), and IsContained().

float lar_content::BeamParticleIdTool::m_tpcMinX
private

Global TPC volume minimum x extent.

Definition at line 95 of file BeamParticleIdTool.h.

Referenced by Initialize(), and IsContained().

float lar_content::BeamParticleIdTool::m_tpcMinY
private

Global TPC volume minimum y extent.

Definition at line 97 of file BeamParticleIdTool.h.

Referenced by Initialize(), and IsContained().

float lar_content::BeamParticleIdTool::m_tpcMinZ
private

Global TPC volume minimum z extent.

Definition at line 99 of file BeamParticleIdTool.h.

Referenced by Initialize(), and IsContained().

PlaneVector lar_content::BeamParticleIdTool::m_tpcPlanes
private

Vector of all planes making up global TPC volume.

Definition at line 103 of file BeamParticleIdTool.h.

Referenced by GetTPCIntercepts(), and Initialize().


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