Jpp  15.0.0
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::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 173 of file JDetectorIntegration_t.hh.

Member Typedef Documentation

Definition at line 178 of file JDetectorIntegration_t.hh.

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

Definition at line 180 of file JDetectorIntegration_t.hh.

Definition at line 181 of file JDetectorIntegration_t.hh.

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

Definition at line 182 of file JDetectorIntegration_t.hh.

Constructor & Destructor Documentation

JDATABASE::JDetectorIntegration_t::JDetectorIntegration_t ( )
inline

Default constructor.

Definition at line 188 of file JDetectorIntegration_t.hh.

189  {}

Member Function Documentation

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

Table name.

Definition at line 176 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 202 of file JDetectorIntegration_t.hh.

203  {
204  using namespace std;
205 
206  up .clear();
207  down.clear();
208 
209  for (size_t index = 0; index != this->size(); ++index) {
210 
211  JProductIntegration_t& product = (*this)[index];
212 
213  product.unset();
214 
215  up .insert(make_pair(product.content .getUPI(), index));
216  down.insert(make_pair(product.container.getUPI(), index));
217  }
218 
219  for (iterator product = this->begin(); product != this->end(); ++product) {
220  if (product->operation == detid) {
221  configure(*product, JPeriod_t(product->start_date, product->end_date));
222  }
223  }
224 
225  up .clear();
226  down.clear();
227 
228  for (size_t index = 0; index != this->size(); ++index) {
229 
230  const JProductIntegration_t& product = (*this)[index];
231 
232  if (product.has()) {
233  up .insert(make_pair(product.content .getUPI(), index));
234  down.insert(make_pair(product.container.getUPI(), index));
235  }
236  }
237  }
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
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 247 of file JDetectorIntegration_t.hh.

249  {
250  using namespace std;
251 
252  if (upi.getPBS() >= pbs) {
253 
254  const range_type range = find(upi);
255 
256  switch (distance(range.first, range.second)) {
257 
258  case 1:
259  {
260  const JProductIntegration_t& product = (*this)[range.first->second];
261 
262  if (product.container.getPBS() == pbs)
263  return product;
264  else
265  return trace(product.container.getUPI(), pbs);
266  }
267 
268  case 0:
269  THROW(JDatabaseException, "Invalid UPI " << upi);
270 
271  default:
272  THROW(JDatabaseException, "Ambiguous integration of UPI " << upi);
273  }
274 
275  } else {
276 
277  THROW(JDatabaseException, "Invalid PBS " << upi.getPBS() << " < " << pbs);
278  }
279  }
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:670
const JPBS_t & getPBS() const
Get PBS.
Definition: JPBS_t.hh:99
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 288 of file JDetectorIntegration_t.hh.

289  {
290  using namespace std;
291 
293 
294  range = find(upi);
295 
296  for (map_type::const_iterator i = range.first; i != range.second; ++i) {
297 
298  out << upi << " -> ";
299 
300  print(out, (*this)[i->second]);
301  }
302 
303  range = down.equal_range(upi);
304 
305  for (range_iterator i = range.first; i != range.second; ++i) {
306  out << "<- " << (*this)[i->second] << endl;
307  }
308  }
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 317 of file JDetectorIntegration_t.hh.

318  {
319  using namespace std;
320 
321  out << product.container.getUPI() << ' '
322  //<< JPeriod_t(product.start_date, product.end_date) << ' '
323  << "-> ";
324 
325  const range_type range = find(product.container.getUPI());
326 
327  for (map_type::const_iterator i = range.first; i != range.second; ++i) {
328  print(out, (*this)[i->second]);
329  }
330 
331  if (distance(range.first, range.second) != 1) {
332  out << product.operation << std::endl;
333  }
334  }
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 389 of file JDetectorIntegration_t.hh.

390  {
391  return up.equal_range(upi);
392  }
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 403 of file JDetectorIntegration_t.hh.

404  {
405  range_const_iterator p = up.lower_bound(JUPI_t(pbs));
406  range_const_iterator q = p;
407 
408  while (q != up.end() && (*this)[q->second].content.getPBS() <= pbs) {
409  ++q;
410  }
411 
412  return range_type(p,q);
413  }
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 424 of file JDetectorIntegration_t.hh.

425  {
426  return down.equal_range(upi);
427  }
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 sets the status all related products.

Parameters
productproduct
periodvalidity period

Definition at line 438 of file JDetectorIntegration_t.hh.

439  {
440  using namespace std;
441 
442  product.set();
443 
444  vector<int> buffer;
445 
446  range_type range = down.equal_range(product.content);
447 
448  for (range_iterator i = range.first; i != range.second; ++i) {
449 
450  if ((*this)[i->second].start_date <= period.getLowerLimit()) {
451 
452  int ns = 0;
453 
454  for (vector<int>::iterator p = buffer.begin(); p != buffer.end(); ++p) {
455 
456  if ((*this)[*p].overlap((*this)[i->second])) {
457 
458  ++ns;
459 
460  if ((*this)[i->second].start_date > (*this)[*p].start_date) {
461  *p = i->second;
462  }
463  }
464  }
465 
466  if (ns == 0) {
467  buffer.push_back(i->second);
468  }
469  }
470  }
471 
472  for (vector<int>::const_iterator i = buffer.begin(); i != buffer.end(); ++i) {
473  configure((*this)[*i], period);
474  }
475  }
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.

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 344 of file JDetectorIntegration_t.hh.

345  {
346  using namespace std;
347 
348  for (JProductIntegration parameters; rs >> parameters; ) {
349 
350  const JProductIntegration_t product(parameters);
351 
352  detector.up .insert(make_pair(product.content .getUPI(), detector.size()));
353  detector.down.insert(make_pair(product.container.getUPI(), detector.size()));
354 
355  detector.push_back(product);
356  }
357 
358  rs.Close();
359 
360  return true;
361  }
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 371 of file JDetectorIntegration_t.hh.

372  {
373  for (const_iterator i = object.begin(); i != object.end(); ++i) {
374  out << *i << std::endl;
375  }
376 
377  return out;
378  }

Member Data Documentation

map_type JDATABASE::JDetectorIntegration_t::up
protected

up link UPI to integration data

Definition at line 477 of file JDetectorIntegration_t.hh.

map_type JDATABASE::JDetectorIntegration_t::down
protected

down link UPI to integration data

Definition at line 478 of file JDetectorIntegration_t.hh.


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