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

LArMuonLeadingHelper class. More...

#include "LArMuonLeadingHelper.h"

Classes

class  ValidationParameters
 ValidationParameters class. More...
 

Public Types

typedef std::map< const pandora::MCParticle *, pandora::CaloHitList > LeadingMCParticleToPostBremsstrahlungHitList
 

Static Public Member Functions

static MCProcess GetLeadingProcess (const pandora::MCParticle *const pMCParticle)
 Return the MCProcess of the leading particle (tier 1) in the delta ray/michel hierarchy. More...
 
static bool IsDeltaRay (const pandora::MCParticle *const pMCParticle)
 Return true if input MCParticle is a child of a cosmic ray and has 'delta ray' process tag. More...
 
static bool IsMichel (const pandora::MCParticle *const pMCParticle)
 Return true if input MCParticle is a child of a cosmic ray and has 'decay' process tag. More...
 
static bool IsMuonLeading (const pandora::MCParticle *const pMCParticle)
 Return true if input MCParticle is in tier 1 of the cosmic ray hierarchy. More...
 
static const pandora::MCParticle * GetLeadingParticle (const pandora::MCParticle *const pMCParticle)
 Return leading particle in the delta ray/michel hierarchy i.e. tier below cosmic ray. More...
 
static void SelectReconstructableLeadingParticles (const pandora::MCParticleList *pMCParticleList, const pandora::CaloHitList *pCaloHitList, const ValidationParameters &parameters, const pandora::CaloHitList &recoMuonHitList, LArMCParticleHelper::MCContributionMap &selectedMCParticlesToHitsMap)
 Select target, reconstructable mc particles in the cosmic ray hierarchy. More...
 
static void GetPfoMatchContamination (const pandora::MCParticle *const pLeadingParticle, const pandora::CaloHitList &matchedPfoHitList, pandora::CaloHitList &parentTrackHits, pandora::CaloHitList &otherTrackHits, pandora::CaloHitList &otherShowerHits)
 Separate a leading pfo hit list according to the true owner of the hit e.g. other shower. More...
 
static void GetMuonPfoContaminationContribution (const pandora::CaloHitList &cosmicRayPfoHitList, const pandora::CaloHitList &leadingMCHitList, pandora::CaloHitList &leadingHitsInParentCosmicRay)
 Determine the leading MCParticle hits within a cosmic ray pfo hit list. More...
 
static float GetClosestDistance (const pandora::Cluster *const pCluster, const pandora::CartesianPointVector &cartesianPointVector)
 Get closest distance between a specified cluster and list of positions. More...
 
static float GetClosestDistance (const pandora::CaloHit *const pCaloHit, const pandora::CartesianPointVector &cartesianPointVector)
 Get closest distance between a specified calo hit and list of positions. More...
 
static pandora::StatusCode GetClosestPosition (const pandora::CartesianVector &referencePoint, const pandora::CartesianPointVector &cartesianPointVector, const pandora::Cluster *const pCluster, const float maxDistanceToCluster, const float maxDistanceToReferencePoint, pandora::CartesianVector &closestPosition)
 Get the closest position from an input list of projected positions that lies close to both a reference point and an input cluster. More...
 
static void GetClosestPositions (const pandora::CartesianPointVector &cartesianPointVector1, const pandora::Cluster *const pCluster2, pandora::CartesianVector &outputPosition1, pandora::CartesianVector &outputPosition2)
 Get the closest positions between a list of positions and a cluster. More...
 

Static Private Member Functions

static void GetMCToLeadingMap (const pandora::MCParticleList *const pMCParticleList, LArMCParticleHelper::MCRelationMap &mcToLeadingMap)
 Construct the hierarchy folding map (cosmic rays folded to themselves, delta ray/michel hierarchy folded to leading particle) More...
 
static void SelectCaloHits (const pandora::CaloHitList *const pCaloHitList, const LArMCParticleHelper::MCRelationMap &mcToTargetMCMap, pandora::CaloHitList &selectedCaloHitList, const bool selectInputHits, const float minHitSharingFraction, const pandora::CaloHitList &recoMuonHitList, LeadingMCParticleToPostBremsstrahlungHitList &leadingMCParticleToPostBremsstrahlungHitList)
 Select a subset of calo hits representing those that represent "reconstructable" regions of the event. More...
 
static bool RejectBremsstrahlungHits (const pandora::CaloHit *const pCaloHit, LeadingMCParticleToPostBremsstrahlungHitList &leadingMCParticleToPostBremsstrahlungHitList)
 Identify and record the hits that are post-bremsstralung radiation in a cosmic ray hierarchy. More...
 
static void AddInPostBremsstrahlungHits (const LeadingMCParticleToPostBremsstrahlungHitList &leadingMCParticleToPostBremsstrahlungHitList, const float maxBremsstrahlungSeparation, LArMCParticleHelper::MCContributionMap &leadingMCToTrueHitListMap)
 Identify the reconstructable post-bremsstrahlung radiation hits. More...
 
static void AddInPostBremsstrahlungHits (const pandora::MCParticle *const pLeadingParticle, const LeadingMCParticleToPostBremsstrahlungHitList &leadingMCParticleToPostBremsstrahlungHitList, const float maxBremsstrahlungSeparation, LArMCParticleHelper::MCContributionMap &leadingMCToTrueHitListMap, const pandora::HitType tpcView)
 Identify the reconstructable post-bremsstrahlung radiation hits. More...
 
