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

CheatingBeamParticleIdTool class. More...

#include "CheatingBeamParticleIdTool.h"

Inheritance diagram for lar_content::CheatingBeamParticleIdTool:
lar_content::CheatingSliceIdBaseTool lar_content::SliceIdBaseTool

Public Member Functions

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

Static Public Member Functions

static void GetTargetParticleWeight (const pandora::PfoList *const pPfoList, float &targetParticleWeight, float &totalWeight, std::function< bool(const pandora::MCParticle *const)> fCriteria)
 Get the target particle weight in a list of pfos. More...
 
static void GetTargetParticleWeight (const pandora::CaloHit *const pCaloHit, float &targetParticleWeight, float &totalWeight, std::function< bool(const pandora::MCParticle *const)> fCriteria)
 Get the target particle weight for a calo hit. More...
 

Private Member Functions

pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 

Private Attributes

float m_minWeightFraction
 The minimum weight fraction for identifying a slice as a beam particle. More...
 

Detailed Description

CheatingBeamParticleIdTool class.

Definition at line 20 of file CheatingBeamParticleIdTool.h.

Constructor & Destructor Documentation

lar_content::CheatingBeamParticleIdTool::CheatingBeamParticleIdTool ( )

Constructor.

Definition at line 21 of file CheatingBeamParticleIdTool.cc.

21  :
23 {
24 }
TFile f
Definition: plotHisto.C:6
float m_minWeightFraction
The minimum weight fraction for identifying a slice as a beam particle.

Member Function Documentation

static void lar_content::CheatingSliceIdBaseTool::GetTargetParticleWeight ( const pandora::PfoList *const  pPfoList,
float &  targetParticleWeight,
float &  totalWeight,
std::function< bool(const pandora::MCParticle *const)>  fCriteria 
)
staticinherited

Get the target particle weight in a list of pfos.

Parameters
pPfoListaddress of the pfo list
targetParticleWeightthe target particle weight
totalWeightthe total weight
fCriteriaa function which returns a bool (= shouldSelect) for a given input MCParticle

Referenced by lar_content::CheatingCosmicRayTaggingTool::FindAmbiguousPfos(), lar_content::CheatingCosmicRayIdentificationAlg::Run(), and SelectOutputPfos().

static void lar_content::CheatingSliceIdBaseTool::GetTargetParticleWeight ( const pandora::CaloHit *const  pCaloHit,
float &  targetParticleWeight,
float &  totalWeight,
std::function< bool(const pandora::MCParticle *const)>  fCriteria 
)
staticinherited

Get the target particle weight for a calo hit.

Parameters
pCaloHitaddress of the calo hit
targetParticleWeightthe target particle weight
totalWeightthe total weight
fCriteriaa function which returns a bool (= shouldSelect) for a given input MCParticle
StatusCode lar_content::CheatingBeamParticleIdTool::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 71 of file CheatingBeamParticleIdTool.cc.

References m_minWeightFraction.

72 {
73  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "MinimumWeightFraction", m_minWeightFraction));
74 
75  return STATUS_CODE_SUCCESS;
76 }
float m_minWeightFraction
The minimum weight fraction for identifying a slice as a beam particle.
void lar_content::CheatingBeamParticleIdTool::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::CheatingSliceIdBaseTool.

Definition at line 28 of file CheatingBeamParticleIdTool.cc.

References f, lar_content::LArPfoHelper::GetAllDownstreamPfos(), lar_content::CheatingSliceIdBaseTool::GetTargetParticleWeight(), lar_content::LArMCParticleHelper::IsBeamParticle(), lar_content::LArPfoHelper::IsTestBeam(), and m_minWeightFraction.

30 {
31  if (testBeamSliceHypotheses.size() != crSliceHypotheses.size())
32  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
33 
34  for (unsigned int sliceIndex = 0, nSlices = testBeamSliceHypotheses.size(); sliceIndex < nSlices; ++sliceIndex)
35  {
36  float beamParticleWeight(0.f), totalWeight(0.f);
37  const PfoList &testBeamPfoList(testBeamSliceHypotheses.at(sliceIndex));
38 
39  for (const Pfo *const pTestBeamPfo : testBeamPfoList)
40  {
41  if (!LArPfoHelper::IsTestBeam(pTestBeamPfo))
42  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
43 
44  PfoList downstreamPfos;
45  LArPfoHelper::GetAllDownstreamPfos(pTestBeamPfo, downstreamPfos);
46 
47  float thisBeamParticleWeight(0.f), thisTotalWeight(0.f);
48  CheatingSliceIdBaseTool::GetTargetParticleWeight(&downstreamPfos, thisBeamParticleWeight, thisTotalWeight, LArMCParticleHelper::IsBeamParticle);
49 
50  beamParticleWeight += thisBeamParticleWeight;
51  totalWeight += thisTotalWeight;
52  }
53 
54  const float beamWeightFraction(totalWeight < std::numeric_limits<float>::epsilon() ? 0.f : beamParticleWeight / totalWeight);
55 
56  if (beamWeightFraction > m_minWeightFraction)
57  {
58  const PfoList &sliceOutput(testBeamSliceHypotheses.at(sliceIndex));
59  selectedPfos.insert(selectedPfos.end(), sliceOutput.begin(), sliceOutput.end());
60  }
61  else
62  {
63  const PfoList &sliceOutput(crSliceHypotheses.at(sliceIndex));
64  selectedPfos.insert(selectedPfos.end(), sliceOutput.begin(), sliceOutput.end());
65  }
66  }
67 }
TFile f
Definition: plotHisto.C:6
static bool IsTestBeam(const pandora::ParticleFlowObject *const pPfo)
Whether a pfo is a test beam particle.
static bool IsBeamParticle(const pandora::MCParticle *const pMCParticle)
Returns true if passed a primary beam MCParticle.
float m_minWeightFraction
The minimum weight fraction for identifying a slice as a beam particle.
static void GetTargetParticleWeight(const pandora::PfoList *const pPfoList, float &targetParticleWeight, float &totalWeight, std::function< bool(const pandora::MCParticle *const)> fCriteria)
Get the target particle weight in a list of pfos.
static void GetAllDownstreamPfos(const pandora::PfoList &inputPfoList, pandora::PfoList &outputPfoList)
Get a flat list of all pfos, recursively, of all daughters associated with those pfos in an input lis...

Member Data Documentation

float lar_content::CheatingBeamParticleIdTool::m_minWeightFraction
private

The minimum weight fraction for identifying a slice as a beam particle.

Definition at line 34 of file CheatingBeamParticleIdTool.h.

Referenced by ReadSettings(), and SelectOutputPfos().


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