Jpp - the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | 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  { WILD_CARD = -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...
 
void reverse ()
 Reverse constraints. More...
 
bool is_valid (const bool option=false) const
 Check validity of TDC constrants. More...
 

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 34 of file JTDC_t.hh.

Member Typedef Documentation

Definition at line 37 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 42 of file JTDC_t.hh.

Member Enumeration Documentation

anonymous enum

Wild card for module identifier and TDC.

Enumerator
WILD_CARD 

Definition at line 48 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::WILD_CARD, all possible TDCs in the given module are inserted.

Parameters
valuemodule identifier and TDC

Definition at line 59 of file JTDC_t.hh.

60  {
61  if (value.second == WILD_CARD) {
62 
63  for (int pmt = 0; pmt != NUMBER_OF_PMTS; ++pmt) {
64  multimap_type::insert(value_type(value.first, pmt));
65  }
66 
67  } else {
68 
69  multimap_type::insert(value);
70  }
71  }
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::WILD_CARD, all possible TDCs in the given module are inserted.

Parameters
idmodule identifier
tdcTDC

Definition at line 83 of file JTDC_t.hh.

84  {
85  this->insert(value_type(id, tdc));
86  }
void insert(const value_type &value)
Insert constraint.
Definition: JTDC_t.hh:59
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::WILD_CARD are returned.

Parameters
idmodule identifier
Returns
range of constraints

Definition at line 98 of file JTDC_t.hh.

99  {
100  range_type range = multimap_type::equal_range(id);
101 
102  if (range.first == range.second) {
103  range = multimap_type::equal_range(WILD_CARD);
104  }
105 
106  return range;
107  }
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:42
void JCALIBRATE::JTDC_t::reverse ( )
inline

Reverse constraints.

Definition at line 113 of file JTDC_t.hh.

114  {
115  JTDC_t buffer;
116 
117  for (JTDC_t::const_iterator p = this->begin(); p != this->end(); ) {
118 
119  JTDC_t::const_iterator q = p;
120 
121  for ( ; q != this->end() && q->first == p->first; ++q) {}
122 
123  for (int pmt = 0; pmt != NUMBER_OF_PMTS; ++pmt) {
124 
125  JTDC_t::const_iterator i = p;
126 
127  for ( ; i != q && i->second != pmt; ++i) {}
128 
129  if (i == q) {
130  buffer.insert(value_type(p->first, pmt));
131  }
132  }
133 
134  p = q;
135  }
136 
137  this->swap(buffer);
138  }
Auxiliary class for TDC constraints.
Definition: JTDC_t.hh:34
void insert(const value_type &value)
Insert constraint.
Definition: JTDC_t.hh:59
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 147 of file JTDC_t.hh.

148  {
149  for (const_iterator i = this->begin(); i != this->end(); ++i) {
150 
151  if (i->first < WILD_CARD) {
152 
153  if (option) {
154  THROW(JValueOutOfRange, "Invalid module identifier: " << i->first << " < " << WILD_CARD);
155  }
156 
157  return false;
158  }
159 
160  if (i->second < 0 || i->second >= NUMBER_OF_PMTS) {
161 
162  if (option) {
163  THROW(JValueOutOfRange, "Invalid TDC: " << i->second << " {0, .., " << NUMBER_OF_PMTS - 1 << "}");
164  }
165 
166  return false;
167  }
168  }
169 
170  return true;
171  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:670
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 181 of file JTDC_t.hh.

182  {
183  using namespace std;
184  using namespace JPP;
185 
186  JStringStream is(in);
187 
188  if (getFileStatus(is.str().c_str())) {
189  is.load();
190  }
191 
192  for (int id, pmt; is >> id >> pmt; ) {
193  tdc.insert(JTDC_t::value_type(id, pmt));
194  }
195 
196  return in;
197  }
is
Definition: JDAQCHSM.chsm:167
static JStat getFileStatus
Function object for file status.
Definition: JStat.hh:173
void insert(const value_type &value)
Insert constraint.
Definition: JTDC_t.hh:59
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 source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:38
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 207 of file JTDC_t.hh.

208  {
209  for (JTDC_t::const_iterator i = tdc.begin(); i != tdc.end(); ++i) {
210  out << ' ' << i->first
211  << ' ' << i->second;
212  }
213 
214  return out;
215  }

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