All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Member Functions | Private Attributes | List of all members
sbnd::PandoraNuScoreCosmicIdAlg Class Reference

#include <PandoraNuScoreCosmicIdAlg.h>

Classes

struct  Config
 

Public Member Functions

 PandoraNuScoreCosmicIdAlg (const Config &config)
 
 PandoraNuScoreCosmicIdAlg (const fhicl::ParameterSet &pset)
 
 ~PandoraNuScoreCosmicIdAlg ()
 
void reconfigure (const Config &config)
 
bool PandoraNuScoreCosmicId (recob::Track track, const art::Event &event)
 
bool PandoraNuScoreCosmicId (recob::PFParticle pfparticle, std::map< size_t, art::Ptr< recob::PFParticle > > pfParticleMap, const art::Event &event)
 
recob::PFParticle GetPFPNeutrino (recob::PFParticle pfparticle, std::map< size_t, art::Ptr< recob::PFParticle > > &pfParticleMap)
 
recob::PFParticle GetPFPNeutrino (recob::PFParticle pfp, const std::vector< recob::PFParticle > &pfpVec)
 
float GetPandoraNuScore (recob::PFParticle pfparticle, art::FindManyP< larpandoraobj::PFParticleMetadata > PFPMetaDataAssoc)
 

Private Attributes

art::InputTag fPandoraLabel
 
art::InputTag fTpcTrackModuleLabel
 
float fNuScoreCut
 

Detailed Description

Definition at line 34 of file PandoraNuScoreCosmicIdAlg.h.

Constructor & Destructor Documentation

sbnd::PandoraNuScoreCosmicIdAlg::PandoraNuScoreCosmicIdAlg ( const Config config)

Definition at line 5 of file PandoraNuScoreCosmicIdAlg.cc.

5  {
6 
7  this->reconfigure(config);
8 
9  }
void reconfigure(const Config &config)
sbnd::PandoraNuScoreCosmicIdAlg::PandoraNuScoreCosmicIdAlg ( const fhicl::ParameterSet &  pset)
inline

Definition at line 60 of file PandoraNuScoreCosmicIdAlg.h.

60  :
61  PandoraNuScoreCosmicIdAlg(fhicl::Table<Config>(pset, {})()) {}
PandoraNuScoreCosmicIdAlg(const Config &config)
sbnd::PandoraNuScoreCosmicIdAlg::~PandoraNuScoreCosmicIdAlg ( )

Definition at line 17 of file PandoraNuScoreCosmicIdAlg.cc.

17  {
18 
19  }

Member Function Documentation

float sbnd::PandoraNuScoreCosmicIdAlg::GetPandoraNuScore ( recob::PFParticle  pfparticle,
art::FindManyP< larpandoraobj::PFParticleMetadata PFPMetaDataAssoc 
)

Definition at line 110 of file PandoraNuScoreCosmicIdAlg.cc.

111  {
112 
113  const std::vector<art::Ptr<larpandoraobj::PFParticleMetadata> > pfpMetaVec =
114  PFPMetaDataAssoc.at(pfparticle.Self());
115 
116  if (pfpMetaVec.size() !=1){
117  std::cout<<"Cannot get PFPMetadata"<<std::endl;
118  return 99999;
119  }
120 
121  art::Ptr<larpandoraobj::PFParticleMetadata> pfpMeta = pfpMetaVec.front();
122 
123  larpandoraobj::PFParticleMetadata::PropertiesMap propertiesMap = pfpMeta->GetPropertiesMap();
124  auto propertiesMapIter = propertiesMap.find("NuScore");
125  if (propertiesMapIter == propertiesMap.end()){
126  std::cout<<"Cannot get PFP Nu Score in Metadata"<<std::endl;
127  std::cout<<"PFP pdg: "<<pfparticle.PdgCode()<<std::endl;
128  return 99999;
129  }
130 
131  return propertiesMapIter->second;
132  }
size_t Self() const
Returns the index of this particle.
Definition: PFParticle.h:92
int PdgCode() const
Return the type of particle as a PDG ID.
Definition: PFParticle.h:83
std::map< std::string, float > PropertiesMap
BEGIN_PROLOG could also be cout
recob::PFParticle sbnd::PandoraNuScoreCosmicIdAlg::GetPFPNeutrino ( recob::PFParticle  pfparticle,
std::map< size_t, art::Ptr< recob::PFParticle > > &  pfParticleMap 
)

Definition at line 82 of file PandoraNuScoreCosmicIdAlg.cc.

82  {
83 
84  if ((pfparticle.PdgCode()==12) ||(pfparticle.PdgCode()==14)){
85  return pfparticle;
86  } else {
87  art::Ptr<recob::PFParticle> parentPFP= pfParticleMap.at(pfparticle.Parent());
88  return GetPFPNeutrino(*parentPFP, pfParticleMap);
89  }
90  }
int PdgCode() const
Return the type of particle as a PDG ID.
Definition: PFParticle.h:83
recob::PFParticle GetPFPNeutrino(recob::PFParticle pfparticle, std::map< size_t, art::Ptr< recob::PFParticle > > &pfParticleMap)
size_t Parent() const
Definition: PFParticle.h:96
recob::PFParticle sbnd::PandoraNuScoreCosmicIdAlg::GetPFPNeutrino ( recob::PFParticle  pfp,
const std::vector< recob::PFParticle > &  pfpVec 
)

Definition at line 92 of file PandoraNuScoreCosmicIdAlg.cc.

93  {
94 
95  if ((pfparticle.PdgCode()==12) ||(pfparticle.PdgCode()==14)){
96  return pfparticle;
97  } else {
98  size_t parentID = pfparticle.Parent();
99  auto parentPFPIter = std::find_if(pfpVec.begin(), pfpVec.end(),
100  [&](const auto& pfp){return pfp.Self()==parentID;});
101 
102  if (parentPFPIter==pfpVec.end()){
103  return pfparticle;
104  } else {
105  return GetPFPNeutrino(*parentPFPIter, pfpVec);
106  }
107  }
108  }
size_t Self() const
Returns the index of this particle.
Definition: PFParticle.h:92
recob::PFParticle GetPFPNeutrino(recob::PFParticle pfparticle, std::map< size_t, art::Ptr< recob::PFParticle > > &pfParticleMap)
bool sbnd::PandoraNuScoreCosmicIdAlg::PandoraNuScoreCosmicId ( recob::Track  track,
const art::Event &  event 
)

Definition at line 32 of file PandoraNuScoreCosmicIdAlg.cc.

32  {
33 
34  // Get the pfps and associations
35  art::Handle< std::vector<recob::PFParticle> > pfParticleHandle;
36  event.getByLabel(fPandoraLabel, pfParticleHandle);
37  art::FindManyP<recob::Track> pfPartToTrackAssoc(pfParticleHandle, event, fTpcTrackModuleLabel);
38  art::FindManyP<larpandoraobj::PFParticleMetadata> PFPMetaDataAssoc(pfParticleHandle, event, fPandoraLabel);
39 
40  // Loop over all the pfps
41  for(auto const pfp : (*pfParticleHandle)){
42  // Get the associated track if there is one
43  const std::vector< art::Ptr<recob::Track> > associatedTracks(pfPartToTrackAssoc.at(pfp.Self()));
44  if(associatedTracks.size() != 1) continue;
45  recob::Track trk = *associatedTracks.front();
46  if(trk.ID() != track.ID()) continue;
47 
48  recob::PFParticle PFPNeutrino = GetPFPNeutrino(pfp, (*pfParticleHandle));
49 
50  float pfpNuScore = GetPandoraNuScore(PFPNeutrino, PFPMetaDataAssoc);
51  if (pfpNuScore < fNuScoreCut){
52  return true;
53  } else {
54  return false;
55  }
56  }
57  return false;
58 
59  }
recob::PFParticle GetPFPNeutrino(recob::PFParticle pfparticle, std::map< size_t, art::Ptr< recob::PFParticle > > &pfParticleMap)
float GetPandoraNuScore(recob::PFParticle pfparticle, art::FindManyP< larpandoraobj::PFParticleMetadata > PFPMetaDataAssoc)
Hierarchical representation of particle flow.
Definition: PFParticle.h:44
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a &quot;fitted&quot; track:
bool sbnd::PandoraNuScoreCosmicIdAlg::PandoraNuScoreCosmicId ( recob::PFParticle  pfparticle,
std::map< size_t, art::Ptr< recob::PFParticle > >  pfParticleMap,
const art::Event &  event 
)

Definition at line 62 of file PandoraNuScoreCosmicIdAlg.cc.

63  {
64 
65  // Get pfp associations to t0s
66  art::Handle< std::vector<recob::PFParticle> > pfParticleHandle;
67  event.getByLabel(fPandoraLabel, pfParticleHandle);
68 
69  art::FindManyP<larpandoraobj::PFParticleMetadata> PFPMetaDataAssoc(pfParticleHandle, event, fPandoraLabel);
70 
71  recob::PFParticle PFPNeutrino = GetPFPNeutrino(pfparticle, pfParticleMap);
72 
73  float pfpNuScore = GetPandoraNuScore(PFPNeutrino, PFPMetaDataAssoc);
74 
75  if (pfpNuScore < fNuScoreCut){
76  return true;
77  }
78  return false;
79  }
recob::PFParticle GetPFPNeutrino(recob::PFParticle pfparticle, std::map< size_t, art::Ptr< recob::PFParticle > > &pfParticleMap)
float GetPandoraNuScore(recob::PFParticle pfparticle, art::FindManyP< larpandoraobj::PFParticleMetadata > PFPMetaDataAssoc)
Hierarchical representation of particle flow.
Definition: PFParticle.h:44
void sbnd::PandoraNuScoreCosmicIdAlg::reconfigure ( const Config config)

Definition at line 22 of file PandoraNuScoreCosmicIdAlg.cc.

22  {
23 
24  fPandoraLabel = config.PandoraLabel();
25  fTpcTrackModuleLabel = config.TpcTrackModuleLabel();
26  fNuScoreCut = config.NuScoreCut();
27 
28  return;
29  }

Member Data Documentation

float sbnd::PandoraNuScoreCosmicIdAlg::fNuScoreCut
private

Definition at line 86 of file PandoraNuScoreCosmicIdAlg.h.

art::InputTag sbnd::PandoraNuScoreCosmicIdAlg::fPandoraLabel
private

Definition at line 84 of file PandoraNuScoreCosmicIdAlg.h.

art::InputTag sbnd::PandoraNuScoreCosmicIdAlg::fTpcTrackModuleLabel
private

Definition at line 85 of file PandoraNuScoreCosmicIdAlg.h.


The documentation for this class was generated from the following files: