1#define _RootEventBaseCnv_CXX
7#include "GaudiKernel/IDataManagerSvc.h"
8#include "GaudiKernel/IService.h"
9#include "GaudiKernel/IEvtSelector.h"
10#include "GaudiKernel/ISvcLocator.h"
11#include "GaudiKernel/RegistryEntry.h"
12#include "GaudiKernel/MsgStream.h"
13#include "GaudiKernel/DataObject.h"
14#include "GaudiKernel/IConverter.h"
15#include "GaudiKernel/IAddressCreator.h"
16#include "GaudiKernel/SmartIF.h"
19#include "RootEventData/TDigiEvent.h"
20#include "RootCnvSvc/RootEvtSelector.h"
21#include "RootCnvSvc/RootEventBaseCnv.h"
22#include "RootCnvSvc/RootCnvSvc.h"
23#include "RootCnvSvc/RootAddress.h"
27using namespace DataSvcHelpers;
34 MsgStream log(
msgSvc(),
"RootEventBaseCnv");
38 sc = serviceLocator()->getService(
"EventDataSvc", isvc,
true);
40 sc = isvc->queryInterface(IDataProviderSvc::interfaceID(), (
void**)&
m_eds);
43 log << MSG::ERROR <<
"Unable start EventData service within RootEventBaseCnv" << endreq;
47 if (!
m_rootInterface) log << MSG::ERROR <<
"Unable to start Root interface within RootCnvSvc" << endreq;
54 sc = serviceLocator()->getService (
"RootEvtSelector", isvc,
false);
55 if (!sc.isSuccess()) sc = serviceLocator()->getService (
"EventSelector", isvc,
false);
57 sc = isvc->queryInterface(IID_IRootEvtSelector, (
void**)&
m_evtsel);
60 log << MSG::WARNING <<
"Unable to start event selector service within RootCnvSvc" << endreq;
79 IOpaqueAddress*& addr) {
82 MsgStream log(
msgSvc(),
"RootEventBaseCnv");
84 StatusCode sc= StatusCode::SUCCESS;
91 if (sc.isFailure() || !rootaddr ) {
92 log << MSG::ERROR <<
"Could not create address for clid " <<obj->clID()<<
", objname "<<obj->name()<<endreq;
93 return StatusCode::FAILURE;
102 if (sc.isFailure()) {
103 log << MSG::ERROR <<
"Could not transform object" << endreq;
107 return StatusCode::SUCCESS;
113 MsgStream log(
msgSvc(),
"RootEventBaseCnv");
114 return StatusCode::SUCCESS;
121 MsgStream log(
msgSvc(),
"RootEventBaseCnv");
122 return StatusCode::SUCCESS;
128 StatusCode status = Converter::initialize();
130 if ( status.isSuccess() ) {
132 status = serviceLocator()->service(
"RootCnvSvc", isvc,
false);
133 if ( !status.isSuccess() ) status = serviceLocator()->service(
"EventCnvSvc", isvc,
true);
134 if ( status.isSuccess() ) {
147 return Converter::finalize();
151 const std::string& treename,
const std::string& branchname) {
158 DataObject*& refpObject) {
160 MsgStream log(
msgSvc(),
"RootEventBaseCnv");
161 log << MSG::DEBUG <<
"RootEventBaseCnv::createObj with clid " <<addr->clID()<< endreq;
169 log << MSG::ERROR <<
"Could not downcast to Root address" << endreq;
170 return StatusCode::FAILURE;
174 static int entryN =0;
178 static int branchN=0;
179 static bool isSet=
true;
181 static int entryBefore = 0;
182 static bool addEntryEachFile =
true;
196 if(temp == branchN) {
238 addEntryEachFile =
false;
241 if(lastBrn == brN && isSet ){
246 if(isSet==
false) log << MSG::INFO <<
" 1st method set event as : "<<int(entryN/branchN)<<endreq;
247 if(isSet==
false) raddr->
setEntryNr(
int(entryN/branchN));
255 else log << MSG::ERROR <<
"eventId error!!!"<<endreq;
257 log << MSG::INFO <<
" 2nd method set event as : "<<eventID<<endreq;
276 if (sc.isFailure()) {
277 log << MSG::ERROR <<
"Could not read branch " << raddr->
getBranchname(nb) << endreq;
286 IConverter *p=conversionSvc()->converter(
CLID_top);
289 log << MSG::ERROR <<
"Could not downcast to RootEventBaseCnv " << endreq;
290 return StatusCode::FAILURE;
298 if (sc.isFailure()) {
299 log << MSG::ERROR <<
"Could not transform object" << endreq;
304 IRegistry* ent = addr->registry();
307 if (sc.isFailure()) {
308 log << MSG::ERROR <<
"Could not register object " << raddr->
getPath()<<
" status "<<sc.getCode()<<endreq;
314 return StatusCode::SUCCESS;
const long int ROOT_StorageType
const InterfaceID IID_IRootCnvSvc
Definition of a Root address, derived from IOpaqueAddress.
void setEntryNr(int entry)
std::string getPath() const
std::string getTreename() const
std::string getBranchname(int i) const
Short_t getNrBranches() const
object regrouping CLID and pathname with treename/branchname
virtual StatusCode createAddress(long int svc_type, const CLID &clid, const std::string *par, const unsigned long *ip, IOpaqueAddress *&refpAddress)
create address containing ROOT treename, branchname, entry number
Base class for all Root Converters.
virtual StatusCode DataObjectToTObject(DataObject *dat, RootAddress *addr)=0
Do the concrete conversion from TDS to ROOT.
virtual StatusCode fillObjRefs(IOpaqueAddress *pAddress, DataObject *pObject)
Resolve the references of the converted object.
virtual StatusCode createObj(IOpaqueAddress *addr, DataObject *&dat)
Convert the persistent object to transient.
IDataProviderSvc * m_eds
pointer to eventdataservice
std::vector< RootCnvSvc::Leaf > m_leaves
virtual StatusCode initialize()
TObject * getReadObject() const
get the object to be read
int m_branchNrEvtNavigator
virtual StatusCode finalize()
std::vector< void * > m_adresses
each converter knows the corresponding adresses
RootEvtSelector * m_evtsel
TArrayS * m_branchNumbers
array with number of branches for reading
virtual StatusCode TObjectToDataObject(DataObject *&dat)=0
Do the concrete conversion from ROOT to TDS.
void declareObject(const std::string &fullPath, const CLID &clid, const std::string &treename, const std::string &branchname)
Store TDS path to link a particular converter to an object on the TDS.
std::string m_currentFileName
int m_branchNr
the branchNr of this converter for writing
RootInterface * m_rootInterface
pointer to the RootInterface
CLID CLID_top
the CLID of the upper converter if any
TObject * m_objRead
the object that was read
virtual StatusCode fillRepRefs(IOpaqueAddress *pAddress, DataObject *pObject)
Resolve the references of the converted object.
RootEventBaseCnv(const CLID &clid, ISvcLocator *svc)
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress)
Convert the transient object to the requested representation.
virtual StatusCode getBranchEntry(int nr, int entry, int &nb)
get entry from this branch
virtual bool getSelectFromTag()
virtual Int_t getEntries()
get nr of entries
virtual bool getENDFILE()
virtual StatusCode setBranchAddress(const std::string treename, const std::string branchname, void *addr, int &nb)
set branch address
static RootInterface * Instance(MsgStream log)
singleton behaviour
virtual std::string getCurrentFileName()