LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
CheatingCosmicRayTaggingTool.cc
Go to the documentation of this file.
1 
9 #include "Pandora/AlgorithmHeaders.h"
10 
13 
16 
17 using namespace pandora;
18 
19 namespace lar_content
20 {
21 
22 CheatingCosmicRayTaggingTool::CheatingCosmicRayTaggingTool() :
23  m_maxCosmicRayFraction(0.25f)
24 {
25 }
26 
27 //------------------------------------------------------------------------------------------------------------------------------------------
28 
29 void CheatingCosmicRayTaggingTool::FindAmbiguousPfos(const PfoList &parentCosmicRayPfos, PfoList &ambiguousPfos, const MasterAlgorithm *const /*pAlgorithm*/)
30 {
31  if (this->GetPandora().GetSettings()->ShouldDisplayAlgorithmInfo())
32  std::cout << "----> Running Algorithm Tool: " << this->GetInstanceName() << ", " << this->GetType() << std::endl;
33 
34  PfoList ambiguousParentPfos;
35 
36  for (const Pfo *const pParentCosmicRayPfo : parentCosmicRayPfos)
37  {
38  PfoList downstreamPfos;
39  LArPfoHelper::GetAllDownstreamPfos(pParentCosmicRayPfo, downstreamPfos);
40 
41  float thisCosmicRayWeight(0.f), thisTotalWeight(0.f);
42  CheatingSliceIdBaseTool::GetTargetParticleWeight(&downstreamPfos, thisCosmicRayWeight, thisTotalWeight, LArMCParticleHelper::IsCosmicRay);
43 
44  if ((thisTotalWeight > 0.f) && ((thisCosmicRayWeight / thisTotalWeight) < m_maxCosmicRayFraction))
45  ambiguousParentPfos.push_back(pParentCosmicRayPfo);
46  }
47 
48  LArPfoHelper::GetAllConnectedPfos(ambiguousParentPfos, ambiguousPfos);
49 }
50 
51 //------------------------------------------------------------------------------------------------------------------------------------------
52 
53 StatusCode CheatingCosmicRayTaggingTool::ReadSettings(const TiXmlHandle xmlHandle)
54 {
55  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
56  "MaxCosmicRayFraction", m_maxCosmicRayFraction));
57 
58  return STATUS_CODE_SUCCESS;
59 }
60 
61 } // namespace lar_content
Header file for the pfo helper class.
Header file for the cheating slice id base tool class.
TFile f
Definition: plotHisto.C:6
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...