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"
13#include "RawEvent/DigiEvent.h"
14#include "DstEvent/DstEvent.h"
15#include "McTruth/McEvent.h"
16#include "TrigEvent/TrigEvent.h"
17#include "HltEvent/HltEvent.h"
18#include "RootCnvSvc/RootInterface.h"
20#include "RootCnvSvc/RootAddress.h"
21#include "RootCnvSvc/RootCnvSvc.h"
22#include "RootCnvSvc/RootEvtSelector.h"
25#include "RootCnvSvc/Dst/MdcDedxCnv.h"
26#include "RootCnvSvc/Dst/CgemDedxCnv.h"
27#include "RootCnvSvc/Dst/DstCnv.h"
28#include "RootCnvSvc/Digi/EmcDigiCnv.h"
29#include "RootCnvSvc/Mc/EmcMcHitCnv.h"
30#include "RootCnvSvc/Dst/EmcTrackCnv.h"
31#include "RootCnvSvc/EventCnv.h"
32#include "RootCnvSvc/Dst/ExtTrackCnv.h"
33#include "RootCnvSvc/Mc/McCnv.h"
34#include "RootCnvSvc/Mc/McParticleCnv.h"
35#include "RootCnvSvc/Digi/MdcDigiCnv.h"
36#include "RootCnvSvc/Dst/MdcKalTrackCnv.h"
37#include "RootCnvSvc/Mc/MdcMcHitCnv.h"
38#include "RootCnvSvc/Dst/MdcTrackCnv.h"
39#include "RootCnvSvc/Digi/CgemDigiCnv.h"
40#include "RootCnvSvc/Dst/CgemKalTrackCnv.h"
41#include "RootCnvSvc/Mc/CgemMcHitCnv.h"
42#include "RootCnvSvc/Dst/CgemTrackCnv.h"
43#include "RootCnvSvc/Dst/CgemSegmentCnv.h"
44#include "RootCnvSvc/Digi/MucDigiCnv.h"
45#include "RootCnvSvc/Mc/MucMcHitCnv.h"
46#include "RootCnvSvc/Dst/MucTrackCnv.h"
47#include "RootCnvSvc/Digi/DigiCnv.h"
48#include "RootCnvSvc/Digi/TofDigiCnv.h"
49#include "RootCnvSvc/Mc/TofMcHitCnv.h"
50#include "RootCnvSvc/Dst/TofTrackCnv.h"
51#include "RootCnvSvc/Digi/LumiDigiCnv.h"
53#include "RootCnvSvc/Rec/RecMucTrackCnv.h"
54#include "RootCnvSvc/Rec/RecMdcTrackCnv.h"
55#include "RootCnvSvc/Rec/RecMdcHitCnv.h"
56#include "RootCnvSvc/Rec/RecMdcKalTrackCnv.h"
57#include "RootCnvSvc/Rec/RecMdcKalHelixSegCnv.h"
58#include "RootCnvSvc/Rec/RecMdcDedxCnv.h"
59#include "RootCnvSvc/Rec/RecMdcDedxHitCnv.h"
60#include "RootCnvSvc/Rec/RecCgemTrackCnv.h"
61#include "RootCnvSvc/Rec/RecCgemSegmentCnv.h"
62#include "RootCnvSvc/Rec/RecCgemHitCnv.h"
63#include "RootCnvSvc/Rec/RecCgemKalTrackCnv.h"
64#include "RootCnvSvc/Rec/RecCgemKalHelixSegCnv.h"
65#include "RootCnvSvc/Rec/RecCgemDedxCnv.h"
66#include "RootCnvSvc/Rec/RecCgemDedxHitCnv.h"
67#include "RootCnvSvc/Rec/RecCgemClusterCnv.h"
68#include "RootCnvSvc/Rec/RecTofTrackCnv.h"
69#include "RootCnvSvc/Rec/RecBTofCalHitCnv.h"
70#include "RootCnvSvc/Rec/RecETofCalHitCnv.h"
71#include "RootCnvSvc/Rec/RecMucRecHitCnv.h"
72#include "RootCnvSvc/Rec/RecEmcHitCnv.h"
73#include "RootCnvSvc/Rec/RecEmcClusterCnv.h"
74#include "RootCnvSvc/Rec/RecEmcShowerCnv.h"
75#include "RootCnvSvc/Rec/RecEvTimeCnv.h"
76#include "RootCnvSvc/Rec/RecExtTrackCnv.h"
77#include "RootCnvSvc/Rec/RecTrackCnv.h"
79#include "RootCnvSvc/EvtRec/EvtRecCnv.h"
80#include "RootCnvSvc/EvtRec/EvtRecEventCnv.h"
81#include "RootCnvSvc/EvtRec/EvtRecTrackCnv.h"
82#include "RootCnvSvc/EvtRec/EvtRecPrimaryVertexCnv.h"
83#include "RootCnvSvc/EvtRec/EvtRecVeeVertexCnv.h"
84#include "RootCnvSvc/EvtRec/EvtRecPi0Cnv.h"
85#include "RootCnvSvc/EvtRec/EvtRecEtaToGGCnv.h"
86#include "RootCnvSvc/EvtRec/EvtRecDTagCnv.h"
87#include "RootCnvSvc/Rec/RecZddChannelCnv.h"
90#include "RootCnvSvc/Trig/TrigCnv.h"
91#include "RootCnvSvc/Trig/TrigDataCnv.h"
93#include "RootCnvSvc/Hlt/HltCnv.h"
94#include "RootCnvSvc/Hlt/HltRawCnv.h"
95#include "RootCnvSvc/Hlt/HltInfCnv.h"
96#include "RootCnvSvc/Hlt/DstHltInfCnv.h"
98#include "RootCnvSvc/EvtHeaderCnv.h"
99#include "RootCnvSvc/EvtNavigatorCnv.h"
106static const char* rcsid =
"$Id: RootCnvSvc.cxx,v 1.4 2015/09/11 23:43:52 wulh Exp $";
118 MsgStream log(
msgSvc(),
"RootCnvSvc");
119 log << MSG::DEBUG <<
"RootCnvSvc::constructor" << endreq;
122 sc = serviceLocator()->getService (
"RootEvtSelector", isvc,
false);
123 if (!sc.isSuccess()) sc = serviceLocator()->getService (
"EventSelector", isvc,
false);
124 if (sc.isSuccess()) {
125 sc = isvc->queryInterface(IID_IRootEvtSelector, (
void**)&m_evtsel);
128 log << MSG::WARNING <<
"Unable to start event selector service within RootCnvSvc" << endreq;
132 if (!m_rootInterface) log << MSG::ERROR <<
"Unable to start Root service within RootCnvSvc" << endreq;
137 declareProperty(
"digiTreeName", m_dtreeName=
"Event");
139 declareProperty(
"digiRootInputFile",m_difileName);
140 if (m_difileName.size()==0){
141 m_difileName.push_back(
"digi.root");
143 declareProperty(
"digiRootOutputFile",m_dofileName =
"");
146 declareProperty(
"digiSplitMode", m_dsplitMode=m_minSplit);
148 declareProperty(
"digiBufferSize", m_dbufSize=3200000);
150 declareProperty(
"digiCompressionLevel", m_dcompressionLevel=1);
160 MsgStream log(
msgSvc(), name());
161 log << MSG::DEBUG <<
"RootCnvSvc::initialize" << endreq;
162 StatusCode status = ConversionSvc::initialize();
163 if ( status.isSuccess() ) {
165 IDataProviderSvc *pIDP = 0;
167 status = service(
"EventDataSvc", pIDP,
true);
168 if ( status.isSuccess() ) {
169 status = setDataProvider ( pIDP );
177 status = addConverters();
178 if ( !status.isSuccess() ) {
179 log << MSG::ERROR <<
"Unable to add converters to the service" << endreq;
187 for (LeafMap::iterator k = m_leaves.begin(); k != m_leaves.end(); k++ ) {
188 std::string path = (*k).first;
189 for (LeafMap::iterator j = m_leaves.begin(); j != m_leaves.end(); j++ ) {
190 std::string path2 = (*j).first;
191 std::string pp = (*j).first.substr(0, (*j).first.rfind(
"/"));
192 if ( path == pp && path != (*j).first ) {
193 (*k).second->push_back((*j).second);
207 MsgStream log(
msgSvc(), name());
208 log << MSG::DEBUG <<
"RootCnvSvc::finalize" << endreq;
210 ConversionSvc::finalize();
212 for (LeafMap::iterator k = m_leaves.begin(); k != m_leaves.end(); k++ ) {
215 m_leaves.erase(m_leaves.begin(), m_leaves.end());
220StatusCode RootCnvSvc::initFiles () {
221 MsgStream log(
msgSvc(), name());
222 log << MSG::DEBUG <<
"RootCnvSvc::initFiles" << endreq;
223 StatusCode sc=StatusCode::SUCCESS;
230 int nSize = m_difileName.size();
231 log<<MSG::INFO<<
"Root Input files "<<nSize<<endreq;
233 log<<MSG::INFO<<
"Unable to find input file"<<endreq;
234 return StatusCode::FAILURE;
237 for(
int i = 0;i<nSize;i++){
239 std::string
s=m_difileName[i];
240 std::vector<int> wildcardPos;
241 for(
int pos=0;pos<
s.size();pos++) {
242 pos=
s.find_first_of(
'?',pos);
244 wildcardPos.push_back(pos);
250 if(wildcardPos.size()!=0) {
252 int maxNo=pow(10.,(
int)wildcardPos.size());
253 if(nEnd!=0&&nEnd<maxNo) maxNo=nEnd;
256 if(nStart!=-1) i=nStart;
257 if(nStart>nEnd) log<<MSG::WARNING<<
"file's StartNo>EndNo"<<endreq;
259 std::vector<int>::iterator it=wildcardPos.end();
261 while(it!=wildcardPos.begin()){
265 s.replace((*it),1,1,c);
267 if(access(
s.c_str(),0)!=-1) {
268 sc = m_rootInterface->
addInput(m_dtreeName,
s);
269 if (sc.isFailure())
return sc;
274 sc = m_rootInterface->
addInput(m_dtreeName,m_difileName[i]);
275 if (sc.isFailure())
return sc;
290 if (m_dsplitMode<m_minSplit) {
291 log << MSG::WARNING <<
"RootCnvSvc::initFiles Recon splitlevel cant be lower than "<<m_minSplit<<
", reset" << endreq;
292 m_dsplitMode=m_minSplit;
295 if(
"" != m_dofileName ){
296 sc=m_rootInterface->
addOutput(m_dtreeName,m_dofileName,m_dsplitMode,m_dbufSize,m_dcompressionLevel);
298 log << MSG::WARNING <<
"No specified digiRootOutputFile!" << endreq;
308 MsgStream log(
msgSvc(), name());
309 log << MSG::DEBUG <<
"RootCnvSvc::declareObject " << leaf.
path <<
" classid: " << leaf.
clid << endreq;
311 std::pair<LeafMap::iterator, bool> p = m_leaves.insert(LeafMap::value_type( leaf.
path, ll) );
313 return StatusCode::SUCCESS;
316 return StatusCode::FAILURE;
323 MsgStream log(
msgSvc(), name());
325 log << MSG::DEBUG <<
"RootCnvSvc::updateServiceState" << endreq;
327 StatusCode status = INVALID_ADDRESS;
328 IRegistry* ent = pAddress->registry();
330 SmartIF<IDataManagerSvc> iaddrReg(dataProvider());
332 status = StatusCode::SUCCESS;
333 std::string path = ent->identifier();
334 LeafMap::iterator itm = m_leaves.find(path);
335 if ( itm != m_leaves.end() ) {
336 Leaf* leaf = (*itm).second;
338 for ( Leaf::iterator il = leaf->begin(); il != leaf->end(); il++ ) {
339 IOpaqueAddress* newAddr = 0;
340 unsigned long ipars[2] = {0, 0};
341 if (m_evtsel) ipars[0]=m_evtsel->
getRecId();
343 std::string spars[3]={(*il)->path,(*il)->treename,(*il)->branchname};
350 log << MSG::DEBUG <<
"RootCnvSvc::updateService " <<
" ***** " <<
351 (*il)->clid <<
" ***** " << (*il)->path <<endreq;
353 if ( ir.isSuccess() ) {
354 ir = iaddrReg->registerAddress((*il)->path, newAddr);
355 if ( !ir.isSuccess() ) {
364 return StatusCode::SUCCESS;
374 return ConversionSvc::queryInterface(riid, ppvInterface);
377 return StatusCode::SUCCESS;
382 const std::string* spars,
383 const unsigned long* ipars,
384 IOpaqueAddress*& refpAddress)
386 MsgStream log(
msgSvc(), name() );
388 if (svc_type != repSvcType() ) {
389 log << MSG::ERROR <<
"RootCnvSvc::bad storage type" << svc_type << endreq;
390 return StatusCode::FAILURE;
393 std::string path = spars[0];
394 std::string treename = spars[1];
395 std::string branchname = spars[2];
397 if (path.size()==0) path=
"/Event";
400 path,treename,branchname,entry);
401 return StatusCode::SUCCESS;
410 MsgStream log(
msgSvc(), name() );
411 log << MSG::INFO <<
"RootCnvSvc::commitOutput starts." << endreq;
413 StatusCode sc=m_rootInterface->
fillTrees();
415 log << MSG::ERROR <<
"No Root tree was filled" << endreq;
420 if (oEvtHeader) oEvtHeader->
Clear();
422 if (oEvtNavigator) oEvtNavigator->
Clear();
426 if (oDst) oDst->
Clear();
428 if (oMc) oMc->
Clear();
430 if (oRecTrack) oRecTrack->
Clear();
432 if (oEvtRecEvent) oEvtRecEvent->
Clear();
434 if(oTrig) oTrig->
Clear();
436 if(oHlt) oHlt->
Clear();
446 MsgStream log(
msgSvc(), name());
449 log << MSG::DEBUG <<
"RootCnvSvc::createAddress"<<endreq;
451 StatusCode status = INVALID_ADDRESS;
452 IRegistry* ent = obj->registry();
455 SmartIF<IDataManagerSvc> iaddrReg(dataProvider());
456 std::string path = ent->identifier();
457 LeafMap::iterator itm = m_leaves.find(path);
460 if ( itm != m_leaves.end() ) {
461 Leaf* leaf = (*itm).second;
463 std::string spars[3] ;
469 unsigned long ipars[2] ={0,0};
470 if (m_evtsel) ipars[0]=m_evtsel->
getRecId();
473 if ( status.isSuccess() ) {
474 status = iaddrReg->registerAddress((IRegistry*)0,path, newAddr);
475 if ( !status.isSuccess() ) {
479 return StatusCode::SUCCESS;
489 MsgStream log(
msgSvc(), name());
492 LeafMap::iterator itm = m_leaves.find(path);
493 SmartIF<IDataManagerSvc> iaddrReg(dataProvider());
494 if ( itm != m_leaves.end() ) {
495 Leaf* leaf = (*itm).second;
497 std::string spars[3] ;
502 unsigned long ipars[2] = {0,0};
503 if (m_evtsel) ipars[0]=m_evtsel->
getRecId();
505 if ( status.isSuccess() ) {
506 status = iaddrReg->registerAddress((IRegistry*)0,path, newAddr);
507 if ( !status.isSuccess() ) {
511 return StatusCode::SUCCESS;
516 return StatusCode::FAILURE;
521 StatusCode RootCnvSvc::addConverters () {
522 MsgStream log(
msgSvc(), name());
600 return StatusCode::SUCCESS;
const long int ROOT_StorageType
*******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 InterfaceID IID_IRootCnvSvc
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 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 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).
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 CgemDigiCol
_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 DstCgemDedxCol
_EXTERN_ std::string DstMdcDedxCol
_EXTERN_ std::string DstTofTrackCol
_EXTERN_ std::string DstCgemSegmentCol
_EXTERN_ std::string DstMdcTrackCol
_EXTERN_ std::string DstCgemTrackCol
_EXTERN_ std::string DstMucTrackCol
_EXTERN_ std::string DstCgemKalTrackCol
_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 CgemMcHitCol
_EXTERN_ std::string McParticleCol
_EXTERN_ std::string Event
_EXTERN_ std::string RecCgemTrackCol
_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 RecCgemDedxCol
_EXTERN_ std::string RecCgemHitCol
_EXTERN_ std::string RecMdcDedxCol
_EXTERN_ std::string RecZddChannelCol
_EXTERN_ std::string RecTofTrackCol
_EXTERN_ std::string RecEsTimeCol
_EXTERN_ std::string RecCgemClusterCol
_EXTERN_ std::string RecCgemKalTrackCol
_EXTERN_ std::string RecCgemSegmentCol
_EXTERN_ std::string RecEmcHitCol
_EXTERN_ std::string RecCgemDedxHitCol
_EXTERN_ std::string RecMdcTrackCol
_EXTERN_ std::string RecMdcDedxHitCol
_EXTERN_ std::string Event
_EXTERN_ std::string RecMdcKalTrackCol
_EXTERN_ std::string RecCgemKalHelixSegCol
_EXTERN_ std::string RecMucTrackCol
_EXTERN_ std::string RecMdcHitCol
_EXTERN_ std::string RecEmcShowerCol
_EXTERN_ std::string TrigData
_EXTERN_ std::string Event