| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

RegistrationSequenceCnv.cc

Go to the documentation of this file.
00001 #include "RootIOSvc/RootIOAddress.h"
00002 #include "PerBaseEvent/RegistrationSequenceCnv.h"
00003 #include "PerBaseEvent/TemporalDataObjectCnv.h"
00004 
00005 #include "Event/HeaderObject.h"
00006 
00007 #include "DybKernel/ObjectReg.h"
00008 #include "GaudiKernel/IDataManagerSvc.h"
00009 #include "GaudiKernel/IDataProviderSvc.h"
00010 
00011 using namespace DayaBay;
00012 using namespace std;
00013 
00014 RegistrationSequenceCnv::RegistrationSequenceCnv(ISvcLocator* svc)
00015     : RootIOTypedCnv<PerRegistrationSequence,RegistrationSequence>("PerRegistrationSequence",
00016                                                                  classID(),svc)
00017 {
00018 }
00019 
00020 RegistrationSequenceCnv::~RegistrationSequenceCnv()
00021 {
00022 }
00023 
00024 
00025 StatusCode RegistrationSequenceCnv::PerToTran(const PerRegistrationSequence& perobj, 
00026                                               RegistrationSequence& tranobj)
00027 {
00028     MsgStream log(msgSvc(), "RegistrationSequenceCnv::PerToTran");
00029 
00030     StatusCode sc = TemporalDataObjectCnv::toTran(perobj,tranobj);    
00031     if (sc.isFailure()) {
00032         log<<MSG::ERROR<<"Failed in PerToTran"<<endreq;
00033     } else {
00034         log<<MSG::DEBUG<<"RegistrationSequence converted"<<endreq;
00035     }
00036     return sc;
00037 }
00038 
00039 StatusCode RegistrationSequenceCnv::fillObjRefs(IOpaqueAddress* /* addr */,
00040                                                 DataObject* tranobj)
00041 {
00042     MsgStream log(msgSvc(), "RegistrationSequenceCnv::fillObjRefs");
00043 
00044     RegistrationSequence* rs = dynamic_cast<RegistrationSequence*>(tranobj);
00045     if (!rs) return StatusCode::FAILURE;
00046 
00047     unsigned int skipped = 0;
00048 
00049     PerRegistrationSequence& trs = getPerInputObject();
00050     size_t siz = trs.reglist.size();
00051     log << MSG::DEBUG << siz << " registrations" << endreq;
00052     for (size_t ind = 0; ind < siz; ++ind) {
00053 
00054         const PerRegSeqReg& reg = trs.reglist[ind];
00055 
00056         if (reg.path == "/Event/Random/RandomHeader") {
00057             ++skipped;
00058             log << MSG::DEBUG
00059                 << "Not retrieving '/Event/Random/RandomHeader'" 
00060                 << endreq;
00061             continue;
00062         }
00063 
00064         RootInputAddress* ria = new RootInputAddress(reg.clid,reg.path);
00065 
00066         ria->setEntry(reg.entry);
00067         ria->setFileNumber(m_ris->fileNumber());
00068 
00069         RootInputStream* ris = m_rioSvc->inputStream(*ria);
00070         if (!ris) {
00071           log << MSG::WARNING
00072               << "No input stream for " << reg.path
00073               << " will not register anything in the TES"
00074               << endreq;
00075           delete ria;
00076           continue;
00077         }
00078         ria->setStream(ris);
00079 
00080         // register address
00081         log << MSG::DEBUG << "registering " << reg.path
00082             << " entry " << reg.entry << " fileNum " << m_ris->fileNumber() 
00083             << endreq;
00084 
00085         StatusCode sc = m_rioSvc->dataMgrSvc()->registerAddress(reg.path,ria);
00086         
00087         if(sc.getCode()==IDataProviderSvc::DOUBL_OBJ_PATH) {
00088           // Two data objects in the same location.
00089           log << MSG::DEBUG << "IDataProviderSvc::DOUBL_OBJ_PATH Catched "<<endreq;
00090           DataObject* exist_obj=0;
00091           // Since it exist unregister it first, then register the address again.
00092           // It is in AES now if AES is in use.
00093           sc = m_rioSvc->dataSvc()->findObject(reg.path,exist_obj);
00094           if(sc.isSuccess() && exist_obj) {
00095             m_rioSvc->dataSvc()->unregisterObject(exist_obj);       
00096             exist_obj->release(); // why release, check DybDataSvc.cpp and DocDB 3242, page 2 memo
00097             sc = m_rioSvc->dataMgrSvc()->registerAddress(reg.path,ria);
00098           }
00099         }
00100 
00101         if (sc.isFailure()) {
00102           log << MSG::ERROR
00103               << "failed to register address at " << reg.path
00104               << endreq;
00105           return sc;
00106         }
00107 
00108         DataObject* other_tranobj = 0;
00109         // This should trigger an RS registration.
00110         sc = m_rioSvc->dataSvc()->retrieveObject(reg.path,other_tranobj);
00111         if (!other_tranobj || sc.isFailure()) {
00112             log << MSG::WARNING << "failed to retrieve object at " 
00113                 << reg.path << ", continuing...." << endreq;
00114             continue;
00115         }
00116         log << MSG::DEBUG << "retrieved " << reg.path 
00117             << " registration #" << rs->size()
00118             << endreq;
00119 
00120         log << MSG::DEBUG << "inputaddress "<<ria->entry()<<"\t"<<ria->tespath()<<endreq;
00121 
00122         TemporalDataObject* tdo=dynamic_cast<TemporalDataObject*>(other_tranobj);
00123         log << MSG::DEBUG <<tdo<<endreq;
00124         if(tdo!=0) tdo->setInputAddress(ria);
00125     }
00126     log << MSG::DEBUG << "copied " << rs->size()
00127         << " registrations" << endreq;
00128     if (siz - rs->size() > skipped) {
00129         log << MSG::WARNING << "have " << siz
00130             << " registrations from file but only converted " 
00131             << rs->size() 
00132             << " (" << skipped << " skipped on purpose)"
00133             << endreq;
00134     }
00135     return StatusCode::SUCCESS;
00136 }
00137 
00138 StatusCode RegistrationSequenceCnv::TranToPer(const RegistrationSequence& tranobj, 
00139                                               PerRegistrationSequence& perobj)
00140 {
00141     StatusCode sc = TemporalDataObjectCnv::toPer(tranobj,perobj);    
00142     if (sc.isFailure()) return sc;
00143 
00144     perobj.reglist.clear();
00145     return StatusCode::SUCCESS;
00146 }
00147 
00148 StatusCode RegistrationSequenceCnv::fillRepRefs(IOpaqueAddress* /* addr */,
00149                                                 DataObject* tranobj)
00150 {
00151     RegistrationSequence* rs = dynamic_cast<RegistrationSequence*>(tranobj);
00152     if (!rs) return StatusCode::FAILURE;
00153 
00154     PerRegistrationSequence& trs = getPerOutputObject();
00155 
00156     const IRegistrationSequence::Registrations &rlist = rs->registrations();
00157     IRegistrationSequence::Registrations::const_iterator it, done = rlist.end();
00158     for (it = rlist.begin(); it != done; ++it) {
00159         const ObjectReg& oreg = *it;
00160         if( oreg.store() ){
00161           trs.reglist.push_back(PerRegSeqReg(oreg.path(),oreg.entry(),
00162                                              oreg.object()->clID()));
00163         }
00164     }
00165 
00166     return StatusCode::SUCCESS;
00167 }
00168 
00169 
00170 
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:18:44 2011 for PerBaseEvent by doxygen 1.4.7