24 m_visualizePfo(false),
25 m_visualizeSlice(false),
26 m_groupMCByPdg(false),
27 m_showPfoByPid(false),
28 m_showPfoMatchedMC(false),
30 m_transparencyThresholdE{-1.f},
31 m_energyScaleThresholdE{1.f},
54 this->MakeSelection(pMCParticleList, pCaloHitList, targetMCParticleToHitsMap);
60 this->VisualizeMCByPdgCode(targetMCParticleToHitsMap);
62 this->VisualizeIndependentMC(targetMCParticleToHitsMap);
66 const PfoList *pPfoList(
nullptr);
70 this->VisualizePfoByParticleId(*pPfoList);
75 this->VisualizeIndependentPfo(*pPfoList, targetMCParticleToHitsMap);
77 this->VisualizeIndependentPfo(*pPfoList);
82 const PfoList *pPfoList(
nullptr);
84 this->VisualizeReconstructedSlice(*pPfoList);
87 return STATUS_CODE_SUCCESS;
96 const std::map<int, const std::string> keys = {{13,
"mu"}, {11,
"e"}, {22,
"gamma"}, {321,
"kaon"}, {211,
"pi"}, {2212,
"p"}};
97 const std::map<int, Color> colors = {{0, RED}, {1, BLACK}, {2, BLUE}, {3, CYAN}, {4, MAGENTA}, {5, GREEN}, {6, ORANGE}, {7, GRAY}};
110 const auto iter{mcMap.find(pMC)};
111 if (iter == mcMap.end())
113 std::string key(
"other");
116 const int pdg{std::abs(pMC->GetParticleId())};
117 if (keys.find(pdg) != keys.end())
126 for (
const CaloHit *pCaloHit : iter->second)
128 const HitType view{pCaloHit->GetHitType()};
129 if (view == HitType::TPC_VIEW_U)
130 uHits.emplace_back(pCaloHit);
131 else if (view == HitType::TPC_VIEW_V)
132 vHits.emplace_back(pCaloHit);
134 wHits.emplace_back(pCaloHit);
136 std::string suffix{std::to_string(mcIdx) +
"_" + key};
143 colorIdx = (colorIdx + 1) >= colors.size() ? 0 : colorIdx + 1;
154 const std::map<int, const std::string> keys = {{13,
"mu"}, {11,
"e"}, {22,
"gamma"}, {321,
"kaon"}, {211,
"pi"}, {2212,
"p"}};
155 const std::map<std::string, Color> colors = {
156 {
"mu", MAGENTA}, {
"e", RED}, {
"gamma", ORANGE}, {
"kaon", BLACK}, {
"pi", GREEN}, {
"p", BLUE}, {
"other", GRAY}};
158 std::map<std::string, CaloHitList> uHits, vHits, wHits;
159 for (
const auto &[key, value] : keys)
170 for (
const auto &[pMC, pCaloHits] : mcMap)
172 for (
const CaloHit *pCaloHit : pCaloHits)
174 const HitType view{pCaloHit->GetHitType()};
178 const int pdg{std::abs(pMC->GetParticleId())};
179 std::string key(
"other");
180 if (keys.find(pdg) != keys.end())
183 if (view == HitType::TPC_VIEW_U)
184 uHits[key].emplace_back(pCaloHit);
185 else if (view == HitType::TPC_VIEW_V)
186 vHits[key].emplace_back(pCaloHit);
188 wHits[key].emplace_back(pCaloHit);
200 for (
const auto &[key, value] : keys)
203 if (!uHits[value].empty())
206 if (!uHits[
"other"].empty())
209 for (
const auto &[key, value] : keys)
212 if (!vHits[value].empty())
215 if (!vHits[
"other"].empty())
218 for (
const auto &[key, value] : keys)
221 if (!wHits[value].empty())
224 if (!wHits[
"other"].empty())
232void VisualParticleMonitoringAlgorithm::VisualizeIndependentPfo(
const PfoList &pfoList)
const
236 this->VisualizeIndependentPfo(pfoList, mcMap);
243 const std::map<int, Color> colors = {{0, RED}, {1, BLACK}, {2, BLUE}, {3, CYAN}, {4, MAGENTA}, {5, GREEN}, {6, ORANGE}, {7, GRAY}};
259 for (
const auto view : {HitType::TPC_VIEW_U, HitType::TPC_VIEW_V, HitType::TPC_VIEW_W})
264 for (
const CaloHit *pCaloHit : caloHits)
266 const HitType view{pCaloHit->GetHitType()};
267 if (view == HitType::TPC_VIEW_U)
268 uHits.emplace_back(pCaloHit);
269 else if (view == HitType::TPC_VIEW_V)
270 vHits.emplace_back(pCaloHit);
271 else if (view == HitType::TPC_VIEW_W)
272 wHits.emplace_back(pCaloHit);
274 std::string suffix{std::to_string(pfoIdx)};
275 suffix += isTrack ?
"_T" :
"_S";
282 colorIdx = (colorIdx + 1) >= colors.size() ? 0 : colorIdx + 1;
290 const auto iter{mcMap.find(pMC)};
291 if (iter != mcMap.end())
294 for (
const CaloHit *pCaloHit : iter->second)
296 const HitType view{pCaloHit->GetHitType()};
297 if (view == HitType::TPC_VIEW_U)
298 uHitsMC.emplace_back(pCaloHit);
299 else if (view == HitType::TPC_VIEW_V)
300 vHitsMC.emplace_back(pCaloHit);
301 else if (view == HitType::TPC_VIEW_W)
302 wHitsMC.emplace_back(pCaloHit);
304 std::string mcSuffix(suffix +
"_MC");
305 if (!uHitsMC.empty())
307 if (!vHitsMC.empty())
309 if (!wHitsMC.empty())
326void VisualParticleMonitoringAlgorithm::VisualizeReconstructedSlice(
const PfoList &pfoList)
const
328 const std::map<int, Color> colors = {{0, RED}, {1, BLACK}, {2, BLUE}, {3, CYAN}, {4, MAGENTA}, {5, GREEN}, {6, ORANGE}, {7, GRAY}};
342 for (
const auto view : {HitType::TPC_VIEW_U, HitType::TPC_VIEW_V, HitType::TPC_VIEW_W})
347 for (
const CaloHit *pCaloHit : caloHits)
349 const HitType view{pCaloHit->GetHitType()};
350 if (view == HitType::TPC_VIEW_U)
351 uHits.emplace_back(pCaloHit);
352 else if (view == HitType::TPC_VIEW_V)
353 vHits.emplace_back(pCaloHit);
354 else if (view == HitType::TPC_VIEW_W)
355 wHits.emplace_back(pCaloHit);
357 std::string suffix{std::to_string(pfoIdx)};
358 suffix += isTrack ?
"_T" :
"_S";
365 colorIdx = (colorIdx + 1) >= colors.size() ? 0 : colorIdx + 1;
374void VisualParticleMonitoringAlgorithm::VisualizePfoByParticleId(
const PfoList &pfoList)
const
387 CaloHitList uTrackHits, vTrackHits, wTrackHits, uShowerHits, vShowerHits, wShowerHits;
390 for (
const auto view : {HitType::TPC_VIEW_U, HitType::TPC_VIEW_V, HitType::TPC_VIEW_W})
395 for (
const CaloHit *pCaloHit : caloHits)
397 const HitType view{pCaloHit->GetHitType()};
398 if (view == HitType::TPC_VIEW_U)
401 uTrackHits.emplace_back(pCaloHit);
403 uShowerHits.emplace_back(pCaloHit);
405 else if (view == HitType::TPC_VIEW_V)
408 vTrackHits.emplace_back(pCaloHit);
410 vShowerHits.emplace_back(pCaloHit);
415 wTrackHits.emplace_back(pCaloHit);
417 wShowerHits.emplace_back(pCaloHit);
422 std::string suffix{std::to_string(pfoIdx) +
"_T"};
423 if (!uTrackHits.empty())
425 if (!vTrackHits.empty())
427 if (!wTrackHits.empty())
432 std::string suffix{std::to_string(pfoIdx) +
"_S"};
433 if (!uShowerHits.empty())
435 if (!vShowerHits.empty())
437 if (!wShowerHits.empty())
448void VisualParticleMonitoringAlgorithm::MakeSelection(
452 LArMCParticleHelper::PrimaryParameters parameters;
453 parameters.m_minPrimaryGoodHits = 2;
454 parameters.m_minHitsForGoodView = 1;
455 parameters.m_maxPhotonPropagation = std::numeric_limits<float>::max();
456 parameters.m_minHitSharingFraction = 0;
457 parameters.m_foldBackHierarchy =
false;
496 return STATUS_CODE_SUCCESS;
Header file for the lar calo hit class.
Header file for the lar mc particle class.
Header file for the pfo helper class.
#define PANDORA_RETURN_RESULT_IF_AND_IF(StatusCode1, StatusCode2, Operator, Command)
#define PANDORA_RETURN_RESULT_IF(StatusCode1, Operator, Command)
Header file for the particle visualisation algorithm.
static pandora::StatusCode GetCurrentList(const pandora::Algorithm &algorithm, const T *&pT)
Get the current list.
static pandora::StatusCode GetList(const pandora::Algorithm &algorithm, const std::string &listName, const T *&pT)
Get a named list.
static bool IsCosmicRay(const pandora::MCParticle *const pMCParticle)
Return true if passed a primary cosmic ray MCParticle.
static bool IsBeamParticle(const pandora::MCParticle *const pMCParticle)
Returns true if passed a primary beam MCParticle.
static void SelectReconstructableMCParticles(const pandora::MCParticleList *pMCParticleList, const pandora::CaloHitList *pCaloHitList, const PrimaryParameters ¶meters, std::function< bool(const pandora::MCParticle *const)> fCriteria, MCContributionMap &selectedMCParticlesToHitsMap)
Select target, reconstructable mc particles that match given criteria.
std::unordered_map< const pandora::MCParticle *, pandora::CaloHitList > MCContributionMap
static void GetBreadthFirstHierarchyRepresentation(const pandora::MCParticle *const pMCParticle, pandora::MCParticleList &mcParticleList)
Retrieve a linearised representation of the MC particle hierarchy in breadth first order....
static const pandora::MCParticle * GetMainMCParticle(const pandora::ParticleFlowObject *const pPfo)
Find the mc particle making the largest contribution to 2D clusters in a specified pfo.
static bool IsBeamNeutrinoFinalState(const pandora::MCParticle *const pMCParticle)
Returns true if passed a primary neutrino final state MCParticle.
static bool IsTrack(const pandora::ParticleFlowObject *const pPfo)
Return track flag based on Pfo Particle ID.
static void GetBreadthFirstHierarchyRepresentation(const pandora::ParticleFlowObject *const pPfo, pandora::PfoList &pfoList)
Retrieve a linearised representation of the PFO hierarchy in breadth first order. This iterates over ...
static void GetIsolatedCaloHits(const pandora::PfoList &pfoList, const pandora::HitType &hitType, pandora::CaloHitList &caloHitList)
Get a list of isolated calo hits of a particular hit type from a list of pfos.
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.
float m_transparencyThresholdE
Cell energy for which transparency is saturated (0%, fully opaque)
std::string m_caloHitListName
Name of input calo hit list.
virtual ~VisualParticleMonitoringAlgorithm()
float m_energyScaleThresholdE
Cell energy for which color is at top end of continous color palette.
bool m_showPfoByPid
Whether or not to colour PFOs by particle id.
bool m_showPfoMatchedMC
Whether or not to display the best matched MC particle for a PFO.
bool m_visualizeSlice
Whether or not to visualize reconstructed slices.
bool m_isTestBeam
Whether or not this is a test beam experiment.
bool m_groupMCByPdg
Whether or not to group MC particles by particle id.
bool m_visualizeMC
Whether or not to visualize MC particles.
pandora::StatusCode Run()
Run the algorithm.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
float m_scalingFactor
TEve works with [cm], Pandora usually works with [mm] (but LArContent went with cm too)
bool m_visualizePfo
Whether or not to visualize PFOs.
std::string m_pfoListName
Name of input PFO list.
VisualParticleMonitoringAlgorithm()
Default constructor.
ParticleFlowObject class.
const Pandora & GetPandora() const
Get the associated pandora instance.
StatusCodeException class.
static StatusCode ReadValue(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, T &t)
Read a value from an xml element.
HitType
Calorimeter hit type enum.
MANAGED_CONTAINER< const MCParticle * > MCParticleList
MANAGED_CONTAINER< const CaloHit * > CaloHitList
StatusCode
The StatusCode enum.
MANAGED_CONTAINER< const ParticleFlowObject * > PfoList