IWire.h
Go to the documentation of this file.
1 #ifndef WIRECELLIFACE_IWIRE
2 #define WIRECELLIFACE_IWIRE
3 
4 #include "WireCellUtil/Point.h"
5 #include "WireCellIface/IData.h"
8 
9 #include <set>
10 #include <map>
11 #include <vector>
12 #include <memory>
13 
14 namespace WireCell {
15 
16 
17  /// Interface to information about a physical wire segment.
18  class IWire : public IData<IWire> {
19  public:
20  virtual ~IWire();
21 
22  /// Detector-dependent, globally unique ID number. Negative
23  /// is illegal, not guaranteed consecutive.
24  virtual int ident() const = 0;
25 
26  /// The ID of the plane this wire is in
27  virtual WirePlaneId planeid() const = 0;
28 
29  /// Consecutive, zero-based index into an ordered sequence of
30  /// wires in their plane
31  virtual int index() const = 0;
32 
33  /// Detector-dependent electronics channel number, negative is
34  /// illegal. All wires with a common channel number are
35  /// considered electrically connected.
36  virtual int channel() const = 0;
37 
38  /// Return the number of wire segments between the channel
39  /// input and this wire. Wire directly attached to channel
40  /// input is segment==0.
41  virtual int segment() const = 0;
42 
43  /// Return the ray representing the wire segment.
44  // fixme: may want to change this to a const reference to save the copy
45  virtual WireCell::Ray ray() const = 0;
46 
47  /// Return the center point of the wire. Convenience method.
48  virtual WireCell::Point center() const;
49 
50  }; // class IWire
51 
53 
54  /// Some common collections.
55  typedef std::pair<IWire::pointer, IWire::pointer> IWirePair;
56 
57  // A set ordered by wire ident
59  bool operator()(const IWire::pointer& lhs, const IWire::pointer& rhs) const {
60  if (lhs->ident() == rhs->ident()) {
61  return lhs.get() < rhs.get(); // break tie with pointer
62  }
63  return lhs->ident() < rhs->ident();
64  }
65  };
66  typedef std::set<IWire::pointer, IWireCompareIdent> IWireSet;
67 
68  // Compare by wire index
70  bool operator()(const IWire::pointer& lhs, const IWire::pointer& rhs) const {
71  // fixme: should probably do something smarter here if two are not in same plane.....
72  if (lhs->index() == rhs->index()) {
73  return lhs.get() < rhs.get(); // break tie with pointer
74  }
75  return lhs->index() < rhs->index();
76  }
77  };
78  typedef std::set<IWire::pointer, IWireCompareIndex> IWireIndexSet;
79 
80  // A set ordered by wire segment
82  bool operator()(const IWire::pointer& lhs, const IWire::pointer& rhs) const {
83  if (lhs->segment() == rhs->segment()) {
84  return lhs.get() < rhs.get(); // break tie with pointer
85  }
86  return lhs->segment() < rhs->segment();
87  }
88  };
89  typedef std::set<IWire::pointer, IWireCompareSegment> IWireSegmentSet;
90 
91 }
92 
93 
94 #endif
std::pair< Point, Point > Ray
A line segment running from a first (tail) to a second (head) point.
Definition: Point.h:21
std::shared_ptr< const IWire > pointer
Definition: IData.h:19
virtual WireCell::Point center() const
Return the center point of the wire. Convenience method.
Definition: IWire.cxx:9
bool ascending_index(IWire::pointer lhs, IWire::pointer rhs)
Definition: IWire.cxx:16
std::set< IWire::pointer, IWireCompareSegment > IWireSegmentSet
Definition: IWire.h:89
virtual int ident() const =0
std::set< IWire::pointer, IWireCompareIdent > IWireSet
Definition: IWire.h:66
virtual int channel() const =0
std::set< IWire::pointer, IWireCompareIndex > IWireIndexSet
Definition: IWire.h:78
virtual int index() const =0
virtual WireCell::Ray ray() const =0
Return the ray representing the wire segment.
std::pair< IWire::pointer, IWire::pointer > IWirePair
Some common collections.
Definition: IWire.h:55
bool operator()(const IWire::pointer &lhs, const IWire::pointer &rhs) const
Definition: IWire.h:59
Interface to information about a physical wire segment.
Definition: IWire.h:18
bool operator()(const IWire::pointer &lhs, const IWire::pointer &rhs) const
Definition: IWire.h:82
bool operator()(const IWire::pointer &lhs, const IWire::pointer &rhs) const
Definition: IWire.h:70
Definition: Main.h:22
virtual WirePlaneId planeid() const =0
The ID of the plane this wire is in.
virtual int segment() const =0
virtual ~IWire()
Definition: IWire.cxx:4