LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
Exceptions.h
Go to the documentation of this file.
1 
15 #ifndef LARCOREALG_GEOMETRY_EXCEPTIONS_H
16 #define LARCOREALG_GEOMETRY_EXCEPTIONS_H
17 
18 
19 // LArSoft libraries
20 #include "larcoreobj/SimpleTypesAndConstants/geo_types.h" // geo::PlaneID, ...
21 
22 // Framework libraries
23 #include "cetlib_except/exception.h"
24 
25 // C/C++ standard library
26 #include <limits> // std::numeric_limits<>
27 
28 
29 namespace geo {
30 
43  public:
44 
46  static constexpr int InvalidWireNo = std::numeric_limits<int>::max();
47 
48 
51  InvalidWireError(std::string cat): cet::exception(cat) {}
52 
55  std::string cat,
56  geo::PlaneID const& planeID,
57  int badWireNo,
58  int betterWireNo
59  )
60  : cet::exception(cat)
61  , fPlaneID(planeID)
62  , fWireNumber(badWireNo)
63  , fBetterWireNo(betterWireNo)
64  {}
65 
68  (std::string cat, geo::PlaneID const& planeID, int badWireNo)
69  : cet::exception(cat)
70  , fPlaneID(planeID)
71  , fWireNumber(badWireNo)
72  {}
73 
76  std::string cat,
77  int badWireNo,
78  int betterWireNo
79  )
80  : cet::exception(cat)
81  , fWireNumber(badWireNo)
82  , fBetterWireNo(betterWireNo)
83  {}
84 
87  std::string cat,
88  int badWireNo
89  )
90  : cet::exception(cat)
91  , fWireNumber(badWireNo)
92  {}
93 
94 
97 
99  bool hasBadWire() const { return fWireNumber != InvalidWireNo; }
100 
102  int badWire() const { return fWireNumber; }
103 
106 
108 
109 
112 
114  bool hasSuggestedWire() const { return fBetterWireNo != InvalidWireNo; }
115 
117  int suggestedWire() const { return fBetterWireNo; }
118 
121 
123 
124 
127 
129  bool hasPlane() const { return fPlaneID.isValid; }
130 
132  geo::PlaneID const& planeID() const { return fPlaneID; }
133 
135 
136  private:
138 
141 
144 
146  geo::WireID makeWireID(int wireNo) const
147  { return { fPlaneID, (geo::WireID::WireID_t) wireNo }; }
148 
149 
150  }; // class InvalidWireError
151 
152 
159  public:
160  InvalidWireIDError(std::string cat): cet::exception(cat) {}
161 
162  InvalidWireIDError(std::string cat, int bad_wire, int better_wire = -1):
163  cet::exception(cat),
164  wire_number(bad_wire), better_wire_number(better_wire)
165  {}
166 
167  int wire_number = -1;
168  int better_wire_number = -1;
169  }; // class InvalidWireIDError
170 
171 
172 } // namespace geo
173 
174 #endif // LARCOREALG_GEOMETRY_EXCEPTIONS_H
int suggestedWire() const
Returns a better wire number.
Definition: Exceptions.h:117
bool hasBadWire() const
Returns whether we known the bad wire number.
Definition: Exceptions.h:99
The data type to uniquely identify a Plane.
Definition: geo_types.h:250
bool isValid
Whether this ID points to a valid element.
Definition: geo_types.h:129
int badWire() const
Returns the bad wire number.
Definition: Exceptions.h:102
InvalidWireError(std::string cat, int badWireNo, int betterWireNo)
Constructor: no plane information.
Definition: Exceptions.h:75
int fBetterWireNo
a suggestion for a good wire number
Definition: Exceptions.h:143
Int_t max
Definition: plot.C:27
InvalidWireIDError(std::string cat, int bad_wire, int better_wire=-1)
Definition: Exceptions.h:162
InvalidWireError(std::string cat, int badWireNo)
Constructor: no plane information and no suggestion.
Definition: Exceptions.h:86
InvalidWireError(std::string cat, geo::PlaneID const &planeID, int badWireNo, int betterWireNo)
Constructor with the complete information.
Definition: Exceptions.h:54
geo::PlaneID fPlaneID
plane the wire belongs to
Definition: Exceptions.h:137
geo::PlaneID const & planeID() const
Return the plane ID recorded with the exception.
Definition: Exceptions.h:132
Definition of data types for geometry description.
InvalidWireIDError(std::string cat)
Definition: Exceptions.h:160
geo::WireID badWireID() const
Returns the bad wire ID.
Definition: Exceptions.h:105
unsigned int WireID_t
Type for the ID number.
Definition: geo_types.h:306
InvalidWireError(std::string cat)
Definition: Exceptions.h:51
static constexpr int InvalidWireNo
Value used to represent an invalid wire number.
Definition: Exceptions.h:46
bool hasPlane() const
Return whether a plane is recorded with the exception.
Definition: Exceptions.h:129
geo::WireID makeWireID(int wireNo) const
Transform a wire number into wire ID.
Definition: Exceptions.h:146
Exception thrown on invalid wire number.
Definition: Exceptions.h:42
Exception thrown on invalid wire number (e.g. NearestWireID())
Definition: Exceptions.h:158
geo::WireID suggestedWireID() const
Returns a better wire ID.
Definition: Exceptions.h:120
Namespace collecting geometry-related classes utilities.
bool hasSuggestedWire() const
Returns whether we known a better wire number.
Definition: Exceptions.h:114
int fWireNumber
the invalid wire number
Definition: Exceptions.h:140
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33