CGEM BOSS 6.6.5.h
BESIII Offline Software System
Loading...
Searching...
No Matches
RootCnvSvc Class Reference

Root Event Conversion Service which coordinates all of our converters. More...

#include <RootCnvSvc.h>

+ Inheritance diagram for RootCnvSvc:

Classes

class  Leaf
 object regrouping CLID and pathname with treename/branchname More...
 

Public Member Functions

RootInterfacegetRootInterface ()
 
virtual StatusCode initialize ()
 
virtual StatusCode finalize ()
 
virtual StatusCode updateServiceState (IOpaqueAddress *pAddress)
 Update state of the service.
 
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvInterface)
 Override inherited queryInterface due to enhanced interface.
 
virtual StatusCode declareObject (const Leaf &leaf)
 Associates a path on TDS with a particular converter.
 
virtual StatusCode commitOutput (const std::string &output, bool do_commit)
 Commit pending output (fill the TTrees).
 
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
 
virtual StatusCode createAddress (DataObject *obj, IOpaqueAddress *&refpAddress)
 
virtual StatusCode createAddress (std::string path, IOpaqueAddress *&refpAddress)
 
DigiCnvgetDigiCnv ()
 
DstCnvgetDstCnv ()
 
McCnvgetMcCnv ()
 
TrigCnvgetTrigCnv ()
 
HltCnvgetHltCnv ()
 
EvtRecCnvgetEvtRecCnv ()
 
void setDigiCnv (DigiCnv *reccnv)
 
void setDstCnv (DstCnv *dstcnv)
 
void setMcCnv (McCnv *mccnv)
 
void setTrigCnv (TrigCnv *trigcnv)
 
void setHltCnv (HltCnv *hltcnv)
 
void setEvtRecCnv (EvtRecCnv *evtreccnv)
 
void setRecTrackCnv (RecTrackCnv *rectrackcnv)
 
void setEvtHeaderCnv (EvtHeaderCnv *evtheadercnv)
 
void setEvtNavigatorCnv (EvtNavigatorCnv *evtnavigatorcnv)
 
void setEventCnv (EventCnv *eventCnv)
 
RecTrackCnvgetRecTrackCnv ()
 
EvtHeaderCnvgetEvtHeaderCnv ()
 
EvtNavigatorCnvgetEvtNavigatorCnv ()
 
EventCnvgetEventCnv ()
 

Protected Member Functions

 RootCnvSvc (const std::string &name, ISvcLocator *svc)
 
virtual ~RootCnvSvc ()
 

Friends

class SvcFactory< RootCnvSvc >
 

Detailed Description

Root Event Conversion Service which coordinates all of our converters.

When a component requests an item not yet available on the TDS, the RootcnvSvc is called to find the appropriiate converter to gain access to the data and put it on the TDS. Based on SICb service written by Markus Frank. If an item is mentioned in the jobOptions as one to be written out, it will be converted from TDS to ROOT by the appropriate converter

Based on the RootCnvSvc of GLast.

Definition at line 40 of file RootCnvSvc.h.

Constructor & Destructor Documentation

◆ RootCnvSvc()

RootCnvSvc::RootCnvSvc ( const std::string & name,
ISvcLocator * svc )
protected

Definition at line 114 of file RootCnvSvc.cxx.

115 : ConversionSvc(name, svc, ROOT_StorageType), m_minSplit(1), m_evtsel(0)
116{
117 StatusCode sc;
118 MsgStream log(msgSvc(), "RootCnvSvc");
119 log << MSG::DEBUG << "RootCnvSvc::constructor" << endreq;
120
121 IService* isvc = 0;
122 sc = serviceLocator()->getService ("RootEvtSelector", isvc, false);
123 if (!sc.isSuccess()) sc = serviceLocator()->getService ("EventSelector", isvc, false);
124 if (sc.isSuccess()) {
125 sc = isvc->queryInterface(IID_IRootEvtSelector, (void**)&m_evtsel);
126 }
127 if(sc.isFailure()) {
128 log << MSG::WARNING << "Unable to start event selector service within RootCnvSvc" << endreq;
129 }
130
131 m_rootInterface= RootInterface::Instance(log);
132 if (!m_rootInterface) log << MSG::ERROR << "Unable to start Root service within RootCnvSvc" << endreq;
133
134
135
136 //Digi
137 declareProperty("digiTreeName", m_dtreeName="Event"); //"Rec"->"Event"
138
139 declareProperty("digiRootInputFile",m_difileName);
140 if (m_difileName.size()==0){
141 m_difileName.push_back("digi.root");
142 }
143 declareProperty("digiRootOutputFile",m_dofileName = "");
144
145 // Split mode for writing the TTree [0,99]
146 declareProperty("digiSplitMode", m_dsplitMode=m_minSplit);
147 // Buffer size for writing ROOT data
148 declareProperty("digiBufferSize", m_dbufSize=3200000);
149 // ROOT default compression
150 declareProperty("digiCompressionLevel", m_dcompressionLevel=1);
151
152}
const long int ROOT_StorageType
IMessageSvc * msgSvc()
static RootInterface * Instance(MsgStream log)
singleton behaviour

◆ ~RootCnvSvc()

virtual RootCnvSvc::~RootCnvSvc ( )
inlineprotectedvirtual

Definition at line 175 of file RootCnvSvc.h.

175{ };

Member Function Documentation

◆ commitOutput()

StatusCode RootCnvSvc::commitOutput ( const std::string & output,
bool do_commit )
virtual

Commit pending output (fill the TTrees).

Definition at line 405 of file RootCnvSvc.cxx.

406 {
407
408
409
410 MsgStream log( msgSvc(), name() );
411 log << MSG::INFO << "RootCnvSvc::commitOutput starts." << endreq;
412
413 StatusCode sc=m_rootInterface->fillTrees();
414 if (sc.isFailure())
415 log << MSG::ERROR << "No Root tree was filled" << endreq;
416
417 // objects must be cleared after fill
418 else{
419 TObject* oEvtHeader = m_evtheaderCnv->getWriteObject();
420 if (oEvtHeader) oEvtHeader->Clear();
421 TObject* oEvtNavigator = m_evtnavigatorCnv->getWriteObject();
422 if (oEvtNavigator) oEvtNavigator->Clear();
423 TObject* o=m_dCnv->getWriteObject();
424 if (o) o->Clear();
425 TObject* oDst=m_dstCnv->getWriteObject();
426 if (oDst) oDst->Clear();
427 TObject* oMc=m_mcCnv->getWriteObject();
428 if (oMc) oMc->Clear();
429 TObject* oRecTrack=m_rectrackCnv->getWriteObject();
430 if (oRecTrack) oRecTrack->Clear();
431 TObject* oEvtRecEvent = m_evtRecCnv->getWriteObject();
432 if (oEvtRecEvent) oEvtRecEvent->Clear();
433 TObject* oTrig = m_trigCnv->getWriteObject();
434 if(oTrig) oTrig->Clear();
435 TObject* oHlt = m_hltCnv->getWriteObject();
436 if(oHlt) oHlt->Clear();
437 }
438 m_common.clear();
439
440 return sc;
441 }
static TDigiEvent * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
Definition DigiCnv.h:35
static TDstEvent * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
Definition DstCnv.h:36
static TEvtHeader * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
static TEvtNavigator * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
static TEvtRecObject * getWriteObject()
Definition EvtRecCnv.h:26
static THltEvent * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
Definition HltCnv.h:35
static TMcEvent * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
Definition McCnv.h:35
static TRecTrackEvent * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
Definition RecTrackCnv.h:36
virtual StatusCode fillTrees()
fill in all trees
static TTrigEvent * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
Definition TrigCnv.h:35

◆ createAddress() [1/3]

StatusCode RootCnvSvc::createAddress ( DataObject * obj,
IOpaqueAddress *& refpAddress )
virtual

Definition at line 443 of file RootCnvSvc.cxx.

443 {
444
445 // create address for this object
446 MsgStream log(msgSvc(), name());
447
448
449 log << MSG::DEBUG << "RootCnvSvc::createAddress"<<endreq;
450
451 StatusCode status = INVALID_ADDRESS;
452 IRegistry* ent = obj->registry();
453
454 if ( 0 != ent ) {
455 SmartIF<IDataManagerSvc> iaddrReg(dataProvider());
456 std::string path = ent->identifier();
457 LeafMap::iterator itm = m_leaves.find(path);
458
459
460 if ( itm != m_leaves.end() ) {
461 Leaf* leaf = (*itm).second;
462 if ( 0 != leaf ) {
463 std::string spars[3] ;
464 spars[0]=path;
465 spars[1]=leaf->treename;
466 spars[2]=leaf->branchname;
467
468
469 unsigned long ipars[2] ={0,0};
470 if (m_evtsel) ipars[0]=m_evtsel->getRecId();
471
472 status=addressCreator()->createAddress(ROOT_StorageType,leaf->clid,spars,ipars,newAddr);
473 if ( status.isSuccess() ) {
474 status = iaddrReg->registerAddress((IRegistry*)0,path, newAddr);
475 if ( !status.isSuccess() ) {
476 newAddr->release();
477 }
478 }
479 return StatusCode::SUCCESS;
480 }
481 }
482 }
483 return status;
484 }
int getRecId() const

◆ createAddress() [2/3]

StatusCode RootCnvSvc::createAddress ( long int svc_type,
const CLID & clid,
const std::string * par,
const unsigned long * ip,
IOpaqueAddress *& refpAddress )
virtual

create address containing ROOT treename, branchname, entry number

Definition at line 380 of file RootCnvSvc.cxx.

385 {
386 MsgStream log( msgSvc(), name() );
387
388 if (svc_type != repSvcType() ) {
389 log << MSG::ERROR << "RootCnvSvc::bad storage type" << svc_type << endreq;
390 return StatusCode::FAILURE;
391 }
392
393 std::string path = spars[0];
394 std::string treename = spars[1];
395 std::string branchname = spars[2];
396 int entry=ipars[0];
397 if (path.size()==0) path="/Event";
398 refpAddress = new RootAddress(ROOT_StorageType,
399 clid,
400 path,treename,branchname,entry);
401 return StatusCode::SUCCESS;
402 }
Definition of a Root address, derived from IOpaqueAddress.
Definition RootAddress.h:21

Referenced by RootEventBaseCnv::createRep(), and updateServiceState().

◆ createAddress() [3/3]

StatusCode RootCnvSvc::createAddress ( std::string path,
IOpaqueAddress *& refpAddress )
virtual

Definition at line 486 of file RootCnvSvc.cxx.

486 {
487
488 // create address for this object
489 MsgStream log(msgSvc(), name());
490
491 StatusCode status;
492 LeafMap::iterator itm = m_leaves.find(path);
493 SmartIF<IDataManagerSvc> iaddrReg(dataProvider());
494 if ( itm != m_leaves.end() ) {
495 Leaf* leaf = (*itm).second;
496 if ( 0 != leaf ) {
497 std::string spars[3] ;
498 spars[0]=path;
499 spars[1]=leaf->treename;
500 spars[2]=leaf->branchname;
501
502 unsigned long ipars[2] = {0,0};
503 if (m_evtsel) ipars[0]=m_evtsel->getRecId();
504 status=addressCreator()->createAddress(ROOT_StorageType,leaf->clid,spars,ipars,newAddr);
505 if ( status.isSuccess() ) {
506 status = iaddrReg->registerAddress((IRegistry*)0,path, newAddr);
507 if ( !status.isSuccess() ) {
508 newAddr->release();
509 }
510 }
511 return StatusCode::SUCCESS;
512 }
513 }
514
515
516 return StatusCode::FAILURE;
517 }

◆ declareObject()

StatusCode RootCnvSvc::declareObject ( const Leaf & leaf)
virtual

Associates a path on TDS with a particular converter.

Definition at line 305 of file RootCnvSvc.cxx.

305 {
306 // Purpose and Method: Callback from each of the individual converters that allows
307 // association of TDS path and converter.
308 MsgStream log(msgSvc(), name());
309 log << MSG::DEBUG << "RootCnvSvc::declareObject " << leaf.path << " classid: " << leaf.clid << endreq;
310 Leaf* ll = new Leaf(leaf);
311 std::pair<LeafMap::iterator, bool> p = m_leaves.insert(LeafMap::value_type( leaf.path, ll) );
312 if( p.second ) {
313 return StatusCode::SUCCESS;
314 }
315 delete ll;
316 return StatusCode::FAILURE;
317}

◆ finalize()

StatusCode RootCnvSvc::finalize ( )
virtual

Definition at line 206 of file RootCnvSvc.cxx.

206 {
207 MsgStream log(msgSvc(), name());
208 log << MSG::DEBUG << "RootCnvSvc::finalize" << endreq;
209
210 ConversionSvc::finalize();
211 // log << MSG::INFO<<"this is the end of RootCnvsvc finalize"<<endreq;
212 for (LeafMap::iterator k = m_leaves.begin(); k != m_leaves.end(); k++ ) {
213 delete (*k).second;
214 }
215 m_leaves.erase(m_leaves.begin(), m_leaves.end());
216
217 return m_rootInterface->finalize();
218}
virtual StatusCode finalize()

◆ getDigiCnv()

◆ getDstCnv()

◆ getEventCnv()

EventCnv * RootCnvSvc::getEventCnv ( )
inline

Definition at line 169 of file RootCnvSvc.h.

