Jpp  17.0.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 | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
JDATABASE::JDetectorIntegration_t Struct Reference

Detector integration. More...

#include <JDetectorIntegration_t.hh>

Inheritance diagram for JDATABASE::JDetectorIntegration_t:
std::vector< JProductIntegration_t >

Public Types

typedef std::multimap< JUPI_t,
int > 
map_type
 
typedef std::pair
< map_type::const_iterator,
map_type::const_iterator > 
range_type
 
typedef map_type::const_iterator range_const_iterator
 
typedef map_type::const_iterator range_iterator
 

Public Member Functions

 JDetectorIntegration_t ()
 Default constructor. More...
 
void configure (const std::string &detid)
 Configure detector integration for given detector identifier. More...
 
const JProductIntegration_ttrace (const JUPI_t &upi, const JPBS_t &pbs=PBS::DETECTOR) const
 Trace product up to given integration level. More...
 
void print (std::ostream &out, const JUPI_t &upi) const
 Print product trace. More...
 
void print (std::ostream &out, const JProductIntegration_t &product) const
 Print product trace. More...
 
range_type find (const JUPI_t &upi) const
 Find range of products with given UPI. More...
 
range_type find (const JPBS_t &pbs) const
 Find range of products with given PBS. More...
 
range_type get (const JUPI_t &upi) const
 Get components of product with given UPI. More...
 

Static Public Member Functions

static const char *const getName ()
 Table name. More...
 

Protected Member Functions

void configure (JProductIntegration_t &product, const JPeriod_t &period)
 Configure detector integration for given detector identifier. More...
 

Protected Attributes

map_type up
 up link UPI to integration data More...
 
map_type down
 down link UPI to integration data More...
 

Friends

bool operator>> (ResultSet &rs, JDetectorIntegration_t &detector)
 Read detector integration from result set. More...
 
std::istream & operator>> (std::istream &in, JDetectorIntegration_t &detector)
 Read detector integration from input stream. More...
 
std::ostream & operator<< (std::ostream &out, const JDetectorIntegration_t &object)
 Write detector integration to output stream. More...
 

Detailed Description

Detector integration.

This class is used

Note that the method configure should be used to set up the integration data for a specific detector.

Definition at line 162 of file JDetectorIntegration_t.hh.

Member Typedef Documentation

Definition at line 167 of file JDetectorIntegration_t.hh.

typedef std::pair<map_type::const_iterator, map_type::const_iterator> JDATABASE::JDetectorIntegration_t::range_type

Definition at line 169 of file JDetectorIntegration_t.hh.

Definition at line 170 of file JDetectorIntegration_t.hh.

typedef map_type::const_iterator JDATABASE::JDetectorIntegration_t::range_iterator

Definition at line 171 of file JDetectorIntegration_t.hh.

Constructor & Destructor Documentation

JDATABASE::JDetectorIntegration_t::JDetectorIntegration_t ( )
inline

Default constructor.

Definition at line 177 of file JDetectorIntegration_t.hh.

178  {}

Member Function Documentation

static const char* const JDATABASE::JDetectorIntegration_t::getName ( )
inlinestatic

Table name.

Definition at line 165 of file JDetectorIntegration_t.hh.

void JDATABASE::JDetectorIntegration_t::configure ( const std::string &  detid)
inline

Configure detector integration for given detector identifier.

The components of the given detector are selected based on the following rules:

  1. the component should have a start date before that of the given detector;
  2. if multiple components appear at the same place in the same container, the one with the latest start date is taken.
Parameters
detiddetector identifier

Definition at line 191 of file JDetectorIntegration_t.hh.

192  {
193  using namespace std;
194 
195  up .clear();
196  down.clear();
197 
198  for (size_t index = 0; index != this->size(); ++index) {
199 
200  JProductIntegration_t& product = (*this)[index];
201 
202  product.unset();
203 
204  up .insert(make_pair(product.content .getUPI(), index));
205  down.insert(make_pair(product.container.getUPI(), index));
206  }
207 
208  for (iterator product = this->begin(); product != this->end(); ++product) {
209  if (product->operation == detid) {
210  configure(*product, JPeriod_t(product->start_date, product->end_date));
211  }
212  }
213 
214  up .clear();
215  down.clear();
216 
217  for (size_t index = 0; index != this->size(); ++index) {
218 
219  const JProductIntegration_t& product = (*this)[index];
220 
221  if (product.is_set()) {
222  up .insert(make_pair(product.content .getUPI(), index));
223  down.insert(make_pair(product.container.getUPI(), index));
224  }
225  }
226  }
void unset()
Unset product status.
map_type up
up link UPI to integration data
const JUPI_t & getUPI() const
Get UPI.
Definition: JUPI_t.hh:97
JTOOLS::JRange< JDate_t > JPeriod_t
Type definition of period.
map_type down
down link UPI to integration data
bool is_set() const
Check product status.
void configure(const std::string &detid)
Configure detector integration for given detector identifier.
Auxiliary class for product integration data.
const JProductIntegration_t& JDATABASE::JDetectorIntegration_t::trace ( const JUPI_t upi,
const JPBS_t pbs = PBS::DETECTOR 
) const
inline

Trace product up to given integration level.

Parameters
upiUPI
pbsPBS
Returns
product

Definition at line 236 of file JDetectorIntegration_t.hh.

238  {
239  using namespace std;
240 
241  if (upi.getPBS() >= pbs) {
242 
243  const range_type range = find(upi);
244 
245  switch (distance(range.first, range.second)) {
246 
247  case 1:
248  {
249  const JProductIntegration_t& product = (*this)[range.first->second];
250 
251  if (product.container.getPBS() == pbs)
252  return product;
253  else
254  return trace(product.container.getUPI(), pbs);
255  }
256 
257  case 0:
258  THROW(JDatabaseException, "Invalid UPI " << upi);
259 
260  default:
261  THROW(JDatabaseException, "Ambiguous integration of UPI " << upi);
262  }
263 
264  } else {
265 
266  THROW(JDatabaseException, "Invalid PBS " << upi.getPBS() << " < " << pbs);
267  }
268  }
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:696
const JPBS_t & getPBS() const
Get PBS.
Definition: JPBS_t.hh:101
const JUPI_t & getUPI() const
Get UPI.
Definition: JUPI_t.hh:97
std::pair< map_type::const_iterator, map_type::const_iterator > range_type
const JProductIntegration_t & trace(const JUPI_t &upi, const JPBS_t &pbs=PBS::DETECTOR) const
Trace product up to given integration level.
range_type find(const JUPI_t &upi) const
Find range of products with given UPI.
z range($ZMAX-$ZMIN)< $MINIMAL_DZ." fi fi typeset -Z 4 STRING typeset -Z 2 FLOOR JPlot1D -f $
Auxiliary class for product integration data.
void JDATABASE::JDetectorIntegration_t::print ( std::ostream &  out,
const JUPI_t upi 
) const
inline

Print product trace.

Parameters
outoutput stream
upiUPI

Definition at line 277 of file JDetectorIntegration_t.hh.

278  {
279  using namespace std;
280 
282 
283  range = find(upi);
284 
285  for (map_type::const_iterator i = range.first; i != range.second; ++i) {
286 
287  out << upi << " -> ";
288 
289  print(out, (*this)[i->second]);
290  }
291 
292  range = down.equal_range(upi);
293 
294  for (range_iterator i = range.first; i != range.second; ++i) {
295  out << "<- " << (*this)[i->second] << endl;
296  }
297  }
void print(std::ostream &out, const JUPI_t &upi) const
Print product trace.
std::pair< map_type::const_iterator, map_type::const_iterator > range_type
range_type find(const JUPI_t &upi) const
Find range of products with given UPI.
z range($ZMAX-$ZMIN)< $MINIMAL_DZ." fi fi typeset -Z 4 STRING typeset -Z 2 FLOOR JPlot1D -f $
map_type down
down link UPI to integration data
void JDATABASE::JDetectorIntegration_t::print ( std::ostream &  out,
const JProductIntegration_t product 
) const
inline

Print product trace.

Parameters
outoutput stream
productproduct

Definition at line 306 of file JDetectorIntegration_t.hh.

307  {
308  using namespace std;
309 
310  out << product.container.getUPI() << ' '
311  //<< JPeriod_t(product.start_date, product.end_date) << ' '
312  << "-> ";
313 
314  const range_type range = find(product.container.getUPI());
315 
316  for (map_type::const_iterator i = range.first; i != range.second; ++i) {
317  print(out, (*this)[i->second]);
318  }
319 
320  if (distance(range.first, range.second) != 1) {
321  out << product.operation << std::endl;
322  }
323  }
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
void print(std::ostream &out, const JUPI_t &upi) const
Print product trace.
const JUPI_t & getUPI() const
Get UPI.
Definition: JUPI_t.hh:97
std::pair< map_type::const_iterator, map_type::const_iterator > range_type
range_type find(const JUPI_t &upi) const
Find range of products with given UPI.
z range($ZMAX-$ZMIN)< $MINIMAL_DZ." fi fi typeset -Z 4 STRING typeset -Z 2 FLOOR JPlot1D -f $
range_type JDATABASE::JDetectorIntegration_t::find ( const JUPI_t upi) const
inline

Find range of products with given UPI.


The returned range corresponds to the usual begin and end iterators, each pointing to an STL pair consisting of a UPI and index.

Parameters
upiUPI
Returns
index

Definition at line 427 of file JDetectorIntegration_t.hh.

428  {
429  return up.equal_range(upi);
430  }
map_type up
up link UPI to integration data
range_type JDATABASE::JDetectorIntegration_t::find ( const JPBS_t pbs) const
inline

Find range of products with given PBS.


The returned range corresponds to the usual begin and end iterators, each pointing to an STL pair consisting of a UPI and index.

Parameters
pbsPBS
Returns
range

Definition at line 441 of file JDetectorIntegration_t.hh.

442  {
443  range_const_iterator p = up.lower_bound(JUPI_t(pbs));
444  range_const_iterator q = p;
445 
446  while (q != up.end() && (*this)[q->second].content.getPBS() <= pbs) {
447  ++q;
448  }
449 
450  return range_type(p,q);
451  }
map_type up
up link UPI to integration data
Universal product identifier (UPI).
Definition: JUPI_t.hh:29
std::pair< map_type::const_iterator, map_type::const_iterator > range_type
map_type::const_iterator range_const_iterator
range_type JDATABASE::JDetectorIntegration_t::get ( const JUPI_t upi) const
inline

Get components of product with given UPI.


The returned range corresponds to the usual begin and end iterators, each pointing to an STL pair consisting of a UPI and index.

Parameters
upiUPI
Returns
index

Definition at line 462 of file JDetectorIntegration_t.hh.

463  {
464  return down.equal_range(upi);
465  }
map_type down
down link UPI to integration data
void JDATABASE::JDetectorIntegration_t::configure ( JProductIntegration_t product,
const JPeriod_t period 
)
inlineprotected

Configure detector integration for given detector identifier.


This method recursively sets the status all related products.

Parameters
productproduct
periodvalidity period

Definition at line 476 of file JDetectorIntegration_t.hh.

477  {
478  using namespace std;
479 
480  product.set();
481 
482  map<int, int> zmap; // position -> index
483 
484  const range_type range = down.equal_range(product.content);
485 
486  for (range_iterator i = range.first; i != range.second; ++i) {
487 
488  const JProductIntegration_t& object = (*this)[i->second];
489 
490  if (object.start_date <= period.getLowerLimit()) {
491  if (zmap.count(object.position) == 0 || object.start_date > (*this)[zmap[object.position]].start_date) {
492  zmap[object.position] = i->second;
493  }
494  }
495  }
496 
497  for (map<int, int>::iterator i = zmap.begin(); i != zmap.end(); ++i) {
498  configure((*this)[i->second], period);
499  }
500  }
T getLowerLimit() const
Get lower limit.
Definition: JRange.hh:202
std::pair< map_type::const_iterator, map_type::const_iterator > range_type
z range($ZMAX-$ZMIN)< $MINIMAL_DZ." fi fi typeset -Z 4 STRING typeset -Z 2 FLOOR JPlot1D -f $
map_type down
down link UPI to integration data
void configure(const std::string &detid)
Configure detector integration for given detector identifier.
Auxiliary class for product integration data.

Friends And Related Function Documentation

bool operator>> ( ResultSet &  rs,
JDetectorIntegration_t detector 
)
friend

Read detector integration from result set.

Parameters
rsresult set
detectordetector
Returns
true if read; else false

Definition at line 333 of file JDetectorIntegration_t.hh.

334  {
335  using namespace std;
336 
337  for (JProductIntegration parameters; rs >> parameters; ) {
338 
339  const JProductIntegration_t product(parameters);
340 
341  detector.up .insert(make_pair(product.content .getUPI(), detector.size()));
342  detector.down.insert(make_pair(product.container.getUPI(), detector.size()));
343 
344  detector.push_back(product);
345  }
346 
347  rs.Close();
348 
349  return true;
350  }
map_type up
up link UPI to integration data
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
Definition: diff-Tuna.sh:38
map_type down
down link UPI to integration data
Auxiliary class for product integration data.
std::istream& operator>> ( std::istream &  in,
JDetectorIntegration_t detector 
)
friend

Read detector integration from input stream.

The input should be conform output of JPrintDB -q "integration" -c ";" -W1.

Parameters
ininput stream
detectordetector integration
Returns
input stream

Definition at line 362 of file JDetectorIntegration_t.hh.

363  {
364  using namespace std;
365  using namespace JPP;
366 
367  in.ignore(numeric_limits<streamsize>::max(), '\n');
368 
369  for (string buffer; getline(in, buffer); ) {
370 
371  istringstream is(buffer);
372 
373  const locale loc(is.getloc(), new JWhiteSpacesFacet(is.getloc(), ";"));
374 
375  is.imbue(loc);
376 
378 
379  is >> buffer; istringstream(trim(buffer)) >> parameters.OPERATIONID;
380  is >> buffer; istringstream(trim(buffer)) >> parameters.CITY;
381  is >> buffer; istringstream(trim(buffer)) >> parameters.LOCATIONID;
382  is >> buffer; istringstream(trim(buffer)) >> parameters.LOGIN;
383  is >> buffer; istringstream(trim(buffer)) >> parameters.USERID;
384  is >> buffer; istringstream(trim(buffer)) >> parameters.STARTD;
385  is >> buffer; istringstream(trim(buffer)) >> parameters.ENDD;
386  is >> buffer; istringstream(trim(buffer)) >> parameters.CONTAINER_UPI;
387  is >> buffer; istringstream(trim(buffer)) >> parameters.POSITION;
388  is >> buffer; istringstream(trim(buffer)) >> parameters.CONTENT_UPI;
389 
390  const JProductIntegration_t product(parameters);
391 
392  detector.up .insert(make_pair(product.content .getUPI(), detector.size()));
393  detector.down.insert(make_pair(product.container.getUPI(), detector.size()));
394 
395  detector.push_back(product);
396  }
397 
398  return in;
399  }
map_type up
up link UPI to integration data
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
Definition: diff-Tuna.sh:38
is
Definition: JDAQCHSM.chsm:167
std::string trim(const std::string &buffer)
Trim string.
Definition: JLangToolkit.hh:79
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
Definition: JString.hh:478
map_type down
down link UPI to integration data
char * loc(char *orig)
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:46
Auxiliary class for product integration data.
std::ostream& operator<< ( std::ostream &  out,
const JDetectorIntegration_t object 
)
friend

Write detector integration to output stream.

Parameters
outoutput stream
objectdetector integration
Returns
output stream

Definition at line 409 of file JDetectorIntegration_t.hh.

410  {
411  for (const_iterator i = object.begin(); i != object.end(); ++i) {
412  out << *i << std::endl;
413  }
414 
415  return out;
416  }

Member Data Documentation

map_type JDATABASE::JDetectorIntegration_t::up
protected

up link UPI to integration data

Definition at line 502 of file JDetectorIntegration_t.hh.

map_type JDATABASE::JDetectorIntegration_t::down
protected

down link UPI to integration data

Definition at line 503 of file JDetectorIntegration_t.hh.


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