BOSS 7.1.2
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 ()
 
 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 41 of file RootCnvSvc.h.

Constructor & Destructor Documentation

◆ RootCnvSvc()

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

Definition at line 101 of file RootCnvSvc.cxx.

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

◆ ~RootCnvSvc()

virtual RootCnvSvc::~RootCnvSvc ( )
inlinevirtual

Definition at line 182 of file RootCnvSvc.h.

182{ };

Member Function Documentation

◆ commitOutput()

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

Commit pending output (fill the TTrees).

Definition at line 402 of file RootCnvSvc.cxx.

403 {
404
405
406
407 MsgStream log( msgSvc(), name() );
408 log << MSG::INFO << "RootCnvSvc::commitOutput starts." << endreq;
409
410 StatusCode sc=m_rootInterface->fillTrees();
411 if (sc.isFailure())
412 log << MSG::ERROR << "No Root tree was filled" << endreq;
413
414 // objects must be cleared after fill
415 else{
416 TObject* oEvtHeader = m_evtheaderCnv->getWriteObject();
417 if (oEvtHeader) oEvtHeader->Clear();
418 TObject* oEvtNavigator = m_evtnavigatorCnv->getWriteObject();
419 if (oEvtNavigator) oEvtNavigator->Clear();
420 TObject* o=m_dCnv->getWriteObject();
421 if (o) o->Clear();
422 TObject* oDst=m_dstCnv->getWriteObject();
423 if (oDst) oDst->Clear();
424 TObject* oMc=m_mcCnv->getWriteObject();
425 if (oMc) oMc->Clear();
426 TObject* oRecTrack=m_rectrackCnv->getWriteObject();
427 if (oRecTrack) oRecTrack->Clear();
428 TObject* oEvtRecEvent = m_evtRecCnv->getWriteObject();
429 if (oEvtRecEvent) oEvtRecEvent->Clear();
430 TObject* oTrig = m_trigCnv->getWriteObject();
431 if(oTrig) oTrig->Clear();
432 TObject* oHlt = m_hltCnv->getWriteObject();
433 if(oHlt) oHlt->Clear();
434 }
435 m_common.clear();
436
437 return sc;
438 }
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 440 of file RootCnvSvc.cxx.

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

382 {
383 MsgStream log( msgSvc(), name() );
384
385 if (svc_type != repSvcType() ) {
386 log << MSG::ERROR << "RootCnvSvc::bad storage type" << svc_type << endreq;
387 return StatusCode::FAILURE;
388 }
389
390 std::string path = spars[0];
391 std::string treename = spars[1];
392 std::string branchname = spars[2];
393 int entry=ipars[0];
394 if (path.size()==0) path="/Event";
395 refpAddress = new RootAddress(ROOT_StorageType,
396 clid,
397 path,treename,branchname,entry);
398 return StatusCode::SUCCESS;
399 }
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 483 of file RootCnvSvc.cxx.

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

◆ declareObject()

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

Associates a path on TDS with a particular converter.

Definition at line 302 of file RootCnvSvc.cxx.

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

◆ finalize()

StatusCode RootCnvSvc::finalize ( )
virtual

Definition at line 203 of file RootCnvSvc.cxx.

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

◆ getDigiCnv()

◆ getDstCnv()

◆ getEventCnv()

EventCnv * RootCnvSvc::getEventCnv ( )
inline

Definition at line 176 of file RootCnvSvc.h.

176{return m_eventCnv;}

◆ getEvtHeaderCnv()

EvtHeaderCnv * RootCnvSvc::getEvtHeaderCnv ( )
inline

Definition at line 174 of file RootCnvSvc.h.

174{return m_evtheaderCnv;}

◆ getEvtNavigatorCnv()

EvtNavigatorCnv * RootCnvSvc::getEvtNavigatorCnv ( )
inline

Definition at line 175 of file RootCnvSvc.h.

175{return m_evtnavigatorCnv;}

◆ getEvtRecCnv()

◆ getHltCnv()

HltCnv * RootCnvSvc::getHltCnv ( )
inline

Definition at line 158 of file RootCnvSvc.h.

158{ return m_hltCnv; } //fucd

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

◆ getMcCnv()

◆ getRecTrackCnv()

◆ getRootInterface()

RootInterface * RootCnvSvc::getRootInterface ( )
inline

Definition at line 127 of file RootCnvSvc.h.

127{return m_rootInterface;}

◆ getTrigCnv()

TrigCnv * RootCnvSvc::getTrigCnv ( )
inline

Definition at line 157 of file RootCnvSvc.h.

157{ return m_trigCnv; } //caogf

Referenced by TrigDataCnv::DataObjectToTObject().

◆ initialize()

StatusCode RootCnvSvc::initialize ( )
virtual

Definition at line 145 of file RootCnvSvc.cxx.

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

◆ queryInterface()

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

Override inherited queryInterface due to enhanced interface.

Definition at line 364 of file RootCnvSvc.cxx.

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

◆ setDigiCnv()

void RootCnvSvc::setDigiCnv ( DigiCnv * reccnv)
inline

Definition at line 161 of file RootCnvSvc.h.

161{m_dCnv=reccnv;}

Referenced by DigiCnv::initialize().

◆ setDstCnv()

void RootCnvSvc::setDstCnv ( DstCnv * dstcnv)
inline

Definition at line 162 of file RootCnvSvc.h.

162{m_dstCnv=dstcnv;}

Referenced by DstCnv::initialize().

◆ setEventCnv()

void RootCnvSvc::setEventCnv ( EventCnv * eventCnv)
inline

Definition at line 170 of file RootCnvSvc.h.

170{m_eventCnv=eventCnv;}

◆ setEvtHeaderCnv()

void RootCnvSvc::setEvtHeaderCnv ( EvtHeaderCnv * evtheadercnv)
inline

Definition at line 168 of file RootCnvSvc.h.

168{m_evtheaderCnv=evtheadercnv;}

Referenced by EvtHeaderCnv::initialize().

◆ setEvtNavigatorCnv()

void RootCnvSvc::setEvtNavigatorCnv ( EvtNavigatorCnv * evtnavigatorcnv)
inline

Definition at line 169 of file RootCnvSvc.h.

169{m_evtnavigatorCnv=evtnavigatorcnv;}

Referenced by EvtNavigatorCnv::initialize().

◆ setEvtRecCnv()

void RootCnvSvc::setEvtRecCnv ( EvtRecCnv * evtreccnv)
inline

Definition at line 166 of file RootCnvSvc.h.

166{ m_evtRecCnv = evtreccnv; } //zoujh

Referenced by EvtRecCnv::initialize().

◆ setHltCnv()

void RootCnvSvc::setHltCnv ( HltCnv * hltcnv)
inline

Definition at line 165 of file RootCnvSvc.h.

165{ m_hltCnv = hltcnv; } //fucd

Referenced by HltCnv::initialize().

◆ setMcCnv()

void RootCnvSvc::setMcCnv ( McCnv * mccnv)
inline

Definition at line 163 of file RootCnvSvc.h.

163{m_mcCnv=mccnv;}

Referenced by McCnv::initialize().

◆ setRecTrackCnv()

void RootCnvSvc::setRecTrackCnv ( RecTrackCnv * rectrackcnv)
inline

Definition at line 167 of file RootCnvSvc.h.

167{m_rectrackCnv=rectrackcnv;}

Referenced by RecTrackCnv::initialize().

◆ setTrigCnv()

void RootCnvSvc::setTrigCnv ( TrigCnv * trigcnv)
inline

Definition at line 164 of file RootCnvSvc.h.

164{ m_trigCnv = trigcnv; } //caogf

Referenced by TrigCnv::initialize().

◆ updateServiceState()

StatusCode RootCnvSvc::updateServiceState ( IOpaqueAddress * pAddress)
virtual

Update state of the service.

Definition at line 317 of file RootCnvSvc.cxx.

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


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