/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Public Member Functions | Static Public Member Functions | Private Attributes
DybNextEntryPolicyTool Class Reference

An entry policy tools that monotonically increases the entry by 1. More...

#include <DybNextEntryPolicyTool.h>

Inheritance diagram for DybNextEntryPolicyTool:
Inheritance graph
[legend]
Collaboration diagram for DybNextEntryPolicyTool:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 DybNextEntryPolicyTool (const std::string &type, const std::string &name, const IInterface *parent)
virtual ~DybNextEntryPolicyTool ()
StatusCode queryInterface (const InterfaceID &riid, void **ppvIf)
virtual StatusCode initialize ()
int set_entries (int entries)
int next_entry ()

Static Public Member Functions

static const InterfaceID & interfaceID ()

Private Attributes

int m_entries
int m_entry
int m_step
std::string m_modeName
int m_mode
Rndm::Numbers m_rand
int m_last
int m_stop
int m_count

Detailed Description

An entry policy tools that monotonically increases the entry by 1.

Brett Viren <bv@bnl.gov> Mon Nov 15 13:25:03 2010

Definition at line 24 of file DybNextEntryPolicyTool.h.


Constructor & Destructor Documentation

DybNextEntryPolicyTool::DybNextEntryPolicyTool ( const std::string &  type,
const std::string &  name,
const IInterface *  parent 
)

Definition at line 8 of file DybNextEntryPolicyTool.cc.

    : GaudiTool(type,name,parent)
    , m_entries(-1)
    , m_entry(0)
    , m_step(1)
    , m_last(-1)
    , m_stop(-1)
    , m_count(0)
{
    declareInterface<IDybEntryPolicyTool>(this);
    declareProperty("Start",m_entry=0, "Entry to start at");
    declareProperty("Step",m_step=1, "Number of entries to step");
    declareProperty("Mode",m_modeName="random","Loading mode: random or sequential");
    declareProperty("Stop",m_stop=-1,"Stop after providing the given number of entries.  <0 (def) is free running, 0 means stop after the number of set entries have been returned");
}
DybNextEntryPolicyTool::~DybNextEntryPolicyTool ( ) [virtual]

Definition at line 26 of file DybNextEntryPolicyTool.cc.

{

}

Member Function Documentation

StatusCode DybNextEntryPolicyTool::queryInterface ( const InterfaceID &  riid,
void **  ppvIf 
)

Definition at line 31 of file DybNextEntryPolicyTool.cc.

{
    if ( riid == IDybEntryPolicyTool::interfaceID() )  {
        *ppvIf = (IDybEntryPolicyTool*)this;
        addRef();
        return StatusCode::SUCCESS;
    }
    return AlgTool::queryInterface( riid, ppvIf );
}
StatusCode DybNextEntryPolicyTool::initialize ( ) [virtual]

Definition at line 41 of file DybNextEntryPolicyTool.cc.

{
  IRndmGenSvc *rgs = 0;
  if (service("RndmGenSvc",rgs,true).isFailure()) {
    fatal() << "Failed to get random service" << endreq;
    return StatusCode::FAILURE;
  }

  StatusCode sc;
  if (m_rand.initialize(rgs, Rndm::Flat(0,1)).isFailure()) {
    fatal() << "Failed to initialize flat random numbers" << endreq;
    return StatusCode::FAILURE;
  }

  if( m_modeName=="random" ) {
    m_mode=1;
  }
  if( m_modeName=="sequential" ) {
    m_mode=2;
  }
  info()<<"Running mode: "<<m_modeName<<" "<<m_mode<<endreq;
  return StatusCode::SUCCESS;
}
int DybNextEntryPolicyTool::set_entries ( int  entries) [virtual]

Implements IDybEntryPolicyTool.

Definition at line 65 of file DybNextEntryPolicyTool.cc.

{
  m_entries = entries;
  if (!m_stop) {
      m_stop = entries;
  }
  return m_entries;
}
int DybNextEntryPolicyTool::next_entry ( ) [virtual]

Implements IDybEntryPolicyTool.

Definition at line 74 of file DybNextEntryPolicyTool.cc.

{
  int ret = 0;
  
  ++m_count;
  if (m_stop > 0 && m_count == m_stop) {
      // this should be the last execution cycle
      IEventProcessor* evt = svc<IEventProcessor>("ApplicationMgr");
      evt->stopRun();
      evt->release();
  }

  
  // [0,entries-1]
  if( m_mode==1 ) {
      do {
          ret = int( m_rand() * m_entries );
      }
      while (ret == m_last);    // don't pick the same one twice in a row
  }

  if( m_mode==2 ) {
    ret = m_entry;
    m_entry += m_step;
    if( m_entries>0 ) m_entry = m_entry % m_entries;
  }
 
  m_last = ret;
  return ret;
}
const InterfaceID & IDybEntryPolicyTool::interfaceID ( ) [static, inherited]

Definition at line 7 of file IDybEntryPolicyTool.cc.

{
    return IID_IDybEntryPolicyTool; 
}

Member Data Documentation

Definition at line 45 of file DybNextEntryPolicyTool.h.

Definition at line 46 of file DybNextEntryPolicyTool.h.

Definition at line 46 of file DybNextEntryPolicyTool.h.

std::string DybNextEntryPolicyTool::m_modeName [private]

Definition at line 49 of file DybNextEntryPolicyTool.h.

Definition at line 50 of file DybNextEntryPolicyTool.h.

Rndm::Numbers DybNextEntryPolicyTool::m_rand [private]

Definition at line 54 of file DybNextEntryPolicyTool.h.

Definition at line 55 of file DybNextEntryPolicyTool.h.

Definition at line 56 of file DybNextEntryPolicyTool.h.

Definition at line 57 of file DybNextEntryPolicyTool.h.


The documentation for this class was generated from the following files:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 10:15:57 for DybIO by doxygen 1.7.4