2#include "GaudiKernel/SmartIF.h"
6#include "GaudiKernel/GenericAddress.h"
7#include "GaudiKernel/IDataManagerSvc.h"
8#include "GaudiKernel/IDataProviderSvc.h"
9#include "GaudiKernel/ISvcLocator.h"
10#include "GaudiKernel/MsgStream.h"
11#include "GaudiKernel/RegistryEntry.h"
13#include "DstEvent/DstEvent.h"
14#include "HltEvent/HltEvent.h"
15#include "McTruth/McEvent.h"
16#include "RawEvent/DigiEvent.h"
17#include "RootCnvSvc/RootInterface.h"
18#include "TrigEvent/TrigEvent.h"
20#include "RootCnvSvc/RootAddress.h"
21#include "RootCnvSvc/RootCnvSvc.h"
22#include "RootCnvSvc/RootEvtSelector.h"
24#include "RootCnvSvc/Digi/DigiCnv.h"
25#include "RootCnvSvc/Digi/EmcDigiCnv.h"
26#include "RootCnvSvc/Digi/LumiDigiCnv.h"
27#include "RootCnvSvc/Digi/MdcDigiCnv.h"
28#include "RootCnvSvc/Digi/MucDigiCnv.h"
29#include "RootCnvSvc/Digi/TofDigiCnv.h"
30#include "RootCnvSvc/Dst/DstCnv.h"
31#include "RootCnvSvc/Dst/EmcTrackCnv.h"
32#include "RootCnvSvc/Dst/ExtTrackCnv.h"
33#include "RootCnvSvc/Dst/MdcDedxCnv.h"
34#include "RootCnvSvc/Dst/MdcKalTrackCnv.h"
35#include "RootCnvSvc/Dst/MdcTrackCnv.h"
36#include "RootCnvSvc/Dst/MucTrackCnv.h"
37#include "RootCnvSvc/Dst/TofTrackCnv.h"
38#include "RootCnvSvc/EventCnv.h"
39#include "RootCnvSvc/Mc/EmcMcHitCnv.h"
40#include "RootCnvSvc/Mc/McCnv.h"
41#include "RootCnvSvc/Mc/McParticleCnv.h"
42#include "RootCnvSvc/Mc/MdcMcHitCnv.h"
43#include "RootCnvSvc/Mc/MucMcHitCnv.h"
44#include "RootCnvSvc/Mc/TofMcHitCnv.h"
46#include "RootCnvSvc/Rec/RecBTofCalHitCnv.h"
47#include "RootCnvSvc/Rec/RecETofCalHitCnv.h"
48#include "RootCnvSvc/Rec/RecEmcClusterCnv.h"
49#include "RootCnvSvc/Rec/RecEmcHitCnv.h"
50#include "RootCnvSvc/Rec/RecEmcShowerCnv.h"
51#include "RootCnvSvc/Rec/RecEvTimeCnv.h"
52#include "RootCnvSvc/Rec/RecExtTrackCnv.h"
53#include "RootCnvSvc/Rec/RecMdcDedxCnv.h"
54#include "RootCnvSvc/Rec/RecMdcDedxHitCnv.h"
55#include "RootCnvSvc/Rec/RecMdcHitCnv.h"
56#include "RootCnvSvc/Rec/RecMdcKalHelixSegCnv.h"
57#include "RootCnvSvc/Rec/RecMdcKalTrackCnv.h"
58#include "RootCnvSvc/Rec/RecMdcTrackCnv.h"
59#include "RootCnvSvc/Rec/RecMucRecHitCnv.h"
60#include "RootCnvSvc/Rec/RecMucTrackCnv.h"
61#include "RootCnvSvc/Rec/RecTofTrackCnv.h"
62#include "RootCnvSvc/Rec/RecTrackCnv.h"
64#include "RootCnvSvc/EvtRec/EvtRecCnv.h"
65#include "RootCnvSvc/EvtRec/EvtRecDTagCnv.h"
66#include "RootCnvSvc/EvtRec/EvtRecEtaToGGCnv.h"
67#include "RootCnvSvc/EvtRec/EvtRecEventCnv.h"
68#include "RootCnvSvc/EvtRec/EvtRecPi0Cnv.h"
69#include "RootCnvSvc/EvtRec/EvtRecPrimaryVertexCnv.h"
70#include "RootCnvSvc/EvtRec/EvtRecTrackCnv.h"
71#include "RootCnvSvc/EvtRec/EvtRecVeeVertexCnv.h"
72#include "RootCnvSvc/Rec/RecZddChannelCnv.h"
74#include "RootCnvSvc/Trig/TrigCnv.h"
75#include "RootCnvSvc/Trig/TrigDataCnv.h"
77#include "RootCnvSvc/Hlt/DstHltInfCnv.h"
78#include "RootCnvSvc/Hlt/HltCnv.h"
79#include "RootCnvSvc/Hlt/HltInfCnv.h"
80#include "RootCnvSvc/Hlt/HltRawCnv.h"
82#include "RootCnvSvc/EvtHeaderCnv.h"
83#include "RootCnvSvc/EvtNavigatorCnv.h"
90static const char* rcsid =
"$Id: RootCnvSvc.cxx,v 1.74 2022/02/21 22:04:49 maqm Exp $";
100 : base_class( name, svc,
ROOT_StorageType ), m_minSplit( 1 ), m_evtsel( 0 ) {
103 declareProperty(
"digiTreeName", m_dtreeName =
"Event" );
105 declareProperty(
"digiRootInputFile", m_difileName );
106 declareProperty(
"digiRootOutputFile", m_dofileName =
"" );
109 declareProperty(
"digiSplitMode", m_dsplitMode = m_minSplit );
111 declareProperty(
"digiBufferSize", m_dbufSize = 3200000 );
113 declareProperty(
"digiCompressionLevel", m_dcompressionLevel = 1 );
114 declareProperty(
"selectFromTag", m_selectFromTag = 0 );
115 declareProperty(
"tagInputFile", m_tagInputFile );
118 declareProperty(
"readETS", m_readETS =
false );
127 MsgStream log(
msgSvc(), name() );
130 log << MSG::DEBUG <<
"RootCnvSvc::initialize" << endmsg;
133 sc = serviceLocator()->getService(
"RootEvtSelector", isvc,
false );
134 if ( !sc.isSuccess() ) sc = serviceLocator()->getService(
"EventSelector", isvc,
false );
135 if ( sc.isSuccess() )
136 { sc = isvc->queryInterface( IID_IRootEvtSelector, (
void**)&m_evtsel ); }
137 if ( sc.isFailure() )
139 log << MSG::WARNING <<
"Unable to start event selector service within RootCnvSvc"
144 if ( !m_rootInterface )
145 log << MSG::ERROR <<
"Unable to start Root service within RootCnvSvc" << endmsg;
147 StatusCode status = ConversionSvc::initialize();
148 if ( status.isSuccess() )
151 IDataProviderSvc* pIDP = 0;
153 status = service(
"EventDataSvc", pIDP,
true );
154 if ( status.isSuccess() ) { status = setDataProvider( pIDP ); }
155 else {
return status; }
158 status = addConverters();
159 if ( !status.isSuccess() )
161 log << MSG::ERROR <<
"Unable to add converters to the service" << endmsg;
168 for ( LeafMap::iterator k = m_leaves.begin(); k != m_leaves.end(); k++ )
170 std::string path = ( *k ).first;
171 for ( LeafMap::iterator j = m_leaves.begin(); j != m_leaves.end(); j++ )
173 std::string path2 = ( *j ).first;
174 std::string pp = ( *j ).first.substr( 0, ( *j ).first.rfind(
"/" ) );
175 if ( path == pp && path != ( *j ).first )
176 { ( *k ).second->push_back( ( *j ).second ); }
182 status = initFiles();
184 m_rootInterface->setSelectFromTag( m_selectFromTag );
185 if ( m_selectFromTag && m_tagInputFile.empty() ) { m_tagInputFile = m_difileName; }
186 m_rootInterface->setTagInputFile( m_tagInputFile );
193 MsgStream log(
msgSvc(), name() );
194 log << MSG::DEBUG <<
"RootCnvSvc::finalize" << endmsg;
196 ConversionSvc::finalize();
198 for ( LeafMap::iterator k = m_leaves.begin(); k != m_leaves.end(); k++ )
199 {
delete ( *k ).second; }
200 m_leaves.erase( m_leaves.begin(), m_leaves.end() );
202 return m_rootInterface->finalize();
205StatusCode RootCnvSvc::initFiles() {
206 MsgStream log(
msgSvc(), name() );
207 log << MSG::DEBUG <<
"RootCnvSvc::initFiles" << endmsg;
208 StatusCode sc = StatusCode::SUCCESS;
215 int nSize = m_difileName.size();
216 log << MSG::INFO <<
"Root Input files " << nSize << endmsg;
219 log << MSG::INFO <<
"Unable to find input file" << endmsg;
223 for (
int i = 0; i < nSize; i++ )
263 if ( !filesystem::is_regular_file( m_difileName[i] ) )
265 error() <<
"Input file does not exist: " << m_difileName[i] << endmsg;
266 return StatusCode::FAILURE;
269 sc = m_rootInterface->addInput( m_dtreeName, m_difileName[i] );
270 if ( sc.isFailure() )
return sc;
284 if ( m_dsplitMode < m_minSplit )
286 log << MSG::WARNING <<
"RootCnvSvc::initFiles Recon splitlevel cant be lower than "
287 << m_minSplit <<
", reset" << endmsg;
288 m_dsplitMode = m_minSplit;
291 if (
"" != m_dofileName )
293 sc = m_rootInterface->addOutput( m_dtreeName, m_dofileName, m_dsplitMode, m_dbufSize,
294 m_dcompressionLevel );
296 else { log << MSG::WARNING <<
"No specified digiRootOutputFile!" << endmsg; }
304 MsgStream log(
msgSvc(), name() );
305 log << MSG::DEBUG <<
"RootCnvSvc::declareObject " << leaf.
path <<
" classid: " << leaf.
clid
308 std::pair<LeafMap::iterator, bool> p =
309 m_leaves.insert( LeafMap::value_type( leaf.
path, ll ) );
310 if ( p.second ) {
return StatusCode::SUCCESS; }
312 return StatusCode::FAILURE;
319 MsgStream log(
msgSvc(), name() );
321 log << MSG::DEBUG <<
"RootCnvSvc::updateServiceState" << endmsg;
323 StatusCode status = StatusCode::FAILURE;
324 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() )
334 Leaf* leaf = ( *itm ).second;
337 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 };
347 log << MSG::DEBUG <<
"RootCnvSvc::updateService "
348 <<
" ***** " << ( *il )->clid <<
" ***** " << ( *il )->path << endmsg;
350 if ( ir.isSuccess() )
352 ir = iaddrReg->registerAddress( ( *il )->path, newAddr );
353 if ( !ir.isSuccess() )
363 return StatusCode::SUCCESS;
379 const std::string* spars,
const unsigned long* ipars,
380 IOpaqueAddress*& refpAddress ) {
381 MsgStream log(
msgSvc(), name() );
383 if ( svc_type != repSvcType() )
385 log << MSG::ERROR <<
"RootCnvSvc::bad storage type" << svc_type << endmsg;
386 return StatusCode::FAILURE;
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";
395 return StatusCode::SUCCESS;
400 MsgStream log(
msgSvc(), name() );
401 log << MSG::INFO <<
"RootCnvSvc::commitOutput starts." << endmsg;
403 StatusCode sc = m_rootInterface->fillTrees();
404 if ( sc.isFailure() ) log << MSG::ERROR <<
"No Root tree was filled" << endmsg;
409 TObject* oEvtHeader = m_evtheaderCnv->getWriteObject();
410 if ( oEvtHeader ) oEvtHeader->Clear();
411 TObject* oEvtNavigator = m_evtnavigatorCnv->getWriteObject();
412 if ( oEvtNavigator ) oEvtNavigator->Clear();
413 TObject* o = m_dCnv->getWriteObject();
415 TObject* oDst = m_dstCnv->getWriteObject();
416 if ( oDst ) oDst->Clear();
417 TObject* oMc = m_mcCnv->getWriteObject();
418 if ( oMc ) oMc->Clear();
419 TObject* oRecTrack = m_rectrackCnv->getWriteObject();
420 if ( oRecTrack ) oRecTrack->Clear();
421 TObject* oEvtRecEvent = m_evtRecCnv->getWriteObject();
422 if ( oEvtRecEvent ) oEvtRecEvent->Clear();
423 TObject* oTrig = m_trigCnv->getWriteObject();
424 if ( oTrig ) oTrig->Clear();
425 TObject* oHlt = m_hltCnv->getWriteObject();
426 if ( oHlt ) oHlt->Clear();
436 MsgStream log(
msgSvc(), name() );
438 log << MSG::DEBUG <<
"RootCnvSvc::createAddress" << endmsg;
440 StatusCode status = StatusCode::FAILURE;
441 IRegistry* ent = obj->registry();
445 SmartIF<IDataManagerSvc> iaddrReg( dataProvider() );
446 std::string path = ent->identifier();
447 LeafMap::iterator itm = m_leaves.find( path );
449 if ( itm != m_leaves.end() )
451 Leaf* leaf = ( *itm ).second;
454 std::string spars[3];
459 unsigned long ipars[2] = { 0, 0 };
460 if ( m_evtsel ) ipars[0] = m_evtsel->getRecId();
464 if ( status.isSuccess() )
466 status = iaddrReg->registerAddress( (IRegistry*)0, path, newAddr );
467 if ( !status.isSuccess() ) { newAddr->release(); }
469 return StatusCode::SUCCESS;
472 else { log << MSG::ERROR <<
"Leaf not found for path: " << path << endmsg; }
480 MsgStream log(
msgSvc(), name() );
483 LeafMap::iterator itm = m_leaves.find( path );
484 SmartIF<IDataManagerSvc> iaddrReg( dataProvider() );
485 if ( itm != m_leaves.end() )
487 Leaf* leaf = ( *itm ).second;
490 std::string spars[3];
495 unsigned long ipars[2] = { 0, 0 };
496 if ( m_evtsel ) ipars[0] = m_evtsel->getRecId();
499 if ( status.isSuccess() )
501 status = iaddrReg->registerAddress( (IRegistry*)0, path, newAddr );
502 if ( !status.isSuccess() ) { newAddr->release(); }
504 return StatusCode::SUCCESS;
508 return StatusCode::FAILURE;
512StatusCode RootCnvSvc::addConverters() {
513 MsgStream log(
msgSvc(), name() );
529 "m_runId:m_eventId:m_time:m_eventTag:m_flag1:m_flag2:m_etsT1:m_etsT2" ) );
534 "m_runId:m_eventId:m_time:m_eventTag:m_flag1:m_flag2" ) );
537 "m_mcMdcMcHits:m_mcMdcTracks:m_mcEmcMcHits:m_mcEmcRecShowers" ) );
542 "m_mcParticleCol" ) );
546 "m_mdcKalTrackCol" ) );
583 "m_recMdcTrackCol" ) );
585 "m_recMdcHitCol" ) );
587 "Event",
"m_recMdcKalTrackCol" ) );
591 "m_recMdcDedxCol" ) );
593 "Event",
"m_recMdcDedxHitCol" ) );
596 "m_recEvTimeCol" ) );
598 "m_recTofTrackCol" ) );
600 "Event",
"m_recBTofCalHitCol" ) );
602 "Event",
"m_recETofCalHitCol" ) );
604 "m_recEmcHitCol" ) );
606 "Event",
"m_recEmcClusterCol" ) );
608 "m_recEmcShowerCol" ) );
610 "m_recMucTrackCol" ) );
612 "m_recMucHitCol" ) );
614 "m_recExtTrackCol" ) );
616 "Event",
"m_recZddChannelCol" ) );
621 "m_evtRecTrackCol" ) );
625 "Event",
"m_evtRecVeeVertexCol" ) );
627 "m_evtRecPi0Col" ) );
629 "Event",
"m_evtRecEtaToGGCol" ) );
631 "m_evtRecDTagCol" ) );
633 return StatusCode::SUCCESS;
637 const ICnvFactory* fac ) {
714 return ConversionSvc::createConverter( typ, wanted, fac );
DECLARE_COMPONENT(BesBdkRc)
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
Concrete converter for the Rec branch.
static const CLID & classID()
Concrete converter for the Dst branch.
static const CLID & classID()
Concrete converter for the DstHltInf.
static const CLID & classID()
Concrete converter for the EmcDigi collection.
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
Concrete converter for the Event header stored in the TDS /Event Based on the EventCnv of GLAST.
static const CLID & classID()
Concrete converter for the EvtNavigator branch.
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()
Concrete converter for the Rec branch.
static const CLID & classID()
Concrete converter for the HltInf.
static const CLID & classID()
Concrete converter for the HltRaw collection.
static const CLID & classID()
static const CLID & classID()
Concrete converter for the Mc branch.
static const CLID & classID()
Concrete converter for the McParticle collection.
static const CLID & classID()
static const CLID & classID()
Concrete converter for the MdcDigi collection.
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()
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).
IConverter * createConverter(long typ, const CLID &wanted, const ICnvFactory *fac) override
RootCnvSvc(const std::string &name, ISvcLocator *svc)
virtual StatusCode declareObject(const Leaf &leaf)
Override inherited queryInterface due to enhanced interface.
virtual StatusCode finalize()
static RootInterface * Instance(const std::string &name)
singleton behaviour
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
Concrete converter for the Rec branch.
static const CLID & classID()
Concrete converter for the TrigData.
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