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

In This Package:

Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes
DybInputLoadTool Class Reference

A tool to do input loading of Dyb RootIO files. More...

#include <DybInputLoadTool.h>

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

List of all members.

Public Types

typedef std::pair< std::string,
DayaBay::HeaderObject * > 
ExecutionFrameEntry
typedef std::vector
< ExecutionFrameEntry
ExecutionFrame

Public Member Functions

 DybInputLoadTool (const std::string &type, const std::string &name, const IInterface *parent)
virtual ~DybInputLoadTool ()
StatusCode queryInterface (const InterfaceID &riid, void **ppvIf)
virtual StatusCode initialize ()
virtual StatusCode finalize ()
DayaBay::HeaderObjectget_header (int entry, const std::string &path, bool input_headers=true, int fileNumber=-1)
IDybInputLoadTool::ExecutionFrame get_frame (int entry, const std::string &path=DayaBay::RegistrationSequenceLocation::Default, bool input_headers=true)
int get_entries (const std::string &path)

Static Public Member Functions

static const InterfaceID & interfaceID ()

Private Types

typedef std::pair< int,
std::string > 
HoID
typedef std::map< HoID,
DayaBay::HeaderObject * > 
HoCache

Private Member Functions

RootInputStreamget_stream (const std::string &path)
template<class PerType >
PerType * get_pobj (int entry, const std::string &path, int fileNumber=-1)
DataObject * get_dataobject (int clID, const std::string &path)

Private Attributes

std::string m_rioSvcName
std::string m_convSvcName
IRootIOSvcm_rioSvc
IConversionSvc * m_convSvc
HoCache m_hocache
bool m_cache_hos

Detailed Description

A tool to do input loading of Dyb RootIO files.

This will allow loading of HeaderObjects w/out using the full Gaudi mechanism and, in particular, w/out involving the event store. It should probably not be used in jobs where the normal input mechanism is used.

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

Definition at line 31 of file DybInputLoadTool.h.


Member Typedef Documentation

typedef std::pair<int,std::string> DybInputLoadTool::HoID [private]

Definition at line 73 of file DybInputLoadTool.h.

Definition at line 74 of file DybInputLoadTool.h.

typedef std::pair<std::string,DayaBay::HeaderObject*> IDybInputLoadTool::ExecutionFrameEntry [inherited]

Definition at line 29 of file IDybInputLoadTool.h.

typedef std::vector<ExecutionFrameEntry> IDybInputLoadTool::ExecutionFrame [inherited]

Definition at line 30 of file IDybInputLoadTool.h.


Constructor & Destructor Documentation

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

Definition at line 18 of file DybInputLoadTool.cc.

    : GaudiTool(type,name,parent)
    , m_rioSvc(0)
    , m_convSvc(0)
    , m_cache_hos(false)
{
    declareInterface<IDybInputLoadTool>(this);
    declareProperty("RootIOSvc",m_rioSvcName="RootIOCnvSvc",
                    "Name of the IRootIOSvc to use");
    declareProperty("ConversionSvc",m_convSvcName="RootIOCnvSvc",
                    "Name of the IConversionSvc to use");
}
DybInputLoadTool::~DybInputLoadTool ( ) [virtual]

Definition at line 33 of file DybInputLoadTool.cc.

{
}

Member Function Documentation

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

Definition at line 37 of file DybInputLoadTool.cc.

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

Definition at line 48 of file DybInputLoadTool.cc.

{
    MsgStream log(msgSvc(), "DybInputLoadTool");
    { // IRootIOSvc
        IService* isvc = 0; 
        StatusCode sc = this->service(m_rioSvcName,isvc,true);
        if(sc.isFailure()){
            log << MSG::ERROR << "Failed to get "<<m_rioSvcName<<" RootIOCnvSvc" << endreq;
            return sc;
        }

        sc = isvc->queryInterface(IRootIOSvc::interfaceID(), (void**)&m_rioSvc);
        if (sc.isFailure()) {
            log << MSG::ERROR << "Service " << m_rioSvcName
                << " does not implement IRootIOSvc" << endreq;
            return sc;
        }
    }

    { // IConversionSvc
        IService* isvc = 0; 
        StatusCode sc = this->service(m_convSvcName,isvc,true);
        if(sc.isFailure()){
            log << MSG::ERROR << "Failed to get "<<m_convSvcName<<" ConversionSvc" << endreq;
            return sc;
        }

        sc = isvc->queryInterface(IConversionSvc::interfaceID(), (void**)&m_convSvc);
        if (sc.isFailure()) {
            log << MSG::ERROR << "Service " << m_convSvcName
                << " does not implement IConversionSvc" << endreq;
            return sc;
        }
    }
    return StatusCode::SUCCESS;
}
StatusCode DybInputLoadTool::finalize ( ) [virtual]

Definition at line 85 of file DybInputLoadTool.cc.

{
    return StatusCode::SUCCESS;
}
HeaderObject * DybInputLoadTool::get_header ( int  entry,
const std::string &  path,
bool  input_headers = true,
int  fileNumber = -1 
) [virtual]

Implements IDybInputLoadTool.

Definition at line 196 of file DybInputLoadTool.cc.

{
    MsgStream log(msgSvc(), "DybInputLoadTool");

    // See if we are cacheing hos and if we have a ho we know.
    if (m_cache_hos) {
        HoID id(entry,path);
        HoCache::iterator it = m_hocache.find(id);
        if (it != m_hocache.end()) {
            return it->second;
        }
    }

    PerHeaderObject* pho = this->get_pobj<PerHeaderObject>(entry,path,fileNumber);
    if (!pho) return 0;

    log << MSG::DEBUG << "get_header("<<entry<<",\"" << path << "\"," 
        << " id=" << pho->clID 
        << " w/ "
        << pho->inputHeaders.size()
        << " inputHeaders, " << input_headers<<",f#"<<fileNumber
        <<") -> ho @ " << pho->context.GetTimeStamp()
        <<endreq;

    std::vector<PerRef> pinputHeaders = pho->inputHeaders;
    pho->inputHeaders.clear();

    std::vector<const IHeader*> tinputHeaders;
    if (input_headers) {
        
        if (fileNumber == -1) { // we MUST set a file number when
                                // resolving references
            RootInputStream* ris = this->get_stream(path);
            fileNumber = ris->fileNumber();
            log << MSG::DEBUG << "get_header: using file number " << fileNumber << endreq;
        }

        for (size_t ind=0; ind< pinputHeaders.size(); ++ind) {
            HeaderObject* ho = this->get_header(pinputHeaders[ind].entry(),
                                                pinputHeaders[ind].path(),
                                                input_headers, fileNumber);
            if (ho) tinputHeaders.push_back(ho);
        }
    }
    log << MSG::DEBUG << "get_header: restored " << tinputHeaders.size()
        << " inputHeaders out of a possible "
        << pinputHeaders.size() << endreq;

    DataObject* dobj = this->get_dataobject(pho->clID, path);
    if (!dobj) return 0;
    
    HeaderObject* ho = dynamic_cast<HeaderObject*>(dobj);
    if (input_headers) ho->setInputHeaders(tinputHeaders);

    log << MSG::DEBUG << "get_header: got HO: id#" << ho->clID()
        << " \"" << ho->defLoc() << "\" @ " << ho->context().AsString()
        << endreq;

    // If we are cacheing hos keep the ho we know.
    if (m_cache_hos) {
        m_hocache[HoID(entry,path)] = ho;
    }

    return ho;
}
IDybInputLoadTool::ExecutionFrame DybInputLoadTool::get_frame ( int  entry,
const std::string &  path = DayaBay::RegistrationSequenceLocation::Default,
bool  input_headers = true 
) [virtual]

Implements IDybInputLoadTool.

Definition at line 264 of file DybInputLoadTool.cc.

{
    MsgStream log(msgSvc(), "DybInputLoadTool");

    IDybInputLoadTool::ExecutionFrame ef;

    PerRegistrationSequence* prs = this->get_pobj<PerRegistrationSequence>(entry,path);
    if (!prs) return ef;

    m_cache_hos = true;
    m_hocache.clear();
    for (size_t ind=0; ind < prs->reglist.size(); ++ind) {
        RootInputStream* ris = this->get_stream(path);
        int fileNumber = ris->fileNumber();

        HeaderObject* ho = this->get_header(prs->reglist[ind].entry,
                                            prs->reglist[ind].path,
                                            input_headers, fileNumber);
        if (!ho) {
            log << MSG::ERROR << "Failed to get Header object at entry " 
                << prs->reglist[ind].entry << " and path " << prs->reglist[ind].path << endreq;
            continue;
        }

        IDybInputLoadTool::ExecutionFrameEntry entry(prs->reglist[ind].path,ho);
        ef.push_back(entry);
    }
    m_cache_hos = false;
    m_hocache.clear();
    return ef;
}
int DybInputLoadTool::get_entries ( const std::string &  path) [virtual]

Implements IDybInputLoadTool.

Definition at line 297 of file DybInputLoadTool.cc.

{
    IRootIOSvc::InputStreamMap& ism = m_rioSvc->inputStreams();
    IRootIOSvc::InputStreamMap::iterator it = ism.find(path);
    if (it != ism.end()) {
        return it->second->entries();
    }
    return -1;
}
RootInputStream * DybInputLoadTool::get_stream ( const std::string &  path) [private]

Definition at line 90 of file DybInputLoadTool.cc.

{
    IRootIOSvc::InputStreamMap& ism = m_rioSvc->inputStreams();
    IRootIOSvc::InputStreamMap::iterator it = ism.find(path);
    if (it != ism.end()) {
        return it->second;
    }
    it = ism.find("default");
    if (it != ism.end()) {
        return it->second;
    }
    return 0;
}
template<class PerType >
PerType * DybInputLoadTool::get_pobj ( int  entry,
const std::string &  path,
int  fileNumber = -1 
) [private]

Definition at line 110 of file DybInputLoadTool.cc.

{
    MsgStream log(msgSvc(), "DybInputLoadTool");

    RootInputStream* ris = this->get_stream(path);
    if (!ris) {
        log << MSG::ERROR << "Failed to get input stream for " << path << endreq;
        return 0;
    }

    if (fileNumber == -1) {
        bool ok = ris->setEntry(entry);
        if (!ok) {
            log << MSG::ERROR << "Failed to setEntry(" << entry
                << ") with stream \"" << path << "\"" << endreq;
            return 0;
        }
    }
    else {
        bool ok = ris->setFileEntry(fileNumber,entry);
        if (!ok) {
            log << MSG::ERROR << "Failed to setFileEntry(" << fileNumber << "," << entry
                << ") with stream \"" << path << "\"" << endreq;
            return 0;
        }
    }

    PerType* pto = dynamic_cast<PerType*>(ris->obj());
    if (!pto) {
        log << MSG::ERROR << "Cast failed for object at entry = " << entry
            << " in stream \"" << path << "\"" << endreq;
        return 0;
    }

    return pto;
}
DataObject * DybInputLoadTool::get_dataobject ( int  clID,
const std::string &  path 
) [private]

Definition at line 155 of file DybInputLoadTool.cc.

{
    MsgStream log(msgSvc(), "DybInputLoadTool");

    IConverter* converter = m_convSvc->converter(clID);
    if (!converter) {
        log << MSG::ERROR << "Failed to get converter for class ID = " << clID
            << " in stream \"" << path << "\"" << endreq;
        return 0;
    }

    RootIOBaseCnv* riocnv = dynamic_cast<RootIOBaseCnv*>(converter);
    if (!riocnv) {
        log << MSG::ERROR << "Converter not a RootIOBaseCnv for class ID = " << clID
            << " in stream \"" << path << "\"" << endreq;
        return 0;
    }

    RootInputStream* ris = this->get_stream(path);
    if (!ris) {
        log << MSG::ERROR << "Failed to get input stream for " << path << endreq;
        return 0;
    }

    RootInputAddress ria(clID,path);
    ria.setStream(ris);
    ria.readDone();             // It is assumed that the persistent
                                // object is already read into memory
                                // (in this case, it is done in
                                // get_pobj()) so we tell createObj()
                                // not to do it again.
    DataObject* dobj = 0;
    StatusCode sc = riocnv->createObj(&ria,dobj);
    if (sc.isFailure()) {
        log << MSG::ERROR << "Failed to createObj for class ID = " << clID
            << " in stream \"" << path << "\"" << endreq;
        return 0;
    }
    return dobj;
}
const InterfaceID & IDybInputLoadTool::interfaceID ( ) [static, inherited]

Definition at line 7 of file IDybInputLoadTool.cc.

{
    return IID_IDybInputLoadTool; 
}

Member Data Documentation

std::string DybInputLoadTool::m_rioSvcName [private]

Definition at line 69 of file DybInputLoadTool.h.

std::string DybInputLoadTool::m_convSvcName [private]

Definition at line 69 of file DybInputLoadTool.h.

Definition at line 70 of file DybInputLoadTool.h.

IConversionSvc* DybInputLoadTool::m_convSvc [private]

Definition at line 71 of file DybInputLoadTool.h.

Definition at line 75 of file DybInputLoadTool.h.

Definition at line 76 of file DybInputLoadTool.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