LArSoft  v07_13_02
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 791 of file MasterAlgorithm.cc.

Referenced by Reset().

792 {
793  PandoraContentApi::CaloHit::Parameters parameters;
794  parameters.m_positionVector = pInputCaloHit->GetPositionVector();
795  parameters.m_expectedDirection = pInputCaloHit->GetExpectedDirection();
796  parameters.m_cellNormalVector = pInputCaloHit->GetCellNormalVector();
797  parameters.m_cellGeometry = pInputCaloHit->GetCellGeometry();
798  parameters.m_cellSize0 = pInputCaloHit->GetCellSize0();
799  parameters.m_cellSize1 = pInputCaloHit->GetCellSize1();
800  parameters.m_cellThickness = pInputCaloHit->GetCellThickness();
801  parameters.m_nCellRadiationLengths = pInputCaloHit->GetNCellRadiationLengths();
802  parameters.m_nCellInteractionLengths = pInputCaloHit->GetNCellInteractionLengths();
803  parameters.m_time = pInputCaloHit->GetTime();
804  parameters.m_inputEnergy = pInputCaloHit->GetInputEnergy();
805  parameters.m_mipEquivalentEnergy = pInputCaloHit->GetMipEquivalentEnergy();
806  parameters.m_electromagneticEnergy = pInputCaloHit->GetElectromagneticEnergy();
807  parameters.m_hadronicEnergy = pInputCaloHit->GetHadronicEnergy();
808  parameters.m_isDigital = pInputCaloHit->IsDigital();
809  parameters.m_hitType = pInputCaloHit->GetHitType();
810  parameters.m_hitRegion = pInputCaloHit->GetHitRegion();
811  parameters.m_layer = pInputCaloHit->GetLayer();
812  parameters.m_isInOuterSamplingLayer = pInputCaloHit->IsInOuterSamplingLayer();
813  parameters.m_pParentAddress = static_cast<const void*>(pParentCaloHit);
814 
815  const CaloHit *pNewCaloHit(nullptr);
816  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::CaloHit::Create(*this, parameters, pNewCaloHit));
817 
818  PandoraContentApi::CaloHit::Metadata metadata;
819  metadata.m_isIsolated = pInputCaloHit->IsIsolated();
820  metadata.m_isPossibleMip = pInputCaloHit->IsPossibleMip();
821  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::CaloHit::AlterMetadata(*this, pNewCaloHit, metadata));
822 
823  return pNewCaloHit;
824 }
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 828 of file MasterAlgorithm.cc.

830 {
831  PandoraContentApi::Cluster::Parameters parameters;
832  parameters.m_caloHitList = newCaloHitList;
833  parameters.m_isolatedCaloHitList = newIsolatedCaloHitList;
834 
835  const Cluster *pNewCluster(nullptr);
836  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Cluster::Create(*this, parameters, pNewCluster));
837 
838  PandoraContentApi::Cluster::Metadata metadata;
839  metadata.m_particleId = pInputCluster->GetParticleId();
840  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Cluster::AlterMetadata(*this, pNewCluster, metadata));
841 
842  return pNewCluster;
843 }
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 862 of file MasterAlgorithm.cc.

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

Referenced by Reset().

864 {
865  PandoraContentApi::ParticleFlowObject::Parameters parameters;
866  parameters.m_particleId = pInputPfo->GetParticleId();
867  parameters.m_charge = pInputPfo->GetCharge();
868  parameters.m_mass = pInputPfo->GetMass();
869  parameters.m_energy = pInputPfo->GetEnergy();
870  parameters.m_momentum = pInputPfo->GetMomentum();
871  parameters.m_clusterList = newClusterList;
872  parameters.m_trackList.clear();
873  parameters.m_vertexList = newVertexList;
874  parameters.m_propertiesToAdd = pInputPfo->GetPropertiesMap();
875 
876  const ParticleFlowObject *pNewPfo(nullptr);
877  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ParticleFlowObject::Create(*this, parameters, pNewPfo));
878 
879  return pNewPfo;
880 }
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 847 of file MasterAlgorithm.cc.

848 {
849  PandoraContentApi::Vertex::Parameters parameters;
850  parameters.m_position = pInputVertex->GetPosition();
851  parameters.m_vertexLabel = pInputVertex->GetVertexLabel();
852  parameters.m_vertexType = pInputVertex->GetVertexType();
853 
854  const Vertex *pNewVertex(nullptr);
855  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Vertex::Create(*this, parameters, pNewVertex));
856 
857  return pNewVertex;
858 }
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 1152 of file MasterAlgorithm.cc.

Referenced by ReadSettings().

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

Definition at line 1026 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().

1027 {
1028  ExternalSteeringParameters *pExternalParameters(nullptr);
1029 
1030  if (this->ExternalParametersPresent())
1031  {
1032  pExternalParameters = dynamic_cast<ExternalSteeringParameters*>(this->GetExternalParameters());
1033  if (!pExternalParameters) return STATUS_CODE_FAILURE;
1034  }
1035 
1036  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->ReadExternalSettings(pExternalParameters, !pExternalParameters ? InputBool() :
1037  pExternalParameters->m_shouldRunAllHitsCosmicReco, xmlHandle, "ShouldRunAllHitsCosmicReco", m_shouldRunAllHitsCosmicReco));
1038 
1039  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->ReadExternalSettings(pExternalParameters, !pExternalParameters ? InputBool() :
1040  pExternalParameters->m_shouldRunStitching, xmlHandle, "ShouldRunStitching", m_shouldRunStitching));
1041 
1043  {
1044  std::cout << "MasterAlgorithm::ReadSettings - ShouldRunStitching requires ShouldRunAllHitsCosmicReco to be true" << std::endl;
1045  return STATUS_CODE_INVALID_PARAMETER;
1046  }
1047 
1049  {
1050  AlgorithmToolVector algorithmToolVector;
1051  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ProcessAlgorithmToolList(*this, xmlHandle, "StitchingTools", algorithmToolVector));
1052 
1053  for (AlgorithmTool *const pAlgorithmTool : algorithmToolVector)
1054  {
1055  StitchingBaseTool *const pStitchingTool(dynamic_cast<StitchingBaseTool*>(pAlgorithmTool));
1056  if (!pStitchingTool) return STATUS_CODE_INVALID_PARAMETER;
1057  m_stitchingToolVector.push_back(pStitchingTool);
1058  }
1059  }
1060 
1061  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->ReadExternalSettings(pExternalParameters, !pExternalParameters ? InputBool() :
1062  pExternalParameters->m_shouldRunCosmicHitRemoval, xmlHandle, "ShouldRunCosmicHitRemoval", m_shouldRunCosmicHitRemoval));
1063 
1065  {
1066  std::cout << "MasterAlgorithm::ReadSettings - ShouldRunCosmicHitRemoval requires ShouldRunAllHitsCosmicReco to be true" << std::endl;
1067  return STATUS_CODE_INVALID_PARAMETER;
1068  }
1069 
1071  {
1072  AlgorithmToolVector algorithmToolVector;
1073  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ProcessAlgorithmToolList(*this, xmlHandle, "CosmicRayTaggingTools", algorithmToolVector));
1074 
1075  for (AlgorithmTool *const pAlgorithmTool : algorithmToolVector)
1076  {
1077  CosmicRayTaggingBaseTool *const pCosmicRayTaggingTool(dynamic_cast<CosmicRayTaggingBaseTool*>(pAlgorithmTool));
1078  if (!pCosmicRayTaggingTool) return STATUS_CODE_INVALID_PARAMETER;
1079  m_cosmicRayTaggingToolVector.push_back(pCosmicRayTaggingTool);
1080  }
1081  }
1082 
1083  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->ReadExternalSettings(pExternalParameters, !pExternalParameters ? InputBool() :
1084  pExternalParameters->m_shouldRunSlicing, xmlHandle, "ShouldRunSlicing", m_shouldRunSlicing));
1085 
1086  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->ReadExternalSettings(pExternalParameters, !pExternalParameters ? InputBool() :
1087  pExternalParameters->m_shouldRunNeutrinoRecoOption, xmlHandle, "ShouldRunNeutrinoRecoOption", m_shouldRunNeutrinoRecoOption));
1088 
1089  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->ReadExternalSettings(pExternalParameters, !pExternalParameters ? InputBool() :
1090  pExternalParameters->m_shouldRunCosmicRecoOption, xmlHandle, "ShouldRunCosmicRecoOption", m_shouldRunCosmicRecoOption));
1091 
1092  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->ReadExternalSettings(pExternalParameters, !pExternalParameters ? InputBool() :
1093  pExternalParameters->m_shouldPerformSliceId, xmlHandle, "ShouldPerformSliceId", m_shouldPerformSliceId));
1094 
1096  {
1097  std::cout << "MasterAlgorithm::ReadSettings - ShouldPerformSliceId requires ShouldRunSlicing and both neutrino and cosmic reconstruction options" << std::endl;
1098  return STATUS_CODE_INVALID_PARAMETER;
1099  }
1100 
1102  {
1103  AlgorithmToolVector algorithmToolVector;
1104  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ProcessAlgorithmToolList(*this, xmlHandle, "SliceIdTools", algorithmToolVector));
1105 
1106  for (AlgorithmTool *const pAlgorithmTool : algorithmToolVector)
1107  {
1108  SliceIdBaseTool *const pSliceIdIdTool(dynamic_cast<SliceIdBaseTool*>(pAlgorithmTool));
1109  if (!pSliceIdIdTool) return STATUS_CODE_INVALID_PARAMETER;
1110  m_sliceIdToolVector.push_back(pSliceIdIdTool);
1111  }
1112  }
1113 
1114  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->ReadExternalSettings(pExternalParameters, !pExternalParameters ? InputBool() :
1115  pExternalParameters->m_printOverallRecoStatus, xmlHandle, "PrintOverallRecoStatus", m_printOverallRecoStatus));
1116 
1117  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
1118  "VisualizeOverallRecoStatus", m_visualizeOverallRecoStatus));
1119 
1120  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
1121  "FullWidthCRWorkerWireGaps", m_fullWidthCRWorkerWireGaps));
1122 
1123  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
1124  "PassMCParticlesToWorkerInstances", m_passMCParticlesToWorkerInstances));
1125 
1126  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
1127  "FilePathEnvironmentVariable", m_filePathEnvironmentVariable));
1128 
1129  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "CRSettingsFile", m_crSettingsFile));
1130  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "NuSettingsFile", m_nuSettingsFile));
1131  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "SlicingSettingsFile", m_slicingSettingsFile));
1135 
1137  {
1138  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "InputMCParticleListName", m_inputMCParticleListName));
1139  }
1140 
1141  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "InputHitListName", m_inputHitListName));
1142  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "RecreatedPfoListName", m_recreatedPfoListName));
1143  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "RecreatedClusterListName", m_recreatedClusterListName));
1144  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "RecreatedVertexListName", m_recreatedVertexListName));
1145  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "InTimeMaxX0", m_inTimeMaxX0));
1146 
1147  return STATUS_CODE_SUCCESS;
1148 }
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 582 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().

583 {
584  for (const Pandora *const pCRWorker : m_crWorkerInstances)
585  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::Reset(*pCRWorker));
586 
588  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::Reset(*m_pSlicingWorkerInstance));
589 
591  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::Reset(*m_pSliceNuWorkerInstance));
592 
594  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::Reset(*m_pSliceCRWorkerInstance));
595 
596  return STATUS_CODE_SUCCESS;
597 }
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 413 of file MasterAlgorithm.cc.

References lar_content::LArPfoHelper::GetAllConnectedPfos().

Referenced by Run().

414 {
415  PfoList allPfosToDelete;
416  LArPfoHelper::GetAllConnectedPfos(ambiguousPfos, allPfosToDelete);
417 
418  for (const Pfo *const pPfoToDelete : allPfosToDelete)
419  {
420  const ClusterList clusterList(pPfoToDelete->GetClusterList());
421  const VertexList vertexList(pPfoToDelete->GetVertexList());
422  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Delete(*this, pPfoToDelete));
423  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Delete(*this, &clusterList));
424  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Delete(*this, &vertexList));
425  }
426 
427  return STATUS_CODE_SUCCESS;
428 }
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 489 of file MasterAlgorithm.cc.

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

Referenced by Run().

490 {
491  unsigned int sliceCounter(0);
492 
493  for (const CaloHitList &sliceHits : sliceVector)
494  {
495  for (const CaloHit *const pSliceCaloHit : sliceHits)
496  {
497  // ATTN Must ensure we copy the hit actually owned by master instance; access differs with/without slicing enabled
498  const CaloHit *const pCaloHitInMaster(m_shouldRunSlicing ? static_cast<const CaloHit*>(pSliceCaloHit->GetParentAddress()) : pSliceCaloHit);
499 
501  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->Copy(m_pSliceNuWorkerInstance, pCaloHitInMaster));
502 
504  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->Copy(m_pSliceCRWorkerInstance, pCaloHitInMaster));
505  }
506 
508  {
510  std::cout << "Running nu worker instance for slice " << (sliceCounter + 1) << " of " << sliceVector.size() << std::endl;
511 
512  const PfoList *pSliceNuPfos(nullptr);
513  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::ProcessEvent(*m_pSliceNuWorkerInstance));
514  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::GetCurrentPfoList(*m_pSliceNuWorkerInstance, pSliceNuPfos));
515  nuSliceHypotheses.push_back(*pSliceNuPfos);
516 
517  for (const ParticleFlowObject *const pPfo : *pSliceNuPfos)
518  {
519  PandoraContentApi::ParticleFlowObject::Metadata metadata;
520  metadata.m_propertiesToAdd["SliceIndex"] = sliceCounter;
521  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ParticleFlowObject::AlterMetadata(*this, pPfo, metadata));
522  }
523  }
524 
526  {
528  std::cout << "Running cr worker instance for slice " << (sliceCounter + 1) << " of " << sliceVector.size() << std::endl;
529 
530  const PfoList *pSliceCRPfos(nullptr);
531  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::ProcessEvent(*m_pSliceCRWorkerInstance));
532  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::GetCurrentPfoList(*m_pSliceCRWorkerInstance, pSliceCRPfos));
533  crSliceHypotheses.push_back(*pSliceCRPfos);
534 
535  for (const ParticleFlowObject *const pPfo : *pSliceCRPfos)
536  {
537  PandoraContentApi::ParticleFlowObject::Metadata metadata;
538  metadata.m_propertiesToAdd["SliceIndex"] = sliceCounter;
539  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ParticleFlowObject::AlterMetadata(*this, pPfo, metadata));
540  }
541  }
542 
543  ++sliceCounter;
544  }
545 
546  if (m_shouldRunNeutrinoRecoOption && m_shouldRunCosmicRecoOption && (nuSliceHypotheses.size() != crSliceHypotheses.size()))
547  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
548 
549  return STATUS_CODE_SUCCESS;
550 }
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 432 of file MasterAlgorithm.cc.

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

Referenced by Run().

433 {
434  for (const VolumeIdToHitListMap::value_type &mapEntry : volumeIdToHitListMap)
435  {
436  for (const CaloHit *const pCaloHit : mapEntry.second.m_truncatedHitList)
437  {
438  if (!PandoraContentApi::IsAvailable(*this, pCaloHit))
439  continue;
440 
441  const HitType hitType(pCaloHit->GetHitType());
442  if ((TPC_VIEW_U != hitType) && (TPC_VIEW_V != hitType) && (TPC_VIEW_W != hitType))
443  continue;
444 
445  if (m_shouldRunSlicing)
446  {
447  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->Copy(m_pSlicingWorkerInstance, pCaloHit));
448  }
449  else
450  {
451  if (sliceVector.empty()) sliceVector.push_back(CaloHitList());
452  sliceVector.back().push_back(pCaloHit);
453  }
454  }
455  }
456 
457  if (m_shouldRunSlicing)
458  {
460  std::cout << "Running slicing worker instance" << std::endl;
461 
462  const PfoList *pSlicePfos(nullptr);
463  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::ProcessEvent(*m_pSlicingWorkerInstance));
464  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::GetCurrentPfoList(*m_pSlicingWorkerInstance, pSlicePfos));
465 
467  {
468  PANDORA_MONITORING_API(VisualizeParticleFlowObjects(this->GetPandora(), pSlicePfos, "OnePfoPerSlice", BLUE));
469  PANDORA_MONITORING_API(ViewEvent(this->GetPandora()));
470  }
471 
472  for (const Pfo *const pSlicePfo : *pSlicePfos)
473  {
474  sliceVector.push_back(CaloHitList());
475  LArPfoHelper::GetCaloHits(pSlicePfo, TPC_VIEW_U, sliceVector.back());
476  LArPfoHelper::GetCaloHits(pSlicePfo, TPC_VIEW_V, sliceVector.back());
477  LArPfoHelper::GetCaloHits(pSlicePfo, TPC_VIEW_W, sliceVector.back());
478  }
479  }
480 
482  std::cout << "Identified " << sliceVector.size() << " slice(s)" << std::endl;
483 
484  return STATUS_CODE_SUCCESS;
485 }
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 554 of file MasterAlgorithm.cc.

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

Referenced by Run().

555 {
557  std::cout << "Select best slice hypotheses" << std::endl;
558 
559  PfoList selectedSlicePfos;
560 
562  {
563  for (SliceIdBaseTool *const pSliceIdTool : m_sliceIdToolVector)
564  pSliceIdTool->SelectOutputPfos(this, nuSliceHypotheses, crSliceHypotheses, selectedSlicePfos);
565  }
567  {
568  const SliceHypotheses &sliceHypotheses(m_shouldRunNeutrinoRecoOption ? nuSliceHypotheses : crSliceHypotheses);
569 
570  for (const PfoList &slice : sliceHypotheses)
571  selectedSlicePfos.insert(selectedSlicePfos.end(), slice.begin(), slice.end());
572  }
573 
574  PfoList newSlicePfoList;
575  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->Recreate(selectedSlicePfos, newSlicePfoList));
576 
577  return STATUS_CODE_SUCCESS;
578 }
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 
393  for (const Pfo *const pPfo : *pRecreatedCRPfos)
394  {
395  const bool isClearCosmic(ambiguousPfos.end() == std::find(ambiguousPfos.begin(), ambiguousPfos.end(), pPfo));
396  PandoraContentApi::ParticleFlowObject::Metadata metadata;
397  metadata.m_propertiesToAdd["IsClearCosmic"] = (isClearCosmic ? 1.f : 0.f);
398  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ParticleFlowObject::AlterMetadata(*this, pPfo, metadata));
399  }
400 
402  {
403  PANDORA_MONITORING_API(VisualizeParticleFlowObjects(this->GetPandora(), &clearCosmicRayPfos, "ClearCRPfos", RED));
404  PANDORA_MONITORING_API(VisualizeParticleFlowObjects(this->GetPandora(), &ambiguousPfos, "AmbiguousCRPfos", BLUE));
405  PANDORA_MONITORING_API(ViewEvent(this->GetPandora()));
406  }
407 
408  return STATUS_CODE_SUCCESS;
409 }
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: