1#define _RootEventBaseCnv_CXX
7#include "GaudiKernel/CommonMessaging.h"
8#include "GaudiKernel/DataObject.h"
9#include "GaudiKernel/IAddressCreator.h"
10#include "GaudiKernel/IConverter.h"
11#include "GaudiKernel/IDataManagerSvc.h"
12#include "GaudiKernel/IEvtSelector.h"
13#include "GaudiKernel/IService.h"
14#include "GaudiKernel/ISvcLocator.h"
15#include "GaudiKernel/MsgStream.h"
16#include "GaudiKernel/RegistryEntry.h"
17#include "GaudiKernel/SmartIF.h"
19#include "RootCnvSvc/IRootCnvSvc.h"
20#include "RootCnvSvc/RootAddress.h"
21#include "RootCnvSvc/RootCnvSvc.h"
22#include "RootCnvSvc/RootEventBaseCnv.h"
23#include "RootCnvSvc/RootEvtSelector.h"
24#include "RootEventData/TDigiEvent.h"
28using namespace DataSvcHelpers;
52 MsgStream log(
msgSvc(),
"RootEventBaseCnv" );
54 StatusCode sc = StatusCode::SUCCESS;
57 sc =
m_cnvSvc->createAddress( obj, addr );
61 if ( sc.isFailure() || !rootaddr )
63 log << MSG::ERROR <<
"Could not create address for clid " << obj->clID() <<
", objname "
64 << obj->name() << endmsg;
65 return StatusCode::FAILURE;
76 log << MSG::ERROR <<
"Could not transform object" << endmsg;
80 return StatusCode::SUCCESS;
85 MsgStream log(
msgSvc(),
"RootEventBaseCnv" );
86 return StatusCode::SUCCESS;
92 MsgStream log(
msgSvc(),
"RootEventBaseCnv" );
93 return StatusCode::SUCCESS;
98 MsgStream log(
msgSvc(),
"RootEventBaseCnv" );
99 log << MSG::INFO <<
"RootEventBaseCnv::initialize" << endmsg;
101 StatusCode status = Converter::initialize();
105 log << MSG::ERROR <<
"Unable to start Root interface within RootCnvSvc" << endmsg;
112 sc = serviceLocator()->getService(
"EventDataSvc", isvc,
true );
113 if ( sc.isSuccess() )
114 { sc = isvc->queryInterface( IDataProviderSvc::interfaceID(), (
void**)&
m_eds ); }
115 if ( sc.isFailure() )
116 { log << MSG::ERROR <<
"Unable start EventData service within RootEventBaseCnv" << endmsg; }
124 sc = serviceLocator()->getService(
"RootEvtSelector", isvc,
false );
125 if ( !sc.isSuccess() ) sc = serviceLocator()->getService(
"EventSelector", isvc,
false );
126 if ( sc.isSuccess() )
127 { sc = isvc->queryInterface( IID_IRootEvtSelector, (
void**)&
m_evtsel ); }
128 if ( sc.isFailure() )
130 log << MSG::WARNING <<
"Unable to start event selector service within RootCnvSvc"
151 if ( !status.isSuccess() )
return status;
153 status = service(
"RootCnvSvc",
m_cnvSvc,
false );
154 if ( !status.isSuccess() ) status = service(
"EventCnvSvc",
m_cnvSvc,
true );
165 return Converter::finalize();
169 const std::string& treename,
170 const std::string& branchname ) {
178 MsgStream log(
msgSvc(),
"RootEventBaseCnv" );
179 log << MSG::DEBUG <<
"RootEventBaseCnv::createObj with clid " << addr->clID() << endmsg;
190 log << MSG::ERROR <<
"Could not downcast to Root address" << endmsg;
191 return StatusCode::FAILURE;
195 static int entryN = 0;
199 static int branchN = 0;
200 static bool isSet =
true;
202 static int entryBefore = 0;
203 static bool addEntryEachFile =
true;
215 if ( temp == branchN ) { temp = 0; }
220 if (
m_evtsel->getRecId() - entryBefore == 0 )
245 if ( !sc.isSuccess() )
251 if ( temp > 0 ) temp--;
260 if ( addEntryEachFile && (
m_evtsel->getRecId() > entryBefore ) )
263 addEntryEachFile =
false;
266 if ( lastBrn == brN && isSet )
272 if ( isSet ==
false )
273 log << MSG::INFO <<
" 1st method set event as : " << int( entryN / branchN ) << endmsg;
274 if ( isSet ==
false )
276 if (
m_evtsel ) log << MSG::INFO <<
" event id = " <<
m_evtsel->getRecId() << endmsg;
279 if ( entryBefore >
m_evtsel->getRecId() )
281 else if ( entryBefore ==
m_evtsel->getRecId() ) eventID = 0;
282 else log << MSG::ERROR <<
"eventId error!!!" << endmsg;
284 log << MSG::INFO <<
" 2nd method set event as : " << eventID << endmsg;
305 if ( sc.isFailure() )
307 log << MSG::ERROR <<
"Could not read branch " << raddr->
getBranchname( nb ) << endmsg;
318 IConverter* p = conversionSvc()->converter(
CLID_top );
322 log << MSG::ERROR <<
"Could not downcast to RootEventBaseCnv " << endmsg;
323 return StatusCode::FAILURE;
331 if ( sc.isFailure() )
333 log << MSG::ERROR <<
"Could not transform object" << endmsg;
338 IRegistry* ent = addr->registry();
341 sc =
m_eds->registerObject( raddr->
getPath(), refpObject );
342 if ( sc.isFailure() )
344 log << MSG::ERROR <<
"Could not register object " << raddr->
getPath() <<
" status "
345 << sc.getCode() << endmsg;
351 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 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.
std::string m_rootTreename
each converter knows it's treename
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
std::string m_rootBranchname
root branchname (may be concatenated of severals)
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.
static RootInterface * Instance(const std::string &name)
singleton behaviour