LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
lar_content::MasterAlgorithm Class Reference

MasterAlgorithm class. More...

#include "MasterAlgorithm.h"

Inheritance diagram for lar_content::MasterAlgorithm:

Classes

class  ExternalSteeringParameters
 External steering parameters class. More...
 
class  LArTPCHitList
 LArTPCHitList class. More...
 

Public Types

typedef std::unordered_map< const pandora::ParticleFlowObject *, const pandora::LArTPC * > PfoToLArTPCMap
 

Public Member Functions

 MasterAlgorithm ()
 Default constructor. More...
 
void ShiftPfoHierarchy (const pandora::ParticleFlowObject *const pParentPfo, const PfoToLArTPCMap &pfoToLArTPCMap, const float x0) const
 Shift a Pfo hierarchy by a specified x0 value. More...
 
void StitchPfos (const pandora::ParticleFlowObject *const pPfoToEnlarge, const pandora::ParticleFlowObject *const pPfoToDelete, PfoToLArTPCMap &pfoToLArTPCMap) const
 Stitch together a pair of pfos. More...
 

Private Types

typedef std::map< unsigned int, LArTPCHitListVolumeIdToHitListMap
 
typedef std::vector< StitchingBaseTool * > StitchingToolVector
 
typedef std::vector< CosmicRayTaggingBaseTool * > CosmicRayTaggingToolVector
 
typedef std::vector< SliceIdBaseTool * > SliceIdToolVector
 

Private Member Functions

pandora::StatusCode Run ()
 
pandora::StatusCode InitializeWorkerInstances ()
 Initialize pandora worker instances. More...
 
pandora::StatusCode CopyMCParticles () const
 Copy mc particles in the named input list to all pandora worker instances. More...
 
pandora::StatusCode GetVolumeIdToHitListMap (VolumeIdToHitListMap &volumeIdToHitListMap) const
 Get the mapping from lar tpc volume id to lists of all hits, and truncated hits. More...
 
pandora::StatusCode RunCosmicRayReconstruction (const VolumeIdToHitListMap &volumeIdToHitListMap) const
 Run the cosmic-ray reconstruction worker instances. More...
 
pandora::StatusCode RecreateCosmicRayPfos (PfoToLArTPCMap &pfoToLArTPCMap) const
 Recreate cosmic-ray pfos (created by worker instances) in the master instance. More...
 
pandora::StatusCode StitchCosmicRayPfos (PfoToLArTPCMap &pfoToLArTPCMap, PfoToFloatMap &stitchedPfosToX0Map) const
 Stitch together cosmic-ray pfos crossing between adjacent lar tpcs. More...
 
pandora::StatusCode TagCosmicRayPfos (const PfoToFloatMap &stitchedPfosToX0Map, pandora::PfoList &clearCosmicRayPfos, pandora::PfoList &ambiguousPfos) const
 Tag clear, unambiguous cosmic-ray pfos. More...
 
pandora::StatusCode RunCosmicRayHitRemoval (const pandora::PfoList &ambiguousPfos) const
 Run cosmic-ray hit removal, freeing hits in ambiguous pfos for further processing. More...
 
pandora::StatusCode RunSlicing (const VolumeIdToHitListMap &volumeIdToHitListMap, SliceVector &sliceVector) const
 Run the event slicing procedures, dividing available hits up into distinct 3D regions. More...
 
pandora::StatusCode RunSliceReconstruction (SliceVector &sliceVector, SliceHypotheses &nuSliceHypotheses, SliceHypotheses &crSliceHypotheses) const
 Process each slice under different reconstruction hypotheses. More...
 
pandora::StatusCode SelectBestSliceHypotheses (const SliceHypotheses &nuSliceHypotheses, const SliceHypotheses &crSliceHypotheses) const
 Examine slice hypotheses to identify the most appropriate to provide in final event output. More...
 
pandora::StatusCode Reset ()
 Reset all worker instances. More...
 
pandora::StatusCode Copy (const pandora::Pandora *const pPandora, const pandora::CaloHit *const pCaloHit) const
 Copy a specified calo hit to the provided pandora instance. More...
 
pandora::StatusCode Copy (const pandora::Pandora *const pPandora, const pandora::MCParticle *const pMCParticle, const LArMCParticleFactory *const pMCParticleFactory) const
 Copy a specified mc particle to the provided pandora instance. More...
 
pandora::StatusCode Recreate (const pandora::PfoList &inputPfoList, pandora::PfoList &newPfoList) const
 Recreate a specified list of pfos in the current pandora instance. More...
 
pandora::StatusCode Recreate (const pandora::ParticleFlowObject *const pInputPfo, const pandora::ParticleFlowObject *const pNewParentPfo, pandora::PfoList &newPfoList) const
 Recreate a specified pfo in the current pandora instance. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
const pandora::Pandora * CreateWorkerInstance (const pandora::LArTPCMap &larTPCMap, const pandora::DetectorGapList &gapList, const std::string &settingsFile, const std::string &name) const
 Create a pandora worker instance to handle a number of LArTPCs. More...
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 
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. More...
 

Private Attributes

bool m_workerInstancesInitialized
 Whether all worker instances have been initialized. More...
 
bool m_shouldRunAllHitsCosmicReco
 Whether to run all hits cosmic-ray reconstruction. More...
 
bool m_shouldRunStitching
 Whether to stitch cosmic-ray muons crossing between volumes. More...
 
bool m_shouldRunCosmicHitRemoval
 Whether to remove hits from tagged cosmic-rays. More...
 
bool m_shouldRunSlicing
 Whether to slice events into separate regions for processing. More...
 
bool m_shouldRunNeutrinoRecoOption
 Whether to run neutrino reconstruction for each slice. More...
 
bool m_shouldRunCosmicRecoOption
 Whether to run cosmic-ray reconstruction for each slice. More...
 
bool m_shouldPerformSliceId
 Whether to identify slices and select most appropriate pfos. More...
 
bool m_printOverallRecoStatus
 Whether to print current operation status messages. More...
 
bool m_visualizeOverallRecoStatus
 Whether to display results of current operations. More...
 
PandoraInstanceList m_crWorkerInstances
 The list of cosmic-ray reconstruction worker instances. More...
 
const pandora::Pandora * m_pSlicingWorkerInstance
 The slicing worker instance. More...
 
const pandora::Pandora * m_pSliceNuWorkerInstance
 The per-slice neutrino reconstruction worker instance. More...
 
const pandora::Pandora * m_pSliceCRWorkerInstance
 The per-slice cosmic-ray reconstruction worker instance. More...
 
bool m_fullWidthCRWorkerWireGaps
 Whether wire-type line gaps in cosmic-ray worker instances should cover all drift time. More...
 
bool m_passMCParticlesToWorkerInstances
 Whether to pass mc particle details (and links to calo hits) to worker instances. More...
 
StitchingToolVector m_stitchingToolVector
 The stitching tool vector. More...
 
CosmicRayTaggingToolVector m_cosmicRayTaggingToolVector
 The cosmic-ray tagging tool vector. More...
 
SliceIdToolVector m_sliceIdToolVector
 The slice id tool vector. More...
 
std::string m_filePathEnvironmentVariable
 The environment variable providing a list of paths to xml files. More...
 
std::string m_crSettingsFile
 The cosmic-ray reconstruction settings file. More...
 
std::string m_nuSettingsFile
 The neutrino reconstruction settings file. More...
 
std::string m_slicingSettingsFile
 The slicing settings file. More...
 
std::string m_inputMCParticleListName
 The input mc particle list name. More...
 
std::string m_inputHitListName
 The input hit list name. More...
 
std::string m_recreatedPfoListName
 The output recreated pfo list name. More...
 
std::string m_recreatedClusterListName
 The output recreated cluster list name. More...
 
std::string m_recreatedVertexListName
 The output recreated vertex list name. More...
 
float m_inTimeMaxX0
 Cut on X0 to determine whether particle is clear cosmic ray. More...
 

Detailed Description

MasterAlgorithm class.

Definition at line 36 of file MasterAlgorithm.h.

Member Typedef Documentation

typedef std::unordered_map<const pandora::ParticleFlowObject*, const pandora::LArTPC*> lar_content::MasterAlgorithm::PfoToLArTPCMap

Definition at line 60 of file MasterAlgorithm.h.

Definition at line 321 of file MasterAlgorithm.h.

Definition at line 319 of file MasterAlgorithm.h.

typedef std::map<unsigned int, LArTPCHitList> lar_content::MasterAlgorithm::VolumeIdToHitListMap
private

Definition at line 92 of file MasterAlgorithm.h.

Constructor & Destructor Documentation

lar_content::MasterAlgorithm::MasterAlgorithm ( )

Default constructor.

Definition at line 35 of file MasterAlgorithm.cc.

35  :
40  m_shouldRunSlicing(true),
46  m_pSlicingWorkerInstance(nullptr),
47  m_pSliceNuWorkerInstance(nullptr),
48  m_pSliceCRWorkerInstance(nullptr),
51  m_filePathEnvironmentVariable("FW_SEARCH_PATH"),
52  m_inTimeMaxX0(1.f)
53 {
54 }
const pandora::Pandora * m_pSlicingWorkerInstance
The slicing worker instance.
bool m_shouldRunNeutrinoRecoOption
Whether to run neutrino reconstruction for each slice.
bool m_shouldRunAllHitsCosmicReco
Whether to run all hits cosmic-ray reconstruction.
bool m_shouldPerformSliceId
Whether to identify slices and select most appropriate pfos.
TFile f
Definition: plotHisto.C:6
const pandora::Pandora * m_pSliceCRWorkerInstance
The per-slice cosmic-ray reconstruction worker instance.
bool m_printOverallRecoStatus
Whether to print current operation status messages.
const pandora::Pandora * m_pSliceNuWorkerInstance
The per-slice neutrino reconstruction worker instance.
bool m_workerInstancesInitialized
Whether all worker instances have been initialized.
bool m_visualizeOverallRecoStatus
Whether to display results of current operations.
bool m_fullWidthCRWorkerWireGaps
Whether wire-type line gaps in cosmic-ray worker instances should cover all drift time...
std::string m_filePathEnvironmentVariable
The environment variable providing a list of paths to xml files.
bool m_shouldRunSlicing
Whether to slice events into separate regions for processing.
bool m_shouldRunCosmicRecoOption
Whether to run cosmic-ray reconstruction for each slice.
bool m_shouldRunCosmicHitRemoval
Whether to remove hits from tagged cosmic-rays.
bool m_shouldRunStitching
Whether to stitch cosmic-ray muons crossing between volumes.
float m_inTimeMaxX0
Cut on X0 to determine whether particle is clear cosmic ray.
bool m_passMCParticlesToWorkerInstances
Whether to pass mc particle details (and links to calo hits) to worker instances. ...

Member Function Documentation

pandora::StatusCode lar_content::MasterAlgorithm::Copy ( const pandora::Pandora *const  pPandora,
const pandora::CaloHit *const  pCaloHit 
) const
private

Copy a specified calo hit to the provided pandora instance.

Parameters
pPandorathe address of the target pandora instance
pCaloHitthe address of the calo hit

Referenced by CopyMCParticles(), Reset(), RunCosmicRayReconstruction(), RunSliceReconstruction(), and RunSlicing().

pandora::StatusCode lar_content::MasterAlgorithm::Copy ( const pandora::Pandora *const  pPandora,
const pandora::MCParticle *const  pMCParticle,
const LArMCParticleFactory *const  pMCParticleFactory 
) const
private

Copy a specified mc particle to the provided pandora instance.

Parameters
pPandorathe address of the target pandora instance
pMCParticlethe address of the mc particle
pMCParticleFactorythe address of the mc particle factory, allowing decoration of instances with information beyond that expected by sdk
StatusCode lar_content::MasterAlgorithm::CopyMCParticles ( ) const
private

Copy mc particles in the named input list to all pandora worker instances.

Definition at line 237 of file MasterAlgorithm.cc.

References Copy(), m_crWorkerInstances, m_inputMCParticleListName, m_pSliceCRWorkerInstance, m_pSliceNuWorkerInstance, and m_pSlicingWorkerInstance.

Referenced by Run().

238 {
239  const MCParticleList *pMCParticleList(nullptr);
240  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetList(*this, m_inputMCParticleListName, pMCParticleList));
241 
242  PandoraInstanceList pandoraWorkerInstances(m_crWorkerInstances);
243  if (m_pSlicingWorkerInstance) pandoraWorkerInstances.push_back(m_pSlicingWorkerInstance);
244  if (m_pSliceNuWorkerInstance) pandoraWorkerInstances.push_back(m_pSliceNuWorkerInstance);
245  if (m_pSliceCRWorkerInstance) pandoraWorkerInstances.push_back(m_pSliceCRWorkerInstance);
246 
247  LArMCParticleFactory mcParticleFactory;
248 
249  for (const Pandora *const pPandoraWorker : pandoraWorkerInstances)
250  {
251  for (const MCParticle *const pMCParticle : *pMCParticleList)
252  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->Copy(pPandoraWorker, pMCParticle, &mcParticleFactory));
253  }
254 
255  return STATUS_CODE_SUCCESS;
256 }
std::string m_inputMCParticleListName
The input mc particle list name.
pandora::StatusCode Copy(const pandora::Pandora *const pPandora, const pandora::CaloHit *const pCaloHit) const
Copy a specified calo hit to the provided pandora instance.
const pandora::Pandora * m_pSlicingWorkerInstance
The slicing worker instance.
std::vector< const pandora::Pandora * > PandoraInstanceList
const pandora::Pandora * m_pSliceCRWorkerInstance
The per-slice cosmic-ray reconstruction worker instance.
const pandora::Pandora * m_pSliceNuWorkerInstance
The per-slice neutrino reconstruction worker instance.
PandoraInstanceList m_crWorkerInstances
The list of cosmic-ray reconstruction worker instances.
const CaloHit * lar_content::MasterAlgorithm::CreateCaloHit ( const pandora::CaloHit *const  pInputCaloHit,
const pandora::CaloHit *const  pParentCaloHit 
) const
private

Create a new calo hit in the current pandora instance, based upon the provided input calo hit.

Parameters
pInputCaloHitthe address of the input calo hit
pParentCaloHitthe address of the parent calo hit
Returns
the address of the new calo hit

Definition at line 787 of file MasterAlgorithm.cc.

Referenced by Reset().

788 {
789  PandoraContentApi::CaloHit::Parameters parameters;
790  parameters.m_positionVector = pInputCaloHit->GetPositionVector();
791  parameters.m_expectedDirection = pInputCaloHit->GetExpectedDirection();
792  parameters.m_cellNormalVector = pInputCaloHit->GetCellNormalVector();
793  parameters.m_cellGeometry = pInputCaloHit->GetCellGeometry();
794  parameters.m_cellSize0 = pInputCaloHit->GetCellSize0();
795  parameters.m_cellSize1 = pInputCaloHit->GetCellSize1();
796  parameters.m_cellThickness = pInputCaloHit->GetCellThickness();
797  parameters.m_nCellRadiationLengths = pInputCaloHit->GetNCellRadiationLengths();
798  parameters.m_nCellInteractionLengths = pInputCaloHit->GetNCellInteractionLengths();
799  parameters.m_time = pInputCaloHit->GetTime();
800  parameters.m_inputEnergy = pInputCaloHit->GetInputEnergy();
801  parameters.m_mipEquivalentEnergy = pInputCaloHit->GetMipEquivalentEnergy();
802  parameters.m_electromagneticEnergy = pInputCaloHit->GetElectromagneticEnergy();
803  parameters.m_hadronicEnergy = pInputCaloHit->GetHadronicEnergy();
804  parameters.m_isDigital = pInputCaloHit->IsDigital();
805  parameters.m_hitType = pInputCaloHit->GetHitType();
806  parameters.m_hitRegion = pInputCaloHit->GetHitRegion();
807  parameters.m_layer = pInputCaloHit->GetLayer();
808  parameters.m_isInOuterSamplingLayer = pInputCaloHit->IsInOuterSamplingLayer();
809  parameters.m_pParentAddress = static_cast<const void*>(pParentCaloHit);
810 
811  const CaloHit *pNewCaloHit(nullptr);
812  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::CaloHit::Create(*this, parameters, pNewCaloHit));
813 
814  PandoraContentApi::CaloHit::Metadata metadata;
815  metadata.m_isIsolated = pInputCaloHit->IsIsolated();
816  metadata.m_isPossibleMip = pInputCaloHit->IsPossibleMip();
817  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::CaloHit::AlterMetadata(*this, pNewCaloHit, metadata));
818 
819  return pNewCaloHit;
820 }
const Cluster * lar_content::MasterAlgorithm::CreateCluster ( const pandora::Cluster *const  pInputCluster,
const pandora::CaloHitList &  newCaloHitList,
const pandora::CaloHitList &  newIsolatedCaloHitList 
) const
private

Create a new cluster in the current pandora instance, based upon the provided input cluster.

Parameters
pInputClusterthe address of the input cluster
newCaloHitListthe list of calo hits for the new cluster
newIsolatedCaloHitListthe list of isolated calo hits for the new cluster
Returns
the address of the new cluster

Definition at line 824 of file MasterAlgorithm.cc.

826 {
827  PandoraContentApi::Cluster::Parameters parameters;
828  parameters.m_caloHitList = newCaloHitList;
829  parameters.m_isolatedCaloHitList = newIsolatedCaloHitList;
830 
831  const Cluster *pNewCluster(nullptr);
832  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Cluster::Create(*this, parameters, pNewCluster));
833 
834  PandoraContentApi::Cluster::Metadata metadata;
835  metadata.m_particleId = pInputCluster->GetParticleId();
836  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Cluster::AlterMetadata(*this, pNewCluster, metadata));
837 
838  return pNewCluster;
839 }
const ParticleFlowObject * lar_content::MasterAlgorithm::CreatePfo ( const pandora::ParticleFlowObject *const  pInputPfo,
const pandora::ClusterList &  newClusterList,
const pandora::VertexList &  newVertexList 
) const
private

Create a new pfo in the current pandora instance, based upon the provided input pfo.

Parameters
pInputPfothe address of the input pfo
newClusterListthe list of clusters for the new pfo
newVertexListthe list of vertices for the new pfo
Returns
the address of the new pfo

Definition at line 858 of file MasterAlgorithm.cc.

References MultiPandoraApi::AddDaughterPandoraInstance(), CreateWorkerInstance(), m_fullWidthCRWorkerWireGaps, max, min, LArContent::RegisterAlgorithms(), and LArContent::RegisterBasicPlugins().

Referenced by Reset().

860 {
861  PandoraContentApi::ParticleFlowObject::Parameters parameters;
862  parameters.m_particleId = pInputPfo->GetParticleId();
863  parameters.m_charge = pInputPfo->GetCharge();
864  parameters.m_mass = pInputPfo->GetMass();
865  parameters.m_energy = pInputPfo->GetEnergy();
866  parameters.m_momentum = pInputPfo->GetMomentum();
867  parameters.m_clusterList = newClusterList;
868  parameters.m_trackList.clear();
869  parameters.m_vertexList = newVertexList;
870  parameters.m_propertiesToAdd = pInputPfo->GetPropertiesMap();
871 
872  const ParticleFlowObject *pNewPfo(nullptr);
873  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ParticleFlowObject::Create(*this, parameters, pNewPfo));
874 
875  return pNewPfo;
876 }
const Vertex * lar_content::MasterAlgorithm::CreateVertex ( const pandora::Vertex *const  pInputVertex) const
private

Create a new vertex in the current pandora instance, based upon the provided input vertex.

Parameters
pInputVertexthe address of the input vertex
Returns
the address of the new vertex

Definition at line 843 of file MasterAlgorithm.cc.

844 {
845  PandoraContentApi::Vertex::Parameters parameters;
846  parameters.m_position = pInputVertex->GetPosition();
847  parameters.m_vertexLabel = pInputVertex->GetVertexLabel();
848  parameters.m_vertexType = pInputVertex->GetVertexType();
849 
850  const Vertex *pNewVertex(nullptr);
851  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Vertex::Create(*this, parameters, pNewVertex));
852 
853  return pNewVertex;
854 }
const pandora::Pandora* lar_content::MasterAlgorithm::CreateWorkerInstance ( const pandora::LArTPC &  larTPC,
const pandora::DetectorGapList &  gapList,
const std::string &  settingsFile,
const std::string &  name 
) const
private

Create a pandora worker instance to handle a single LArTPC.

Parameters
larTPCthe lar tpc
gapListthe gap list
settingsFilethe pandora settings file
namethe pandora instance name
Returns
the address of the pandora instance

Referenced by CreatePfo(), and InitializeWorkerInstances().

const pandora::Pandora* lar_content::MasterAlgorithm::CreateWorkerInstance ( const pandora::LArTPCMap &  larTPCMap,
const pandora::DetectorGapList &  gapList,
const std::string &  settingsFile,
const std::string &  name 
) const
private

Create a pandora worker instance to handle a number of LArTPCs.

Parameters
larTPCMapthe lar tpc map
gapListthe gap list
settingsFilethe pandora settings file
namethe pandora instance name
Returns
the address of the pandora instance
StatusCode lar_content::MasterAlgorithm::GetVolumeIdToHitListMap ( VolumeIdToHitListMap volumeIdToHitListMap) const
private

Get the mapping from lar tpc volume id to lists of all hits, and truncated hits.

Parameters
volumeIdToHitListMapto receive the populated volume id to hit list map

Definition at line 260 of file MasterAlgorithm.cc.

References lar_content::LArCaloHit::GetLArTPCVolumeId(), and m_inputHitListName.

Referenced by Run().

261 {
262  const LArTPCMap &larTPCMap(this->GetPandora().GetGeometry()->GetLArTPCMap());
263  const unsigned int nLArTPCs(larTPCMap.size());
264 
265  const CaloHitList *pCaloHitList(nullptr);
266  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetList(*this, m_inputHitListName, pCaloHitList));
267 
268  for (const CaloHit *const pCaloHit : *pCaloHitList)
269  {
270  const LArCaloHit *const pLArCaloHit(dynamic_cast<const LArCaloHit*>(pCaloHit));
271 
272  if (!pLArCaloHit && (1 != nLArTPCs))
273  return STATUS_CODE_INVALID_PARAMETER;
274 
275  const unsigned int volumeId(pLArCaloHit ? pLArCaloHit->GetLArTPCVolumeId() : 0);
276  const LArTPC *const pLArTPC(larTPCMap.at(volumeId));
277 
278  LArTPCHitList &larTPCHitList(volumeIdToHitListMap[volumeId]);
279  larTPCHitList.m_allHitList.push_back(pCaloHit);
280 
281  if (((pCaloHit->GetPositionVector().GetX() >= (pLArTPC->GetCenterX() - 0.5f * pLArTPC->GetWidthX())) &&
282  (pCaloHit->GetPositionVector().GetX() <= (pLArTPC->GetCenterX() + 0.5f * pLArTPC->GetWidthX()))))
283  {
284  larTPCHitList.m_truncatedHitList.push_back(pCaloHit);
285  }
286  }
287 
288  return STATUS_CODE_SUCCESS;
289 }
std::string m_inputHitListName
The input hit list name.
StatusCode lar_content::MasterAlgorithm::InitializeWorkerInstances ( )
private

Initialize pandora worker instances.

Definition at line 199 of file MasterAlgorithm.cc.

References CreateWorkerInstance(), m_crSettingsFile, m_crWorkerInstances, m_nuSettingsFile, m_pSliceCRWorkerInstance, m_pSliceNuWorkerInstance, m_pSlicingWorkerInstance, m_shouldRunCosmicRecoOption, m_shouldRunNeutrinoRecoOption, m_shouldRunSlicing, m_slicingSettingsFile, m_workerInstancesInitialized, and util::flags::to_string().

Referenced by Run().

200 {
201  // ATTN Used to be in the regular Initialize callback, but detector gap list cannot be extracted in client app before the first event
203  return STATUS_CODE_ALREADY_INITIALIZED;
204 
205  try
206  {
207  const LArTPCMap &larTPCMap(this->GetPandora().GetGeometry()->GetLArTPCMap());
208  const DetectorGapList &gapList(this->GetPandora().GetGeometry()->GetDetectorGapList());
209 
210  for (const LArTPCMap::value_type &mapEntry : larTPCMap)
211  {
212  const unsigned int volumeId(mapEntry.second->GetLArTPCVolumeId());
213  m_crWorkerInstances.push_back(this->CreateWorkerInstance(*(mapEntry.second), gapList, m_crSettingsFile, "CRWorkerInstance" + std::to_string(volumeId)));
214  }
215 
216  if (m_shouldRunSlicing)
217  m_pSlicingWorkerInstance = this->CreateWorkerInstance(larTPCMap, gapList, m_slicingSettingsFile, "SlicingWorker");
218 
220  m_pSliceNuWorkerInstance = this->CreateWorkerInstance(larTPCMap, gapList, m_nuSettingsFile, "SliceNuWorker");
221 
223  m_pSliceCRWorkerInstance = this->CreateWorkerInstance(larTPCMap, gapList, m_crSettingsFile, "SliceCRWorker");
224  }
225  catch (const StatusCodeException &statusCodeException)
226  {
227  std::cout << "MasterAlgorithm: Exception during initialization of worker instances " << statusCodeException.ToString() << std::endl;
228  return statusCodeException.GetStatusCode();
229  }
230 
232  return STATUS_CODE_SUCCESS;
233 }
const pandora::Pandora * m_pSlicingWorkerInstance
The slicing worker instance.
bool m_shouldRunNeutrinoRecoOption
Whether to run neutrino reconstruction for each slice.
std::string m_slicingSettingsFile
The slicing settings file.
const pandora::Pandora * m_pSliceCRWorkerInstance
The per-slice cosmic-ray reconstruction worker instance.
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.
const pandora::Pandora * m_pSliceNuWorkerInstance
The per-slice neutrino reconstruction worker instance.
std::string m_nuSettingsFile
The neutrino reconstruction settings file.
bool m_workerInstancesInitialized
Whether all worker instances have been initialized.
std::string m_crSettingsFile
The cosmic-ray reconstruction settings file.
std::string to_string(Flag_t< Storage > const flag)
Convert a flag into a stream (shows its index).
Definition: BitMask.h:187
bool m_shouldRunSlicing
Whether to slice events into separate regions for processing.
bool m_shouldRunCosmicRecoOption
Whether to run cosmic-ray reconstruction for each slice.
PandoraInstanceList m_crWorkerInstances
The list of cosmic-ray reconstruction worker instances.
StatusCode lar_content::MasterAlgorithm::ReadExternalSettings ( const ExternalSteeringParameters *const  pExternalParameters,
const pandora::InputBool  inputBool,
const pandora::TiXmlHandle  xmlHandle,
const std::string &  xmlTag,
bool &  outputBool 
)
private

Read settings from external steering parameters block, if present, otherwise from xml as standard.

Parameters
pExternalParametersthe address of the external parameters (if present)
inputBoolthe input boolean value, from the external parameters (if present)
xmlHandlethe xml handle
xmlTagthe xml tag
outputBoolto receive the output boolean value

Definition at line 1148 of file MasterAlgorithm.cc.

Referenced by ReadSettings().

1150 {
1151  if (pExternalParameters && inputBool.IsInitialized())
1152  {
1153  outputBool = inputBool.Get();
1154  }
1155  else
1156  {
1157  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, xmlTag, outputBool));
1158  }
1159 
1160  return STATUS_CODE_SUCCESS;
1161 }
StatusCode lar_content::MasterAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 1022 of file MasterAlgorithm.cc.

References lar_content::LArFileHelper::FindFileInPath(), m_cosmicRayTaggingToolVector, m_crSettingsFile, m_filePathEnvironmentVariable, m_fullWidthCRWorkerWireGaps, m_inputHitListName, m_inputMCParticleListName, m_inTimeMaxX0, m_nuSettingsFile, m_passMCParticlesToWorkerInstances, lar_content::MasterAlgorithm::ExternalSteeringParameters::m_printOverallRecoStatus, m_printOverallRecoStatus, m_recreatedClusterListName, m_recreatedPfoListName, m_recreatedVertexListName, lar_content::MasterAlgorithm::ExternalSteeringParameters::m_shouldPerformSliceId, m_shouldPerformSliceId, lar_content::MasterAlgorithm::ExternalSteeringParameters::m_shouldRunAllHitsCosmicReco, m_shouldRunAllHitsCosmicReco, lar_content::MasterAlgorithm::ExternalSteeringParameters::m_shouldRunCosmicHitRemoval, m_shouldRunCosmicHitRemoval, lar_content::MasterAlgorithm::ExternalSteeringParameters::m_shouldRunCosmicRecoOption, m_shouldRunCosmicRecoOption, lar_content::MasterAlgorithm::ExternalSteeringParameters::m_shouldRunNeutrinoRecoOption, m_shouldRunNeutrinoRecoOption, lar_content::MasterAlgorithm::ExternalSteeringParameters::m_shouldRunSlicing, m_shouldRunSlicing, lar_content::MasterAlgorithm::ExternalSteeringParameters::m_shouldRunStitching, m_shouldRunStitching, m_sliceIdToolVector, m_slicingSettingsFile, m_stitchingToolVector, m_visualizeOverallRecoStatus, and ReadExternalSettings().

1023 {
1024  ExternalSteeringParameters *pExternalParameters(nullptr);
1025 
1026  if (this->ExternalParametersPresent())
1027  {
1028  pExternalParameters = dynamic_cast<ExternalSteeringParameters*>(this->GetExternalParameters());
1029  if (!pExternalParameters) return STATUS_CODE_FAILURE;
1030  }
1031 
1032  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->ReadExternalSettings(pExternalParameters, !pExternalParameters ? InputBool() :
1033  pExternalParameters->m_shouldRunAllHitsCosmicReco, xmlHandle, "ShouldRunAllHitsCosmicReco", m_shouldRunAllHitsCosmicReco));
1034 
1035  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->ReadExternalSettings(pExternalParameters, !pExternalParameters ? InputBool() :
1036  pExternalParameters->m_shouldRunStitching, xmlHandle, "ShouldRunStitching", m_shouldRunStitching));
1037 
1039  {
1040  std::cout << "MasterAlgorithm::ReadSettings - ShouldRunStitching requires ShouldRunAllHitsCosmicReco to be true" << std::endl;
1041  return STATUS_CODE_INVALID_PARAMETER;
1042  }
1043 
1045  {
1046  AlgorithmToolVector algorithmToolVector;
1047  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ProcessAlgorithmToolList(*this, xmlHandle, "StitchingTools", algorithmToolVector));
1048 
1049  for (AlgorithmTool *const pAlgorithmTool : algorithmToolVector)
1050  {
1051  StitchingBaseTool *const pStitchingTool(dynamic_cast<StitchingBaseTool*>(pAlgorithmTool));
1052  if (!pStitchingTool) return STATUS_CODE_INVALID_PARAMETER;
1053  m_stitchingToolVector.push_back(pStitchingTool);
1054  }
1055  }
1056 
1057  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->ReadExternalSettings(pExternalParameters, !pExternalParameters ? InputBool() :
1058  pExternalParameters->m_shouldRunCosmicHitRemoval, xmlHandle, "ShouldRunCosmicHitRemoval", m_shouldRunCosmicHitRemoval));
1059 
1061  {
1062  std::cout << "MasterAlgorithm::ReadSettings - ShouldRunCosmicHitRemoval requires ShouldRunAllHitsCosmicReco to be true" << std::endl;
1063  return STATUS_CODE_INVALID_PARAMETER;
1064  }
1065 
1067  {
1068  AlgorithmToolVector algorithmToolVector;
1069  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ProcessAlgorithmToolList(*this, xmlHandle, "CosmicRayTaggingTools", algorithmToolVector));
1070 
1071  for (AlgorithmTool *const pAlgorithmTool : algorithmToolVector)
1072  {
1073  CosmicRayTaggingBaseTool *const pCosmicRayTaggingTool(dynamic_cast<CosmicRayTaggingBaseTool*>(pAlgorithmTool));
1074  if (!pCosmicRayTaggingTool) return STATUS_CODE_INVALID_PARAMETER;
1075  m_cosmicRayTaggingToolVector.push_back(pCosmicRayTaggingTool);
1076  }
1077  }
1078 
1079  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->ReadExternalSettings(pExternalParameters, !pExternalParameters ? InputBool() :
1080  pExternalParameters->m_shouldRunSlicing, xmlHandle, "ShouldRunSlicing", m_shouldRunSlicing));
1081 
1082  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->ReadExternalSettings(pExternalParameters, !pExternalParameters ? InputBool() :
1083  pExternalParameters->m_shouldRunNeutrinoRecoOption, xmlHandle, "ShouldRunNeutrinoRecoOption", m_shouldRunNeutrinoRecoOption));
1084 
1085  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->ReadExternalSettings(pExternalParameters, !pExternalParameters ? InputBool() :
1086  pExternalParameters->m_shouldRunCosmicRecoOption, xmlHandle, "ShouldRunCosmicRecoOption", m_shouldRunCosmicRecoOption));
1087 
1088  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->ReadExternalSettings(pExternalParameters, !pExternalParameters ? InputBool() :
1089  pExternalParameters->m_shouldPerformSliceId, xmlHandle, "ShouldPerformSliceId", m_shouldPerformSliceId));
1090 
1092  {
1093  std::cout << "MasterAlgorithm::ReadSettings - ShouldPerformSliceId requires ShouldRunSlicing and both neutrino and cosmic reconstruction options" << std::endl;
1094  return STATUS_CODE_INVALID_PARAMETER;
1095  }
1096 
1098  {
1099  AlgorithmToolVector algorithmToolVector;
1100  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ProcessAlgorithmToolList(*this, xmlHandle, "SliceIdTools", algorithmToolVector));
1101 
1102  for (AlgorithmTool *const pAlgorithmTool : algorithmToolVector)
1103  {
1104  SliceIdBaseTool *const pSliceIdIdTool(dynamic_cast<SliceIdBaseTool*>(pAlgorithmTool));
1105  if (!pSliceIdIdTool) return STATUS_CODE_INVALID_PARAMETER;
1106  m_sliceIdToolVector.push_back(pSliceIdIdTool);
1107  }
1108  }
1109 
1110  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->ReadExternalSettings(pExternalParameters, !pExternalParameters ? InputBool() :
1111  pExternalParameters->m_printOverallRecoStatus, xmlHandle, "PrintOverallRecoStatus", m_printOverallRecoStatus));
1112 
1113  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
1114  "VisualizeOverallRecoStatus", m_visualizeOverallRecoStatus));
1115 
1116  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
1117  "FullWidthCRWorkerWireGaps", m_fullWidthCRWorkerWireGaps));
1118 
1119  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
1120  "PassMCParticlesToWorkerInstances", m_passMCParticlesToWorkerInstances));
1121 
1122  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
1123  "FilePathEnvironmentVariable", m_filePathEnvironmentVariable));
1124 
1125  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "CRSettingsFile", m_crSettingsFile));
1126  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "NuSettingsFile", m_nuSettingsFile));
1127  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "SlicingSettingsFile", m_slicingSettingsFile));
1131 
1133  {
1134  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "InputMCParticleListName", m_inputMCParticleListName));
1135  }
1136 
1137  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "InputHitListName", m_inputHitListName));
1138  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "RecreatedPfoListName", m_recreatedPfoListName));
1139  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "RecreatedClusterListName", m_recreatedClusterListName));
1140  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "RecreatedVertexListName", m_recreatedVertexListName));
1141  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "InTimeMaxX0", m_inTimeMaxX0));
1142 
1143  return STATUS_CODE_SUCCESS;
1144 }
std::string m_inputMCParticleListName
The input mc particle list name.
CosmicRayTaggingToolVector m_cosmicRayTaggingToolVector
The cosmic-ray tagging tool vector.
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...
bool m_shouldRunNeutrinoRecoOption
Whether to run neutrino reconstruction for each slice.
bool m_shouldRunAllHitsCosmicReco
Whether to run all hits cosmic-ray reconstruction.
bool m_shouldPerformSliceId
Whether to identify slices and select most appropriate pfos.
std::string m_slicingSettingsFile
The slicing settings file.
std::string m_recreatedVertexListName
The output recreated vertex list name.
bool m_printOverallRecoStatus
Whether to print current operation status messages.
std::string m_nuSettingsFile
The neutrino reconstruction settings file.
StitchingToolVector m_stitchingToolVector
The stitching tool vector.
std::string m_recreatedClusterListName
The output recreated cluster list name.
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...
bool m_visualizeOverallRecoStatus
Whether to display results of current operations.
std::string m_crSettingsFile
The cosmic-ray reconstruction settings file.
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::string m_filePathEnvironmentVariable
The environment variable providing a list of paths to xml files.
bool m_shouldRunSlicing
Whether to slice events into separate regions for processing.
bool m_shouldRunCosmicRecoOption
Whether to run cosmic-ray reconstruction for each slice.
SliceIdToolVector m_sliceIdToolVector
The slice id tool vector.
bool m_shouldRunCosmicHitRemoval
Whether to remove hits from tagged cosmic-rays.
bool m_shouldRunStitching
Whether to stitch cosmic-ray muons crossing between volumes.
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 lar_content::MasterAlgorithm::Recreate ( const pandora::PfoList &  inputPfoList,
pandora::PfoList &  newPfoList 
) const
private

Recreate a specified list of pfos in the current pandora instance.

Parameters
inputPfoListthe input pfo list
newPfoListto receive the list of new pfos

Referenced by RecreateCosmicRayPfos(), Reset(), and SelectBestSliceHypotheses().

pandora::StatusCode lar_content::MasterAlgorithm::Recreate ( const pandora::ParticleFlowObject *const  pInputPfo,
const pandora::ParticleFlowObject *const  pNewParentPfo,
pandora::PfoList &  newPfoList 
) const
private

Recreate a specified pfo in the current pandora instance.

Parameters
pInputPfothe input pfo
pNewParentPfothe new parent of the new output pfo (nullptr if none)
newPfoListto receive the list of new pfos
StatusCode lar_content::MasterAlgorithm::RecreateCosmicRayPfos ( PfoToLArTPCMap pfoToLArTPCMap) const
private

Recreate cosmic-ray pfos (created by worker instances) in the master instance.

Parameters
pfoToLArTPCMapto receive the populated pfo to lar tpc map

Definition at line 319 of file MasterAlgorithm.cc.

References m_crWorkerInstances, and Recreate().

Referenced by Run().

320 {
321  for (const Pandora *const pCRWorker : m_crWorkerInstances)
322  {
323  const PfoList *pCRPfos(nullptr);
324  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::GetCurrentPfoList(*pCRWorker, pCRPfos));
325 
326  PfoList newPfoList;
327  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->Recreate(*pCRPfos, newPfoList));
328 
329  const LArTPC &larTPC(pCRWorker->GetGeometry()->GetLArTPC());
330 
331  for (const Pfo *const pNewPfo : newPfoList)
332  pfoToLArTPCMap[pNewPfo] = &larTPC;
333  }
334 
335  return STATUS_CODE_SUCCESS;
336 }
pandora::StatusCode Recreate(const pandora::PfoList &inputPfoList, pandora::PfoList &newPfoList) const
Recreate a specified list of pfos in the current pandora instance.
PandoraInstanceList m_crWorkerInstances
The list of cosmic-ray reconstruction worker instances.
StatusCode lar_content::MasterAlgorithm::Reset ( )
private

Reset all worker instances.

Definition at line 578 of file MasterAlgorithm.cc.

References Copy(), CreateCaloHit(), CreatePfo(), lar_content::LArMCParticle::GetNuanceCode(), lar_content::LArPfoHelper::GetThreeDClusterList(), lar_content::LArPfoHelper::GetTwoDClusterList(), m_crWorkerInstances, lar_content::LArMCParticleParameters::m_nuanceCode, m_passMCParticlesToWorkerInstances, m_pSliceCRWorkerInstance, m_pSliceNuWorkerInstance, m_pSlicingWorkerInstance, m_recreatedClusterListName, m_recreatedPfoListName, m_recreatedVertexListName, Recreate(), Reset(), and lar_content::LArMCParticleHelper::SortByMomentum().

Referenced by Run().

579 {
580  for (const Pandora *const pCRWorker : m_crWorkerInstances)
581  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::Reset(*pCRWorker));
582 
584  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::Reset(*m_pSlicingWorkerInstance));
585 
587  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::Reset(*m_pSliceNuWorkerInstance));
588 
590  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::Reset(*m_pSliceCRWorkerInstance));
591 
592  return STATUS_CODE_SUCCESS;
593 }
const pandora::Pandora * m_pSlicingWorkerInstance
The slicing worker instance.
const pandora::Pandora * m_pSliceCRWorkerInstance
The per-slice cosmic-ray reconstruction worker instance.
ntupleExperimental Reset()
const pandora::Pandora * m_pSliceNuWorkerInstance
The per-slice neutrino reconstruction worker instance.
PandoraInstanceList m_crWorkerInstances
The list of cosmic-ray reconstruction worker instances.
StatusCode lar_content::MasterAlgorithm::Run ( )
private

Definition at line 152 of file MasterAlgorithm.cc.

References CopyMCParticles(), GetVolumeIdToHitListMap(), InitializeWorkerInstances(), m_passMCParticlesToWorkerInstances, m_shouldRunAllHitsCosmicReco, m_shouldRunCosmicHitRemoval, m_shouldRunCosmicRecoOption, m_shouldRunNeutrinoRecoOption, m_shouldRunStitching, m_workerInstancesInitialized, RecreateCosmicRayPfos(), Reset(), RunCosmicRayHitRemoval(), RunCosmicRayReconstruction(), RunSliceReconstruction(), RunSlicing(), SelectBestSliceHypotheses(), StitchCosmicRayPfos(), and TagCosmicRayPfos().

153 {
154  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->Reset());
155 
157  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->InitializeWorkerInstances());
158 
160  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->CopyMCParticles());
161 
162  PfoToFloatMap stitchedPfosToX0Map;
163  VolumeIdToHitListMap volumeIdToHitListMap;
164  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->GetVolumeIdToHitListMap(volumeIdToHitListMap));
165 
167  {
168  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->RunCosmicRayReconstruction(volumeIdToHitListMap));
169 
170  PfoToLArTPCMap pfoToLArTPCMap;
171  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->RecreateCosmicRayPfos(pfoToLArTPCMap));
172 
174  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->StitchCosmicRayPfos(pfoToLArTPCMap, stitchedPfosToX0Map));
175  }
176 
178  {
179  PfoList clearCosmicRayPfos, ambiguousPfos;
180  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->TagCosmicRayPfos(stitchedPfosToX0Map, clearCosmicRayPfos, ambiguousPfos));
181  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->RunCosmicRayHitRemoval(ambiguousPfos));
182  }
183 
184  SliceVector sliceVector;
185  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->RunSlicing(volumeIdToHitListMap, sliceVector));
186 
188  {
189  SliceHypotheses nuSliceHypotheses, crSliceHypotheses;
190  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->RunSliceReconstruction(sliceVector, nuSliceHypotheses, crSliceHypotheses));
191  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->SelectBestSliceHypotheses(nuSliceHypotheses, crSliceHypotheses));
192  }
193 
194  return STATUS_CODE_SUCCESS;
195 }
std::vector< pandora::CaloHitList > SliceVector
pandora::StatusCode CopyMCParticles() const
Copy mc particles in the named input list to all pandora worker instances.
bool m_shouldRunNeutrinoRecoOption
Whether to run neutrino reconstruction for each slice.
bool m_shouldRunAllHitsCosmicReco
Whether to run all hits cosmic-ray reconstruction.
std::unordered_map< const pandora::ParticleFlowObject *, float > PfoToFloatMap
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.
pandora::StatusCode RunSliceReconstruction(SliceVector &sliceVector, SliceHypotheses &nuSliceHypotheses, SliceHypotheses &crSliceHypotheses) const
Process each slice under different reconstruction hypotheses.
std::map< unsigned int, LArTPCHitList > VolumeIdToHitListMap
std::vector< pandora::PfoList > SliceHypotheses
pandora::StatusCode InitializeWorkerInstances()
Initialize pandora worker instances.
bool m_workerInstancesInitialized
Whether all worker instances have been initialized.
pandora::StatusCode Reset()
Reset all worker instances.
pandora::StatusCode TagCosmicRayPfos(const PfoToFloatMap &stitchedPfosToX0Map, pandora::PfoList &clearCosmicRayPfos, pandora::PfoList &ambiguousPfos) const
Tag clear, unambiguous cosmic-ray pfos.
pandora::StatusCode StitchCosmicRayPfos(PfoToLArTPCMap &pfoToLArTPCMap, PfoToFloatMap &stitchedPfosToX0Map) const
Stitch together cosmic-ray pfos crossing between adjacent lar tpcs.
pandora::StatusCode GetVolumeIdToHitListMap(VolumeIdToHitListMap &volumeIdToHitListMap) const
Get the mapping from lar tpc volume id to lists of all hits, and truncated hits.
pandora::StatusCode RecreateCosmicRayPfos(PfoToLArTPCMap &pfoToLArTPCMap) const
Recreate cosmic-ray pfos (created by worker instances) in the master instance.
bool m_shouldRunCosmicRecoOption
Whether to run cosmic-ray reconstruction for each slice.
pandora::StatusCode SelectBestSliceHypotheses(const SliceHypotheses &nuSliceHypotheses, const SliceHypotheses &crSliceHypotheses) const
Examine slice hypotheses to identify the most appropriate to provide in final event output...
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.
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.
StatusCode lar_content::MasterAlgorithm::RunCosmicRayHitRemoval ( const pandora::PfoList &  ambiguousPfos) const
private

Run cosmic-ray hit removal, freeing hits in ambiguous pfos for further processing.

Parameters
ambiguousPfosthe list of ambiguous cosmic-ray pfos

Definition at line 409 of file MasterAlgorithm.cc.

References lar_content::LArPfoHelper::GetAllConnectedPfos().

Referenced by Run().

410 {
411  PfoList allPfosToDelete;
412  LArPfoHelper::GetAllConnectedPfos(ambiguousPfos, allPfosToDelete);
413 
414  for (const Pfo *const pPfoToDelete : allPfosToDelete)
415  {
416  const ClusterList clusterList(pPfoToDelete->GetClusterList());
417  const VertexList vertexList(pPfoToDelete->GetVertexList());
418  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Delete(*this, pPfoToDelete));
419  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Delete(*this, &clusterList));
420  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Delete(*this, &vertexList));
421  }
422 
423  return STATUS_CODE_SUCCESS;
424 }
static void GetAllConnectedPfos(const pandora::PfoList &inputPfoList, pandora::PfoList &outputPfoList)
Get a flat list of all pfos, recursively including all daughters and parents associated with those pf...
std::list< Vertex > VertexList
Definition: DCEL.h:178
StatusCode lar_content::MasterAlgorithm::RunCosmicRayReconstruction ( const VolumeIdToHitListMap volumeIdToHitListMap) const
private

Run the cosmic-ray reconstruction worker instances.

Parameters
volumeIdToHitListMapthe volume id to hit list map

Definition at line 293 of file MasterAlgorithm.cc.

References Copy(), m_crWorkerInstances, m_printOverallRecoStatus, and ProcessEvent().

Referenced by Run().

294 {
295  unsigned int workerCounter(0);
296 
297  for (const Pandora *const pCRWorker : m_crWorkerInstances)
298  {
299  const LArTPC &larTPC(pCRWorker->GetGeometry()->GetLArTPC());
300  VolumeIdToHitListMap::const_iterator iter(volumeIdToHitListMap.find(larTPC.GetLArTPCVolumeId()));
301 
302  if (volumeIdToHitListMap.end() == iter)
303  continue;
304 
305  for (const CaloHit *const pCaloHit : iter->second.m_allHitList)
306  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->Copy(pCRWorker, pCaloHit));
307 
309  std::cout << "Running cosmic-ray reconstruction worker instance " << ++workerCounter << " of " << m_crWorkerInstances.size() << std::endl;
310 
311  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::ProcessEvent(*pCRWorker));
312  }
313 
314  return STATUS_CODE_SUCCESS;
315 }
pandora::StatusCode Copy(const pandora::Pandora *const pPandora, const pandora::CaloHit *const pCaloHit) const
Copy a specified calo hit to the provided pandora instance.
void ProcessEvent(G4int iProp, size_t nEv)
Definition: errprop.cc:172
bool m_printOverallRecoStatus
Whether to print current operation status messages.
intermediate_table::const_iterator const_iterator
PandoraInstanceList m_crWorkerInstances
The list of cosmic-ray reconstruction worker instances.
StatusCode lar_content::MasterAlgorithm::RunSliceReconstruction ( SliceVector sliceVector,
SliceHypotheses nuSliceHypotheses,
SliceHypotheses crSliceHypotheses 
) const
private

Process each slice under different reconstruction hypotheses.

Parameters
sliceVectorthe slice vector
nuSliceHypothesesto receive the vector of slice neutrino hypotheses
crSliceHypothesesto receive the vector of slice cosmic-ray hypotheses

Definition at line 485 of file MasterAlgorithm.cc.

References Copy(), m_printOverallRecoStatus, m_pSliceCRWorkerInstance, m_pSliceNuWorkerInstance, m_shouldRunCosmicRecoOption, m_shouldRunNeutrinoRecoOption, m_shouldRunSlicing, and ProcessEvent().

Referenced by Run().

486 {
487  unsigned int sliceCounter(0);
488 
489  for (const CaloHitList &sliceHits : sliceVector)
490  {
491  for (const CaloHit *const pSliceCaloHit : sliceHits)
492  {
493  // ATTN Must ensure we copy the hit actually owned by master instance; access differs with/without slicing enabled
494  const CaloHit *const pCaloHitInMaster(m_shouldRunSlicing ? static_cast<const CaloHit*>(pSliceCaloHit->GetParentAddress()) : pSliceCaloHit);
495 
497  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->Copy(m_pSliceNuWorkerInstance, pCaloHitInMaster));
498 
500  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->Copy(m_pSliceCRWorkerInstance, pCaloHitInMaster));
501  }
502 
503  ++sliceCounter;
504 
506  {
508  std::cout << "Running nu worker instance for slice " << sliceCounter << " of " << sliceVector.size() << std::endl;
509 
510  const PfoList *pSliceNuPfos(nullptr);
511  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::ProcessEvent(*m_pSliceNuWorkerInstance));
512  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::GetCurrentPfoList(*m_pSliceNuWorkerInstance, pSliceNuPfos));
513  nuSliceHypotheses.push_back(*pSliceNuPfos);
514 
515  for (const ParticleFlowObject *const pPfo : *pSliceNuPfos)
516  {
517  PandoraContentApi::ParticleFlowObject::Metadata metadata;
518  metadata.m_propertiesToAdd["SliceIndex"] = sliceCounter;
519  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ParticleFlowObject::AlterMetadata(*this, pPfo, metadata));
520  }
521  }
522 
524  {
526  std::cout << "Running cr worker instance for slice " << sliceCounter << " of " << sliceVector.size() << std::endl;
527 
528  const PfoList *pSliceCRPfos(nullptr);
529  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::ProcessEvent(*m_pSliceCRWorkerInstance));
530  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::GetCurrentPfoList(*m_pSliceCRWorkerInstance, pSliceCRPfos));
531  crSliceHypotheses.push_back(*pSliceCRPfos);
532 
533  for (const ParticleFlowObject *const pPfo : *pSliceCRPfos)
534  {
535  PandoraContentApi::ParticleFlowObject::Metadata metadata;
536  metadata.m_propertiesToAdd["SliceIndex"] = sliceCounter;
537  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ParticleFlowObject::AlterMetadata(*this, pPfo, metadata));
538  }
539  }
540  }
541 
542  if (m_shouldRunNeutrinoRecoOption && m_shouldRunCosmicRecoOption && (nuSliceHypotheses.size() != crSliceHypotheses.size()))
543  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
544 
545  return STATUS_CODE_SUCCESS;
546 }
pandora::StatusCode Copy(const pandora::Pandora *const pPandora, const pandora::CaloHit *const pCaloHit) const
Copy a specified calo hit to the provided pandora instance.
bool m_shouldRunNeutrinoRecoOption
Whether to run neutrino reconstruction for each slice.
void ProcessEvent(G4int iProp, size_t nEv)
Definition: errprop.cc:172
const pandora::Pandora * m_pSliceCRWorkerInstance
The per-slice cosmic-ray reconstruction worker instance.
bool m_printOverallRecoStatus
Whether to print current operation status messages.
const pandora::Pandora * m_pSliceNuWorkerInstance
The per-slice neutrino reconstruction worker instance.
bool m_shouldRunSlicing
Whether to slice events into separate regions for processing.
bool m_shouldRunCosmicRecoOption
Whether to run cosmic-ray reconstruction for each slice.
StatusCode lar_content::MasterAlgorithm::RunSlicing ( const VolumeIdToHitListMap volumeIdToHitListMap,
SliceVector sliceVector 
) const
private

Run the event slicing procedures, dividing available hits up into distinct 3D regions.

Parameters
volumeIdToHitListMapthe volume id to hit list map
sliceVectorto receive the populated slice vector

Definition at line 428 of file MasterAlgorithm.cc.

References Copy(), lar_content::LArPfoHelper::GetCaloHits(), m_printOverallRecoStatus, m_pSlicingWorkerInstance, m_shouldRunSlicing, m_visualizeOverallRecoStatus, and ProcessEvent().

Referenced by Run().

429 {
430  for (const VolumeIdToHitListMap::value_type &mapEntry : volumeIdToHitListMap)
431  {
432  for (const CaloHit *const pCaloHit : mapEntry.second.m_truncatedHitList)
433  {
434  if (!PandoraContentApi::IsAvailable(*this, pCaloHit))
435  continue;
436 
437  const HitType hitType(pCaloHit->GetHitType());
438  if ((TPC_VIEW_U != hitType) && (TPC_VIEW_V != hitType) && (TPC_VIEW_W != hitType))
439  continue;
440 
441  if (m_shouldRunSlicing)
442  {
443  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->Copy(m_pSlicingWorkerInstance, pCaloHit));
444  }
445  else
446  {
447  if (sliceVector.empty()) sliceVector.push_back(CaloHitList());
448  sliceVector.back().push_back(pCaloHit);
449  }
450  }
451  }
452 
453  if (m_shouldRunSlicing)
454  {
456  std::cout << "Running slicing worker instance" << std::endl;
457 
458  const PfoList *pSlicePfos(nullptr);
459  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::ProcessEvent(*m_pSlicingWorkerInstance));
460  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::GetCurrentPfoList(*m_pSlicingWorkerInstance, pSlicePfos));
461 
463  {
464  PANDORA_MONITORING_API(VisualizeParticleFlowObjects(this->GetPandora(), pSlicePfos, "OnePfoPerSlice", BLUE));
465  PANDORA_MONITORING_API(ViewEvent(this->GetPandora()));
466  }
467 
468  for (const Pfo *const pSlicePfo : *pSlicePfos)
469  {
470  sliceVector.push_back(CaloHitList());
471  LArPfoHelper::GetCaloHits(pSlicePfo, TPC_VIEW_U, sliceVector.back());
472  LArPfoHelper::GetCaloHits(pSlicePfo, TPC_VIEW_V, sliceVector.back());
473  LArPfoHelper::GetCaloHits(pSlicePfo, TPC_VIEW_W, sliceVector.back());
474  }
475  }
476 
478  std::cout << "Identified " << sliceVector.size() << " slice(s)" << std::endl;
479 
480  return STATUS_CODE_SUCCESS;
481 }
pandora::StatusCode Copy(const pandora::Pandora *const pPandora, const pandora::CaloHit *const pCaloHit) const
Copy a specified calo hit to the provided pandora instance.
const pandora::Pandora * m_pSlicingWorkerInstance
The slicing worker instance.
void ProcessEvent(G4int iProp, size_t nEv)
Definition: errprop.cc:172
bool m_printOverallRecoStatus
Whether to print current operation status messages.
bool m_visualizeOverallRecoStatus
Whether to display results of current operations.
bool m_shouldRunSlicing
Whether to slice events into separate regions for processing.
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.
StatusCode lar_content::MasterAlgorithm::SelectBestSliceHypotheses ( const SliceHypotheses nuSliceHypotheses,
const SliceHypotheses crSliceHypotheses 
) const
private

Examine slice hypotheses to identify the most appropriate to provide in final event output.

Parameters
nuSliceHypothesesthe vector of slice neutrino hypotheses
crSliceHypothesesthe vector of slice cosmic-ray hypotheses

Definition at line 550 of file MasterAlgorithm.cc.

References m_printOverallRecoStatus, m_shouldPerformSliceId, m_shouldRunCosmicRecoOption, m_shouldRunNeutrinoRecoOption, m_sliceIdToolVector, and Recreate().

Referenced by Run().

551 {
553  std::cout << "Select best slice hypotheses" << std::endl;
554 
555  PfoList selectedSlicePfos;
556 
558  {
559  for (SliceIdBaseTool *const pSliceIdTool : m_sliceIdToolVector)
560  pSliceIdTool->SelectOutputPfos(this, nuSliceHypotheses, crSliceHypotheses, selectedSlicePfos);
561  }
563  {
564  const SliceHypotheses &sliceHypotheses(m_shouldRunNeutrinoRecoOption ? nuSliceHypotheses : crSliceHypotheses);
565 
566  for (const PfoList &slice : sliceHypotheses)
567  selectedSlicePfos.insert(selectedSlicePfos.end(), slice.begin(), slice.end());
568  }
569 
570  PfoList newSlicePfoList;
571  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->Recreate(selectedSlicePfos, newSlicePfoList));
572 
573  return STATUS_CODE_SUCCESS;
574 }
pandora::StatusCode Recreate(const pandora::PfoList &inputPfoList, pandora::PfoList &newPfoList) const
Recreate a specified list of pfos in the current pandora instance.
bool m_shouldRunNeutrinoRecoOption
Whether to run neutrino reconstruction for each slice.
bool m_shouldPerformSliceId
Whether to identify slices and select most appropriate pfos.
bool m_printOverallRecoStatus
Whether to print current operation status messages.
std::vector< pandora::PfoList > SliceHypotheses
bool m_shouldRunCosmicRecoOption
Whether to run cosmic-ray reconstruction for each slice.
SliceIdToolVector m_sliceIdToolVector
The slice id tool vector.
void lar_content::MasterAlgorithm::ShiftPfoHierarchy ( const pandora::ParticleFlowObject *const  pParentPfo,
const PfoToLArTPCMap pfoToLArTPCMap,
const float  x0 
) const

Shift a Pfo hierarchy by a specified x0 value.

Parameters
pPfothe address of the parent pfo
stitchingInfothe source for additional, local, stitching information
x0the x0 correction relative to the input pfo

Definition at line 58 of file MasterAlgorithm.cc.

References lar_content::LArPfoHelper::GetAllDownstreamPfos(), and m_visualizeOverallRecoStatus.

Referenced by lar_content::StitchingCosmicRayMergingTool::StitchPfos().

59 {
60  if (!pParentPfo->GetParentPfoList().empty())
61  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
62 
63  PfoToLArTPCMap::const_iterator larTPCIter(pfoToLArTPCMap.find(pParentPfo));
64 
65  if (pfoToLArTPCMap.end() == larTPCIter)
66  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
67 
68  PfoList pfoList;
69  LArPfoHelper::GetAllDownstreamPfos(pParentPfo, pfoList);
70  const float signedX0(larTPCIter->second->IsDriftInPositiveX() ? -x0 : x0);
71 
73  {
74  std::cout << "ShiftPfoHierarchy: signedX0 " << signedX0 << std::endl;
75  PANDORA_MONITORING_API(VisualizeParticleFlowObjects(this->GetPandora(), &pfoList, "BeforeShiftCRPfos", GREEN));
76  }
77 
78  for (const ParticleFlowObject *const pDaughterPfo : pfoList)
79  {
80  CaloHitList caloHitList;
81  for (const Cluster *const pCluster : pDaughterPfo->GetClusterList())
82  {
83  pCluster->GetOrderedCaloHitList().FillCaloHitList(caloHitList);
84  caloHitList.insert(caloHitList.end(), pCluster->GetIsolatedCaloHitList().begin(), pCluster->GetIsolatedCaloHitList().end());
85  }
86 
87  for (const CaloHit *const pCaloHit : caloHitList)
88  {
89  PandoraContentApi::CaloHit::Metadata metadata;
90  metadata.m_x0 = signedX0;
91  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::CaloHit::AlterMetadata(*this, pCaloHit, metadata));
92  }
93 
94  for (const Vertex *const pVertex : pDaughterPfo->GetVertexList())
95  {
96  PandoraContentApi::Vertex::Metadata metadata;
97  metadata.m_x0 = signedX0;
98  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Vertex::AlterMetadata(*this, pVertex, metadata));
99  }
100  }
101 
103  {
104  PANDORA_MONITORING_API(VisualizeParticleFlowObjects(this->GetPandora(), &pfoList, "AfterShiftCRPfos", RED));
105  PANDORA_MONITORING_API(ViewEvent(this->GetPandora()));
106  }
107 }
intermediate_table::const_iterator const_iterator
bool m_visualizeOverallRecoStatus
Whether to display results of current operations.
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...
StatusCode lar_content::MasterAlgorithm::StitchCosmicRayPfos ( PfoToLArTPCMap pfoToLArTPCMap,
PfoToFloatMap stitchedPfosToX0Map 
) const
private

Stitch together cosmic-ray pfos crossing between adjacent lar tpcs.

Parameters
pfoToLArTPCMapthe pfo to lar tpc map
stitchedPfosToX0Mapto receive the map of cosmic-ray pfos that have been stitched between lar tpcs to the X0 shift

Definition at line 340 of file MasterAlgorithm.cc.

References m_stitchingToolVector, and m_visualizeOverallRecoStatus.

Referenced by Run().

341 {
342  const PfoList *pRecreatedCRPfos(nullptr);
343  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::GetCurrentPfoList(this->GetPandora(), pRecreatedCRPfos));
344 
346  {
347  PANDORA_MONITORING_API(VisualizeParticleFlowObjects(this->GetPandora(), pRecreatedCRPfos, "RecreatedCRPfos", GREEN));
348  PANDORA_MONITORING_API(ViewEvent(this->GetPandora()));
349  }
350 
351  for (StitchingBaseTool *const pStitchingTool : m_stitchingToolVector)
352  pStitchingTool->Run(this, pRecreatedCRPfos, pfoToLArTPCMap, stitchedPfosToX0Map);
353 
355  {
356  PANDORA_MONITORING_API(VisualizeParticleFlowObjects(this->GetPandora(), pRecreatedCRPfos, "AfterStitchingCRPfos", RED));
357  PANDORA_MONITORING_API(ViewEvent(this->GetPandora()));
358  }
359 
360  return STATUS_CODE_SUCCESS;
361 }
StitchingToolVector m_stitchingToolVector
The stitching tool vector.
bool m_visualizeOverallRecoStatus
Whether to display results of current operations.
void lar_content::MasterAlgorithm::StitchPfos ( const pandora::ParticleFlowObject *const  pPfoToEnlarge,
const pandora::ParticleFlowObject *const  pPfoToDelete,
PfoToLArTPCMap pfoToLArTPCMap 
) const

Stitch together a pair of pfos.

Parameters
pPfoToEnlargethe address of the pfo to enlarge
pPfoToDeletethe address of the pfo to delete (will become a dangling pointer)
stitchingInfothe source for additional, local, stitching information

Definition at line 111 of file MasterAlgorithm.cc.

References lar_content::LArClusterHelper::GetClusterHitType(), lar_content::PfoMopUpBaseAlgorithm::GetParentCluster(), m_recreatedClusterListName, m_recreatedPfoListName, and m_recreatedVertexListName.

Referenced by lar_content::StitchingCosmicRayMergingTool::StitchPfos().

113 {
114  if (pPfoToEnlarge == pPfoToDelete)
115  throw StatusCodeException(STATUS_CODE_NOT_ALLOWED);
116 
117  // ATTN Remove pfos from pfo to lar tpc map here, avoiding problems if stitching across multiple tpcs.
118  pfoToLArTPCMap.erase(pPfoToEnlarge);
119  pfoToLArTPCMap.erase(pPfoToDelete);
120 
121  const PfoList daughterPfos(pPfoToDelete->GetDaughterPfoList());
122  const ClusterVector daughterClusters(pPfoToDelete->GetClusterList().begin(), pPfoToDelete->GetClusterList().end());
123  const VertexVector daughterVertices(pPfoToDelete->GetVertexList().begin(), pPfoToDelete->GetVertexList().end());
124 
125  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Delete(*this, pPfoToDelete, m_recreatedPfoListName));
126 
127  for (const ParticleFlowObject *const pDaughterPfo : daughterPfos)
128  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SetPfoParentDaughterRelationship(*this, pPfoToEnlarge, pDaughterPfo));
129 
130  for (const Vertex *const pDaughterVertex : daughterVertices)
131  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Delete(*this, pDaughterVertex, m_recreatedVertexListName));
132 
133  for (const Cluster *const pDaughterCluster : daughterClusters)
134  {
135  const HitType daughterHitType(LArClusterHelper::GetClusterHitType(pDaughterCluster));
136  const Cluster *pParentCluster(PfoMopUpBaseAlgorithm::GetParentCluster(pPfoToEnlarge->GetClusterList(), daughterHitType));
137 
138  if (pParentCluster)
139  {
140  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::MergeAndDeleteClusters(*this, pParentCluster, pDaughterCluster,
142  }
143  else
144  {
145  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::AddToPfo(*this, pPfoToEnlarge, pDaughterCluster));
146  }
147  }
148 }
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
std::string m_recreatedVertexListName
The output recreated vertex list name.
std::string m_recreatedClusterListName
The output recreated cluster list name.
static const pandora::Cluster * GetParentCluster(const pandora::ClusterList &clusterList, const pandora::HitType hitType)
Select the parent cluster (same hit type and most hits) using a provided cluster list and hit type...
std::string m_recreatedPfoListName
The output recreated pfo list name.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
std::vector< art::Ptr< recob::Vertex > > VertexVector
StatusCode lar_content::MasterAlgorithm::TagCosmicRayPfos ( const PfoToFloatMap stitchedPfosToX0Map,
pandora::PfoList &  clearCosmicRayPfos,
pandora::PfoList &  ambiguousPfos 
) const
private

Tag clear, unambiguous cosmic-ray pfos.

Parameters
stitchedPfosToX0Mapa map of cosmic-ray pfos that have been stitched between lar tpcs to the X0 shift
clearCosmicRayPfosto receive the list of clear cosmic-ray pfos
ambiguousPfosto receive the list of ambiguous cosmic-ray pfos for further analysis

Definition at line 365 of file MasterAlgorithm.cc.

References m_cosmicRayTaggingToolVector, m_inTimeMaxX0, and m_visualizeOverallRecoStatus.

Referenced by Run().

366 {
367  const PfoList *pRecreatedCRPfos(nullptr);
368  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::GetCurrentPfoList(this->GetPandora(), pRecreatedCRPfos));
369 
370  PfoList nonStitchedParentCosmicRayPfos;
371  for (const Pfo *const pPfo : *pRecreatedCRPfos)
372  {
373  if (!pPfo->GetParentPfoList().empty())
374  continue;
375 
376  PfoToFloatMap::const_iterator pfoToX0Iter = stitchedPfosToX0Map.find(pPfo);
377  const float x0Shift((pfoToX0Iter != stitchedPfosToX0Map.end()) ? pfoToX0Iter->second : 0.f);
378  PfoList &targetList((std::fabs(x0Shift) > m_inTimeMaxX0) ? clearCosmicRayPfos : nonStitchedParentCosmicRayPfos);
379  targetList.push_back(pPfo);
380  }
381 
382  for (CosmicRayTaggingBaseTool *const pCosmicRayTaggingTool : m_cosmicRayTaggingToolVector)
383  pCosmicRayTaggingTool->FindAmbiguousPfos(nonStitchedParentCosmicRayPfos, ambiguousPfos, this);
384 
385  for (const Pfo *const pPfo : nonStitchedParentCosmicRayPfos)
386  {
387  const bool isClearCosmic(ambiguousPfos.end() == std::find(ambiguousPfos.begin(), ambiguousPfos.end(), pPfo));
388 
389  if (isClearCosmic)
390  clearCosmicRayPfos.push_back(pPfo);
391 
392  PandoraContentApi::ParticleFlowObject::Metadata metadata;
393  metadata.m_propertiesToAdd["IsClearCosmic"] = (isClearCosmic ? 1.f : 0.f);
394  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ParticleFlowObject::AlterMetadata(*this, pPfo, metadata));
395  }
396 
398  {
399  PANDORA_MONITORING_API(VisualizeParticleFlowObjects(this->GetPandora(), &clearCosmicRayPfos, "ClearCRPfos", RED));
400  PANDORA_MONITORING_API(VisualizeParticleFlowObjects(this->GetPandora(), &ambiguousPfos, "AmbiguousCRPfos", BLUE));
401  PANDORA_MONITORING_API(ViewEvent(this->GetPandora()));
402  }
403 
404  return STATUS_CODE_SUCCESS;
405 }
CosmicRayTaggingToolVector m_cosmicRayTaggingToolVector
The cosmic-ray tagging tool vector.
intermediate_table::const_iterator const_iterator
bool m_visualizeOverallRecoStatus
Whether to display results of current operations.
float m_inTimeMaxX0
Cut on X0 to determine whether particle is clear cosmic ray.

Member Data Documentation

CosmicRayTaggingToolVector lar_content::MasterAlgorithm::m_cosmicRayTaggingToolVector
private

The cosmic-ray tagging tool vector.

Definition at line 324 of file MasterAlgorithm.h.

Referenced by ReadSettings(), and TagCosmicRayPfos().

std::string lar_content::MasterAlgorithm::m_crSettingsFile
private

The cosmic-ray reconstruction settings file.

Definition at line 328 of file MasterAlgorithm.h.

Referenced by InitializeWorkerInstances(), and ReadSettings().

PandoraInstanceList lar_content::MasterAlgorithm::m_crWorkerInstances
private

The list of cosmic-ray reconstruction worker instances.

Definition at line 311 of file MasterAlgorithm.h.

Referenced by CopyMCParticles(), InitializeWorkerInstances(), RecreateCosmicRayPfos(), Reset(), and RunCosmicRayReconstruction().

std::string lar_content::MasterAlgorithm::m_filePathEnvironmentVariable
private

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

Definition at line 327 of file MasterAlgorithm.h.

Referenced by ReadSettings().

bool lar_content::MasterAlgorithm::m_fullWidthCRWorkerWireGaps
private

Whether wire-type line gaps in cosmic-ray worker instances should cover all drift time.

Definition at line 316 of file MasterAlgorithm.h.

Referenced by CreatePfo(), and ReadSettings().

std::string lar_content::MasterAlgorithm::m_inputHitListName
private

The input hit list name.

Definition at line 333 of file MasterAlgorithm.h.

Referenced by GetVolumeIdToHitListMap(), and ReadSettings().

std::string lar_content::MasterAlgorithm::m_inputMCParticleListName
private

The input mc particle list name.

Definition at line 332 of file MasterAlgorithm.h.

Referenced by CopyMCParticles(), and ReadSettings().

float lar_content::MasterAlgorithm::m_inTimeMaxX0
private

Cut on X0 to determine whether particle is clear cosmic ray.

Definition at line 338 of file MasterAlgorithm.h.

Referenced by ReadSettings(), and TagCosmicRayPfos().

std::string lar_content::MasterAlgorithm::m_nuSettingsFile
private

The neutrino reconstruction settings file.

Definition at line 329 of file MasterAlgorithm.h.

Referenced by InitializeWorkerInstances(), and ReadSettings().

bool lar_content::MasterAlgorithm::m_passMCParticlesToWorkerInstances
private

Whether to pass mc particle details (and links to calo hits) to worker instances.

Definition at line 317 of file MasterAlgorithm.h.

Referenced by ReadSettings(), Reset(), and Run().

bool lar_content::MasterAlgorithm::m_printOverallRecoStatus
private

Whether to print current operation status messages.

Definition at line 308 of file MasterAlgorithm.h.

Referenced by ReadSettings(), RunCosmicRayReconstruction(), RunSliceReconstruction(), RunSlicing(), and SelectBestSliceHypotheses().

const pandora::Pandora* lar_content::MasterAlgorithm::m_pSliceCRWorkerInstance
private

The per-slice cosmic-ray reconstruction worker instance.

Definition at line 314 of file MasterAlgorithm.h.

Referenced by CopyMCParticles(), InitializeWorkerInstances(), Reset(), and RunSliceReconstruction().

const pandora::Pandora* lar_content::MasterAlgorithm::m_pSliceNuWorkerInstance
private

The per-slice neutrino reconstruction worker instance.

Definition at line 313 of file MasterAlgorithm.h.

Referenced by CopyMCParticles(), InitializeWorkerInstances(), Reset(), and RunSliceReconstruction().

const pandora::Pandora* lar_content::MasterAlgorithm::m_pSlicingWorkerInstance
private

The slicing worker instance.

Definition at line 312 of file MasterAlgorithm.h.

Referenced by CopyMCParticles(), InitializeWorkerInstances(), Reset(), and RunSlicing().

std::string lar_content::MasterAlgorithm::m_recreatedClusterListName
private

The output recreated cluster list name.

Definition at line 335 of file MasterAlgorithm.h.

Referenced by ReadSettings(), Reset(), and StitchPfos().

std::string lar_content::MasterAlgorithm::m_recreatedPfoListName
private

The output recreated pfo list name.

Definition at line 334 of file MasterAlgorithm.h.

Referenced by ReadSettings(), Reset(), and StitchPfos().

std::string lar_content::MasterAlgorithm::m_recreatedVertexListName
private

The output recreated vertex list name.

Definition at line 336 of file MasterAlgorithm.h.

Referenced by ReadSettings(), Reset(), and StitchPfos().

bool lar_content::MasterAlgorithm::m_shouldPerformSliceId
private

Whether to identify slices and select most appropriate pfos.

Definition at line 307 of file MasterAlgorithm.h.

Referenced by ReadSettings(), and SelectBestSliceHypotheses().

bool lar_content::MasterAlgorithm::m_shouldRunAllHitsCosmicReco
private

Whether to run all hits cosmic-ray reconstruction.

Definition at line 301 of file MasterAlgorithm.h.

Referenced by ReadSettings(), and Run().

bool lar_content::MasterAlgorithm::m_shouldRunCosmicHitRemoval
private

Whether to remove hits from tagged cosmic-rays.

Definition at line 303 of file MasterAlgorithm.h.

Referenced by ReadSettings(), and Run().

bool lar_content::MasterAlgorithm::m_shouldRunCosmicRecoOption
private

Whether to run cosmic-ray reconstruction for each slice.

Definition at line 306 of file MasterAlgorithm.h.

Referenced by InitializeWorkerInstances(), ReadSettings(), Run(), RunSliceReconstruction(), and SelectBestSliceHypotheses().

bool lar_content::MasterAlgorithm::m_shouldRunNeutrinoRecoOption
private

Whether to run neutrino reconstruction for each slice.

Definition at line 305 of file MasterAlgorithm.h.

Referenced by InitializeWorkerInstances(), ReadSettings(), Run(), RunSliceReconstruction(), and SelectBestSliceHypotheses().

bool lar_content::MasterAlgorithm::m_shouldRunSlicing
private

Whether to slice events into separate regions for processing.

Definition at line 304 of file MasterAlgorithm.h.

Referenced by InitializeWorkerInstances(), ReadSettings(), RunSliceReconstruction(), and RunSlicing().

bool lar_content::MasterAlgorithm::m_shouldRunStitching
private

Whether to stitch cosmic-ray muons crossing between volumes.

Definition at line 302 of file MasterAlgorithm.h.

Referenced by ReadSettings(), and Run().

SliceIdToolVector lar_content::MasterAlgorithm::m_sliceIdToolVector
private

The slice id tool vector.

Definition at line 325 of file MasterAlgorithm.h.

Referenced by ReadSettings(), and SelectBestSliceHypotheses().

std::string lar_content::MasterAlgorithm::m_slicingSettingsFile
private

The slicing settings file.

Definition at line 330 of file MasterAlgorithm.h.

Referenced by InitializeWorkerInstances(), and ReadSettings().

StitchingToolVector lar_content::MasterAlgorithm::m_stitchingToolVector
private

The stitching tool vector.

Definition at line 323 of file MasterAlgorithm.h.

Referenced by ReadSettings(), and StitchCosmicRayPfos().

bool lar_content::MasterAlgorithm::m_visualizeOverallRecoStatus
private

Whether to display results of current operations.

Definition at line 309 of file MasterAlgorithm.h.

Referenced by ReadSettings(), RunSlicing(), ShiftPfoHierarchy(), StitchCosmicRayPfos(), and TagCosmicRayPfos().

bool lar_content::MasterAlgorithm::m_workerInstancesInitialized
private

Whether all worker instances have been initialized.

Definition at line 299 of file MasterAlgorithm.h.

Referenced by InitializeWorkerInstances(), and Run().


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