Example #1
0
/// Initialize Particle Gun parameters
StatusCode ConstPtParticleGun::initialize() {
  StatusCode sc = GaudiTool::initialize();
  if (!sc.isSuccess()) return sc;

  IRndmGenSvc* randSvc = svc<IRndmGenSvc>("RndmGenSvc", true);
  sc = m_flatGenerator.initialize(randSvc, Rndm::Flat(0., 1.));
  if (!sc.isSuccess()) return Error("Cannot initialize flat generator");

  // check momentum and angles
  if ((m_minEta > m_maxEta) || (m_minPhi > m_maxPhi)) return Error("Incorrect values for eta or phi!");

  m_deltaPhi = m_maxPhi - m_minPhi;
  m_deltaEta = m_maxEta - m_minEta;

  // setup particle information
  m_masses.clear();
  auto pd = Pythia8::ParticleData();

  info() << "Particle type chosen randomly from :";
  PIDs::iterator icode;
  for (icode = m_pdgCodes.begin(); icode != m_pdgCodes.end(); ++icode) {
    info() << " " << *icode;
    m_masses.push_back(pd.m0(*icode));
  }

  info() << endmsg;

  info() << "Eta range: " << m_minEta << "  <-> " << m_maxEta << endmsg;
  info() << "Phi range: " << m_minPhi / Gaudi::Units::rad << " rad <-> " << m_maxPhi / Gaudi::Units::rad << " rad"
         << endmsg;

  return sc;
}
Example #2
0
    /// Initialize
    virtual StatusCode initialize()
    {
      MsgStream log(msgSvc(), name());
      StatusCode sc = service("CounterSvc", m_cntSvc, true);
      if ( !sc.isSuccess() )    {
        log << MSG::ERROR << "Could not connect to CounterSvc." << endmsg;
        return sc;
      }
      sc = m_cntSvc->create(m_counterBaseName, "EventCount", 1000, m_evtCount);
      if ( !sc.isSuccess() )    {
        log << MSG::ERROR << "Could not create counter CounterTest::EventCount." << endmsg;
        return sc;
      }
      m_total = m_cntSvc->create(m_counterBaseName, "TotalCount").counter();
      try  {
        m_total = m_cntSvc->create(m_counterBaseName, "TotalCount").counter();
      }
      catch( std::exception& e)  {
        log << MSG::ALWAYS << "Exception: " << e.what() << endmsg;
      }
      ICounterSvc::Printout p(m_cntSvc);
      m_cntSvc->print(m_counterBaseName, "EventCount", p).ignore();
      m_cntSvc->print(m_counterBaseName, p).ignore();
      //
      m_cntSvc->create(m_counterBaseName, "Eff1") ;
      m_cntSvc->create(m_counterBaseName, "Eff2") ;
      m_cntSvc->create(m_counterBaseName, "Sum") ;

      return sc ;
    }
