Jpp  18.3.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 pmt PMT identifier
51  */
53  {
54  moduleID = pmt.getModuleID();
55  pmtAddress = pmt.getPMTAddress();
56  }
57 
58 
59  /**
60  * Virtual destructor.
61  */
63  {}
64 
65 
66  /**
67  * Get module identifier.
68  *
69  * \return module identifier
70  */
71  int getModuleID() const
72  {
73  return moduleID;
74  }
75 
76 
77  /**
78  * Get PMT address.
79  *
80  * \return PMT address
81  */
82  int getPMTAddress() const
83  {
84  return pmtAddress;
85  }
86 
87 
88  /**
89  * Compare PMT identifiers.
90  *
91  * The comparison is applied to the module identifer and to the PMT address.
92  * If the module identifier or PMT address is <tt>-1</tt>, the corresponding comparison evaluates to <tt>true</tt>.
93  *
94  * \param first first PMT identifier
95  * \param second second PMT identifier
96  * \result true if first and second PMT identifier are equal; else false
97  */
98  static inline bool compare(const JPMTIdentifier_t& first, const JPMTIdentifier_t& second)
99  {
100  return ((first .getModuleID() == second.getModuleID() ||
101  first .getModuleID() == -1 ||
102  second.getModuleID() == -1)
103 
104  &&
105 
106  (first .getPMTAddress() == second.getPMTAddress() ||
107  first .getPMTAddress() == -1 ||
108  second.getPMTAddress() == -1));
109  }
110 
111 
112  /**
113  * Read PMT identifier from input.
114  *
115  * \param in input stream
116  * \param id PMT identifier
117  * \return input stream
118  */
119  friend inline std::istream& operator>>(std::istream& in, JPMTIdentifier_t& id)
120  {
121  in >> id.moduleID;
122  in >> id.pmtAddress;
123 
124  return in;
125  }
126 
127 
128  /**
129  * Write PMT identifier to output.
130  *
131  * \param out output stream
132  * \param id PMT identifier
133  * \return output stream
134  */
135  friend inline std::ostream& operator<<(std::ostream& out, const JPMTIdentifier_t& id)
136  {
137  out << id.moduleID << ' ';
138  out << id.pmtAddress;
139 
140  return out;
141  }
142 
143  /**
144  * Type conversion operator.
145  *
146  * \return PMT identifier
147  */
148  operator JDAQPMTIdentifier () const
149  {
151  }
152 
153 
155 
156  protected:
157  int moduleID;
159  };
160 
161 
162  /**
163  * Equal operator for PMT identifiers.
164  *
165  * \param first PMT identifier
166  * \param second PMT identifier
167  * \result true if first PMT equal second PMT; else false
168  */
169  inline bool operator==(const JPMTIdentifier_t& first, const JPMTIdentifier_t& second)
170  {
171  return (first.getModuleID() == second.getModuleID() &&
172  first.getPMTAddress() == second.getPMTAddress());
173  }
174 
175 
176  /**
177  * Less than operator for PMT identifiers.
178  *
179  * The less than operator is applied first to the module identifer and then to the PMT address.
180  *
181  * \param first PMT identifier
182  * \param second PMT identifier
183  * \result true if first PMT lower than second PMT; else false
184  */
185  inline bool operator<(const JPMTIdentifier_t& first, const JPMTIdentifier_t& second)
186  {
187  if (first.getModuleID() == second.getModuleID())
188  return first.getPMTAddress() < second.getPMTAddress();
189  else
190  return first.getModuleID() < second.getModuleID();
191  }
192 
193 }
194 
195 #endif
ClassDef(JPMTIdentifier_t, 8)
bool operator<(const JEvent &first, const JEvent &second)
Less than operator for events.
int getModuleID() const
Get module identifier.
bool operator==(const JHit &first, const JHit &second)
Equal operator for hits.
JPMTIdentifier_t()
Default constructor.
Definition: JRoot.hh:19
friend std::ostream & operator<<(std::ostream &out, const JPMTIdentifier_t &id)
Write PMT identifier to output.
then echo The file $DIR KM3NeT_00000001_00000000 root already please rename or remove it first
int getPMTAddress() const
Get PMT identifier.
friend std::istream & operator>>(std::istream &in, JPMTIdentifier_t &id)
Read PMT identifier from input.
static bool compare(const JPMTIdentifier_t &first, const JPMTIdentifier_t &second)
Compare PMT identifiers.
JPMTIdentifier_t(int id, int tdc)
Constructor.
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:48
int getPMTAddress() const
Get PMT address.
JPMTIdentifier_t(const JDAQPMTIdentifier &pmt)
Copy constructor.
int getModuleID() const
Get module identifier.
virtual ~JPMTIdentifier_t()
Virtual destructor.