BOSS 7.0.7
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 100 of file RootCnvSvc.cxx.

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

◆ ~RootCnvSvc()

virtual RootCnvSvc::~RootCnvSvc ( )
inlineprotectedvirtual

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 401 of file RootCnvSvc.cxx.

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

◆ createAddress() [1/3]

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

Definition at line 439 of file RootCnvSvc.cxx.

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

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

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

◆ declareObject()

StatusCode RootCnvSvc::declareObject ( const Leaf leaf)
virtual

Associates a path on TDS with a particular converter.

Definition at line 301 of file RootCnvSvc.cxx.

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

◆ finalize()

StatusCode RootCnvSvc::finalize ( )
virtual

Definition at line 202 of file RootCnvSvc.cxx.

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

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

◆ queryInterface()

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

Override inherited queryInterface due to enhanced interface.

Definition at line 363 of file RootCnvSvc.cxx.

363 {
364
365 if ( IID_IRootCnvSvc == riid ) {
366 *ppvInterface = (RootCnvSvc*)this;
367 }
368 else {
369 // Interface is not directly availible: try out a base class
370 return ConversionSvc::queryInterface(riid, ppvInterface);
371 }
372 addRef();
373 return StatusCode::SUCCESS;
374 }
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 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 316 of file RootCnvSvc.cxx.

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

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: