BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
RawDataCnvSvc Class Reference

#include <RawDataCnvSvc.h>

Inheritance diagram for RawDataCnvSvc:

Public Member Functions

 RawDataCnvSvc (const std::string &name, ISvcLocator *svc)
StatusCode initialize ()
StatusCode finalize ()
StatusCode declareObject (const IRawDataCnvSvc::Leaf &leaf)
 Associates a path on TDS with a particular converter.
StatusCode createAddress (long svc_type, const CLID &clid, const std::string *par, const unsigned long *ip, IOpaqueAddress *&refpAddress)
 Override inherited queryInterface due to enhanced interface.
StatusCode createAddress (long storageType, const CLID &clid, const std::string &, IOpaqueAddress *&refpAddress)
StatusCode addConverters ()
 Add converters to the service.
StatusCode connectOutput (const std::string &t)
StatusCode connectOutput (const std::string &t, const std::string &)
StatusCode commitOutput (const std::string &t, bool b)
WriteRawEvent *& getRawEvent ()
IConverter * createConverter (long typ, const CLID &clid, const ICnvFactory *fac)
StatusCode updateServiceState (IOpaqueAddress *pAddress)

Detailed Description

Definition at line 8 of file RawDataCnvSvc.h.

Constructor & Destructor Documentation

◆ RawDataCnvSvc()

RawDataCnvSvc::RawDataCnvSvc ( const std::string & name,
ISvcLocator * svc )

Definition at line 35 of file RawDataCnvSvc.cxx.

36 : base_class( name, svc, PACKEDRAWEVENT_StorageType ) {
37 declareProperty( "RawDataOutputSvc", m_ioSvcName );
38 declareProperty( "Status", m_status = 0xFFFFFFFF ); // fucd
39}

Member Function Documentation

◆ addConverters()

StatusCode RawDataCnvSvc::addConverters ( )

Add converters to the service.

Definition at line 99 of file RawDataCnvSvc.cxx.

99 {
100 MsgStream log( msgSvc(), name() );
101 // log << MSG::INFO << name() << " PackedRawDataCnvSvc::addConverters" << endmsg;
103 IRawDataCnvSvc::Leaf( EventModel::EventH, RawDataCnv::classID(), "PASS", 0 ) );
104 // log << MSG::INFO << "EventModel::EventH " << RawDataCnv::classID() << endmsg;
105 declareObject( IRawDataCnvSvc::Leaf( EventModel::EventHeader, RawDataEvtHeaderCnv::classID(),
106 "PASS", 0 ) );
107 // log << MSG::INFO << "EventModel::EventHeader " << RawDataEvtHeaderCnv::classID() <<
108 // endmsg;
110 IRawDataCnvSvc::Leaf( EventModel::MC::Event, RawDataMcCnv::classID(), "PASS", 0 ) );
111 declareObject( IRawDataCnvSvc::Leaf( EventModel::MC::McParticleCol,
112 RawDataMcParticleCnv::classID(), "PASS", 0 ) );
113 declareObject( IRawDataCnvSvc::Leaf( EventModel::MC::MdcMcHitCol,
114 RawDataMdcMcHitCnv::classID(), "PASS", 0 ) );
115 declareObject( IRawDataCnvSvc::Leaf( EventModel::MC::TofMcHitCol,
116 RawDataTofMcHitCnv::classID(), "PASS", 0 ) );
117 declareObject( IRawDataCnvSvc::Leaf( EventModel::MC::EmcMcHitCol,
118 RawDataEmcMcHitCnv::classID(), "PASS", 0 ) );
119 declareObject( IRawDataCnvSvc::Leaf( EventModel::MC::MucMcHitCol,
120 RawDataMucMcHitCnv::classID(), "PASS", 0 ) );
122 IRawDataCnvSvc::Leaf( EventModel::Digi::Event, RawDataDigiCnv::classID(), "PASS", 0 ) );
123 declareObject( IRawDataCnvSvc::Leaf( EventModel::Digi::MdcDigiCol,
124 RawDataMdcDigiCnv::classID(), "PASS", 0 ) );
125 declareObject( IRawDataCnvSvc::Leaf( EventModel::Digi::TofDigiCol,
126 RawDataTofDigiCnv::classID(), "PASS", 0 ) );
127 declareObject( IRawDataCnvSvc::Leaf( EventModel::Digi::LumiDigiCol,
128 RawDataLumiDigiCnv::classID(), "PASS", 0 ) );
129 declareObject( IRawDataCnvSvc::Leaf( EventModel::Digi::EmcDigiCol,
130 RawDataEmcDigiCnv::classID(), "PASS", 0 ) );
131 declareObject( IRawDataCnvSvc::Leaf( EventModel::Digi::MucDigiCol,
132 RawDataMucDigiCnv::classID(), "PASS", 0 ) );
134 IRawDataCnvSvc::Leaf( EventModel::Trig::Event, RawDataTrigCnv::classID(), "PASS", 0 ) );
135 declareObject( IRawDataCnvSvc::Leaf( EventModel::Trig::TrigGTDCol,
136 RawDataTrigGTDCnv::classID(), "PASS", 0 ) );
138 IRawDataCnvSvc::Leaf( EventModel::Hlt::Event, RawDataHltCnv::classID(), "PASS", 0 ) );
140 "PASS", 0 ) );
141 declareObject( IRawDataCnvSvc::Leaf( EventModel::Zdd::ZddEvent,
142 RawDataZddEventCnv::classID(), "PASS", 0 ) );
143
144 return StatusCode::SUCCESS;
145}
IMessageSvc * msgSvc()
StatusCode declareObject(const IRawDataCnvSvc::Leaf &leaf)
Associates a path on TDS with a particular converter.
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()

Referenced by initialize().

◆ commitOutput()

StatusCode RawDataCnvSvc::commitOutput ( const std::string & t,
bool b )

Definition at line 178 of file RawDataCnvSvc.cxx.

178 {
179 MsgStream log( msgSvc(), name() );
180
181 log << MSG::DEBUG << "In flushOutput" << endmsg;
182
183 if ( !m_ioSvc )
184 {
185 log << MSG::ERROR << "RawDataCnvSvc not configure for output" << endmsg;
186 return StatusCode::FAILURE;
187 }
188
189 log << MSG::DEBUG << "commitOutput: Size of Event (words) =" << m_rawEvent->size_word()
190 << endmsg;
191
192 if ( !m_ioSvc->putEvent( m_rawEvent ) )
193 {
194 log << MSG::ERROR << "commitOutput failed to send output" << endmsg;
195 return StatusCode::FAILURE;
196 }
197
198 // delete ...
199 const eformat::write::SubDetectorFragment* sd = m_rawEvent->first_child();
200 while ( sd != 0 )
201 {
202 const eformat::write::ROSFragment* ros = sd->first_child();
203 while ( ros != 0 )
204 {
205 const eformat::write::ROBFragment* rob = ros->first_child();
206 while ( rob != 0 )
207 {
208 const eformat::write::ROBFragment* rob_tmp = rob;
209 rob = rob->next();
210 delete rob_tmp;
211 }
212 const eformat::write::ROSFragment* ros_tmp = ros;
213 ros = ros->next();
214 delete ros_tmp;
215 }
216 const eformat::write::SubDetectorFragment* sd_tmp = sd;
217 sd = sd->next();
218 delete sd_tmp;
219 }
220 delete m_rawEvent;
221
222 return StatusCode::SUCCESS;
223}

◆ connectOutput() [1/2]

StatusCode RawDataCnvSvc::connectOutput ( const std::string & t)

Definition at line 147 of file RawDataCnvSvc.cxx.

147 {
148
149 MsgStream log( msgSvc(), name() );
150
151 log << MSG::DEBUG << " In connectOutput " << endmsg;
152
153 // Get DataObj from TDS
154 SmartDataPtr<Event::EventHeader> evt( dataProvider(), EventModel::EventHeader );
155 if ( !evt )
156 {
157 log << MSG::ERROR << "Did not retrieve event" << endmsg;
158 return StatusCode::FAILURE;
159 }
160 unsigned int eventNo = evt->eventNumber();
161 unsigned int runNo = evt->runNumber();
162
163 m_rawEvent = new WriteRawEvent( 0x790000, // source_id
164 eventNo, // global_id
165 runNo, // run_no
166 eventNo, // lel1_id
167 0, // lel1_type
168 0, // lel2_info
169 ef_info // ef_info
170 );
171 // const unsigned int status = 0; // place holder for status
172 if ( m_status != 0xFFFFFFFF ) m_rawEvent->status( 1, &m_status );
173 else m_rawEvent->status( 0, NULL ); // fucd
174
175 return StatusCode::SUCCESS;
176}
int runNo
Definition DQA_TO_DB.cxx:13
eformat::write::FullEventFragment WriteRawEvent
int eventNo

Referenced by connectOutput().

◆ connectOutput() [2/2]

StatusCode RawDataCnvSvc::connectOutput ( const std::string & t,
const std::string &  )
inline

Definition at line 38 of file RawDataCnvSvc.h.

38 {
39 return connectOutput( t );
40 }
StatusCode connectOutput(const std::string &t)
int t()
Definition t.c:1

◆ createAddress() [1/2]

StatusCode RawDataCnvSvc::createAddress ( long storageType,
const CLID & clid,
const std::string & ,
IOpaqueAddress *& refpAddress )

