LArSoft  v06_85_00
Liquid Argon Software toolkit - http://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 
15 
16 #include <unordered_map>
17 
18 namespace lar_content
19 {
20 
21 class StitchingBaseTool;
22 class CosmicRayTaggingBaseTool;
23 class SliceIdBaseTool;
25 
26 typedef std::vector<pandora::CaloHitList> SliceVector;
27 typedef std::vector<pandora::PfoList> SliceHypotheses;
28 typedef std::unordered_map<const pandora::ParticleFlowObject*, const pandora::LArTPC*> PfoToLArTPCMap;
29 typedef std::unordered_map<const pandora::ParticleFlowObject*, float> PfoToFloatMap;
30 
31 //------------------------------------------------------------------------------------------------------------------------------------------
32 
36 class MasterAlgorithm : public pandora::ExternallyConfiguredAlgorithm
37 {
38 public:
43 
47  class ExternalSteeringParameters : public pandora::ExternalParameters
48  {
49  public:
50  pandora::InputBool m_shouldRunAllHitsCosmicReco;
51  pandora::InputBool m_shouldRunStitching;
52  pandora::InputBool m_shouldRunCosmicHitRemoval;
53  pandora::InputBool m_shouldRunSlicing;
54  pandora::InputBool m_shouldRunNeutrinoRecoOption;
55  pandora::InputBool m_shouldRunCosmicRecoOption;
56  pandora::InputBool m_shouldPerformSliceId;
57  pandora::InputBool m_printOverallRecoStatus;
58  };
59 
60  typedef std::unordered_map<const pandora::ParticleFlowObject*, const pandora::LArTPC*> PfoToLArTPCMap;
61 
69  void ShiftPfoHierarchy(const pandora::ParticleFlowObject *const pParentPfo, const PfoToLArTPCMap &pfoToLArTPCMap, const float x0) const;
70 
78  void StitchPfos(const pandora::ParticleFlowObject *const pPfoToEnlarge, const pandora::ParticleFlowObject *const pPfoToDelete,
79  PfoToLArTPCMap &pfoToLArTPCMap) const;
80 
81 private:
86  {
87  public:
88  pandora::CaloHitList m_allHitList;
89  pandora::CaloHitList m_truncatedHitList;
90  };
91 
92  typedef std::map<unsigned int, LArTPCHitList> VolumeIdToHitListMap;
93 
94  pandora::StatusCode Run();
95 
99  pandora::StatusCode InitializeWorkerInstances();
100 
104  pandora::StatusCode CopyMCParticles() const;
105 
111  pandora::StatusCode GetVolumeIdToHitListMap(VolumeIdToHitListMap &volumeIdToHitListMap) const;
112 
118  pandora::StatusCode RunCosmicRayReconstruction(const VolumeIdToHitListMap &volumeIdToHitListMap) const;
119 
125  pandora::StatusCode RecreateCosmicRayPfos(PfoToLArTPCMap &pfoToLArTPCMap) const;
126 
133  pandora::StatusCode StitchCosmicRayPfos(PfoToLArTPCMap &pfoToLArTPCMap, PfoToFloatMap &stitchedPfosToX0Map) const;
134 
142  pandora::StatusCode TagCosmicRayPfos(const PfoToFloatMap &stitchedPfosToX0Map, pandora::PfoList &clearCosmicRayPfos, pandora::PfoList &ambiguousPfos) const;
143 
149  pandora::StatusCode RunCosmicRayHitRemoval(const pandora::PfoList &ambiguousPfos) const;
150 
157  pandora::StatusCode RunSlicing(const VolumeIdToHitListMap &volumeIdToHitListMap, SliceVector &sliceVector) const;
158 
166  pandora::StatusCode RunSliceReconstruction(SliceVector &sliceVector, SliceHypotheses &nuSliceHypotheses, SliceHypotheses &crSliceHypotheses) const;
167 
174  pandora::StatusCode SelectBestSliceHypotheses(const SliceHypotheses &nuSliceHypotheses, const SliceHypotheses &crSliceHypotheses) const;
175 
179  pandora::StatusCode Reset();
180 
187  pandora::StatusCode Copy(const pandora::Pandora *const pPandora, const pandora::CaloHit *const pCaloHit) const;
188 
196  pandora::StatusCode Copy(const pandora::Pandora *const pPandora, const pandora::MCParticle *const pMCParticle, const LArMCParticleFactory *const pMCParticleFactory) const;
197 
204  pandora::StatusCode Recreate(const pandora::PfoList &inputPfoList, pandora::PfoList &newPfoList) const;
205 
213  pandora::StatusCode Recreate(const pandora::ParticleFlowObject *const pInputPfo, const pandora::ParticleFlowObject *const pNewParentPfo,
214  pandora::PfoList &newPfoList) const;
215 
224  const pandora::CaloHit *CreateCaloHit(const pandora::CaloHit *const pInputCaloHit, const pandora::CaloHit *const pParentCaloHit) const;
225 
235  const pandora::Cluster *CreateCluster(const pandora::Cluster *const pInputCluster, const pandora::CaloHitList &newCaloHitList,
236  const pandora::CaloHitList &newIsolatedCaloHitList) const;
237 
245  const pandora::Vertex *CreateVertex(const pandora::Vertex *const pInputVertex) const;
246 
256  const pandora::ParticleFlowObject *CreatePfo(const pandora::ParticleFlowObject *const pInputPfo, const pandora::ClusterList &newClusterList,
257  const pandora::VertexList &newVertexList) const;
258 
269  const pandora::Pandora *CreateWorkerInstance(const pandora::LArTPC &larTPC, const pandora::DetectorGapList &gapList,
270  const std::string &settingsFile, const std::string &name) const;
271 
282  const pandora::Pandora *CreateWorkerInstance(const pandora::LArTPCMap &larTPCMap, const pandora::DetectorGapList &gapList,
283  const std::string &settingsFile, const std::string &name) const;
284 
285  pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle);
286 
296  pandora::StatusCode ReadExternalSettings(const ExternalSteeringParameters *const pExternalParameters, const pandora::InputBool inputBool,
297  const pandora::TiXmlHandle xmlHandle, const std::string &xmlTag, bool &outputBool);
298 
300 
310 
312  const pandora::Pandora *m_pSlicingWorkerInstance;
313  const pandora::Pandora *m_pSliceNuWorkerInstance;
314  const pandora::Pandora *m_pSliceCRWorkerInstance;
315 
318 
319  typedef std::vector<StitchingBaseTool*> StitchingToolVector;
320  typedef std::vector<CosmicRayTaggingBaseTool*> CosmicRayTaggingToolVector;
321  typedef std::vector<SliceIdBaseTool*> SliceIdToolVector;
322 
323  StitchingToolVector m_stitchingToolVector;
324  CosmicRayTaggingToolVector m_cosmicRayTaggingToolVector;
325  SliceIdToolVector m_sliceIdToolVector;
326 
328  std::string m_crSettingsFile;
329  std::string m_nuSettingsFile;
330  std::string m_slicingSettingsFile;
331 
333  std::string m_inputHitListName;
337 
339 };
340 
341 //------------------------------------------------------------------------------------------------------------------------------------------
342 //------------------------------------------------------------------------------------------------------------------------------------------
343 
347 class StitchingBaseTool : public pandora::AlgorithmTool
348 {
349 public:
358  virtual void Run(const MasterAlgorithm *const pAlgorithm, const pandora::PfoList *const pMultiPfoList, PfoToLArTPCMap &pfoToLArTPCMap, PfoToFloatMap &stitchedPfosToX0Map) = 0;
359 };
360 
361 //------------------------------------------------------------------------------------------------------------------------------------------
362 //------------------------------------------------------------------------------------------------------------------------------------------
363 
367 class CosmicRayTaggingBaseTool : public pandora::AlgorithmTool
368 {
369 public:
377  virtual void FindAmbiguousPfos(const pandora::PfoList &parentCosmicRayPfos, pandora::PfoList &ambiguousPfos, const MasterAlgorithm *const pAlgorithm) = 0;
378 };
379 
380 //------------------------------------------------------------------------------------------------------------------------------------------
381 //------------------------------------------------------------------------------------------------------------------------------------------
382 
386 class SliceIdBaseTool : public pandora::AlgorithmTool
387 {
388 public:
397  virtual void SelectOutputPfos(const pandora::Algorithm *const pAlgorithm, const SliceHypotheses &nuSliceHypotheses, const SliceHypotheses &crSliceHypotheses,
398  pandora::PfoList &selectedPfos) = 0;
399 };
400 
401 } // namespace lar_content
402 
403 #endif // #ifndef LAR_MASTER_ALGORITHM_H
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.
std::vector< pandora::CaloHitList > SliceVector
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< CosmicRayTaggingBaseTool * > CosmicRayTaggingToolVector
pandora::InputBool m_shouldRunStitching
Whether to stitch cosmic-ray muons crossing between volumes.
CosmicRayTaggingBaseTool class.
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.
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.
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::unordered_map< const pandora::ParticleFlowObject *, float > PfoToFloatMap
std::string m_slicingSettingsFile
The slicing settings file.
std::unordered_map< const pandora::ParticleFlowObject *, const pandora::LArTPC * > PfoToLArTPCMap
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
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.
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
MasterAlgorithm()
Default constructor.
const pandora::Pandora * m_pSliceNuWorkerInstance
The per-slice neutrino reconstruction worker instance.
std::vector< pandora::PfoList > SliceHypotheses
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.
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::vector< SliceIdBaseTool * > SliceIdToolVector
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::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...
LArMCParticleFactory responsible for object creation.
Definition: LArMCParticle.h:64
pandora::StatusCode StitchCosmicRayPfos(PfoToLArTPCMap &pfoToLArTPCMap, PfoToFloatMap &stitchedPfosToX0Map) const
Stitch together cosmic-ray pfos crossing between adjacent lar tpcs.
std::string m_filePathEnvironmentVariable
The environment variable providing a list of paths to xml files.
SliceIdBaseTool class.
StitchingBaseTool 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.
std::vector< StitchingBaseTool * > StitchingToolVector
pandora::StatusCode Run()
pandora::InputBool m_shouldRunCosmicRecoOption
Whether to run cosmic-ray reconstruction for each slice.
std::unordered_map< const pandora::ParticleFlowObject *, const pandora::LArTPC * > PfoToLArTPCMap
pandora::CaloHitList m_allHitList
The list of all hits originating from a given LArTPC.
pandora::StatusCode SelectBestSliceHypotheses(const SliceHypotheses &nuSliceHypotheses, const SliceHypotheses &crSliceHypotheses) const
Examine slice hypotheses to identify the most appropriate to provide in final event output...
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.
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:178
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.