All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CheatingNeutrinoIdTool.cc
Go to the documentation of this file.
1 /**
2  * @file larpandoracontent/LArCheating/CheatingNeutrinoIdTool.cc
3  *
4  * @brief Implementation of the cheating neutrino id tool class.
5  *
6  * $Log: $
7  */
8 
9 #include "Pandora/AlgorithmHeaders.h"
10 
12 
15 
16 using namespace pandora;
17 
18 namespace lar_content
19 {
20 
21 void CheatingNeutrinoIdTool::SelectOutputPfos(const pandora::Algorithm *const /*pAlgorithm*/, const SliceHypotheses &nuSliceHypotheses,
22  const SliceHypotheses &crSliceHypotheses, PfoList &selectedPfos)
23 {
24  if (nuSliceHypotheses.size() != crSliceHypotheses.size())
25  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
26 
27  float bestNeutrinoWeight(0.f);
28  unsigned int bestSliceIndex(std::numeric_limits<unsigned int>::max());
29 
30  for (unsigned int sliceIndex = 0, nSlices = nuSliceHypotheses.size(); sliceIndex < nSlices; ++sliceIndex)
31  {
32  float neutrinoWeight(0.f);
33  const PfoList &neutrinoPfoList(nuSliceHypotheses.at(sliceIndex));
34 
35  for (const Pfo *const pNeutrinoPfo : neutrinoPfoList)
36  {
37  if (!LArPfoHelper::IsNeutrino(pNeutrinoPfo))
38  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
39 
40  PfoList downstreamPfos;
41  LArPfoHelper::GetAllDownstreamPfos(pNeutrinoPfo, downstreamPfos);
42 
43  float thisNeutrinoWeight(0.f), thisTotalWeight(0.f);
44  CheatingSliceIdBaseTool::GetTargetParticleWeight(&downstreamPfos, thisNeutrinoWeight, thisTotalWeight, LArMCParticleHelper::IsNeutrino);
45  neutrinoWeight += thisNeutrinoWeight;
46  }
47 
48  if (neutrinoWeight > bestNeutrinoWeight)
49  {
50  bestNeutrinoWeight = neutrinoWeight;
51  bestSliceIndex = sliceIndex;
52  }
53  }
54 
55  for (unsigned int sliceIndex = 0, nSlices = nuSliceHypotheses.size(); sliceIndex < nSlices; ++sliceIndex)
56  {
57  const PfoList &sliceOutput((bestSliceIndex == sliceIndex) ? nuSliceHypotheses.at(sliceIndex) : crSliceHypotheses.at(sliceIndex));
58  selectedPfos.insert(selectedPfos.end(), sliceOutput.begin(), sliceOutput.end());
59  }
60 }
61 
62 //------------------------------------------------------------------------------------------------------------------------------------------
63 
64 StatusCode CheatingNeutrinoIdTool::ReadSettings(const TiXmlHandle /*xmlHandle*/)
65 {
66  return STATUS_CODE_SUCCESS;
67 }
68 
69 } // namespace lar_content
Header file for the pfo helper class.
Header file for the lar monte carlo particle helper helper class.
std::vector< pandora::PfoList > SliceHypotheses
required by fuzzyCluster table::sbnd_g4_services gaushitTruthMatch pandora
Definition: reco_sbnd.fcl:182
Header file for the cheating neutrino id tool class.