Example #3
0
//------------------------------------------------------------------------------
DataObject* HistogramSvc::createDirectory(CSTR parentDir,CSTR subDir) {
  DataObject*  directory = new DataObject();
  if (0 != directory)  {
    DataObject* pnode;
    StatusCode status = DataSvc::retrieveObject(parentDir, pnode);
    if(status.isSuccess()) {
      status = DataSvc::registerObject(pnode, subDir, directory);
      if (!status.isSuccess())   {
        MsgStream log(msgSvc(), name());
        log << MSG::ERROR << "Unable to create the histogram directory: "
                          << parentDir << "/" << subDir << endmsg;
        delete directory;
        return 0;
      }
    }
    else {
      MsgStream log(msgSvc(), name());
      log << MSG::ERROR << "Unable to create the histogram directory: "
                        << parentDir << "/" << subDir << endmsg;
      delete directory;
      return 0;
    }
  }
  return directory;
}
Example #4
0
/// Get previous iteration item from the event loop context, but skip jump elements
StatusCode EventSelector::previous(Context& refCtxt, int jump) const  {
  EvtSelectorContext *pIt  = dynamic_cast<EvtSelectorContext*>(&refCtxt);
  if ( pIt && jump > 0 )    {
    StatusCode sc = StatusCode::SUCCESS;
    for ( int i = 0; i < jump && sc.isSuccess(); ++i ) {
      const EventSelectorDataStream* s = m_streamtool->getStream(pIt->ID());
      Context* it = pIt->context();
      IEvtSelector* sel = s->selector();
      if ( it && sel )    { // First exploit the current stream
                            // This stream is empty: advance to the next stream
        sc = sel->previous(*it);  // This stream is empty: advance to the next stream
        if ( !sc.isSuccess() )   {
          sc = lastOfPreviousStream(true, *pIt);
        }
        else  {
          pIt->increaseCounters(false);
          pIt->set(it, 0);
        }
        printEvtInfo(pIt);
        if ( !sc.isSuccess() ) {
          return sc;
        }
      }
      pIt->increaseCounters(false);
    }
    return sc;
  }
  printEvtInfo(pIt);
  return StatusCode::FAILURE;
}
Example #5
0
// IEvtSelector::first()
StatusCode
EventSelector::firstOfNextStream(bool shutDown, EvtSelectorContext& iter) const {
  StatusCode status = StatusCode::SUCCESS;
  IDataStreamTool::size_type iter_id = (m_reconfigure) ? 0 : iter.ID()+1;
  if ( m_reconfigure ) const_cast<EventSelector*>(this)->m_reconfigure = false;
  if ( shutDown )   {
    if ( iter.ID() >= 0 && iter.ID() < (long)m_streamtool->size() )   {
      const EventSelectorDataStream* s = m_streamtool->getStream(iter.ID());
      if ( s->isInitialized() )    {
        EventSelector* thisPtr = const_cast<EventSelector*>(this);
        if ( s->selector() && iter.context() )  {
          Context* ctxt = iter.context();
          s->selector()->releaseContext(ctxt).ignore();
          iter.set(0,0);
        }
        status = thisPtr->m_streamtool->finalizeStream(const_cast<EventSelectorDataStream*>(s));
        iter.set(0,0);
      }
    }
  }

  const EventSelectorDataStream* s ;
  status = m_streamtool->getNextStream( s , iter_id );

  if ( status.isSuccess() )   {

    if(s!=NULL) {
    if ( !s->isInitialized() )    {
      EventSelector* thisPtr = const_cast<EventSelector*>(this);
      status = thisPtr->m_streamtool->initializeStream(const_cast<EventSelectorDataStream*>(s));
    }

    if ( status.isSuccess() ) {
      const IEvtSelector* sel = s->selector();
      if ( sel )    {
        Context* ctxt = 0;
        status = sel->createContext(ctxt);
        if ( status.isSuccess() )   {
          status = sel->resetCriteria(s->criteria(), *ctxt);
          if ( status.isSuccess() )   {
            MsgStream log(msgSvc(), name());
            iter.set(this, iter_id, ctxt, 0);
            log << MSG::INFO << *s << endmsg;
            m_incidentSvc->fireIncident(Incident(s->dbName(),IncidentType::BeginInputFile));
            return StatusCode::SUCCESS;
          }
        }
      }
    }
      m_incidentSvc->fireIncident(Incident(s->dbName(),IncidentType::FailInputFile));
    }
  }

  iter.set(this, -1, 0, 0);
  status.setChecked();
  //m_incidentSvc->fireIncident(Incident(s->dbName(),IncidentType::FailInputFile));
  return StatusCode::FAILURE;
}
Example #6
0
//------------------------------------------------------------------------------
StatusCode HistogramSvc::connectInput(CSTR ident) {
  MsgStream log (msgSvc(), name());
  DataObject* pO = 0;
  StatusCode status = this->findObject(m_rootName, pO);
  if (status.isSuccess())   {
    Tokenizer tok(true);
    std::string::size_type loc = ident.find(" ");
    std::string filename, auth, svc = "", typ = "";
    std::string logname = ident.substr(0,loc);
    tok.analyse(ident.substr(loc+1,ident.length()), " ", "", "", "=", "'", "'");
    for (Tokenizer::Items::iterator i = tok.items().begin();
         i != tok.items().end(); i++) {
      CSTR tag = (*i).tag();
      switch(::toupper(tag[0]))   {
      case 'F':   // FILE='<file name>'
      case 'D':   // DATAFILE='<file name>'
        filename = (*i).value();
        break;
      case 'T':   // TYP='<HBOOK,ROOT,OBJY,...>'
        typ = (*i).value();
        break;
      default:
        break;
      }
    }
    if (typ.length() > 0)    {
      // Now add the registry entry to the store
      std::string entryname = m_rootName;
      entryname += '/';
      entryname += logname;
      GenericAddress* pA = 0;
      switch(::toupper(typ[0])) {
      case 'H':
        pA=new GenericAddress(HBOOK_StorageType,CLID_StatisticsFile,
                              filename,entryname,0,'O');
        break;
      case 'R':
        pA=new GenericAddress(ROOT_StorageType,CLID_StatisticsFile,
                              filename,entryname,0,'O');
        break;
      }
      if (0 != pA)    {
        status = registerAddress(pO, logname, pA);
        if (status.isSuccess())    {
          log << MSG::INFO << "Added stream file:" << filename
              << " as " << logname << endmsg;
          return status;
        }
        pA->release();
      }
    }
  }
  log << MSG::ERROR << "Cannot add " << ident << " invalid filename!" << endmsg;
  return StatusCode::FAILURE;
}
Example #7
0
// Work entry point
StatusCode EvtCollectionStream::execute() {
  StatusCode status = (m_pTupleSvc) ? StatusCode::SUCCESS : StatusCode::FAILURE;
  if ( status.isSuccess() )   {
    for ( Items::iterator i = m_itemList.begin(); i != m_itemList.end(); i++ )    {
      StatusCode iret = m_pTupleSvc->writeRecord((*i)->path());
      if ( !iret.isSuccess() )    {
        status = iret;
      }
    }
  }
  return status;
}
Example #8
0
//--------------------------------------------------------------------------------------------
// implementation of IService::reinitialize
//--------------------------------------------------------------------------------------------
StatusCode MTEventLoopMgr::reinitialize() {

  // initilaize the base class
  StatusCode sc = MinimalEventLoopMgr::reinitialize();

  MsgStream log(msgSvc(), name());
  if( sc.isFailure() ) {
    log << MSG::DEBUG << "Error Initializing base class MinimalEventLoopMgr." << endmsg;
    return sc;
  }

  // Check to see whether a new Event Selector has been specified
  setProperty(m_appMgrProperty->getProperty("EvtSel"));
  if( m_evtsel != "NONE" || m_evtsel.length() == 0) {
    IEvtSelector* theEvtSel;
    IService*     theSvc;
    sc = service( "EventSelector", theEvtSel );
    sc = service( "EventSelector", theSvc );
    if( sc.isSuccess() && ( theEvtSel != m_evtSelector ) ) {
      // Setup Event Selector
      m_evtSelector = theEvtSel;
      if (theSvc->state() == IService::INITIALIZED) {
        sc = theSvc->reinitialize();
        if( sc.isFailure() ){
          log << MSG::ERROR << "Failure Reinitializing EventSelector "
              << theSvc->name( ) << endmsg;
          return sc;
        }
      } else {
        sc = theSvc->initialize();
        if( sc.isFailure() ){
          log << MSG::ERROR << "Failure Initializing EventSelector "
              << theSvc->name( ) << endmsg;
          return sc;
        }
      }
      sc = theEvtSel->createContext(m_evtCtxt);
      if( !sc.isSuccess() ) {
        log << MSG::ERROR << "Can not create Context "
            << theSvc->name( ) << endmsg;
        return sc;
      }
      log << MSG::INFO << "EventSelector service changed to "
          << theSvc->name( ) << endmsg;
    }
  }
  else {
    m_evtSelector = 0;
    m_evtCtxt = 0;
  }
  return StatusCode::SUCCESS;
}
Example #9
0
// IEvtSelector::first()
StatusCode
EventSelector::lastOfPreviousStream(bool shutDown, EvtSelectorContext& iter) const {
  StatusCode status = StatusCode::SUCCESS;
  if ( shutDown )   {
    if ( iter.ID() >= 0 && iter.ID() < (long)m_streamtool->size() )   {
      const EventSelectorDataStream* s = m_streamtool->getStream(iter.ID());
      if ( s->isInitialized() )    {
        EventSelector* thisPtr = const_cast<EventSelector*>(this);
        if ( s->selector() && iter.context() )  {
          Context* ctxt = iter.context();
          s->selector()->releaseContext(ctxt);
          iter.set(0,0);
        }
        status = thisPtr->m_streamtool->finalizeStream(const_cast<EventSelectorDataStream*>(s));
        iter.set(0,0);
      }
    }
  }

  IDataStreamTool::size_type iter_id = iter.ID()-1;
  const EventSelectorDataStream* s ;
  status = m_streamtool->getPreviousStream( s , iter_id );

  if ( status.isSuccess() )   {

    if ( !s->isInitialized() )    {
      EventSelector* thisPtr = const_cast<EventSelector*>(this);
      status = thisPtr->m_streamtool->initializeStream(const_cast<EventSelectorDataStream*>(s));
    }
    if ( status.isSuccess() )   {
      const IEvtSelector* sel = s->selector();
      if ( sel )  {
        Context* ctxt = 0;
        status = sel->createContext(ctxt);
        if ( status.isSuccess() )   {
          status = sel->resetCriteria(s->criteria(), *ctxt);
          if ( status.isSuccess() )   {
            MsgStream log(msgSvc(), name());
            iter.set(this, iter_id, ctxt, 0);
            log << MSG::INFO << *s << endmsg;
            return StatusCode::SUCCESS;
          }
        }
      }
    }
  }

  iter.set(this, -1, 0, 0);
  return StatusCode::FAILURE;
}
Example #10
0
// IService::sysInitialize
StatusCode Service::sysInitialize() {
  StatusCode sc;

  try {
    m_targetState = Gaudi::StateMachine::INITIALIZED;
    Gaudi::Guards::AuditorGuard guard(this,
                                      // check if we want to audit the initialize
                                      (m_auditorInitialize) ? auditorSvc().get() : 0,
                                      IAuditor::Initialize);
    if ((name() != "MessageSvc") && msgSvc().isValid()) // pre-set the outputLevel from the MessageSvc value
      m_outputLevel = msgSvc()->outputLevel(name());
    sc = initialize(); // This should change the state to Gaudi::StateMachine::CONFIGURED
    if (sc.isSuccess())
      m_state = m_targetState;
    return sc;
  }
  catch ( const GaudiException& Exception )  {
    fatal() << "in sysInitialize(): exception with tag=" << Exception.tag()
        << " is caught" << endmsg;
    error() << Exception  << endmsg;
    //	  Stat stat( chronoSvc() , Exception.tag() );
  }
  catch( const std::exception& Exception ) {
    fatal() << "in sysInitialize(): standard std::exception is caught" << endmsg;
    error() << Exception.what()  << endmsg;
    //	  Stat stat( chronoSvc() , "*std::exception*" );
  }
  catch(...) {
    fatal() << "in sysInitialize(): UNKNOWN Exception is caught" << endmsg;
    //	  Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
  }

  return StatusCode::FAILURE;
}
//=============================================================================
// Initialization
//=============================================================================
StatusCode PatPixelHitManager::initialize() {
	m_event_number = 0;
	m_max_hits = 0;
  StatusCode sc = GaudiTool::initialize(); // must be executed first
  if ( sc.isFailure() ) return sc;  // error printed already by GaudiAlgorithm

  if ( msgLevel(MSG::DEBUG) ) debug() << "==> Initialize" << endmsg;

  m_veloPix      = getDet<DeVeloPix>( DeVeloPixLocation::Default );

  // make sure we are up-to-date on populated VELO stations
  registerCondition( (*(m_veloPix->leftSensorsBegin()))->geometry(), &PatPixelHitManager::rebuildGeometry );
  registerCondition( (*(m_veloPix->rightSensorsBegin()))->geometry(), &PatPixelHitManager::rebuildGeometry );

  // first update
  sc = updMgrSvc()->update(this);
  if(!sc.isSuccess()) {
    return Error( "Failed to update station structure." );
  }

  // invalidate measurements at the beginning of each event
  incSvc()->addListener(this, IncidentType::BeginEvent);

  m_pool.resize( 10000 );
  m_nextInPool = m_pool.begin();
  m_maxSize = 0;
  m_eventReady = false;

  return StatusCode::SUCCESS;
}
Example #12
0
// ============================================================================
StatusCode Tuples::TupleObj::fill( const char*  format ... )
{
  // check the underlying tuple
  if ( invalid()      ) { return InvalidTuple ; }
  // decode format string into tokens
  Tokens tokens ;
  tokenize( format , tokens , " ,;" );
  if ( tokens.empty() ) { return StatusCode::SUCCESS ; }
  /// decode arguments
  va_list valist ;
  va_start( valist , format ) ;
  // loop over all tokens
  StatusCode status = StatusCode::SUCCESS ;
  for( Tokens::const_iterator token = tokens.begin() ;
       tokens.end() != token && status.isSuccess() ; ++token )
  {
    const double val = va_arg( valist , double );
    status = column( *token , val );
    if( status.isFailure() )
    { Error ( "fill(): Can not add column '" + *token + "' " ) ; }
  }
  // mandatory !!!
  va_end( valist );
  //
  return status ;
}
Example #13
0
//-----------------------------------------------------------------------------
/// Switch to object directory (=Parent directory)
TDirectory* RootHistCnv::RConverter::changeDirectory(DataObject* pObject)
//-----------------------------------------------------------------------------
{
  if ( pObject )    {
    IRegistry* pReg = pObject->registry();
    if ( pReg )    {
      SmartIF<IDataManagerSvc> dataMgr(dataProvider());
      if ( dataMgr.isValid() )    {
        IRegistry* pParentReg = 0;
        StatusCode status = dataMgr->objectParent(pReg, pParentReg);
        if ( status.isSuccess() )  {
          IOpaqueAddress* pParAddr = pParentReg->address();
          if ( pParAddr )   {
            TDirectory* pParentDir = (TDirectory*)pParAddr->ipar()[0];
            if ( pParentDir )   {
              gDirectory->cd(pParentDir->GetPath());
              return pParentDir;
            }
          }
        }
      }
    }
  }
  return 0;
}
Example #14
0
//------------------------------------------------------------------------------
DataObject* HistogramSvc::createPath(CSTR newPath)  {
  std::string tmpPath = newPath;
  if (tmpPath[0] != SEPARATOR)    {
    tmpPath.insert(tmpPath.begin(), SEPARATOR);
    tmpPath.insert(tmpPath.begin(), m_rootName.begin(), m_rootName.end());
  }
  // Remove trailing "/" from newPath if it exists
  if (tmpPath.rfind(SEPARATOR) == tmpPath.length()-1) {
    tmpPath.erase(tmpPath.rfind(SEPARATOR),1);
  }
  DataObject* pObject = 0;
  StatusCode sc = DataSvc::findObject(tmpPath, pObject);
  if(sc.isSuccess()) {
    return pObject;
  }
  int sep = tmpPath.rfind(SEPARATOR);
  std::string rest(tmpPath, sep+1, tmpPath.length()-sep);
  std::string subPath(tmpPath, 0, sep);
  if(0 != sep) {
    createPath(subPath);
  }
  else {
    MsgStream log(msgSvc(), name());
    log << MSG::ERROR << "Unable to create the histogram path" << endmsg;
    return 0;
  }
  pObject = createDirectory(subPath, rest);
  return pObject;
}
/// IService implementation: Db event selector override
StatusCode StagedIODataManager::initialize() {
  // Initialize base class
  StatusCode status = Service::initialize();
  MsgStream log(msgSvc(), name());
  log << MSG::DEBUG << "StagedIODataManager initializing..." << endmsg;
  if ( !status.isSuccess() ) {
    log << MSG::ERROR << "Error initializing base class Service!" << endmsg;
    return status;
  }
  // Retrieve conversion service handling event iteration
  m_catalog = serviceLocator()->service(m_catalogSvcName);
  if( !m_catalog.isValid() ) {
    log << MSG::ERROR
    << "Unable to localize interface IFileCatalog from service:"
    << m_catalogSvcName << endmsg;
    return StatusCode::FAILURE;
  }
  m_incSvc = serviceLocator()->service("IncidentSvc");
  if( !m_incSvc.isValid() ) {
    log << MSG::ERROR << "Error initializing IncidentSvc Service!" << endmsg;
    return status;
  }

  m_stager = serviceLocator()->service("FileStagerSvc", false);
  if( !m_stager.isValid() ) {
    log << MSG::ERROR << "Error initializing File Stager Service!" << endmsg;
    return status;
  }
  return status;
}
Example #16
0
StatusCode
StatusCodeSvc::initialize() {

  StatusCode sc = Service::initialize();
  if (!sc.isSuccess()) return sc;

  MsgStream log( msgSvc(), name() );
  log << MSG::INFO << "initialize" << endmsg;

  std::vector<std::string>::const_iterator itr;
  for (itr = m_pFilter.value().begin(); itr != m_pFilter.value().end(); ++itr) {
    // we need to do this if someone has gotten to regFnc before initialize

    string fnc,lib;
    parseFilter(*itr,fnc,lib);

    if (fnc != "") {
      filterFnc(fnc);
      m_filterfnc.insert(fnc);
    }

    if (lib != "") {
      filterLib(lib);
      m_filterlib.insert(lib);
    }

  }

  return StatusCode::SUCCESS;

}
Example #17
0
// IService::sysStart
StatusCode Service::sysStart() {
  StatusCode sc;

  try {
    m_targetState = Gaudi::StateMachine::ChangeState(Gaudi::StateMachine::START,m_state);
    Gaudi::Guards::AuditorGuard guard(this,
                                      // check if we want to audit the initialize
                                      (m_auditorStart) ? auditorSvc().get() : 0,
                                      IAuditor::Start);
    sc = start();
    if (sc.isSuccess())
      m_state = m_targetState;
    return sc;
  }
  catch ( const GaudiException& Exception )  {
    fatal() << "in sysStart(): exception with tag=" << Exception.tag()
        << " is caught" << endmsg;
    error() << Exception  << endmsg;
    //    Stat stat( chronoSvc() , Exception.tag() );
  }
  catch( const std::exception& Exception ) {
    fatal() << "in sysStart(): standard std::exception is caught" << endmsg;
    fatal() << Exception.what()  << endmsg;
    //    Stat stat( chronoSvc() , "*std::exception*" );
  }
  catch(...) {
    fatal() << "in sysStart(): UNKNOWN Exception is caught" << endmsg;
    //    Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
  }

  return StatusCode::FAILURE;
}
Example #18
0
/// Add data service
StatusCode PersistencySvc::addCnvService(IConversionSvc* servc)    {
    if ( 0 != servc )   {
        long type = servc->repSvcType();
        long def_typ = (m_cnvDefault) ? m_cnvDefault->repSvcType() : 0;
        Services::iterator it = m_cnvServices.find( type );
        IConversionSvc* cnv_svc = 0;
        if ( it != m_cnvServices.end() )    {
            cnv_svc = (*it).second.conversionSvc();
        }
        if ( type == def_typ )     {
            m_cnvDefault = servc;
        }
        if ( cnv_svc != servc )   {
            IAddressCreator* icr = 0;
            StatusCode status  = servc->queryInterface(IAddressCreator::interfaceID(), pp_cast<void>(&icr));
            if ( status.isSuccess() )   {
                IService* isvc = 0;
                status = servc->queryInterface(IService::interfaceID(), pp_cast<void>(&isvc));
                if ( status.isSuccess() )    {
                    if ( 0 != cnv_svc )   {
                        removeCnvService (type).ignore();
                    }
                    std::pair<Services::iterator, bool> p =
                        m_cnvServices.insert( Services::value_type( type, ServiceEntry(type, isvc, servc, icr)));
                    if( p.second )    {
                        info() << "Added successfully Conversion service:" << isvc->name() << endmsg;
                        servc->addRef();
                        servc->setAddressCreator(this).ignore();
                        servc->setDataProvider(m_dataSvc).ignore();
                        return StatusCode::SUCCESS;
                    }
                    info() << "Cannot add Conversion service of type " << isvc->name() << endmsg;
                    isvc->release();
                    icr->release();
                    return StatusCode::FAILURE;
                }
                icr->release();
            }
            info() << "Cannot add Conversion service of type " << type << endmsg;
            return StatusCode::FAILURE;
        }
        else    {
            return StatusCode::SUCCESS;
        }
    }
    return BAD_STORAGE_TYPE;
}
Example #19
0
//------------------------------------------------------------------------------
StatusCode HistogramSvc::initialize()   {
  MsgStream log(msgSvc(), name());
  StatusCode status = DataSvc::initialize();
  // Set root object
  if (status.isSuccess()) {
    DataObject* rootObj = new DataObject();
    status = setRoot("/stat", rootObj);
    if (!status.isSuccess()) {
      log << MSG::ERROR << "Unable to set hstogram data store root." << endmsg;
      delete rootObj;
      return status;
    }
    IConversionSvc* svc = 0;
    status = service("HistogramPersistencySvc",svc,true);
    if ( status.isSuccess() )   {
      setDataLoader( svc ).ignore();
      svc->release();
    }
    else  {
      log << MSG::ERROR << "Could not find HistogramPersistencySvc." << endmsg;
      return status;
    }
    // Connect all input streams (if any)
    for (DBaseEntries::iterator j = m_input.begin(); j != m_input.end(); j++)    {
      status = connectInput(*j);
      if (!status.isSuccess())  {
        return status;
      }
    }
  }
  if ( !m_defs1D.empty() )
  {
    log << MSG::INFO << " Predefined 1D-Histograms: " << endmsg ;
    for ( Histo1DMap::const_iterator ih = m_defs1D.begin() ;
          m_defs1D.end() != ih ; ++ih )
    {
      log << MSG::INFO
          << " Path='"       << ih->first  << "'"
          << " Description " << ih->second << endmsg ;
    }
  }
  return status;
}
Example #20
0
  // Initialize engine
  template <class TYPE> StatusCode Engine<TYPE>::initialize()          {
    m_seeds.erase(m_seeds.begin(), m_seeds.end());
    StatusCode status = RndmEngine::initialize();
    if ( m_seeds.size() == 0 )  {
      // Default seeds
      long theSeed = 1234567;
      m_seeds.push_back(theSeed);
      m_seeds.push_back(0);
    }
    MsgStream log(msgSvc(), name());
    if ( status.isSuccess() )   {
      status = initializeEngine();
      if ( status.isSuccess() )   {
        log << MSG::INFO << "Generator engine type:"
        	  << System::typeinfoName(typeid(TYPE))
	          << endmsg;
        if ( m_useTable )   {
          if ( m_row > 214 || m_col > 1 )   {
            log << MSG::ERROR << "Generator engine seed table has dimension [215][2], you gave:"
                << " Row=" << m_row << " Column:" << m_col << endmsg;
            status = StatusCode::FAILURE;
          }
          else    {
            log << MSG::INFO << "Generator engine seeds from table."
                << " Row=" << m_row << " Column:" << m_col << endmsg;
          }
        }
        log << "Current Seed:" << m_hepEngine->getSeed();
        log << " Luxury:" << m_lux;
        log << endmsg;
        // Use the default static engine if required (e.g. for GEANT4)
        if ( m_setSingleton )   {
            HepRandom::setTheEngine(m_hepEngine);
          log << "This is the GEANT4 engine!" << endmsg;
        }
        return status;
      }
    }
    log << MSG::ERROR << "Cannot initialze random engine of type:"
    	  << System::typeinfoName(typeid(TYPE))
        << endmsg;
    return status;
  }
