DUNEAnaEventUtils.cxx
Go to the documentation of this file.
1 /**
2 *
3 * @file dunereco/AnaUtils/DUNEAnaEventUtils.cxx
4 *
5 * @brief Utility containing helpful functions for end users to access products from events
6 */
7 
10 
11 #include "cetlib_except/exception.h"
13 
21 
24 
25 namespace dune_ana
26 {
27 
28 std::vector<art::Ptr<recob::PFParticle>> DUNEAnaEventUtils::GetPFParticles(const art::Event &evt, const std::string &label)
29 {
30  return DUNEAnaEventUtils::GetProductVector<recob::PFParticle>(evt,label);
31 }
32 
33 //-----------------------------------------------------------------------------------------------------------------------------------------
34 
35 std::vector<art::Ptr<recob::Track>> DUNEAnaEventUtils::GetTracks(const art::Event &evt, const std::string &label)
36 {
37  mf::LogWarning("DUNEAna") << " Please note: accessing PFParticle tracks through this method is not the recommended workflow.\n"
38  << " Please use DUNEAnaEventUtils::GetPFParticles and access the tracks with DUNEAnaPFParticleUtils::GetTrack."
39  << std::endl;
40 
41  return DUNEAnaEventUtils::GetProductVector<recob::Track>(evt,label);
42 }
43 
44 //-----------------------------------------------------------------------------------------------------------------------------------------
45 
46 std::vector<art::Ptr<recob::Shower>> DUNEAnaEventUtils::GetShowers(const art::Event &evt, const std::string &label)
47 {
48  mf::LogWarning("DUNEAna") << " Please note: accessing PFParticle showers through this method is not the recommended workflow.\n"
49  << " Please use DUNEAnaEventUtils::GetPFParticles and access the tracks with DUNEAnaPFParticleUtils::GetShower."
50  << std::endl;
51 
52  return DUNEAnaEventUtils::GetProductVector<recob::Shower>(evt,label);
53 }
54 
55 //-----------------------------------------------------------------------------------------------------------------------------------------
56 
57 std::vector<art::Ptr<recob::Vertex>> DUNEAnaEventUtils::GetVertices(const art::Event &evt, const std::string &label)
58 {
59  return DUNEAnaEventUtils::GetProductVector<recob::Vertex>(evt,label);
60 }
61 
62 //-----------------------------------------------------------------------------------------------------------------------------------------
63 
64 std::vector<art::Ptr<recob::Hit>> DUNEAnaEventUtils::GetHits(const art::Event &evt, const std::string &label)
65 {
66  return DUNEAnaEventUtils::GetProductVector<recob::Hit>(evt,label);
67 }
68 
69 //-----------------------------------------------------------------------------------------------------------------------------------------
70 
71 std::vector<art::Ptr<recob::Wire>> DUNEAnaEventUtils::GetWires(const art::Event &evt, const std::string &label)
72 {
73  return DUNEAnaEventUtils::GetProductVector<recob::Wire>(evt,label);
74 }
75 
76 //-----------------------------------------------------------------------------------------------------------------------------------------
77 
78 std::vector<art::Ptr<recob::SpacePoint>> DUNEAnaEventUtils::GetSpacePoints(const art::Event &evt, const std::string &label)
79 {
80  return DUNEAnaEventUtils::GetProductVector<recob::SpacePoint>(evt,label);
81 }
82 
83 //-----------------------------------------------------------------------------------------------------------------------------------------
84 
85 std::vector<art::Ptr<recob::Slice>> DUNEAnaEventUtils::GetSlices(const art::Event &evt, const std::string &label)
86 {
87  return DUNEAnaEventUtils::GetProductVector<recob::Slice>(evt,label);
88 }
89 
90 //-----------------------------------------------------------------------------------------------------------------------------------------
91 
92 std::vector<art::Ptr<simb::MCTruth>> DUNEAnaEventUtils::GetMCTruths(const art::Event &evt, const std::string &label)
93 {
94  return DUNEAnaEventUtils::GetProductVector<simb::MCTruth>(evt,label);
95 }
96 
97 //-----------------------------------------------------------------------------------------------------------------------------------------
98 
99 std::vector<art::Ptr<simb::MCParticle>> DUNEAnaEventUtils::GetMCParticles(const art::Event &evt, const std::string &label)
100 {
101  return DUNEAnaEventUtils::GetProductVector<simb::MCParticle>(evt,label);
102 }
103 
104 //-----------------------------------------------------------------------------------------------------------------------------------------
105 
106 std::vector<art::Ptr<recob::PFParticle>> DUNEAnaEventUtils::GetClearCosmics(const art::Event &evt, const std::string &label)
107 {
108  std::vector<art::Ptr<recob::PFParticle>> theseParticles = DUNEAnaEventUtils::GetProductVector<recob::PFParticle>(evt,label);
109 
110  std::vector<art::Ptr<recob::PFParticle>> theseCosmics;
111 
112  // We only want primary cosmic rays
113  for (art::Ptr<recob::PFParticle> pParticle : theseParticles)
114  {
115  if (!pParticle->IsPrimary())
116  {
117  continue;
118  }
119 
120  if (DUNEAnaPFParticleUtils::IsClearCosmic(pParticle, evt, label))
121  {
122  theseCosmics.push_back(pParticle);
123  }
124  }
125 
126  return theseCosmics;
127 }
128 
129 //-----------------------------------------------------------------------------------------------------------------------------------------
130 
132 {
133  if (!HasNeutrino(evt,label))
134  {
135  throw cet::exception("DUNEAna") << "DUNEAnaEventUtils::GetNeutrino --- No neutrino found";
136  }
137 
138  art::Ptr<recob::PFParticle> pNeutrino;
139  std::vector<art::Ptr<recob::PFParticle>> particles = DUNEAnaEventUtils::GetPFParticles(evt,label);
140  for (art::Ptr<recob::PFParticle> pParticle : particles)
141  {
142  if (DUNEAnaPFParticleUtils::IsNeutrino(pParticle))
143  {
144  pNeutrino = pParticle;
145  break;
146  }
147  }
148  return pNeutrino;
149 }
150 
151 //-----------------------------------------------------------------------------------------------------------------------------------------
152 
154 {
155  bool hasNeutrino = false;
156  std::vector<art::Ptr<recob::PFParticle>> particles = DUNEAnaEventUtils::GetPFParticles(evt,label);
157  for (art::Ptr<recob::PFParticle> pParticle : particles)
158  {
159  if(!pParticle->IsPrimary())
160  {
161  continue;
162  }
163  if (DUNEAnaPFParticleUtils::IsNeutrino(pParticle))
164  {
165  hasNeutrino = true;
166  break;
167  }
168  }
169  return hasNeutrino;
170 }
171 
172 //-----------------------------------------------------------------------------------------------------------------------------------------
173 
174 std::vector<art::Ptr<cvn::Result>> DUNEAnaEventUtils::GetCVNResults(const art::Event &evt, const std::string &label)
175 {
176  return DUNEAnaEventUtils::GetProductVector<cvn::Result>(evt,label);
177 }
178 
179 //-----------------------------------------------------------------------------------------------------------------------------------------
180 
181 std::vector<art::Ptr<ctp::CTPResult>> DUNEAnaEventUtils::GetSquIDResults(const art::Event &evt, const std::string &label)
182 {
183  return DUNEAnaEventUtils::GetProductVector<ctp::CTPResult>(evt,label);
184 }
185 
186 } // namespace dune_ana
187 
Class storing the result from the convolutional track PID.
std::string string
Definition: nybbler.cc:12
static bool IsClearCosmic(const art::Ptr< recob::PFParticle > &pParticle, const art::Event &evt, const std::string &pParticleLabel)
Check if this particle is a clear cosmic ray.
static art::Ptr< recob::PFParticle > GetNeutrino(const art::Event &evt, const std::string &label)
Get the neutrino from the event.
static std::vector< art::Ptr< recob::Hit > > GetHits(const art::Event &evt, const std::string &label)
Get the hits from the event.
static bool HasNeutrino(const art::Event &evt, const std::string &label)
Check to see if the event has a reconstructed neutrino.
static std::vector< art::Ptr< recob::Wire > > GetWires(const art::Event &evt, const std::string &label)
Get the wires from the event.
static std::vector< art::Ptr< ctp::CTPResult > > GetSquIDResults(const art::Event &evt, const std::string &label)
Get the SquID track PID result objects from the event.
static std::vector< art::Ptr< simb::MCParticle > > GetMCParticles(const art::Event &evt, const std::string &label)
Get the MC particles from the event.
static std::vector< art::Ptr< recob::PFParticle > > GetClearCosmics(const art::Event &evt, const std::string &label)
Get the clear cosmic ray primaries from the event.
static std::vector< art::Ptr< recob::Track > > GetTracks(const art::Event &evt, const std::string &label)
Get the tracks from the event. This function shouldn&#39;t be used as the basis of an analysis...
Result for CVN.
static bool IsNeutrino(const art::Ptr< recob::PFParticle > &pParticle)
Check if this particle is a neutrino.
static std::vector< art::Ptr< recob::Vertex > > GetVertices(const art::Event &evt, const std::string &label)
Get the vertices from the event.
Utility containing helpful functions for end users to access information about PFParticles.
Utility containing helpful functions for end users to access products from events.
static std::vector< art::Ptr< recob::SpacePoint > > GetSpacePoints(const art::Event &evt, const std::string &label)
Get the spacepoints from the event.
Declaration of signal hit object.
static std::vector< art::Ptr< simb::MCTruth > > GetMCTruths(const art::Event &evt, const std::string &label)
Get the MC truths from the event.
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
Provides recob::Track data product.
static std::vector< art::Ptr< recob::Shower > > GetShowers(const art::Event &evt, const std::string &label)
Get the showers from the event. This function shouldn&#39;t be used as the basis of an analysis...
TCEvent evt
Definition: DataStructs.cxx:7
static std::vector< art::Ptr< cvn::Result > > GetCVNResults(const art::Event &evt, const std::string &label)
Get the CVN result objects from the event.
static std::vector< art::Ptr< recob::PFParticle > > GetPFParticles(const art::Event &evt, const std::string &label)
Get the particles from the event.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
static std::vector< art::Ptr< recob::Slice > > GetSlices(const art::Event &evt, const std::string &label)
Get the slices from the event.