static void SelectLeadingMCParticles (const pandora::MCParticleList *pMCParticleList, pandora::MCParticleVector &selectedParticles)
 Select all tier 0 and tier 1 MCParticles in cosmic ray hierarchies from an input list. More...
 

Detailed Description

LArMuonLeadingHelper class.

Definition at line 20 of file LArMuonLeadingHelper.h.

Member Typedef Documentation

typedef std::map<const pandora::MCParticle *, pandora::CaloHitList> lar_content::LArMuonLeadingHelper::LeadingMCParticleToPostBremsstrahlungHitList

Definition at line 37 of file LArMuonLeadingHelper.h.

Member Function Documentation

void lar_content::LArMuonLeadingHelper::AddInPostBremsstrahlungHits ( const LeadingMCParticleToPostBremsstrahlungHitList leadingMCParticleToPostBremsstrahlungHitList,
const float  maxBremsstrahlungSeparation,
LArMCParticleHelper::MCContributionMap leadingMCToTrueHitListMap 
)
staticprivate

Identify the reconstructable post-bremsstrahlung radiation hits.

Parameters
leadingMCParticleToPostBremsstrahlungHitListthe mapping of leading MCParticles to post-bremsstrahlung hits
maxBremsstrahlungSeparationthe maximum separation of a reconstructable post-bremsstrahlung hit from the pre-radiation hits
leadingMCToTrueHitListMapthe mapping of cosmic ray and leading MCParticles to their reconstructable hits

Definition at line 265 of file LArMuonLeadingHelper.cc.

References lar_content::LArClusterHelper::GetClosestDistance().

Referenced by SelectReconstructableLeadingParticles().

267 {
268  MCParticleVector leadingMCParticleVector;
269  for (auto &entry : leadingMCParticleToPostBremsstrahlungHitList)
270  leadingMCParticleVector.push_back(entry.first);
271 
272  for (const MCParticle *const pLeadingMCParticle : leadingMCParticleVector)
273  {
274  // Do not add in hits for which there are no main particle hits
275  if (leadingMCToTrueHitListMap.find(pLeadingMCParticle) == leadingMCToTrueHitListMap.end())
276  continue;
277 
278  LArMuonLeadingHelper::AddInPostBremsstrahlungHits(pLeadingMCParticle, leadingMCParticleToPostBremsstrahlungHitList,
279  maxBremsstrahlungSeparation, leadingMCToTrueHitListMap, TPC_VIEW_U);
280  LArMuonLeadingHelper::AddInPostBremsstrahlungHits(pLeadingMCParticle, leadingMCParticleToPostBremsstrahlungHitList,
281  maxBremsstrahlungSeparation, leadingMCToTrueHitListMap, TPC_VIEW_V);
282  LArMuonLeadingHelper::AddInPostBremsstrahlungHits(pLeadingMCParticle, leadingMCParticleToPostBremsstrahlungHitList,
283  maxBremsstrahlungSeparation, leadingMCToTrueHitListMap, TPC_VIEW_W);
284  }
285 }
static void AddInPostBremsstrahlungHits(const LeadingMCParticleToPostBremsstrahlungHitList &leadingMCParticleToPostBremsstrahlungHitList, const float maxBremsstrahlungSeparation, LArMCParticleHelper::MCContributionMap &leadingMCToTrueHitListMap)
Identify the reconstructable post-bremsstrahlung radiation hits.
std::vector< art::Ptr< simb::MCParticle > > MCParticleVector
static void lar_content::LArMuonLeadingHelper::AddInPostBremsstrahlungHits ( const pandora::MCParticle *const  pLeadingParticle,
const LeadingMCParticleToPostBremsstrahlungHitList leadingMCParticleToPostBremsstrahlungHitList,
const float  maxBremsstrahlungSeparation,
LArMCParticleHelper::MCContributionMap leadingMCToTrueHitListMap,
const pandora::HitType  tpcView 
)
staticprivate

Identify the reconstructable post-bremsstrahlung radiation hits.

Parameters
pLeadingParticlethe address of the input leading MCParticle
leadingMCParticleToPostBremsstrahlungHitListthe mapping of leading MCParticles to post-bremsstrahlung hits
maxBremsstrahlungSeparationthe maximum separation of a reconstructable post-bremsstrahlung hit from the pre-radiation hits
leadingMCToTrueHitListMapthe mapping of cosmic ray and leading MCParticles to their reconstructable hits
tpcViewthe TPC view of the hits to be collected
static float lar_content::LArMuonLeadingHelper::GetClosestDistance ( const pandora::Cluster *const  pCluster,
const pandora::CartesianPointVector &  cartesianPointVector 
)
static

Get closest distance between a specified cluster and list of positions.

Parameters
pClusteraddress of the input cluster
cartesianPointVectorthe list of input positions
Returns
the closest distance

Referenced by lar_content::TwoViewDeltaRayMatchingAlgorithm::CollectThirdViewClusters(), GetMuonPfoContaminationContribution(), and lar_content::NViewDeltaRayMatchingAlgorithm< T >::GetProjectedPositions().

