CMS 3D CMS Logo

Public Member Functions | Private Attributes

triggerExpression::Prescaler Class Reference

#include <TriggerExpressionPrescaler.h>

Inheritance diagram for triggerExpression::Prescaler:
triggerExpression::UnaryOperator triggerExpression::Evaluator

List of all members.

Public Member Functions

void dump (std::ostream &out) const
void init (const Data &data)
bool operator() (const Data &data) const
 Prescaler (Evaluator *arg, unsigned int prescale)

Private Attributes

unsigned int m_counter
unsigned int m_prescale

Detailed Description

Definition at line 9 of file TriggerExpressionPrescaler.h.


Constructor & Destructor Documentation

triggerExpression::Prescaler::Prescaler ( Evaluator arg,
unsigned int  prescale 
) [inline]

Definition at line 11 of file TriggerExpressionPrescaler.h.

                                                    :
    UnaryOperator(arg),
    m_prescale(prescale),
    m_counter()
  { }

Member Function Documentation

void triggerExpression::Prescaler::dump ( std::ostream &  out) const [inline, virtual]

Implements triggerExpression::Evaluator.

Definition at line 21 of file TriggerExpressionPrescaler.h.

References m_prescale.

                                    {
    out << "(" << (*m_arg) << " / " << m_prescale << ")";
  }
void triggerExpression::Prescaler::init ( const Data data) [virtual]

Reimplemented from triggerExpression::UnaryOperator.

Definition at line 22 of file TriggerExpressionPrescaler.cc.

References triggerExpression::Data::eventNumber(), and m_counter.

                                      {
  // initialize the depending modules
  UnaryOperator::init(data);

  // initialize the counter to the first event number seen, 
  // in order to avoid all prescalers on different FUs to be syncronous
  m_counter = data.eventNumber();
}
bool triggerExpression::Prescaler::operator() ( const Data data) const [virtual]

Implements triggerExpression::Evaluator.

Definition at line 5 of file TriggerExpressionPrescaler.cc.

References runTheMatrix::data, m_counter, m_prescale, and query::result.

                                                  {
  // if the prescale factor is 0, we never need to run any dependent module,
  // so we can safely skip the rest of the processing
  if (m_prescale == 0)
    return false;

  bool result = ((*m_arg)(data));
  if (not result)
    return false;

  // if the prescale factor is 1, we do not need to keep track of the event counter
  if (m_prescale == 1)
    return true;

  return (++m_counter % m_prescale) == 0;
}

Member Data Documentation

unsigned int triggerExpression::Prescaler::m_counter [mutable, private]

Definition at line 27 of file TriggerExpressionPrescaler.h.

Referenced by init(), and operator()().

Definition at line 26 of file TriggerExpressionPrescaler.h.

Referenced by dump(), and operator()().