Jpp
JPMTIdentifier_t.hh
Go to the documentation of this file.
1 #ifndef __JTRIGGER__JPMTIDENTIFIER_T__
2 #define __JTRIGGER__JPMTIDENTIFIER_T__
3 
4 #include <TROOT.h>
5 #include <TObject.h>
6 
8 
9 /**
10  * \author rgruiz
11  */
12 
13 namespace JTRIGGER {
14 
16 
17 
18  /*
19  * Auxiliary class to read the pmt identifiers from an ascii file to the trigger parameters
20  */
22  public TObject
23  {
24  public:
25  /**
26  * Default constructor.
27  */
29  moduleID (-1),
30  pmtAddress(-1)
31  {}
32 
33 
34  /**
35  * Constructor.
36  *
37  * \param id module identifier
38  * \param tdc PMT readout channel
39  */
40  JPMTIdentifier_t(int id , int tdc)
41  {
42  moduleID = id;
43  pmtAddress = tdc;
44  }
45 
46 
47  /**
48  * Copy constructor.
49  *
50  * \param id module identifier
51  * \param tdc PMT readout channel
52  */
54  {
55  moduleID = pmt.getModuleID();
56  pmtAddress = pmt.getPMTAddress();
57  }
58 
59 
60  /**
61  * Virtual destructor.
62  */
64  {}
65 
66 
67  /**
68  * Get module identifier.
69  *
70  * \return module identifier
71  */
72  int getModuleID() const
73  {
74  return moduleID;
75  }
76 
77 
78  /**
79  * Get PMT address.
80  *
81  * \return PMT address
82  */
83  int getPMTAddress() const
84  {
85  return pmtAddress;
86  }
87 
88 
89  /**
90  * Compare PMT identifiers.
91  *
92  * The comparison is applied to the module identifer and to the PMT address.
93  * If the module identifier or PMT address is <tt>-1</tt>, the corresponding comparison evaluates to <tt>true</tt>.
94  *
95  * \param first first PMT identifier
96  * \param second second PMT identifier
97  * \result true if first and second PMT identifier are equal; else false
98  */
99  static inline bool compare(const JPMTIdentifier_t& first, const JPMTIdentifier_t& second)
100  {
101  return ((first .getModuleID() == second.getModuleID() ||
102  first .getModuleID() == -1 ||
103  second.getModuleID() == -1)
104 
105  &&
106 
107  (first .getPMTAddress() == second.getPMTAddress() ||
108  first .getPMTAddress() == -1 ||
109  second.getPMTAddress() == -1));
110  }
111 
112 
113  /**
114  * Read PMT identifier from input.
115  *
116  * \param in input stream
117  * \param id PMT identifier
118  * \return input stream
119  */
120  friend inline std::istream& operator>>(std::istream& in, JPMTIdentifier_t& id)
121  {
122  in >> id.moduleID;
123  in >> id.pmtAddress;
124 
125  return in;
126  }
127 
128 
129  /**
130  * Write PMT identifier to output.
131  *
132  * \param out output stream
133  * \param id PMT identifier
134  * \return output stream
135  */
136  friend inline std::ostream& operator<<(std::ostream& out, const JPMTIdentifier_t& id)
137  {
138  out << id.moduleID << ' ';
139  out << id.pmtAddress;
140 
141  return out;
142  }
143 
144  /**
145  * Type conversion operator.
146  *
147  * \return PMT identifier
148  */
149  operator JDAQPMTIdentifier () const
150  {
152  }
153 
154 
156 
157  protected:
158  int moduleID;
160  };
161 
162 
163  /**
164  * Equal operator for PMT identifiers.
165  *
166  * \param first PMT identifier
167  * \param second PMT identifier
168  * \result true if first PMT equal second PMT; else false
169  */
170  inline bool operator==(const JPMTIdentifier_t& first, const JPMTIdentifier_t& second)
171  {
172  return (first.getModuleID() == second.getModuleID() &&
173  first.getPMTAddress() == second.getPMTAddress());
174  }
175 
176 
177  /**
178  * Less than operator for PMT identifiers.
179  *
180  * The less than operator is applied first to the module identifer and then to the PMT address.
181  *
182  * \param first PMT identifier
183  * \param second PMT identifier
184  * \result true if first PMT lower than second PMT; else false
185  */
186  inline bool operator<(const JPMTIdentifier_t& first, const JPMTIdentifier_t& second)
187  {
188  if (first.getModuleID() == second.getModuleID())
189  return first.getPMTAddress() < second.getPMTAddress();
190  else
191  return first.getModuleID() < second.getModuleID();
192  }
193 
194 }
195 
196 #endif
TObject
Definition: JRoot.hh:19
KM3NETDAQ::JDAQPMTIdentifier::getPMTAddress
int getPMTAddress() const
Get PMT identifier.
Definition: JDAQPMTIdentifier.hh:78
JTRIGGER::JPMTIdentifier_t::getPMTAddress
int getPMTAddress() const
Get PMT address.
Definition: JPMTIdentifier_t.hh:83
JTRIGGER::JPMTIdentifier_t::JPMTIdentifier_t
JPMTIdentifier_t()
Default constructor.
Definition: JPMTIdentifier_t.hh:28
JTRIGGER::JPMTIdentifier_t::moduleID
int moduleID
Definition: JPMTIdentifier_t.hh:158
KM3NETDAQ::JDAQModuleIdentifier::getModuleID
int getModuleID() const
Get module identifier.
Definition: JDAQModuleIdentifier.hh:72
JTRIGGER::JPMTIdentifier_t::operator<<
friend std::ostream & operator<<(std::ostream &out, const JPMTIdentifier_t &id)
Write PMT identifier to output.
Definition: JPMTIdentifier_t.hh:136
JTRIGGER::JPMTIdentifier_t::operator>>
friend std::istream & operator>>(std::istream &in, JPMTIdentifier_t &id)
Read PMT identifier from input.
Definition: JPMTIdentifier_t.hh:120
JTRIGGER::JPMTIdentifier_t::pmtAddress
int pmtAddress
Definition: JPMTIdentifier_t.hh:159
JTRIGGER::operator==
bool operator==(const JHit &first, const JHit &second)
Equal operator for hits.
Definition: JHit.hh:261
JTRIGGER::JPMTIdentifier_t::JPMTIdentifier_t
JPMTIdentifier_t(int id, int tdc)
Constructor.
Definition: JPMTIdentifier_t.hh:40
JTRIGGER::JPMTIdentifier_t::compare
static bool compare(const JPMTIdentifier_t &first, const JPMTIdentifier_t &second)
Compare PMT identifiers.
Definition: JPMTIdentifier_t.hh:99
KM3NETDAQ::JDAQPMTIdentifier
PMT identifier.
Definition: JDAQPMTIdentifier.hh:25
JTRIGGER::JPMTIdentifier_t::getModuleID
int getModuleID() const
Get module identifier.
Definition: JPMTIdentifier_t.hh:72
JTRIGGER::JPMTIdentifier_t::JPMTIdentifier_t
JPMTIdentifier_t(const JDAQPMTIdentifier &pmt)
Copy constructor.
Definition: JPMTIdentifier_t.hh:53
JTRIGGER::JPMTIdentifier_t
Definition: JPMTIdentifier_t.hh:21
JDAQPMTIdentifier.hh
JTRIGGER
Checksum.
Definition: JSupport/JSupport.hh:35
JTRIGGER::operator<
bool operator<(const JEvent &first, const JEvent &second)
Less than operator for events.
Definition: JEvent.hh:214
JTRIGGER::JPMTIdentifier_t::ClassDef
ClassDef(JPMTIdentifier_t, 8)
JTRIGGER::JPMTIdentifier_t::~JPMTIdentifier_t
virtual ~JPMTIdentifier_t()
Virtual destructor.
Definition: JPMTIdentifier_t.hh:63