Jpp  18.0.0-rc.4
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, const bool option=false)
 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...
 
void load (const char *const file_name, const std::string &separator=";")
 Load detector integration from CSV formatted input file. 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 &object)
 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 JDetectorIntegration_t::configure should be used to set up the integration data for a specific detector.

Definition at line 187 of file JDetectorIntegration_t.hh.

Member Typedef Documentation

Definition at line 192 of file JDetectorIntegration_t.hh.

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

Definition at line 194 of file JDetectorIntegration_t.hh.

Definition at line 195 of file JDetectorIntegration_t.hh.

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

Definition at line 196 of file JDetectorIntegration_t.hh.

Constructor & Destructor Documentation

JDATABASE::JDetectorIntegration_t::JDetectorIntegration_t ( )
inline

Default constructor.

Definition at line 202 of file JDetectorIntegration_t.hh.

203  {}

Member Function Documentation

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

Table name.

Definition at line 190 of file JDetectorIntegration_t.hh.

void JDATABASE::JDetectorIntegration_t::configure ( const std::string detid,
const bool  option = false 
)
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.

The option can be used to retain only those products that are part of the given detector.

Parameters
detiddetector identifier
optionoption

Definition at line 219 of file JDetectorIntegration_t.hh.

220  {
221  using namespace std;
222  using namespace JPP;
223 
224  up .clear();
225  down.clear();
226 
227  for (size_t index = 0; index != this->size(); ++index) {
228 
229  JProductIntegration_t& product = (*this)[index];
230 
231  product.unset();
232 
233  up .insert(make_pair(product.content .getUPI(), index));
234  down.insert(make_pair(product.container.getUPI(), index));
235  }
236 
237  for (iterator product = this->begin(); product != this->end(); ++product) {
238  if (product->operation == detid) {
239  configure(*product, JPeriod_t(product->start_date, product->end_date));
240  }
241  }
242 
243  if (option) {
244  this->erase(partition(this->begin(), this->end(), make_predicate(&JProductIntegration_t::is_set, true)), this->end());
245  }
246 
247  up .clear();
248  down.clear();
249 
250  for (size_t index = 0; index != this->size(); ++index) {
251 
252  const JProductIntegration_t& product = (*this)[index];
253 
254  if (product.is_set()) {
255  up .insert(make_pair(product.content .getUPI(), index));
256  down.insert(make_pair(product.container.getUPI(), index));
257  }
258  }
259  }
JPredicate< JResult_t T::*, JComparison::eq > make_predicate(JResult_t T::*member, const JResult_t value)
Helper method to create predicate for data member.
Definition: JPredicate.hh:128
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, const bool option=false)
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 269 of file JDetectorIntegration_t.hh.

271  {
272  using namespace std;
273 
274  if (upi.getPBS() >= pbs) {
275 
276  const range_type range = find(upi);
277 
278  switch (distance(range.first, range.second)) {
279 
280  case 1:
281  {
282  const JProductIntegration_t& product = (*this)[range.first->second];
283 
284  if (product.container.getPBS() == pbs)
285  return product;
286  else
287  return trace(product.container.getUPI(), pbs);
288  }
289 
290  case 0:
291  THROW(JDatabaseException, "Invalid UPI " << upi);
292 
293  default:
294  THROW(JDatabaseException, "Ambiguous integration of UPI " << upi);
295  }
296 
297  } else {
298 
299  THROW(JDatabaseException, "Invalid PBS " << upi.getPBS() << " < " << pbs);
300  }
301  }
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 310 of file JDetectorIntegration_t.hh.

311  {
312  using namespace std;
313 
315 
316  range = find(upi);
317 
318  for (map_type::const_iterator i = range.first; i != range.second; ++i) {
319 
320  out << upi << " -> ";
321 
322  print(out, (*this)[i->second]);
323  }
324 
325  range = down.equal_range(upi);
326 
327  for (range_iterator i = range.first; i != range.second; ++i) {
328  out << "<- " << (*this)[i->second] << endl;
329  }
330  }
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 339 of file JDetectorIntegration_t.hh.

340  {
341  using namespace std;
342 
343  out << product.container.getUPI() << ' '
344  //<< JPeriod_t(product.start_date, product.end_date) << ' '
345  << "-> ";
346 
347  const range_type range = find(product.container.getUPI());
348 
349  for (map_type::const_iterator i = range.first; i != range.second; ++i) {
350  print(out, (*this)[i->second]);
351  }
352 
353  if (distance(range.first, range.second) != 1) {
354  out << product.operation << std::endl;
355  }
356  }
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 $
void JDATABASE::JDetectorIntegration_t::load ( const char *const  file_name,
const std::string separator = ";" 
)
inline

Load detector integration from CSV formatted input file.

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

Parameters
file_namefile name
separatorseparator

Definition at line 394 of file JDetectorIntegration_t.hh.

395  {
396  using namespace std;
397  using namespace JPP;
398 
399  ifstream in(file_name);
400 
401  in.ignore(numeric_limits<streamsize>::max(), '\n');
402 
403  for (string buffer; getline(in, buffer); ) {
404 
405  istringstream is(buffer);
406 
407  const locale loc(is.getloc(), new JWhiteSpacesFacet(is.getloc(), separator));
408 
409  is.imbue(loc);
410 
412 
413  is >> buffer; istringstream(trim(buffer)) >> parameters.OPERATIONID;
414  is >> buffer; istringstream(trim(buffer)) >> parameters.CITY;
415  is >> buffer; istringstream(trim(buffer)) >> parameters.LOCATIONID;
416  is >> buffer; istringstream(trim(buffer)) >> parameters.LOGIN;
417  is >> buffer; istringstream(trim(buffer)) >> parameters.USERID;
418  is >> buffer; istringstream(trim(buffer)) >> parameters.STARTD;
419  is >> buffer; istringstream(trim(buffer)) >> parameters.ENDD;
420  is >> buffer; istringstream(trim(buffer)) >> parameters.CONTAINER_UPI;
421  is >> buffer; istringstream(trim(buffer)) >> parameters.POSITION;
422  is >> buffer; istringstream(trim(buffer)) >> parameters.CONTENT_UPI;
423 
424  const JProductIntegration_t product(parameters);
425 
426  this->up .insert(make_pair(product.content .getUPI(), this->size()));
427  this->down.insert(make_pair(product.container.getUPI(), this->size()));
428 
429  this->push_back(product);
430  }
431 
432  in.close();
433  }
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::ostream & separator(std::ostream &out)
Print separator.
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.
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 484 of file JDetectorIntegration_t.hh.

485  {
486  return up.equal_range(upi);
487  }
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 498 of file JDetectorIntegration_t.hh.

499  {
500  range_const_iterator p = up.lower_bound(JUPI_t(pbs));
501  range_const_iterator q = p;
502 
503  while (q != up.end() && (*this)[q->second].content.getPBS() <= pbs) {
504  ++q;
505  }
506 
507  return range_type(p,q);
508  }
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 519 of file JDetectorIntegration_t.hh.

520  {
521  return down.equal_range(upi);
522  }
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 533 of file JDetectorIntegration_t.hh.

534  {
535  using namespace std;
536 
537  product.set();
538 
539  map<int, int> zmap; // position -> index
540 
541  const range_type range = down.equal_range(product.content);
542 
543  for (range_iterator i = range.first; i != range.second; ++i) {
544 
545  const JProductIntegration_t& object = (*this)[i->second];
546 
547  if (object.start_date <= period.getLowerLimit()) {
548  if (zmap.count(object.position) == 0 || object.start_date > (*this)[zmap[object.position]].start_date) {
549  zmap[object.position] = i->second;
550  }
551  }
552  }
553 
554  for (map<int, int>::iterator i = zmap.begin(); i != zmap.end(); ++i) {
555  configure((*this)[i->second], period);
556  }
557  }
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, const bool option=false)
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 366 of file JDetectorIntegration_t.hh.

367  {
368  using namespace std;
369 
370  for (JProductIntegration parameters; rs >> parameters; ) {
371 
372  const JProductIntegration_t product(parameters);
373 
374  detector.up .insert(make_pair(product.content .getUPI(), detector.size()));
375  detector.down.insert(make_pair(product.container.getUPI(), detector.size()));
376 
377  detector.push_back(product);
378  }
379 
380  rs.Close();
381 
382  return true;
383  }
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 object 
)
friend

Read detector integration from input stream.

Parameters
ininput stream
objectdetector integration
Returns
input stream

Definition at line 443 of file JDetectorIntegration_t.hh.

444  {
445  using namespace std;
446 
447  for (JProductIntegration_t product; in >> product; ) {
448 
449  object.up .insert(make_pair(product.content .getUPI(), object.size()));
450  object.down.insert(make_pair(product.container.getUPI(), object.size()));
451 
452  object.push_back(product);
453  }
454 
455  return in;
456  }
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 466 of file JDetectorIntegration_t.hh.

467  {
468  for (const_iterator i = object.begin(); i != object.end(); ++i) {
469  out << *i << std::endl;
470  }
471 
472  return out;
473  }

Member Data Documentation

map_type JDATABASE::JDetectorIntegration_t::up
protected

up link UPI to integration data

Definition at line 559 of file JDetectorIntegration_t.hh.

map_type JDATABASE::JDetectorIntegration_t::down
protected

down link UPI to integration data

Definition at line 560 of file JDetectorIntegration_t.hh.


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