Definition at line 344 of file RawDataCnvSvc.cxx.

345 {
346 return createAddress( storageType, clid, nullptr, nullptr, refpAddress );
347}
StatusCode createAddress(long svc_type, const CLID &clid, const std::string *par, const unsigned long *ip, IOpaqueAddress *&refpAddress)
Override inherited queryInterface due to enhanced interface.

◆ createAddress() [2/2]

StatusCode RawDataCnvSvc::createAddress ( long svc_type,
const CLID & clid,
const std::string * par,
const unsigned long * ip,
IOpaqueAddress *& refpAddress )

Override inherited queryInterface due to enhanced interface.

Definition at line 328 of file RawDataCnvSvc.cxx.

330 {
331 MsgStream log( msgSvc(), name() );
332
333 if ( storageType != repSvcType() )
334 {
335 log << MSG::ERROR << "bad storage type" << storageType << endmsg;
336 return StatusCode::FAILURE;
337 }
338
339 refpAddress = new GenericAddress( storageType, clid, "", "", 0 );
340
341 return StatusCode::SUCCESS;
342}

Referenced by createAddress(), and updateServiceState().

◆ createConverter()

IConverter * RawDataCnvSvc::createConverter ( long typ,
const CLID & clid,
const ICnvFactory * fac )

Definition at line 225 of file RawDataCnvSvc.cxx.

226 {
227 if ( wanted == RawDataCnv::classID() ) return new RawDataCnv( Gaudi::svcLocator() );
228 if ( wanted == RawDataDigiCnv::classID() ) return new RawDataDigiCnv( Gaudi::svcLocator() );
229 if ( wanted == RawDataEmcDigiCnv::classID() )
230 return new RawDataEmcDigiCnv( Gaudi::svcLocator() );
231 if ( wanted == RawDataEmcMcHitCnv::classID() )
232 return new RawDataEmcMcHitCnv( Gaudi::svcLocator() );
233 if ( wanted == RawDataEvtHeaderCnv::classID() )
234 return new RawDataEvtHeaderCnv( Gaudi::svcLocator() );
235 if ( wanted == RawDataHltCnv::classID() ) return new RawDataHltCnv( Gaudi::svcLocator() );
236 if ( wanted == RawDataHltRawCnv::classID() )
237 return new RawDataHltRawCnv( Gaudi::svcLocator() );
238 if ( wanted == RawDataLumiDigiCnv::classID() )
239 return new RawDataLumiDigiCnv( Gaudi::svcLocator() );
240 if ( wanted == RawDataMcCnv::classID() ) return new RawDataMcCnv( Gaudi::svcLocator() );
241 if ( wanted == RawDataMcParticleCnv::classID() )
242 return new RawDataMcParticleCnv( Gaudi::svcLocator() );
243 if ( wanted == RawDataMdcDigiCnv::classID() )
244 return new RawDataMdcDigiCnv( Gaudi::svcLocator() );
245 if ( wanted == RawDataMdcMcHitCnv::classID() )
246 return new RawDataMdcMcHitCnv( Gaudi::svcLocator() );
247 if ( wanted == RawDataMucDigiCnv::classID() )
248 return new RawDataMucDigiCnv( Gaudi::svcLocator() );
249 if ( wanted == RawDataMucMcHitCnv::classID() )
250 return new RawDataMucMcHitCnv( Gaudi::svcLocator() );
251 if ( wanted == RawDataTofDigiCnv::classID() )
252 return new RawDataTofDigiCnv( Gaudi::svcLocator() );
253 if ( wanted == RawDataTofMcHitCnv::classID() )
254 return new RawDataTofMcHitCnv( Gaudi::svcLocator() );
255 if ( wanted == RawDataTrigCnv::classID() ) return new RawDataTrigCnv( Gaudi::svcLocator() );
256 if ( wanted == RawDataTrigGTDCnv::classID() )
257 return new RawDataTrigGTDCnv( Gaudi::svcLocator() );
258 if ( wanted == RawDataZddEventCnv::classID() )
259 return new RawDataZddEventCnv( Gaudi::svcLocator() );
260 return ConversionSvc::createConverter( typ, wanted, fac );
261}

◆ declareObject()

StatusCode RawDataCnvSvc::declareObject ( const IRawDataCnvSvc::Leaf & leaf)

Associates a path on TDS with a particular converter.

Definition at line 271 of file RawDataCnvSvc.cxx.

271 {
272 // Purpose and Method: Callback from each of the individual converters that allows
273 // association of TDS path and converter.
274 Leaf* ll = new Leaf( leaf );
275 std::pair<LeafMap::iterator, bool> p =
276 m_leaves.insert( LeafMap::value_type( leaf.path, ll ) );
277 if ( p.second ) { return StatusCode::SUCCESS; }
278 delete ll;
279 return StatusCode::FAILURE;
280}

Referenced by addConverters().

◆ finalize()

StatusCode RawDataCnvSvc::finalize ( )

Definition at line 263 of file RawDataCnvSvc.cxx.

263 {
264 StatusCode status = ConversionSvc::finalize();
265 for ( LeafMap::iterator k = m_leaves.begin(); k != m_leaves.end(); k++ )
266 { delete ( *k ).second; }
267 m_leaves.erase( m_leaves.begin(), m_leaves.end() );
268 return status;
269}

◆ getRawEvent()

WriteRawEvent *& RawDataCnvSvc::getRawEvent ( )
inline

Definition at line 46 of file RawDataCnvSvc.h.

46{ return m_rawEvent; }

◆ initialize()

StatusCode RawDataCnvSvc::initialize ( )

Definition at line 41 of file RawDataCnvSvc.cxx.

41 {
42 StatusCode iret;
43 StatusCode sc = ConversionSvc::initialize();
44
45 if ( sc.isFailure() )
46 {
47 error() << "Unable to initialize ConversionSvc" << endmsg;
48 return sc;
49 }
50
51 IDataProviderSvc* pIDP = 0;
52 // Set event data service
53 sc = service( "EventDataSvc", pIDP, true );
54 if ( !sc.isSuccess() )
55 {
56 error() << "Unable to get EventDataSvc" << endmsg;
57 return sc;
58 }
59
60 sc = setDataProvider( pIDP );
61 if ( !sc.isSuccess() )
62 {
63 error() << "Unable to set DataProvider" << endmsg;
64 return sc;
65 }
66
67 // Add converters to the service
68 sc = addConverters();
69 if ( !sc.isSuccess() )
70 {
71 error() << "Unable to add converters to the service" << endmsg;
72 return sc;
73 }
74
75 // Now we have to configure the map of leaves
76 // Which should contain the association of converters with
77 // paths on the TDS
78 for ( LeafMap::iterator k = m_leaves.begin(); k != m_leaves.end(); k++ )
79 {
80 std::string path = ( *k ).first;
81 for ( LeafMap::iterator j = m_leaves.begin(); j != m_leaves.end(); j++ )
82 {
83 std::string pp = ( *j ).first.substr( 0, ( *j ).first.rfind( "/" ) );
84 if ( path == pp && path != ( *j ).first ) { ( *k ).second->push_back( ( *j ).second ); }
85 }
86 }
87
88 sc = service( m_ioSvcName, m_ioSvc );
89 if ( sc != StatusCode::SUCCESS )
90 {
91 warning() << "Cant get RawDataOutputSvc " << endmsg;
92 // return sc;
93 }
94
95 return StatusCode::SUCCESS;
96}
StatusCode addConverters()
Add converters to the service.

◆ updateServiceState()

StatusCode RawDataCnvSvc::updateServiceState ( IOpaqueAddress * pAddress)

Definition at line 282 of file RawDataCnvSvc.cxx.

282 {
283
284 // not sure about the use of recid or bank...
285 MsgStream log( msgSvc(), name() );
286 StatusCode status = Status::INVALID_ADDRESS;
287 IRegistry* ent = pAddress->registry();
288
289 if ( 0 != ent )
290 {
291 SmartIF<IDataManagerSvc> iaddrReg( dataProvider() );
292 // if ( 0 != iaddrReg ) {
293 status = StatusCode::SUCCESS;
294 std::string path = ent->identifier();
295
296 LeafMap::iterator itm = m_leaves.find( path );
297 if ( itm != m_leaves.end() )
298 {
299 IRawDataCnvSvc::Leaf* leaf = ( *itm ).second;
300 if ( 0 != leaf )
301 {
302 // ipar[0] = leaf->userParameter;
303 for ( Leaf::iterator il = leaf->begin(); il != leaf->end(); il++ )
304 {
305 IOpaqueAddress* newAddr = 0;
306 unsigned long ipars[2] = { 0, 0 }; //{(*il)->userParameter, new_rid};
307 const std::string spars[2] = { "", "" }; //{par[0], (*il)->bank};
308
309 StatusCode ir = createAddress( repSvcType(), ( *il )->clid, spars, ipars, newAddr );
310 if ( ir.isSuccess() )
311 {
312 ir = iaddrReg->registerAddress( ( *il )->path, newAddr );
313 if ( !ir.isSuccess() )
314 {
315 newAddr->release();
316 status = ir;
317 }
318 }
319 }
320 }
321 }
322 }
323 else { status = IInterface::Status::NO_INTERFACE; }
324
325 return status;
326}

The documentation for this class was generated from the following files: