LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
lar_content::MvaPfoCharacterisationAlgorithm< T > Class Template Reference

MvaPfoCharacterisationAlgorithm class. More...

#include "MvaPfoCharacterisationAlgorithm.h"

Inheritance diagram for lar_content::MvaPfoCharacterisationAlgorithm< T >:
lar_content::PfoCharacterisationBaseAlgorithm

Public Member Functions

 MvaPfoCharacterisationAlgorithm ()
 Default constructor. More...
 

Protected Member Functions

virtual bool IsClearTrack (const pandora::ParticleFlowObject *const pPfo) const
 Whether pfo is identified as a clear track. More...
 
virtual bool IsClearTrack (const pandora::Cluster *const pCluster) const
 Whether cluster is identified as a clear track. More...
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 
pandora::StatusCode Run ()
 
virtual bool IsClearTrack3x2D (const pandora::ParticleFlowObject *const pPfo) const
 Whether pfo is identified as a clear track using its three clusters. More...
 

Protected Attributes

ClusterCharacterisationFeatureTool::FeatureToolMap m_featureToolMap
 The feature tool map. More...
 
PfoCharacterisationFeatureTool::FeatureToolMap m_featureToolMapThreeD
 FeatureToolMap as a map for 3D info. More...
 
PfoCharacterisationFeatureTool::FeatureToolMap m_featureToolMapNoChargeInfo
 FeatureToolMap as a map for missing W view. More...
 
pandora::StringVector m_algorithmToolNames
 Vector of strings saving feature tool order for use in feature calculation. More...
 
pandora::StringVector m_algorithmToolNamesNoChargeInfo
 Vector of strings saving feature tool order for use in feature calculation (missing W view) More...
 
m_mva
 The mva. More...
 
m_mvaNoChargeInfo
 The mva for missing W view. More...
 
bool m_persistFeatures
 Whether to write the features to the properties map. More...
 
bool m_trainingSetMode
 Whether to train. More...
 
bool m_testBeamMode
 Whether the training set is from a test beam experiment. More...
 
bool m_enableProbability
 Whether to use probabilities instead of binary classification. More...
 
bool m_useThreeDInformation
 Whether to use 3D information. More...
 
float m_minProbabilityCut
 The minimum probability to label a cluster as track-like. More...
 
unsigned int m_minCaloHitsCut
 The minimum number of calo hits to qualify as a track. More...
 
bool m_applyFiducialCut
 Whether to apply a fiducial volume cut during training. More...
 
float m_fiducialMinX
 Fiducial volume minimum x. More...
 
float m_fiducialMaxX
 Fiducial volume maximum x. More...
 
float m_fiducialMinY
 Fiducial volume minimum y. More...
 
float m_fiducialMaxY
 Fiducial volume maximum y. More...
 
float m_fiducialMinZ
 Fiducial volume minimum z. More...
 
float m_fiducialMaxZ
 Fiducial volume maximum z. More...
 
bool m_applyReconstructabilityChecks
 Whether to apply reconstructability checks during training. More...
 
std::string m_caloHitListName
 Name of input calo hit list. More...
 
std::string m_mcParticleListName
 Name of input MC particle list. More...
 
std::string m_trainingOutputFile
 The training output file. More...
 
std::string m_filePathEnvironmentVariable
 The environment variable providing a list of paths to mva files. More...
 
std::string m_mvaFileName
 The mva input file. More...
 
std::string m_mvaName
 The name of the mva to find. More...
 
std::string m_mvaFileNameNoChargeInfo
 The mva input file for PFOs missing the W view, and thus charge info. More...
 
std::string m_mvaNameNoChargeInfo
 The name of the mva to find for PFOs missing the W view, and thus charge info. More...
 
LArMCParticleHelper::PrimaryParameters m_primaryParameters
 The mc particle primary selection parameters. More...
 
std::string m_trackPfoListName
 The track pfo list name. More...
 
std::string m_showerPfoListName
 The shower pfo list name. More...
 
pandora::StringVector m_inputPfoListNames
 The names of the input pfo lists. More...
 
bool m_updateClusterIds
 Whether to update daughter cluster particle id labels to match pfo id. More...
 
bool m_postBranchAddition
 Whether to use configuration for shower clusters post branch addition. More...
 
unsigned int m_minTrackLikeViews
 The minimum number of track-like views to declare a pfo as track-like. More...
 

Private Member Functions

bool PassesFiducialCut (const pandora::CartesianVector &vertex) const
 Checks if the interaction vertex is within the fiducial volume. More...
 

Detailed Description

template<typename T>
class lar_content::MvaPfoCharacterisationAlgorithm< T >

MvaPfoCharacterisationAlgorithm class.

Definition at line 28 of file MvaPfoCharacterisationAlgorithm.h.

Constructor & Destructor Documentation

Default constructor.

Definition at line 24 of file MvaPfoCharacterisationAlgorithm.cc.

References util::abs(), lar_content::LArMvaHelper::CalculateFeatures(), lar_content::LArMvaHelper::CalculateProbability(), lar_content::LArMvaHelper::Classify(), lar_content::MvaPfoCharacterisationAlgorithm< T >::IsClearTrack(), lar_content::MvaPfoCharacterisationAlgorithm< T >::m_algorithmToolNames, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_enableProbability, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_featureToolMap, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_minCaloHitsCut, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_minProbabilityCut, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_mva, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_trainingOutputFile, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_trainingSetMode, and lar_content::LArMvaHelper::ProduceTrainingExample().

24  :
25  m_persistFeatures(false),
26  m_trainingSetMode(false),
27  m_testBeamMode(false),
28  m_enableProbability(true),
32  m_applyFiducialCut(false),
33  m_fiducialMinX(-std::numeric_limits<float>::max()),
34  m_fiducialMaxX(std::numeric_limits<float>::max()),
35  m_fiducialMinY(-std::numeric_limits<float>::max()),
36  m_fiducialMaxY(std::numeric_limits<float>::max()),
37  m_fiducialMinZ(-std::numeric_limits<float>::max()),
38  m_fiducialMaxZ(std::numeric_limits<float>::max()),
40  m_filePathEnvironmentVariable("FW_SEARCH_PATH")
41 {
42 }
bool m_enableProbability
Whether to use probabilities instead of binary classification.
unsigned int m_minCaloHitsCut
The minimum number of calo hits to qualify as a track.
bool m_testBeamMode
Whether the training set is from a test beam experiment.
bool m_applyReconstructabilityChecks
Whether to apply reconstructability checks during training.
bool m_applyFiducialCut
Whether to apply a fiducial volume cut during training.
TFile f
Definition: plotHisto.C:6
float m_minProbabilityCut
The minimum probability to label a cluster as track-like.
std::string m_filePathEnvironmentVariable
The environment variable providing a list of paths to mva files.
bool m_persistFeatures
Whether to write the features to the properties map.
bool m_useThreeDInformation
Whether to use 3D information.

