OfflineChan.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \file OfflineChan.h
3 /// \brief Simple object representing a (plane, cell) pair
4 ///
5 /// \version $Id: OfflineChan.h,v 1.1 2012-08-21 23:10:42 bckhouse Exp $
6 /// \author bckhouse@caltech.edu
7 ////////////////////////////////////////////////////////////////////////
8 
9 #ifndef GEO_OFFLINECHAN_H
10 #define GEO_OFFLINECHAN_H
11 
12 #include <ostream>
13 
14 namespace geo
15 {
16  /// A (plane, cell) pair
18  {
19  public:
20  OfflineChan() : fPlane(0), fCell(0) {}
21 
22 #ifndef __GCCXML__
23  OfflineChan(unsigned short plane, unsigned short cell)
24  : fPlane(plane), fCell(cell)
25  {
26  }
27 
29  int ToDBValidityChan() const;
30 
31  unsigned short Plane() const {return fPlane;}
32  unsigned short Cell() const {return fCell;}
33 
34  // Allowing this to be inlined makes a large performance improvement
35  bool operator==(const OfflineChan& rhs) const
36  { return fPlane == rhs.fPlane && fCell == rhs.fCell; }
37 #endif
38  // Allow this object to be stored in various sorted containers
39  bool operator<(const OfflineChan& rhs) const;
40  protected:
41  unsigned short fPlane, fCell;
42  };
43 
44  std::ostream& operator<<(std::ostream&, const OfflineChan&);
45 }
46 
47 #ifndef __GCCXML__
48 // This enables OfflineChans to be put in unsorted_map etc
49 namespace std {
50  template<>
51  struct hash<geo::OfflineChan>
52  {
53  public:
54  inline size_t operator()(const geo::OfflineChan& c) const
55  {
56  return c.ToDBValidityChan();
57  }
58  };
59 }
60 #endif
61 
62 #endif // GEO_OFFLINECHAN_H
63 
64 ////////////////////////////////////////////////////////////////////////
bool operator==(const OfflineChan &rhs) const
Definition: OfflineChan.h:35
int ToDBValidityChan() const
Definition: OfflineChan.cxx:19
std::ostream & operator<<(std::ostream &os, const OfflineChan &chan)
Definition: OfflineChan.cxx:35
unsigned short Plane() const
Definition: OfflineChan.h:31
size_t operator()(const geo::OfflineChan &c) const
Definition: OfflineChan.h:54
OfflineChan(unsigned short plane, unsigned short cell)
Definition: OfflineChan.h:23
unsigned short Cell() const
Definition: OfflineChan.h:32
unsigned short fCell
Definition: OfflineChan.h:41
A (plane, cell) pair.
Definition: OfflineChan.h:17
bool operator<(const OfflineChan &rhs) const
Definition: OfflineChan.cxx:27
unsigned short fPlane
Definition: OfflineChan.h:41
Helper for AttenCurve.
Definition: Path.h:10
static OfflineChan FromDBValidityChan(int chan)
Definition: OfflineChan.cxx:13