Example #21
0
/// Create event address using event selector
StatusCode MTEventLoopMgr::getEventRoot(IOpaqueAddress*& refpAddr)  {
  refpAddr = 0;
  StatusCode sc = m_evtSelector->next(*m_evtCtxt);
  if ( !sc.isSuccess() )  {
    return sc;
  }
  // Create root address and assign address to data service
  sc = m_evtSelector->createAddress(*m_evtCtxt,refpAddr);
  if( !sc.isSuccess() )  {
    sc = m_evtSelector->next(*m_evtCtxt);
    if ( sc.isSuccess() )  {
      sc = m_evtSelector->createAddress(*m_evtCtxt,refpAddr);
      if ( !sc.isSuccess() )  {
        MsgStream log( msgSvc(), name() );
        log << MSG::WARNING << "Error creating IOpaqueAddress." << endmsg;
      }
    }
  }
  return sc;
}
Example #22
0
StatusCode RecordStream::finalize() {
  MsgStream log(msgSvc(), name());
  log << MSG::INFO << "Set up File Summary Record" << endmsg;
  if( !m_fireIncidents && log.level() <= MSG::VERBOSE )
    log << MSG::VERBOSE << "will not fire incidents" << endmsg;
  StatusCode sc = OutputStream::execute();
  if( !sc.isSuccess() )  {
    log << MSG::WARNING << "Error writing run summary record....." << endmsg;
  }
  return OutputStream::finalize();
}
Example #23
0
// IService implementation: initialize the service
StatusCode AppMgrRunable::initialize()   {
  StatusCode sc = Service::initialize();
  if ( sc.isSuccess() )     {
    sc = serviceLocator()->queryInterface(IAppMgrUI::interfaceID(), pp_cast<void>(&m_appMgrUI));
    // get property from application manager
    if ( m_evtMax == (int)0xFEEDBABE )   {
      SmartIF<IProperty> props(serviceLocator());
      setProperty(props->getProperty("EvtMax")).ignore();
    }
  }
  return sc;
}
Example #24
0
//=============================================================================
// Initialisation
//=============================================================================
StatusCode TbPacketRecycler::initialize() {

  // Initialise the base class.
  StatusCode sc = TbAlgorithm::initialize();
  if (sc.isFailure()) return sc;
  IToolSvc* toolsvc = nullptr;
  sc = service("ToolSvc", toolsvc);
  if (!sc.isSuccess()) {
    return Error("Unable to get a handle to the tool service", sc);
  }
  for (unsigned int i = 0; i < m_nPlanes; ++i) {
    TbRawStream* foo = nullptr;
    sc = toolSvc()->retrieveTool("TbRawStream/" + std::to_string(i), foo);
    if (!sc.isSuccess()) {
      return Error("Unable to retrieve TbRawStream for plane " + 
                   std::to_string(i), sc);
    }
    m_streams.push_back(foo);
  }
  return StatusCode::SUCCESS;
}
//=============================================================================
StatusCode InputStreamParser::initialize() {

  MsgStream logger(msgSvc(), name());

  StatusCode status = AlgTool::initialize();
  if( !status.isSuccess() ) {
    logger << MSG::FATAL << "Error. Cannot initialize base class." << endmsg;
    return status;
  }

  return StatusCode::SUCCESS;

}
//====================================================
StatusCode InputStreamParser::extractStreams(const StreamSpecs & inputs, StreamSpecs & parsedInputs) {
  m_inCollection = & parsedInputs;
  StatusCode sc = StatusCode::FAILURE;
  MsgStream log(msgSvc(), name());
  for ( std::vector<std::string>::const_iterator itr = inputs.begin(); itr != inputs.end(); ++itr ) {
    sc = extractStream(*itr);
    if (!sc.isSuccess()) {
      log << MSG::ERROR << " Could not access the file(s). " << endmsg;
      ::abort();
    }
  }

  return sc;
}
Example #27
0
/// Get next iteration item from the event loop context, but skip jump elements
StatusCode EventSelector::next(Context& refCtxt, int /* jump */ ) const  {
  EvtSelectorContext *pIt  = dynamic_cast<EvtSelectorContext*>(&refCtxt);
  if ( pIt )    {
    if ( pIt->ID() != -1 ) {
      const EventSelectorDataStream* s = m_streamtool->getStream(pIt->ID());
      Context* it = pIt->context();
      IEvtSelector* sel = s->selector();
      if ( it && sel )    { // First exploit the current stream
        StatusCode sc = sel->next(*it);  // This stream is empty: advance to the next stream
        if ( !sc.isSuccess() )   {
          m_incidentSvc->fireIncident(Incident(s->dbName(),IncidentType::EndInputFile));
          sc = firstOfNextStream(true, *pIt);
          if (sc.isSuccess() ) sc = next(*pIt);
        }
        else  {
          pIt->increaseCounters(false);
          pIt->set(it, 0);
          printEvtInfo(pIt);
        }
        return sc;
      }
      else if ( m_reconfigure )  {
        StatusCode sc = firstOfNextStream(false, *pIt);
        printEvtInfo(pIt);
        return sc;
      }
    }
    else if ( m_reconfigure )  {
      StatusCode sc = firstOfNextStream(false, *pIt);
      printEvtInfo(pIt);
      return sc;
    }
    pIt->increaseCounters(false);
  }
  printEvtInfo(pIt);
  return StatusCode::FAILURE;
}
Example #28
0
/// IService implementation: Db event selector override
StatusCode EventSelector::initialize()    {
  // Initialize base class
  StatusCode status = Service::initialize();
  MsgStream logger(msgSvc(), name());
  if ( !status.isSuccess() )    {
    logger << MSG::ERROR << "Error initializing base class Service!" << endmsg;
    return status;
  }
  // Get the references to the services that are needed by the ApplicationMgr itself
  m_incidentSvc = serviceLocator()->service("IncidentSvc");
  if( !m_incidentSvc.isValid() )  {
    logger << MSG::FATAL << "Error retrieving IncidentSvc." << endmsg;
    return StatusCode::FAILURE;
  }
  if ( m_evtMax != INT_MAX )   {
    logger << MSG::ERROR << "EvtMax is an obsolete property of the event selector." << endmsg;
    logger << MSG::ERROR << "Please set \"ApplicationMgr.EvtMax = " << m_evtMax
           << ";\" to process the requested number of events." << endmsg;
    return StatusCode::FAILURE;
  }

  m_toolSvc = serviceLocator()->service("ToolSvc");
  if ( !m_toolSvc.isValid() ) {
    logger << MSG::ERROR << " Could not locate the Tool Service! " << endmsg;
    return StatusCode::FAILURE;
  }

  status = m_toolSvc->retrieveTool(m_streamManager.c_str(), m_streamtool, this);

  if( status.isFailure() ) {
    logger << MSG::ERROR << "Error initializing "
           << m_streamManager << endmsg;
    return status;
  }

  status = m_streamtool->clear();
  if( status.isFailure() ) {
    // Message already printed by the tool
    return status;
  }

  status = m_streamtool->addStreams(m_streamSpecs);

  m_streamSpecsLast = m_streamSpecs;

  m_streamID          = 0;

  return status;
}
Example #29
0
StatusCode
ServiceLocatorHelper::createService(const std::string& name,
				    const InterfaceID& iid,
				    void** ppSvc) const {
  SmartIF<IService> theSvc = service(name, false, true);
  if (!theSvc.isValid()) return StatusCode::FAILURE;
  StatusCode sc = theSvc->queryInterface(iid, ppSvc);
  if (!sc.isSuccess()) {
    *ppSvc = 0;
    log() << MSG::ERROR
      << "ServiceLocatorHelper::createService: wrong interface id "
      << iid << " for service " << name << endmsg;
  }
  return sc;
}
Example #30
0
//--------------------------------------------------------------------------
StatusCode RootHistCnv::RConverter::createAddress(const std::string& rzdir,
						  const CLID& clid,
						  long id,
						  TObject* pTobj,
						  IOpaqueAddress*& refpAddress)
//--------------------------------------------------------------------------
{
  std::ostringstream obj; obj << id;
  StatusCode status = createAddress(rzdir, clid, obj.str(), pTobj, refpAddress);
  if ( status.isSuccess() )   {
    unsigned long* ipar = (unsigned long*)refpAddress->ipar();
    ipar[0] = id;
  }
  return status;
}