Jpp
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
JDATABASE::JDetectorIntegration Struct Reference

Detector integration. More...

#include <JDetectorIntegration.hh>

Public Types

typedef std::multimap< JUPI, 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
 
typedef std::vector< JProductIntegration_tdata_type
 
typedef data_type::const_iterator const_iterator
 
typedef data_type::iterator iterator
 
typedef data_type::const_reverse_iterator const_reverse_iterator
 
typedef data_type::reverse_iterator reverse_iterator
 

Public Member Functions

 JDetectorIntegration ()
 Default constructor. More...
 
const_iterator begin () const
 begin of integration data More...
 
const_iterator end () const
 end of integration data More...
 
const_reverse_iterator rbegin () const
 reverse begin of integration data More...
 
const_reverse_iterator rend () const
 reverse end of integration data More...
 
bool empty () const
 check emptyness of integration data More...
 
size_t size () const
 size of integration data More...
 
const JProductIntegration_toperator[] (const int index) const
 Get product at given index. More...
 
void configure (const std::string &detid)
 Configure detector integration for given detector identifier. More...
 
const JProductIntegration_ttrace (const JUPI &upi, const JPBS &pbs=PBS::DETECTOR) const
 Trace product up to given integration level. More...
 
void print (std::ostream &out, const JUPI &upi) const
 Print product trace. More...
 
void print (std::ostream &out, const JProductIntegration_t &product) const
 Print product trace. More...
 
int find (const JUPI &upi) const
 Find index of unique product with given UPI. More...
 
range_type find (const JPBS &pbs) const
 Find range of products with given PBS. 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

data_type data
 integration data More...
 
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 &detector)
 Read detector integration from result set. More...
 
std::ostream & operator<< (std::ostream &out, const JDetectorIntegration &object)
 Write detector integration to output stream. More...
 

Detailed Description

Detector integration.

This class is used

Definition at line 294 of file JDetectorIntegration.hh.

Member Typedef Documentation

◆ map_type

Definition at line 299 of file JDetectorIntegration.hh.

◆ range_type

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

Definition at line 301 of file JDetectorIntegration.hh.

◆ range_const_iterator

Definition at line 302 of file JDetectorIntegration.hh.

◆ range_iterator

typedef map_type::const_iterator JDATABASE::JDetectorIntegration::range_iterator

Definition at line 303 of file JDetectorIntegration.hh.

◆ data_type

Definition at line 305 of file JDetectorIntegration.hh.

◆ const_iterator

typedef data_type::const_iterator JDATABASE::JDetectorIntegration::const_iterator

Definition at line 306 of file JDetectorIntegration.hh.

◆ iterator

typedef data_type::iterator JDATABASE::JDetectorIntegration::iterator

Definition at line 307 of file JDetectorIntegration.hh.

◆ const_reverse_iterator

typedef data_type::const_reverse_iterator JDATABASE::JDetectorIntegration::const_reverse_iterator

Definition at line 308 of file JDetectorIntegration.hh.

◆ reverse_iterator

typedef data_type::reverse_iterator JDATABASE::JDetectorIntegration::reverse_iterator

Definition at line 309 of file JDetectorIntegration.hh.

Constructor & Destructor Documentation

◆ JDetectorIntegration()

JDATABASE::JDetectorIntegration::JDetectorIntegration ( )
inline

Default constructor.

Definition at line 315 of file JDetectorIntegration.hh.

316  {}

Member Function Documentation

◆ getName()

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

Table name.

Definition at line 296 of file JDetectorIntegration.hh.

◆ begin()

const_iterator JDATABASE::JDetectorIntegration::begin ( ) const
inline

begin of integration data

Definition at line 319 of file JDetectorIntegration.hh.

◆ end()

const_iterator JDATABASE::JDetectorIntegration::end ( ) const
inline

end of integration data

Definition at line 320 of file JDetectorIntegration.hh.

◆ rbegin()

const_reverse_iterator JDATABASE::JDetectorIntegration::rbegin ( ) const
inline

reverse begin of integration data

Definition at line 321 of file JDetectorIntegration.hh.

◆ rend()

const_reverse_iterator JDATABASE::JDetectorIntegration::rend ( ) const
inline

reverse end of integration data

Definition at line 322 of file JDetectorIntegration.hh.

◆ empty()

bool JDATABASE::JDetectorIntegration::empty ( ) const
inline

check emptyness of integration data

Definition at line 324 of file JDetectorIntegration.hh.

◆ size()

size_t JDATABASE::JDetectorIntegration::size ( ) const
inline

size of integration data

Definition at line 325 of file JDetectorIntegration.hh.

◆ operator[]()

const JProductIntegration_t& JDATABASE::JDetectorIntegration::operator[] ( const int  index) const
inline

Get product at given index.

Parameters
indexindex
Returns
product

Definition at line 334 of file JDetectorIntegration.hh.

335  {
336  return data[index];
337  }

◆ configure() [1/2]

void JDATABASE::JDetectorIntegration::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 350 of file JDetectorIntegration.hh.

351  {
352  using namespace std;
353 
354  up .clear();
355  down.clear();
356 
357  for (size_t index = 0; index != data.size(); ++index) {
358 
359  JProductIntegration_t& product = data[index];
360 
361  product.unset();
362 
363  up .insert(make_pair(product.content .getUPI(), index));
364  down.insert(make_pair(product.container.getUPI(), index));
365  }
366 
367 
368  for (data_type::iterator product = data.begin(); product != data.end(); ++product) {
369  if (product->operation == detid) {
370  configure(*product, JPeriod_t(product->start_date, product->end_date));
371  }
372  }
373 
374 
375  up .clear();
376  down.clear();
377 
378  for (size_t index = 0; index != data.size(); ++index) {
379 
380  const JProductIntegration_t& product = data[index];
381 
382  if (product.has()) {
383  up .insert(make_pair(product.content .getUPI(), index));
384  down.insert(make_pair(product.container.getUPI(), index));
385  }
386  }
387  }

◆ trace()

const JProductIntegration_t& JDATABASE::JDetectorIntegration::trace ( const JUPI upi,
const JPBS pbs = PBS::DETECTOR 
) const
inline

Trace product up to given integration level.

Parameters
upiUPI
pbsPBS
Returns
product

Definition at line 397 of file JDetectorIntegration.hh.

399  {
400  if (upi.getPBS() >= pbs) {
401 
402  const int index = find(upi);
403 
404  if (index != -1) {
405 
406  const JProductIntegration_t& product = data[index];
407 
408  if (product.container.getPBS() == pbs)
409  return product;
410  else
411  return trace(product.container.getUPI(), pbs);
412 
413  } else {
414 
415  THROW(JDatabaseException, "Invalid UPI " << upi);
416  }
417 
418  } else {
419 
420  THROW(JDatabaseException, "Invalid PBS " << upi.getPBS() << " < " << pbs);
421  }
422  }

◆ print() [1/2]

void JDATABASE::JDetectorIntegration::print ( std::ostream &  out,
const JUPI upi 
) const
inline

Print product trace.

Parameters
outoutput stream
upiUPI

Definition at line 431 of file JDetectorIntegration.hh.

432  {
433  using namespace std;
434 
435  const int index = find(upi);
436 
437  if (index != -1) {
438 
439  out << upi << " -> ";
440 
441  print(out, data[index]);
442  }
443 
444  const range_type range = down.equal_range(upi);
445 
446  for (range_iterator i = range.first; i != range.second; ++i) {
447  out << "<- " << data[i->second] << endl;
448  }
449  }

◆ print() [2/2]

void JDATABASE::JDetectorIntegration::print ( std::ostream &  out,
const JProductIntegration_t product 
) const
inline

Print product trace.

Parameters
outoutput stream
productproduct

Definition at line 458 of file JDetectorIntegration.hh.

459  {
460  out << product.container.getUPI() << ' '
461  << JPeriod_t(product.start_date, product.end_date) << ' '
462  << " -> ";
463 
464  const int index = find(product.container.getUPI());
465 
466  if (index != -1)
467  print(out, data[index]);
468  else
469  out << product.operation << std::endl;
470  }

◆ find() [1/2]

int JDATABASE::JDetectorIntegration::find ( const JUPI upi) const
inline

Find index of unique product with given UPI.


This method can only be used after method JDetectorIntegration::configure.

Parameters
upiUPI
Returns
index

Definition at line 522 of file JDetectorIntegration.hh.

523  {
524  const range_type range = up.equal_range(upi);
525 
526  switch (std::distance(range.first, range.second)) {
527 
528  case 0:
529  return -1;
530 
531  case 1:
532  return range.first->second;
533 
534  default:
535  THROW(JDatabaseException, "Ambiguous integration of UPI (call first method JDetectorIntegration::configure) " << upi);
536  }
537  }

◆ find() [2/2]

range_type JDATABASE::JDetectorIntegration::find ( const JPBS pbs) const
inline

Find range of products with given PBS.


The returned range correspond 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 548 of file JDetectorIntegration.hh.

549  {
550  range_const_iterator p = up.lower_bound(JUPI(pbs));
551  range_const_iterator q = p;
552 
553  while (q != up.end() && data[q->second].content.getPBS() <= pbs) {
554  ++q;
555  }
556 
557  return range_type(p,q);
558  }

◆ configure() [2/2]

void JDATABASE::JDetectorIntegration::configure ( JProductIntegration_t product,
const JPeriod_t period 
)
inlineprotected

Configure detector integration for given detector identifier.


This method sets the status all related products.

Parameters
productproduct
periodvalidity period

Definition at line 568 of file JDetectorIntegration.hh.

569  {
570  using namespace std;
571 
572  product.set();
573 
574  vector<int> buffer;
575 
576  range_type range = down.equal_range(product.content);
577 
578  for (range_iterator i = range.first; i != range.second; ++i) {
579 
580  if (data[i->second].start_date <= period.getLowerLimit()) {
581 
582  int ns = 0;
583 
584  for (vector<int>::iterator p = buffer.begin(); p != buffer.end(); ++p) {
585 
586  if (data[*p].overlap(data[i->second])) {
587 
588  ++ns;
589 
590  if (data[i->second].start_date > data[*p].start_date) {
591  *p = i->second;
592  }
593  }
594  }
595 
596  if (ns == 0) {
597  buffer.push_back(i->second);
598  }
599  }
600  }
601 
602  for (vector<int>::const_iterator i = buffer.begin(); i != buffer.end(); ++i) {
603  configure(data[*i], period);
604  }
605  }

Friends And Related Function Documentation

◆ operator>>

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

Read detector integration from result set.

Parameters
rsresult set
detectordetector
Returns
true if read; else false

Definition at line 480 of file JDetectorIntegration.hh.

481  {
482  for (JProductIntegration parameters; rs >> parameters; ) {
483 
484  const JProductIntegration_t product(parameters);
485 
486  detector.up .insert(make_pair(product.content .getUPI(), detector.data.size()));
487  detector.down.insert(make_pair(product.container.getUPI(), detector.data.size()));
488 
489  detector.data.push_back(product);
490  }
491 
492  rs.Close();
493 
494  return true;
495  }

◆ operator<<

std::ostream& operator<< ( std::ostream &  out,
const JDetectorIntegration object 
)
friend

Write detector integration to output stream.

Parameters
outoutput stream
objectdetector integration
Returns
output stream

Definition at line 505 of file JDetectorIntegration.hh.

506  {
507  for (const_iterator i = object.data.begin(); i != object.data.end(); ++i) {
508  out << *i << std::endl;
509  }
510 
511  return out;
512  }

Member Data Documentation

◆ data

data_type JDATABASE::JDetectorIntegration::data
protected

integration data

Definition at line 608 of file JDetectorIntegration.hh.

◆ up

map_type JDATABASE::JDetectorIntegration::up
protected

up link UPI to integration data

Definition at line 609 of file JDetectorIntegration.hh.

◆ down

map_type JDATABASE::JDetectorIntegration::down
protected

down link UPI to integration data

Definition at line 610 of file JDetectorIntegration.hh.


The documentation for this struct was generated from the following file:
JDATABASE::JDetectorIntegration::range_iterator
map_type::const_iterator range_iterator
Definition: JDetectorIntegration.hh:303
JTOOLS::JRange::getLowerLimit
T getLowerLimit() const
Get lower limit.
Definition: JRange.hh:215
JDATABASE::JProductIntegration_t::has
bool has() const
Has status.
Definition: JDetectorIntegration.hh:214
JDATABASE::JDetectorIntegration::range_type
std::pair< map_type::const_iterator, map_type::const_iterator > range_type
Definition: JDetectorIntegration.hh:301
JDATABASE::JProductIntegration_t::operation
std::string operation
Definition: JDetectorIntegration.hh:275
JDATABASE::JDetectorIntegration::find
int find(const JUPI &upi) const
Find index of unique product with given UPI.
Definition: JDetectorIntegration.hh:522
JDATABASE::JProductIntegration_t::unset
void unset()
Unset status.
Definition: JDetectorIntegration.hh:232
std::vector< int >
distance
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
Definition: PhysicsEvent.hh:434
JDATABASE::JProductIntegration_t::container
JUPI container
Definition: JDetectorIntegration.hh:277
JTOOLS::overlap
bool overlap(const JRange< T, JComparator_t > &first, const JRange< T, JComparator_t > &second)
Test overlap between ranges.
Definition: JRange.hh:653
JDATABASE::JDetectorIntegration::print
void print(std::ostream &out, const JUPI &upi) const
Print product trace.
Definition: JDetectorIntegration.hh:431
JDATABASE::JDetectorIntegration::data
data_type data
integration data
Definition: JDetectorIntegration.hh:608
JDATABASE::JProductIntegration_t::content
JUPI content
Definition: JDetectorIntegration.hh:278
JDATABASE::JDetectorIntegration::trace
const JProductIntegration_t & trace(const JUPI &upi, const JPBS &pbs=PBS::DETECTOR) const
Trace product up to given integration level.
Definition: JDetectorIntegration.hh:397
JDATABASE::JDetectorIntegration::const_iterator
data_type::const_iterator const_iterator
Definition: JDetectorIntegration.hh:306
JDATABASE::JDetectorIntegration::range_const_iterator
map_type::const_iterator range_const_iterator
Definition: JDetectorIntegration.hh:302
JDATABASE::JProductIntegration_t::set
void set()
Set status.
Definition: JDetectorIntegration.hh:223
THROW
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:669
JDATABASE::JUPI::getUPI
const JUPI & getUPI() const
Get UPI.
Definition: JUPI.hh:68
JDATABASE::JDetectorIntegration::up
map_type up
up link UPI to integration data
Definition: JDetectorIntegration.hh:609
JDATABASE::JPeriod_t
JTOOLS::JRange< JDate_t > JPeriod_t
Type definition of period.
Definition: JDetectorIntegration.hh:159
JDATABASE::JDetectorIntegration::configure
void configure(const std::string &detid)
Configure detector integration for given detector identifier.
Definition: JDetectorIntegration.hh:350
std
Definition: jaanetDictionary.h:36
JDATABASE::JProductIntegration_t::end_date
JDate_t end_date
Definition: JDetectorIntegration.hh:280
JDATABASE::JDetectorIntegration::down
map_type down
down link UPI to integration data
Definition: JDetectorIntegration.hh:610
JDATABASE::JProductIntegration_t::start_date
JDate_t start_date
Definition: JDetectorIntegration.hh:279
JDATABASE::JPBS::getPBS
const JPBS & getPBS() const
Get PBS.
Definition: JPBS.hh:106
JDATABASE::JProductIntegration
Definition: JProductIntegration.hh:17
JDATABASE::JUPI
Universal product identifier (UPI).
Definition: JUPI.hh:29
JDATABASE::JProductIntegration_t
Auxiliary class for product integration data.
Definition: JDetectorIntegration.hh:182