static float lar_content::LArMuonLeadingHelper::GetClosestDistance ( const pandora::CaloHit *const  pCaloHit,
const pandora::CartesianPointVector &  cartesianPointVector 
)
static

Get closest distance between a specified calo hit and list of positions.

Parameters
pCaloHitthe address of the input calo hit
cartesianPointVectorthe list of input positions
Returns
the closest distance
StatusCode lar_content::LArMuonLeadingHelper::GetClosestPosition ( const pandora::CartesianVector &  referencePoint,
const pandora::CartesianPointVector &  cartesianPointVector,
const pandora::Cluster *const  pCluster,
const float  maxDistanceToCluster,
const float  maxDistanceToReferencePoint,
pandora::CartesianVector &  closestPosition 
)
static

Get the closest position from an input list of projected positions that lies close to both a reference point and an input cluster.

Parameters
referencePointthe input reference point
cartesianPointVectorthe input list of projected positions
pClusterthe input cluster
maxDistanceToClusterthe maximum distance to the cluster
maxDistanceToReferencePointthe maximum distance to the reference point
closestPositionto receive the closest position if found
Returns
whether a closest position could be found

Definition at line 445 of file LArMuonLeadingHelper.cc.

References lar_content::LArClusterHelper::GetClosestDistance().

Referenced by lar_content::NViewDeltaRayMatchingAlgorithm< T >::GetProjectedPositions().

447 {
448  bool found(false);
449  float shortestDistanceSquared(std::numeric_limits<float>::max());
450 
451  for (const CartesianVector &testPosition : cartesianPointVector)
452  {
453  if (LArClusterHelper::GetClosestDistance(testPosition, pCluster) > maxDistanceToCluster)
454  continue;
455 
456  const float separationSquared((testPosition - referencePoint).GetMagnitude());
457 
458  if (separationSquared > maxDistanceToReferencePoint)
459  continue;
460 
461  if (separationSquared < shortestDistanceSquared)
462  {
463  shortestDistanceSquared = separationSquared;
464  closestPosition = testPosition;
465  found = true;
466  }
467  }
468 
469  return found ? STATUS_CODE_SUCCESS : STATUS_CODE_NOT_FOUND;
470 }
static float GetClosestDistance(const pandora::ClusterList &clusterList1, const pandora::ClusterList &clusterList2)
Get closest distance between clusters in a pair of cluster lists.
void lar_content::LArMuonLeadingHelper::GetClosestPositions ( const pandora::CartesianPointVector &  cartesianPointVector1,
const pandora::Cluster *const  pCluster2,
pandora::CartesianVector &  outputPosition1,
pandora::CartesianVector &  outputPosition2 
)
static

Get the closest positions between a list of positions and a cluster.

Parameters
cartesianPointVector1the input list of positions
pCluster2the address of the input cluster
outputPosition1the closest position in the list of positions
outputPosition2the closest position in the cluster

Definition at line 474 of file LArMuonLeadingHelper.cc.

References f.

Referenced by lar_content::NViewDeltaRayMatchingAlgorithm< T >::GetProjectedPositions().

476 {
477  bool distanceFound(false);
478  float minDistanceSquared(std::numeric_limits<float>::max());
479 
480  CartesianVector closestPosition1(0.f, 0.f, 0.f);
481  CartesianVector closestPosition2(0.f, 0.f, 0.f);
482 
483  CaloHitList caloHitList2;
484  pCluster2->GetOrderedCaloHitList().FillCaloHitList(caloHitList2);
485 
486  for (const CartesianVector &positionVector1 : cartesianPointVector1)
487  {
488  for (const CaloHit *const pCaloHit : caloHitList2)
489  {
490  const CartesianVector &positionVector2(pCaloHit->GetPositionVector());
491 
492  const float distanceSquared((positionVector1 - positionVector2).GetMagnitudeSquared());
493 
494  if (distanceSquared < minDistanceSquared)
495  {
496  minDistanceSquared = distanceSquared;
497  closestPosition1 = positionVector1;
498  closestPosition2 = positionVector2;
499  distanceFound = true;
500  }
501  }
502  }
503 
504  if (!distanceFound)
505  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
506 
507  outputPosition1 = closestPosition1;
508  outputPosition2 = closestPosition2;
509 }
TFile f
Definition: plotHisto.C:6
const MCParticle * lar_content::LArMuonLeadingHelper::GetLeadingParticle ( const pandora::MCParticle *const  pMCParticle)
static

Return leading particle in the delta ray/michel hierarchy i.e. tier below cosmic ray.

Parameters
pMCParticlethe input MCParticle

Definition at line 73 of file LArMuonLeadingHelper.cc.

References lar_content::LArMCParticleHelper::GetHierarchyTier().

Referenced by GetLeadingProcess(), GetMCToLeadingMap(), and GetPfoMatchContamination().

