3#include "GaudiKernel/SmartIF.h"
4#include "GaudiKernel/SvcFactory.h"
6#include "GaudiKernel/MsgStream.h"
7#include "GaudiKernel/ISvcLocator.h"
8#include "GaudiKernel/IDataProviderSvc.h"
9#include "GaudiKernel/IDataManagerSvc.h"
10#include "GaudiKernel/RegistryEntry.h"
11#include "GaudiKernel/GenericAddress.h"
92static const char* rcsid =
"$Id: RootCnvSvc.cxx,v 1.74 2022/02/21 22:04:49 maqm Exp $";
105 MsgStream log(
msgSvc(),
"RootCnvSvc");
106 log << MSG::DEBUG <<
"RootCnvSvc::constructor" << endreq;
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);
115 log << MSG::WARNING <<
"Unable to start event selector service within RootCnvSvc" << endreq;
119 if (!m_rootInterface) log << MSG::ERROR <<
"Unable to start Root service within RootCnvSvc" << endreq;
124 declareProperty(
"digiTreeName", m_dtreeName=
"Event");
126 declareProperty(
"digiRootInputFile",m_difileName);
130 declareProperty(
"digiRootOutputFile",m_dofileName =
"");
133 declareProperty(
"digiSplitMode", m_dsplitMode=m_minSplit);
135 declareProperty(
"digiBufferSize", m_dbufSize=3200000);
137 declareProperty(
"digiCompressionLevel", m_dcompressionLevel=1);
138 declareProperty(
"selectFromTag", m_selectFromTag=0);
139 declareProperty(
"tagInputFile", m_tagInputFile);
142 declareProperty(
"readETS", m_readETS =
false);
151 MsgStream log(
msgSvc(), name());
152 log << MSG::DEBUG <<
"RootCnvSvc::initialize" << endreq;
153 StatusCode status = ConversionSvc::initialize();
154 if ( status.isSuccess() ) {
156 IDataProviderSvc *pIDP = 0;
158 status = service(
"EventDataSvc", pIDP,
true);
159 if ( status.isSuccess() ) {
160 status = setDataProvider ( pIDP );
168 status = addConverters();
169 if ( !status.isSuccess() ) {
170 log << MSG::ERROR <<
"Unable to add converters to the service" << endreq;
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);
194 if ( m_selectFromTag && m_tagInputFile.empty() ) {
195 m_tagInputFile = m_difileName;
204 MsgStream log(
msgSvc(), name());
205 log << MSG::DEBUG <<
"RootCnvSvc::finalize" << endreq;
207 ConversionSvc::finalize();
209 for (LeafMap::iterator k = m_leaves.begin(); k != m_leaves.end(); k++ ) {
212 m_leaves.erase(m_leaves.begin(), m_leaves.end());
217StatusCode RootCnvSvc::initFiles () {
218 MsgStream log(
msgSvc(), name());
219 log << MSG::DEBUG <<
"RootCnvSvc::initFiles" << endreq;
220 StatusCode sc=StatusCode::SUCCESS;
227 int nSize = m_difileName.size();
228 log<<MSG::INFO<<
"Root Input files "<<nSize<<endreq;
230 log<<MSG::INFO<<
"Unable to find input file"<<endreq;
234 for(
int i = 0;i<nSize;i++){
271 sc = m_rootInterface->
addInput(m_dtreeName,m_difileName[i]);
272 if (sc.isFailure())
return sc;
287 if (m_dsplitMode<m_minSplit) {
288 log << MSG::WARNING <<
"RootCnvSvc::initFiles Recon splitlevel cant be lower than "<<m_minSplit<<
", reset" << endreq;
289 m_dsplitMode=m_minSplit;
292 if(
"" != m_dofileName ){
293 sc=m_rootInterface->
addOutput(m_dtreeName,m_dofileName,m_dsplitMode,m_dbufSize,m_dcompressionLevel);
295 log << MSG::WARNING <<
"No specified digiRootOutputFile!" << endreq;
305 MsgStream log(
msgSvc(), name());
306 log << MSG::DEBUG <<
"RootCnvSvc::declareObject " << leaf.
path <<
" classid: " << leaf.
clid << endreq;
308 std::pair<LeafMap::iterator, bool> p = m_leaves.insert(LeafMap::value_type( leaf.
path, ll) );
310 return StatusCode::SUCCESS;
313 return StatusCode::FAILURE;
320 MsgStream log(
msgSvc(), name());
322 log << MSG::DEBUG <<
"RootCnvSvc::updateServiceState" << endreq;
324 StatusCode status = INVALID_ADDRESS;
325 IRegistry* ent = pAddress->registry();
327 SmartIF<IDataManagerSvc> iaddrReg(dataProvider());
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;
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();
340 std::string spars[3]={(*il)->path,(*il)->treename,(*il)->branchname};
347 log << MSG::DEBUG <<
"RootCnvSvc::updateService " <<
" ***** " <<
348 (*il)->clid <<
" ***** " << (*il)->path <<endreq;
350 if ( ir.isSuccess() ) {
351 ir = iaddrReg->registerAddress((*il)->path, newAddr);
352 if ( !ir.isSuccess() ) {
361 return StatusCode::SUCCESS;
371 return ConversionSvc::queryInterface(riid, ppvInterface);
374 return StatusCode::SUCCESS;
379 const std::string* spars,
380 const unsigned long* ipars,
381 IOpaqueAddress*& refpAddress)
383 MsgStream log(
msgSvc(), name() );
385 if (svc_type != repSvcType() ) {
386 log << MSG::ERROR <<
"RootCnvSvc::bad storage type" << svc_type << endreq;
387 return StatusCode::FAILURE;
390 std::string path = spars[0];
391 std::string treename = spars[1];
392 std::string branchname = spars[2];
394 if (path.size()==0) path=
"/Event";
397 path,treename,branchname,entry);
398 return StatusCode::SUCCESS;
407 MsgStream log(
msgSvc(), name() );
408 log << MSG::INFO <<
"RootCnvSvc::commitOutput starts." << endreq;
410 StatusCode sc=m_rootInterface->
fillTrees();
412 log << MSG::ERROR <<
"No Root tree was filled" << endreq;
417 if (oEvtHeader) oEvtHeader->
Clear();
419 if (oEvtNavigator) oEvtNavigator->
Clear();
423 if (oDst) oDst->
Clear();
425 if (oMc) oMc->
Clear();
427 if (oRecTrack) oRecTrack->
Clear();
429 if (oEvtRecEvent) oEvtRecEvent->
Clear();
431 if(oTrig) oTrig->
Clear();
433 if(oHlt) oHlt->
Clear();
443 MsgStream log(
msgSvc(), name());
446 log << MSG::DEBUG <<
"RootCnvSvc::createAddress"<<endreq;
448 StatusCode status = INVALID_ADDRESS;
449 IRegistry* ent = obj->registry();
452 SmartIF<IDataManagerSvc> iaddrReg(dataProvider());
453 std::string path = ent->identifier();
454 LeafMap::iterator itm = m_leaves.find(path);
457 if ( itm != m_leaves.end() ) {
458 Leaf* leaf = (*itm).second;
460 std::string spars[3] ;
466 unsigned long ipars[2] ={0,0};
467 if (m_evtsel) ipars[0]=m_evtsel->
getRecId();
470 if ( status.isSuccess() ) {
471 status = iaddrReg->registerAddress((IRegistry*)0,path, newAddr);
472 if ( !status.isSuccess() ) {
476 return StatusCode::SUCCESS;
486 MsgStream log(
msgSvc(), name());
489 LeafMap::iterator itm = m_leaves.find(path);
490 SmartIF<IDataManagerSvc> iaddrReg(dataProvider());
491 if ( itm != m_leaves.end() ) {
492 Leaf* leaf = (*itm).second;
494 std::string spars[3] ;
499 unsigned long ipars[2] = {0,0};
500 if (m_evtsel) ipars[0]=m_evtsel->
getRecId();
502 if ( status.isSuccess() ) {
503 status = iaddrReg->registerAddress((IRegistry*)0,path, newAddr);
504 if ( !status.isSuccess() ) {
508 return StatusCode::SUCCESS;
513 return StatusCode::FAILURE;
518 StatusCode RootCnvSvc::addConverters () {
519 MsgStream log(
msgSvc(), name());
588 return StatusCode::SUCCESS;
*******INTEGER m_nBinMax INTEGER m_NdiMax !No of bins in histogram for cell exploration division $ !Last vertex $ !Last active cell $ !Last cell in buffer $ !No of sampling when dividing cell $ !No of function total $ !Flag for random ceel for $ !Flag for type of for WtMax $ !Flag which decides whether vertices are included in the sampling $ entire domain is hyp !Maximum effective eevents per saves r n generator level $ !Flag for chat level in output
const long int ROOT_StorageType
const InterfaceID IID_IRootCnvSvc
static const CLID & classID()
static TDigiEvent * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
static const CLID & classID()
static TDstEvent * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static TEvtNavigator * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
static const CLID & classID()
static TEvtRecObject * getWriteObject()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static THltEvent * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static TMcEvent * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static TRecTrackEvent * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
static const CLID & classID()
static const CLID & classID()
Definition of a Root address, derived from IOpaqueAddress.
object regrouping CLID and pathname with treename/branchname
Root Event Conversion Service which coordinates all of our converters.
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 initialize()
virtual StatusCode updateServiceState(IOpaqueAddress *pAddress)
Update state of the service.
virtual StatusCode commitOutput(const std::string &output, bool do_commit)
Commit pending output (fill the TTrees).
virtual StatusCode declareObject(const Leaf &leaf)
Associates a path on TDS with a particular converter.
virtual StatusCode finalize()
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvInterface)
Override inherited queryInterface due to enhanced interface.
virtual StatusCode finalize()
virtual void setTagInputFile(std::vector< std::string > input)
virtual StatusCode addInput(const std::string &treename, const std::string &file)
add input tree to the list
static RootInterface * Instance(MsgStream log)
singleton behaviour
virtual StatusCode addOutput(const std::string &treename, const std::string &file, int splitx, int bufsize, int compression)
add output tree to the list
virtual StatusCode fillTrees()
fill in all trees
virtual void setSelectFromTag(bool temp)
void Clear(Option_t *option="")
void Clear(Option_t *option="")
void Clear(Option_t *option="")
void Clear(Option_t *option="")
void Clear(Option_t *option="")
void Clear(Option_t *option="")
void Clear(Option_t *option="")
void Clear(Option_t *option="")
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static TTrigEvent * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
static const CLID & classID()
static int expandEnvVar(std::string *toExpand, const std::string &openDel=std::string("$("), const std::string &closeDel=std::string(")"))
_EXTERN_ std::string Event
_EXTERN_ std::string MdcDigiCol
_EXTERN_ std::string MucDigiCol
_EXTERN_ std::string LumiDigiCol
_EXTERN_ std::string EmcDigiCol
_EXTERN_ std::string TofDigiCol
_EXTERN_ std::string Event
_EXTERN_ std::string DstEmcShowerCol
_EXTERN_ std::string DstMdcKalTrackCol
_EXTERN_ std::string DstExtTrackCol
_EXTERN_ std::string DstMdcDedxCol
_EXTERN_ std::string DstTofTrackCol
_EXTERN_ std::string DstMdcTrackCol
_EXTERN_ std::string DstMucTrackCol
_EXTERN_ std::string EvtRecPi0Col
_EXTERN_ std::string Event
_EXTERN_ std::string EvtRecPrimaryVertex
_EXTERN_ std::string EvtRecEvent
_EXTERN_ std::string EvtRecVeeVertexCol
_EXTERN_ std::string EvtRecEtaToGGCol
_EXTERN_ std::string EvtRecDTagCol
_EXTERN_ std::string EvtRecTrackCol
_EXTERN_ std::string Event
_EXTERN_ std::string HltInf
_EXTERN_ std::string HltRawCol
_EXTERN_ std::string DstHltInf
_EXTERN_ std::string EmcMcHitCol
_EXTERN_ std::string MucMcHitCol
_EXTERN_ std::string MdcMcHitCol
_EXTERN_ std::string TofMcHitCol
_EXTERN_ std::string McParticleCol
_EXTERN_ std::string Event
_EXTERN_ std::string RecMdcKalHelixSegCol
_EXTERN_ std::string RecEmcClusterCol
_EXTERN_ std::string MucRecHitCol
_EXTERN_ std::string RecETofCalHitCol
_EXTERN_ std::string RecBTofCalHitCol
_EXTERN_ std::string RecExtTrackCol
_EXTERN_ std::string RecMdcDedxCol
_EXTERN_ std::string RecZddChannelCol
_EXTERN_ std::string RecTofTrackCol
_EXTERN_ std::string RecEsTimeCol
_EXTERN_ std::string RecEmcHitCol
_EXTERN_ std::string RecMdcTrackCol
_EXTERN_ std::string RecMdcDedxHitCol
_EXTERN_ std::string Event
_EXTERN_ std::string RecMdcKalTrackCol
_EXTERN_ std::string RecMucTrackCol
_EXTERN_ std::string RecMdcHitCol
_EXTERN_ std::string RecEmcShowerCol
_EXTERN_ std::string TrigData
_EXTERN_ std::string Event