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"
91static const char* rcsid =
"$Id: RootCnvSvc.cxx,v 1.64 2011/08/17 09:24:38 azhemchugov Exp $";
103 MsgStream log(
msgSvc(),
"RootCnvSvc");
104 log << MSG::DEBUG <<
"RootCnvSvc::constructor" << endreq;
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);
113 log << MSG::WARNING <<
"Unable to start event selector service within RootCnvSvc" << endreq;
117 if (!m_rootInterface) log << MSG::ERROR <<
"Unable to start Root service within RootCnvSvc" << endreq;
122 declareProperty(
"digiTreeName", m_dtreeName=
"Event");
124 declareProperty(
"digiRootInputFile",m_difileName);
125 if (m_difileName.size()==0){
126 m_difileName.push_back(
"digi.root");
128 declareProperty(
"digiRootOutputFile",m_dofileName =
"");
131 declareProperty(
"digiSplitMode", m_dsplitMode=m_minSplit);
133 declareProperty(
"digiBufferSize", m_dbufSize=3200000);
135 declareProperty(
"digiCompressionLevel", m_dcompressionLevel=1);
145 MsgStream log(
msgSvc(), name());
146 log << MSG::DEBUG <<
"RootCnvSvc::initialize" << endreq;
147 StatusCode status = ConversionSvc::initialize();
148 if ( status.isSuccess() ) {
150 IDataProviderSvc *pIDP = 0;
152 status = service(
"EventDataSvc", pIDP,
true);
153 if ( status.isSuccess() ) {
154 status = setDataProvider ( pIDP );
162 status = addConverters();
163 if ( !status.isSuccess() ) {
164 log << MSG::ERROR <<
"Unable to add converters to the service" << endreq;
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);
192 MsgStream log(
msgSvc(), name());
193 log << MSG::DEBUG <<
"RootCnvSvc::finalize" << endreq;
195 ConversionSvc::finalize();
197 for (LeafMap::iterator k = m_leaves.begin(); k != m_leaves.end(); k++ ) {
200 m_leaves.erase(m_leaves.begin(), m_leaves.end());
205StatusCode RootCnvSvc::initFiles () {
206 MsgStream log(
msgSvc(), name());
207 log << MSG::DEBUG <<
"RootCnvSvc::initFiles" << endreq;
208 StatusCode sc=StatusCode::SUCCESS;
215 int nSize = m_difileName.size();
216 log<<MSG::INFO<<
"Root Input files "<<nSize<<endreq;
218 log<<MSG::INFO<<
"Unable to find input file"<<endreq;
219 return StatusCode::FAILURE;
222 for(
int i = 0;i<nSize;i++){
224 std::string
s=m_difileName[i];
225 std::vector<int> wildcardPos;
226 for(
int pos=0;pos<
s.size();pos++) {
227 pos=
s.find_first_of(
'?',pos);
229 wildcardPos.push_back(pos);
235 if(wildcardPos.size()!=0) {
237 int maxNo=pow(10.,(
int)wildcardPos.size());
238 if(nEnd!=0&&nEnd<maxNo) maxNo=nEnd;
241 if(nStart!=-1) i=nStart;
242 if(nStart>nEnd) log<<MSG::WARNING<<
"file's StartNo>EndNo"<<endreq;
244 std::vector<int>::iterator it=wildcardPos.end();
246 while(it!=wildcardPos.begin()){
250 s.replace((*it),1,1,c);
252 if(access(
s.c_str(),0)!=-1) {
253 sc = m_rootInterface->
addInput(m_dtreeName,
s);
254 if (sc.isFailure())
return sc;
259 sc = m_rootInterface->
addInput(m_dtreeName,m_difileName[i]);
260 if (sc.isFailure())
return sc;
275 if (m_dsplitMode<m_minSplit) {
276 log << MSG::WARNING <<
"RootCnvSvc::initFiles Recon splitlevel cant be lower than "<<m_minSplit<<
", reset" << endreq;
277 m_dsplitMode=m_minSplit;
280 if(
"" != m_dofileName ){
281 sc=m_rootInterface->
addOutput(m_dtreeName,m_dofileName,m_dsplitMode,m_dbufSize,m_dcompressionLevel);
283 log << MSG::WARNING <<
"No specified digiRootOutputFile!" << endreq;
293 MsgStream log(
msgSvc(), name());
294 log << MSG::DEBUG <<
"RootCnvSvc::declareObject " << leaf.
path <<
" classid: " << leaf.
clid << endreq;
296 std::pair<LeafMap::iterator, bool> p = m_leaves.insert(LeafMap::value_type( leaf.
path, ll) );
298 return StatusCode::SUCCESS;
301 return StatusCode::FAILURE;
308 MsgStream log(
msgSvc(), name());
310 log << MSG::DEBUG <<
"RootCnvSvc::updateServiceState" << endreq;
312 StatusCode status = INVALID_ADDRESS;
313 IRegistry* ent = pAddress->registry();
315 SmartIF<IDataManagerSvc> iaddrReg(dataProvider());
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;
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();
328 std::string spars[3]={(*il)->path,(*il)->treename,(*il)->branchname};
335 log << MSG::DEBUG <<
"RootCnvSvc::updateService " <<
" ***** " <<
336 (*il)->clid <<
" ***** " << (*il)->path <<endreq;
338 if ( ir.isSuccess() ) {
339 ir = iaddrReg->registerAddress((*il)->path, newAddr);
340 if ( !ir.isSuccess() ) {
349 return StatusCode::SUCCESS;
359 return ConversionSvc::queryInterface(riid, ppvInterface);
362 return StatusCode::SUCCESS;
367 const std::string* spars,
368 const unsigned long* ipars,
369 IOpaqueAddress*& refpAddress)
371 MsgStream log(
msgSvc(), name() );
373 if (svc_type != repSvcType() ) {
374 log << MSG::ERROR <<
"RootCnvSvc::bad storage type" << svc_type << endreq;
375 return StatusCode::FAILURE;
378 std::string path = spars[0];
379 std::string treename = spars[1];
380 std::string branchname = spars[2];
382 if (path.size()==0) path=
"/Event";
385 path,treename,branchname,entry);
386 return StatusCode::SUCCESS;
395 MsgStream log(
msgSvc(), name() );
396 log << MSG::INFO <<
"RootCnvSvc::commitOutput starts." << endreq;
398 StatusCode sc=m_rootInterface->
fillTrees();
400 log << MSG::ERROR <<
"No Root tree was filled" << endreq;
405 if (oEvtHeader) oEvtHeader->
Clear();
407 if (oEvtNavigator) oEvtNavigator->
Clear();
411 if (oDst) oDst->
Clear();
413 if (oMc) oMc->
Clear();
415 if (oRecTrack) oRecTrack->
Clear();
417 if (oEvtRecEvent) oEvtRecEvent->
Clear();
419 if(oTrig) oTrig->
Clear();
421 if(oHlt) oHlt->
Clear();
431 MsgStream log(
msgSvc(), name());
434 log << MSG::DEBUG <<
"RootCnvSvc::createAddress"<<endreq;
436 StatusCode status = INVALID_ADDRESS;
437 IRegistry* ent = obj->registry();
440 SmartIF<IDataManagerSvc> iaddrReg(dataProvider());
441 std::string path = ent->identifier();
442 LeafMap::iterator itm = m_leaves.find(path);
445 if ( itm != m_leaves.end() ) {
446 Leaf* leaf = (*itm).second;
448 std::string spars[3] ;
454 unsigned long ipars[2] ={0,0};
455 if (m_evtsel) ipars[0]=m_evtsel->
getRecId();
458 if ( status.isSuccess() ) {
459 status = iaddrReg->registerAddress((IRegistry*)0,path, newAddr);
460 if ( !status.isSuccess() ) {
464 return StatusCode::SUCCESS;
474 MsgStream log(
msgSvc(), name());
477 LeafMap::iterator itm = m_leaves.find(path);
478 SmartIF<IDataManagerSvc> iaddrReg(dataProvider());
479 if ( itm != m_leaves.end() ) {
480 Leaf* leaf = (*itm).second;
482 std::string spars[3] ;
487 unsigned long ipars[2] = {0,0};
488 if (m_evtsel) ipars[0]=m_evtsel->
getRecId();
490 if ( status.isSuccess() ) {
491 status = iaddrReg->registerAddress((IRegistry*)0,path, newAddr);
492 if ( !status.isSuccess() ) {
496 return StatusCode::SUCCESS;
501 return StatusCode::FAILURE;
506 StatusCode RootCnvSvc::addConverters () {
507 MsgStream log(
msgSvc(), name());
570 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()
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).
RootCnvSvc(const std::string &name, ISvcLocator *svc)
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 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
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(")"))
static int catchOptionVal(std::string *toCatch, const int ops=0, 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 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