169{return m_eventCnv;}

◆ getEvtHeaderCnv()

EvtHeaderCnv * RootCnvSvc::getEvtHeaderCnv ( )
inline

Definition at line 167 of file RootCnvSvc.h.

167{return m_evtheaderCnv;}

◆ getEvtNavigatorCnv()

EvtNavigatorCnv * RootCnvSvc::getEvtNavigatorCnv ( )
inline

Definition at line 168 of file RootCnvSvc.h.

168{return m_evtnavigatorCnv;}

◆ getEvtRecCnv()

◆ getHltCnv()

HltCnv * RootCnvSvc::getHltCnv ( )
inline

Definition at line 151 of file RootCnvSvc.h.

151{ return m_hltCnv; } //fucd

Referenced by DstHltInfCnv::DataObjectToTObject(), HltInfCnv::DataObjectToTObject(), and HltRawCnv::DataObjectToTObject().

◆ getMcCnv()

◆ getRecTrackCnv()

◆ getRootInterface()

RootInterface * RootCnvSvc::getRootInterface ( )
inline

Definition at line 120 of file RootCnvSvc.h.

120{return m_rootInterface;}

◆ getTrigCnv()

TrigCnv * RootCnvSvc::getTrigCnv ( )
inline

Definition at line 150 of file RootCnvSvc.h.

150{ return m_trigCnv; } //caogf

Referenced by TrigDataCnv::DataObjectToTObject().

◆ initialize()

StatusCode RootCnvSvc::initialize ( )
virtual

Definition at line 154 of file RootCnvSvc.cxx.

154 {
155 // Purpose and Method: Setup GLAST's Event Converter Service.
156 // Associate RootCnvSvc with the EventDataSvc
157 // Associate the list of known converters with this RootCnvSvc
158 // configure map of leaves
159
160 MsgStream log(msgSvc(), name());
161 log << MSG::DEBUG << "RootCnvSvc::initialize" << endreq;
162 StatusCode status = ConversionSvc::initialize();
163 if ( status.isSuccess() ) {
164 // ISvcLocator* svclocator = serviceLocator(); [unused for now]
165 IDataProviderSvc *pIDP = 0;
166 // Set event data service
167 status = service("EventDataSvc", pIDP, true);
168 if ( status.isSuccess() ) {
169 status = setDataProvider ( pIDP );
170 }
171 else {
172 return status;
173 }
174
175
176 // Add converters to the service
177 status = addConverters();
178 if ( !status.isSuccess() ) {
179 log << MSG::ERROR << "Unable to add converters to the service" << endreq;
180 return status;
181 }
182
183
184 // Now we have to configure the map of leaves
185 // Which should contain the association of converters with
186 // paths on the TDS
187 for (LeafMap::iterator k = m_leaves.begin(); k != m_leaves.end(); k++ ) {
188 std::string path = (*k).first;
189 for (LeafMap::iterator j = m_leaves.begin(); j != m_leaves.end(); j++ ) {
190 std::string path2 = (*j).first;
191 std::string pp = (*j).first.substr(0, (*j).first.rfind("/"));
192 if ( path == pp && path != (*j).first ) {
193 (*k).second->push_back((*j).second);
194 }
195 }
196 }
197 }
198
199 // get properties and tell RootInterface about files
200 status=initFiles();
201
202
203 return status;
204}

◆ queryInterface()

StatusCode RootCnvSvc::queryInterface ( const InterfaceID & riid,
void ** ppvInterface )
virtual

Override inherited queryInterface due to enhanced interface.

Definition at line 367 of file RootCnvSvc.cxx.

367 {
368
369 if ( IID_IRootCnvSvc == riid ) {
370 *ppvInterface = (RootCnvSvc*)this;
371 }
372 else {
373 // Interface is not directly availible: try out a base class
374 return ConversionSvc::queryInterface(riid, ppvInterface);
375 }
376 addRef();
377 return StatusCode::SUCCESS;
378 }
const InterfaceID IID_IRootCnvSvc
Root Event Conversion Service which coordinates all of our converters.
Definition RootCnvSvc.h:40

◆ setDigiCnv()

void RootCnvSvc::setDigiCnv ( DigiCnv * reccnv)
inline

Definition at line 154 of file RootCnvSvc.h.

154{m_dCnv=reccnv;}

Referenced by DigiCnv::initialize().

◆ setDstCnv()

void RootCnvSvc::setDstCnv ( DstCnv * dstcnv)
inline

Definition at line 155 of file RootCnvSvc.h.

155{m_dstCnv=dstcnv;}

Referenced by DstCnv::initialize().

◆ setEventCnv()

void RootCnvSvc::setEventCnv ( EventCnv * eventCnv)
inline

Definition at line 163 of file RootCnvSvc.h.

163{m_eventCnv=eventCnv;}

◆ setEvtHeaderCnv()

void RootCnvSvc::setEvtHeaderCnv ( EvtHeaderCnv * evtheadercnv)
inline

Definition at line 161 of file RootCnvSvc.h.

161{m_evtheaderCnv=evtheadercnv;}

Referenced by EvtHeaderCnv::initialize().

◆ setEvtNavigatorCnv()

void RootCnvSvc::setEvtNavigatorCnv ( EvtNavigatorCnv * evtnavigatorcnv)
inline

Definition at line 162 of file RootCnvSvc.h.

162{m_evtnavigatorCnv=evtnavigatorcnv;}

Referenced by EvtNavigatorCnv::initialize().

◆ setEvtRecCnv()

void RootCnvSvc::setEvtRecCnv ( EvtRecCnv * evtreccnv)
inline

Definition at line 159 of file RootCnvSvc.h.

159{ m_evtRecCnv = evtreccnv; } //zoujh

Referenced by EvtRecCnv::initialize().

◆ setHltCnv()

void RootCnvSvc::setHltCnv ( HltCnv * hltcnv)
inline

Definition at line 158 of file RootCnvSvc.h.

158{ m_hltCnv = hltcnv; } //fucd

Referenced by HltCnv::initialize().

◆ setMcCnv()

void RootCnvSvc::setMcCnv ( McCnv * mccnv)
inline

Definition at line 156 of file RootCnvSvc.h.

156{m_mcCnv=mccnv;}

Referenced by McCnv::initialize().

◆ setRecTrackCnv()

void RootCnvSvc::setRecTrackCnv ( RecTrackCnv * rectrackcnv)
inline

Definition at line 160 of file RootCnvSvc.h.

160{m_rectrackCnv=rectrackcnv;}

Referenced by RecTrackCnv::initialize().

◆ setTrigCnv()

void RootCnvSvc::setTrigCnv ( TrigCnv * trigcnv)
inline

Definition at line 157 of file RootCnvSvc.h.

157{ m_trigCnv = trigcnv; } //caogf

Referenced by TrigCnv::initialize().

◆ updateServiceState()

StatusCode RootCnvSvc::updateServiceState ( IOpaqueAddress * pAddress)
virtual

Update state of the service.

Definition at line 320 of file RootCnvSvc.cxx.

320 {
321
322 // not sure about the use of recid or bank...
323 MsgStream log(msgSvc(), name());
324
325 log << MSG::DEBUG << "RootCnvSvc::updateServiceState" << endreq;
326
327 StatusCode status = INVALID_ADDRESS;
328 IRegistry* ent = pAddress->registry();
329 if ( 0 != ent ) {
330 SmartIF<IDataManagerSvc> iaddrReg(dataProvider());
331 // if ( 0 != iaddrReg ) {
332 status = StatusCode::SUCCESS;
333 std::string path = ent->identifier();
334 LeafMap::iterator itm = m_leaves.find(path);
335 if ( itm != m_leaves.end() ) {
336 Leaf* leaf = (*itm).second;
337 if ( 0 != leaf ) {
338 for ( Leaf::iterator il = leaf->begin(); il != leaf->end(); il++ ) {
339 IOpaqueAddress* newAddr = 0;
340 unsigned long ipars[2] = {0, 0}; //
341 if (m_evtsel) ipars[0]=m_evtsel->getRecId();
342
343 std::string spars[3]={(*il)->path,(*il)->treename,(*il)->branchname};
344
345 StatusCode ir =createAddress(ROOT_StorageType,
346 (*il)->clid,
347 spars,
348 ipars,
349 newAddr);
350 log << MSG::DEBUG << "RootCnvSvc::updateService " << " ***** " <<
351 (*il)->clid << " ***** " << (*il)->path <<endreq;
352
353 if ( ir.isSuccess() ) {
354 ir = iaddrReg->registerAddress((*il)->path, newAddr);
355 if ( !ir.isSuccess() ) {
356 newAddr->release();
357 status = ir;
358 }
359 }
360 }
361 }
362 }
363 }
364 return StatusCode::SUCCESS;
365 }
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

Friends And Related Symbol Documentation

◆ SvcFactory< RootCnvSvc >

friend class SvcFactory< RootCnvSvc >
friend

Definition at line 25 of file RootCnvSvc.h.


The documentation for this class was generated from the following files: