LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
CheatingNeutrinoIdTool.cc
Go to the documentation of this file.
1 
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, const SliceHypotheses &crSliceHypotheses, PfoList &selectedPfos)
22 {
23  if (nuSliceHypotheses.size() != crSliceHypotheses.size())
24  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
25 
26  float bestNeutrinoWeight(0.f);
27  unsigned int bestSliceIndex(std::numeric_limits<unsigned int>::max());
28 
29  for (unsigned int sliceIndex = 0, nSlices = nuSliceHypotheses.size(); sliceIndex < nSlices; ++sliceIndex)
30  {
31  float neutrinoWeight(0.f);
32  const PfoList &neutrinoPfoList(nuSliceHypotheses.at(sliceIndex));
33 
34  for (const Pfo *const pNeutrinoPfo : neutrinoPfoList)
35  {
36  if (!LArPfoHelper::IsNeutrino(pNeutrinoPfo))
37  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
38 
39  PfoList downstreamPfos;
40  LArPfoHelper::GetAllDownstreamPfos(pNeutrinoPfo, downstreamPfos);
41 
42  float thisNeutrinoWeight(0.f), thisTotalWeight(0.f);
43  CheatingSliceIdBaseTool::GetTargetParticleWeight(&downstreamPfos, thisNeutrinoWeight, thisTotalWeight, LArMCParticleHelper::IsNeutrino);
44  neutrinoWeight += thisNeutrinoWeight;
45  }
46 
47  if (neutrinoWeight > bestNeutrinoWeight)
48  {
49  bestNeutrinoWeight = neutrinoWeight;
50  bestSliceIndex = sliceIndex;
51  }
52  }
53 
54  for (unsigned int sliceIndex = 0, nSlices = nuSliceHypotheses.size(); sliceIndex < nSlices; ++sliceIndex)
55  {
56  const PfoList &sliceOutput((bestSliceIndex == sliceIndex) ? nuSliceHypotheses.at(sliceIndex) : crSliceHypotheses.at(sliceIndex));
57  selectedPfos.insert(selectedPfos.end(), sliceOutput.begin(), sliceOutput.end());
58  }
59 }
60 
61 //------------------------------------------------------------------------------------------------------------------------------------------
62 
63 StatusCode CheatingNeutrinoIdTool::ReadSettings(const TiXmlHandle /*xmlHandle*/)
64 {
65  return STATUS_CODE_SUCCESS;
66 }
67 
68 } // namespace lar_content
Header file for the pfo helper class.
TFile f
Definition: plotHisto.C:6
Int_t max
Definition: plot.C:27
Header file for the lar monte carlo particle helper helper class.
std::vector< pandora::PfoList > SliceHypotheses
Header file for the cheating neutrino id tool class.