BOSS 6.6.4.p01
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 99 of file RootCnvSvc.cxx.

100 : ConversionSvc(name, svc, ROOT_StorageType), m_minSplit(1), m_evtsel(0)
101{
102 StatusCode sc;
103 MsgStream log(msgSvc(), "RootCnvSvc");
104 log << MSG::DEBUG << "RootCnvSvc::constructor" << endreq;
105
106 IService* isvc = 0;
107 sc = serviceLocator()->getService ("RootEvtSelector", isvc, false);
108 if (!sc.isSuccess()) sc = serviceLocator()->getService ("EventSelector", isvc, false);
109 if (sc.isSuccess()) {
110 sc = isvc->queryInterface(IID_IRootEvtSelector, (void**)&m_evtsel);
111 }
112 if(sc.isFailure()) {
113 log << MSG::WARNING << "Unable to start event selector service within RootCnvSvc" << endreq;
114 }
115
116 m_rootInterface= RootInterface::Instance(log);
117 if (!m_rootInterface) log << MSG::ERROR << "Unable to start Root service within RootCnvSvc" << endreq;
118
119
120
121 //Digi
122 declareProperty("digiTreeName", m_dtreeName="Event"); //"Rec"->"Event"
123
124 declareProperty("digiRootInputFile",m_difileName);
125 if (m_difileName.size()==0){
126 m_difileName.push_back("digi.root");
127 }
128 declareProperty("digiRootOutputFile",m_dofileName = "");
129
130 // Split mode for writing the TTree [0,99]
131 declareProperty("digiSplitMode", m_dsplitMode=m_minSplit);
132 // Buffer size for writing ROOT data
133 declareProperty("digiBufferSize", m_dbufSize=3200000);
134 // ROOT default compression
135 declareProperty("digiCompressionLevel", m_dcompressionLevel=1);
136
137}
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 390 of file RootCnvSvc.cxx.

391 {
392
393
394
395 MsgStream log( msgSvc(), name() );
396 log << MSG::INFO << "RootCnvSvc::commitOutput starts." << endreq;
397
398 StatusCode sc=m_rootInterface->fillTrees();
399 if (sc.isFailure())
400 log << MSG::ERROR << "No Root tree was filled" << endreq;
401
402 // objects must be cleared after fill
403 else{
404 TObject* oEvtHeader = m_evtheaderCnv->getWriteObject();
405 if (oEvtHeader) oEvtHeader->Clear();
406 TObject* oEvtNavigator = m_evtnavigatorCnv->getWriteObject();
407 if (oEvtNavigator) oEvtNavigator->Clear();
408 TObject* o=m_dCnv->getWriteObject();
409 if (o) o->Clear();
410 TObject* oDst=m_dstCnv->getWriteObject();
411 if (oDst) oDst->Clear();
412 TObject* oMc=m_mcCnv->getWriteObject();
413 if (oMc) oMc->Clear();
414 TObject* oRecTrack=m_rectrackCnv->getWriteObject();
415 if (oRecTrack) oRecTrack->Clear();
416 TObject* oEvtRecEvent = m_evtRecCnv->getWriteObject();
417 if (oEvtRecEvent) oEvtRecEvent->Clear();
418 TObject* oTrig = m_trigCnv->getWriteObject();
419 if(oTrig) oTrig->Clear();
420 TObject* oHlt = m_hltCnv->getWriteObject();
421 if(oHlt) oHlt->Clear();
422 }
423 m_common.clear();
424
425 return sc;
426 }
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)
Definition: EvtHeaderCnv.h:37
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
void Clear(Option_t *option="")
Definition: TDigiEvent.cxx:83
void Clear(Option_t *option="")
Definition: TDstEvent.cxx:108
void Clear(Option_t *option="")
Definition: TEvtHeader.cxx:30
void Clear(Option_t *option="")
void Clear(Option_t *option="")
void Clear(Option_t *option="")
Definition: THltEvent.cxx:55
void Clear(Option_t *option="")
Definition: TMcEvent.cxx:93
void Clear(Option_t *option="")
void Clear(Option_t *option="")
Definition: TTrigEvent.cxx:35
static TTrigEvent * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
Definition: TrigCnv.h:35
void clear()
Definition: commonData.cxx:147

◆ createAddress() [1/3]

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

Definition at line 428 of file RootCnvSvc.cxx.

428 {
429
430 // create address for this object
431 MsgStream log(msgSvc(), name());
432
433
434 log << MSG::DEBUG << "RootCnvSvc::createAddress"<<endreq;
435
436 StatusCode status = INVALID_ADDRESS;
437 IRegistry* ent = obj->registry();
438
439 if ( 0 != ent ) {
440 SmartIF<IDataManagerSvc> iaddrReg(dataProvider());
441 std::string path = ent->identifier();
442 LeafMap::iterator itm = m_leaves.find(path);
443
444
445 if ( itm != m_leaves.end() ) {
446 Leaf* leaf = (*itm).second;
447 if ( 0 != leaf ) {
448 std::string spars[3] ;
449 spars[0]=path;
450 spars[1]=leaf->treename;
451 spars[2]=leaf->branchname;
452
453
454 unsigned long ipars[2] ={0,0};
455 if (m_evtsel) ipars[0]=m_evtsel->getRecId();
456
457 status=addressCreator()->createAddress(ROOT_StorageType,leaf->clid,spars,ipars,newAddr);
458 if ( status.isSuccess() ) {
459 status = iaddrReg->registerAddress((IRegistry*)0,path, newAddr);
460 if ( !status.isSuccess() ) {
461 newAddr->release();
462 }
463 }
464 return StatusCode::SUCCESS;
465 }
466 }
467 }
468 return status;
469 }
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 365 of file RootCnvSvc.cxx.

370 {
371 MsgStream log( msgSvc(), name() );
372
373 if (svc_type != repSvcType() ) {
374 log << MSG::ERROR << "RootCnvSvc::bad storage type" << svc_type << endreq;
375 return StatusCode::FAILURE;
376 }
377
378 std::string path = spars[0];
379 std::string treename = spars[1];
380 std::string branchname = spars[2];
381 int entry=ipars[0];
382 if (path.size()==0) path="/Event";
383 refpAddress = new RootAddress(ROOT_StorageType,
384 clid,
385 path,treename,branchname,entry);
386 return StatusCode::SUCCESS;
387 }
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 471 of file RootCnvSvc.cxx.

471 {
472
473 // create address for this object
474 MsgStream log(msgSvc(), name());
475
476 StatusCode status;
477 LeafMap::iterator itm = m_leaves.find(path);
478 SmartIF<IDataManagerSvc> iaddrReg(dataProvider());
479 if ( itm != m_leaves.end() ) {
480 Leaf* leaf = (*itm).second;
481 if ( 0 != leaf ) {
482 std::string spars[3] ;
483 spars[0]=path;
484 spars[1]=leaf->treename;
485 spars[2]=leaf->branchname;
486
487 unsigned long ipars[2] = {0,0};
488 if (m_evtsel) ipars[0]=m_evtsel->getRecId();
489 status=addressCreator()->createAddress(ROOT_StorageType,leaf->clid,spars,ipars,newAddr);
490 if ( status.isSuccess() ) {
491 status = iaddrReg->registerAddress((IRegistry*)0,path, newAddr);
492 if ( !status.isSuccess() ) {
493 newAddr->release();
494 }
495 }
496 return StatusCode::SUCCESS;
497 }
498 }
499
500
501 return StatusCode::FAILURE;
502 }

◆ declareObject()

StatusCode RootCnvSvc::declareObject ( const Leaf leaf)
virtual

Associates a path on TDS with a particular converter.

Definition at line 290 of file RootCnvSvc.cxx.

290 {
291 // Purpose and Method: Callback from each of the individual converters that allows
292 // association of TDS path and converter.
293 MsgStream log(msgSvc(), name());
294 log << MSG::DEBUG << "RootCnvSvc::declareObject " << leaf.path << " classid: " << leaf.clid << endreq;
295 Leaf* ll = new Leaf(leaf);
296 std::pair<LeafMap::iterator, bool> p = m_leaves.insert(LeafMap::value_type( leaf.path, ll) );
297 if( p.second ) {
298 return StatusCode::SUCCESS;
299 }
300 delete ll;
301 return StatusCode::FAILURE;
302}

◆ finalize()

StatusCode RootCnvSvc::finalize ( )
virtual

Definition at line 191 of file RootCnvSvc.cxx.

191 {
192 MsgStream log(msgSvc(), name());
193 log << MSG::DEBUG << "RootCnvSvc::finalize" << endreq;
194
195 ConversionSvc::finalize();
196 // log << MSG::INFO<<"this is the end of RootCnvsvc finalize"<<endreq;
197 for (LeafMap::iterator k = m_leaves.begin(); k != m_leaves.end(); k++ ) {
198 delete (*k).second;
199 }
200 m_leaves.erase(m_leaves.begin(), m_leaves.end());
201
202 return m_rootInterface->finalize();
203}
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 139 of file RootCnvSvc.cxx.

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

◆ queryInterface()

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

Override inherited queryInterface due to enhanced interface.

Definition at line 352 of file RootCnvSvc.cxx.

352 {
353
354 if ( IID_IRootCnvSvc == riid ) {
355 *ppvInterface = (RootCnvSvc*)this;
356 }
357 else {
358 // Interface is not directly availible: try out a base class
359 return ConversionSvc::queryInterface(riid, ppvInterface);
360 }
361 addRef();
362 return StatusCode::SUCCESS;
363 }
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 305 of file RootCnvSvc.cxx.

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

Friends And Related Function 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: