CheatingCosmicRayTaggingTool.cc
Go to the documentation of this file.
1 /**
2  * @file larpandoracontent/LArCheating/CheatingCosmicRayTaggingTool.cc
3  *
4  * @brief Implementation of the cheating cosmic-ray tagging tool class.
5  *
6  * $Log: $
7  */
8 
9 #include "Pandora/AlgorithmHeaders.h"
10 
13 
16 
17 using namespace pandora;
18 
19 namespace lar_content
20 {
21 
22 CheatingCosmicRayTaggingTool::CheatingCosmicRayTaggingTool() : m_maxCosmicRayFraction(0.25f)
23 {
24 }
25 
26 //------------------------------------------------------------------------------------------------------------------------------------------
27 
28 void CheatingCosmicRayTaggingTool::FindAmbiguousPfos(const PfoList &parentCosmicRayPfos, PfoList &ambiguousPfos, const MasterAlgorithm *const /*pAlgorithm*/)
29 {
30  if (this->GetPandora().GetSettings()->ShouldDisplayAlgorithmInfo())
31  std::cout << "----> Running Algorithm Tool: " << this->GetInstanceName() << ", " << this->GetType() << std::endl;
32 
33  PfoList ambiguousParentPfos;
34 
35  for (const Pfo *const pParentCosmicRayPfo : parentCosmicRayPfos)
36  {
37  PfoList downstreamPfos;
38  LArPfoHelper::GetAllDownstreamPfos(pParentCosmicRayPfo, downstreamPfos);
39 
40  float thisCosmicRayWeight(0.f), thisTotalWeight(0.f);
41  CheatingSliceIdBaseTool::GetTargetParticleWeight(&downstreamPfos, thisCosmicRayWeight, thisTotalWeight, LArMCParticleHelper::IsCosmicRay);
42 
43  if ((thisTotalWeight > 0.f) && ((thisCosmicRayWeight / thisTotalWeight) < m_maxCosmicRayFraction))
44  ambiguousParentPfos.push_back(pParentCosmicRayPfo);
45  }
46 
47  LArPfoHelper::GetAllConnectedPfos(ambiguousParentPfos, ambiguousPfos);
48 }
49 
50 //------------------------------------------------------------------------------------------------------------------------------------------
51 
52 StatusCode CheatingCosmicRayTaggingTool::ReadSettings(const TiXmlHandle xmlHandle)
53 {
54  PANDORA_RETURN_RESULT_IF_AND_IF(
55  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MaxCosmicRayFraction", m_maxCosmicRayFraction));
56 
57  return STATUS_CODE_SUCCESS;
58 }
59 
60 } // namespace lar_content
Header file for the pfo helper class.
Header file for the cheating slice id base tool class.
static bool IsCosmicRay(const pandora::MCParticle *const pMCParticle)
Return true if passed a primary cosmic ray MCParticle.
Header file for the lar monte carlo particle helper helper class.
Header file for the cheating cosmic-ray tagging tool class.
void FindAmbiguousPfos(const pandora::PfoList &parentCosmicRayPfos, pandora::PfoList &ambiguousPfos, const MasterAlgorithm *const pAlgorithm)
Find the list of ambiguous pfos (could represent cosmic-ray muons or neutrinos)
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
static void GetTargetParticleWeight(const pandora::PfoList *const pPfoList, float &targetParticleWeight, float &totalWeight, std::function< bool(const pandora::MCParticle *const)> fCriteria)
Get the target particle weight in a list of pfos.
MasterAlgorithm class.
float m_maxCosmicRayFraction
The maximum cosmic ray fraction for a pfo to be declared an ambiguous cosmic ray. ...
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...
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...
QTextStream & endl(QTextStream &s)