LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
Event.cxx
Go to the documentation of this file.
1 //
3 // \brief Definition of event object for LArSoft
4 //
5 // \author brebel@fnal.gov
6 //
9 
12 
13 #include <algorithm> // for std::sort
14 #include <iomanip>
15 #include <ostream>
16 
17 namespace recob {
18 
19  //----------------------------------------------------------------------
21 
22  //----------------------------------------------------------------------
23  Event::Event(int id) : fID(id) {}
24 
25  //----------------------------------------------------------------------
26  double Event::Energy() const
27  {
28  // loop over all vertex objects and get the
29  mf::LogWarning("Event") << "Event::Energy() is not yet defined. Need to decide "
30  << " how to calculate energy of Vertex"
31  << " Return util:kBogusD for now.";
32 
33  return util::kBogusD;
34  }
35 
36  //----------------------------------------------------------------------
37  double Event::SigmaEnergy() const
38  {
39  // loop over all vertex objects and get the
40  mf::LogWarning("Event") << "Event::SigmaEnergy() is not yet defined. Need to decide "
41  << " how to calculate uncertainty in energy of Prong/Vertex"
42  << " Return util:kBogusD for now.";
43 
44  return util::kBogusD;
45  }
46 
47  //----------------------------------------------------------------------
48  const recob::Vertex* Event::PrimaryVertex(std::vector<const recob::Vertex*>& vtxs) const
49  {
50  // sort the vertices, set the first one in z to be the primary
51  std::sort(vtxs.begin(), vtxs.end());
52  return vtxs.front();
53  }
54 
55  //----------------------------------------------------------------------
56  // ostream operator.
57  //
58  std::ostream& operator<<(std::ostream& o, const Event& a)
59  {
60 
61  o << std::setprecision(5);
62  o << "Event " << a.fID << std::setw(5) << " Energy = " << a.Energy() << " +/- "
63  << a.SigmaEnergy() << std::endl;
64 
65  return o;
66  }
67 
68  //----------------------------------------------------------------------
69  // < operator.
70  //
71  bool operator<(const Event& a, const Event& b)
72  {
73  return a.Energy() < b.Energy();
74  }
75 
76 }
int fID
id for this event
Definition: Event.h:25
Namespace for general, non-LArSoft-specific utilities.
Definition: PIDAAlg.h:26
Reconstruction base classes.
double Energy() const
Definition: Event.cxx:26
constexpr int kBogusI
obviously bogus integer value
Definition of vertex object for LArSoft.
Definition: Vertex.h:35
friend bool operator<(const Event &a, const Event &b)
Definition: Event.cxx:71
friend std::ostream & operator<<(std::ostream &o, const Event &a)
Definition: Event.cxx:58
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
double SigmaEnergy() const
Definition: Event.cxx:37
constexpr double kBogusD
obviously bogus double value
const recob::Vertex * PrimaryVertex(std::vector< const recob::Vertex * > &vtxs) const
Definition: Event.cxx:48
Collection of Physical constants used in LArSoft.