74 {
75  if (!pMCParticle)
76  throw StatusCodeException(STATUS_CODE_FAILURE);
77 
78  if (LArMCParticleHelper::GetHierarchyTier(pMCParticle) == 0)
79  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
80 
81  const MCParticle *pParentMCParticle = pMCParticle;
82 
83  while (LArMCParticleHelper::GetHierarchyTier(pParentMCParticle) != 1)
84  {
85  const MCParticleList &parentList(pParentMCParticle->GetParentList());
86 
87  if (parentList.size() != 1)
88  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
89 
90  pParentMCParticle = parentList.front();
91  }
92 
93  return pParentMCParticle;
94 }
static int GetHierarchyTier(const pandora::MCParticle *const pMCParticle)
Determine the position in the hierarchy for the MCParticle.
MCProcess lar_content::LArMuonLeadingHelper::GetLeadingProcess ( const pandora::MCParticle *const  pMCParticle)
static

Return the MCProcess of the leading particle (tier 1) in the delta ray/michel hierarchy.

Parameters
pMCParticlethe address of the input MCParticle
Returns
the MCProcess of the leading particle (tier 1) in the delta ray/michel hierarchy

Definition at line 34 of file LArMuonLeadingHelper.cc.

References lar_content::LArMCParticleHelper::GetHierarchyTier(), GetLeadingParticle(), lar_content::LArMCParticle::GetProcess(), and lar_content::MC_PROC_UNKNOWN.

Referenced by IsDeltaRay(), and IsMichel().

35 {
36  if (LArMCParticleHelper::GetHierarchyTier(pMCParticle) == 0)
37  return MC_PROC_UNKNOWN;
38 
39  const MCParticle *const pLeadingParticle(LArMuonLeadingHelper::GetLeadingParticle(pMCParticle));
40  const LArMCParticle *const pLArMCParticle(dynamic_cast<const LArMCParticle *>(pLeadingParticle));
41 
42  if (!pLArMCParticle)
43  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
44 
45  return pLArMCParticle->GetProcess();
46 }
static const pandora::MCParticle * GetLeadingParticle(const pandora::MCParticle *const pMCParticle)
Return leading particle in the delta ray/michel hierarchy i.e. tier below cosmic ray.
static int GetHierarchyTier(const pandora::MCParticle *const pMCParticle)
Determine the position in the hierarchy for the MCParticle.
void lar_content::LArMuonLeadingHelper::GetMCToLeadingMap ( const pandora::MCParticleList *const  pMCParticleList,
LArMCParticleHelper::MCRelationMap mcToLeadingMap 
)
staticprivate

Construct the hierarchy folding map (cosmic rays folded to themselves, delta ray/michel hierarchy folded to leading particle)

Parameters
pMCParticleListthe address of the list of MCParticles
mcToLeadingMapthe hierarchy folding map

Definition at line 98 of file LArMuonLeadingHelper.cc.

References GetLeadingParticle(), lar_content::LArMCParticleHelper::GetParentMCParticle(), and lar_content::LArMCParticleHelper::IsCosmicRay().

Referenced by SelectReconstructableLeadingParticles().

99 {
100  for (const MCParticle *const pMCParticle : *pMCParticleList)
101  {
102  const MCParticle *const pParentMCParticle(LArMCParticleHelper::GetParentMCParticle(pMCParticle));
103 
104  if (!LArMCParticleHelper::IsCosmicRay(pParentMCParticle))
105  continue;
106 
107  // For the CRs: fold hits to themselves, for the DRs: fold hits to the leading MCParticle
108  if (pMCParticle == pParentMCParticle)
109  {
110  mcToLeadingMap[pMCParticle] = pMCParticle;
111  }
112  else
113  {
114  const MCParticle *const pLeadingMCParticle(LArMuonLeadingHelper::GetLeadingParticle(pMCParticle));
115  mcToLeadingMap[pMCParticle] = pLeadingMCParticle;
116  }
117  }
118 }
static const pandora::MCParticle * GetLeadingParticle(const pandora::MCParticle *const pMCParticle)
Return leading particle in the delta ray/michel hierarchy i.e. tier below cosmic ray.
static bool IsCosmicRay(const pandora::MCParticle *const pMCParticle)
Return true if passed a primary cosmic ray MCParticle.
static const pandora::MCParticle * GetParentMCParticle(const pandora::MCParticle *const pMCParticle)
Get the parent mc particle.
void lar_content::LArMuonLeadingHelper::GetMuonPfoContaminationContribution ( const pandora::CaloHitList &  cosmicRayPfoHitList,
const pandora::CaloHitList &  leadingMCHitList,
pandora::CaloHitList &  leadingHitsInParentCosmicRay 
)
static

Determine the leading MCParticle hits within a cosmic ray pfo hit list.

Parameters
cosmicRayPfoHitListthe cosmic ray pfo hit list
leadingMCHitListthe list of hits that belong to the leading MCParticle
leadingHitsInParentCosmicRaythe output list of 'stolen' leading MCParticle hits

Definition at line 395 of file LArMuonLeadingHelper.cc.

References GetClosestDistance().

Referenced by lar_content::MuonLeadingEventValidationAlgorithm::ProcessOutput().

397 {
398  for (const CaloHit *const pCaloHit : cosmicRayPfoHitList)
399  {
400  if (std::find(leadingMCHitList.begin(), leadingMCHitList.end(), pCaloHit) != leadingMCHitList.end())
401  leadingHitsInParentCosmicRay.push_back(pCaloHit);
402  }
403 }
void lar_content::LArMuonLeadingHelper::GetPfoMatchContamination ( const pandora::MCParticle *const  pLeadingParticle,
const pandora::CaloHitList &  matchedPfoHitList,
pandora::CaloHitList &  parentTrackHits,
pandora::CaloHitList &  otherTrackHits,
pandora::CaloHitList &  otherShowerHits 
)
static

