LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
MasterAlgorithm.h
Go to the documentation of this file.
1 
8 #ifndef LAR_MASTER_ALGORITHM_H
9 #define LAR_MASTER_ALGORITHM_H 1
10 
11 #include "Pandora/AlgorithmTool.h"
12 #include "Pandora/ExternallyConfiguredAlgorithm.h"
13 
16 
21 
22 #include <unordered_map>
23 
24 namespace lar_content
25 {
26 
28 
29 typedef std::vector<pandora::CaloHitList> SliceVector;
30 typedef std::vector<pandora::PfoList> SliceHypotheses;
31 typedef std::unordered_map<const pandora::ParticleFlowObject *, const pandora::LArTPC *> PfoToLArTPCMap;
32 typedef std::unordered_map<const pandora::ParticleFlowObject *, float> PfoToFloatMap;
33 
34 //------------------------------------------------------------------------------------------------------------------------------------------
35 
39 class MasterAlgorithm : public pandora::ExternallyConfiguredAlgorithm
40 {
41 public:
46 
50  class ExternalSteeringParameters : public pandora::ExternalParameters
51  {
52  public:
53  pandora::InputBool m_shouldRunAllHitsCosmicReco;
54  pandora::InputBool m_shouldRunStitching;
55  pandora::InputBool m_shouldRunCosmicHitRemoval;
56  pandora::InputBool m_shouldRunSlicing;
57  pandora::InputBool m_shouldRunNeutrinoRecoOption;
58  pandora::InputBool m_shouldRunCosmicRecoOption;
59  pandora::InputBool m_shouldPerformSliceId;
60  pandora::InputBool m_printOverallRecoStatus;
61  };
62 
63  typedef std::unordered_map<const pandora::ParticleFlowObject *, const pandora::LArTPC *> PfoToLArTPCMap;
64 
72  void ShiftPfoHierarchy(const pandora::ParticleFlowObject *const pParentPfo, const PfoToLArTPCMap &pfoToLArTPCMap, const float x0) const;
73 
81  void StitchPfos(const pandora::ParticleFlowObject *const pPfoToEnlarge, const pandora::ParticleFlowObject *const pPfoToDelete,
82  PfoToLArTPCMap &pfoToLArTPCMap) const;
83 
84 protected:
89  {
90  public:
91  pandora::CaloHitList m_allHitList;
92  pandora::CaloHitList m_truncatedHitList;
93  };
94 
95  typedef std::map<unsigned int, LArTPCHitList> VolumeIdToHitListMap;
96 
97  pandora::StatusCode Run();
98 
102  pandora::StatusCode InitializeWorkerInstances();
103 
107  pandora::StatusCode CopyMCParticles() const;
108 
114  pandora::StatusCode GetVolumeIdToHitListMap(VolumeIdToHitListMap &volumeIdToHitListMap) const;
115 
121  pandora::StatusCode RunCosmicRayReconstruction(const VolumeIdToHitListMap &volumeIdToHitListMap) const;
122 
128  pandora::StatusCode RecreateCosmicRayPfos(PfoToLArTPCMap &pfoToLArTPCMap) const;
129 
136  pandora::StatusCode StitchCosmicRayPfos(PfoToLArTPCMap &pfoToLArTPCMap, PfoToFloatMap &stitchedPfosToX0Map) const;
137 
145  pandora::StatusCode TagCosmicRayPfos(
146  const PfoToFloatMap &stitchedPfosToX0Map, pandora::PfoList &clearCosmicRayPfos, pandora::PfoList &ambiguousPfos) const;
147 
153  pandora::StatusCode RunCosmicRayHitRemoval(const pandora::PfoList &ambiguousPfos) const;
154 
161  pandora::StatusCode RunSlicing(const VolumeIdToHitListMap &volumeIdToHitListMap, SliceVector &sliceVector) const;
162 
170  pandora::StatusCode RunSliceReconstruction(SliceVector &sliceVector, SliceHypotheses &nuSliceHypotheses, SliceHypotheses &crSliceHypotheses) const;
171 
178  pandora::StatusCode SelectBestSliceHypotheses(const SliceHypotheses &nuSliceHypotheses, const SliceHypotheses &crSliceHypotheses) const;
179 
183  pandora::StatusCode Reset();
184 
191  pandora::StatusCode Copy(const pandora::Pandora *const pPandora, const pandora::CaloHit *const pCaloHit) const;
192 
200  pandora::StatusCode Copy(const pandora::Pandora *const pPandora, const pandora::MCParticle *const pMCParticle,
201  const LArMCParticleFactory *const pMCParticleFactory) const;
202 
209  pandora::StatusCode Recreate(const pandora::PfoList &inputPfoList, pandora::PfoList &newPfoList) const;
210 
218  pandora::StatusCode Recreate(const pandora::ParticleFlowObject *const pInputPfo, const pandora::ParticleFlowObject *const pNewParentPfo,
219  pandora::PfoList &newPfoList) const;
220 
229  const pandora::CaloHit *CreateCaloHit(const pandora::CaloHit *const pInputCaloHit, const pandora::CaloHit *const pParentCaloHit) const;
230 
240  const pandora::Cluster *CreateCluster(const pandora::Cluster *const pInputCluster, const pandora::CaloHitList &newCaloHitList,
241  const pandora::CaloHitList &newIsolatedCaloHitList) const;
242 
250  const pandora::Vertex *CreateVertex(const pandora::Vertex *const pInputVertex) const;
251 
261  const pandora::ParticleFlowObject *CreatePfo(const pandora::ParticleFlowObject *const pInputPfo,
262  const pandora::ClusterList &newClusterList, const pandora::VertexList &newVertexList) const;
263 
274  const pandora::Pandora *CreateWorkerInstance(const pandora::LArTPC &larTPC, const pandora::DetectorGapList &gapList,
275  const std::string &settingsFile, const std::string &name) const;
276 
287  const pandora::Pandora *CreateWorkerInstance(const pandora::LArTPCMap &larTPCMap, const pandora::DetectorGapList &gapList,
288  const std::string &settingsFile, const std::string &name) const;
289 
295  virtual pandora::StatusCode RegisterCustomContent(const pandora::Pandora *const pPandora) const;
296 
297  pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle);
298 
308  pandora::StatusCode ReadExternalSettings(const ExternalSteeringParameters *const pExternalParameters,
309  const pandora::InputBool inputBool, const pandora::TiXmlHandle xmlHandle, const std::string &xmlTag, bool &outputBool);
310 
312 
313  unsigned int m_larCaloHitVersion;
314 
325 
327  const pandora::Pandora *m_pSlicingWorkerInstance;
328  const pandora::Pandora *m_pSliceNuWorkerInstance;
329  const pandora::Pandora *m_pSliceCRWorkerInstance;
330 
333 
334  typedef std::vector<StitchingBaseTool *> StitchingToolVector;
335  typedef std::vector<CosmicRayTaggingBaseTool *> CosmicRayTaggingToolVector;
336  typedef std::vector<SliceIdBaseTool *> SliceIdToolVector;
337  typedef std::vector<SliceSelectionBaseTool *> SliceSelectionToolVector;
338 
339  StitchingToolVector m_stitchingToolVector;
340  CosmicRayTaggingToolVector m_cosmicRayTaggingToolVector;
341  SliceIdToolVector m_sliceIdToolVector;
342  SliceSelectionToolVector m_sliceSelectionToolVector;
343 
345  std::string m_crSettingsFile;
346  std::string m_nuSettingsFile;
347  std::string m_slicingSettingsFile;
348 
350  std::string m_inputHitListName;
354 
357 };
358 
359 } // namespace lar_content
360 
361 #endif // #ifndef LAR_MASTER_ALGORITHM_H
Header file for the stitching tool base class.
std::string m_inputMCParticleListName
The input mc particle list name.
pandora::InputBool m_shouldRunCosmicHitRemoval
Whether to remove hits from tagged cosmic-rays.
const pandora::ParticleFlowObject * CreatePfo(const pandora::ParticleFlowObject *const pInputPfo, const pandora::ClusterList &newClusterList, const pandora::VertexList &newVertexList) const
Create a new pfo in the current pandora instance, based upon the provided input pfo.
LArCaloHitFactory m_larCaloHitFactory
Factory for creating LArCaloHits during hit copying.
std::vector< pandora::PfoList > SliceHypotheses
CosmicRayTaggingToolVector m_cosmicRayTaggingToolVector
The cosmic-ray tagging tool vector.
pandora::StatusCode Copy(const pandora::Pandora *const pPandora, const pandora::CaloHit *const pCaloHit) const
Copy a specified calo hit to the provided pandora instance.
std::vector< SliceSelectionBaseTool * > SliceSelectionToolVector
pandora::InputBool m_shouldRunStitching
Whether to stitch cosmic-ray muons crossing between volumes.
pandora::StatusCode Recreate(const pandora::PfoList &inputPfoList, pandora::PfoList &newPfoList) const
Recreate a specified list of pfos in the current pandora instance.
pandora::StatusCode ReadExternalSettings(const ExternalSteeringParameters *const pExternalParameters, const pandora::InputBool inputBool, const pandora::TiXmlHandle xmlHandle, const std::string &xmlTag, bool &outputBool)
Read settings from external steering parameters block, if present, otherwise from xml as standard...
const pandora::Pandora * m_pSlicingWorkerInstance
The slicing worker instance.
Header file for the lar calo hit class.
Header file for the stitching tool base class.
pandora::StatusCode CopyMCParticles() const
Copy mc particles in the named input list to all pandora worker instances.
const pandora::CaloHit * CreateCaloHit(const pandora::CaloHit *const pInputCaloHit, const pandora::CaloHit *const pParentCaloHit) const
Create a new calo hit in the current pandora instance, based upon the provided input calo hit...
bool m_shouldRunNeutrinoRecoOption
Whether to run neutrino reconstruction for each slice.
bool m_shouldRunAllHitsCosmicReco
Whether to run all hits cosmic-ray reconstruction.
bool m_shouldRemoveOutOfTimeHits
Whether to remove out of time hits.
pandora::InputBool m_shouldRunSlicing
Whether to slice events into separate regions for processing.
bool m_shouldPerformSliceId
Whether to identify slices and select most appropriate pfos.
std::string m_slicingSettingsFile
The slicing settings file.
pandora::StatusCode RunCosmicRayHitRemoval(const pandora::PfoList &ambiguousPfos) const
Run cosmic-ray hit removal, freeing hits in ambiguous pfos for further processing.
std::string m_recreatedVertexListName
The output recreated vertex list name.
std::vector< const pandora::Pandora * > PandoraInstanceList
std::unordered_map< const pandora::ParticleFlowObject *, const pandora::LArTPC * > PfoToLArTPCMap
const pandora::Vertex * CreateVertex(const pandora::Vertex *const pInputVertex) const
Create a new vertex in the current pandora instance, based upon the provided input vertex...
const pandora::Pandora * m_pSliceCRWorkerInstance
The per-slice cosmic-ray reconstruction worker instance.
SliceSelectionToolVector m_sliceSelectionToolVector
The slice selection tool vector.
pandora::InputBool m_shouldRunAllHitsCosmicReco
Whether to run all hits cosmic-ray reconstruction.
const pandora::Cluster * CreateCluster(const pandora::Cluster *const pInputCluster, const pandora::CaloHitList &newCaloHitList, const pandora::CaloHitList &newIsolatedCaloHitList) const
Create a new cluster in the current pandora instance, based upon the provided input cluster...
bool m_printOverallRecoStatus
Whether to print current operation status messages.
const pandora::Pandora * CreateWorkerInstance(const pandora::LArTPC &larTPC, const pandora::DetectorGapList &gapList, const std::string &settingsFile, const std::string &name) const
Create a pandora worker instance to handle a single LArTPC.
pandora::StatusCode RunSliceReconstruction(SliceVector &sliceVector, SliceHypotheses &nuSliceHypotheses, SliceHypotheses &crSliceHypotheses) const
Process each slice under different reconstruction hypotheses.
std::map< unsigned int, LArTPCHitList > VolumeIdToHitListMap
std::unordered_map< const pandora::ParticleFlowObject *, float > PfoToFloatMap
MasterAlgorithm()
Default constructor.
const pandora::Pandora * m_pSliceNuWorkerInstance
The per-slice neutrino reconstruction worker instance.
std::string m_nuSettingsFile
The neutrino reconstruction settings file.
pandora::InputBool m_shouldRunNeutrinoRecoOption
Whether to run neutrino reconstruction for each slice.
pandora::StatusCode InitializeWorkerInstances()
Initialize pandora worker instances.
bool m_workerInstancesInitialized
Whether all worker instances have been initialized.
void ShiftPfoHierarchy(const pandora::ParticleFlowObject *const pParentPfo, const PfoToLArTPCMap &pfoToLArTPCMap, const float x0) const
Shift a Pfo hierarchy by a specified x0 value.
StitchingToolVector m_stitchingToolVector
The stitching tool vector.
pandora::StatusCode Reset()
Reset all worker instances.
unsigned int m_larCaloHitVersion
The LArCaloHit version for LArCaloHitFactory.
Header file for the MultiPandoraApi class.
pandora::InputBool m_printOverallRecoStatus
Whether to print current operation status messages.
std::string m_recreatedClusterListName
The output recreated cluster list name.
bool m_visualizeOverallRecoStatus
Whether to display results of current operations.
pandora::StatusCode TagCosmicRayPfos(const PfoToFloatMap &stitchedPfosToX0Map, pandora::PfoList &clearCosmicRayPfos, pandora::PfoList &ambiguousPfos) const
Tag clear, unambiguous cosmic-ray pfos.
std::string m_crSettingsFile
The cosmic-ray reconstruction settings file.
void StitchPfos(const pandora::ParticleFlowObject *const pPfoToEnlarge, const pandora::ParticleFlowObject *const pPfoToDelete, PfoToLArTPCMap &pfoToLArTPCMap) const
Stitch together a pair of pfos.
std::vector< StitchingBaseTool * > StitchingToolVector
std::string m_recreatedPfoListName
The output recreated pfo list name.
bool m_fullWidthCRWorkerWireGaps
Whether wire-type line gaps in cosmic-ray worker instances should cover all drift time...
std::vector< CosmicRayTaggingBaseTool * > CosmicRayTaggingToolVector
LArMCParticleFactory responsible for object creation.
pandora::StatusCode StitchCosmicRayPfos(PfoToLArTPCMap &pfoToLArTPCMap, PfoToFloatMap &stitchedPfosToX0Map) const
Stitch together cosmic-ray pfos crossing between adjacent lar tpcs.
std::unordered_map< const pandora::ParticleFlowObject *, const pandora::LArTPC * > PfoToLArTPCMap
std::string m_filePathEnvironmentVariable
The environment variable providing a list of paths to xml files.
Header file for the cosmic ray tagging tool base class.
pandora::StatusCode GetVolumeIdToHitListMap(VolumeIdToHitListMap &volumeIdToHitListMap) const
Get the mapping from lar tpc volume id to lists of all hits, and truncated hits.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
pandora::StatusCode RecreateCosmicRayPfos(PfoToLArTPCMap &pfoToLArTPCMap) const
Recreate cosmic-ray pfos (created by worker instances) in the master instance.
MasterAlgorithm class.
bool m_shouldRunSlicing
Whether to slice events into separate regions for processing.
bool m_shouldRunCosmicRecoOption
Whether to run cosmic-ray reconstruction for each slice.
pandora::InputBool m_shouldPerformSliceId
Whether to identify slices and select most appropriate pfos.
virtual pandora::StatusCode RegisterCustomContent(const pandora::Pandora *const pPandora) const
Register custom content, such as algorithms or algorithm tools, with a specified pandora instance...
pandora::StatusCode Run()
pandora::InputBool m_shouldRunCosmicRecoOption
Whether to run cosmic-ray reconstruction for each slice.
pandora::CaloHitList m_allHitList
The list of all hits originating from a given LArTPC.
std::vector< SliceIdBaseTool * > SliceIdToolVector
pandora::StatusCode SelectBestSliceHypotheses(const SliceHypotheses &nuSliceHypotheses, const SliceHypotheses &crSliceHypotheses) const
Examine slice hypotheses to identify the most appropriate to provide in final event output...
boost::graph_traits< ModuleGraph >::vertex_descriptor Vertex
Definition: ModuleGraph.h:25
Header file for the stitching tool base class.
LArCaloHitFactory responsible for object creation.
Definition: LArCaloHit.h:110
pandora::CaloHitList m_truncatedHitList
The list of hits confined within LArTPC boundaries for given beam t0 value.
PandoraInstanceList m_crWorkerInstances
The list of cosmic-ray reconstruction worker instances.
SliceIdToolVector m_sliceIdToolVector
The slice id tool vector.
std::vector< pandora::CaloHitList > SliceVector
bool m_shouldRunCosmicHitRemoval
Whether to remove hits from tagged cosmic-rays.
pandora::StatusCode RunSlicing(const VolumeIdToHitListMap &volumeIdToHitListMap, SliceVector &sliceVector) const
Run the event slicing procedures, dividing available hits up into distinct 3D regions.
bool m_shouldRunStitching
Whether to stitch cosmic-ray muons crossing between volumes.
std::list< Vertex > VertexList
Definition: DCEL.h:169
float m_inTimeMaxX0
Cut on X0 to determine whether particle is clear cosmic ray.
std::string m_inputHitListName
The input hit list name.
bool m_passMCParticlesToWorkerInstances
Whether to pass mc particle details (and links to calo hits) to worker instances. ...
pandora::StatusCode RunCosmicRayReconstruction(const VolumeIdToHitListMap &volumeIdToHitListMap) const
Run the cosmic-ray reconstruction worker instances.