Jpp
 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>

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_t
data_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_t ()
 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_t &detector)
 Read detector integration from result set. 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

Definition at line 180 of file JDetectorIntegration_t.hh.

Member Typedef Documentation

Definition at line 185 of file JDetectorIntegration_t.hh.

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

Definition at line 187 of file JDetectorIntegration_t.hh.

Definition at line 188 of file JDetectorIntegration_t.hh.

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

Definition at line 189 of file JDetectorIntegration_t.hh.

Definition at line 191 of file JDetectorIntegration_t.hh.

typedef data_type::const_iterator JDATABASE::JDetectorIntegration_t::const_iterator

Definition at line 192 of file JDetectorIntegration_t.hh.

typedef data_type::iterator JDATABASE::JDetectorIntegration_t::iterator

Definition at line 193 of file JDetectorIntegration_t.hh.

typedef data_type::const_reverse_iterator JDATABASE::JDetectorIntegration_t::const_reverse_iterator

Definition at line 194 of file JDetectorIntegration_t.hh.

typedef data_type::reverse_iterator JDATABASE::JDetectorIntegration_t::reverse_iterator

Definition at line 195 of file JDetectorIntegration_t.hh.

Constructor & Destructor Documentation

JDATABASE::JDetectorIntegration_t::JDetectorIntegration_t ( )
inline

Default constructor.

Definition at line 201 of file JDetectorIntegration_t.hh.

202  {}

Member Function Documentation

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

Table name.

Definition at line 182 of file JDetectorIntegration_t.hh.

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

begin of integration data

Definition at line 205 of file JDetectorIntegration_t.hh.

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

end of integration data

Definition at line 206 of file JDetectorIntegration_t.hh.

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

reverse begin of integration data

Definition at line 207 of file JDetectorIntegration_t.hh.

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

reverse end of integration data

Definition at line 208 of file JDetectorIntegration_t.hh.

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

check emptyness of integration data

Definition at line 210 of file JDetectorIntegration_t.hh.

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

size of integration data

Definition at line 211 of file JDetectorIntegration_t.hh.

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

Get product at given index.

Parameters
indexindex
Returns
product

Definition at line 220 of file JDetectorIntegration_t.hh.

221  {
222  return data[index];
223  }
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 236 of file JDetectorIntegration_t.hh.

237  {
238  using namespace std;
239 
240  up .clear();
241  down.clear();
242 
243  for (size_t index = 0; index != data.size(); ++index) {
244 
245  JProductIntegration_t& product = data[index];
246 
247  product.unset();
248 
249  up .insert(make_pair(product.content .getUPI(), index));
250  down.insert(make_pair(product.container.getUPI(), index));
251  }
252 
253 
254  for (data_type::iterator product = data.begin(); product != data.end(); ++product) {
255  if (product->operation == detid) {
256  configure(*product, JPeriod_t(product->start_date, product->end_date));
257  }
258  }
259 
260 
261  up .clear();
262  down.clear();
263 
264  for (size_t index = 0; index != data.size(); ++index) {
265 
266  const JProductIntegration_t& product = data[index];
267 
268  if (product.has()) {
269  up .insert(make_pair(product.content .getUPI(), index));
270  down.insert(make_pair(product.container.getUPI(), index));
271  }
272  }
273  }
map_type up
up link UPI to integration data
JTOOLS::JRange< JDate_t > JPeriod_t
Type definition of period.
map_type down
down link UPI to integration data
const JUPI & getUPI() const
Get UPI.
Definition: JUPI.hh:68
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 upi,
const JPBS pbs = PBS::DETECTOR 
) const
inline

Trace product up to given integration level.

Parameters
upiUPI
pbsPBS
Returns
product

Definition at line 283 of file JDetectorIntegration_t.hh.

285  {
286  if (upi.getPBS() >= pbs) {
287 
288  const int index = find(upi);
289 
290  if (index != -1) {
291 
292  const JProductIntegration_t& product = data[index];
293 
294  if (product.container.getPBS() == pbs)
295  return product;
296  else
297  return trace(product.container.getUPI(), pbs);
298 
299  } else {
300 
301  THROW(JDatabaseException, "Invalid UPI " << upi);
302  }
303 
304  } else {
305 
306  THROW(JDatabaseException, "Invalid PBS " << upi.getPBS() << " < " << pbs);
307  }
308  }
const JPBS & getPBS() const
Get PBS.
Definition: JPBS.hh:105
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:670
const JUPI & getUPI() const
Get UPI.
Definition: JUPI.hh:68
int find(const JUPI &upi) const
Find index of unique product with given UPI.
const JProductIntegration_t & trace(const JUPI &upi, const JPBS &pbs=PBS::DETECTOR) const
Trace product up to given integration level.
Auxiliary class for product integration data.
void JDATABASE::JDetectorIntegration_t::print ( std::ostream &  out,
const JUPI upi 
) const
inline

Print product trace.

Parameters
outoutput stream
upiUPI

Definition at line 317 of file JDetectorIntegration_t.hh.

318  {
319  using namespace std;
320 
321  const int index = find(upi);
322 
323  if (index != -1) {
324 
325  out << upi << " -> ";
326 
327  print(out, data[index]);
328  }
329 
330  const range_type range = down.equal_range(upi);
331 
332  for (range_iterator i = range.first; i != range.second; ++i) {
333  out << "<- " << data[i->second] << endl;
334  }
335  }
void print(std::ostream &out, const JUPI &upi) const
Print product trace.
std::pair< map_type::const_iterator, map_type::const_iterator > range_type
map_type down
down link UPI to integration data
int find(const JUPI &upi) const
Find index of unique product with given UPI.
void JDATABASE::JDetectorIntegration_t::print ( std::ostream &  out,
const JProductIntegration_t product 
) const
inline

Print product trace.

Parameters
outoutput stream
productproduct

Definition at line 344 of file JDetectorIntegration_t.hh.

345  {
346  out << product.container.getUPI() << ' '
347  << JPeriod_t(product.start_date, product.end_date) << ' '
348  << " -> ";
349 
350  const int index = find(product.container.getUPI());
351 
352  if (index != -1)
353  print(out, data[index]);
354  else
355  out << product.operation << std::endl;
356  }
void print(std::ostream &out, const JUPI &upi) const
Print product trace.
JTOOLS::JRange< JDate_t > JPeriod_t
Type definition of period.
const JUPI & getUPI() const
Get UPI.
Definition: JUPI.hh:68
int find(const JUPI &upi) const
Find index of unique product with given UPI.
int JDATABASE::JDetectorIntegration_t::find ( const JUPI upi) const
inline

Find index of unique product with given UPI.


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

Parameters
upiUPI
Returns
index

Definition at line 408 of file JDetectorIntegration_t.hh.

409  {
410  const range_type range = up.equal_range(upi);
411 
412  switch (std::distance(range.first, range.second)) {
413 
414  case 0:
415  return -1;
416 
417  case 1:
418  return range.first->second;
419 
420  default:
421  THROW(JDatabaseException, "Ambiguous integration of UPI (call first method JDetectorIntegration_t::configure) " << upi);
422  }
423  }
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
map_type up
up link UPI to integration data
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:670
std::pair< map_type::const_iterator, map_type::const_iterator > range_type
range_type JDATABASE::JDetectorIntegration_t::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 434 of file JDetectorIntegration_t.hh.

435  {
436  range_const_iterator p = up.lower_bound(JUPI(pbs));
437  range_const_iterator q = p;
438 
439  while (q != up.end() && data[q->second].content.getPBS() <= pbs) {
440  ++q;
441  }
442 
443  return range_type(p,q);
444  }
map_type up
up link UPI to integration data
std::pair< map_type::const_iterator, map_type::const_iterator > range_type
map_type::const_iterator range_const_iterator
Universal product identifier (UPI).
Definition: JUPI.hh:30
void JDATABASE::JDetectorIntegration_t::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 454 of file JDetectorIntegration_t.hh.

455  {
456  using namespace std;
457 
458  product.set();
459 
460  vector<int> buffer;
461 
462  range_type range = down.equal_range(product.content);
463 
464  for (range_iterator i = range.first; i != range.second; ++i) {
465 
466  if (data[i->second].start_date <= period.getLowerLimit()) {
467 
468  int ns = 0;
469 
470  for (vector<int>::iterator p = buffer.begin(); p != buffer.end(); ++p) {
471 
472  if (data[*p].overlap(data[i->second])) {
473 
474  ++ns;
475 
476  if (data[i->second].start_date > data[*p].start_date) {
477  *p = i->second;
478  }
479  }
480  }
481 
482  if (ns == 0) {
483  buffer.push_back(i->second);
484  }
485  }
486  }
487 
488  for (vector<int>::const_iterator i = buffer.begin(); i != buffer.end(); ++i) {
489  configure(data[*i], period);
490  }
491  }
T getLowerLimit() const
Get lower limit.
Definition: JRange.hh:215
std::pair< map_type::const_iterator, map_type::const_iterator > range_type
map_type down
down link UPI to integration data
bool overlap(const JRange< T, JComparator_t > &first, const JRange< T, JComparator_t > &second)
Test overlap between ranges.
Definition: JRange.hh:664
void configure(const std::string &detid)
Configure detector integration for given detector identifier.

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  for (JProductIntegration parameters; rs >> parameters; ) {
369 
370  const JProductIntegration_t product(parameters);
371 
372  detector.up .insert(make_pair(product.content .getUPI(), detector.data.size()));
373  detector.down.insert(make_pair(product.container.getUPI(), detector.data.size()));
374 
375  detector.data.push_back(product);
376  }
377 
378  rs.Close();
379 
380  return true;
381  }
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::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 391 of file JDetectorIntegration_t.hh.

392  {
393  for (const_iterator i = object.data.begin(); i != object.data.end(); ++i) {
394  out << *i << std::endl;
395  }
396 
397  return out;
398  }
data_type::const_iterator const_iterator

Member Data Documentation

data_type JDATABASE::JDetectorIntegration_t::data
protected

integration data

Definition at line 494 of file JDetectorIntegration_t.hh.

map_type JDATABASE::JDetectorIntegration_t::up
protected

up link UPI to integration data

Definition at line 495 of file JDetectorIntegration_t.hh.

map_type JDATABASE::JDetectorIntegration_t::down
protected

down link UPI to integration data

Definition at line 496 of file JDetectorIntegration_t.hh.


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