Separate a leading pfo hit list according to the true owner of the hit e.g. other shower.

Parameters
pLeadingParticlethe address of the input leading MCParticle
matchedPfoHitListthe input leading pfo hit list
parentTrackHitsthe output list of hits that belong to the parent cosmic ray
otherTrackHitsthe output list of hits that belong to a cosmic ray that is not the parent
otherShowerHitsthe output list of hits that belong to a different shower hierarchy

Definition at line 370 of file LArMuonLeadingHelper.cc.

References GetLeadingParticle(), lar_content::LArMCParticleHelper::GetParentMCParticle(), and lar_content::LArMCParticleHelper::IsCosmicRay().

Referenced by lar_content::MuonLeadingEventValidationAlgorithm::ProcessOutput().

372 {
373  const MCParticle *const pParentCosmicRay(LArMCParticleHelper::GetParentMCParticle(pLeadingParticle));
374 
375  for (const CaloHit *const pCaloHit : matchedPfoHitList)
376  {
377  const MCParticle *const pHitParticle(MCParticleHelper::GetMainMCParticle(pCaloHit));
378 
379  if (LArMCParticleHelper::IsCosmicRay(pHitParticle))
380  {
381  (pHitParticle == pParentCosmicRay) ? parentTrackHits.push_back(pCaloHit) : otherTrackHits.push_back(pCaloHit);
382  }
383  else
384  {
385  const MCParticle *const pHitLeadingParticle(LArMuonLeadingHelper::GetLeadingParticle(pHitParticle));
386 
387  if (pHitLeadingParticle != pLeadingParticle)
388  otherShowerHits.push_back(pCaloHit);
389  }
390  }
391 }
static const pandora::MCParticle * GetLeadingParticle(const pandora::MCParticle *const pMCParticle)
Return leading particle in the delta ray/michel hierarchy i.e. tier below cosmic ray.
static bool IsCosmicRay(const pandora::MCParticle *const pMCParticle)
Return true if passed a primary cosmic ray MCParticle.
static const pandora::MCParticle * GetParentMCParticle(const pandora::MCParticle *const pMCParticle)
Get the parent mc particle.
bool lar_content::LArMuonLeadingHelper::IsDeltaRay ( const pandora::MCParticle *const  pMCParticle)
static

Return true if input MCParticle is a child of a cosmic ray and has 'delta ray' process tag.

Parameters
pMCParticlethe input MCParticle

Definition at line 50 of file LArMuonLeadingHelper.cc.

References GetLeadingProcess(), and lar_content::MC_PROC_MU_IONI.

Referenced by lar_content::MuonLeadingEventValidationAlgorithm::ProcessOutput().

51 {
53 }
static MCProcess GetLeadingProcess(const pandora::MCParticle *const pMCParticle)
Return the MCProcess of the leading particle (tier 1) in the delta ray/michel hierarchy.
bool lar_content::LArMuonLeadingHelper::IsMichel ( const pandora::MCParticle *const  pMCParticle)
static

Return true if input MCParticle is a child of a cosmic ray and has 'decay' process tag.

Parameters
pMCParticlethe input MCParticle

Definition at line 57 of file LArMuonLeadingHelper.cc.

References GetLeadingProcess(), and lar_content::MC_PROC_DECAY.

Referenced by lar_content::MuonLeadingEventValidationAlgorithm::ProcessOutput().

58 {
60 }
static MCProcess GetLeadingProcess(const pandora::MCParticle *const pMCParticle)
Return the MCProcess of the leading particle (tier 1) in the delta ray/michel hierarchy.
bool lar_content::LArMuonLeadingHelper::IsMuonLeading ( const pandora::MCParticle *const  pMCParticle)
static

Return true if input MCParticle is in tier 1 of the cosmic ray hierarchy.

Parameters
pMCParticlethe input MCParticle

Definition at line 64 of file LArMuonLeadingHelper.cc.

References lar_content::LArMCParticleHelper::GetHierarchyTier(), lar_content::LArMCParticleHelper::GetParentMCParticle(), and lar_content::LArMCParticleHelper::IsCosmicRay().

Referenced by RejectBremsstrahlungHits(), and SelectLeadingMCParticles().

65 {
66  const MCParticle *const pParentMCParticle(LArMCParticleHelper::GetParentMCParticle(pMCParticle));
67 
68  return ((LArMCParticleHelper::GetHierarchyTier(pMCParticle) == 1) && (LArMCParticleHelper::IsCosmicRay(pParentMCParticle)));
69 }
static int GetHierarchyTier(const pandora::MCParticle *const pMCParticle)
Determine the position in the hierarchy for the MCParticle.
static bool IsCosmicRay(const pandora::MCParticle *const pMCParticle)
Return true if passed a primary cosmic ray MCParticle.
static const pandora::MCParticle * GetParentMCParticle(const pandora::MCParticle *const pMCParticle)
Get the parent mc particle.
bool lar_content::LArMuonLeadingHelper::RejectBremsstrahlungHits ( const pandora::CaloHit *const  pCaloHit,
LeadingMCParticleToPostBremsstrahlungHitList leadingMCParticleToPostBremsstrahlungHitList 
)
staticprivate

Identify and record the hits that are post-bremsstralung radiation in a cosmic ray hierarchy.

Parameters
pCaloHitthe address of the input calo hit
leadingMCParticleToPostBremsstrahlungHitListthe mapping of leading MCParticles to post-bremsstrahlung hits
Returns
whether the hit lies post-bremsstrahlung radiation in a cosmic ray hierarchy

Definition at line 231 of file LArMuonLeadingHelper.cc.

References lar_content::LArMCParticleHelper::GetAllAncestorMCParticles(), lar_content::LArMCParticleHelper::GetHierarchyTier(), and IsMuonLeading().

Referenced by SelectCaloHits().

233 {
234  const MCParticle *const pHitMCParticle(MCParticleHelper::GetMainMCParticle(pCaloHit));
235 
236  MCParticleList ancestorMCParticleList;
237  LArMCParticleHelper::GetAllAncestorMCParticles(pHitMCParticle, ancestorMCParticleList);
238 
239  bool isPostBremsstrahlung(false);
240  const MCParticle *leadingMCParticle(nullptr);
241 
242  for (const MCParticle *const pAncestorMCParticle : ancestorMCParticleList)
243  {
244  if (LArMCParticleHelper::GetHierarchyTier(pAncestorMCParticle) == 1)
245  {
246  if (LArMuonLeadingHelper::IsMuonLeading(pAncestorMCParticle))
247  leadingMCParticle = pAncestorMCParticle;
248  }
249 
250  if (pAncestorMCParticle->GetParticleId() == PHOTON)
251  isPostBremsstrahlung = true;
252  }
253 
254  if (isPostBremsstrahlung && leadingMCParticle)
255  {
256  leadingMCParticleToPostBremsstrahlungHitList[leadingMCParticle].push_back(pCaloHit);
257  return true;
258  }
259 
260  return false;
261 }
static int GetHierarchyTier(const pandora::MCParticle *const pMCParticle)
Determine the position in the hierarchy for the MCParticle.
static void GetAllAncestorMCParticles(const pandora::MCParticle *const pMCParticle, pandora::MCParticleList &ancestorMCParticleList)
Get all ancestor mc particles.
static bool IsMuonLeading(const pandora::MCParticle *const pMCParticle)
Return true if input MCParticle is in tier 1 of the cosmic ray hierarchy.
void lar_content::LArMuonLeadingHelper::SelectCaloHits ( const pandora::CaloHitList *const  pCaloHitList,
const LArMCParticleHelper::MCRelationMap mcToTargetMCMap,
pandora::CaloHitList &  selectedCaloHitList,
const bool  selectInputHits,
const float  minHitSharingFraction,
const pandora::CaloHitList &  recoMuonHitList,
LeadingMCParticleToPostBremsstrahlungHitList leadingMCParticleToPostBremsstrahlungHitList 
)
staticprivate

Select a subset of calo hits representing those that represent "reconstructable" regions of the event.

Parameters
pCaloHitListthe address of the input calo hit list
mcToTargetMCMapthe MCParticle to leading MCParticle map
selectedCaloHitListto receive the populated selected calo hit list
selectInputHitswhether to select input hits
minHitSharingFractionthe minimum required charge share of the hit
recoMuonHitListthe list of reconstructed cosmic ray hits
leadingMCParticleToPostBremsstrahlungHitListthe mapping of leading MCParticles to post-bremsstrahlung hits

Definition at line 154 of file LArMuonLeadingHelper.cc.

References f, lar_content::LArMCParticleHelper::IsCosmicRay(), RejectBremsstrahlungHits(), and weight.

Referenced by SelectReconstructableLeadingParticles().

157 {
158  if (!selectInputHits)
159  {
160  selectedCaloHitList.insert(selectedCaloHitList.end(), pCaloHitList->begin(), pCaloHitList->end());
161  return;
162  }
163 
164  for (const CaloHit *const pCaloHit : *pCaloHitList)
165  {
166  try
167  {
168  const MCParticle *const pHitParticle(MCParticleHelper::GetMainMCParticle(pCaloHit));
169 
170  if (mcToTargetMCMap.find(pHitParticle) == mcToTargetMCMap.end())
171  continue;
172 
173  // Remove delta ray hits that have been 'stolen' by the muon
174  if (!LArMCParticleHelper::IsCosmicRay(mcToTargetMCMap.at(pHitParticle)))
175  {
176  if (std::find(recoMuonHitList.begin(), recoMuonHitList.end(), pCaloHit) != recoMuonHitList.end())
177  continue;
178  }
179 
180  MCParticleVector mcParticleContributionVector;
181  for (const auto &mapEntry : pCaloHit->GetMCParticleWeightMap())
182  mcParticleContributionVector.push_back(mapEntry.first);
183 
184  std::sort(mcParticleContributionVector.begin(), mcParticleContributionVector.end(), PointerLessThan<MCParticle>());
185 
186  MCParticleWeightMap targetWeightMap;
187  for (const MCParticle *const pMCParticle : mcParticleContributionVector)
188  {
189  const float weight(pCaloHit->GetMCParticleWeightMap().at(pMCParticle));
190  LArMCParticleHelper::MCRelationMap::const_iterator mcIter = mcToTargetMCMap.find(pMCParticle);
191 
192  if (mcToTargetMCMap.end() != mcIter)
193  targetWeightMap[mcIter->second] += weight;
194  }
195 
196  MCParticleVector mcTargetContributionVector;
197  for (const auto &mapEntry : targetWeightMap)
198  mcTargetContributionVector.push_back(mapEntry.first);
199  std::sort(mcTargetContributionVector.begin(), mcTargetContributionVector.end(), PointerLessThan<MCParticle>());
200 
201  float bestTargetWeight(0.f), targetWeightSum(0.f);
202 
203  for (const MCParticle *const pTargetMCParticle : mcTargetContributionVector)
204  {
205  const float targetWeight(targetWeightMap.at(pTargetMCParticle));
206  targetWeightSum += targetWeight;
207 
208  if (targetWeight > bestTargetWeight)
209  {
210  bestTargetWeight = targetWeight;
211  }
212  }
213 
214  if ((targetWeightSum < std::numeric_limits<float>::epsilon()) || ((bestTargetWeight / targetWeightSum) < minHitSharingFraction))
215  continue;
216 
217  // Remove and record post bremsstrahlung hits
218  if (LArMuonLeadingHelper::RejectBremsstrahlungHits(pCaloHit, leadingMCParticleToPostBremsstrahlungHitList))
219  continue;
220 
221  selectedCaloHitList.push_back(pCaloHit);
222  }
223  catch (const StatusCodeException &)
224  {
225  }
226  }
227 }
static bool RejectBremsstrahlungHits(const pandora::CaloHit *const pCaloHit, LeadingMCParticleToPostBremsstrahlungHitList &leadingMCParticleToPostBremsstrahlungHitList)
Identify and record the hits that are post-bremsstralung radiation in a cosmic ray hierarchy...
intermediate_table::const_iterator const_iterator
TFile f
Definition: plotHisto.C:6
static bool IsCosmicRay(const pandora::MCParticle *const pMCParticle)
Return true if passed a primary cosmic ray MCParticle.
std::vector< art::Ptr< simb::MCParticle > > MCParticleVector
double weight
Definition: plottest35.C:25
void lar_content::LArMuonLeadingHelper::SelectLeadingMCParticles ( const pandora::MCParticleList *  pMCParticleList,
pandora::MCParticleVector &  selectedParticles 
)
staticprivate

Select all tier 0 and tier 1 MCParticles in cosmic ray hierarchies from an input list.

Parameters
pMCParticlethe address of the input MCParticle list
selectedParticlesthe output vector of selected MCParticles

Definition at line 345 of file LArMuonLeadingHelper.cc.

References lar_content::LArMCParticleHelper::GetParentMCParticle(), lar_content::LArMCParticleHelper::IsCosmicRay(), IsMuonLeading(), and lar_content::LArMCParticleHelper::SortByMomentum().

Referenced by SelectReconstructableLeadingParticles().

346 {
347  for (const MCParticle *const pMCParticle : *pMCParticleList)
348  {
349  const MCParticle *const pParentMCParticle(LArMCParticleHelper::GetParentMCParticle(pMCParticle));
350 
351  if (!LArMCParticleHelper::IsCosmicRay(pParentMCParticle))
352  continue;
353 
354  if (pMCParticle == pParentMCParticle)
355  {
356  selectedParticles.push_back(pMCParticle);
357  }
358  else
359  {
360  if (LArMuonLeadingHelper::IsMuonLeading(pMCParticle))
361  selectedParticles.push_back(pMCParticle);
362  }
363  }
364 
365  std::sort(selectedParticles.begin(), selectedParticles.end(), LArMCParticleHelper::SortByMomentum);
366 }
static bool SortByMomentum(const pandora::MCParticle *const pLhs, const pandora::MCParticle *const pRhs)
Sort mc particles by their momentum.
static bool IsCosmicRay(const pandora::MCParticle *const pMCParticle)
Return true if passed a primary cosmic ray MCParticle.
static const pandora::MCParticle * GetParentMCParticle(const pandora::MCParticle *const pMCParticle)
Get the parent mc particle.
static bool IsMuonLeading(const pandora::MCParticle *const pMCParticle)
Return true if input MCParticle is in tier 1 of the cosmic ray hierarchy.
void lar_content::LArMuonLeadingHelper::SelectReconstructableLeadingParticles ( const pandora::MCParticleList *  pMCParticleList,
const pandora::CaloHitList *  pCaloHitList,
const ValidationParameters parameters,
const pandora::CaloHitList &  recoMuonHitList,
LArMCParticleHelper::MCContributionMap selectedMCParticlesToHitsMap 
)
static

Select target, reconstructable mc particles in the cosmic ray hierarchy.

Parameters
pMCParticleListthe address of the list of MCParticles
pCaloHitListthe address of the list of CaloHits
parametersvalidation parameters to decide when an MCParticle is considered reconstructable
recoMuonHitListthe list of reconstructed cosmic ray hits
selectedMCParticlesToHitsMapthe output mapping from selected MCParticles to their hits

Definition at line 122 of file LArMuonLeadingHelper.cc.

References AddInPostBremsstrahlungHits(), lar_content::LArMCParticleHelper::GetMCParticleToCaloHitMatches(), GetMCToLeadingMap(), lar_content::LArMuonLeadingHelper::ValidationParameters::m_maxBremsstrahlungSeparation, lar_content::LArMCParticleHelper::PrimaryParameters::m_minHitSharingFraction, lar_content::LArMCParticleHelper::PrimaryParameters::m_selectInputHits, SelectCaloHits(), SelectLeadingMCParticles(), and lar_content::LArMCParticleHelper::SelectParticlesByHitCount().

Referenced by lar_content::MuonLeadingEventValidationAlgorithm::PerformUnfoldedMatching().

124 {
125  // Obtain hierarchy folding map:
126  LArMCParticleHelper::MCRelationMap mcToLeadingMCMap;
127  LArMuonLeadingHelper::GetMCToLeadingMap(pMCParticleList, mcToLeadingMCMap);
128 
129  // Select reconstructable hits, e.g. remove delta ray hits 'stolen' by the cosmic rays
130  CaloHitList selectedCaloHitList;
131  LeadingMCParticleToPostBremsstrahlungHitList leadingMCParticleToPostBremsstrahlungHitList;
132  LArMuonLeadingHelper::SelectCaloHits(pCaloHitList, mcToLeadingMCMap, selectedCaloHitList, parameters.m_selectInputHits,
133  parameters.m_minHitSharingFraction, recoMuonHitList, leadingMCParticleToPostBremsstrahlungHitList);
134 
135  // Obtain maps: [hit -> leading MCParticle], [leading MCParticle -> list of hits]
136  LArMCParticleHelper::CaloHitToMCMap trueHitToLeadingMCMap;
137  LArMCParticleHelper::MCContributionMap leadingMCToTrueHitListMap;
138  LArMCParticleHelper::GetMCParticleToCaloHitMatches(&selectedCaloHitList, mcToLeadingMCMap, trueHitToLeadingMCMap, leadingMCToTrueHitListMap);
139 
140  // Add in close post bremsstrahlung hits
142  leadingMCParticleToPostBremsstrahlungHitList, parameters.m_maxBremsstrahlungSeparation, leadingMCToTrueHitListMap);
143 
144  // Obtain vector: all mc particles
145  MCParticleVector leadingMCVector;
146  LArMuonLeadingHelper::SelectLeadingMCParticles(pMCParticleList, leadingMCVector);
147 
148  // Ensure the MCParticles have enough "good" hits to be reconstructed
149  LArMCParticleHelper::SelectParticlesByHitCount(leadingMCVector, leadingMCToTrueHitListMap, mcToLeadingMCMap, parameters, selectedMCParticlesToHitsMap);
150 }
static void AddInPostBremsstrahlungHits(const LeadingMCParticleToPostBremsstrahlungHitList &leadingMCParticleToPostBremsstrahlungHitList, const float maxBremsstrahlungSeparation, LArMCParticleHelper::MCContributionMap &leadingMCToTrueHitListMap)
Identify the reconstructable post-bremsstrahlung radiation hits.
std::unordered_map< const pandora::MCParticle *, pandora::CaloHitList > MCContributionMap
std::unordered_map< const pandora::CaloHit *, const pandora::MCParticle * > CaloHitToMCMap
static void SelectLeadingMCParticles(const pandora::MCParticleList *pMCParticleList, pandora::MCParticleVector &selectedParticles)
Select all tier 0 and tier 1 MCParticles in cosmic ray hierarchies from an input list.
static void SelectParticlesByHitCount(const pandora::MCParticleVector &candidateTargets, const MCContributionMap &mcToTrueHitListMap, const MCRelationMap &mcToTargetMCMap, const PrimaryParameters &parameters, MCContributionMap &selectedMCParticlesToHitsMap)
Filter an input vector of MCParticles to ensure they have sufficient good hits to be reconstructable...
std::map< const pandora::MCParticle *, pandora::CaloHitList > LeadingMCParticleToPostBremsstrahlungHitList
static void GetMCParticleToCaloHitMatches(const pandora::CaloHitList *const pCaloHitList, const MCRelationMap &mcToTargetMCMap, CaloHitToMCMap &hitToMCMap, MCContributionMap &mcToTrueHitListMap)
Match calo hits to their parent particles.
std::vector< art::Ptr< simb::MCParticle > > MCParticleVector
static void SelectCaloHits(const pandora::CaloHitList *const pCaloHitList, const LArMCParticleHelper::MCRelationMap &mcToTargetMCMap, pandora::CaloHitList &selectedCaloHitList, const bool selectInputHits, const float minHitSharingFraction, const pandora::CaloHitList &recoMuonHitList, LeadingMCParticleToPostBremsstrahlungHitList &leadingMCParticleToPostBremsstrahlungHitList)
Select a subset of calo hits representing those that represent "reconstructable" regions of the event...
static void GetMCToLeadingMap(const pandora::MCParticleList *const pMCParticleList, LArMCParticleHelper::MCRelationMap &mcToLeadingMap)
Construct the hierarchy folding map (cosmic rays folded to themselves, delta ray/michel hierarchy fol...
std::unordered_map< const pandora::MCParticle *, const pandora::MCParticle * > MCRelationMap

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