Jpp  18.6.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Public Attributes | Friends | List of all members
JCALIBRATE::JTDC_t Struct Reference

Auxiliary class for TDC constraints. More...

#include <JTDC_t.hh>

Inheritance diagram for JCALIBRATE::JTDC_t:
std::multimap< int, int >

Public Types

enum  { WILDCARD = -1 }
 Wild card for module identifier and TDC. More...
 
typedef std::multimap< int, int > multimap_type
 
typedef std::pair
< const_iterator,
const_iterator > 
range_type
 Type definition for range of TDC constraints of a given module identfier. More...
 

Public Member Functions

void insert (const value_type &value)
 Insert constraint. More...
 
void insert (const int id, const int tdc)
 Insert constraint. More...
 
range_type equal_range (const int id)
 Get range of constraints for given module. More...
 
bool has (const int id, const int tdc)
 Check if TDC is constraint. More...
 
void reverse ()
 Reverse constraints. More...
 
bool is_valid (const bool option=false) const
 Check validity of TDC constrants. More...
 

Public Attributes

JComment comment
 

Friends

std::istream & operator>> (std::istream &in, JTDC_t &tdc)
 Read TDC constraints from input. More...
 
std::ostream & operator<< (std::ostream &out, const JTDC_t &tdc)
 Write TDC constraints to output. More...
 

Detailed Description

Auxiliary class for TDC constraints.

Definition at line 37 of file JTDC_t.hh.

Member Typedef Documentation

Definition at line 40 of file JTDC_t.hh.

typedef std::pair<const_iterator, const_iterator> JCALIBRATE::JTDC_t::range_type

Type definition for range of TDC constraints of a given module identfier.

Definition at line 45 of file JTDC_t.hh.

Member Enumeration Documentation

anonymous enum

Wild card for module identifier and TDC.

Enumerator
WILDCARD 

Definition at line 51 of file JTDC_t.hh.

Member Function Documentation

void JCALIBRATE::JTDC_t::insert ( const value_type &  value)
inline

Insert constraint.

Note that if TDC equals JTDC_t::WILDCARD, all possible TDCs in the given module are inserted.

Parameters
valuemodule identifier and TDC

Definition at line 62 of file JTDC_t.hh.

63  {
64  if (value.second == WILDCARD) {
65 
66  for (int pmt = 0; pmt != NUMBER_OF_PMTS; ++pmt) {
67  multimap_type::insert(value_type(value.first, pmt));
68  }
69 
70  } else {
71 
72  multimap_type::insert(value);
73  }
74  }
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
Definition: JDAQ.hh:26
void JCALIBRATE::JTDC_t::insert ( const int  id,
const int  tdc 
)
inline

Insert constraint.

Note that if TDC equals JTDC_t::WILDCARD, all possible TDCs in the given module are inserted.

Parameters
idmodule identifier
tdcTDC

Definition at line 86 of file JTDC_t.hh.

87  {
88  this->insert(value_type(id, tdc));
89  }
void insert(const value_type &value)
Insert constraint.
Definition: JTDC_t.hh:62
range_type JCALIBRATE::JTDC_t::equal_range ( const int  id)
inline

Get range of constraints for given module.

Note that if no data are available for given module identifier, the data corresponding to JTDC_t::WILDCARD are returned.

Parameters
idmodule identifier
Returns
range of constraints

Definition at line 101 of file JTDC_t.hh.

102  {
103  range_type range = multimap_type::equal_range(id);
104 
105  if (range.first == range.second) {
106  range = multimap_type::equal_range(WILDCARD);
107  }
108 
109  return range;
110  }
z range($ZMAX-$ZMIN)< $MINIMAL_DZ." fi fi typeset -Z 4 STRING typeset -Z 2 FLOOR JPlot1D -f $
std::pair< const_iterator, const_iterator > range_type
Type definition for range of TDC constraints of a given module identfier.
Definition: JTDC_t.hh:45
bool JCALIBRATE::JTDC_t::has ( const int  id,
const int  tdc 
)
inline

Check if TDC is constraint.

Parameters
idmodule identifier
tdcTDC channel
Returns
true if given TDC is constraint; else false

Definition at line 120 of file JTDC_t.hh.

121  {
122  const range_type range = equal_range(id);
123 
124  for (JTDC_t::const_iterator i = range.first; i != range.second; ++i) {
125  if (tdc == i->second) {
126  return true;
127  }
128  }
129 
130  return false;
131  }
z range($ZMAX-$ZMIN)< $MINIMAL_DZ." fi fi typeset -Z 4 STRING typeset -Z 2 FLOOR JPlot1D -f $
std::pair< const_iterator, const_iterator > range_type
Type definition for range of TDC constraints of a given module identfier.
Definition: JTDC_t.hh:45
range_type equal_range(const int id)
Get range of constraints for given module.
Definition: JTDC_t.hh:101
void JCALIBRATE::JTDC_t::reverse ( )
inline

Reverse constraints.

Definition at line 137 of file JTDC_t.hh.

138  {
139  JTDC_t buffer;
140 
141  for (JTDC_t::const_iterator p = this->begin(); p != this->end(); ) {
142 
143  JTDC_t::const_iterator q = p;
144 
145  for ( ; q != this->end() && q->first == p->first; ++q) {}
146 
147  for (int pmt = 0; pmt != NUMBER_OF_PMTS; ++pmt) {
148 
149  JTDC_t::const_iterator i = p;
150 
151  for ( ; i != q && i->second != pmt; ++i) {}
152 
153  if (i == q) {
154  buffer.insert(value_type(p->first, pmt));
155  }
156  }
157 
158  p = q;
159  }
160 
161  this->swap(buffer);
162  }
Auxiliary class for TDC constraints.
Definition: JTDC_t.hh:37
void insert(const value_type &value)
Insert constraint.
Definition: JTDC_t.hh:62
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
Definition: JDAQ.hh:26
bool JCALIBRATE::JTDC_t::is_valid ( const bool  option = false) const
inline

Check validity of TDC constrants.

Parameters
optionoption (if true, throw exception if not valid)
Returns
true if valid; else false

Definition at line 171 of file JTDC_t.hh.

172  {
173  for (const_iterator i = this->begin(); i != this->end(); ++i) {
174 
175  if (i->first < WILDCARD) {
176 
177  if (option) {
178  THROW(JValueOutOfRange, "Invalid module identifier: " << i->first << " < " << WILDCARD);
179  }
180 
181  return false;
182  }
183 
184  if (i->second < 0 || i->second >= NUMBER_OF_PMTS) {
185 
186  if (option) {
187  THROW(JValueOutOfRange, "Invalid TDC: " << i->second << " {0, .., " << NUMBER_OF_PMTS - 1 << "}");
188  }
189 
190  return false;
191  }
192  }
193 
194  return true;
195  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
Definition: JDAQ.hh:26

Friends And Related Function Documentation

std::istream& operator>> ( std::istream &  in,
JTDC_t tdc 
)
friend

Read TDC constraints from input.

Parameters
ininput stream
tdcTDC constraints
Returns
input stream

Definition at line 205 of file JTDC_t.hh.

206  {
207  using namespace std;
208  using namespace JPP;
209 
210  JStringStream is(in);
211 
212  if (getFileStatus(is.str().c_str())) {
213  is.load();
214  }
215 
216  is >> tdc.comment;
217 
218  for (int id, pmt; is >> id >> pmt; ) {
219  tdc.insert(JTDC_t::value_type(id, pmt));
220  }
221 
222  return in;
223  }
is
Definition: JDAQCHSM.chsm:167
JComment comment
Definition: JTDC_t.hh:246
static JStat getFileStatus
Function object for file status.
Definition: JStat.hh:173
then fatal The output file must have the wildcard in the e g root fi 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
void insert(const value_type &value)
Insert constraint.
Definition: JTDC_t.hh:62
std::ostream& operator<< ( std::ostream &  out,
const JTDC_t tdc 
)
friend

Write TDC constraints to output.

Parameters
outoutput stream
tdcTDC constraints
Returns
output stream

Definition at line 233 of file JTDC_t.hh.

234  {
235  using namespace std;
236 
237  out << tdc.comment;
238 
239  for (JTDC_t::const_iterator i = tdc.begin(); i != tdc.end(); ++i) {
240  out << setw(10) << i->first << ' ' << setw(2) << i->second << endl;
241  }
242 
243  return out;
244  }
JComment comment
Definition: JTDC_t.hh:246

Member Data Documentation

JComment JCALIBRATE::JTDC_t::comment

Definition at line 246 of file JTDC_t.hh.


The documentation for this struct was generated from the following file: