9 #include "Api/PandoraApi.h" 11 #include "Pandora/AlgorithmHeaders.h" 35 MasterAlgorithm::MasterAlgorithm() :
36 m_workerInstancesInitialized(false),
37 m_shouldRunAllHitsCosmicReco(true),
38 m_shouldRunStitching(true),
39 m_shouldRunCosmicHitRemoval(true),
40 m_shouldRunSlicing(true),
41 m_shouldRunNeutrinoRecoOption(true),
42 m_shouldRunCosmicRecoOption(true),
43 m_shouldPerformSliceId(true),
44 m_printOverallRecoStatus(false),
45 m_visualizeOverallRecoStatus(false),
46 m_pSlicingWorkerInstance(nullptr),
47 m_pSliceNuWorkerInstance(nullptr),
48 m_pSliceCRWorkerInstance(nullptr),
49 m_fullWidthCRWorkerWireGaps(true),
50 m_passMCParticlesToWorkerInstances(false),
51 m_filePathEnvironmentVariable(
"FW_SEARCH_PATH"),
60 if (!pParentPfo->GetParentPfoList().empty())
61 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
65 if (pfoToLArTPCMap.end() == larTPCIter)
66 throw StatusCodeException(STATUS_CODE_NOT_FOUND);
70 const float signedX0(larTPCIter->second->IsDriftInPositiveX() ? -x0 : x0);
74 std::cout <<
"ShiftPfoHierarchy: signedX0 " << signedX0 << std::endl;
75 PANDORA_MONITORING_API(VisualizeParticleFlowObjects(this->GetPandora(), &pfoList,
"BeforeShiftCRPfos", GREEN));
78 for (
const ParticleFlowObject *
const pDaughterPfo : pfoList)
80 CaloHitList caloHitList;
81 for (
const Cluster *
const pCluster : pDaughterPfo->GetClusterList())
83 pCluster->GetOrderedCaloHitList().FillCaloHitList(caloHitList);
84 caloHitList.insert(caloHitList.end(), pCluster->GetIsolatedCaloHitList().begin(), pCluster->GetIsolatedCaloHitList().end());
87 for (
const CaloHit *
const pCaloHit : caloHitList)
89 PandoraContentApi::CaloHit::Metadata metadata;
90 metadata.m_x0 = signedX0;
91 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::CaloHit::AlterMetadata(*
this, pCaloHit, metadata));
94 for (
const Vertex *
const pVertex : pDaughterPfo->GetVertexList())
96 PandoraContentApi::Vertex::Metadata metadata;
97 metadata.m_x0 = signedX0;
98 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Vertex::AlterMetadata(*
this, pVertex, metadata));
104 PANDORA_MONITORING_API(VisualizeParticleFlowObjects(this->GetPandora(), &pfoList,
"AfterShiftCRPfos", RED));
105 PANDORA_MONITORING_API(ViewEvent(this->GetPandora()));
114 if (pPfoToEnlarge == pPfoToDelete)
115 throw StatusCodeException(STATUS_CODE_NOT_ALLOWED);
118 pfoToLArTPCMap.erase(pPfoToEnlarge);
119 pfoToLArTPCMap.erase(pPfoToDelete);
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());
125 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Delete(*
this, pPfoToDelete,
m_recreatedPfoListName));
127 for (
const ParticleFlowObject *
const pDaughterPfo : daughterPfos)
128 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SetPfoParentDaughterRelationship(*
this, pPfoToEnlarge, pDaughterPfo));
130 for (
const Vertex *
const pDaughterVertex : daughterVertices)
131 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Delete(*
this, pDaughterVertex,
m_recreatedVertexListName));
133 for (
const Cluster *
const pDaughterCluster : daughterClusters)
140 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::MergeAndDeleteClusters(*
this, pParentCluster, pDaughterCluster,
145 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::AddToPfo(*
this, pPfoToEnlarge, pDaughterCluster));
154 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->
Reset());
160 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->
CopyMCParticles());
174 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->
StitchCosmicRayPfos(pfoToLArTPCMap, stitchedPfosToX0Map));
179 PfoList clearCosmicRayPfos, ambiguousPfos;
180 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->
TagCosmicRayPfos(stitchedPfosToX0Map, clearCosmicRayPfos, ambiguousPfos));
185 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->
RunSlicing(volumeIdToHitListMap, sliceVector));
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));
194 return STATUS_CODE_SUCCESS;
203 return STATUS_CODE_ALREADY_INITIALIZED;
207 const LArTPCMap &larTPCMap(this->GetPandora().GetGeometry()->GetLArTPCMap());
208 const DetectorGapList &gapList(this->GetPandora().GetGeometry()->GetDetectorGapList());
210 for (
const LArTPCMap::value_type &mapEntry : larTPCMap)
212 const unsigned int volumeId(mapEntry.second->GetLArTPCVolumeId());
225 catch (
const StatusCodeException &statusCodeException)
227 std::cout <<
"MasterAlgorithm: Exception during initialization of worker instances " << statusCodeException.ToString() << std::endl;
228 return statusCodeException.GetStatusCode();
232 return STATUS_CODE_SUCCESS;
239 const MCParticleList *pMCParticleList(
nullptr);
240 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetList(*
this,
m_inputMCParticleListName, pMCParticleList));
249 for (
const Pandora *
const pPandoraWorker : pandoraWorkerInstances)
251 for (
const MCParticle *
const pMCParticle : *pMCParticleList)
252 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->
Copy(pPandoraWorker, pMCParticle, &mcParticleFactory));
255 return STATUS_CODE_SUCCESS;
262 const LArTPCMap &larTPCMap(this->GetPandora().GetGeometry()->GetLArTPCMap());
263 const unsigned int nLArTPCs(larTPCMap.size());
265 const CaloHitList *pCaloHitList(
nullptr);
266 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetList(*
this,
m_inputHitListName, pCaloHitList));
268 for (
const CaloHit *
const pCaloHit : *pCaloHitList)
270 const LArCaloHit *
const pLArCaloHit(dynamic_cast<const LArCaloHit*>(pCaloHit));
272 if (!pLArCaloHit && (1 != nLArTPCs))
273 return STATUS_CODE_INVALID_PARAMETER;
276 const LArTPC *
const pLArTPC(larTPCMap.at(volumeId));
278 LArTPCHitList &larTPCHitList(volumeIdToHitListMap[volumeId]);
279 larTPCHitList.m_allHitList.push_back(pCaloHit);
281 if (((pCaloHit->GetPositionVector().GetX() >= (pLArTPC->GetCenterX() - 0.5f * pLArTPC->GetWidthX())) &&
282 (pCaloHit->GetPositionVector().GetX() <= (pLArTPC->GetCenterX() + 0.5f * pLArTPC->GetWidthX()))))
284 larTPCHitList.m_truncatedHitList.push_back(pCaloHit);
288 return STATUS_CODE_SUCCESS;
295 unsigned int workerCounter(0);
299 const LArTPC &larTPC(pCRWorker->GetGeometry()->GetLArTPC());
302 if (volumeIdToHitListMap.end() == iter)
305 for (
const CaloHit *
const pCaloHit : iter->second.m_allHitList)
306 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->
Copy(pCRWorker, pCaloHit));
309 std::cout <<
"Running cosmic-ray reconstruction worker instance " << ++workerCounter <<
" of " << m_crWorkerInstances.size() << std::endl;
314 return STATUS_CODE_SUCCESS;
323 const PfoList *pCRPfos(
nullptr);
324 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::GetCurrentPfoList(*pCRWorker, pCRPfos));
327 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->
Recreate(*pCRPfos, newPfoList));
329 const LArTPC &larTPC(pCRWorker->GetGeometry()->GetLArTPC());
331 for (
const Pfo *
const pNewPfo : newPfoList)
332 pfoToLArTPCMap[pNewPfo] = &larTPC;
335 return STATUS_CODE_SUCCESS;
342 const PfoList *pRecreatedCRPfos(
nullptr);
343 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::GetCurrentPfoList(this->GetPandora(), pRecreatedCRPfos));
347 PANDORA_MONITORING_API(VisualizeParticleFlowObjects(this->GetPandora(), pRecreatedCRPfos,
"RecreatedCRPfos", GREEN));
348 PANDORA_MONITORING_API(ViewEvent(this->GetPandora()));
352 pStitchingTool->Run(
this, pRecreatedCRPfos, pfoToLArTPCMap, stitchedPfosToX0Map);
356 PANDORA_MONITORING_API(VisualizeParticleFlowObjects(this->GetPandora(), pRecreatedCRPfos,
"AfterStitchingCRPfos", RED));
357 PANDORA_MONITORING_API(ViewEvent(this->GetPandora()));
360 return STATUS_CODE_SUCCESS;
367 const PfoList *pRecreatedCRPfos(
nullptr);
368 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::GetCurrentPfoList(this->GetPandora(), pRecreatedCRPfos));
370 PfoList nonStitchedParentCosmicRayPfos;
371 for (
const Pfo *
const pPfo : *pRecreatedCRPfos)
373 if (!pPfo->GetParentPfoList().empty())
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);
383 pCosmicRayTaggingTool->FindAmbiguousPfos(nonStitchedParentCosmicRayPfos, ambiguousPfos,
this);
385 for (
const Pfo *
const pPfo : nonStitchedParentCosmicRayPfos)
387 const bool isClearCosmic(ambiguousPfos.end() == std::find(ambiguousPfos.begin(), ambiguousPfos.end(), pPfo));
390 clearCosmicRayPfos.push_back(pPfo);
393 for (
const Pfo *
const pPfo : *pRecreatedCRPfos)
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));
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()));
408 return STATUS_CODE_SUCCESS;
415 PfoList allPfosToDelete;
418 for (
const Pfo *
const pPfoToDelete : allPfosToDelete)
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));
427 return STATUS_CODE_SUCCESS;
434 for (
const VolumeIdToHitListMap::value_type &mapEntry : volumeIdToHitListMap)
436 for (
const CaloHit *
const pCaloHit : mapEntry.second.m_truncatedHitList)
438 if (!PandoraContentApi::IsAvailable(*
this, pCaloHit))
441 const HitType hitType(pCaloHit->GetHitType());
442 if ((TPC_VIEW_U != hitType) && (TPC_VIEW_V != hitType) && (TPC_VIEW_W != hitType))
451 if (sliceVector.empty()) sliceVector.push_back(CaloHitList());
452 sliceVector.back().push_back(pCaloHit);
460 std::cout <<
"Running slicing worker instance" << std::endl;
462 const PfoList *pSlicePfos(
nullptr);
464 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::GetCurrentPfoList(*
m_pSlicingWorkerInstance, pSlicePfos));
468 PANDORA_MONITORING_API(VisualizeParticleFlowObjects(this->GetPandora(), pSlicePfos,
"OnePfoPerSlice", BLUE));
469 PANDORA_MONITORING_API(ViewEvent(this->GetPandora()));
472 for (
const Pfo *
const pSlicePfo : *pSlicePfos)
474 sliceVector.push_back(CaloHitList());
482 std::cout <<
"Identified " << sliceVector.size() <<
" slice(s)" << std::endl;
484 return STATUS_CODE_SUCCESS;
491 unsigned int sliceCounter(0);
493 for (
const CaloHitList &sliceHits : sliceVector)
495 for (
const CaloHit *
const pSliceCaloHit : sliceHits)
498 const CaloHit *
const pCaloHitInMaster(
m_shouldRunSlicing ? static_cast<const CaloHit*>(pSliceCaloHit->GetParentAddress()) : pSliceCaloHit);
510 std::cout <<
"Running nu worker instance for slice " << (sliceCounter + 1) <<
" of " << sliceVector.size() << std::endl;
512 const PfoList *pSliceNuPfos(
nullptr);
514 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::GetCurrentPfoList(*
m_pSliceNuWorkerInstance, pSliceNuPfos));
515 nuSliceHypotheses.push_back(*pSliceNuPfos);
517 for (
const ParticleFlowObject *
const pPfo : *pSliceNuPfos)
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));
528 std::cout <<
"Running cr worker instance for slice " << (sliceCounter + 1) <<
" of " << sliceVector.size() << std::endl;
530 const PfoList *pSliceCRPfos(
nullptr);
532 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::GetCurrentPfoList(*
m_pSliceCRWorkerInstance, pSliceCRPfos));
533 crSliceHypotheses.push_back(*pSliceCRPfos);
535 for (
const ParticleFlowObject *
const pPfo : *pSliceCRPfos)
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));
547 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
549 return STATUS_CODE_SUCCESS;
557 std::cout <<
"Select best slice hypotheses" << std::endl;
559 PfoList selectedSlicePfos;
564 pSliceIdTool->SelectOutputPfos(
this, nuSliceHypotheses, crSliceHypotheses, selectedSlicePfos);
570 for (
const PfoList &slice : sliceHypotheses)
571 selectedSlicePfos.insert(selectedSlicePfos.end(), slice.begin(), slice.end());
574 PfoList newSlicePfoList;
575 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->
Recreate(selectedSlicePfos, newSlicePfoList));
577 return STATUS_CODE_SUCCESS;
585 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=,
PandoraApi::Reset(*pCRWorker));
596 return STATUS_CODE_SUCCESS;
605 PandoraApi::CaloHit::Parameters parameters;
606 parameters.m_positionVector = pCaloHit->GetPositionVector();
607 parameters.m_expectedDirection = pCaloHit->GetExpectedDirection();
608 parameters.m_cellNormalVector = pCaloHit->GetCellNormalVector();
609 parameters.m_cellGeometry = pCaloHit->GetCellGeometry();
610 parameters.m_cellSize0 = pCaloHit->GetCellSize0();
611 parameters.m_cellSize1 = pCaloHit->GetCellSize1();
612 parameters.m_cellThickness = pCaloHit->GetCellThickness();
613 parameters.m_nCellRadiationLengths = pCaloHit->GetNCellRadiationLengths();
614 parameters.m_nCellInteractionLengths = pCaloHit->GetNCellInteractionLengths();
615 parameters.m_time = pCaloHit->GetTime();
616 parameters.m_inputEnergy = pCaloHit->GetInputEnergy();
617 parameters.m_mipEquivalentEnergy = pCaloHit->GetMipEquivalentEnergy();
618 parameters.m_electromagneticEnergy = pCaloHit->GetElectromagneticEnergy();
619 parameters.m_hadronicEnergy = pCaloHit->GetHadronicEnergy();
620 parameters.m_isDigital = pCaloHit->IsDigital();
621 parameters.m_hitType = pCaloHit->GetHitType();
622 parameters.m_hitRegion = pCaloHit->GetHitRegion();
623 parameters.m_layer = pCaloHit->GetLayer();
624 parameters.m_isInOuterSamplingLayer = pCaloHit->IsInOuterSamplingLayer();
626 parameters.m_pParentAddress =
static_cast<const void*
>(pCaloHit);
627 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::CaloHit::Create(*pPandora, parameters));
632 for (
const auto &weightMapEntry : pCaloHit->GetMCParticleWeightMap()) mcParticleVector.push_back(weightMapEntry.first);
635 for (
const MCParticle *
const pMCParticle : mcParticleVector)
637 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::SetCaloHitToMCParticleRelationship(*pPandora, pCaloHit,
638 pMCParticle, pCaloHit->GetMCParticleWeightMap().at(pMCParticle)));
642 return STATUS_CODE_SUCCESS;
654 std::cout <<
"MasterAlgorithm::Copy - Expect to pass only LArMCParticles to Pandora worker instances." << std::endl;
655 return STATUS_CODE_INVALID_PARAMETER;
659 parameters.m_energy = pMCParticle->GetEnergy();
660 parameters.m_momentum = pMCParticle->GetMomentum();
661 parameters.m_vertex = pMCParticle->GetVertex();
662 parameters.m_endpoint = pMCParticle->GetEndpoint();
663 parameters.m_particleId = pMCParticle->GetParticleId();
664 parameters.m_mcParticleType = pMCParticle->GetMCParticleType();
666 parameters.m_pParentAddress =
static_cast<const void*
>(pMCParticle);
667 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::MCParticle::Create(*pPandora, parameters, *pMCParticleFactory));
669 for (
const MCParticle *
const pDaughterMCParticle : pMCParticle->GetDaughterList())
670 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::SetMCParentDaughterRelationship(*pPandora, pMCParticle, pDaughterMCParticle));
672 for (
const MCParticle *
const pParentMCParticle : pMCParticle->GetParentList())
673 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::SetMCParentDaughterRelationship(*pPandora, pParentMCParticle, pMCParticle));
675 return STATUS_CODE_SUCCESS;
682 if (inputPfoList.empty())
683 return STATUS_CODE_SUCCESS;
687 std::string clusterListName;
688 const ClusterList *pClusterList(
nullptr);
689 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::CreateTemporaryListAndSetCurrent(*
this, pClusterList, clusterListName));
691 std::string vertexListName;
693 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::CreateTemporaryListAndSetCurrent(*
this, pVertexList, vertexListName));
695 std::string pfoListName;
696 const PfoList *pPfoList(
nullptr);
697 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::CreateTemporaryListAndSetCurrent(*
this, pPfoList, pfoListName));
699 for (
const Pfo *
const pPfo : inputPfoList)
701 if (pPfo->GetParentPfoList().empty())
702 this->
Recreate(pPfo,
nullptr, newPfoList);
705 if (!pClusterList->empty())
708 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ReplaceCurrentList<Cluster>(*
this,
m_recreatedClusterListName));
711 if (!pVertexList->empty())
713 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList<Vertex>(*
this,
m_recreatedVertexListName));
714 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ReplaceCurrentList<Vertex>(*
this,
m_recreatedVertexListName));
717 if (!pPfoList->empty())
719 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList<ParticleFlowObject>(*
this,
m_recreatedPfoListName));
720 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ReplaceCurrentList<ParticleFlowObject>(*
this,
m_recreatedPfoListName));
723 return STATUS_CODE_SUCCESS;
728 StatusCode
MasterAlgorithm::Recreate(
const ParticleFlowObject *
const pInputPfo,
const ParticleFlowObject *
const pNewParentPfo, PfoList &newPfoList)
const 730 ClusterList inputClusterList2D, inputClusterList3D, newClusterList;
734 for (
const Cluster *
const pInputCluster : inputClusterList2D)
736 CaloHitList inputCaloHitList, newCaloHitList, newIsolatedCaloHitList;
737 pInputCluster->GetOrderedCaloHitList().FillCaloHitList(inputCaloHitList);
739 for (
const CaloHit *
const pInputCaloHit : inputCaloHitList)
740 newCaloHitList.push_back(static_cast<const CaloHit*>(pInputCaloHit->GetParentAddress()));
742 for (
const CaloHit *
const pInputCaloHit : pInputCluster->GetIsolatedCaloHitList())
743 newIsolatedCaloHitList.push_back(static_cast<const CaloHit*>(pInputCaloHit->GetParentAddress()));
745 if (!newCaloHitList.empty())
746 newClusterList.push_back(this->CreateCluster(pInputCluster, newCaloHitList, newIsolatedCaloHitList));
749 for (
const Cluster *
const pInputCluster : inputClusterList3D)
751 CaloHitList inputCaloHitList, newCaloHitList, newIsolatedCaloHitList;
752 pInputCluster->GetOrderedCaloHitList().FillCaloHitList(inputCaloHitList);
754 for (
const CaloHit *
const pInputCaloHit : inputCaloHitList)
756 const CaloHit *
const pWorkerParentCaloHit(static_cast<const CaloHit*>(pInputCaloHit->GetParentAddress()));
757 const CaloHit *
const pMasterParentCaloHit(static_cast<const CaloHit*>(pWorkerParentCaloHit->GetParentAddress()));
758 newCaloHitList.push_back(this->
CreateCaloHit(pInputCaloHit, pMasterParentCaloHit));
761 for (
const CaloHit *
const pInputCaloHit : pInputCluster->GetIsolatedCaloHitList())
763 const CaloHit *
const pWorkerParentCaloHit(static_cast<const CaloHit*>(pInputCaloHit->GetParentAddress()));
764 const CaloHit *
const pMasterParentCaloHit(static_cast<const CaloHit*>(pWorkerParentCaloHit->GetParentAddress()));
765 newIsolatedCaloHitList.push_back(this->
CreateCaloHit(pInputCaloHit, pMasterParentCaloHit));
768 if (!newCaloHitList.empty())
769 newClusterList.push_back(this->CreateCluster(pInputCluster, newCaloHitList, newIsolatedCaloHitList));
774 for (
const Vertex *
const pInputVertex : pInputPfo->GetVertexList())
775 newVertexList.push_back(this->CreateVertex(pInputVertex));
777 const ParticleFlowObject *
const pNewPfo(this->
CreatePfo(pInputPfo, newClusterList, newVertexList));
778 newPfoList.push_back(pNewPfo);
781 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SetPfoParentDaughterRelationship(*
this, pNewParentPfo, pNewPfo))
783 for (
const ParticleFlowObject *
const pInputDaughterPfo : pInputPfo->GetDaughterPfoList())
784 this->
Recreate(pInputDaughterPfo, pNewPfo, newPfoList);
786 return STATUS_CODE_SUCCESS;
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);
815 const CaloHit *pNewCaloHit(
nullptr);
816 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::CaloHit::Create(*
this, parameters, pNewCaloHit));
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));
829 const CaloHitList &newIsolatedCaloHitList)
const 831 PandoraContentApi::Cluster::Parameters parameters;
832 parameters.m_caloHitList = newCaloHitList;
833 parameters.m_isolatedCaloHitList = newIsolatedCaloHitList;
835 const Cluster *pNewCluster(
nullptr);
836 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Cluster::Create(*
this, parameters, pNewCluster));
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));
849 PandoraContentApi::Vertex::Parameters parameters;
850 parameters.m_position = pInputVertex->GetPosition();
851 parameters.m_vertexLabel = pInputVertex->GetVertexLabel();
852 parameters.m_vertexType = pInputVertex->GetVertexType();
854 const Vertex *pNewVertex(
nullptr);
855 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Vertex::Create(*
this, parameters, pNewVertex));
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();
876 const ParticleFlowObject *pNewPfo(
nullptr);
877 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ParticleFlowObject::Create(*
this, parameters, pNewPfo));
887 const Pandora *
const pPandora(
new Pandora(name));
895 PandoraApi::Geometry::LArTPC::Parameters larTPCParameters;
896 larTPCParameters.m_larTPCVolumeId = larTPC.GetLArTPCVolumeId();
897 larTPCParameters.m_centerX = larTPC.GetCenterX();
898 larTPCParameters.m_centerY = larTPC.GetCenterY();
899 larTPCParameters.m_centerZ = larTPC.GetCenterZ();
900 larTPCParameters.m_widthX = larTPC.GetWidthX();
901 larTPCParameters.m_widthY = larTPC.GetWidthY();
902 larTPCParameters.m_widthZ = larTPC.GetWidthZ();
903 larTPCParameters.m_wirePitchU = larTPC.GetWirePitchU();
904 larTPCParameters.m_wirePitchV = larTPC.GetWirePitchV();
905 larTPCParameters.m_wirePitchW = larTPC.GetWirePitchW();
906 larTPCParameters.m_wireAngleU = larTPC.GetWireAngleU();
907 larTPCParameters.m_wireAngleV = larTPC.GetWireAngleV();
908 larTPCParameters.m_wireAngleW = larTPC.GetWireAngleW();
909 larTPCParameters.m_sigmaUVW = larTPC.GetSigmaUVW();
910 larTPCParameters.m_isDriftInPositiveX = larTPC.IsDriftInPositiveX();
911 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::Geometry::LArTPC::Create(*pPandora, larTPCParameters));
913 const float tpcMinX(larTPC.GetCenterX() - 0.5f * larTPC.GetWidthX()), tpcMaxX(larTPC.GetCenterX() + 0.5f * larTPC.GetWidthX());
916 for (
const DetectorGap *
const pGap : gapList)
918 const LineGap *
const pLineGap(dynamic_cast<const LineGap*>(pGap));
920 if (pLineGap && (((pLineGap->GetLineEndX() >= tpcMinX) && (pLineGap->GetLineEndX() <= tpcMaxX)) ||
921 ((pLineGap->GetLineStartX() >= tpcMinX) && (pLineGap->GetLineStartX() <= tpcMaxX))) )
923 PandoraApi::Geometry::LineGap::Parameters lineGapParameters;
924 const LineGapType lineGapType(pLineGap->GetLineGapType());
925 lineGapParameters.m_lineGapType = lineGapType;
926 lineGapParameters.m_lineStartX = pLineGap->GetLineStartX();
927 lineGapParameters.m_lineEndX = pLineGap->GetLineEndX();
929 if (
m_fullWidthCRWorkerWireGaps && ((lineGapType == TPC_WIRE_GAP_VIEW_U) || (lineGapType == TPC_WIRE_GAP_VIEW_V) || (lineGapType == TPC_WIRE_GAP_VIEW_W)))
935 lineGapParameters.m_lineStartZ = pLineGap->GetLineStartZ();
936 lineGapParameters.m_lineEndZ = pLineGap->GetLineEndZ();
937 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::Geometry::LineGap::Create(*pPandora, lineGapParameters));
942 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::ReadSettings(*pPandora, settingsFile));
950 if (larTPCMap.empty())
952 std::cout <<
"MasterAlgorithm::CreateWorkerInstance - no LArTPC details provided" << std::endl;
953 throw StatusCodeException(STATUS_CODE_NOT_INITIALIZED);
957 const Pandora *
const pPandora(
new Pandora(name));
965 const LArTPC *
const pFirstLArTPC(larTPCMap.begin()->second);
966 float parentMinX(pFirstLArTPC->GetCenterX() - 0.5f * pFirstLArTPC->GetWidthX());
967 float parentMaxX(pFirstLArTPC->GetCenterX() + 0.5f * pFirstLArTPC->GetWidthX());
968 float parentMinY(pFirstLArTPC->GetCenterY() - 0.5f * pFirstLArTPC->GetWidthY());
969 float parentMaxY(pFirstLArTPC->GetCenterY() + 0.5f * pFirstLArTPC->GetWidthY());
970 float parentMinZ(pFirstLArTPC->GetCenterZ() - 0.5f * pFirstLArTPC->GetWidthZ());
971 float parentMaxZ(pFirstLArTPC->GetCenterZ() + 0.5f * pFirstLArTPC->GetWidthZ());
973 for (
const LArTPCMap::value_type &mapEntry : larTPCMap)
975 const LArTPC *
const pLArTPC(mapEntry.second);
976 parentMinX =
std::min(parentMinX, pLArTPC->GetCenterX() - 0.5f * pLArTPC->GetWidthX());
977 parentMaxX =
std::max(parentMaxX, pLArTPC->GetCenterX() + 0.5f * pLArTPC->GetWidthX());
978 parentMinY =
std::min(parentMinY, pLArTPC->GetCenterY() - 0.5f * pLArTPC->GetWidthY());
979 parentMaxY =
std::max(parentMaxY, pLArTPC->GetCenterY() + 0.5f * pLArTPC->GetWidthY());
980 parentMinZ =
std::min(parentMinZ, pLArTPC->GetCenterZ() - 0.5f * pLArTPC->GetWidthZ());
981 parentMaxZ =
std::max(parentMaxZ, pLArTPC->GetCenterZ() + 0.5f * pLArTPC->GetWidthZ());
984 PandoraApi::Geometry::LArTPC::Parameters larTPCParameters;
985 larTPCParameters.m_larTPCVolumeId = 0;
986 larTPCParameters.m_centerX = 0.5f * (parentMaxX + parentMinX);
987 larTPCParameters.m_centerY = 0.5f * (parentMaxY + parentMinY);
988 larTPCParameters.m_centerZ = 0.5f * (parentMaxZ + parentMinZ);
989 larTPCParameters.m_widthX = parentMaxX - parentMinX;
990 larTPCParameters.m_widthY = parentMaxY - parentMinY;
991 larTPCParameters.m_widthZ = parentMaxZ - parentMinZ;
992 larTPCParameters.m_wirePitchU =
std::max(pFirstLArTPC->GetWirePitchU(), pFirstLArTPC->GetWirePitchV());
993 larTPCParameters.m_wirePitchV =
std::max(pFirstLArTPC->GetWirePitchU(), pFirstLArTPC->GetWirePitchV());
994 larTPCParameters.m_wirePitchW = pFirstLArTPC->GetWirePitchW();
995 larTPCParameters.m_wireAngleU = pFirstLArTPC->GetWireAngleU();
996 larTPCParameters.m_wireAngleV = pFirstLArTPC->GetWireAngleV();
997 larTPCParameters.m_wireAngleW = pFirstLArTPC->GetWireAngleW();
998 larTPCParameters.m_sigmaUVW = pFirstLArTPC->GetSigmaUVW();
999 larTPCParameters.m_isDriftInPositiveX = pFirstLArTPC->IsDriftInPositiveX();
1000 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::Geometry::LArTPC::Create(*pPandora, larTPCParameters));
1003 for (
const DetectorGap *
const pGap : gapList)
1005 const LineGap *
const pLineGap(dynamic_cast<const LineGap*>(pGap));
1009 PandoraApi::Geometry::LineGap::Parameters lineGapParameters;
1010 lineGapParameters.m_lineGapType = pLineGap->GetLineGapType();
1011 lineGapParameters.m_lineStartX = pLineGap->GetLineStartX();
1012 lineGapParameters.m_lineEndX = pLineGap->GetLineEndX();
1013 lineGapParameters.m_lineStartZ = pLineGap->GetLineStartZ();
1014 lineGapParameters.m_lineEndZ = pLineGap->GetLineEndZ();
1015 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::Geometry::LineGap::Create(*pPandora, lineGapParameters));
1020 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraApi::ReadSettings(*pPandora, settingsFile));
1030 if (this->ExternalParametersPresent())
1033 if (!pExternalParameters)
return STATUS_CODE_FAILURE;
1036 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->
ReadExternalSettings(pExternalParameters, !pExternalParameters ? InputBool() :
1039 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->
ReadExternalSettings(pExternalParameters, !pExternalParameters ? InputBool() :
1044 std::cout <<
"MasterAlgorithm::ReadSettings - ShouldRunStitching requires ShouldRunAllHitsCosmicReco to be true" << std::endl;
1045 return STATUS_CODE_INVALID_PARAMETER;
1050 AlgorithmToolVector algorithmToolVector;
1051 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ProcessAlgorithmToolList(*
this, xmlHandle,
"StitchingTools", algorithmToolVector));
1053 for (AlgorithmTool *
const pAlgorithmTool : algorithmToolVector)
1055 StitchingBaseTool *
const pStitchingTool(dynamic_cast<StitchingBaseTool*>(pAlgorithmTool));
1056 if (!pStitchingTool)
return STATUS_CODE_INVALID_PARAMETER;
1061 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->
ReadExternalSettings(pExternalParameters, !pExternalParameters ? InputBool() :
1066 std::cout <<
"MasterAlgorithm::ReadSettings - ShouldRunCosmicHitRemoval requires ShouldRunAllHitsCosmicReco to be true" << std::endl;
1067 return STATUS_CODE_INVALID_PARAMETER;
1072 AlgorithmToolVector algorithmToolVector;
1073 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ProcessAlgorithmToolList(*
this, xmlHandle,
"CosmicRayTaggingTools", algorithmToolVector));
1075 for (AlgorithmTool *
const pAlgorithmTool : algorithmToolVector)
1078 if (!pCosmicRayTaggingTool)
return STATUS_CODE_INVALID_PARAMETER;
1083 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->
ReadExternalSettings(pExternalParameters, !pExternalParameters ? InputBool() :
1086 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->
ReadExternalSettings(pExternalParameters, !pExternalParameters ? InputBool() :
1089 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->
ReadExternalSettings(pExternalParameters, !pExternalParameters ? InputBool() :
1092 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->
ReadExternalSettings(pExternalParameters, !pExternalParameters ? InputBool() :
1097 std::cout <<
"MasterAlgorithm::ReadSettings - ShouldPerformSliceId requires ShouldRunSlicing and both neutrino and cosmic reconstruction options" << std::endl;
1098 return STATUS_CODE_INVALID_PARAMETER;
1103 AlgorithmToolVector algorithmToolVector;
1104 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ProcessAlgorithmToolList(*
this, xmlHandle,
"SliceIdTools", algorithmToolVector));
1106 for (AlgorithmTool *
const pAlgorithmTool : algorithmToolVector)
1108 SliceIdBaseTool *
const pSliceIdIdTool(dynamic_cast<SliceIdBaseTool*>(pAlgorithmTool));
1109 if (!pSliceIdIdTool)
return STATUS_CODE_INVALID_PARAMETER;
1114 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->
ReadExternalSettings(pExternalParameters, !pExternalParameters ? InputBool() :
1117 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
1120 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
1123 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
1126 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
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));
1138 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle,
"InputMCParticleListName",
m_inputMCParticleListName));
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));
1147 return STATUS_CODE_SUCCESS;
1153 const TiXmlHandle xmlHandle,
const std::string &xmlTag,
bool &outputBool)
1155 if (pExternalParameters && inputBool.IsInitialized())
1157 outputBool = inputBool.Get();
1161 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, xmlTag, outputBool));
1164 return STATUS_CODE_SUCCESS;
static void AddDaughterPandoraInstance(const pandora::Pandora *const pPrimaryPandora, const pandora::Pandora *const pDaughterPandora)
Add a pandora daughter instance, associated to a primary pandora instance.
std::string m_inputMCParticleListName
The input mc particle list name.
pandora::InputBool m_shouldRunCosmicHitRemoval
Whether to remove hits from tagged cosmic-rays.
const pandora::ParticleFlowObject * CreatePfo(const pandora::ParticleFlowObject *const pInputPfo, const pandora::ClusterList &newClusterList, const pandora::VertexList &newVertexList) const
Create a new pfo in the current pandora instance, based upon the provided input pfo.
std::vector< pandora::CaloHitList > SliceVector
CosmicRayTaggingToolVector m_cosmicRayTaggingToolVector
The cosmic-ray tagging tool vector.
Header file for the pfo helper class.
pandora::StatusCode Copy(const pandora::Pandora *const pPandora, const pandora::CaloHit *const pCaloHit) const
Copy a specified calo hit to the provided pandora instance.
pandora::InputBool m_shouldRunStitching
Whether to stitch cosmic-ray muons crossing between volumes.
CosmicRayTaggingBaseTool class.
pandora::StatusCode Recreate(const pandora::PfoList &inputPfoList, pandora::PfoList &newPfoList) const
Recreate a specified list of pfos in the current pandora instance.
pandora::StatusCode ReadExternalSettings(const ExternalSteeringParameters *const pExternalParameters, const pandora::InputBool inputBool, const pandora::TiXmlHandle xmlHandle, const std::string &xmlTag, bool &outputBool)
Read settings from external steering parameters block, if present, otherwise from xml as standard...
const pandora::Pandora * m_pSlicingWorkerInstance
The slicing worker instance.
Header file for the lar calo hit class.
static void GetTwoDClusterList(const pandora::ParticleFlowObject *const pPfo, pandora::ClusterList &clusterList)
Get the list of 2D clusters from an input pfo.
int GetNuanceCode() const
Get the nuance code.
pandora::StatusCode CopyMCParticles() const
Copy mc particles in the named input list to all pandora worker instances.
const pandora::CaloHit * CreateCaloHit(const pandora::CaloHit *const pInputCaloHit, const pandora::CaloHit *const pParentCaloHit) const
Create a new calo hit in the current pandora instance, based upon the provided input calo hit...
bool m_shouldRunNeutrinoRecoOption
Whether to run neutrino reconstruction for each slice.
bool m_shouldRunAllHitsCosmicReco
Whether to run all hits cosmic-ray reconstruction.
void ProcessEvent(G4int iProp, size_t nEv)
unsigned int GetLArTPCVolumeId() const
Get the lar tpc volume id.
pandora::InputBool m_shouldRunSlicing
Whether to slice events into separate regions for processing.
bool m_shouldPerformSliceId
Whether to identify slices and select most appropriate pfos.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
std::unordered_map< const pandora::ParticleFlowObject *, float > PfoToFloatMap
std::vector< art::Ptr< simb::MCParticle > > MCParticleVector
std::string m_slicingSettingsFile
The slicing settings file.
std::unordered_map< const pandora::ParticleFlowObject *, const pandora::LArTPC * > PfoToLArTPCMap
pandora::StatusCode RunCosmicRayHitRemoval(const pandora::PfoList &ambiguousPfos) const
Run cosmic-ray hit removal, freeing hits in ambiguous pfos for further processing.
std::string m_recreatedVertexListName
The output recreated vertex list name.
std::vector< const pandora::Pandora * > PandoraInstanceList
const pandora::Vertex * CreateVertex(const pandora::Vertex *const pInputVertex) const
Create a new vertex in the current pandora instance, based upon the provided input vertex...
const pandora::Pandora * m_pSliceCRWorkerInstance
The per-slice cosmic-ray reconstruction worker instance.
static bool SortByMomentum(const pandora::MCParticle *const pLhs, const pandora::MCParticle *const pRhs)
Sort mc particles by their momentum.
pandora::InputBool m_shouldRunAllHitsCosmicReco
Whether to run all hits cosmic-ray reconstruction.
const pandora::Cluster * CreateCluster(const pandora::Cluster *const pInputCluster, const pandora::CaloHitList &newCaloHitList, const pandora::CaloHitList &newIsolatedCaloHitList) const
Create a new cluster in the current pandora instance, based upon the provided input cluster...
bool m_printOverallRecoStatus
Whether to print current operation status messages.
Header file for the master algorithm class.
Header file for the lar monte carlo particle helper helper class.
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.
Header file for the cluster helper class.
pandora::StatusCode RunSliceReconstruction(SliceVector &sliceVector, SliceHypotheses &nuSliceHypotheses, SliceHypotheses &crSliceHypotheses) const
Process each slice under different reconstruction hypotheses.
std::map< unsigned int, LArTPCHitList > VolumeIdToHitListMap
ntupleExperimental Reset()
const pandora::Pandora * m_pSliceNuWorkerInstance
The per-slice neutrino reconstruction worker instance.
static pandora::StatusCode RegisterBasicPlugins(const pandora::Pandora &pandora)
Register the basic lar content plugins with pandora.
std::vector< pandora::PfoList > SliceHypotheses
std::string m_nuSettingsFile
The neutrino reconstruction settings file.
pandora::InputBool m_shouldRunNeutrinoRecoOption
Whether to run neutrino reconstruction for each slice.
pandora::StatusCode InitializeWorkerInstances()
Initialize pandora worker instances.
bool m_workerInstancesInitialized
Whether all worker instances have been initialized.
void ShiftPfoHierarchy(const pandora::ParticleFlowObject *const pParentPfo, const PfoToLArTPCMap &pfoToLArTPCMap, const float x0) const
Shift a Pfo hierarchy by a specified x0 value.
StitchingToolVector m_stitchingToolVector
The stitching tool vector.
pandora::StatusCode Reset()
Reset all worker instances.
pandora::InputBool m_printOverallRecoStatus
Whether to print current operation status messages.
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...
Header file for the file helper class.
bool m_visualizeOverallRecoStatus
Whether to display results of current operations.
pandora::StatusCode TagCosmicRayPfos(const PfoToFloatMap &stitchedPfosToX0Map, pandora::PfoList &clearCosmicRayPfos, pandora::PfoList &ambiguousPfos) const
Tag clear, unambiguous cosmic-ray pfos.
std::string m_crSettingsFile
The cosmic-ray reconstruction settings file.
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...
void StitchPfos(const pandora::ParticleFlowObject *const pPfoToEnlarge, const pandora::ParticleFlowObject *const pPfoToDelete, PfoToLArTPCMap &pfoToLArTPCMap) const
Stitch together a pair of pfos.
Header file for the lar mc particle class.
static void GetThreeDClusterList(const pandora::ParticleFlowObject *const pPfo, pandora::ClusterList &clusterList)
Get the list of 3D clusters from an input pfo.
External steering parameters class.
std::string m_recreatedPfoListName
The output recreated pfo list name.
bool m_fullWidthCRWorkerWireGaps
Whether wire-type line gaps in cosmic-ray worker instances should cover all drift time...
LArMCParticleFactory responsible for object creation.
pandora::StatusCode StitchCosmicRayPfos(PfoToLArTPCMap &pfoToLArTPCMap, PfoToFloatMap &stitchedPfosToX0Map) const
Stitch together cosmic-ray pfos crossing between adjacent lar tpcs.
static pandora::StatusCode RegisterAlgorithms(const pandora::Pandora &pandora)
Register all the lar content algorithms and tools with pandora.
std::string m_filePathEnvironmentVariable
The environment variable providing a list of paths to xml files.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
LAr mc particle parameters.
pandora::StatusCode GetVolumeIdToHitListMap(VolumeIdToHitListMap &volumeIdToHitListMap) const
Get the mapping from lar tpc volume id to lists of all hits, and truncated hits.
std::string to_string(Flag_t< Storage > const flag)
Convert a flag into a stream (shows its index).
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
pandora::StatusCode RecreateCosmicRayPfos(PfoToLArTPCMap &pfoToLArTPCMap) const
Recreate cosmic-ray pfos (created by worker instances) in the master instance.
bool m_shouldRunSlicing
Whether to slice events into separate regions for processing.
pandora::InputInt m_nuanceCode
The nuance code.
Header file for the pfo mop up algorithm base class.
bool m_shouldRunCosmicRecoOption
Whether to run cosmic-ray reconstruction for each slice.
pandora::InputBool m_shouldPerformSliceId
Whether to identify slices and select most appropriate pfos.
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...
pandora::StatusCode Run()
LArRotationalTransformationPlugin class.
Header file detailing content for use with particle flow reconstruction at liquid argon time projecti...
pandora::InputBool 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...
PandoraInstanceList m_crWorkerInstances
The list of cosmic-ray reconstruction worker instances.
SliceIdToolVector m_sliceIdToolVector
The slice id tool vector.
bool m_shouldRunCosmicHitRemoval
Whether to remove hits from tagged cosmic-rays.
Header file for the lar pseudo layer plugin class.
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...
pandora::StatusCode RunSlicing(const VolumeIdToHitListMap &volumeIdToHitListMap, SliceVector &sliceVector) const
Run the event slicing procedures, dividing available hits up into distinct 3D regions.
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.
bool m_shouldRunStitching
Whether to stitch cosmic-ray muons crossing between volumes.
std::list< Vertex > VertexList
LarPandoraPseudoLayerPlugin class.
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. ...
std::vector< art::Ptr< recob::Vertex > > VertexVector
pandora::StatusCode RunCosmicRayReconstruction(const VolumeIdToHitListMap &volumeIdToHitListMap) const
Run the cosmic-ray reconstruction worker instances.