Member Function Documentation

template<typename T >
bool lar_content::MvaPfoCharacterisationAlgorithm< T >::IsClearTrack ( const pandora::ParticleFlowObject *const  pPfo) const
protectedvirtual

Whether pfo is identified as a clear track.

Parameters
pPfoaddress of the relevant pfo
Returns
boolean

Implements lar_content::PfoCharacterisationBaseAlgorithm.

Definition at line 85 of file MvaPfoCharacterisationAlgorithm.cc.

References util::abs(), lar_content::LArMvaHelper::CalculateFeatures(), lar_content::LArMvaHelper::CalculateProbability(), lar_content::LArMvaHelper::Classify(), util::end(), f, lar_content::LArPfoHelper::GetCaloHits(), lar_content::LArPfoHelper::GetClusters(), lar_content::LArMCParticleHelper::GetMainMCParticle(), lar_content::LArMCParticleHelper::GetMCParticleToCaloHitMatches(), lar_content::LArMCParticleHelper::GetMCPrimaryMap(), lar_content::LArMCParticleHelper::GetPfoMCParticleHitSharingMaps(), lar_content::LArMCParticleHelper::GetPfoToReconstructable2DHitsMap(), lar_content::LArMCParticleHelper::IsBeamNeutrinoFinalState(), lar_content::LArMCParticleHelper::IsBeamParticle(), lar_content::LArPfoHelper::IsThreeD(), lar_content::MvaPfoCharacterisationAlgorithm< T >::m_algorithmToolNames, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_algorithmToolNamesNoChargeInfo, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_applyFiducialCut, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_applyReconstructabilityChecks, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_caloHitListName, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_enableProbability, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_featureToolMapNoChargeInfo, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_featureToolMapThreeD, lar_content::LArMCParticleHelper::PrimaryParameters::m_foldBackHierarchy, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_mcParticleListName, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_minProbabilityCut, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_mva, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_mvaNoChargeInfo, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_persistFeatures, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_primaryParameters, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_testBeamMode, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_trainingOutputFile, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_trainingSetMode, lar_content::MvaPfoCharacterisationAlgorithm< T >::PassesFiducialCut(), lar_content::LArMvaHelper::ProduceTrainingExample(), lar_content::LArMCParticleHelper::SelectReconstructableMCParticles(), and value.

Referenced by lar_content::MvaPfoCharacterisationAlgorithm< T >::MvaPfoCharacterisationAlgorithm().

86 {
87  if (!LArPfoHelper::IsThreeD(pPfo))
88  {
90  {
91  object_creation::ParticleFlowObject::Metadata metadata;
92  metadata.m_propertiesToAdd["TrackScore"] = -1.f;
93  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ParticleFlowObject::AlterMetadata(*this, pPfo, metadata));
94  }
95  return (pPfo->GetParticleId() == MU_MINUS);
96  }
97 
98  // Charge related features are only calculated using hits in W view
99  ClusterList wClusterList;
100  LArPfoHelper::GetClusters(pPfo, TPC_VIEW_W, wClusterList);
101 
102  const PfoCharacterisationFeatureTool::FeatureToolMap &chosenFeatureToolMap(wClusterList.empty() ? m_featureToolMapNoChargeInfo : m_featureToolMapThreeD);
103  const StringVector chosenFeatureToolOrder(wClusterList.empty() ? m_algorithmToolNamesNoChargeInfo : m_algorithmToolNames);
104  StringVector featureOrder;
105  const LArMvaHelper::MvaFeatureMap featureMap(
106  LArMvaHelper::CalculateFeatures(chosenFeatureToolOrder, chosenFeatureToolMap, featureOrder, this, pPfo));
107 
108  for (auto const &[featureKey, featureValue] : featureMap)
109  {
110  (void)featureKey;
111 
112  if (!featureValue.IsInitialized())
113  {
115  {
116  object_creation::ParticleFlowObject::Metadata metadata;
117  metadata.m_propertiesToAdd["TrackScore"] = -1.f;
118  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ParticleFlowObject::AlterMetadata(*this, pPfo, metadata));
119  }
120  return (pPfo->GetParticleId() == MU_MINUS);
121  }
122  }
123 
125  {
126  const MCParticleList *pMCParticleList(nullptr);
127  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetList(*this, m_mcParticleListName, pMCParticleList));
128 
129  const CaloHitList *pCaloHitList(nullptr);
130  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetList(*this, m_caloHitListName, pCaloHitList));
131 
132  // Mapping target MCParticles -> truth associated Hits
133  LArMCParticleHelper::MCContributionMap targetMCParticleToHitsMap;
134  if (!m_testBeamMode)
136  LArMCParticleHelper::IsBeamNeutrinoFinalState, targetMCParticleToHitsMap);
137  else
139  pMCParticleList, pCaloHitList, m_primaryParameters, LArMCParticleHelper::IsBeamParticle, targetMCParticleToHitsMap);
140 
141  LArMCParticleHelper::MCContributionMapVector mcParticlesToGoodHitsMaps({targetMCParticleToHitsMap});
142 
143  LArMCParticleHelper::PfoContributionMap pfoToReconstructable2DHitsMap;
145  PfoList(1, pPfo), mcParticlesToGoodHitsMaps, pfoToReconstructable2DHitsMap, m_primaryParameters.m_foldBackHierarchy);
146  if (pfoToReconstructable2DHitsMap.empty())
147  return false;
148 
149  LArMCParticleHelper::PfoToMCParticleHitSharingMap pfoToMCParticleHitSharingMap;
150  LArMCParticleHelper::MCParticleToPfoHitSharingMap mcParticleToPfoHitSharingMap;
152  pfoToReconstructable2DHitsMap, mcParticlesToGoodHitsMaps, pfoToMCParticleHitSharingMap, mcParticleToPfoHitSharingMap);
153  if (pfoToMCParticleHitSharingMap.empty())
154  return false;
155 
156  unsigned int nHitsInBestMCParticleTotal(0);
157  unsigned int nHitsSharedWithBestMCParticleTotal(0);
158  int bestMCParticlePdgCode(0);
159  CartesianVector threeDVertexPosition(0.f, 0.f, 0.f);
160  float hitsShower(0), hitsTrack(0);
161  const LArMCParticleHelper::MCParticleToSharedHitsVector &mcParticleToSharedHitsVector(pfoToMCParticleHitSharingMap.at(pPfo));
162 
163  for (const LArMCParticleHelper::MCParticleCaloHitListPair &mcParticleCaloHitListPair : mcParticleToSharedHitsVector)
164  {
165  const pandora::MCParticle *const pAssociatedMCParticle(mcParticleCaloHitListPair.first);
166  const CaloHitList &allMCHits(targetMCParticleToHitsMap.at(pAssociatedMCParticle));
167  const CaloHitList &associatedMCHits(mcParticleCaloHitListPair.second);
168 
169  if ((PHOTON == pAssociatedMCParticle->GetParticleId()) || (E_MINUS == std::abs(pAssociatedMCParticle->GetParticleId())))
170  hitsShower += associatedMCHits.size();
171  else
172  hitsTrack += associatedMCHits.size();
173 
174  if (associatedMCHits.size() > nHitsSharedWithBestMCParticleTotal)
175  {
176  nHitsSharedWithBestMCParticleTotal = associatedMCHits.size();
177  nHitsInBestMCParticleTotal = allMCHits.size();
178  bestMCParticlePdgCode = pAssociatedMCParticle->GetParticleId();
179  threeDVertexPosition = pAssociatedMCParticle->GetVertex();
180  }
181  }
182 
183  const float trackShowerHitsRatio((hitsTrack + hitsShower) > 0 ? hitsTrack / (hitsTrack + hitsShower) : 0.f);
184  const bool isTrueTrack(trackShowerHitsRatio >= 0.5);
185 
186  const int nHitsInPfoTotal(pfoToReconstructable2DHitsMap.at(pPfo).size());
187  const float purity((nHitsInPfoTotal > 0) ? nHitsSharedWithBestMCParticleTotal / static_cast<float>(nHitsInPfoTotal) : 0.f);
188  const float completeness(
189  (nHitsInBestMCParticleTotal > 0) ? nHitsSharedWithBestMCParticleTotal / static_cast<float>(nHitsInBestMCParticleTotal) : 0.f);
190 
191  CaloHitList checkHitListW;
192  LArPfoHelper::GetCaloHits(pPfo, TPC_VIEW_W, checkHitListW);
193  CaloHitList checkHitListU;
194  LArPfoHelper::GetCaloHits(pPfo, TPC_VIEW_U, checkHitListU);
195  CaloHitList checkHitListV;
196  LArPfoHelper::GetCaloHits(pPfo, TPC_VIEW_V, checkHitListV);
197  CaloHitList checkHitListAll;
198  checkHitListAll.splice(checkHitListAll.end(), checkHitListW);
199  checkHitListAll.splice(checkHitListAll.end(), checkHitListU);
200  checkHitListAll.splice(checkHitListAll.end(), checkHitListV);
201 
203  LArMCParticleHelper::GetMCPrimaryMap(pMCParticleList, mcPrimaryMap);
204 
205  LArMCParticleHelper::MCContributionMap mcToTrueHitListMap;
207  LArMCParticleHelper::GetMCParticleToCaloHitMatches(&checkHitListAll, mcPrimaryMap, hitToMCMap, mcToTrueHitListMap);
208 
209  unsigned int showerCount(0), allCount(0);
210  for (const CaloHit *pHit : checkHitListAll)
211  {
212  if (hitToMCMap.find(pHit) != hitToMCMap.end())
213  {
214  const MCParticle *pHitMCParticle(hitToMCMap.at(pHit));
215  if ((PHOTON == pHitMCParticle->GetParticleId()) || (E_MINUS == std::abs(pHitMCParticle->GetParticleId())))
216  ++showerCount;
217  ++allCount;
218  }
219  }
220 
221  if (allCount == 0)
222  return false;
223  const float showerProbability(showerCount / static_cast<float>(allCount));
224  const bool mischaracterisedPfo((showerProbability < 0.5f && !isTrueTrack) || (showerProbability > 0.5 && isTrueTrack) ? true : false);
225  const bool isMainMCParticleSet(bestMCParticlePdgCode != 0);
226 
227  if (isMainMCParticleSet)
228  {
229  if (completeness >= 0.f && purity >= 0.f && !mischaracterisedPfo && (!m_applyFiducialCut || this->PassesFiducialCut(threeDVertexPosition)))
230  {
231  std::string outputFile(m_trainingOutputFile);
232  const std::string end = ((wClusterList.empty()) ? "noChargeInfo.txt" : ".txt");
233  outputFile.append(end);
234  LArMvaHelper::ProduceTrainingExample(outputFile, isTrueTrack, featureOrder, featureMap);
235  }
236  }
237 
238  return isTrueTrack;
239  }
240  else if (m_trainingSetMode)
241  {
242  bool isTrueTrack(false);
243  bool isMainMCParticleSet(false);
244 
245  try
246  {
247  const MCParticle *const pMCParticle(LArMCParticleHelper::GetMainMCParticle(pPfo));
248  isTrueTrack = ((PHOTON != pMCParticle->GetParticleId()) && (E_MINUS != std::abs(pMCParticle->GetParticleId())));
249  isMainMCParticleSet = (pMCParticle->GetParticleId() != 0);
250  }
251  catch (const StatusCodeException &)
252  {
253  }
254 
255  if (isMainMCParticleSet)
256  {
257  std::string outputFile(m_trainingOutputFile);
258  outputFile.append(wClusterList.empty() ? "noChargeInfo.txt" : ".txt");
259  LArMvaHelper::ProduceTrainingExample(outputFile, isTrueTrack, featureOrder, featureMap);
260  }
261 
262  return isTrueTrack;
263  }
264 
265  // If no failures, proceed with MvaPfoCharacterisationAlgorithm classification
266  if (!m_enableProbability)
267  {
268  return LArMvaHelper::Classify((wClusterList.empty() ? m_mvaNoChargeInfo : m_mva), featureOrder, featureMap);
269  }
270  else
271  {
272  const double score(LArMvaHelper::CalculateProbability((wClusterList.empty() ? m_mvaNoChargeInfo : m_mva), featureOrder, featureMap));
273  object_creation::ParticleFlowObject::Metadata metadata;
274  metadata.m_propertiesToAdd["TrackScore"] = score;
275  if (m_persistFeatures)
276  {
277  for (auto const &[name, value] : featureMap)
278  {
279  metadata.m_propertiesToAdd[name] = value.Get();
280  }
281  }
282  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ParticleFlowObject::AlterMetadata(*this, pPfo, metadata));
283  return (m_minProbabilityCut <= score);
284  }
285 }
bool m_enableProbability
Whether to use probabilities instead of binary classification.
std::string m_trainingOutputFile
The training output file.
static bool Classify(const MvaInterface &classifier, TCONTAINER &&featureContainer)
Use the trained classifier to predict the boolean class of an example.
Definition: LArMvaHelper.h:331
pandora::StringVector m_algorithmToolNamesNoChargeInfo
Vector of strings saving feature tool order for use in feature calculation (missing W view) ...
static bool IsThreeD(const pandora::ParticleFlowObject *const pPfo)
Does Pfo contain 3D clusters.
std::unordered_map< const pandora::MCParticle *, pandora::CaloHitList > MCContributionMap
std::string m_caloHitListName
Name of input calo hit list.
std::pair< const pandora::MCParticle *, pandora::CaloHitList > MCParticleCaloHitListPair
LArMCParticleHelper::PrimaryParameters m_primaryParameters
The mc particle primary selection parameters.
static void GetClusters(const pandora::PfoList &pfoList, const pandora::HitType &hitType, pandora::ClusterList &clusterList)
Get a list of clusters of a particular hit type from a list of pfos.
static pandora::StatusCode ProduceTrainingExample(const std::string &trainingOutputFile, const bool result, TCONTAINER &&featureContainer)
Produce a training example with the given features and result.
Definition: LArMvaHelper.h:285
std::string m_mcParticleListName
Name of input MC particle list.
bool m_testBeamMode
Whether the training set is from a test beam experiment.
static void GetPfoToReconstructable2DHitsMap(const pandora::PfoList &pfoList, const MCContributionMap &selectedMCParticleToHitsMap, PfoContributionMap &pfoToReconstructable2DHitsMap, const bool foldBackHierarchy)
Get mapping from Pfo to reconstructable 2D hits (=good hits belonging to a selected reconstructable M...
PfoCharacterisationFeatureTool::FeatureToolMap m_featureToolMapNoChargeInfo
FeatureToolMap as a map for missing W view.
std::unordered_map< const pandora::CaloHit *, const pandora::MCParticle * > CaloHitToMCMap
constexpr auto abs(T v)
Returns the absolute value of the argument.
bool m_applyReconstructabilityChecks
Whether to apply reconstructability checks during training.
static void GetPfoMCParticleHitSharingMaps(const PfoContributionMap &pfoToReconstructable2DHitsMap, const MCContributionMapVector &selectedMCParticleToHitsMaps, PfoToMCParticleHitSharingMap &pfoToMCParticleHitSharingMap, MCParticleToPfoHitSharingMap &mcParticleToPfoHitSharingMap)
Get the mappings from Pfo -> pair (reconstructable MCparticles, number of reconstructable 2D hits sha...
std::map< const pandora::MCParticle *, PfoToSharedHitsVector > MCParticleToPfoHitSharingMap
bool m_applyFiducialCut
Whether to apply a fiducial volume cut during training.
bool m_foldBackHierarchy
whether to fold the hierarchy back to the primary (neutrino) or leading particles (test beam) ...
static void GetMCPrimaryMap(const pandora::MCParticleList *const pMCParticleList, MCRelationMap &mcPrimaryMap)
Get mapping from individual mc particles (in a provided list) and their primary parent mc particles...
MvaTypes::MvaFeatureMap MvaFeatureMap
Definition: LArMvaHelper.h:78
static const pandora::MCParticle * GetMainMCParticle(const pandora::ParticleFlowObject *const pPfo)
Find the mc particle making the largest contribution to 2D clusters in a specified pfo...
std::map< std::string, MvaFeatureTool< Ts... > * > FeatureToolMap
Definition: LArMvaHelper.h:37
TFile f
Definition: plotHisto.C:6
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
static void SelectReconstructableMCParticles(const pandora::MCParticleList *pMCParticleList, const pandora::CaloHitList *pCaloHitList, const PrimaryParameters &parameters, std::function< bool(const pandora::MCParticle *const)> fCriteria, MCContributionMap &selectedMCParticlesToHitsMap)
Select target, reconstructable mc particles that match given criteria.
static void GetMCParticleToCaloHitMatches(const pandora::CaloHitList *const pCaloHitList, const MCRelationMap &mcToTargetMCMap, CaloHitToMCMap &hitToMCMap, MCContributionMap &mcToTrueHitListMap)
Match calo hits to their parent particles.
static bool IsBeamParticle(const pandora::MCParticle *const pMCParticle)
Returns true if passed a primary beam MCParticle.
bool PassesFiducialCut(const pandora::CartesianVector &vertex) const
Checks if the interaction vertex is within the fiducial volume.
double value
Definition: spectrum.C:18
std::vector< MCContributionMap > MCContributionMapVector
float m_minProbabilityCut
The minimum probability to label a cluster as track-like.
PfoCharacterisationFeatureTool::FeatureToolMap m_featureToolMapThreeD
FeatureToolMap as a map for 3D info.
static MvaFeatureVector CalculateFeatures(const MvaFeatureToolVector< Ts... > &featureToolVector, TARGS &&...args)
Calculate the features in a given feature tool vector.
Definition: LArMvaHelper.h:399
std::vector< MCParticleCaloHitListPair > MCParticleToSharedHitsVector
static double CalculateProbability(const MvaInterface &classifier, TCONTAINER &&featureContainer)
Use the trained mva to calculate a classification probability for an example.
Definition: LArMvaHelper.h:369
pandora::StringVector m_algorithmToolNames
Vector of strings saving feature tool order for use in feature calculation.
std::unordered_map< const pandora::ParticleFlowObject *, pandora::CaloHitList > PfoContributionMap
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.
static bool IsBeamNeutrinoFinalState(const pandora::MCParticle *const pMCParticle)
Returns true if passed a primary neutrino final state MCParticle.
std::unordered_map< const pandora::MCParticle *, const pandora::MCParticle * > MCRelationMap
bool m_persistFeatures
Whether to write the features to the properties map.
std::map< const pandora::ParticleFlowObject *, MCParticleToSharedHitsVector > PfoToMCParticleHitSharingMap
template<typename T >
virtual bool lar_content::MvaPfoCharacterisationAlgorithm< T >::IsClearTrack ( const pandora::Cluster *const  pCluster) const
protectedvirtual

Whether cluster is identified as a clear track.

Parameters
pClusteraddress of the relevant cluster
Returns
boolean

Implements lar_content::PfoCharacterisationBaseAlgorithm.

bool lar_content::PfoCharacterisationBaseAlgorithm::IsClearTrack3x2D ( const pandora::ParticleFlowObject *const  pPfo) const
protectedvirtualinherited

Whether pfo is identified as a clear track using its three clusters.

Parameters
pPfoaddress of the relevant pfo
Returns
boolean

Definition at line 108 of file PfoCharacterisationBaseAlgorithm.cc.

References lar_content::LArClusterHelper::GetClusterHitType(), lar_content::LArPfoHelper::GetTwoDClusterList(), lar_content::PfoCharacterisationBaseAlgorithm::IsClearTrack(), and lar_content::PfoCharacterisationBaseAlgorithm::m_minTrackLikeViews.

Referenced by lar_content::PfoCharacterisationBaseAlgorithm::Run().

109 {
110  ClusterList twoDClusterList;
111  LArPfoHelper::GetTwoDClusterList(pPfo, twoDClusterList);
112 
113  typedef std::set<pandora::HitType> HitTypeSet;
114  HitTypeSet hitTypeSet;
115 
116  unsigned int nTrackLikeViews(0);
117  for (const Cluster *const pCluster : twoDClusterList)
118  {
119  const HitType hitType(LArClusterHelper::GetClusterHitType(pCluster));
120  if (!hitTypeSet.insert(hitType).second)
121  continue;
122 
123  if (this->IsClearTrack(pCluster))
124  ++nTrackLikeViews;
125 
126  if (nTrackLikeViews >= m_minTrackLikeViews)
127  return true;
128  }
129 
130  return false;
131 }
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.
virtual bool IsClearTrack(const pandora::ParticleFlowObject *const pPfo) const =0
Whether pfo is identified as a clear track.
unsigned int m_minTrackLikeViews
The minimum number of track-like views to declare a pfo as track-like.
HitType
Definition: HitType.h:12
template<typename T >
bool lar_content::MvaPfoCharacterisationAlgorithm< T >::PassesFiducialCut ( const pandora::CartesianVector &  vertex) const
private

Checks if the interaction vertex is within the fiducial volume.

Parameters
vertexThe coordinates of the vertex

Definition at line 433 of file MvaPfoCharacterisationAlgorithm.cc.

References lar_content::MvaPfoCharacterisationAlgorithm< T >::m_fiducialMaxX, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_fiducialMaxY, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_fiducialMaxZ, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_fiducialMinX, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_fiducialMinY, and lar_content::MvaPfoCharacterisationAlgorithm< T >::m_fiducialMinZ.

Referenced by lar_content::MvaPfoCharacterisationAlgorithm< T >::IsClearTrack().

434 {
435  const float vx(vertex.GetX()), vy(vertex.GetY()), vz(vertex.GetZ());
436  return m_fiducialMinX <= vx && vx <= m_fiducialMaxX && m_fiducialMinY <= vy && vy <= m_fiducialMaxY && m_fiducialMinZ <= vz && vz <= m_fiducialMaxZ;
437 }
vertex reconstruction
template<typename T >
StatusCode lar_content::MvaPfoCharacterisationAlgorithm< T >::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
protected

Definition at line 290 of file MvaPfoCharacterisationAlgorithm.cc.

References lar_content::LArMvaHelper::AddFeatureToolToMap(), lar_content::LArFileHelper::FindFileInPath(), lar_content::MvaPfoCharacterisationAlgorithm< T >::m_algorithmToolNames, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_algorithmToolNamesNoChargeInfo, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_applyFiducialCut, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_applyReconstructabilityChecks, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_caloHitListName, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_enableProbability, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_featureToolMap, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_featureToolMapNoChargeInfo, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_featureToolMapThreeD, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_fiducialMaxX, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_fiducialMaxY, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_fiducialMaxZ, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_fiducialMinX, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_fiducialMinY, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_fiducialMinZ, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_filePathEnvironmentVariable, lar_content::LArMCParticleHelper::PrimaryParameters::m_foldBackHierarchy, lar_content::LArMCParticleHelper::PrimaryParameters::m_maxPhotonPropagation, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_mcParticleListName, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_minCaloHitsCut, lar_content::LArMCParticleHelper::PrimaryParameters::m_minHitsForGoodView, lar_content::LArMCParticleHelper::PrimaryParameters::m_minHitSharingFraction, lar_content::LArMCParticleHelper::PrimaryParameters::m_minPrimaryGoodHits, lar_content::LArMCParticleHelper::PrimaryParameters::m_minPrimaryGoodViews, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_minProbabilityCut, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_mva, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_mvaFileName, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_mvaFileNameNoChargeInfo, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_mvaName, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_mvaNameNoChargeInfo, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_mvaNoChargeInfo, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_persistFeatures, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_primaryParameters, lar_content::LArMCParticleHelper::PrimaryParameters::m_selectInputHits, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_testBeamMode, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_trainingOutputFile, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_trainingSetMode, lar_content::MvaPfoCharacterisationAlgorithm< T >::m_useThreeDInformation, lar_content::LArMvaHelper::ProcessAlgorithmToolListToMap(), and lar_content::PfoCharacterisationBaseAlgorithm::ReadSettings().

291 {
292  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
293  XmlHelper::ReadValue(xmlHandle, "MinPrimaryGoodHits", m_primaryParameters.m_minPrimaryGoodHits));
294 
295  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
296  XmlHelper::ReadValue(xmlHandle, "MinHitsForGoodView", m_primaryParameters.m_minHitsForGoodView));
297 
298  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
299  XmlHelper::ReadValue(xmlHandle, "MinPrimaryGoodViews", m_primaryParameters.m_minPrimaryGoodViews));
300 
301  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
302  XmlHelper::ReadValue(xmlHandle, "SelectInputHits", m_primaryParameters.m_selectInputHits));
303 
304  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
305  XmlHelper::ReadValue(xmlHandle, "MinHitSharingFraction", m_primaryParameters.m_minHitSharingFraction));
306 
307  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
308  XmlHelper::ReadValue(xmlHandle, "MaxPhotonPropagation", m_primaryParameters.m_maxPhotonPropagation));
309 
310  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
311  XmlHelper::ReadValue(xmlHandle, "FoldToPrimaries", m_primaryParameters.m_foldBackHierarchy));
312 
313  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "PersistFeatures", m_persistFeatures));
314 
315  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "TrainingSetMode", m_trainingSetMode));
316 
317  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinCaloHitsCut", m_minCaloHitsCut));
318 
319  PANDORA_RETURN_RESULT_IF_AND_IF(
320  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "UseThreeDInformation", m_useThreeDInformation));
321 
322  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
323  XmlHelper::ReadValue(xmlHandle, "FilePathEnvironmentVariable", m_filePathEnvironmentVariable));
324 
325  // ATTN Support legacy XML configurations (note an order of precedence of XML keys exists)
326  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "BdtFileName", m_mvaFileName));
327  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "SvmFileName", m_mvaFileName));
328  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MvaFileName", m_mvaFileName));
329 
330  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "BdtName", m_mvaName));
331  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "SvmName", m_mvaName));
332  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MvaName", m_mvaName));
333 
335  {
336  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
337  XmlHelper::ReadValue(xmlHandle, "BdtFileNameNoChargeInfo", m_mvaFileNameNoChargeInfo));
338  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
339  XmlHelper::ReadValue(xmlHandle, "SvmFileNameNoChargeInfo", m_mvaFileNameNoChargeInfo));
340  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
341  XmlHelper::ReadValue(xmlHandle, "MvaFileNameNoChargeInfo", m_mvaFileNameNoChargeInfo));
342 
343  PANDORA_RETURN_RESULT_IF_AND_IF(
344  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "BdtNameNoChargeInfo", m_mvaNameNoChargeInfo));
345  PANDORA_RETURN_RESULT_IF_AND_IF(
346  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "SvmNameNoChargeInfo", m_mvaNameNoChargeInfo));
347  PANDORA_RETURN_RESULT_IF_AND_IF(
348  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MvaNameNoChargeInfo", m_mvaNameNoChargeInfo));
349  }
350 
351  PANDORA_RETURN_RESULT_IF_AND_IF(
352  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "EnableProbability", m_enableProbability));
353 
354  PANDORA_RETURN_RESULT_IF_AND_IF(
355  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinProbabilityCut", m_minProbabilityCut));
356 
357  if (m_trainingSetMode)
358  {
359  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "CaloHitListName", m_caloHitListName));
360  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "MCParticleListName", m_mcParticleListName));
361  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "TrainingOutputFileName", m_trainingOutputFile));
362  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "TestBeamMode", m_testBeamMode));
363  PANDORA_RETURN_RESULT_IF_AND_IF(
364  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "ApplyFiducialCut", m_applyFiducialCut));
365  if (m_applyFiducialCut)
366  {
367  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "FiducialCutMinX", m_fiducialMinX));
368  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "FiducialCutMaxX", m_fiducialMaxX));
369  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "FiducialCutMinY", m_fiducialMinY));
370  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "FiducialCutMaxY", m_fiducialMaxY));
371  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "FiducialCutMinZ", m_fiducialMinZ));
372  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "FiducialCutMaxZ", m_fiducialMaxZ));
373  }
374  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
375  XmlHelper::ReadValue(xmlHandle, "ApplyReconstructabilityChecks", m_applyReconstructabilityChecks));
376  }
377  else
378  {
379  if (m_mvaFileName.empty() || m_mvaName.empty())
380  {
381  std::cout << "MvaPfoCharacterisationAlgorithm: MvaFileName and MvaName must be set if in classification mode " << std::endl;
382  return STATUS_CODE_INVALID_PARAMETER;
383  }
384 
386  m_mva.Initialize(fullMvaFileName, m_mvaName);
387 
389  {
390  if (m_mvaFileNameNoChargeInfo.empty() || m_mvaNameNoChargeInfo.empty())
391  {
392  std::cout << "MvaPfoCharacterisationAlgorithm: MvaFileNameNoChargeInfo and MvaNameNoChargeInfo must be set if in classification mode for no charge info in 3D mode "
393  << std::endl;
394  return STATUS_CODE_INVALID_PARAMETER;
395  }
396  const std::string fullMvaFileNameNoChargeInfo(LArFileHelper::FindFileInPath(m_mvaFileNameNoChargeInfo, m_filePathEnvironmentVariable));
397  m_mvaNoChargeInfo.Initialize(fullMvaFileNameNoChargeInfo, m_mvaNameNoChargeInfo);
398  }
399  }
400 
401  LArMvaHelper::AlgorithmToolMap algorithmToolMap;
402  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=,
403  LArMvaHelper::ProcessAlgorithmToolListToMap(*this, xmlHandle, "FeatureTools", m_algorithmToolNames, algorithmToolMap));
404 
406  {
407  // and the map for NoChargeInfo
408  LArMvaHelper::AlgorithmToolMap algorithmToolMapNoChargeInfo;
409  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=,
411  *this, xmlHandle, "FeatureToolsNoChargeInfo", m_algorithmToolNamesNoChargeInfo, algorithmToolMapNoChargeInfo));
412 
413  for (auto const &[pAlgorithmToolName, pAlgorithmTool] : algorithmToolMap)
414  PANDORA_RETURN_RESULT_IF(
415  STATUS_CODE_SUCCESS, !=, LArMvaHelper::AddFeatureToolToMap(pAlgorithmTool, pAlgorithmToolName, m_featureToolMapThreeD));
416 
417  for (auto const &[pAlgorithmToolName, pAlgorithmTool] : algorithmToolMapNoChargeInfo)
418  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=,
419  LArMvaHelper::AddFeatureToolToMap(pAlgorithmTool, pAlgorithmToolName, m_featureToolMapNoChargeInfo));
420  }
421  else
422  {
423  for (auto const &[pAlgorithmToolName, pAlgorithmTool] : algorithmToolMap)
424  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, LArMvaHelper::AddFeatureToolToMap(pAlgorithmTool, pAlgorithmToolName, m_featureToolMap));
425  }
426 
428 }
bool m_enableProbability
Whether to use probabilities instead of binary classification.
std::string m_trainingOutputFile
The training output file.
pandora::StringVector m_algorithmToolNamesNoChargeInfo
Vector of strings saving feature tool order for use in feature calculation (missing W view) ...
unsigned int m_minPrimaryGoodViews
the minimum number of primary good views
std::string m_caloHitListName
Name of input calo hit list.
std::map< std::string, pandora::AlgorithmTool * > AlgorithmToolMap
Definition: LArMvaHelper.h:79
bool m_selectInputHits
whether to select input hits
LArMCParticleHelper::PrimaryParameters m_primaryParameters
The mc particle primary selection parameters.
std::string m_mcParticleListName
Name of input MC particle list.
unsigned int m_minCaloHitsCut
The minimum number of calo hits to qualify as a track.
bool m_testBeamMode
Whether the training set is from a test beam experiment.
unsigned int m_minPrimaryGoodHits
the minimum number of primary good Hits
ClusterCharacterisationFeatureTool::FeatureToolMap m_featureToolMap
The feature tool map.
PfoCharacterisationFeatureTool::FeatureToolMap m_featureToolMapNoChargeInfo
FeatureToolMap as a map for missing W view.
bool m_applyReconstructabilityChecks
Whether to apply reconstructability checks during training.
bool m_applyFiducialCut
Whether to apply a fiducial volume cut during training.
bool m_foldBackHierarchy
whether to fold the hierarchy back to the primary (neutrino) or leading particles (test beam) ...
unsigned int m_minHitsForGoodView
the minimum number of Hits for a good view
float m_maxPhotonPropagation
the maximum photon propagation length
std::string m_mvaNameNoChargeInfo
The name of the mva to find for PFOs missing the W view, and thus charge info.
std::string m_mvaName
The name of the mva to find.
static std::string FindFileInPath(const std::string &unqualifiedFileName, const std::string &environmentVariable, const std::string &delimiter=":")
Find the fully-qualified file name by searching through a list of delimiter-separated paths in a name...
float m_minHitSharingFraction
the minimum Hit sharing fraction
static pandora::StatusCode ProcessAlgorithmToolListToMap(const pandora::Algorithm &algorithm, const pandora::TiXmlHandle &xmlHandle, const std::string &listName, pandora::StringVector &algorithToolNameVector, AlgorithmToolMap &algorithmToolMap)
Process a list of algorithms tools in an xml file, using a map. Idea is for this to go to XmlHelper i...
Definition: LArMvaHelper.cc:16
float m_minProbabilityCut
The minimum probability to label a cluster as track-like.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
std::string m_mvaFileNameNoChargeInfo
The mva input file for PFOs missing the W view, and thus charge info.
PfoCharacterisationFeatureTool::FeatureToolMap m_featureToolMapThreeD
FeatureToolMap as a map for 3D info.
std::string m_filePathEnvironmentVariable
The environment variable providing a list of paths to mva files.
pandora::StringVector m_algorithmToolNames
Vector of strings saving feature tool order for use in feature calculation.
bool m_persistFeatures
Whether to write the features to the properties map.
bool m_useThreeDInformation
Whether to use 3D information.
static pandora::StatusCode AddFeatureToolToMap(pandora::AlgorithmTool *const pFeatureTool, std::string pFeatureToolName, MvaFeatureToolMap< Ts... > &featureToolMap)
Add a feature tool to a map of feature tools.
Definition: LArMvaHelper.h:465
StatusCode lar_content::PfoCharacterisationBaseAlgorithm::Run ( )
protectedinherited

Definition at line 39 of file PfoCharacterisationBaseAlgorithm.cc.

References lar_content::LArPfoHelper::GetTwoDClusterList(), lar_content::PfoCharacterisationBaseAlgorithm::IsClearTrack(), lar_content::PfoCharacterisationBaseAlgorithm::IsClearTrack3x2D(), lar_content::PfoCharacterisationBaseAlgorithm::m_inputPfoListNames, lar_content::PfoCharacterisationBaseAlgorithm::m_showerPfoListName, lar_content::PfoCharacterisationBaseAlgorithm::m_trackPfoListName, lar_content::PfoCharacterisationBaseAlgorithm::m_updateClusterIds, and lar_content::PfoCharacterisationBaseAlgorithm::m_useThreeDInformation.

40 {
41  PfoList tracksToShowers, showersToTracks;
42 
43  for (const std::string &pfoListName : m_inputPfoListNames)
44  {
45  const PfoList *pPfoList(nullptr);
46  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraContentApi::GetList(*this, pfoListName, pPfoList));
47 
48  if (!pPfoList || pPfoList->empty())
49  {
50  if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
51  std::cout << "PfoCharacterisationBaseAlgorithm: unable to find pfo list " << pfoListName << std::endl;
52 
53  continue;
54  }
55 
56  for (const ParticleFlowObject *const pPfo : *pPfoList)
57  {
58  PandoraContentApi::ParticleFlowObject::Metadata pfoMetadata;
59  const bool isTrackLike(m_useThreeDInformation ? this->IsClearTrack(pPfo) : this->IsClearTrack3x2D(pPfo));
60 
61  if (isTrackLike)
62  {
63  pfoMetadata.m_particleId = MU_MINUS;
64 
65  if (m_showerPfoListName == pfoListName)
66  showersToTracks.push_back(pPfo);
67  }
68  else
69  {
70  pfoMetadata.m_particleId = E_MINUS;
71 
72  if (m_trackPfoListName == pfoListName)
73  tracksToShowers.push_back(pPfo);
74  }
75 
76  if (pPfo->GetParticleId() != pfoMetadata.m_particleId.Get())
77  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ParticleFlowObject::AlterMetadata(*this, pPfo, pfoMetadata));
78 
79  if (!m_updateClusterIds)
80  continue;
81 
82  ClusterList twoDClusterList;
83  LArPfoHelper::GetTwoDClusterList(pPfo, twoDClusterList);
84 
85  for (const Cluster *const pCluster : twoDClusterList)
86  {
87  if (pCluster->GetParticleId() == pfoMetadata.m_particleId.Get())
88  continue;
89 
90  PandoraContentApi::Cluster::Metadata clusterMetadata;
91  clusterMetadata.m_particleId = pfoMetadata.m_particleId.Get();
92  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Cluster::AlterMetadata(*this, pCluster, clusterMetadata));
93  }
94  }
95  }
96 
97  if (!tracksToShowers.empty())
98  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList(*this, m_trackPfoListName, m_showerPfoListName, tracksToShowers));
99 
100  if (!showersToTracks.empty())
101  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList(*this, m_showerPfoListName, m_trackPfoListName, showersToTracks));
102 
103  return STATUS_CODE_SUCCESS;
104 }
virtual bool IsClearTrack3x2D(const pandora::ParticleFlowObject *const pPfo) const
Whether pfo is identified as a clear track using its three clusters.
pandora::StringVector m_inputPfoListNames
The names of the input pfo lists.
static void GetTwoDClusterList(const pandora::ParticleFlowObject *const pPfo, pandora::ClusterList &clusterList)
Get the list of 2D clusters from an input pfo.
virtual bool IsClearTrack(const pandora::ParticleFlowObject *const pPfo) const =0
Whether pfo is identified as a clear track.
bool m_updateClusterIds
Whether to update daughter cluster particle id labels to match pfo id.
bool m_useThreeDInformation
Whether to use PFO and 3D information or clusters for characterisation.
std::string m_showerPfoListName
The shower pfo list name.

Member Data Documentation

template<typename T >
pandora::StringVector lar_content::MvaPfoCharacterisationAlgorithm< T >::m_algorithmToolNames
protected
template<typename T >
pandora::StringVector lar_content::MvaPfoCharacterisationAlgorithm< T >::m_algorithmToolNamesNoChargeInfo
protected

Vector of strings saving feature tool order for use in feature calculation (missing W view)

Definition at line 47 of file MvaPfoCharacterisationAlgorithm.h.

Referenced by lar_content::MvaPfoCharacterisationAlgorithm< T >::IsClearTrack(), and lar_content::MvaPfoCharacterisationAlgorithm< T >::ReadSettings().

template<typename T >
bool lar_content::MvaPfoCharacterisationAlgorithm< T >::m_applyFiducialCut
protected
template<typename T >
bool lar_content::MvaPfoCharacterisationAlgorithm< T >::m_applyReconstructabilityChecks
protected

Whether to apply reconstructability checks during training.

Definition at line 66 of file MvaPfoCharacterisationAlgorithm.h.

Referenced by lar_content::MvaPfoCharacterisationAlgorithm< T >::IsClearTrack(), and lar_content::MvaPfoCharacterisationAlgorithm< T >::ReadSettings().

template<typename T >
std::string lar_content::MvaPfoCharacterisationAlgorithm< T >::m_caloHitListName
protected
template<typename T >
std::string lar_content::MvaPfoCharacterisationAlgorithm< T >::m_filePathEnvironmentVariable
protected

The environment variable providing a list of paths to mva files.

Definition at line 72 of file MvaPfoCharacterisationAlgorithm.h.

Referenced by lar_content::MvaPfoCharacterisationAlgorithm< T >::ReadSettings().

pandora::StringVector lar_content::PfoCharacterisationBaseAlgorithm::m_inputPfoListNames
protectedinherited
template<typename T >
std::string lar_content::MvaPfoCharacterisationAlgorithm< T >::m_mcParticleListName
protected
template<typename T >
unsigned int lar_content::MvaPfoCharacterisationAlgorithm< T >::m_minCaloHitsCut
protected
unsigned int lar_content::PfoCharacterisationBaseAlgorithm::m_minTrackLikeViews
protectedinherited

The minimum number of track-like views to declare a pfo as track-like.

Definition at line 71 of file PfoCharacterisationBaseAlgorithm.h.

Referenced by lar_content::PfoCharacterisationBaseAlgorithm::IsClearTrack3x2D(), and lar_content::PfoCharacterisationBaseAlgorithm::ReadSettings().

template<typename T >
std::string lar_content::MvaPfoCharacterisationAlgorithm< T >::m_mvaFileName
protected

The mva input file.

Definition at line 73 of file MvaPfoCharacterisationAlgorithm.h.

Referenced by lar_content::MvaPfoCharacterisationAlgorithm< T >::ReadSettings().

template<typename T >
std::string lar_content::MvaPfoCharacterisationAlgorithm< T >::m_mvaFileNameNoChargeInfo
protected

The mva input file for PFOs missing the W view, and thus charge info.

Definition at line 75 of file MvaPfoCharacterisationAlgorithm.h.

Referenced by lar_content::MvaPfoCharacterisationAlgorithm< T >::ReadSettings().

template<typename T >
std::string lar_content::MvaPfoCharacterisationAlgorithm< T >::m_mvaName
protected

The name of the mva to find.

Definition at line 74 of file MvaPfoCharacterisationAlgorithm.h.

Referenced by lar_content::MvaPfoCharacterisationAlgorithm< T >::ReadSettings().

template<typename T >
std::string lar_content::MvaPfoCharacterisationAlgorithm< T >::m_mvaNameNoChargeInfo
protected

The name of the mva to find for PFOs missing the W view, and thus charge info.

Definition at line 76 of file MvaPfoCharacterisationAlgorithm.h.

Referenced by lar_content::MvaPfoCharacterisationAlgorithm< T >::ReadSettings().

template<typename T >
T lar_content::MvaPfoCharacterisationAlgorithm< T >::m_mvaNoChargeInfo
protected
template<typename T >
bool lar_content::MvaPfoCharacterisationAlgorithm< T >::m_persistFeatures
protected
bool lar_content::PfoCharacterisationBaseAlgorithm::m_postBranchAddition
protectedinherited

Whether to use configuration for shower clusters post branch addition.

Definition at line 69 of file PfoCharacterisationBaseAlgorithm.h.

std::string lar_content::PfoCharacterisationBaseAlgorithm::m_showerPfoListName
protectedinherited
template<typename T >
bool lar_content::MvaPfoCharacterisationAlgorithm< T >::m_testBeamMode
protected

Whether the training set is from a test beam experiment.

Definition at line 54 of file MvaPfoCharacterisationAlgorithm.h.

Referenced by lar_content::MvaPfoCharacterisationAlgorithm< T >::IsClearTrack(), and lar_content::MvaPfoCharacterisationAlgorithm< T >::ReadSettings().

std::string lar_content::PfoCharacterisationBaseAlgorithm::m_trackPfoListName
protectedinherited
bool lar_content::PfoCharacterisationBaseAlgorithm::m_updateClusterIds
protectedinherited

Whether to update daughter cluster particle id labels to match pfo id.

Definition at line 68 of file PfoCharacterisationBaseAlgorithm.h.

Referenced by lar_content::PfoCharacterisationBaseAlgorithm::ReadSettings(), and lar_content::PfoCharacterisationBaseAlgorithm::Run().

template<typename T >
bool lar_content::MvaPfoCharacterisationAlgorithm< T >::m_useThreeDInformation
protected

Whether to use 3D information.

Definition at line 56 of file MvaPfoCharacterisationAlgorithm.h.

Referenced by lar_content::MvaPfoCharacterisationAlgorithm< T >::ReadSettings().


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