Jpp  16.0.3
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JPBSSequence.hh
Go to the documentation of this file.
1 #ifndef __JDB__JPBSSEQUENCE__
2 #define __JDB__JPBSSEQUENCE__
3 
4 #include <vector>
5 #include <algorithm>
6 #include <iterator>
7 
8 #include "JMath/JMath.hh"
9 
10 #include "JDB/JPBS_t.hh"
11 
12 
13 /**
14  * \author mdejong
15  */
16 namespace JDATABASE {}
17 namespace JPP { using namespace JDATABASE; }
18 
19 namespace JDATABASE {
20 
21  using JMATH::JMath;
22 
23 
24  /**
25  * Auxiliary data structure for a sequence of %PBS values.
26  *
27  * A sequence of %PBS values corresponds to the integration chain of a product,\n
28  * starting from the lowest integration level to the highest integration level.
29  */
30  struct JPBSSequence :
31  public std::vector<JPBS_t>
32  {
33  /**
34  * Default constructor.
35  */
37  {}
38 
39 
40  /**
41  * Constructor.
42  *
43  * \param pbs %PBS
44  */
45  JPBSSequence(const JPBS_t& pbs) :
46  std::vector<JPBS_t>(1, pbs)
47  {}
48 
49 
50  /**
51  * Constructor.
52  *
53  * \param input %PBS data
54  */
55  JPBSSequence(const std::initializer_list<JPBS_t>& input) :
56  std::vector<JPBS_t>(input)
57  {}
58 
59 
60  /**
61  * Chain %PBS sequences.
62  *
63  * \param first first %PBS sequence
64  * \param second second %PBS sequence
65  * \return combined %PBS sequence
66  */
67  friend inline JPBSSequence operator+(const JPBSSequence& first, const JPBSSequence& second)
68  {
69  using namespace std;
70 
71  JPBSSequence buffer(first);
72 
73  copy(second.begin(), second.end(), back_inserter(buffer));
74 
75  return buffer;
76  }
77  };
78 
79 
80  /**
81  * Auxiliary data structure for set of %PBS sequences.
82  *
83  * A set of %PBS sequences corresponds to all possible integration chains of a product,\n
84  * starting from the lowest integration level to the highest integration level.
85  */
86  struct JPBSSequences :
87  public std::vector<JPBSSequence>,
88  public JMath<JPBSSequences>
89  {
90  /**
91  * Default constructor.
92  */
94  {}
95 
96 
97  /**
98  * Constructor.
99  *
100  * \param input %PBS sequence
101  */
102  JPBSSequences(const JPBSSequence& input) :
103  std::vector<JPBSSequence>(1, input)
104  {}
105 
106 
107  /**
108  * Constructor.
109  *
110  * \param input %PBS sequence data
111  */
112  JPBSSequences(const std::initializer_list<JPBSSequences>& input)
113  {
114  using namespace std;
115 
116  for (std::initializer_list<JPBSSequences>::const_iterator i = input.begin(); i != input.end(); ++i) {
117  copy(i->begin(), i->end(), back_inserter(*this));
118  }
119  }
120 
121 
122  /**
123  * Add %PBS sequences.
124  *
125  * \param input %PBS sequences
126  * \return this %PBS sequences
127  */
129  {
130  for (JPBSSequences::const_iterator i = input.begin(); i != input.end(); ++i) {
131  this->push_back(*i);
132  }
133 
134  return *this;
135  }
136 
137 
138  /**
139  * Add %PBS to %PBS sequences.
140  *
141  * \param pbs %PBS
142  * \param input %PBS sequences
143  * \return %PBS sequences
144  */
145  friend inline JPBSSequences operator+(const JPBS_t& pbs, const JPBSSequences& input)
146  {
147  JPBSSequences buffer;
148 
149  for (JPBSSequences::const_iterator i = input.begin(); i != input.end(); ++i) {
150  buffer.push_back(pbs + *i);
151  }
152 
153  return buffer;
154  }
155  };
156 
157 
158  /**
159  * Name space to encapsulate %PBS values.
160  */
161  namespace PBS {
162 
163  /**
164  * %PBS sequences for detection unit.
165  */
168  };
169 
170  /**
171  * %PBS sequences for optical module.
172  */
173  static const JPBSSequences DOM_SEQUENCES = {
175  };
176 
177  /**
178  * %PBS sequences for base module.
179  */
180  static const JPBSSequences BASE_SEQUENCES = {
182  PBS::BASE_CONTAINER + PBS::DETECTION_UNIT_SEQUENCES
183  };
184 
185  /**
186  * %PBS sequences for central-logic board.
187  */
188  static const JPBSSequences CLB_SEQUENCES = {
191  };
192 
193  /**
194  * %PBS sequences for PMT.
195  */
196  static const JPBSSequences PMT_SEQUENCES = {
198  };
199 
200  /**
201  * %PBS sequences for AHRS.
202  */
203  static const JPBSSequences AHRS_SEQUENCES = {
205  };
206 
207  /**
208  * %PBS sequences for acoustic sensor.
209  */
212  };
213 
214  /**
215  * %PBS sequences for hydrophone.
216  */
219  };
220  }
221 
222 
223  /**
224  * Auxiliary class to get %PBS sequences as a function of %PBS.
225  */
227  public std::map<JPBS_t, JPBSSequences>
228  {
229  /**
230  * Default constructor.
231  */
233  {
235  (*this)[PBS::DOM] = PBS::DOM_SEQUENCES;
236  (*this)[PBS::BASE] = PBS::BASE_SEQUENCES;
237  (*this)[PBS::CLB] = PBS::CLB_SEQUENCES;
238  (*this)[PBS::PMT] = PBS::PMT_SEQUENCES;
239  (*this)[PBS::AHRS] = PBS::AHRS_SEQUENCES;
242  }
243 
244 
245  /**
246  * Get %PBS sequences for the given %PBS.
247  *
248  * \param pbs %PBS
249  * \return %PBS sequences
250  */
251  JPBSSequences operator()(const JPBS_t& pbs) const
252  {
253  const_iterator p = this->find(pbs);
254 
255  if (p != this->end()) {
256 
257  return p->second;
258 
259  } else {
260 
261  JPBSSequence buffer;
262 
263  for (JPBS_t i = pbs; !i.empty(); i.pop_back()) {
264  buffer.push_back(i);
265  }
266 
267  return buffer;
268  }
269  }
270  };
271 
272 
273  /**
274  * Function object to get %PBS sequences as a function of %PBS.
275  */
277 }
278 
279 #endif
280 
static const JPBSSequences DOM_SEQUENCES
PBS sequences for optical module.
static const JPBS_t BASE(3, 2)
PBS of detection unit base
Auxiliary base class for aritmetic operations of derived class types.
Definition: JMath.hh:110
static JGetPBSSequences getPBSSequences
Function object to get PBS sequences as a function of PBS.
friend JPBSSequences operator+(const JPBS_t &pbs, const JPBSSequences &input)
Add PBS to PBS sequences.
static const JPBS_t DOM(3, 4)
PBS of optical module
static const JPBS_t PMT(3, 4, 2, 3)
PBS of photo-multiplier tube (PMT)
static const JPBSSequences PMT_SEQUENCES
PBS sequences for PMT.
static const JPBSSequences ACOUSTIC_SENSOR_SEQUENCES
PBS sequences for acoustic sensor.
JPBSSequences()
Default constructor.
Definition: JPBSSequence.hh:93
JGetPBSSequences()
Default constructor.
static const JPBSSequences HYDROPHONE_SEQUENCES
PBS sequences for hydrophone.
JPBSSequence()
Default constructor.
Definition: JPBSSequence.hh:36
then echo The file $DIR KM3NeT_00000001_00000000 root already please rename or remove it first
static const JPBS_t CLB(3, 4, 3, 2)
PBS of central-logic board
Auxiliary class to get PBS sequences as a function of PBS.
static const JPBS_t ACOUSTIC_SENSOR(3, 4, 3, 6, 2)
PBS of piezo sensor
JPBSSequences(const JPBSSequence &input)
Constructor.
JPBSSequence(const std::initializer_list< JPBS_t > &input)
Constructor.
Definition: JPBSSequence.hh:55
Auxiliary data structure for a sequence of PBS values.
Definition: JPBSSequence.hh:30
JPBSSequence(const JPBS_t &pbs)
Constructor.
Definition: JPBSSequence.hh:45
static const JPBS_t BASE_CONTAINER(3, 2, 2)
PBS of detection unit base container
Auxiliary data structure for set of PBS sequences.
Definition: JPBSSequence.hh:86
static const JPBSSequences CLB_SEQUENCES
PBS sequences for central-logic board.
JPBSSequences & add(const JPBSSequences &input)
Add PBS sequences.
JPBSSequences operator()(const JPBS_t &pbs) const
Get PBS sequences for the given PBS.
static const JPBS_t DETECTION_UNIT(3)
PBS of detection unit
friend JPBSSequence operator+(const JPBSSequence &first, const JPBSSequence &second)
Chain PBS sequences.
Definition: JPBSSequence.hh:67
static const JPBSSequences AHRS_SEQUENCES
PBS sequences for AHRS.
static const JPBS_t HYDROPHONE(4, 5)
PBS of hydrophone
static const JPBSSequences BASE_SEQUENCES
PBS sequences for base module.
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:139
Base class for data structures with artithmetic capabilities.
Product breakdown structure (PBS).
Definition: JPBS_t.hh:25
static const JPBSSequences DETECTION_UNIT_SEQUENCES
PBS sequences for detection unit.
set_variable DETECTOR
JPBSSequences(const std::initializer_list< JPBSSequences > &input)
Constructor.
static const JPBS_t AHRS(3, 4, 3, 4)
PBS of compass